@byteluck-fe/model-driven-core-all 1.3.0-beta.25 → 1.5.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/getHackerControl.js +172 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/loadRemoteScripts.js +138 -0
- package/dist/esm/registerByteluckControls.js +88 -0
- package/dist/esm/registerCustomControls.js +152 -0
- package/dist/esm/upgradeCustomControlSchema.js +60 -0
- package/dist/index.umd.js +1 -0
- package/dist/types/getHackerControl.d.ts +21 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/loadRemoteScripts.d.ts +7 -0
- package/dist/types/registerByteluckControls.d.ts +6 -0
- package/dist/types/registerCustomControls.d.ts +22 -0
- package/dist/types/upgradeCustomControlSchema.d.ts +2 -0
- package/package.json +7 -7
- package/src/index.ts +0 -9
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
function _assertThisInitialized(self) {
|
|
2
|
+
if (self === void 0) {
|
|
3
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
|
+
}
|
|
5
|
+
return self;
|
|
6
|
+
}
|
|
7
|
+
function _classCallCheck(instance, Constructor) {
|
|
8
|
+
if (!(instance instanceof Constructor)) {
|
|
9
|
+
throw new TypeError("Cannot call a class as a function");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function _defineProperties(target, props) {
|
|
13
|
+
for(var i = 0; i < props.length; i++){
|
|
14
|
+
var descriptor = props[i];
|
|
15
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
16
|
+
descriptor.configurable = true;
|
|
17
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
18
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
22
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
23
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
24
|
+
return Constructor;
|
|
25
|
+
}
|
|
26
|
+
function _getPrototypeOf(o) {
|
|
27
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
28
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
29
|
+
};
|
|
30
|
+
return _getPrototypeOf(o);
|
|
31
|
+
}
|
|
32
|
+
function _inherits(subClass, superClass) {
|
|
33
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
34
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
35
|
+
}
|
|
36
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
37
|
+
constructor: {
|
|
38
|
+
value: subClass,
|
|
39
|
+
writable: true,
|
|
40
|
+
configurable: true
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
44
|
+
}
|
|
45
|
+
function _possibleConstructorReturn(self, call) {
|
|
46
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
47
|
+
return call;
|
|
48
|
+
}
|
|
49
|
+
return _assertThisInitialized(self);
|
|
50
|
+
}
|
|
51
|
+
function _setPrototypeOf(o, p) {
|
|
52
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
53
|
+
o.__proto__ = p;
|
|
54
|
+
return o;
|
|
55
|
+
};
|
|
56
|
+
return _setPrototypeOf(o, p);
|
|
57
|
+
}
|
|
58
|
+
var _typeof = function(obj) {
|
|
59
|
+
"@swc/helpers - typeof";
|
|
60
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
61
|
+
};
|
|
62
|
+
function _isNativeReflectConstruct() {
|
|
63
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
64
|
+
if (Reflect.construct.sham) return false;
|
|
65
|
+
if (typeof Proxy === "function") return true;
|
|
66
|
+
try {
|
|
67
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
68
|
+
return true;
|
|
69
|
+
} catch (e) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function _createSuper(Derived) {
|
|
74
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
75
|
+
return function _createSuperInternal() {
|
|
76
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
77
|
+
if (hasNativeReflectConstruct) {
|
|
78
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
79
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
80
|
+
} else {
|
|
81
|
+
result = Super.apply(this, arguments);
|
|
82
|
+
}
|
|
83
|
+
return _possibleConstructorReturn(this, result);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
import { RuntimeControl } from "@byteluck-fe/model-driven-core";
|
|
87
|
+
import { DesignerControl } from "@byteluck-fe/model-driven-core";
|
|
88
|
+
import { Property } from "@byteluck-fe/model-driven-core";
|
|
89
|
+
export function getHackerControl(comid, type, tipMessage) {
|
|
90
|
+
var HackerControlClass;
|
|
91
|
+
// 伪造一个组件
|
|
92
|
+
if (type === "runtime") {
|
|
93
|
+
HackerControlClass = /*#__PURE__*/ function(RuntimeControl) {
|
|
94
|
+
"use strict";
|
|
95
|
+
_inherits(HackerControl, RuntimeControl);
|
|
96
|
+
var _super = _createSuper(HackerControl);
|
|
97
|
+
function HackerControl(props) {
|
|
98
|
+
_classCallCheck(this, HackerControl);
|
|
99
|
+
var _this;
|
|
100
|
+
_this = _super.call(this, props);
|
|
101
|
+
_this.props = {};
|
|
102
|
+
return _this;
|
|
103
|
+
}
|
|
104
|
+
_createClass(HackerControl, null, [
|
|
105
|
+
{
|
|
106
|
+
key: "controlType",
|
|
107
|
+
get: function get() {
|
|
108
|
+
return comid;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]);
|
|
112
|
+
return HackerControl;
|
|
113
|
+
}(RuntimeControl);
|
|
114
|
+
} else {
|
|
115
|
+
HackerControlClass = /*#__PURE__*/ function(DesignerControl) {
|
|
116
|
+
"use strict";
|
|
117
|
+
_inherits(HackerControl, DesignerControl);
|
|
118
|
+
var _super = _createSuper(HackerControl);
|
|
119
|
+
function HackerControl(props) {
|
|
120
|
+
_classCallCheck(this, HackerControl);
|
|
121
|
+
var _this;
|
|
122
|
+
_this = _super.call(this, props);
|
|
123
|
+
_this.props = {};
|
|
124
|
+
return _this;
|
|
125
|
+
}
|
|
126
|
+
_createClass(HackerControl, null, [
|
|
127
|
+
{
|
|
128
|
+
key: "controlType",
|
|
129
|
+
get: function get() {
|
|
130
|
+
return comid;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
]);
|
|
134
|
+
return HackerControl;
|
|
135
|
+
}(DesignerControl);
|
|
136
|
+
}
|
|
137
|
+
var HackerPropertyClass = /*#__PURE__*/ function(Property) {
|
|
138
|
+
"use strict";
|
|
139
|
+
_inherits(HackerPropertyClass, Property);
|
|
140
|
+
var _super = _createSuper(HackerPropertyClass);
|
|
141
|
+
function HackerPropertyClass() {
|
|
142
|
+
_classCallCheck(this, HackerPropertyClass);
|
|
143
|
+
return _super.apply(this, arguments);
|
|
144
|
+
}
|
|
145
|
+
return HackerPropertyClass;
|
|
146
|
+
}(Property);
|
|
147
|
+
var template = '<div style="background:#fff0ef;color:#ff6459;padding:8px 16px;border-radius:4px;"><i class="iconfont iconshibaimian" style="margin-right:4px"></i>'.concat(tipMessage, "</di>");
|
|
148
|
+
var control = {
|
|
149
|
+
Runtime: HackerControlClass,
|
|
150
|
+
Designer: HackerControlClass,
|
|
151
|
+
Property: HackerPropertyClass,
|
|
152
|
+
Setting: [],
|
|
153
|
+
Views: {
|
|
154
|
+
Desktop: {
|
|
155
|
+
template: template
|
|
156
|
+
},
|
|
157
|
+
Mobile: {
|
|
158
|
+
template: template
|
|
159
|
+
},
|
|
160
|
+
Designer: {
|
|
161
|
+
template: template
|
|
162
|
+
},
|
|
163
|
+
Settings: {
|
|
164
|
+
template: template
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
upgrade: function(schema) {
|
|
168
|
+
return schema;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
return control;
|
|
172
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "@byteluck-fe/model-driven-core";
|
|
2
|
+
export * from "@byteluck-fe/model-driven-shared";
|
|
3
|
+
export * from "@byteluck-fe/model-driven-controls";
|
|
4
|
+
export * from "@byteluck-fe/model-driven-upgrade";
|
|
5
|
+
export * from "./loadRemoteScripts";
|
|
6
|
+
export * from "./registerCustomControls";
|
|
7
|
+
export * from "./upgradeCustomControlSchema";
|
|
8
|
+
export * from "./registerByteluckControls";
|
|
9
|
+
export * from "./getHackerControl";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _asyncToGenerator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
import regeneratorRuntime from "regenerator-runtime";
|
|
31
|
+
var jobs = [];
|
|
32
|
+
var module = {
|
|
33
|
+
exports: {}
|
|
34
|
+
};
|
|
35
|
+
var hacked = false;
|
|
36
|
+
var beforeModule = window.module, beforeExports = window.exports, beforeRequire = window.require;
|
|
37
|
+
function hackWindow(globalModules) {
|
|
38
|
+
if (!hacked) {
|
|
39
|
+
window.module = module;
|
|
40
|
+
window.exports = module.exports;
|
|
41
|
+
window.require = function(module) {
|
|
42
|
+
return globalModules[module];
|
|
43
|
+
};
|
|
44
|
+
hacked = true;
|
|
45
|
+
}
|
|
46
|
+
return function resetHackWindow() {
|
|
47
|
+
window.module = beforeModule;
|
|
48
|
+
window.exports = beforeExports;
|
|
49
|
+
window.require = beforeRequire;
|
|
50
|
+
hacked = false;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function loadScriptFromTag(url, globalModules) {
|
|
54
|
+
var p = new Promise(function(resolve, reject) {
|
|
55
|
+
var script = document.createElement("script");
|
|
56
|
+
var resetHackWindow = hackWindow(globalModules);
|
|
57
|
+
script.src = url;
|
|
58
|
+
script.type = "text/javascript";
|
|
59
|
+
var loadEnd = function() {
|
|
60
|
+
document.head.removeChild(script);
|
|
61
|
+
var index = jobs.findIndex(function(j) {
|
|
62
|
+
return j === p;
|
|
63
|
+
});
|
|
64
|
+
jobs.splice(index, 1);
|
|
65
|
+
if (jobs.length === 0) {
|
|
66
|
+
resetHackWindow();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
script.onerror = function(e) {
|
|
70
|
+
loadEnd();
|
|
71
|
+
reject(e);
|
|
72
|
+
};
|
|
73
|
+
script.onload = function() {
|
|
74
|
+
resolve(module.exports);
|
|
75
|
+
loadEnd();
|
|
76
|
+
};
|
|
77
|
+
document.head.appendChild(script);
|
|
78
|
+
});
|
|
79
|
+
jobs.push(p);
|
|
80
|
+
return p;
|
|
81
|
+
}
|
|
82
|
+
export function nativeFetch(url) {
|
|
83
|
+
return fetch(url, {
|
|
84
|
+
mode: "cors",
|
|
85
|
+
cache: "no-cache",
|
|
86
|
+
credentials: "same-origin"
|
|
87
|
+
}).then(function(response) {
|
|
88
|
+
if (response.ok === false) {
|
|
89
|
+
throw "not found resource:" + url;
|
|
90
|
+
} else {
|
|
91
|
+
return response.text();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
export function loadScriptFromFetch(url, globalModules) {
|
|
96
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
|
|
97
|
+
fetch: nativeFetch
|
|
98
|
+
};
|
|
99
|
+
return new Promise(function(resolve, reject) {
|
|
100
|
+
var newUrl = url.replace(/^(https?:)?\/\/.*?\/component/, "/component");
|
|
101
|
+
options.fetch(newUrl).then(function(response) {
|
|
102
|
+
var module = {
|
|
103
|
+
exports: {}
|
|
104
|
+
};
|
|
105
|
+
new Function("module", "exports", "require", response)(module, module.exports, function(id) {
|
|
106
|
+
return globalModules[id];
|
|
107
|
+
});
|
|
108
|
+
resolve(module.exports);
|
|
109
|
+
}).catch(function(e) {
|
|
110
|
+
reject(e);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export function loadRemoteControl(url, globalModules) {
|
|
115
|
+
return loadScriptFromFetch(url, globalModules);
|
|
116
|
+
}
|
|
117
|
+
export function loadRemoteControls(urls, globalModules) {
|
|
118
|
+
return _loadRemoteControls.apply(this, arguments);
|
|
119
|
+
}
|
|
120
|
+
function _loadRemoteControls() {
|
|
121
|
+
_loadRemoteControls = _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(urls, globalModules) {
|
|
122
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
123
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
124
|
+
case 0:
|
|
125
|
+
_ctx.next = 2;
|
|
126
|
+
return Promise.all(urls.map(function(url) {
|
|
127
|
+
return loadRemoteControl(url, globalModules);
|
|
128
|
+
}));
|
|
129
|
+
case 2:
|
|
130
|
+
return _ctx.abrupt("return", _ctx.sent);
|
|
131
|
+
case 3:
|
|
132
|
+
case "end":
|
|
133
|
+
return _ctx.stop();
|
|
134
|
+
}
|
|
135
|
+
}, _callee);
|
|
136
|
+
}));
|
|
137
|
+
return _loadRemoteControls.apply(this, arguments);
|
|
138
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _asyncToGenerator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
import regeneratorRuntime from "regenerator-runtime";
|
|
31
|
+
import { getHackerControl } from "./getHackerControl";
|
|
32
|
+
import { nativeFetch, loadRemoteControl } from "./loadRemoteScripts";
|
|
33
|
+
export function registerByteluckControls(url, payload) {
|
|
34
|
+
return _registerByteluckControls.apply(this, arguments);
|
|
35
|
+
}
|
|
36
|
+
function _registerByteluckControls() {
|
|
37
|
+
_registerByteluckControls = _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(url, payload) {
|
|
38
|
+
var version, byteluckControls, componentsStr, components, controls;
|
|
39
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
40
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
41
|
+
case 0:
|
|
42
|
+
version = payload.version;
|
|
43
|
+
if (payload.version === "random") {
|
|
44
|
+
version = new Date().valueOf().toString();
|
|
45
|
+
}
|
|
46
|
+
byteluckControls = new Map();
|
|
47
|
+
_ctx.next = 5;
|
|
48
|
+
return nativeFetch("".concat(url, "/component.json?v=").concat(version));
|
|
49
|
+
case 5:
|
|
50
|
+
componentsStr = _ctx.sent;
|
|
51
|
+
components = [];
|
|
52
|
+
if (!(componentsStr !== undefined)) {
|
|
53
|
+
_ctx.next = 13;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
components = JSON.parse(componentsStr);
|
|
57
|
+
_ctx.next = 11;
|
|
58
|
+
return loadRemoteControl("".concat(url, "/").concat(payload.type, ".js?v=").concat(version), payload.globalModules);
|
|
59
|
+
case 11:
|
|
60
|
+
controls = _ctx.sent;
|
|
61
|
+
components.map(function(item) {
|
|
62
|
+
var control = controls.find(function(control) {
|
|
63
|
+
if (payload.type === "runtime") {
|
|
64
|
+
return control.Runtime.controlType === item.id;
|
|
65
|
+
} else {
|
|
66
|
+
return control.Designer.controlType === item.id;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
if (control === undefined) {
|
|
70
|
+
control = getHackerControl(item.id, payload.type, "内置组件加载错误");
|
|
71
|
+
}
|
|
72
|
+
byteluckControls.set(item.id, {
|
|
73
|
+
props: item,
|
|
74
|
+
version: item.version,
|
|
75
|
+
isLoaded: true,
|
|
76
|
+
control: control
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
case 13:
|
|
80
|
+
return _ctx.abrupt("return", byteluckControls);
|
|
81
|
+
case 14:
|
|
82
|
+
case "end":
|
|
83
|
+
return _ctx.stop();
|
|
84
|
+
}
|
|
85
|
+
}, _callee);
|
|
86
|
+
}));
|
|
87
|
+
return _registerByteluckControls.apply(this, arguments);
|
|
88
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _asyncToGenerator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
import regeneratorRuntime from "regenerator-runtime";
|
|
31
|
+
import { loadRemoteControl } from "./loadRemoteScripts";
|
|
32
|
+
import { warn } from "@byteluck-fe/model-driven-shared";
|
|
33
|
+
import { getHackerControl } from "./getHackerControl";
|
|
34
|
+
export function registerCustomControls(components, refLibs, payload) {
|
|
35
|
+
return _registerCustomControls.apply(this, arguments);
|
|
36
|
+
}
|
|
37
|
+
function _registerCustomControls() {
|
|
38
|
+
_registerCustomControls = _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(components, refLibs, payload) {
|
|
39
|
+
var registered;
|
|
40
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
41
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
42
|
+
case 0:
|
|
43
|
+
registered = new Map();
|
|
44
|
+
if (!(components.length === 0)) {
|
|
45
|
+
_ctx.next = 3;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
return _ctx.abrupt("return", registered);
|
|
49
|
+
case 3:
|
|
50
|
+
_ctx.next = 5;
|
|
51
|
+
return Promise.all(components.map(function() {
|
|
52
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(item) {
|
|
53
|
+
var isLoaded, control, url, link, reg, reg1, styleLink;
|
|
54
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
55
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
56
|
+
case 0:
|
|
57
|
+
isLoaded = true;
|
|
58
|
+
;
|
|
59
|
+
_ctx.prev = 2;
|
|
60
|
+
isLoaded = true;
|
|
61
|
+
url = "";
|
|
62
|
+
if (payload.type === "runtime") {
|
|
63
|
+
url = item.runtime;
|
|
64
|
+
} else {
|
|
65
|
+
url = item.designer;
|
|
66
|
+
}
|
|
67
|
+
url += "?v=" + item.version;
|
|
68
|
+
_ctx.next = 9;
|
|
69
|
+
return loadRemoteControl(url, refLibs);
|
|
70
|
+
case 9:
|
|
71
|
+
control = _ctx.sent;
|
|
72
|
+
_ctx.next = 17;
|
|
73
|
+
break;
|
|
74
|
+
case 12:
|
|
75
|
+
_ctx.prev = 12;
|
|
76
|
+
_ctx.t0 = _ctx["catch"](2);
|
|
77
|
+
isLoaded = false;
|
|
78
|
+
warn("加载自定义控件异常,会影响到的控件:" + item.id, _ctx.t0);
|
|
79
|
+
control = getHackerControl(item.id, payload.type, payload.tipMessage);
|
|
80
|
+
case 17:
|
|
81
|
+
if (isLoaded) {
|
|
82
|
+
link = "";
|
|
83
|
+
if (payload.type === "runtime" && item.runtimecss !== undefined) {
|
|
84
|
+
reg = new RegExp(item.id + "-runtime-.*?$");
|
|
85
|
+
link = item.runtime.replace(reg, item.runtimecss);
|
|
86
|
+
} else if (payload.type === "designer" && item.designercss !== undefined) {
|
|
87
|
+
reg1 = new RegExp(item.id + "-designer-.*?$");
|
|
88
|
+
link = item.designer.replace(reg1, item.designercss);
|
|
89
|
+
}
|
|
90
|
+
if (link !== "") {
|
|
91
|
+
styleLink = document.createElement("link");
|
|
92
|
+
styleLink.href = link;
|
|
93
|
+
styleLink.rel = "stylesheet";
|
|
94
|
+
document.head.appendChild(styleLink);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (payload.type === "runtime") {
|
|
98
|
+
if (registered.has(control.Runtime.controlType)) {
|
|
99
|
+
warn("repeat register ".concat(control.Runtime.controlType));
|
|
100
|
+
}
|
|
101
|
+
// let oldVersion //此处不能赋值
|
|
102
|
+
// component_id_version_list.every(id => {
|
|
103
|
+
// const index = String(control.Runtime.controlType).indexOf(':')
|
|
104
|
+
// if (id.startsWith(control.Runtime.controlType) && index > -1) {
|
|
105
|
+
// oldVersion = String(control.Runtime.controlType).substring(index + 1)
|
|
106
|
+
// return false
|
|
107
|
+
// } else {
|
|
108
|
+
// return true
|
|
109
|
+
// }
|
|
110
|
+
// })
|
|
111
|
+
registered.set(control.Runtime.controlType, {
|
|
112
|
+
props: item,
|
|
113
|
+
version: item.version,
|
|
114
|
+
isLoaded: isLoaded,
|
|
115
|
+
control: control
|
|
116
|
+
});
|
|
117
|
+
} else {
|
|
118
|
+
if (registered.has(control.Designer.controlType)) {
|
|
119
|
+
warn("repeat register ".concat(control.Designer.controlType));
|
|
120
|
+
}
|
|
121
|
+
registered.set(control.Designer.controlType, {
|
|
122
|
+
props: item,
|
|
123
|
+
version: item.version,
|
|
124
|
+
isLoaded: isLoaded,
|
|
125
|
+
control: control
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
case 19:
|
|
129
|
+
case "end":
|
|
130
|
+
return _ctx.stop();
|
|
131
|
+
}
|
|
132
|
+
}, _callee, null, [
|
|
133
|
+
[
|
|
134
|
+
2,
|
|
135
|
+
12
|
|
136
|
+
]
|
|
137
|
+
]);
|
|
138
|
+
}));
|
|
139
|
+
return function(item) {
|
|
140
|
+
return _ref.apply(this, arguments);
|
|
141
|
+
};
|
|
142
|
+
}()));
|
|
143
|
+
case 5:
|
|
144
|
+
return _ctx.abrupt("return", registered);
|
|
145
|
+
case 6:
|
|
146
|
+
case "end":
|
|
147
|
+
return _ctx.stop();
|
|
148
|
+
}
|
|
149
|
+
}, _callee);
|
|
150
|
+
}));
|
|
151
|
+
return _registerCustomControls.apply(this, arguments);
|
|
152
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
function _arrayLikeToArray(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _arrayWithHoles(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _iterableToArrayLimit(arr, i) {
|
|
10
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
11
|
+
if (_i == null) return;
|
|
12
|
+
var _arr = [];
|
|
13
|
+
var _n = true;
|
|
14
|
+
var _d = false;
|
|
15
|
+
var _s, _e;
|
|
16
|
+
try {
|
|
17
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
18
|
+
_arr.push(_s.value);
|
|
19
|
+
if (i && _arr.length === i) break;
|
|
20
|
+
}
|
|
21
|
+
} catch (err) {
|
|
22
|
+
_d = true;
|
|
23
|
+
_e = err;
|
|
24
|
+
} finally{
|
|
25
|
+
try {
|
|
26
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
27
|
+
} finally{
|
|
28
|
+
if (_d) throw _e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return _arr;
|
|
32
|
+
}
|
|
33
|
+
function _nonIterableRest() {
|
|
34
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
35
|
+
}
|
|
36
|
+
function _slicedToArray(arr, i) {
|
|
37
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
38
|
+
}
|
|
39
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
40
|
+
if (!o) return;
|
|
41
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
42
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
43
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
44
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
45
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
46
|
+
}
|
|
47
|
+
export function upgradeCustomControlSchema(schema, registered, componentList, payload) {
|
|
48
|
+
var hasControl = registered.get(schema.type);
|
|
49
|
+
if (hasControl && hasControl.control.upgrade) {
|
|
50
|
+
var oldVersion = "";
|
|
51
|
+
componentList === null || componentList === void 0 ? void 0 : componentList.map(function(comIdWithVersion) {
|
|
52
|
+
var ref = _slicedToArray(comIdWithVersion.split(":"), 2), comid = ref[0], version = ref[1];
|
|
53
|
+
if (hasControl.props.id === comid) {
|
|
54
|
+
oldVersion = version !== null && version !== void 0 ? version : "";
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
schema = hasControl.control.upgrade(schema, hasControl.version, oldVersion, payload);
|
|
58
|
+
}
|
|
59
|
+
return schema;
|
|
60
|
+
}
|