@byteluck-fe/model-driven-core-all 3.0.0-beta.6 → 3.0.0-beta.9
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 +174 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/loadRemoteScripts.js +225 -0
- package/dist/esm/registerByteluckControls.js +180 -0
- package/dist/esm/registerCustomControls.js +319 -0
- package/dist/esm/upgradeCustomControlSchema.js +60 -0
- package/dist/index.umd.js +1 -0
- package/dist/types/getHackerControl.d.ts +23 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/loadRemoteScripts.d.ts +7 -0
- package/dist/types/registerByteluckControls.d.ts +7 -0
- package/dist/types/registerCustomControls.d.ts +23 -0
- package/dist/types/upgradeCustomControlSchema.d.ts +2 -0
- package/package.json +6 -6
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
function _assert_this_initialized(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 _call_super(_this, derived, args) {
|
|
8
|
+
derived = _get_prototype_of(derived);
|
|
9
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
10
|
+
}
|
|
11
|
+
function _class_call_check(instance, Constructor) {
|
|
12
|
+
if (!(instance instanceof Constructor)) {
|
|
13
|
+
throw new TypeError("Cannot call a class as a function");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _defineProperties(target, props) {
|
|
17
|
+
for(var i = 0; i < props.length; i++){
|
|
18
|
+
var descriptor = props[i];
|
|
19
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
20
|
+
descriptor.configurable = true;
|
|
21
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
22
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
26
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
27
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
28
|
+
return Constructor;
|
|
29
|
+
}
|
|
30
|
+
function _define_property(obj, key, value) {
|
|
31
|
+
if (key in obj) {
|
|
32
|
+
Object.defineProperty(obj, key, {
|
|
33
|
+
value: value,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
obj[key] = value;
|
|
40
|
+
}
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
function _get_prototype_of(o) {
|
|
44
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
45
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
46
|
+
};
|
|
47
|
+
return _get_prototype_of(o);
|
|
48
|
+
}
|
|
49
|
+
function _inherits(subClass, superClass) {
|
|
50
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
51
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
52
|
+
}
|
|
53
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
54
|
+
constructor: {
|
|
55
|
+
value: subClass,
|
|
56
|
+
writable: true,
|
|
57
|
+
configurable: true
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
61
|
+
}
|
|
62
|
+
function _possible_constructor_return(self, call) {
|
|
63
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
64
|
+
return call;
|
|
65
|
+
}
|
|
66
|
+
return _assert_this_initialized(self);
|
|
67
|
+
}
|
|
68
|
+
function _set_prototype_of(o, p) {
|
|
69
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
70
|
+
o.__proto__ = p;
|
|
71
|
+
return o;
|
|
72
|
+
};
|
|
73
|
+
return _set_prototype_of(o, p);
|
|
74
|
+
}
|
|
75
|
+
function _type_of(obj) {
|
|
76
|
+
"@swc/helpers - typeof";
|
|
77
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
78
|
+
}
|
|
79
|
+
function _is_native_reflect_construct() {
|
|
80
|
+
try {
|
|
81
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
82
|
+
} catch (_) {}
|
|
83
|
+
return (_is_native_reflect_construct = function() {
|
|
84
|
+
return !!result;
|
|
85
|
+
})();
|
|
86
|
+
}
|
|
87
|
+
import { RuntimeControl } from '@byteluck-fe/model-driven-core';
|
|
88
|
+
import { DesignerControl } from '@byteluck-fe/model-driven-core';
|
|
89
|
+
import { Property } from '@byteluck-fe/model-driven-core';
|
|
90
|
+
export function getHackerControl(comid, type, tipMessage) {
|
|
91
|
+
var HackerControlClass;
|
|
92
|
+
// 伪造一个组件
|
|
93
|
+
if (type === 'runtime') {
|
|
94
|
+
HackerControlClass = /*#__PURE__*/ function(RuntimeControl) {
|
|
95
|
+
"use strict";
|
|
96
|
+
_inherits(HackerControl, RuntimeControl);
|
|
97
|
+
function HackerControl(props) {
|
|
98
|
+
_class_call_check(this, HackerControl);
|
|
99
|
+
var _this;
|
|
100
|
+
_this = _call_super(this, HackerControl, [
|
|
101
|
+
props
|
|
102
|
+
]), _define_property(_this, "props", {});
|
|
103
|
+
return _this;
|
|
104
|
+
}
|
|
105
|
+
_create_class(HackerControl, null, [
|
|
106
|
+
{
|
|
107
|
+
key: "controlType",
|
|
108
|
+
get: function get() {
|
|
109
|
+
return comid;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
]);
|
|
113
|
+
return HackerControl;
|
|
114
|
+
}(RuntimeControl);
|
|
115
|
+
} else {
|
|
116
|
+
HackerControlClass = /*#__PURE__*/ function(DesignerControl) {
|
|
117
|
+
"use strict";
|
|
118
|
+
_inherits(HackerControl, DesignerControl);
|
|
119
|
+
function HackerControl(props) {
|
|
120
|
+
_class_call_check(this, HackerControl);
|
|
121
|
+
var _this;
|
|
122
|
+
_this = _call_super(this, HackerControl, [
|
|
123
|
+
props
|
|
124
|
+
]), _define_property(_this, "props", {});
|
|
125
|
+
return _this;
|
|
126
|
+
}
|
|
127
|
+
_create_class(HackerControl, null, [
|
|
128
|
+
{
|
|
129
|
+
key: "controlType",
|
|
130
|
+
get: function get() {
|
|
131
|
+
return comid;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
]);
|
|
135
|
+
return HackerControl;
|
|
136
|
+
}(DesignerControl);
|
|
137
|
+
}
|
|
138
|
+
var HackerPropertyClass = /*#__PURE__*/ function(Property) {
|
|
139
|
+
"use strict";
|
|
140
|
+
_inherits(HackerPropertyClass, Property);
|
|
141
|
+
function HackerPropertyClass() {
|
|
142
|
+
_class_call_check(this, HackerPropertyClass);
|
|
143
|
+
return _call_super(this, HackerPropertyClass, arguments);
|
|
144
|
+
}
|
|
145
|
+
return HackerPropertyClass;
|
|
146
|
+
}(Property);
|
|
147
|
+
var template = '<div style="background:#fff0ef;color:#ff6459;padding:8px 16px;border-radius:4px;"><i class="low-code iconshibaimian" style="margin-right:4px"></i>'.concat(tipMessage, "</div>");
|
|
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
|
+
error: {
|
|
165
|
+
template: template
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
upgrade: function(schema) {
|
|
170
|
+
return schema;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
return control;
|
|
174
|
+
}
|
|
@@ -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,225 @@
|
|
|
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 _async_to_generator(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
|
+
function _ts_generator(thisArg, body) {
|
|
31
|
+
var f, y, t, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
41
|
+
return this;
|
|
42
|
+
}), g;
|
|
43
|
+
function verb(n) {
|
|
44
|
+
return function(v) {
|
|
45
|
+
return step([
|
|
46
|
+
n,
|
|
47
|
+
v
|
|
48
|
+
]);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function step(op) {
|
|
52
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
53
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
54
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
55
|
+
if (y = 0, t) op = [
|
|
56
|
+
op[0] & 2,
|
|
57
|
+
t.value
|
|
58
|
+
];
|
|
59
|
+
switch(op[0]){
|
|
60
|
+
case 0:
|
|
61
|
+
case 1:
|
|
62
|
+
t = op;
|
|
63
|
+
break;
|
|
64
|
+
case 4:
|
|
65
|
+
_.label++;
|
|
66
|
+
return {
|
|
67
|
+
value: op[1],
|
|
68
|
+
done: false
|
|
69
|
+
};
|
|
70
|
+
case 5:
|
|
71
|
+
_.label++;
|
|
72
|
+
y = op[1];
|
|
73
|
+
op = [
|
|
74
|
+
0
|
|
75
|
+
];
|
|
76
|
+
continue;
|
|
77
|
+
case 7:
|
|
78
|
+
op = _.ops.pop();
|
|
79
|
+
_.trys.pop();
|
|
80
|
+
continue;
|
|
81
|
+
default:
|
|
82
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
+
_ = 0;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
+
_.label = op[1];
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
+
_.label = t[1];
|
|
92
|
+
t = op;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (t && _.label < t[2]) {
|
|
96
|
+
_.label = t[2];
|
|
97
|
+
_.ops.push(op);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t[2]) _.ops.pop();
|
|
101
|
+
_.trys.pop();
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
op = body.call(thisArg, _);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
op = [
|
|
107
|
+
6,
|
|
108
|
+
e
|
|
109
|
+
];
|
|
110
|
+
y = 0;
|
|
111
|
+
} finally{
|
|
112
|
+
f = t = 0;
|
|
113
|
+
}
|
|
114
|
+
if (op[0] & 5) throw op[1];
|
|
115
|
+
return {
|
|
116
|
+
value: op[0] ? op[1] : void 0,
|
|
117
|
+
done: true
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
var jobs = [];
|
|
122
|
+
var module = {
|
|
123
|
+
exports: {}
|
|
124
|
+
};
|
|
125
|
+
var hacked = false;
|
|
126
|
+
var beforeModule = window.module, beforeExports = window.exports, beforeRequire = window.require;
|
|
127
|
+
function hackWindow(globalModules) {
|
|
128
|
+
if (!hacked) {
|
|
129
|
+
window.module = module;
|
|
130
|
+
window.exports = module.exports;
|
|
131
|
+
window.require = function(module) {
|
|
132
|
+
return globalModules[module];
|
|
133
|
+
};
|
|
134
|
+
hacked = true;
|
|
135
|
+
}
|
|
136
|
+
return function resetHackWindow() {
|
|
137
|
+
window.module = beforeModule;
|
|
138
|
+
window.exports = beforeExports;
|
|
139
|
+
window.require = beforeRequire;
|
|
140
|
+
hacked = false;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function loadScriptFromTag(url, globalModules) {
|
|
144
|
+
var p = new Promise(function(resolve, reject) {
|
|
145
|
+
var script = document.createElement('script');
|
|
146
|
+
var resetHackWindow = hackWindow(globalModules);
|
|
147
|
+
script.src = url;
|
|
148
|
+
script.type = 'text/javascript';
|
|
149
|
+
var loadEnd = function() {
|
|
150
|
+
document.head.removeChild(script);
|
|
151
|
+
var index = jobs.findIndex(function(j) {
|
|
152
|
+
return j === p;
|
|
153
|
+
});
|
|
154
|
+
jobs.splice(index, 1);
|
|
155
|
+
if (jobs.length === 0) {
|
|
156
|
+
resetHackWindow();
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
script.onerror = function(e) {
|
|
160
|
+
loadEnd();
|
|
161
|
+
reject(e);
|
|
162
|
+
};
|
|
163
|
+
script.onload = function() {
|
|
164
|
+
resolve(module.exports);
|
|
165
|
+
loadEnd();
|
|
166
|
+
};
|
|
167
|
+
document.head.appendChild(script);
|
|
168
|
+
});
|
|
169
|
+
jobs.push(p);
|
|
170
|
+
return p;
|
|
171
|
+
}
|
|
172
|
+
export function nativeFetch(url) {
|
|
173
|
+
return fetch(url, {
|
|
174
|
+
mode: 'cors',
|
|
175
|
+
cache: 'no-cache',
|
|
176
|
+
credentials: 'same-origin'
|
|
177
|
+
}).then(function(response) {
|
|
178
|
+
if (response.ok === false) {
|
|
179
|
+
throw 'not found resource:' + url;
|
|
180
|
+
} else {
|
|
181
|
+
return response.text();
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
export function loadScriptFromFetch(url, globalModules) {
|
|
186
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
|
|
187
|
+
fetch: nativeFetch
|
|
188
|
+
};
|
|
189
|
+
return new Promise(function(resolve, reject) {
|
|
190
|
+
options.fetch(url).then(function(response) {
|
|
191
|
+
var module = {
|
|
192
|
+
exports: {}
|
|
193
|
+
};
|
|
194
|
+
new Function('module', 'exports', 'require', response)(module, module.exports, function(id) {
|
|
195
|
+
return globalModules[id];
|
|
196
|
+
});
|
|
197
|
+
resolve(module.exports);
|
|
198
|
+
}).catch(function(e) {
|
|
199
|
+
reject(e);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
export function loadRemoteControl(url, globalModules) {
|
|
204
|
+
return loadScriptFromFetch(url, globalModules);
|
|
205
|
+
}
|
|
206
|
+
export function loadRemoteControls(urls, globalModules) {
|
|
207
|
+
return _async_to_generator(function() {
|
|
208
|
+
return _ts_generator(this, function(_state) {
|
|
209
|
+
switch(_state.label){
|
|
210
|
+
case 0:
|
|
211
|
+
return [
|
|
212
|
+
4,
|
|
213
|
+
Promise.all(urls.map(function(url) {
|
|
214
|
+
return loadRemoteControl(url, globalModules);
|
|
215
|
+
}))
|
|
216
|
+
];
|
|
217
|
+
case 1:
|
|
218
|
+
return [
|
|
219
|
+
2,
|
|
220
|
+
_state.sent()
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
})();
|
|
225
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
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 _async_to_generator(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
|
+
function _ts_generator(thisArg, body) {
|
|
31
|
+
var f, y, t, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
41
|
+
return this;
|
|
42
|
+
}), g;
|
|
43
|
+
function verb(n) {
|
|
44
|
+
return function(v) {
|
|
45
|
+
return step([
|
|
46
|
+
n,
|
|
47
|
+
v
|
|
48
|
+
]);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function step(op) {
|
|
52
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
53
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
54
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
55
|
+
if (y = 0, t) op = [
|
|
56
|
+
op[0] & 2,
|
|
57
|
+
t.value
|
|
58
|
+
];
|
|
59
|
+
switch(op[0]){
|
|
60
|
+
case 0:
|
|
61
|
+
case 1:
|
|
62
|
+
t = op;
|
|
63
|
+
break;
|
|
64
|
+
case 4:
|
|
65
|
+
_.label++;
|
|
66
|
+
return {
|
|
67
|
+
value: op[1],
|
|
68
|
+
done: false
|
|
69
|
+
};
|
|
70
|
+
case 5:
|
|
71
|
+
_.label++;
|
|
72
|
+
y = op[1];
|
|
73
|
+
op = [
|
|
74
|
+
0
|
|
75
|
+
];
|
|
76
|
+
continue;
|
|
77
|
+
case 7:
|
|
78
|
+
op = _.ops.pop();
|
|
79
|
+
_.trys.pop();
|
|
80
|
+
continue;
|
|
81
|
+
default:
|
|
82
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
+
_ = 0;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
+
_.label = op[1];
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
+
_.label = t[1];
|
|
92
|
+
t = op;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (t && _.label < t[2]) {
|
|
96
|
+
_.label = t[2];
|
|
97
|
+
_.ops.push(op);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t[2]) _.ops.pop();
|
|
101
|
+
_.trys.pop();
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
op = body.call(thisArg, _);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
op = [
|
|
107
|
+
6,
|
|
108
|
+
e
|
|
109
|
+
];
|
|
110
|
+
y = 0;
|
|
111
|
+
} finally{
|
|
112
|
+
f = t = 0;
|
|
113
|
+
}
|
|
114
|
+
if (op[0] & 5) throw op[1];
|
|
115
|
+
return {
|
|
116
|
+
value: op[0] ? op[1] : void 0,
|
|
117
|
+
done: true
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
import { getHackerControl } from './getHackerControl';
|
|
122
|
+
import { nativeFetch, loadRemoteControl } from './loadRemoteScripts';
|
|
123
|
+
import { getLocaleText } from '@byteluck-fe/locale-message';
|
|
124
|
+
export function registerByteluckControls(url, payload) {
|
|
125
|
+
return _async_to_generator(function() {
|
|
126
|
+
var version, byteluckControls, componentsStr, components, controls;
|
|
127
|
+
return _ts_generator(this, function(_state) {
|
|
128
|
+
switch(_state.label){
|
|
129
|
+
case 0:
|
|
130
|
+
version = payload.version;
|
|
131
|
+
if (payload.version === 'random') {
|
|
132
|
+
version = new Date().valueOf().toString();
|
|
133
|
+
}
|
|
134
|
+
byteluckControls = new Map();
|
|
135
|
+
return [
|
|
136
|
+
4,
|
|
137
|
+
nativeFetch("".concat(url, "/component.json?v=").concat(version))
|
|
138
|
+
];
|
|
139
|
+
case 1:
|
|
140
|
+
componentsStr = _state.sent();
|
|
141
|
+
components = [];
|
|
142
|
+
if (!(componentsStr !== undefined)) return [
|
|
143
|
+
3,
|
|
144
|
+
3
|
|
145
|
+
];
|
|
146
|
+
components = JSON.parse(componentsStr);
|
|
147
|
+
return [
|
|
148
|
+
4,
|
|
149
|
+
loadRemoteControl("".concat(url, "/").concat(payload.type, ".js?v=").concat(version, "&").concat(payload.isPc === false ? 'mobile' : 'desktop'), payload.globalModules)
|
|
150
|
+
];
|
|
151
|
+
case 2:
|
|
152
|
+
controls = _state.sent();
|
|
153
|
+
components.map(function(item) {
|
|
154
|
+
var control = controls.find(function(control) {
|
|
155
|
+
if (payload.type === 'runtime') {
|
|
156
|
+
return control.Runtime.controlType === item.id;
|
|
157
|
+
} else {
|
|
158
|
+
return control.Designer.controlType === item.id;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
if (control === undefined) {
|
|
162
|
+
control = getHackerControl(item.id, payload.type, getLocaleText('CMD.loadCtrlError', null, '内置组件加载错误'));
|
|
163
|
+
}
|
|
164
|
+
byteluckControls.set(item.id, {
|
|
165
|
+
props: item,
|
|
166
|
+
version: item.version,
|
|
167
|
+
isLoaded: true,
|
|
168
|
+
control: control
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
_state.label = 3;
|
|
172
|
+
case 3:
|
|
173
|
+
return [
|
|
174
|
+
2,
|
|
175
|
+
byteluckControls
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
})();
|
|
180
|
+
}
|