@byteluck-fe/model-driven-core-all 2.21.0-beta.15 → 2.21.0-beta.18
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 +4 -4
- 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 +23 -23
- package/dist/esm/upgradeCustomControlSchema.js +3 -3
- package/dist/index.umd.js +1 -1
- package/package.json +4 -4
|
@@ -96,13 +96,13 @@ function _create_super(Derived) {
|
|
|
96
96
|
return _possible_constructor_return(this, result);
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
import { RuntimeControl } from
|
|
100
|
-
import { DesignerControl } from
|
|
101
|
-
import { Property } from
|
|
99
|
+
import { RuntimeControl } from "@byteluck-fe/model-driven-core";
|
|
100
|
+
import { DesignerControl } from "@byteluck-fe/model-driven-core";
|
|
101
|
+
import { Property } from "@byteluck-fe/model-driven-core";
|
|
102
102
|
export function getHackerControl(comid, type, tipMessage) {
|
|
103
103
|
var HackerControlClass;
|
|
104
104
|
// 伪造一个组件
|
|
105
|
-
if (type ===
|
|
105
|
+
if (type === "runtime") {
|
|
106
106
|
HackerControlClass = /*#__PURE__*/ function(RuntimeControl) {
|
|
107
107
|
"use strict";
|
|
108
108
|
_inherits(HackerControl, RuntimeControl);
|
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
|
}
|
|
@@ -206,13 +206,13 @@ 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)
|
|
@@ -220,7 +220,7 @@ function _registerCustomControls() {
|
|
|
220
220
|
case 2:
|
|
221
221
|
control = _state.sent();
|
|
222
222
|
//探测组件是否加载正常
|
|
223
|
-
if (payload.type ===
|
|
223
|
+
if (payload.type === "runtime") {
|
|
224
224
|
control.Runtime.__is_control__ === true;
|
|
225
225
|
} else {
|
|
226
226
|
control.Designer.__is_control__ === true;
|
|
@@ -232,7 +232,7 @@ function _registerCustomControls() {
|
|
|
232
232
|
case 3:
|
|
233
233
|
e = _state.sent();
|
|
234
234
|
isLoaded = false;
|
|
235
|
-
warn(
|
|
235
|
+
warn("加载自定义控件异常,会影响到的控件:" + item.id, e);
|
|
236
236
|
control = getHackerControl(item.id, payload.type, payload.tipMessage);
|
|
237
237
|
return [
|
|
238
238
|
3,
|
|
@@ -240,18 +240,18 @@ function _registerCustomControls() {
|
|
|
240
240
|
];
|
|
241
241
|
case 4:
|
|
242
242
|
if (isLoaded) {
|
|
243
|
-
link =
|
|
244
|
-
if (payload.type ===
|
|
245
|
-
reg = new RegExp(item.id +
|
|
243
|
+
link = "";
|
|
244
|
+
if (payload.type === "runtime" && item.runtimecss !== undefined) {
|
|
245
|
+
reg = new RegExp(item.id + "-runtime-.*?$");
|
|
246
246
|
link = item.runtime.replace(reg, item.runtimecss);
|
|
247
|
-
} else if (payload.type ===
|
|
248
|
-
reg1 = new RegExp(item.id +
|
|
247
|
+
} else if (payload.type === "designer" && item.designercss !== undefined) {
|
|
248
|
+
reg1 = new RegExp(item.id + "-designer-.*?$");
|
|
249
249
|
link = item.designer.replace(reg1, item.designercss);
|
|
250
250
|
}
|
|
251
|
-
if (link !==
|
|
252
|
-
styleLink = document.createElement(
|
|
251
|
+
if (link !== "") {
|
|
252
|
+
styleLink = document.createElement("link");
|
|
253
253
|
styleLink.href = link;
|
|
254
|
-
styleLink.rel =
|
|
254
|
+
styleLink.rel = "stylesheet";
|
|
255
255
|
document.head.appendChild(styleLink);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
@@ -270,17 +270,17 @@ function _registerCustomControls() {
|
|
|
270
270
|
case 1:
|
|
271
271
|
_state.sent();
|
|
272
272
|
componentList === null || componentList === void 0 ? void 0 : componentList.map(function(comIdWithVersion) {
|
|
273
|
-
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];
|
|
274
274
|
var hasControl = registered.has(comid);
|
|
275
275
|
if (hasControl === false) {
|
|
276
276
|
var control = getHackerControl(comid, payload.type, payload.tipMessage);
|
|
277
277
|
pushControl(payload.type, control, registered, false, {
|
|
278
|
-
fieldType:
|
|
278
|
+
fieldType: "",
|
|
279
279
|
id: comid,
|
|
280
|
-
name:
|
|
281
|
-
runtime:
|
|
282
|
-
designer:
|
|
283
|
-
type:
|
|
280
|
+
name: "",
|
|
281
|
+
runtime: "",
|
|
282
|
+
designer: "",
|
|
283
|
+
type: "",
|
|
284
284
|
version: version
|
|
285
285
|
});
|
|
286
286
|
}
|
|
@@ -295,7 +295,7 @@ function _registerCustomControls() {
|
|
|
295
295
|
return _registerCustomControls.apply(this, arguments);
|
|
296
296
|
}
|
|
297
297
|
function pushControl(type, control, registered, isLoaded, props) {
|
|
298
|
-
if (type ===
|
|
298
|
+
if (type === "runtime") {
|
|
299
299
|
if (registered.has(control.Runtime.controlType)) {
|
|
300
300
|
warn("repeat register ".concat(control.Runtime.controlType));
|
|
301
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);
|