@byteluck-fe/model-driven-core-all 2.9.0-alpha.9 → 2.9.1-beta.1
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/README.md +11 -11
- package/dist/esm/getHackerControl.js +20 -33
- package/dist/esm/index.js +9 -9
- package/dist/esm/loadRemoteScripts.js +7 -7
- package/dist/esm/registerByteluckControls.js +5 -5
- package/dist/esm/registerCustomControls.js +29 -23
- package/dist/esm/upgradeCustomControlSchema.js +3 -3
- package/dist/index.umd.js +1 -1
- package/dist/types/getHackerControl.d.ts +23 -23
- package/dist/types/index.d.ts +9 -9
- package/dist/types/loadRemoteScripts.d.ts +7 -7
- package/dist/types/registerByteluckControls.d.ts +6 -6
- package/dist/types/registerCustomControls.d.ts +22 -22
- package/dist/types/upgradeCustomControlSchema.d.ts +2 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# `runtime-all`
|
|
2
|
-
|
|
3
|
-
> TODO: description
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
const runtimeAll = require('runtime-all');
|
|
9
|
-
|
|
10
|
-
// TODO: DEMONSTRATE API
|
|
11
|
-
```
|
|
1
|
+
# `runtime-all`
|
|
2
|
+
|
|
3
|
+
> TODO: description
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
const runtimeAll = require('runtime-all');
|
|
9
|
+
|
|
10
|
+
// TODO: DEMONSTRATE API
|
|
11
|
+
```
|
|
@@ -4,6 +4,10 @@ function _assert_this_initialized(self) {
|
|
|
4
4
|
}
|
|
5
5
|
return self;
|
|
6
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
|
+
}
|
|
7
11
|
function _class_call_check(instance, Constructor) {
|
|
8
12
|
if (!(instance instanceof Constructor)) {
|
|
9
13
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -73,45 +77,29 @@ function _type_of(obj) {
|
|
|
73
77
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
74
78
|
}
|
|
75
79
|
function _is_native_reflect_construct() {
|
|
76
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
77
|
-
if (Reflect.construct.sham) return false;
|
|
78
|
-
if (typeof Proxy === "function") return true;
|
|
79
80
|
try {
|
|
80
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function _create_super(Derived) {
|
|
87
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
88
|
-
return function _createSuperInternal() {
|
|
89
|
-
var Super = _get_prototype_of(Derived), result;
|
|
90
|
-
if (hasNativeReflectConstruct) {
|
|
91
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
92
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
93
|
-
} else {
|
|
94
|
-
result = Super.apply(this, arguments);
|
|
95
|
-
}
|
|
96
|
-
return _possible_constructor_return(this, result);
|
|
97
|
-
};
|
|
81
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
82
|
+
} catch (_) {}
|
|
83
|
+
return (_is_native_reflect_construct = function() {
|
|
84
|
+
return !!result;
|
|
85
|
+
})();
|
|
98
86
|
}
|
|
99
|
-
import { RuntimeControl } from
|
|
100
|
-
import { DesignerControl } from
|
|
101
|
-
import { Property } from
|
|
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';
|
|
102
90
|
export function getHackerControl(comid, type, tipMessage) {
|
|
103
91
|
var HackerControlClass;
|
|
104
92
|
// 伪造一个组件
|
|
105
|
-
if (type ===
|
|
93
|
+
if (type === 'runtime') {
|
|
106
94
|
HackerControlClass = /*#__PURE__*/ function(RuntimeControl) {
|
|
107
95
|
"use strict";
|
|
108
96
|
_inherits(HackerControl, RuntimeControl);
|
|
109
|
-
var _super = _create_super(HackerControl);
|
|
110
97
|
function HackerControl(props) {
|
|
111
98
|
_class_call_check(this, HackerControl);
|
|
112
99
|
var _this;
|
|
113
|
-
_this =
|
|
114
|
-
|
|
100
|
+
_this = _call_super(this, HackerControl, [
|
|
101
|
+
props
|
|
102
|
+
]), _define_property(_this, "props", {});
|
|
115
103
|
return _this;
|
|
116
104
|
}
|
|
117
105
|
_create_class(HackerControl, null, [
|
|
@@ -128,12 +116,12 @@ export function getHackerControl(comid, type, tipMessage) {
|
|
|
128
116
|
HackerControlClass = /*#__PURE__*/ function(DesignerControl) {
|
|
129
117
|
"use strict";
|
|
130
118
|
_inherits(HackerControl, DesignerControl);
|
|
131
|
-
var _super = _create_super(HackerControl);
|
|
132
119
|
function HackerControl(props) {
|
|
133
120
|
_class_call_check(this, HackerControl);
|
|
134
121
|
var _this;
|
|
135
|
-
_this =
|
|
136
|
-
|
|
122
|
+
_this = _call_super(this, HackerControl, [
|
|
123
|
+
props
|
|
124
|
+
]), _define_property(_this, "props", {});
|
|
137
125
|
return _this;
|
|
138
126
|
}
|
|
139
127
|
_create_class(HackerControl, null, [
|
|
@@ -150,10 +138,9 @@ export function getHackerControl(comid, type, tipMessage) {
|
|
|
150
138
|
var HackerPropertyClass = /*#__PURE__*/ function(Property) {
|
|
151
139
|
"use strict";
|
|
152
140
|
_inherits(HackerPropertyClass, Property);
|
|
153
|
-
var _super = _create_super(HackerPropertyClass);
|
|
154
141
|
function HackerPropertyClass() {
|
|
155
142
|
_class_call_check(this, HackerPropertyClass);
|
|
156
|
-
return
|
|
143
|
+
return _call_super(this, HackerPropertyClass, arguments);
|
|
157
144
|
}
|
|
158
145
|
return HackerPropertyClass;
|
|
159
146
|
}(Property);
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
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';
|
|
@@ -146,10 +146,10 @@ function hackWindow(globalModules) {
|
|
|
146
146
|
}
|
|
147
147
|
export function loadScriptFromTag(url, globalModules) {
|
|
148
148
|
var p = new Promise(function(resolve, reject) {
|
|
149
|
-
var script = document.createElement(
|
|
149
|
+
var script = document.createElement('script');
|
|
150
150
|
var resetHackWindow = hackWindow(globalModules);
|
|
151
151
|
script.src = url;
|
|
152
|
-
script.type =
|
|
152
|
+
script.type = 'text/javascript';
|
|
153
153
|
var loadEnd = function() {
|
|
154
154
|
document.head.removeChild(script);
|
|
155
155
|
var index = jobs.findIndex(function(j) {
|
|
@@ -175,12 +175,12 @@ export function loadScriptFromTag(url, globalModules) {
|
|
|
175
175
|
}
|
|
176
176
|
export function nativeFetch(url) {
|
|
177
177
|
return fetch(url, {
|
|
178
|
-
mode:
|
|
179
|
-
cache:
|
|
180
|
-
credentials:
|
|
178
|
+
mode: 'cors',
|
|
179
|
+
cache: 'no-cache',
|
|
180
|
+
credentials: 'same-origin'
|
|
181
181
|
}).then(function(response) {
|
|
182
182
|
if (response.ok === false) {
|
|
183
|
-
throw
|
|
183
|
+
throw 'not found resource:' + url;
|
|
184
184
|
} else {
|
|
185
185
|
return response.text();
|
|
186
186
|
}
|
|
@@ -195,7 +195,7 @@ export function loadScriptFromFetch(url, globalModules) {
|
|
|
195
195
|
var module = {
|
|
196
196
|
exports: {}
|
|
197
197
|
};
|
|
198
|
-
new Function(
|
|
198
|
+
new Function('module', 'exports', 'require', response)(module, module.exports, function(id) {
|
|
199
199
|
return globalModules[id];
|
|
200
200
|
});
|
|
201
201
|
resolve(module.exports);
|
|
@@ -122,8 +122,8 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { getHackerControl } from
|
|
126
|
-
import { nativeFetch, loadRemoteControl } from
|
|
125
|
+
import { getHackerControl } from './getHackerControl';
|
|
126
|
+
import { nativeFetch, loadRemoteControl } from './loadRemoteScripts';
|
|
127
127
|
export function registerByteluckControls(url, payload) {
|
|
128
128
|
return _registerByteluckControls.apply(this, arguments);
|
|
129
129
|
}
|
|
@@ -134,7 +134,7 @@ function _registerByteluckControls() {
|
|
|
134
134
|
switch(_state.label){
|
|
135
135
|
case 0:
|
|
136
136
|
version = payload.version;
|
|
137
|
-
if (payload.version ===
|
|
137
|
+
if (payload.version === 'random') {
|
|
138
138
|
version = new Date().valueOf().toString();
|
|
139
139
|
}
|
|
140
140
|
byteluckControls = new Map();
|
|
@@ -158,14 +158,14 @@ function _registerByteluckControls() {
|
|
|
158
158
|
controls = _state.sent();
|
|
159
159
|
components.map(function(item) {
|
|
160
160
|
var control = controls.find(function(control) {
|
|
161
|
-
if (payload.type ===
|
|
161
|
+
if (payload.type === 'runtime') {
|
|
162
162
|
return control.Runtime.controlType === item.id;
|
|
163
163
|
} else {
|
|
164
164
|
return control.Designer.controlType === item.id;
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
167
|
if (control === undefined) {
|
|
168
|
-
control = getHackerControl(item.id, payload.type,
|
|
168
|
+
control = getHackerControl(item.id, payload.type, '内置组件加载错误');
|
|
169
169
|
}
|
|
170
170
|
byteluckControls.set(item.id, {
|
|
171
171
|
props: item,
|
|
@@ -168,9 +168,9 @@ function _ts_generator(thisArg, body) {
|
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
import { loadRemoteControl } from
|
|
172
|
-
import { warn } from
|
|
173
|
-
import { getHackerControl } from
|
|
171
|
+
import { loadRemoteControl } from './loadRemoteScripts';
|
|
172
|
+
import { warn } from '@byteluck-fe/model-driven-shared';
|
|
173
|
+
import { getHackerControl } from './getHackerControl';
|
|
174
174
|
export function registerCustomControls(componentList, components, refLibs, payload) {
|
|
175
175
|
return _registerCustomControls.apply(this, arguments);
|
|
176
176
|
}
|
|
@@ -190,7 +190,7 @@ function _registerCustomControls() {
|
|
|
190
190
|
//qiyu 2022-4-18 逐个加载自定义组件,只有异常的组件加载为hackerControl
|
|
191
191
|
return [
|
|
192
192
|
4,
|
|
193
|
-
Promise.all(components.map(function() {
|
|
193
|
+
Promise.all(components.map(/*#__PURE__*/ function() {
|
|
194
194
|
var _ref = _async_to_generator(function(item) {
|
|
195
195
|
var isLoaded, control, url, e, link, reg, reg1, styleLink;
|
|
196
196
|
return _ts_generator(this, function(_state) {
|
|
@@ -206,19 +206,25 @@ function _registerCustomControls() {
|
|
|
206
206
|
4
|
|
207
207
|
]);
|
|
208
208
|
isLoaded = true;
|
|
209
|
-
url =
|
|
210
|
-
if (payload.type ===
|
|
209
|
+
url = '';
|
|
210
|
+
if (payload.type === 'runtime') {
|
|
211
211
|
url = item.runtime;
|
|
212
212
|
} else {
|
|
213
213
|
url = item.designer;
|
|
214
214
|
}
|
|
215
|
-
url +=
|
|
215
|
+
url += '?v=' + item.version;
|
|
216
216
|
return [
|
|
217
217
|
4,
|
|
218
218
|
loadRemoteControl(url, refLibs)
|
|
219
219
|
];
|
|
220
220
|
case 2:
|
|
221
221
|
control = _state.sent();
|
|
222
|
+
//探测组件是否加载正常
|
|
223
|
+
if (payload.type === 'runtime') {
|
|
224
|
+
control.Runtime.__is_control__ === true;
|
|
225
|
+
} else {
|
|
226
|
+
control.Designer.__is_control__ === true;
|
|
227
|
+
}
|
|
222
228
|
return [
|
|
223
229
|
3,
|
|
224
230
|
4
|
|
@@ -226,7 +232,7 @@ function _registerCustomControls() {
|
|
|
226
232
|
case 3:
|
|
227
233
|
e = _state.sent();
|
|
228
234
|
isLoaded = false;
|
|
229
|
-
warn(
|
|
235
|
+
warn('加载自定义控件异常,会影响到的控件:' + item.id, e);
|
|
230
236
|
control = getHackerControl(item.id, payload.type, payload.tipMessage);
|
|
231
237
|
return [
|
|
232
238
|
3,
|
|
@@ -234,18 +240,18 @@ function _registerCustomControls() {
|
|
|
234
240
|
];
|
|
235
241
|
case 4:
|
|
236
242
|
if (isLoaded) {
|
|
237
|
-
link =
|
|
238
|
-
if (payload.type ===
|
|
239
|
-
reg = new RegExp(item.id +
|
|
243
|
+
link = '';
|
|
244
|
+
if (payload.type === 'runtime' && item.runtimecss !== undefined) {
|
|
245
|
+
reg = new RegExp(item.id + '-runtime-.*?$');
|
|
240
246
|
link = item.runtime.replace(reg, item.runtimecss);
|
|
241
|
-
} else if (payload.type ===
|
|
242
|
-
reg1 = new RegExp(item.id +
|
|
247
|
+
} else if (payload.type === 'designer' && item.designercss !== undefined) {
|
|
248
|
+
reg1 = new RegExp(item.id + '-designer-.*?$');
|
|
243
249
|
link = item.designer.replace(reg1, item.designercss);
|
|
244
250
|
}
|
|
245
|
-
if (link !==
|
|
246
|
-
styleLink = document.createElement(
|
|
251
|
+
if (link !== '') {
|
|
252
|
+
styleLink = document.createElement('link');
|
|
247
253
|
styleLink.href = link;
|
|
248
|
-
styleLink.rel =
|
|
254
|
+
styleLink.rel = 'stylesheet';
|
|
249
255
|
document.head.appendChild(styleLink);
|
|
250
256
|
}
|
|
251
257
|
}
|
|
@@ -264,17 +270,17 @@ function _registerCustomControls() {
|
|
|
264
270
|
case 1:
|
|
265
271
|
_state.sent();
|
|
266
272
|
componentList === null || componentList === void 0 ? void 0 : componentList.map(function(comIdWithVersion) {
|
|
267
|
-
var _comIdWithVersion_split = _sliced_to_array(comIdWithVersion.split(
|
|
273
|
+
var _comIdWithVersion_split = _sliced_to_array(comIdWithVersion.split(':'), 2), comid = _comIdWithVersion_split[0], version = _comIdWithVersion_split[1];
|
|
268
274
|
var hasControl = registered.has(comid);
|
|
269
275
|
if (hasControl === false) {
|
|
270
276
|
var control = getHackerControl(comid, payload.type, payload.tipMessage);
|
|
271
277
|
pushControl(payload.type, control, registered, false, {
|
|
272
|
-
fieldType:
|
|
278
|
+
fieldType: '',
|
|
273
279
|
id: comid,
|
|
274
|
-
name:
|
|
275
|
-
runtime:
|
|
276
|
-
designer:
|
|
277
|
-
type:
|
|
280
|
+
name: '',
|
|
281
|
+
runtime: '',
|
|
282
|
+
designer: '',
|
|
283
|
+
type: '',
|
|
278
284
|
version: version
|
|
279
285
|
});
|
|
280
286
|
}
|
|
@@ -289,7 +295,7 @@ function _registerCustomControls() {
|
|
|
289
295
|
return _registerCustomControls.apply(this, arguments);
|
|
290
296
|
}
|
|
291
297
|
function pushControl(type, control, registered, isLoaded, props) {
|
|
292
|
-
if (type ===
|
|
298
|
+
if (type === 'runtime') {
|
|
293
299
|
if (registered.has(control.Runtime.controlType)) {
|
|
294
300
|
warn("repeat register ".concat(control.Runtime.controlType));
|
|
295
301
|
}
|
|
@@ -47,11 +47,11 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
47
47
|
export function upgradeCustomControlSchema(schema, registered, componentList, payload) {
|
|
48
48
|
var hasControl = registered.get(schema.type);
|
|
49
49
|
if (hasControl && hasControl.control.upgrade) {
|
|
50
|
-
var oldVersion =
|
|
50
|
+
var oldVersion = '';
|
|
51
51
|
componentList === null || componentList === void 0 ? void 0 : componentList.map(function(comIdWithVersion) {
|
|
52
|
-
var _comIdWithVersion_split = _sliced_to_array(comIdWithVersion.split(
|
|
52
|
+
var _comIdWithVersion_split = _sliced_to_array(comIdWithVersion.split(':'), 2), comid = _comIdWithVersion_split[0], version = _comIdWithVersion_split[1];
|
|
53
53
|
if (hasControl.props.id === comid) {
|
|
54
|
-
oldVersion = version !== null && version !== void 0 ? version :
|
|
54
|
+
oldVersion = version !== null && version !== void 0 ? version : '';
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
schema = hasControl.control.upgrade(schema, hasControl.version, oldVersion, payload);
|