@byteluck-fe/model-driven-core-all 2.21.0-beta.1 → 2.21.0-beta.12

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.
@@ -96,13 +96,13 @@ function _create_super(Derived) {
96
96
  return _possible_constructor_return(this, result);
97
97
  };
98
98
  }
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";
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 === "runtime") {
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 "@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";
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("script");
149
+ var script = document.createElement('script');
150
150
  var resetHackWindow = hackWindow(globalModules);
151
151
  script.src = url;
152
- script.type = "text/javascript";
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: "cors",
179
- cache: "no-cache",
180
- credentials: "same-origin"
178
+ mode: 'cors',
179
+ cache: 'no-cache',
180
+ credentials: 'same-origin'
181
181
  }).then(function(response) {
182
182
  if (response.ok === false) {
183
- throw "not found resource:" + url;
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("module", "exports", "require", response)(module, module.exports, function(id) {
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 "./getHackerControl";
126
- import { nativeFetch, loadRemoteControl } from "./loadRemoteScripts";
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 === "random") {
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 === "runtime") {
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 "./loadRemoteScripts";
172
- import { warn } from "@byteluck-fe/model-driven-shared";
173
- import { getHackerControl } from "./getHackerControl";
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,19 +206,25 @@ function _registerCustomControls() {
206
206
  4
207
207
  ]);
208
208
  isLoaded = true;
209
- url = "";
210
- if (payload.type === "runtime") {
209
+ url = '';
210
+ if (payload.type === 'runtime') {
211
211
  url = item.runtime;
212
212
  } else {
213
213
  url = item.designer;
214
214
  }
215
- url += "?v=" + item.version;
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("加载自定义控件异常,会影响到的控件:" + item.id, e);
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 === "runtime" && item.runtimecss !== undefined) {
239
- reg = new RegExp(item.id + "-runtime-.*?$");
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 === "designer" && item.designercss !== undefined) {
242
- reg1 = new RegExp(item.id + "-designer-.*?$");
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("link");
251
+ if (link !== '') {
252
+ styleLink = document.createElement('link');
247
253
  styleLink.href = link;
248
- styleLink.rel = "stylesheet";
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(":"), 2), comid = _comIdWithVersion_split[0], version = _comIdWithVersion_split[1];
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 === "runtime") {
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(":"), 2), comid = _comIdWithVersion_split[0], version = _comIdWithVersion_split[1];
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);