You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by da...@apache.org on 2017/08/17 03:59:33 UTC
[16/43] incubator-weex git commit: - [jsfm] remove useless apis in
vanilla framework
- [jsfm] remove useless apis in vanilla framework
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/479d7701
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/479d7701
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/479d7701
Branch: refs/heads/0.16-dev
Commit: 479d770121f39be80e49e50974fd04e3c1e2a0a7
Parents: f3ebd62
Author: Hanks <zh...@gmail.com>
Authored: Tue Aug 8 11:47:58 2017 +0800
Committer: Hanks <zh...@gmail.com>
Committed: Tue Aug 8 11:47:58 2017 +0800
----------------------------------------------------------------------
html5/frameworks/vanilla/index.js | 15 +--
html5/render/native/setup.js | 2 +-
packages/weex-vanilla-framework/index.js | 135 ++++++++++++++++++++++
packages/weex-vanilla-framework/index.min.js | 1 +
packages/weex-vanilla-framework/package.json | 21 ++++
5 files changed, 161 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/479d7701/html5/frameworks/vanilla/index.js
----------------------------------------------------------------------
diff --git a/html5/frameworks/vanilla/index.js b/html5/frameworks/vanilla/index.js
index 5887f81..f3b4bc2 100644
--- a/html5/frameworks/vanilla/index.js
+++ b/html5/frameworks/vanilla/index.js
@@ -27,14 +27,6 @@ export function init (cfg) {
config.sendTasks = cfg.sendTasks
}
-export function registerComponents (components) {}
-
-export function registerModules (modules) {}
-
-export function registerMethods (apis) {}
-
-export function prepareInstance (id, options, data) {}
-
export function createInstance (id, code, options = {}, data = {}, serviceObjects = {}) {
const document = new config.Document(id, options.bundleUrl)
const callbacks = {}
@@ -59,8 +51,9 @@ export function createInstance (id, code, options = {}, data = {}, serviceObject
Document: config.Document,
Element: config.Element,
Comment: config.Comment,
- sendTasks: (...args) => config.sendTasks(id, ...args),
- options, document
+ sendTasks: tasks => config.sendTasks(id, tasks, -1),
+ options,
+ document
}, serviceObjects)
const globalKeys = []
@@ -79,8 +72,6 @@ export function createInstance (id, code, options = {}, data = {}, serviceObject
return instance
}
-export function refreshInstance (id, data) {}
-
export function destroyInstance (id) {
delete instanceMap[id]
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/479d7701/html5/render/native/setup.js
----------------------------------------------------------------------
diff --git a/html5/render/native/setup.js b/html5/render/native/setup.js
index 6033ab9..d7404cb 100644
--- a/html5/render/native/setup.js
+++ b/html5/render/native/setup.js
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+
import { subversion } from '../../../package.json'
import runtime from '../../runtime'
import services from '../../services/index'
@@ -55,4 +56,3 @@ export default function (frameworks) {
}
}
}
-
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/479d7701/packages/weex-vanilla-framework/index.js
----------------------------------------------------------------------
diff --git a/packages/weex-vanilla-framework/index.js b/packages/weex-vanilla-framework/index.js
new file mode 100644
index 0000000..a4b20cd
--- /dev/null
+++ b/packages/weex-vanilla-framework/index.js
@@ -0,0 +1,135 @@
+/* 'Weex Vanilla Framework 0.21.2, Build 2017-08-08 11:30. */
+
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.WeexVanillaFramework = global.WeexVanillaFramework || {})));
+}(this, (function (exports) { 'use strict';
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+var config = {};
+
+var instanceMap = {};
+
+function init (cfg) {
+ config.Document = cfg.Document;
+ config.Element = cfg.Element;
+ config.Comment = cfg.Comment;
+ config.sendTasks = cfg.sendTasks;
+}
+
+function createInstance (id, code, options, data, serviceObjects) {
+ if ( options === void 0 ) options = {};
+ if ( data === void 0 ) data = {};
+ if ( serviceObjects === void 0 ) serviceObjects = {};
+
+ var document = new config.Document(id, options.bundleUrl);
+ var callbacks = {};
+ var instance = { id: id, data: data, document: document, callbacks: callbacks };
+
+ var lastCallbackId = 0;
+ document.addCallback = function (func) {
+ lastCallbackId++;
+ callbacks[lastCallbackId] = func;
+ return lastCallbackId
+ };
+ document.handleCallback = function (funcId, data, ifLast) {
+ var callback = callbacks[funcId];
+ if (ifLast) {
+ delete callbacks[funcId];
+ }
+ return callback(data)
+ };
+ instanceMap[id] = instance;
+
+ var globalObjects = Object.assign({
+ Document: config.Document,
+ Element: config.Element,
+ Comment: config.Comment,
+ sendTasks: function (tasks) { return config.sendTasks(id, tasks, -1); },
+ options: options,
+ document: document
+ }, serviceObjects);
+
+ var globalKeys = [];
+ var globalValues = [];
+ for (var key in globalObjects) {
+ globalKeys.push(key);
+ globalValues.push(globalObjects[key]);
+ }
+ globalKeys.push(code);
+
+ var result = new (Function.prototype.bind.apply( Function, [ null ].concat( globalKeys) ));
+ result.apply(void 0, globalValues);
+
+ config.sendTasks(id, [{ module: 'dom', method: 'createFinish', args: [] }], -1);
+
+ return instance
+}
+
+function destroyInstance (id) {
+ delete instanceMap[id];
+}
+
+function getRoot (id) {
+ return instanceMap[id].document.body.toJSON()
+}
+
+function receiveTasks (id, tasks) {
+ var jsHandlers = {
+ fireEvent: function (id, ref, type, data, domChanges) {
+ var ref$1 = instanceMap[id];
+ var document = ref$1.document;
+ var el = document.getRef(ref);
+ return document.fireEvent(el, type, data, domChanges)
+ },
+
+ callback: function (id, funcId, data, ifLast) {
+ var ref = instanceMap[id];
+ var document = ref.document;
+ return document.handleCallback(funcId, data, ifLast)
+ }
+ };
+
+ var ref = instanceMap[id] || {};
+ var document = ref.document;
+ if (document && Array.isArray(tasks)) {
+ var results = [];
+ tasks.forEach(function (task) {
+ var handler = jsHandlers[task.method];
+ var args = [].concat( task.args );
+ if (typeof handler === 'function') {
+ args.unshift(id);
+ results.push(handler.apply(void 0, args));
+ }
+ });
+ return results
+ }
+}
+
+exports.init = init;
+exports.createInstance = createInstance;
+exports.destroyInstance = destroyInstance;
+exports.getRoot = getRoot;
+exports.receiveTasks = receiveTasks;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/479d7701/packages/weex-vanilla-framework/index.min.js
----------------------------------------------------------------------
diff --git a/packages/weex-vanilla-framework/index.min.js b/packages/weex-vanilla-framework/index.min.js
new file mode 100644
index 0000000..199508f
--- /dev/null
+++ b/packages/weex-vanilla-framework/index.min.js
@@ -0,0 +1 @@
+!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.WeexVanillaFramework=e.WeexVanillaFramework||{})}(this,function(e){"use strict";var n={},t={};e.init=function(e){n.Document=e.Document,n.Element=e.Element,n.Comment=e.Comment,n.sendTasks=e.sendTasks},e.createInstance=function(e,o,a,r,c){void 0===a&&(a={}),void 0===r&&(r={}),void 0===c&&(c={});var u=new n.Document(e,a.bundleUrl),i={},d={id:e,data:r,document:u,callbacks:i},s=0;u.addCallback=function(e){return s++,i[s]=e,s},u.handleCallback=function(e,n,t){var o=i[e];return t&&delete i[e],o(n)},t[e]=d;var l=Object.assign({Document:n.Document,Element:n.Element,Comment:n.Comment,sendTasks:function(t){return n.sendTasks(e,t,-1)},options:a,document:u},c),f=[],m=[];for(var p in l)f.push(p),m.push(l[p]);return f.push(o),(new(Function.prototype.bind.apply(Function,[null].concat(f)))).apply(void 0,m),n.sendTasks(e,[{module:"dom",method:"createFinish",ar
gs:[]}],-1),d},e.destroyInstance=function(e){delete t[e]},e.getRoot=function(e){return t[e].document.body.toJSON()},e.receiveTasks=function(e,n){var o={fireEvent:function(e,n,o,a,r){var c=t[e].document,u=c.getRef(n);return c.fireEvent(u,o,a,r)},callback:function(e,n,o,a){return t[e].document.handleCallback(n,o,a)}};if((t[e]||{}).document&&Array.isArray(n)){var a=[];return n.forEach(function(n){var t=o[n.method],r=[].concat(n.args);"function"==typeof t&&(r.unshift(e),a.push(t.apply(void 0,r)))}),a}},Object.defineProperty(e,"__esModule",{value:!0})});
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/479d7701/packages/weex-vanilla-framework/package.json
----------------------------------------------------------------------
diff --git a/packages/weex-vanilla-framework/package.json b/packages/weex-vanilla-framework/package.json
new file mode 100644
index 0000000..89eea8c
--- /dev/null
+++ b/packages/weex-vanilla-framework/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "weex-vanilla-framework",
+ "main": "index.js",
+ "description": "Weex Vanilla Framework",
+ "version": "0.21.2",
+ "engines": {
+ "node": ">=4"
+ },
+ "homepage": "https://github.com/apache/incubator-weex/",
+ "keywords": [
+ "weex",
+ "hybrid",
+ "mvvm",
+ "javascript"
+ ],
+ "license": "Apache-2.0",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/apache/incubator-weex.git"
+ }
+}