@easy-editor/core 1.0.1 → 1.0.3

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/index.cjs CHANGED
@@ -79,6 +79,9 @@ const isPluginEventName = eventName => {
79
79
  const eventSegments = eventName.split(':');
80
80
  return eventSegments.length > 1 && eventSegments[0].length > 0;
81
81
  };
82
+ const isRemoteComponent = schema => {
83
+ return !!(schema.npm && schema.npm.package && schema.npm.package !== 'builtin');
84
+ };
82
85
 
83
86
  const levels = {
84
87
  debug: -1,
@@ -720,7 +723,7 @@ const urlAlphabet = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwy
720
723
 
721
724
  let nanoid = (size = 21) => {
722
725
  let id = '';
723
- let bytes = crypto.getRandomValues(new Uint8Array(size));
726
+ let bytes = crypto.getRandomValues(new Uint8Array(size |= 0));
724
727
  while (size--) {
725
728
  id += urlAlphabet[bytes[size] & 63];
726
729
  }
@@ -972,12 +975,12 @@ function _applyDecs2311(e, t, n, r, o, i) {
972
975
  t[4](this, e);
973
976
  }
974
977
  } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) {
975
- if ((c = y[+s][r]) && 7 != (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet");
978
+ if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet");
976
979
  y[+s][r] = o < 3 ? 1 : o;
977
980
  }
978
981
  }
979
982
  for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) {
980
- var T = b(h[O], "A decorator", "be", !0),
983
+ var T = b(h[O], "A decorator", "be", true),
981
984
  z = n ? h[O - 1] : void 0,
982
985
  A = {},
983
986
  H = {
@@ -986,7 +989,7 @@ function _applyDecs2311(e, t, n, r, o, i) {
986
989
  metadata: a,
987
990
  addInitializer: function (e, t) {
988
991
  if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
989
- b(t, "An initializer", "be", !0), i.push(t);
992
+ b(t, "An initializer", "be", true), i.push(t);
990
993
  }.bind(null, A)
991
994
  };
992
995
  if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = {
@@ -1010,8 +1013,8 @@ function _applyDecs2311(e, t, n, r, o, i) {
1010
1013
  }
1011
1014
  function w(e) {
1012
1015
  return m(e, d, {
1013
- configurable: !0,
1014
- enumerable: !0,
1016
+ configurable: true,
1017
+ enumerable: true,
1015
1018
  value: a
1016
1019
  });
1017
1020
  }
@@ -1057,7 +1060,7 @@ function _toPrimitive$1(t, r) {
1057
1060
  if ("object" != typeof t || !t) return t;
1058
1061
  var e = t[Symbol.toPrimitive];
1059
1062
  if (void 0 !== e) {
1060
- var i = e.call(t, r || "default");
1063
+ var i = e.call(t, r);
1061
1064
  if ("object" != typeof i) return i;
1062
1065
  throw new TypeError("@@toPrimitive must return a primitive value.");
1063
1066
  }
@@ -1325,12 +1328,12 @@ function _arrayLikeToArray(r, a) {
1325
1328
  function _defineProperties(e, r) {
1326
1329
  for (var t = 0; t < r.length; t++) {
1327
1330
  var o = r[t];
1328
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
1331
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
1329
1332
  }
1330
1333
  }
1331
1334
  function _createClass(e, r, t) {
1332
1335
  return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
1333
- writable: !1
1336
+ writable: false
1334
1337
  }), e;
1335
1338
  }
1336
1339
  function _createForOfIteratorHelperLoose(r, e) {
@@ -1341,9 +1344,9 @@ function _createForOfIteratorHelperLoose(r, e) {
1341
1344
  var o = 0;
1342
1345
  return function () {
1343
1346
  return o >= r.length ? {
1344
- done: !0
1347
+ done: true
1345
1348
  } : {
1346
- done: !1,
1349
+ done: false,
1347
1350
  value: r[o++]
1348
1351
  };
1349
1352
  };
@@ -1517,15 +1520,9 @@ function createAtom(name, onBecomeObservedHandler, onBecomeUnobservedHandler) {
1517
1520
  }
1518
1521
  return atom;
1519
1522
  }
1520
- function identityComparer(a, b) {
1521
- return a === b;
1522
- }
1523
1523
  function structuralComparer(a, b) {
1524
1524
  return deepEqual(a, b);
1525
1525
  }
1526
- function shallowComparer(a, b) {
1527
- return deepEqual(a, b, 1);
1528
- }
1529
1526
  function defaultComparer(a, b) {
1530
1527
  if (Object.is) {
1531
1528
  return Object.is(a, b);
@@ -1533,11 +1530,8 @@ function defaultComparer(a, b) {
1533
1530
  return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
1534
1531
  }
1535
1532
  var comparer = {
1536
- identity: identityComparer,
1537
1533
  structural: structuralComparer,
1538
- "default": defaultComparer,
1539
- shallow: shallowComparer
1540
- };
1534
+ "default": defaultComparer};
1541
1535
  function deepEnhancer(v, _, name) {
1542
1536
  if (isObservable(v)) {
1543
1537
  return v;
@@ -1928,7 +1922,8 @@ function make_$5(adm, key, descriptor, source) {
1928
1922
  return computed.make_(adm, key, descriptor, source);
1929
1923
  }
1930
1924
  if (descriptor.set) {
1931
- var set = createAction(key.toString(), descriptor.set);
1925
+ var set = isAction(descriptor.set) ? descriptor.set
1926
+ : createAction(key.toString(), descriptor.set);
1932
1927
  if (source === adm.target_) {
1933
1928
  return adm.defineProperty_(key, {
1934
1929
  configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,
@@ -2249,12 +2244,13 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
2249
2244
  _this.equals = equals;
2250
2245
  _this.value_ = enhancer(value, undefined, name_);
2251
2246
  if (process.env.NODE_ENV !== "production" && notifySpy && isSpyEnabled()) {
2247
+ var _this$value_;
2252
2248
  spyReport({
2253
2249
  type: CREATE,
2254
2250
  object: _this,
2255
2251
  observableKind: "value",
2256
2252
  debugObjectName: _this.name_,
2257
- newValue: "" + _this.value_
2253
+ newValue: "" + ((_this$value_ = _this.value_) == null ? void 0 : _this$value_.toString())
2258
2254
  });
2259
2255
  }
2260
2256
  return _this;
@@ -2408,7 +2404,7 @@ var ComputedValue = /*#__PURE__*/function () {
2408
2404
  });
2409
2405
  }
2410
2406
  }
2411
- ;
2407
+ ;
2412
2408
  _proto.get = function get() {
2413
2409
  if (this.isComputing) {
2414
2410
  die(32, this.name_, this.derivation);
@@ -3104,6 +3100,9 @@ var Reaction = /*#__PURE__*/function () {
3104
3100
  };
3105
3101
  abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
3106
3102
  dispose[$mobx] = this;
3103
+ if ("dispose" in Symbol && typeof Symbol.dispose === "symbol") {
3104
+ dispose[Symbol.dispose] = dispose;
3105
+ }
3107
3106
  return dispose;
3108
3107
  };
3109
3108
  _proto.toString = function toString() {
@@ -4665,6 +4664,7 @@ var ObservableSet = /*#__PURE__*/function () {
4665
4664
  if (!change) {
4666
4665
  return this;
4667
4666
  }
4667
+ value = change.newValue;
4668
4668
  }
4669
4669
  if (!this.has(value)) {
4670
4670
  transaction(function () {
@@ -4736,19 +4736,18 @@ var ObservableSet = /*#__PURE__*/function () {
4736
4736
  return this.data_.has(this.dehanceValue_(value));
4737
4737
  };
4738
4738
  _proto.entries = function entries() {
4739
- var nextIndex = 0;
4740
- var keys = Array.from(this.keys());
4741
- var values = Array.from(this.values());
4739
+ var values = this.values();
4742
4740
  return makeIterableForSet({
4743
4741
  next: function next() {
4744
- var index = nextIndex;
4745
- nextIndex += 1;
4746
- return index < values.length ? {
4747
- value: [keys[index], values[index]],
4748
- done: false
4742
+ var _values$next = values.next(),
4743
+ value = _values$next.value,
4744
+ done = _values$next.done;
4745
+ return !done ? {
4746
+ value: [value, value],
4747
+ done: done
4749
4748
  } : {
4750
4749
  value: undefined,
4751
- done: true
4750
+ done: done
4752
4751
  };
4753
4752
  }
4754
4753
  });
@@ -4759,16 +4758,18 @@ var ObservableSet = /*#__PURE__*/function () {
4759
4758
  _proto.values = function values() {
4760
4759
  this.atom_.reportObserved();
4761
4760
  var self = this;
4762
- var nextIndex = 0;
4763
- var observableValues = Array.from(this.data_.values());
4761
+ var values = this.data_.values();
4764
4762
  return makeIterableForSet({
4765
4763
  next: function next() {
4766
- return nextIndex < observableValues.length ? {
4767
- value: self.dehanceValue_(observableValues[nextIndex++]),
4768
- done: false
4764
+ var _values$next2 = values.next(),
4765
+ value = _values$next2.value,
4766
+ done = _values$next2.done;
4767
+ return !done ? {
4768
+ value: self.dehanceValue_(value),
4769
+ done: done
4769
4770
  } : {
4770
4771
  value: undefined,
4771
- done: true
4772
+ done: done
4772
4773
  };
4773
4774
  }
4774
4775
  });
@@ -4984,7 +4985,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4984
4985
  }, this.defaultAnnotation_, proxyTrap);
4985
4986
  }
4986
4987
  }
4987
- ;
4988
+ ;
4988
4989
  _proto.has_ = function has_(key) {
4989
4990
  if (!globalState.trackingDerivation) {
4990
4991
  return key in this.target_;
@@ -5090,7 +5091,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5090
5091
  }
5091
5092
  return true;
5092
5093
  }
5093
- ;
5094
+ ;
5094
5095
  _proto.defineObservableProperty_ = function defineObservableProperty_(key, value, enhancer, proxyTrap) {
5095
5096
  if (proxyTrap === void 0) {
5096
5097
  proxyTrap = false;
@@ -5136,7 +5137,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5136
5137
  }
5137
5138
  return true;
5138
5139
  }
5139
- ;
5140
+ ;
5140
5141
  _proto.defineComputedProperty_ = function defineComputedProperty_(key, options, proxyTrap) {
5141
5142
  if (proxyTrap === void 0) {
5142
5143
  proxyTrap = false;
@@ -5646,13 +5647,12 @@ function eq(a, b, depth, aStack, bStack) {
5646
5647
  }
5647
5648
  } else {
5648
5649
  var keys = Object.keys(a);
5649
- var key;
5650
- length = keys.length;
5651
- if (Object.keys(b).length !== length) {
5650
+ var _length = keys.length;
5651
+ if (Object.keys(b).length !== _length) {
5652
5652
  return false;
5653
5653
  }
5654
- while (length--) {
5655
- key = keys[length];
5654
+ for (var i = 0; i < _length; i++) {
5655
+ var key = keys[i];
5656
5656
  if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) {
5657
5657
  return false;
5658
5658
  }
@@ -5704,6 +5704,25 @@ if (typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === "object") {
5704
5704
  });
5705
5705
  }
5706
5706
 
5707
+ let AssetLevel = /*#__PURE__*/function (AssetLevel) {
5708
+ AssetLevel[AssetLevel["Environment"] = 1] = "Environment";
5709
+ AssetLevel[AssetLevel["Library"] = 2] = "Library";
5710
+ AssetLevel[AssetLevel["Theme"] = 3] = "Theme";
5711
+ AssetLevel[AssetLevel["Runtime"] = 4] = "Runtime";
5712
+ AssetLevel[AssetLevel["Components"] = 5] = "Components";
5713
+ AssetLevel[AssetLevel["App"] = 6] = "App";
5714
+ return AssetLevel;
5715
+ }({});
5716
+ const AssetLevels = [AssetLevel.Environment, AssetLevel.Library, AssetLevel.Theme, AssetLevel.Runtime, AssetLevel.Components, AssetLevel.App];
5717
+ let AssetType = /*#__PURE__*/function (AssetType) {
5718
+ AssetType["JSUrl"] = "jsUrl";
5719
+ AssetType["CSSUrl"] = "cssUrl";
5720
+ AssetType["CSSText"] = "cssText";
5721
+ AssetType["JSText"] = "jsText";
5722
+ AssetType["Bundle"] = "bundle";
5723
+ return AssetType;
5724
+ }({});
5725
+
5707
5726
  let TRANSFORM_STAGE = /*#__PURE__*/function (TRANSFORM_STAGE) {
5708
5727
  TRANSFORM_STAGE["RENDER"] = "render";
5709
5728
  TRANSFORM_STAGE["SERIALIZE"] = "serialize";
@@ -5922,6 +5941,228 @@ class Session {
5922
5941
  }
5923
5942
  }
5924
5943
 
5944
+ let _initProto$l, _init_type, _init_extra_type, _itemsDecs$1, _init_items, _init_extra_items;
5945
+ const EXTRA_KEY_PREFIX = '___';
5946
+ const getConvertedExtraKey = key => {
5947
+ if (!key) {
5948
+ return '';
5949
+ }
5950
+ let _key = key;
5951
+ if (key.indexOf('.') > 0) {
5952
+ _key = key.split('.')[0];
5953
+ }
5954
+ return EXTRA_KEY_PREFIX + _key + EXTRA_KEY_PREFIX + key.slice(_key.length);
5955
+ };
5956
+ const getOriginalExtraKey = key => {
5957
+ return key.replace(new RegExp(`${EXTRA_KEY_PREFIX}`, 'g'), '');
5958
+ };
5959
+ const isExtraKey = key => {
5960
+ return key.startsWith(EXTRA_KEY_PREFIX);
5961
+ };
5962
+ class Props {
5963
+ static {
5964
+ [_init_type, _init_extra_type, _init_items, _init_extra_items, _initProto$l] = _applyDecs2311(this, [], [[observable, 1, "type"], [_itemsDecs$1, 17, "items"], [computed, 3, "maps"], [computed, 3, "size"], [action, 2, "import"], [action, 2, "purge"], [action, 2, "add"]]).e;
5965
+ }
5966
+ id = (_initProto$l(this), uniqueId('props'));
5967
+ path = [];
5968
+ getNode() {
5969
+ return this.owner;
5970
+ }
5971
+ get props() {
5972
+ return this;
5973
+ }
5974
+ getProps() {
5975
+ return this.props;
5976
+ }
5977
+ #A = _init_type(this, 'map');
5978
+ get type() {
5979
+ return this.#A;
5980
+ }
5981
+ set type(v) {
5982
+ this.#A = v;
5983
+ }
5984
+ #B = (_init_extra_type(this), _init_items(this, []));
5985
+ get items() {
5986
+ return this.#B;
5987
+ }
5988
+ set items(v) {
5989
+ this.#B = v;
5990
+ }
5991
+ get maps() {
5992
+ const maps = new Map();
5993
+ if (this.items.length > 0) {
5994
+ this.items.forEach(prop => {
5995
+ if (prop.key) {
5996
+ maps.set(prop.key, prop);
5997
+ }
5998
+ });
5999
+ }
6000
+ return maps;
6001
+ }
6002
+ get size() {
6003
+ return this.items.length;
6004
+ }
6005
+ constructor(owner, props, extras) {
6006
+ this.owner = owner;
6007
+ if (props != null) {
6008
+ this.items = Object.keys(props).map(key => new Prop(this, key, props[key]));
6009
+ }
6010
+ if (extras) {
6011
+ Object.keys(extras).forEach(key => {
6012
+ this.items.push(new Prop(this, getConvertedExtraKey(key), extras[key]));
6013
+ });
6014
+ }
6015
+ }
6016
+ import(props, extras) {
6017
+ const originItems = this.items;
6018
+ if (props != null) {
6019
+ this.type = 'map';
6020
+ this.items = Object.keys(props).map(key => new Prop(this, key, props[key]));
6021
+ } else {
6022
+ this.type = 'map';
6023
+ this.items = [];
6024
+ }
6025
+ if (extras) {
6026
+ Object.keys(extras).forEach(key => {
6027
+ this.items.push(new Prop(this, getConvertedExtraKey(key), extras[key]));
6028
+ });
6029
+ }
6030
+ originItems.forEach(item => item.purge());
6031
+ }
6032
+ export(stage = TRANSFORM_STAGE.SAVE) {
6033
+ if (this.items.length < 1) {
6034
+ return {};
6035
+ }
6036
+ const props = {};
6037
+ const extras = {};
6038
+ this.items.forEach(item => {
6039
+ const key = item.key;
6040
+ if (key == null || item.isUnset()) return;
6041
+ const value = item.export(stage);
6042
+ if (value != null) {
6043
+ if (typeof key === 'string' && isExtraKey(key)) {
6044
+ extras[getOriginalExtraKey(key)] = value;
6045
+ } else {
6046
+ props[key] = value;
6047
+ }
6048
+ }
6049
+ });
6050
+ return {
6051
+ props,
6052
+ extras
6053
+ };
6054
+ }
6055
+ merge(value, extras) {
6056
+ Object.keys(value).forEach(key => {
6057
+ this.query(key, true).setValue(value[key]);
6058
+ this.query(key, true).initItems();
6059
+ });
6060
+ if (extras) {
6061
+ Object.keys(extras).forEach(key => {
6062
+ this.query(getConvertedExtraKey(key), true).setValue(extras[key]);
6063
+ this.query(getConvertedExtraKey(key), true).initItems();
6064
+ });
6065
+ }
6066
+ }
6067
+ purged = (_init_extra_items(this), false);
6068
+ purge() {
6069
+ if (this.purged) {
6070
+ return;
6071
+ }
6072
+ this.purged = true;
6073
+ for (const item of this.items) {
6074
+ item.purge();
6075
+ }
6076
+ }
6077
+ get(path, createIfNone = false) {
6078
+ const {
6079
+ entry,
6080
+ nest
6081
+ } = splitPath(path);
6082
+ let prop = this.maps.get(entry);
6083
+ if (!prop && createIfNone) {
6084
+ prop = this.add(entry, UNSET$1);
6085
+ }
6086
+ if (prop) {
6087
+ return nest ? prop.get(nest, createIfNone) : prop;
6088
+ }
6089
+ return null;
6090
+ }
6091
+ query(path, createIfNone = true) {
6092
+ return this.get(path, createIfNone);
6093
+ }
6094
+ getProp(path, createIfNone = true) {
6095
+ return this.query(path, createIfNone) || null;
6096
+ }
6097
+ getPropValue(path) {
6098
+ return this.getProp(path, false)?.value;
6099
+ }
6100
+ setPropValue(path, value) {
6101
+ this.getProp(path, true).setValue(value);
6102
+ }
6103
+ delete(prop) {
6104
+ const index = this.items.indexOf(prop);
6105
+ if (index > -1) {
6106
+ this.items.splice(index, 1);
6107
+ prop.purge();
6108
+ }
6109
+ }
6110
+ deleteKey(key) {
6111
+ this.items = this.items.filter((item, i) => {
6112
+ if (item.key === key) {
6113
+ item.purge();
6114
+ this.items.splice(i, 1);
6115
+ return false;
6116
+ }
6117
+ return true;
6118
+ });
6119
+ }
6120
+ add(key, value) {
6121
+ const prop = new Prop(this, key, value);
6122
+ this.items.push(prop);
6123
+ return prop;
6124
+ }
6125
+ has(key) {
6126
+ return this.maps.has(key);
6127
+ }
6128
+ forEach(fn) {
6129
+ for (const item of this.items) {
6130
+ fn(item, item.key);
6131
+ }
6132
+ }
6133
+ map(fn) {
6134
+ return this.items.map(item => {
6135
+ return fn(item, item.key);
6136
+ });
6137
+ }
6138
+ filter(fn) {
6139
+ return this.items.filter(item => {
6140
+ return fn(item, item.key);
6141
+ });
6142
+ }
6143
+ [(_itemsDecs$1 = [observable, observable.shallow], Symbol.iterator)]() {
6144
+ let index = 0;
6145
+ const {
6146
+ items
6147
+ } = this;
6148
+ const length = items.length || 0;
6149
+ return {
6150
+ next() {
6151
+ if (index < length) {
6152
+ return {
6153
+ value: items[index++],
6154
+ done: false
6155
+ };
6156
+ }
6157
+ return {
6158
+ value: undefined,
6159
+ done: true
6160
+ };
6161
+ }
6162
+ };
6163
+ }
6164
+ }
6165
+
5925
6166
  const propertyNameRequiresQuotes = propertyName => {
5926
6167
  try {
5927
6168
  const context = {
@@ -6084,8 +6325,8 @@ const valueToSource = (value, {
6084
6325
  }
6085
6326
  };
6086
6327
 
6087
- let _initProto$i, _keyDecs, _init_key, _init_extra_key, _valueDecs, _init__value, _init_extra__value, _typeDecs, _init__type, _init_extra__type, _itemsDecs$1, _init__items, _init_extra__items, _mapsDecs, _init__maps, _init_extra__maps, _purgedDecs, _init_purged, _init_extra_purged;
6088
- const UNSET = Symbol.for('unset');
6328
+ let _initProto$k, _keyDecs, _init_key, _init_extra_key, _valueDecs, _init__value, _init_extra__value, _typeDecs, _init__type, _init_extra__type, _itemsDecs, _init__items, _init_extra__items, _mapsDecs, _init__maps, _init_extra__maps, _purgedDecs, _init_purged, _init_extra_purged;
6329
+ const UNSET$1 = Symbol.for('unset');
6089
6330
  const isJSExpression = data => {
6090
6331
  if (!isObject$1(data)) {
6091
6332
  return false;
@@ -6100,9 +6341,9 @@ function isJSFunction(data) {
6100
6341
  }
6101
6342
  class Prop {
6102
6343
  static {
6103
- [_init_key, _init_extra_key, _init__value, _init_extra__value, _init__type, _init_extra__type, _init__items, _init_extra__items, _init__maps, _init_extra__maps, _init_purged, _init_extra_purged, _initProto$i] = _applyDecs2311(this, [], [[_keyDecs, 17, "key"], [_valueDecs, 17, "_value"], [computed, 3, "value"], [computed, 3, "code"], [_typeDecs, 17, "_type"], [_itemsDecs$1, 17, "_items"], [_mapsDecs, 17, "_maps"], [computed, 3, "items"], [computed, 3, "maps"], [action, 2, "initItems"], [_purgedDecs, 17, "purged"], [action, 2, "purge"], [action, 2, "remove"], [action, 2, "dispose"], [action, 2, "unset"], [action, 2, "setValue"], [action, 2, "set"], [action, 2, "delete"], [action, 2, "add"], [action, 2, "getPropValue"], [action, 2, "setPropValue"], [action, 2, "clearPropValue"], [action, 2, "forEach"], [action, 2, "map"]]).e;
6344
+ [_init_key, _init_extra_key, _init__value, _init_extra__value, _init__type, _init_extra__type, _init__items, _init_extra__items, _init__maps, _init_extra__maps, _init_purged, _init_extra_purged, _initProto$k] = _applyDecs2311(this, [], [[_keyDecs, 17, "key"], [_valueDecs, 17, "_value"], [computed, 3, "value"], [computed, 3, "code"], [_typeDecs, 17, "_type"], [_itemsDecs, 17, "_items"], [_mapsDecs, 17, "_maps"], [computed, 3, "items"], [computed, 3, "maps"], [action, 2, "initItems"], [_purgedDecs, 17, "purged"], [action, 2, "purge"], [action, 2, "remove"], [action, 2, "dispose"], [action, 2, "unset"], [action, 2, "setValue"], [action, 2, "set"], [action, 2, "delete"], [action, 2, "add"], [action, 2, "getPropValue"], [action, 2, "setPropValue"], [action, 2, "clearPropValue"], [action, 2, "forEach"], [action, 2, "map"]]).e;
6104
6345
  }
6105
- isProp = (_initProto$i(this), true);
6346
+ isProp = (_initProto$k(this), true);
6106
6347
  id = uniqueId('prop');
6107
6348
  #A = _init_key(this);
6108
6349
  get key() {
@@ -6118,7 +6359,7 @@ class Prop {
6118
6359
  getProps() {
6119
6360
  return this.props;
6120
6361
  }
6121
- #B = _init__value(this, UNSET);
6362
+ #B = _init__value(this, UNSET$1);
6122
6363
  get _value() {
6123
6364
  return this.#B;
6124
6365
  }
@@ -6201,13 +6442,13 @@ class Prop {
6201
6442
  get size() {
6202
6443
  return this.items?.length || 0;
6203
6444
  }
6204
- constructor(parent, key, value = UNSET) {
6445
+ constructor(parent, key, value = UNSET$1) {
6205
6446
  this.parent = parent;
6206
6447
  _init_extra_purged(this);
6207
6448
  this.owner = parent.owner;
6208
6449
  this.props = parent.props;
6209
6450
  this.key = key;
6210
- if (value !== UNSET) {
6451
+ if (value !== UNSET$1) {
6211
6452
  this.setValue(value);
6212
6453
  }
6213
6454
  this.initItems();
@@ -6418,7 +6659,7 @@ class Prop {
6418
6659
  return nest ? prop.get(nest, createIfNone) : prop;
6419
6660
  }
6420
6661
  if (createIfNone) {
6421
- prop = new Prop(this, entry, UNSET);
6662
+ prop = new Prop(this, entry, UNSET$1);
6422
6663
  this.set(entry, prop, true);
6423
6664
  if (nest) {
6424
6665
  return prop.get(nest, true);
@@ -6548,7 +6789,7 @@ class Prop {
6548
6789
  return isMap ? fn(item, item.key) : fn(item, index);
6549
6790
  });
6550
6791
  }
6551
- [(_keyDecs = [observable, observable.ref], _valueDecs = [observable, observable.ref], _typeDecs = [observable, observable.ref], _itemsDecs$1 = [observable, observable.shallow], _mapsDecs = [observable, observable.shallow], _purgedDecs = [observable, observable.ref], Symbol.iterator)]() {
6792
+ [(_keyDecs = [observable, observable.ref], _valueDecs = [observable, observable.ref], _typeDecs = [observable, observable.ref], _itemsDecs = [observable, observable.shallow], _mapsDecs = [observable, observable.shallow], _purgedDecs = [observable, observable.ref], Symbol.iterator)]() {
6552
6793
  let index = 0;
6553
6794
  const {
6554
6795
  items
@@ -6601,239 +6842,17 @@ function isValidArrayIndex(key, limit = -1) {
6601
6842
  return n >= 0 && Math.floor(n) === n && Number.isFinite(n) && (limit < 0 || n < limit);
6602
6843
  }
6603
6844
 
6604
- let _initProto$h, _init_type, _init_extra_type, _itemsDecs, _init_items, _init_extra_items;
6605
- const EXTRA_KEY_PREFIX = '___';
6606
- const getConvertedExtraKey = key => {
6607
- if (!key) {
6608
- return '';
6845
+ let _initProto$j, _init_children, _init_extra_children;
6846
+ let NODE_CHILDREN_EVENT = /*#__PURE__*/function (NODE_CHILDREN_EVENT) {
6847
+ NODE_CHILDREN_EVENT["CHANGE"] = "nodeChildren:change";
6848
+ NODE_CHILDREN_EVENT["INSERT"] = "nodeChildren:insert";
6849
+ return NODE_CHILDREN_EVENT;
6850
+ }({});
6851
+ class NodeChildren {
6852
+ static {
6853
+ [_init_children, _init_extra_children, _initProto$j] = _applyDecs2311(this, [], [[[observable, observable.shallow], 17, "children"], [computed, 3, "size"], [action, 2, "import"], [action, 2, "remove"], [action, 2, "purge"], [action, 2, "internalUnlinkChild"], [action, 2, "internalDelete"], [action, 2, "internalInsert"], [action, 2, "mergeChildren"]]).e;
6609
6854
  }
6610
- let _key = key;
6611
- if (key.indexOf('.') > 0) {
6612
- _key = key.split('.')[0];
6613
- }
6614
- return EXTRA_KEY_PREFIX + _key + EXTRA_KEY_PREFIX + key.slice(_key.length);
6615
- };
6616
- const getOriginalExtraKey = key => {
6617
- return key.replace(new RegExp(`${EXTRA_KEY_PREFIX}`, 'g'), '');
6618
- };
6619
- const isExtraKey = key => {
6620
- return key.startsWith(EXTRA_KEY_PREFIX);
6621
- };
6622
- class Props {
6623
- static {
6624
- [_init_type, _init_extra_type, _init_items, _init_extra_items, _initProto$h] = _applyDecs2311(this, [], [[observable, 1, "type"], [_itemsDecs, 17, "items"], [computed, 3, "maps"], [computed, 3, "size"], [action, 2, "import"], [action, 2, "purge"], [action, 2, "add"]]).e;
6625
- }
6626
- id = (_initProto$h(this), uniqueId('props'));
6627
- path = [];
6628
- getNode() {
6629
- return this.owner;
6630
- }
6631
- get props() {
6632
- return this;
6633
- }
6634
- getProps() {
6635
- return this.props;
6636
- }
6637
- #A = _init_type(this, 'map');
6638
- get type() {
6639
- return this.#A;
6640
- }
6641
- set type(v) {
6642
- this.#A = v;
6643
- }
6644
- #B = (_init_extra_type(this), _init_items(this, []));
6645
- get items() {
6646
- return this.#B;
6647
- }
6648
- set items(v) {
6649
- this.#B = v;
6650
- }
6651
- get maps() {
6652
- const maps = new Map();
6653
- if (this.items.length > 0) {
6654
- this.items.forEach(prop => {
6655
- if (prop.key) {
6656
- maps.set(prop.key, prop);
6657
- }
6658
- });
6659
- }
6660
- return maps;
6661
- }
6662
- get size() {
6663
- return this.items.length;
6664
- }
6665
- constructor(owner, props, extras) {
6666
- this.owner = owner;
6667
- if (props != null) {
6668
- this.items = Object.keys(props).map(key => new Prop(this, key, props[key]));
6669
- }
6670
- if (extras) {
6671
- Object.keys(extras).forEach(key => {
6672
- this.items.push(new Prop(this, getConvertedExtraKey(key), extras[key]));
6673
- });
6674
- }
6675
- }
6676
- import(props, extras) {
6677
- const originItems = this.items;
6678
- if (props != null) {
6679
- this.type = 'map';
6680
- this.items = Object.keys(props).map(key => new Prop(this, key, props[key]));
6681
- } else {
6682
- this.type = 'map';
6683
- this.items = [];
6684
- }
6685
- if (extras) {
6686
- Object.keys(extras).forEach(key => {
6687
- this.items.push(new Prop(this, getConvertedExtraKey(key), extras[key]));
6688
- });
6689
- }
6690
- originItems.forEach(item => item.purge());
6691
- }
6692
- export(stage = TRANSFORM_STAGE.SAVE) {
6693
- if (this.items.length < 1) {
6694
- return {};
6695
- }
6696
- const props = {};
6697
- const extras = {};
6698
- this.items.forEach(item => {
6699
- const key = item.key;
6700
- if (key == null || item.isUnset()) return;
6701
- const value = item.export(stage);
6702
- if (value != null) {
6703
- if (typeof key === 'string' && isExtraKey(key)) {
6704
- extras[getOriginalExtraKey(key)] = value;
6705
- } else {
6706
- props[key] = value;
6707
- }
6708
- }
6709
- });
6710
- return {
6711
- props,
6712
- extras
6713
- };
6714
- }
6715
- merge(value, extras) {
6716
- Object.keys(value).forEach(key => {
6717
- this.query(key, true).setValue(value[key]);
6718
- this.query(key, true).initItems();
6719
- });
6720
- if (extras) {
6721
- Object.keys(extras).forEach(key => {
6722
- this.query(getConvertedExtraKey(key), true).setValue(extras[key]);
6723
- this.query(getConvertedExtraKey(key), true).initItems();
6724
- });
6725
- }
6726
- }
6727
- purged = (_init_extra_items(this), false);
6728
- purge() {
6729
- if (this.purged) {
6730
- return;
6731
- }
6732
- this.purged = true;
6733
- for (const item of this.items) {
6734
- item.purge();
6735
- }
6736
- }
6737
- get(path, createIfNone = false) {
6738
- const {
6739
- entry,
6740
- nest
6741
- } = splitPath(path);
6742
- let prop = this.maps.get(entry);
6743
- if (!prop && createIfNone) {
6744
- prop = this.add(entry, UNSET);
6745
- }
6746
- if (prop) {
6747
- return nest ? prop.get(nest, createIfNone) : prop;
6748
- }
6749
- return null;
6750
- }
6751
- query(path, createIfNone = true) {
6752
- return this.get(path, createIfNone);
6753
- }
6754
- getProp(path, createIfNone = true) {
6755
- return this.query(path, createIfNone) || null;
6756
- }
6757
- getPropValue(path) {
6758
- return this.getProp(path, false)?.value;
6759
- }
6760
- setPropValue(path, value) {
6761
- this.getProp(path, true).setValue(value);
6762
- }
6763
- delete(prop) {
6764
- const index = this.items.indexOf(prop);
6765
- if (index > -1) {
6766
- this.items.splice(index, 1);
6767
- prop.purge();
6768
- }
6769
- }
6770
- deleteKey(key) {
6771
- this.items = this.items.filter((item, i) => {
6772
- if (item.key === key) {
6773
- item.purge();
6774
- this.items.splice(i, 1);
6775
- return false;
6776
- }
6777
- return true;
6778
- });
6779
- }
6780
- add(key, value) {
6781
- const prop = new Prop(this, key, value);
6782
- this.items.push(prop);
6783
- return prop;
6784
- }
6785
- has(key) {
6786
- return this.maps.has(key);
6787
- }
6788
- forEach(fn) {
6789
- for (const item of this.items) {
6790
- fn(item, item.key);
6791
- }
6792
- }
6793
- map(fn) {
6794
- return this.items.map(item => {
6795
- return fn(item, item.key);
6796
- });
6797
- }
6798
- filter(fn) {
6799
- return this.items.filter(item => {
6800
- return fn(item, item.key);
6801
- });
6802
- }
6803
- [(_itemsDecs = [observable, observable.shallow], Symbol.iterator)]() {
6804
- let index = 0;
6805
- const {
6806
- items
6807
- } = this;
6808
- const length = items.length || 0;
6809
- return {
6810
- next() {
6811
- if (index < length) {
6812
- return {
6813
- value: items[index++],
6814
- done: false
6815
- };
6816
- }
6817
- return {
6818
- value: undefined,
6819
- done: true
6820
- };
6821
- }
6822
- };
6823
- }
6824
- }
6825
-
6826
- let _initProto$g, _init_children, _init_extra_children;
6827
- let NODE_CHILDREN_EVENT = /*#__PURE__*/function (NODE_CHILDREN_EVENT) {
6828
- NODE_CHILDREN_EVENT["CHANGE"] = "nodeChildren:change";
6829
- NODE_CHILDREN_EVENT["INSERT"] = "nodeChildren:insert";
6830
- return NODE_CHILDREN_EVENT;
6831
- }({});
6832
- class NodeChildren {
6833
- static {
6834
- [_init_children, _init_extra_children, _initProto$g] = _applyDecs2311(this, [], [[[observable, observable.shallow], 17, "children"], [computed, 3, "size"], [action, 2, "import"], [action, 2, "remove"], [action, 2, "purge"], [action, 2, "internalUnlinkChild"], [action, 2, "internalDelete"], [action, 2, "internalInsert"], [action, 2, "mergeChildren"]]).e;
6835
- }
6836
- emitter = (_initProto$g(this), createEventBus('NodeChildren'));
6855
+ emitter = (_initProto$j(this), createEventBus('NodeChildren'));
6837
6856
  getNode() {
6838
6857
  return this.owner;
6839
6858
  }
@@ -7099,7 +7118,7 @@ class NodeChildren {
7099
7118
  }
7100
7119
  }
7101
7120
 
7102
- let _initProto$f, _init__parent, _init_extra__parent;
7121
+ let _initProto$i, _init__parent, _init_extra__parent;
7103
7122
  let NODE_EVENT = /*#__PURE__*/function (NODE_EVENT) {
7104
7123
  NODE_EVENT["ADD"] = "node:add";
7105
7124
  NODE_EVENT["REMOVE"] = "node:remove";
@@ -7110,9 +7129,9 @@ let NODE_EVENT = /*#__PURE__*/function (NODE_EVENT) {
7110
7129
  }({});
7111
7130
  let Node$1 = class Node {
7112
7131
  static {
7113
- [_init__parent, _init_extra__parent, _initProto$f] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_parent"], [computed, 3, "index"], [computed, 3, "zLevel"], [computed, 3, "title"], [computed, 3, "isLinked"], [action, 2, "remove"], [computed, 3, "componentMeta"], [computed, 3, "propsData"]]).e;
7132
+ [_init__parent, _init_extra__parent, _initProto$i] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_parent"], [computed, 3, "index"], [computed, 3, "zLevel"], [computed, 3, "title"], [action, 2, "refreshSettingEntry"], [computed, 3, "isLinked"], [action, 2, "remove"], [computed, 3, "componentMeta"], [computed, 3, "propsData"]]).e;
7114
7133
  }
7115
- emitter = (_initProto$f(this), createEventBus('Node'));
7134
+ emitter = (_initProto$i(this), createEventBus('Node'));
7116
7135
  isNode = true;
7117
7136
  #A = _init__parent(this, null);
7118
7137
  get _parent() {
@@ -7164,6 +7183,17 @@ let Node$1 = class Node {
7164
7183
  this._settingEntry = this.document.designer.createSettingEntry([this]);
7165
7184
  return this._settingEntry;
7166
7185
  }
7186
+ refreshSettingEntry() {
7187
+ if (this._settingEntry) {
7188
+ this._settingEntry.purge();
7189
+ this._settingEntry = undefined;
7190
+ }
7191
+ const {
7192
+ settingsManager
7193
+ } = this.document.designer;
7194
+ settingsManager._sessionId = '';
7195
+ settingsManager.setup([this]);
7196
+ }
7167
7197
  constructor(document, Schema) {
7168
7198
  this.document = document;
7169
7199
  const {
@@ -7175,10 +7205,10 @@ let Node$1 = class Node {
7175
7205
  } = Schema;
7176
7206
  this.id = id || uniqueId('node');
7177
7207
  this.componentName = componentName;
7178
- this._children = new NodeChildren(this, this.initialChildren(children));
7179
7208
  this.props = new Props(this, props, extras);
7180
7209
  this.props.merge(this.upgradeProps(this.initProps(props || {})), this.upgradeProps(extras));
7181
7210
  this.initBuiltinProps();
7211
+ this._children = new NodeChildren(this, this.initialChildren(children));
7182
7212
  this.onVisibleChange(visible => {
7183
7213
  this.document.designer.postEvent(DESIGNER_EVENT.NODE_VISIBLE_CHANGE, this, visible);
7184
7214
  });
@@ -7504,8 +7534,28 @@ let Node$1 = class Node {
7504
7534
  }
7505
7535
  return false;
7506
7536
  }
7537
+ get isRemote() {
7538
+ return this.isRemoteComponent();
7539
+ }
7540
+ get materialUsageKey() {
7541
+ if (this.isRemote) {
7542
+ const version = this.getExtraPropValue('npm.version');
7543
+ return `${this.componentName}@${version}`;
7544
+ }
7545
+ return this.componentName;
7546
+ }
7547
+ isRemoteComponent() {
7548
+ const npm = this.getExtraPropValue('npm');
7549
+ return isRemoteComponent({
7550
+ npm
7551
+ });
7552
+ }
7507
7553
  get componentMeta() {
7508
- return this.document.getComponentMeta(this.componentName);
7554
+ let componentName = this.componentName;
7555
+ if (this.isRemote) {
7556
+ componentName = this.materialUsageKey;
7557
+ }
7558
+ return this.document.getComponentMeta(componentName);
7509
7559
  }
7510
7560
  get propsData() {
7511
7561
  return this.props.export(TRANSFORM_STAGE.SERIALIZE).props || null;
@@ -7749,7 +7799,7 @@ const ensureNode = (node, document) => {
7749
7799
  return nodeInstance;
7750
7800
  };
7751
7801
 
7752
- let _initProto$e, _init__opened, _init_extra__opened, _init__suspended$1, _init_extra__suspended$1, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation;
7802
+ let _initProto$h, _init__opened, _init_extra__opened, _init__suspended$1, _init_extra__suspended$1, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation;
7753
7803
  let DOCUMENT_EVENT = /*#__PURE__*/function (DOCUMENT_EVENT) {
7754
7804
  DOCUMENT_EVENT["ADD"] = "document:add";
7755
7805
  DOCUMENT_EVENT["REMOVE"] = "document:remove";
@@ -7759,9 +7809,9 @@ let DOCUMENT_EVENT = /*#__PURE__*/function (DOCUMENT_EVENT) {
7759
7809
  }({});
7760
7810
  class Document {
7761
7811
  static {
7762
- [_init__opened, _init_extra__opened, _init__suspended$1, _init_extra__suspended$1, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation, _initProto$e] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_opened"], [[observable, observable.ref], 17, "_suspended"], [[observable, observable.shallow], 17, "nodes"], [[observable, observable.ref], 17, "_dropLocation"], [action, 4, "dropLocation"], [action, 2, "import"], [action, 2, "remove"], [action, 2, "purge"], [action, 2, "createNode"], [action, 2, "internalRemoveNode"], [action, 2, "unlinkNode"], [action, 2, "setSuspense"], [action, 2, "open"], [action, 2, "close"]]).e;
7812
+ [_init__opened, _init_extra__opened, _init__suspended$1, _init_extra__suspended$1, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation, _initProto$h] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_opened"], [[observable, observable.ref], 17, "_suspended"], [[observable, observable.shallow], 17, "nodes"], [[observable, observable.ref], 17, "_dropLocation"], [action, 4, "dropLocation"], [action, 2, "import"], [action, 2, "remove"], [action, 2, "purge"], [action, 2, "createNode"], [action, 2, "internalRemoveNode"], [action, 2, "unlinkNode"], [action, 2, "setSuspense"], [action, 2, "open"], [action, 2, "close"]]).e;
7763
7813
  }
7764
- isDocument = (_initProto$e(this), true);
7814
+ isDocument = (_initProto$h(this), true);
7765
7815
  emitter = createEventBus('Document');
7766
7816
  #A = _init__opened(this, false);
7767
7817
  get _opened() {
@@ -7879,6 +7929,11 @@ class Document {
7879
7929
  this.project.removeDocument(this);
7880
7930
  }
7881
7931
  purge() {
7932
+ for (const node of this.nodes) {
7933
+ if (node.componentName) {
7934
+ this.designer.materials.decrementUsage(node.materialUsageKey);
7935
+ }
7936
+ }
7882
7937
  this.rootNode?.purge();
7883
7938
  this.nodes.clear();
7884
7939
  this._nodesMap.clear();
@@ -7889,6 +7944,7 @@ class Document {
7889
7944
  schema.id = undefined;
7890
7945
  }
7891
7946
  let node = null;
7947
+ let isNewNode = false;
7892
7948
  if (schema?.id) {
7893
7949
  node = this.getNode(schema.id);
7894
7950
  if (node && node.componentName === schema.componentName) {
@@ -7902,10 +7958,14 @@ class Document {
7902
7958
  }
7903
7959
  if (!node) {
7904
7960
  node = new Node$1(this, schema);
7961
+ isNewNode = true;
7905
7962
  }
7906
7963
  this.nodes.add(node);
7907
7964
  this._nodesMap.set(node.id, node);
7908
7965
  this.emitter.emit(NODE_EVENT.ADD, node);
7966
+ if (isNewNode && node.componentName) {
7967
+ this.designer.materials.incrementUsage(node.materialUsageKey);
7968
+ }
7909
7969
  return node;
7910
7970
  }
7911
7971
  getNode(id) {
@@ -7940,6 +8000,9 @@ class Document {
7940
8000
  node.remove(true, useMutator);
7941
8001
  }
7942
8002
  unlinkNode(node) {
8003
+ if (node.componentName) {
8004
+ this.designer.materials.decrementUsage(node.materialUsageKey);
8005
+ }
7943
8006
  this.nodes.delete(node);
7944
8007
  this._nodesMap.delete(node.id);
7945
8008
  }
@@ -8007,21 +8070,36 @@ class Document {
8007
8070
  const {
8008
8071
  componentName
8009
8072
  } = node || {};
8010
- if (!existedMap[componentName]) {
8011
- existedMap[componentName] = true;
8012
- componentsMap.push({
8013
- devMode: 'lowCode',
8014
- componentName
8015
- });
8073
+ if (!existedMap[node.materialUsageKey]) {
8074
+ existedMap[node.materialUsageKey] = true;
8075
+ if (node.componentMeta?.npm?.package) {
8076
+ componentsMap.push({
8077
+ ...node.componentMeta.npm,
8078
+ componentName
8079
+ });
8080
+ } else {
8081
+ componentsMap.push({
8082
+ devMode: 'lowCode',
8083
+ componentName
8084
+ });
8085
+ }
8016
8086
  }
8017
8087
  }
8018
8088
  if (Array.isArray(extraComps)) {
8019
8089
  extraComps.forEach(componentName => {
8020
8090
  if (componentName && !existedMap[componentName]) {
8021
- componentsMap.push({
8022
- devMode: 'lowCode',
8023
- componentName
8024
- });
8091
+ const meta = this.getComponentMeta(componentName);
8092
+ if (meta?.npm?.package) {
8093
+ componentsMap.push({
8094
+ ...meta?.npm,
8095
+ componentName
8096
+ });
8097
+ } else {
8098
+ componentsMap.push({
8099
+ devMode: 'lowCode',
8100
+ componentName
8101
+ });
8102
+ }
8025
8103
  }
8026
8104
  });
8027
8105
  }
@@ -8061,7 +8139,7 @@ function isDocument(obj) {
8061
8139
  return obj && obj.isDocument;
8062
8140
  }
8063
8141
 
8064
- let _initProto$d, _init_documents, _init_extra_documents, _init__config, _init_extra__config;
8142
+ let _initProto$g, _init_documents, _init_extra_documents, _init__config, _init_extra__config;
8065
8143
  const logger$5 = createLogger('Project');
8066
8144
  let PROJECT_EVENT = /*#__PURE__*/function (PROJECT_EVENT) {
8067
8145
  PROJECT_EVENT["RENDERER_READY"] = "renderer:ready";
@@ -8070,9 +8148,9 @@ let PROJECT_EVENT = /*#__PURE__*/function (PROJECT_EVENT) {
8070
8148
  }({});
8071
8149
  class Project {
8072
8150
  static {
8073
- [_init_documents, _init_extra_documents, _init__config, _init_extra__config, _initProto$d] = _applyDecs2311(this, [], [[[observable, observable.shallow], 17, "documents"], [computed, 3, "currentDocument"], [observable, 1, "_config"], [computed, 3, "config"], [action, 2, "load"], [action, 2, "unload"], [action, 2, "createDocument"], [action, 2, "removeDocument"]]).e;
8151
+ [_init_documents, _init_extra_documents, _init__config, _init_extra__config, _initProto$g] = _applyDecs2311(this, [], [[[observable, observable.shallow], 17, "documents"], [computed, 3, "currentDocument"], [observable, 1, "_config"], [computed, 3, "config"], [action, 2, "load"], [action, 2, "unload"], [action, 2, "createDocument"], [action, 2, "removeDocument"]]).e;
8074
8152
  }
8075
- emitter = (_initProto$d(this), createEventBus('Project'));
8153
+ emitter = (_initProto$g(this), createEventBus('Project'));
8076
8154
  data = {
8077
8155
  version: '0.0.1',
8078
8156
  componentsMap: [],
@@ -8126,8 +8204,7 @@ class Project {
8126
8204
  if (Array.isArray(curComponentsMap)) {
8127
8205
  curComponentsMap.forEach(item => {
8128
8206
  const found = componentsMap.find(eItem => {
8129
- if (isProCodeComponentType(eItem) && isProCodeComponentType(item) &&
8130
- eItem.componentName === item.componentName) {
8207
+ if (isProCodeComponentType(eItem) && isProCodeComponentType(item) && eItem.package === item.package && eItem.version === item.version && eItem.componentName === item.componentName) {
8131
8208
  return true;
8132
8209
  } else if (isLowCodeComponentType(eItem) && eItem.componentName === item.componentName) {
8133
8210
  return true;
@@ -8337,16 +8414,16 @@ class ActiveTracker {
8337
8414
  }
8338
8415
  }
8339
8416
 
8340
- let _initProto$c, _init__enable, _init_extra__enable, _init__current, _init_extra__current;
8417
+ let _initProto$f, _init__enable, _init_extra__enable, _init__current, _init_extra__current;
8341
8418
  let DETECTING_EVENT = /*#__PURE__*/function (DETECTING_EVENT) {
8342
8419
  DETECTING_EVENT["CHANGE"] = "detecting:change";
8343
8420
  return DETECTING_EVENT;
8344
8421
  }({});
8345
8422
  class Detecting {
8346
8423
  static {
8347
- [_init__enable, _init_extra__enable, _init__current, _init_extra__current, _initProto$c] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_enable"], [action, 4, "enable"], [[observable, observable.ref], 17, "_current"], [action, 2, "capture"], [action, 2, "release"], [action, 2, "leave"]]).e;
8424
+ [_init__enable, _init_extra__enable, _init__current, _init_extra__current, _initProto$f] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_enable"], [action, 4, "enable"], [[observable, observable.ref], 17, "_current"], [action, 2, "capture"], [action, 2, "release"], [action, 2, "leave"]]).e;
8348
8425
  }
8349
- emitter = (_initProto$c(this), createEventBus('Detecting'));
8426
+ emitter = (_initProto$f(this), createEventBus('Detecting'));
8350
8427
  #A = _init__enable(this, true);
8351
8428
  get _enable() {
8352
8429
  return this.#A;
@@ -8402,6 +8479,77 @@ class Detecting {
8402
8479
  }
8403
8480
  }
8404
8481
 
8482
+ const isSimulatorRenderer = obj => {
8483
+ return obj && obj.isSimulatorRenderer;
8484
+ };
8485
+
8486
+ let _init__data, _init_extra__data;
8487
+ const UNSET = Symbol('unset');
8488
+ class ResourceConsumer {
8489
+ static {
8490
+ [_init__data, _init_extra__data] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_data"]]).e;
8491
+ }
8492
+ emitter = createEventBus('ResourceConsumer');
8493
+ #A = _init__data(this, UNSET);
8494
+ get _data() {
8495
+ return this.#A;
8496
+ }
8497
+ set _data(v) {
8498
+ this.#A = v;
8499
+ }
8500
+ _providing = void _init_extra__data(this);
8501
+ _firstConsumed = false;
8502
+ constructor(provider, consumer) {
8503
+ this.consumer = consumer;
8504
+ this._providing = autorun(() => {
8505
+ this._data = provider();
8506
+ });
8507
+ }
8508
+ consume(consumerOrRenderer) {
8509
+ if (this._consuming) {
8510
+ return;
8511
+ }
8512
+ let consumer;
8513
+ if (isSimulatorRenderer(consumerOrRenderer)) {
8514
+ if (!this.consumer) {
8515
+ return;
8516
+ }
8517
+ const rendererConsumer = this.consumer;
8518
+ consumer = data => rendererConsumer(consumerOrRenderer, data);
8519
+ } else {
8520
+ consumer = consumerOrRenderer;
8521
+ }
8522
+ this._consuming = autorun(async () => {
8523
+ if (this._data === UNSET) {
8524
+ return;
8525
+ }
8526
+ await consumer(this._data);
8527
+ if (this.resolveFirst) {
8528
+ this.resolveFirst();
8529
+ } else {
8530
+ this._firstConsumed = true;
8531
+ }
8532
+ });
8533
+ }
8534
+ dispose() {
8535
+ if (this._providing) {
8536
+ this._providing();
8537
+ }
8538
+ if (this._consuming) {
8539
+ this._consuming();
8540
+ }
8541
+ this.emitter.removeAllListeners();
8542
+ }
8543
+ waitFirstConsume() {
8544
+ if (this._firstConsumed) {
8545
+ return Promise.resolve();
8546
+ }
8547
+ return new Promise(resolve => {
8548
+ this.resolveFirst = resolve;
8549
+ });
8550
+ }
8551
+ }
8552
+
8405
8553
  class ScrollTarget {
8406
8554
  get left() {
8407
8555
  return 'scrollX' in this.target ? this.target.scrollX : this.target.scrollLeft;
@@ -8563,13 +8711,13 @@ class Scroller {
8563
8711
  }
8564
8712
  }
8565
8713
 
8566
- let _initProto$b, _init_rect, _init_extra_rect, _init__scale, _init_extra__scale, _init__contentWidth, _init_extra__contentWidth, _init__contentHeight, _init_extra__contentHeight, _init__scrollX, _init_extra__scrollX, _init__scrollY, _init_extra__scrollY, _init__scrolling, _init_extra__scrolling;
8714
+ let _initProto$e, _init_rect, _init_extra_rect, _init__scale, _init_extra__scale, _init__contentWidth, _init_extra__contentWidth, _init__contentHeight, _init_extra__contentHeight, _init__scrollX, _init_extra__scrollX, _init__scrollY, _init_extra__scrollY, _init__scrolling, _init_extra__scrolling;
8567
8715
  const AutoFit = '100%';
8568
8716
  class Viewport {
8569
8717
  static {
8570
- [_init_rect, _init_extra_rect, _init__scale, _init_extra__scale, _init__contentWidth, _init_extra__contentWidth, _init__contentHeight, _init_extra__contentHeight, _init__scrollX, _init_extra__scrollX, _init__scrollY, _init_extra__scrollY, _init__scrolling, _init_extra__scrolling, _initProto$b] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "rect"], [action, 2, "touch"], [computed, 3, "height"], [computed, 3, "width"], [[observable, observable.ref], 17, "_scale"], [computed, 3, "scale"], [action, 4, "scale"], [[observable, observable.ref], 17, "_contentWidth"], [[observable, observable.ref], 17, "_contentHeight"], [computed, 3, "contentHeight"], [computed, 3, "contentWidth"], [[observable, observable.ref], 17, "_scrollX"], [[observable, observable.ref], 17, "_scrollY"], [observable, 1, "_scrolling"]]).e;
8718
+ [_init_rect, _init_extra_rect, _init__scale, _init_extra__scale, _init__contentWidth, _init_extra__contentWidth, _init__contentHeight, _init_extra__contentHeight, _init__scrollX, _init_extra__scrollX, _init__scrollY, _init_extra__scrollY, _init__scrolling, _init_extra__scrolling, _initProto$e] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "rect"], [action, 2, "touch"], [computed, 3, "height"], [computed, 3, "width"], [[observable, observable.ref], 17, "_scale"], [computed, 3, "scale"], [action, 4, "scale"], [[observable, observable.ref], 17, "_contentWidth"], [[observable, observable.ref], 17, "_contentHeight"], [computed, 3, "contentHeight"], [computed, 3, "contentWidth"], [[observable, observable.ref], 17, "_scrollX"], [[observable, observable.ref], 17, "_scrollY"], [observable, 1, "_scrolling"]]).e;
8571
8719
  }
8572
- #A = (_initProto$b(this), _init_rect(this));
8720
+ #A = (_initProto$e(this), _init_rect(this));
8573
8721
  get rect() {
8574
8722
  return this.#A;
8575
8723
  }
@@ -8759,12 +8907,12 @@ class Viewport {
8759
8907
  }
8760
8908
  }
8761
8909
 
8762
- let _initProto$a, _init__props, _init_extra__props, _init__contentWindow, _init_extra__contentWindow, _init__contentDocument, _init_extra__contentDocument, _init__appHelper, _init_extra__appHelper, _init_instancesMap, _init_extra_instancesMap;
8910
+ let _initProto$d, _init__props, _init_extra__props, _init__contentWindow, _init_extra__contentWindow, _init__contentDocument, _init_extra__contentDocument, _init__appHelper, _init_extra__appHelper, _init_instancesMap, _init_extra_instancesMap;
8763
8911
  class Simulator {
8764
8912
  static {
8765
- [_init__props, _init_extra__props, _init__contentWindow, _init_extra__contentWindow, _init__contentDocument, _init_extra__contentDocument, _init__appHelper, _init_extra__appHelper, _init_instancesMap, _init_extra_instancesMap, _initProto$a] = _applyDecs2311(this, [], [[computed, 3, "renderEnv"], [computed, 3, "device"], [computed, 3, "locale"], [computed, 3, "deviceClassName"], [computed, 3, "designMode"], [computed, 3, "dataSourceEngine"], [computed, 3, "deviceStyle"], [computed, 3, "componentsMap"], [[observable, observable.ref], 17, "_props"], [[observable, observable.ref], 17, "_contentWindow"], [[observable, observable.ref], 17, "_contentDocument"], [[observable, observable.ref], 17, "_appHelper"], [observable, 1, "instancesMap"], [action, 2, "setProps"], [action, 2, "set"], [action, 2, "purge"], [action, 2, "mountContentFrame"], [action, 2, "setInstance"]]).e;
8913
+ [_init__props, _init_extra__props, _init__contentWindow, _init_extra__contentWindow, _init__contentDocument, _init_extra__contentDocument, _init__appHelper, _init_extra__appHelper, _init_instancesMap, _init_extra_instancesMap, _initProto$d] = _applyDecs2311(this, [], [[computed, 3, "renderEnv"], [computed, 3, "device"], [computed, 3, "locale"], [computed, 3, "deviceClassName"], [computed, 3, "designMode"], [computed, 3, "dataSourceEngine"], [computed, 3, "componentsAsset"], [computed, 3, "deviceStyle"], [computed, 3, "componentsMap"], [[observable, observable.ref], 17, "_props"], [[observable, observable.ref], 17, "_contentWindow"], [[observable, observable.ref], 17, "_contentDocument"], [[observable, observable.ref], 17, "_appHelper"], [observable, 1, "instancesMap"], [action, 2, "setProps"], [action, 2, "set"], [action, 2, "purge"], [action, 2, "mountContentFrame"], [action, 2, "setInstance"]]).e;
8766
8914
  }
8767
- emitter = (_initProto$a(this), createEventBus('Simulator'));
8915
+ emitter = (_initProto$d(this), createEventBus('Simulator'));
8768
8916
  isSimulator = true;
8769
8917
  autoRender = true;
8770
8918
  get editor() {
@@ -8786,7 +8934,7 @@ class Simulator {
8786
8934
  return this.get('designMode') || 'design';
8787
8935
  }
8788
8936
  get dataSourceEngine() {
8789
- return this.get('dataSourceEngine');
8937
+ return config.get('dataSourceEngine');
8790
8938
  }
8791
8939
  get enableStrictNotFoundMode() {
8792
8940
  return config.get('enableStrictNotFoundMode') ?? false;
@@ -8800,6 +8948,9 @@ class Simulator {
8800
8948
  get faultComponent() {
8801
8949
  return config.get('faultComponent') ?? null;
8802
8950
  }
8951
+ get componentsAsset() {
8952
+ return this.get('componentsAsset');
8953
+ }
8803
8954
  get deviceStyle() {
8804
8955
  return this.get('deviceStyle');
8805
8956
  }
@@ -8903,7 +9054,7 @@ class Simulator {
8903
9054
  rerender() {
8904
9055
  this.renderer?.rerender?.();
8905
9056
  }
8906
- mountContentFrame(iframe) {
9057
+ async mountContentFrame(iframe) {
8907
9058
  if (!iframe || this.iframe === iframe) {
8908
9059
  return;
8909
9060
  }
@@ -8969,10 +9120,11 @@ class Simulator {
8969
9120
  if (onMouseDownHook) {
8970
9121
  onMouseDownHook(downEvent, node);
8971
9122
  }
8972
- const isLeftButton = downEvent.which === 1 || downEvent.button === 0;
9123
+ const isLeftButton = downEvent.button === 0;
8973
9124
  const checkSelect = e => {
8974
9125
  doc.removeEventListener('mouseup', checkSelect, true);
8975
- if (!isShaken(downEvent, e)) {
9126
+ const isLeftButtonSelect = e.button === 0;
9127
+ if (!isShaken(downEvent, e) && isLeftButtonSelect) {
8976
9128
  const {
8977
9129
  id
8978
9130
  } = node;
@@ -9322,6 +9474,9 @@ class Simulator {
9322
9474
  handleAccept({
9323
9475
  container
9324
9476
  }, e) {
9477
+ const {
9478
+ dragObject
9479
+ } = e;
9325
9480
  const document = this.project.currentDocument;
9326
9481
  const {
9327
9482
  rootNode
@@ -9349,16 +9504,12 @@ const getMatched = (elements, selector) => {
9349
9504
  if (!firstQueried) {
9350
9505
  firstQueried = elem.querySelector(selector);
9351
9506
  }
9352
- }
9353
- }
9354
- return firstQueried;
9355
- };
9356
-
9357
- const isSimulatorRenderer = obj => {
9358
- return obj && obj.isSimulatorRenderer;
9507
+ }
9508
+ }
9509
+ return firstQueried;
9359
9510
  };
9360
9511
 
9361
- let _initProto$9, _init__activeSensor, _init_extra__activeSensor, _init__dragging, _init_extra__dragging;
9512
+ let _initProto$c, _init__activeSensor, _init_extra__activeSensor, _init__dragging, _init_extra__dragging;
9362
9513
  let DRAGON_EVENT = /*#__PURE__*/function (DRAGON_EVENT) {
9363
9514
  DRAGON_EVENT["DRAGSTART"] = "dragon:dragstart";
9364
9515
  DRAGON_EVENT["DRAG"] = "dragon:drag";
@@ -9413,9 +9564,9 @@ const getSourceSensor = dragObject => {
9413
9564
  };
9414
9565
  class Dragon {
9415
9566
  static {
9416
- [_init__activeSensor, _init_extra__activeSensor, _init__dragging, _init_extra__dragging, _initProto$9] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_activeSensor"], [[observable, observable.ref], 17, "_dragging"], [action, 2, "boost"], [action, 2, "addSensor"], [action, 2, "removeSensor"]]).e;
9567
+ [_init__activeSensor, _init_extra__activeSensor, _init__dragging, _init_extra__dragging, _initProto$c] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_activeSensor"], [[observable, observable.ref], 17, "_dragging"], [action, 2, "boost"], [action, 2, "addSensor"], [action, 2, "removeSensor"]]).e;
9417
9568
  }
9418
- emitter = (_initProto$9(this), createEventBus('Dragon'));
9569
+ emitter = (_initProto$c(this), createEventBus('Dragon'));
9419
9570
  sensors = [];
9420
9571
  #A = _init__activeSensor(this);
9421
9572
  get _activeSensor() {
@@ -9767,12 +9918,12 @@ class DropLocation {
9767
9918
  }
9768
9919
  }
9769
9920
 
9770
- let _initProto$8, _init__height, _init_extra__height, _init__width, _init_extra__width, _init__left, _init_extra__left, _init__top, _init_extra__top, _init__right, _init_extra__right, _init__bottom, _init_extra__bottom, _init_hasOffset, _init_extra_hasOffset;
9921
+ let _initProto$b, _init__height, _init_extra__height, _init__width, _init_extra__width, _init__left, _init_extra__left, _init__top, _init_extra__top, _init__right, _init_extra__right, _init__bottom, _init_extra__bottom, _init_hasOffset, _init_extra_hasOffset;
9771
9922
  class OffsetObserver {
9772
9923
  static {
9773
- [_init__height, _init_extra__height, _init__width, _init_extra__width, _init__left, _init_extra__left, _init__top, _init_extra__top, _init__right, _init_extra__right, _init__bottom, _init_extra__bottom, _init_hasOffset, _init_extra_hasOffset, _initProto$8] = _applyDecs2311(this, [], [[observable, 1, "_height"], [observable, 1, "_width"], [observable, 1, "_left"], [observable, 1, "_top"], [observable, 1, "_right"], [observable, 1, "_bottom"], [computed, 3, "height"], [computed, 3, "width"], [computed, 3, "top"], [computed, 3, "left"], [computed, 3, "bottom"], [computed, 3, "right"], [observable, 1, "hasOffset"], [computed, 3, "offsetLeft"], [computed, 3, "offsetTop"], [computed, 3, "offsetHeight"], [computed, 3, "offsetWidth"], [computed, 3, "scale"]]).e;
9924
+ [_init__height, _init_extra__height, _init__width, _init_extra__width, _init__left, _init_extra__left, _init__top, _init_extra__top, _init__right, _init_extra__right, _init__bottom, _init_extra__bottom, _init_hasOffset, _init_extra_hasOffset, _initProto$b] = _applyDecs2311(this, [], [[observable, 1, "_height"], [observable, 1, "_width"], [observable, 1, "_left"], [observable, 1, "_top"], [observable, 1, "_right"], [observable, 1, "_bottom"], [computed, 3, "height"], [computed, 3, "width"], [computed, 3, "top"], [computed, 3, "left"], [computed, 3, "bottom"], [computed, 3, "right"], [observable, 1, "hasOffset"], [computed, 3, "offsetLeft"], [computed, 3, "offsetTop"], [computed, 3, "offsetHeight"], [computed, 3, "offsetWidth"], [computed, 3, "scale"]]).e;
9774
9925
  }
9775
- id = (_initProto$8(this), uniqueId('oobx'));
9926
+ id = (_initProto$b(this), uniqueId('oobx'));
9776
9927
  #A = _init__height(this, 0);
9777
9928
  get _height() {
9778
9929
  return this.#A;
@@ -9919,7 +10070,7 @@ class OffsetObserver {
9919
10070
  });
9920
10071
  });
9921
10072
  }
9922
- this.pid = requestIdleCallback(compute);
10073
+ this.pid = requestAnimationFrame(compute);
9923
10074
  pid = this.pid;
9924
10075
  };
9925
10076
  this.compute = compute;
@@ -9935,7 +10086,7 @@ class OffsetObserver {
9935
10086
  }
9936
10087
  purge() {
9937
10088
  if (this.pid) {
9938
- cancelIdleCallback(this.pid);
10089
+ cancelAnimationFrame(this.pid);
9939
10090
  }
9940
10091
  this.pid = undefined;
9941
10092
  }
@@ -9950,16 +10101,16 @@ function createOffsetObserver(nodeInstance) {
9950
10101
  return new OffsetObserver(nodeInstance);
9951
10102
  }
9952
10103
 
9953
- let _initProto$7, _init__selected, _init_extra__selected;
10104
+ let _initProto$a, _init__selected, _init_extra__selected;
9954
10105
  let SELECTION_EVENT = /*#__PURE__*/function (SELECTION_EVENT) {
9955
10106
  SELECTION_EVENT["CHANGE"] = "selection:change";
9956
10107
  return SELECTION_EVENT;
9957
10108
  }({});
9958
10109
  class Selection {
9959
10110
  static {
9960
- [_init__selected, _init_extra__selected, _initProto$7] = _applyDecs2311(this, [], [[[observable, observable.shallow], 17, "_selected"], [action, 2, "select"], [action, 2, "selectAll"], [action, 2, "clear"], [action, 2, "tidy"], [action, 2, "add"], [action, 2, "remove"]]).e;
10111
+ [_init__selected, _init_extra__selected, _initProto$a] = _applyDecs2311(this, [], [[[observable, observable.shallow], 17, "_selected"], [action, 2, "select"], [action, 2, "selectAll"], [action, 2, "clear"], [action, 2, "tidy"], [action, 2, "add"], [action, 2, "remove"]]).e;
9961
10112
  }
9962
- emitter = (_initProto$7(this), createEventBus('Selection'));
10113
+ emitter = (_initProto$a(this), createEventBus('Selection'));
9963
10114
  #A = _init__selected(this, []);
9964
10115
  get _selected() {
9965
10116
  return this.#A;
@@ -10090,12 +10241,12 @@ class Selection {
10090
10241
  }
10091
10242
  }
10092
10243
 
10093
- let _initProto$6, _init__name, _init_extra__name;
10244
+ let _initProto$9, _init__name, _init_extra__name;
10094
10245
  class SettingPropEntry {
10095
10246
  static {
10096
- [_init__name, _init_extra__name, _initProto$6] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_name"], [computed, 3, "path"], [computed, 3, "valueState"]]).e;
10247
+ [_init__name, _init_extra__name, _initProto$9] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_name"], [computed, 3, "path"], [computed, 3, "valueState"]]).e;
10097
10248
  }
10098
- editor = void _initProto$6(this);
10249
+ editor = void _initProto$9(this);
10099
10250
  id = uniqueId('entry');
10100
10251
  emitter = createEventBus('SettingPropEntry');
10101
10252
  #A = _init__name(this);
@@ -10343,7 +10494,7 @@ class SettingPropEntry {
10343
10494
  }
10344
10495
  }
10345
10496
 
10346
- let _initProto$5, _init__expanded, _init_extra__expanded;
10497
+ let _initProto$8, _init__expanded, _init_extra__expanded;
10347
10498
  let PropValueChangedType = /*#__PURE__*/function (PropValueChangedType) {
10348
10499
  PropValueChangedType["SET_VALUE"] = "SET_VALUE";
10349
10500
  PropValueChangedType["SUB_VALUE_CHANGE"] = "SUB_VALUE_CHANGE";
@@ -10362,9 +10513,9 @@ function getSettingFieldCollectorKey(parent, config) {
10362
10513
  }
10363
10514
  class SettingField extends SettingPropEntry {
10364
10515
  static {
10365
- [_init__expanded, _init_extra__expanded, _initProto$5] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_expanded"], [computed, 3, "setter"], [action, 2, "setValue"], [action, 2, "setHotValue"]], 0, void 0, SettingPropEntry).e;
10516
+ [_init__expanded, _init_extra__expanded, _initProto$8] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_expanded"], [computed, 3, "setter"], [action, 2, "setValue"], [action, 2, "setHotValue"]], 0, void 0, SettingPropEntry).e;
10366
10517
  }
10367
- isSettingField = (_initProto$5(this), true);
10518
+ isSettingField = (_initProto$8(this), true);
10368
10519
  get title() {
10369
10520
  return this._title || this.name;
10370
10521
  }
@@ -10510,12 +10661,12 @@ class SettingField extends SettingPropEntry {
10510
10661
  const isSettingField = obj => obj && obj.isSettingField;
10511
10662
  const isDynamicSetter = obj => typeof obj === 'function';
10512
10663
 
10513
- let _initProto$4, _init__settings, _init_extra__settings;
10664
+ let _initProto$7, _init__settings, _init_extra__settings;
10514
10665
  class SettingsManager {
10515
10666
  static {
10516
- [_init__settings, _init_extra__settings, _initProto$4] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_settings"], [computed, 3, "length"], [computed, 3, "componentMeta"], [computed, 3, "settings"], [action, 2, "setup"]]).e;
10667
+ [_init__settings, _init_extra__settings, _initProto$7] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_settings"], [computed, 3, "length"], [computed, 3, "componentMeta"], [computed, 3, "settings"], [action, 2, "setup"]]).e;
10517
10668
  }
10518
- _sessionId = (_initProto$4(this), '');
10669
+ _sessionId = (_initProto$7(this), '');
10519
10670
  #A = _init__settings(this);
10520
10671
  get _settings() {
10521
10672
  return this.#A;
@@ -10559,6 +10710,11 @@ class SettingsManager {
10559
10710
  }
10560
10711
  this._sessionId = sessionId;
10561
10712
  if (nodes.length < 1) {
10713
+ const rootNode = this.designer?.project.currentDocument?.rootNode;
10714
+ if (rootNode) {
10715
+ this._settings = rootNode.settingEntry;
10716
+ return;
10717
+ }
10562
10718
  this._settings = undefined;
10563
10719
  return;
10564
10720
  }
@@ -10603,6 +10759,9 @@ class SettingTopEntry {
10603
10759
  get isLocked() {
10604
10760
  return this.first.locked;
10605
10761
  }
10762
+ get isHidden() {
10763
+ return this.first.hidden;
10764
+ }
10606
10765
  get isMultiple() {
10607
10766
  return this.nodes.length > 1;
10608
10767
  }
@@ -10725,7 +10884,7 @@ const isPurgeable = obj => {
10725
10884
  return obj && obj.purge;
10726
10885
  };
10727
10886
 
10728
- let _initProto$3, _init__simulatorProps, _init_extra__simulatorProps, _init__suspended, _init_extra__suspended;
10887
+ let _initProto$6, _init__simulatorProps, _init_extra__simulatorProps, _init__suspended, _init_extra__suspended;
10729
10888
  const logger$4 = createLogger('Designer');
10730
10889
  let DESIGNER_EVENT = /*#__PURE__*/function (DESIGNER_EVENT) {
10731
10890
  DESIGNER_EVENT["MOUNT"] = "designer:mount";
@@ -10753,9 +10912,9 @@ let DESIGNER_EVENT = /*#__PURE__*/function (DESIGNER_EVENT) {
10753
10912
  }({});
10754
10913
  class Designer {
10755
10914
  static {
10756
- [_init__simulatorProps, _init_extra__simulatorProps, _init__suspended, _init_extra__suspended, _initProto$3] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_simulatorProps"], [[observable, observable.ref], 17, "_suspended"], [computed, 3, "simulatorProps"], [computed, 3, "projectSimulatorProps"]]).e;
10915
+ [_init__simulatorProps, _init_extra__simulatorProps, _init__suspended, _init_extra__suspended, _initProto$6] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_simulatorProps"], [[observable, observable.ref], 17, "_suspended"], [computed, 3, "simulatorProps"], [computed, 3, "projectSimulatorProps"]]).e;
10757
10916
  }
10758
- emitter = (_initProto$3(this), createEventBus('Designer'));
10917
+ emitter = (_initProto$6(this), createEventBus('Designer'));
10759
10918
  activeTracker = new ActiveTracker();
10760
10919
  get materials() {
10761
10920
  return this.editor.get('materials');
@@ -11025,6 +11184,12 @@ let COMPONENT_META_EVENT = /*#__PURE__*/function (COMPONENT_META_EVENT) {
11025
11184
  class ComponentMeta {
11026
11185
  isComponentMeta = true;
11027
11186
  emitter = createEventBus('ComponentMeta');
11187
+ get npm() {
11188
+ return this._npm;
11189
+ }
11190
+ set npm(_npm) {
11191
+ this.setNpm(_npm);
11192
+ }
11028
11193
  get componentName() {
11029
11194
  return this._componentName;
11030
11195
  }
@@ -11056,11 +11221,18 @@ class ComponentMeta {
11056
11221
  this.designer = designer;
11057
11222
  this.parseMetadata(metadata);
11058
11223
  }
11224
+ setNpm(info) {
11225
+ if (!this._npm) {
11226
+ this._npm = info;
11227
+ }
11228
+ }
11059
11229
  parseMetadata(metadata) {
11060
11230
  const {
11061
- componentName
11231
+ componentName,
11232
+ npm
11062
11233
  } = metadata;
11063
11234
  this._metadata = metadata;
11235
+ this._npm = npm || this._npm;
11064
11236
  this._componentName = componentName;
11065
11237
  const {
11066
11238
  title,
@@ -11096,94 +11268,292 @@ class ComponentMeta {
11096
11268
  this.emitter.off(COMPONENT_META_EVENT.CHANGE, fn);
11097
11269
  };
11098
11270
  }
11271
+ dispose() {
11272
+ this.emitter.removeAllListeners();
11273
+ }
11274
+ isRemoteMaterial() {
11275
+ try {
11276
+ return !!(this.npm && this.npm.package && this.npm.package !== 'builtin');
11277
+ } catch (error) {
11278
+ console.warn(`[ComponentMeta] Failed to check if component "${this.componentName}" is remote material:`, error);
11279
+ return false;
11280
+ }
11281
+ }
11099
11282
  }
11100
11283
  function isComponentMeta(obj) {
11101
11284
  return obj && obj.isComponentMeta;
11102
11285
  }
11103
11286
 
11104
- let _initProto$2, _init__componentMetasMap, _init_extra__componentMetasMap;
11105
- class Materials {
11287
+ let MaterialStatus = /*#__PURE__*/function (MaterialStatus) {
11288
+ MaterialStatus["LOADING"] = "loading";
11289
+ MaterialStatus["REGISTERED"] = "registered";
11290
+ MaterialStatus["ACTIVE"] = "active";
11291
+ MaterialStatus["UNLOADING"] = "unloading";
11292
+ MaterialStatus["ERROR"] = "error";
11293
+ return MaterialStatus;
11294
+ }({});
11295
+ let MaterialSource = /*#__PURE__*/function (MaterialSource) {
11296
+ MaterialSource["BUILTIN"] = "builtin";
11297
+ MaterialSource["REMOTE"] = "remote";
11298
+ MaterialSource["DEBUG"] = "debug";
11299
+ return MaterialSource;
11300
+ }({});
11301
+ let RegistryEventType = /*#__PURE__*/function (RegistryEventType) {
11302
+ RegistryEventType["REGISTERED"] = "registered";
11303
+ RegistryEventType["UPDATED"] = "updated";
11304
+ RegistryEventType["UNLOADED"] = "unloaded";
11305
+ RegistryEventType["STATUS_CHANGED"] = "status_changed";
11306
+ RegistryEventType["USAGE_CHANGED"] = "usage_changed";
11307
+ RegistryEventType["ERROR"] = "error";
11308
+ return RegistryEventType;
11309
+ }({});
11310
+
11311
+ let _initProto$5, _init_entries, _init_extra_entries, _init_pendingEntries, _init_extra_pendingEntries, _init__version, _init_extra__version;
11312
+ const COMPONENT_NAME_REGEX = /^[A-Za-z_$][A-Za-z0-9_$.@]*$/;
11313
+ const MAX_COMPONENT_NAME_LENGTH = 255;
11314
+ class MaterialRegistry {
11106
11315
  static {
11107
- [_init__componentMetasMap, _init_extra__componentMetasMap, _initProto$2] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_componentMetasMap"], [action, 2, "createComponentMeta"], [computed, 3, "componentMetasMap"], [computed, 3, "componentsMap"]]).e;
11316
+ [_init_entries, _init_extra_entries, _init_pendingEntries, _init_extra_pendingEntries, _init__version, _init_extra__version, _initProto$5] = _applyDecs2311(this, [], [[[observable, observable.shallow], 17, "entries"], [[observable, observable.shallow], 17, "pendingEntries"], [observable, 1, "_version"], [action, 2, "register"], [action, 2, "unload"], [action, 2, "getOrCreate"], [action, 2, "incrementUsage"], [action, 2, "decrementUsage"], [action, 2, "refresh"], [computed, 3, "componentMetasMap"], [computed, 3, "componentsMap"], [action, 2, "dispose"]]).e;
11108
11317
  }
11109
- #A = (_initProto$2(this), _init__componentMetasMap(this, new Map()));
11110
- get _componentMetasMap() {
11318
+ #A = (_initProto$5(this), _init_entries(this, new Map()));
11319
+ get entries() {
11111
11320
  return this.#A;
11112
11321
  }
11113
- set _componentMetasMap(v) {
11322
+ set entries(v) {
11114
11323
  this.#A = v;
11115
11324
  }
11116
- _lostComponentMetasMap = (_init_extra__componentMetasMap(this), new Map());
11117
- get designer() {
11118
- return this.editor.get('designer');
11325
+ #B = (_init_extra_entries(this), _init_pendingEntries(this, new Map()));
11326
+ get pendingEntries() {
11327
+ return this.#B;
11119
11328
  }
11120
- constructor(editor) {
11121
- this.editor = editor;
11329
+ set pendingEntries(v) {
11330
+ this.#B = v;
11122
11331
  }
11123
- buildComponentMetasMap = metas => {
11124
- for (const meta of metas) {
11125
- this.createComponentMeta(meta);
11332
+ #C = (_init_extra_pendingEntries(this), _init__version(this, 0));
11333
+ get _version() {
11334
+ return this.#C;
11335
+ }
11336
+ set _version(v) {
11337
+ this.#C = v;
11338
+ }
11339
+ listeners = (_init_extra__version(this), new Set());
11340
+ disposed = false;
11341
+ constructor(designer) {
11342
+ this.designer = designer;
11343
+ }
11344
+ get version() {
11345
+ return this._version;
11346
+ }
11347
+ validateComponentName(name) {
11348
+ if (!name || typeof name !== 'string') {
11349
+ return false;
11126
11350
  }
11127
- };
11128
- createComponentMeta(data) {
11129
- const key = data.componentName;
11130
- if (!key) {
11131
- return null;
11351
+ if (name.length > MAX_COMPONENT_NAME_LENGTH) {
11352
+ return false;
11132
11353
  }
11133
- let meta = this._componentMetasMap.get(key);
11134
- if (meta) {
11135
- meta.setMetadata(data);
11136
- this._componentMetasMap.set(key, meta);
11354
+ return COMPONENT_NAME_REGEX.test(name);
11355
+ }
11356
+ emit(event) {
11357
+ const fullEvent = {
11358
+ ...event,
11359
+ timestamp: Date.now()
11360
+ };
11361
+ this.listeners.forEach(listener => {
11362
+ try {
11363
+ listener(fullEvent);
11364
+ } catch (error) {
11365
+ console.error('[MaterialRegistry] Event listener error:', error);
11366
+ }
11367
+ });
11368
+ }
11369
+ createEntry(componentName, meta, options = {}) {
11370
+ return {
11371
+ componentName,
11372
+ status: options.component ? MaterialStatus.ACTIVE : MaterialStatus.REGISTERED,
11373
+ source: options.source ?? MaterialSource.BUILTIN,
11374
+ meta,
11375
+ component: options.component,
11376
+ version: options.version,
11377
+ loadedAt: Date.now(),
11378
+ lastAccessedAt: Date.now(),
11379
+ usageCount: 0
11380
+ };
11381
+ }
11382
+ register(metadata, options = {}) {
11383
+ const componentName = metadata.componentName;
11384
+ if (!this.validateComponentName(componentName)) {
11385
+ console.warn(`[MaterialRegistry] Invalid component name: "${componentName}"`);
11386
+ throw new Error(`Invalid component name: "${componentName}"`);
11387
+ }
11388
+ let entry = this.entries.get(componentName);
11389
+ let isNew = false;
11390
+ if (entry) {
11391
+ if (!options.override) {
11392
+ entry.meta.setMetadata(metadata);
11393
+ entry.lastAccessedAt = Date.now();
11394
+ if (options.component) {
11395
+ entry.component = options.component;
11396
+ entry.status = MaterialStatus.ACTIVE;
11397
+ }
11398
+ } else {
11399
+ entry.meta = new ComponentMeta(this.designer, metadata);
11400
+ entry.component = options.component;
11401
+ entry.status = options.component ? MaterialStatus.ACTIVE : MaterialStatus.REGISTERED;
11402
+ entry.lastAccessedAt = Date.now();
11403
+ }
11137
11404
  } else {
11138
- meta = this._lostComponentMetasMap.get(key);
11139
- if (meta) {
11140
- meta.setMetadata(data);
11141
- this._lostComponentMetasMap.delete(key);
11405
+ const pendingEntry = this.pendingEntries.get(componentName);
11406
+ if (pendingEntry) {
11407
+ pendingEntry.meta.setMetadata(metadata);
11408
+ pendingEntry.status = options.component ? MaterialStatus.ACTIVE : MaterialStatus.REGISTERED;
11409
+ pendingEntry.component = options.component;
11410
+ pendingEntry.source = options.source ?? MaterialSource.BUILTIN;
11411
+ pendingEntry.version = options.version;
11412
+ pendingEntry.lastAccessedAt = Date.now();
11413
+ entry = pendingEntry;
11414
+ this.pendingEntries.delete(componentName);
11415
+ isNew = true;
11142
11416
  } else {
11143
- meta = new ComponentMeta(this.designer, data);
11417
+ const meta = new ComponentMeta(this.designer, metadata);
11418
+ entry = this.createEntry(componentName, meta, options);
11419
+ isNew = true;
11144
11420
  }
11145
- this._componentMetasMap.set(key, meta);
11421
+ this.entries.set(componentName, entry);
11146
11422
  }
11147
- return meta;
11423
+ this.emit({
11424
+ type: isNew ? RegistryEventType.REGISTERED : RegistryEventType.UPDATED,
11425
+ componentName,
11426
+ entry
11427
+ });
11428
+ return entry.meta;
11148
11429
  }
11149
- getComponentMeta(componentName, generateMetadata) {
11150
- if (this._componentMetasMap.has(componentName)) {
11151
- return this._componentMetasMap.get(componentName);
11430
+ async unload(componentName, options = {}) {
11431
+ const entry = this.entries.get(componentName);
11432
+ if (!entry) {
11433
+ console.warn(`[MaterialRegistry] Component not found: "${componentName}"`);
11434
+ return false;
11435
+ }
11436
+ if (!options.force && entry.usageCount > 0) {
11437
+ console.warn(`[MaterialRegistry] Cannot unload "${componentName}": ${entry.usageCount} instances in use`);
11438
+ return false;
11439
+ }
11440
+ entry.status = MaterialStatus.UNLOADING;
11441
+ this.emit({
11442
+ type: RegistryEventType.STATUS_CHANGED,
11443
+ componentName,
11444
+ entry,
11445
+ previousStatus: MaterialStatus.ACTIVE
11446
+ });
11447
+ if (entry.meta.dispose) {
11448
+ entry.meta.dispose();
11449
+ }
11450
+ this.entries.delete(componentName);
11451
+ this.emit({
11452
+ type: RegistryEventType.UNLOADED,
11453
+ componentName
11454
+ });
11455
+ this.refresh();
11456
+ return true;
11457
+ }
11458
+ get(componentName) {
11459
+ const entry = this.entries.get(componentName);
11460
+ if (entry) {
11461
+ entry.lastAccessedAt = Date.now();
11462
+ }
11463
+ return entry;
11464
+ }
11465
+ getOrCreate(componentName, generateMetadata) {
11466
+ const entry = this.entries.get(componentName);
11467
+ if (entry) {
11468
+ entry.lastAccessedAt = Date.now();
11469
+ return entry.meta;
11152
11470
  }
11153
- if (this._lostComponentMetasMap.has(componentName)) {
11154
- return this._lostComponentMetasMap.get(componentName);
11471
+ const pendingEntry = this.pendingEntries.get(componentName);
11472
+ if (pendingEntry) {
11473
+ pendingEntry.lastAccessedAt = Date.now();
11474
+ return pendingEntry.meta;
11155
11475
  }
11156
- const meta = new ComponentMeta(this.designer, {
11476
+ const metadata = {
11157
11477
  componentName,
11158
11478
  ...(generateMetadata ? generateMetadata() : null)
11479
+ };
11480
+ const meta = new ComponentMeta(this.designer, metadata);
11481
+ const newEntry = this.createEntry(componentName, meta, {
11482
+ source: MaterialSource.BUILTIN
11159
11483
  });
11160
- this._lostComponentMetasMap.set(componentName, meta);
11484
+ newEntry.status = MaterialStatus.LOADING;
11485
+ this.pendingEntries.set(componentName, newEntry);
11161
11486
  return meta;
11162
11487
  }
11163
- getComponentSnippets() {
11164
- return Array.from(this._componentMetasMap.values()).flatMap(meta => meta.snippets);
11488
+ has(componentName) {
11489
+ return this.entries.has(componentName);
11490
+ }
11491
+ incrementUsage(componentName) {
11492
+ const entry = this.entries.get(componentName) || this.pendingEntries.get(componentName);
11493
+ if (entry) {
11494
+ entry.usageCount++;
11495
+ this.emit({
11496
+ type: RegistryEventType.USAGE_CHANGED,
11497
+ componentName,
11498
+ entry
11499
+ });
11500
+ }
11165
11501
  }
11166
- getComponentMetasMap() {
11167
- return this._componentMetasMap;
11502
+ decrementUsage(componentName) {
11503
+ const entry = this.entries.get(componentName) || this.pendingEntries.get(componentName);
11504
+ if (entry && entry.usageCount > 0) {
11505
+ entry.usageCount--;
11506
+ this.emit({
11507
+ type: RegistryEventType.USAGE_CHANGED,
11508
+ componentName,
11509
+ entry
11510
+ });
11511
+ }
11512
+ }
11513
+ canUnload(componentName) {
11514
+ const entry = this.entries.get(componentName);
11515
+ if (!entry) {
11516
+ return false;
11517
+ }
11518
+ return entry.usageCount === 0;
11519
+ }
11520
+ subscribe(listener) {
11521
+ this.listeners.add(listener);
11522
+ return () => {
11523
+ this.listeners.delete(listener);
11524
+ };
11525
+ }
11526
+ getAll() {
11527
+ return new Map(this.entries);
11528
+ }
11529
+ getBySource(source) {
11530
+ const result = [];
11531
+ this.entries.forEach(entry => {
11532
+ if (entry.source === source) {
11533
+ result.push(entry);
11534
+ }
11535
+ });
11536
+ return result;
11537
+ }
11538
+ refresh() {
11539
+ this._version++;
11540
+ this.entries = new Map(this.entries);
11168
11541
  }
11169
11542
  get componentMetasMap() {
11170
11543
  const maps = {};
11171
- this._componentMetasMap.forEach((config, key) => {
11172
- const metaData = config.getMetadata();
11173
- maps[key] = metaData;
11544
+ this.entries.forEach((entry, key) => {
11545
+ maps[key] = entry.meta.getMetadata();
11174
11546
  });
11175
11547
  return maps;
11176
11548
  }
11177
11549
  get componentsMap() {
11178
11550
  const maps = {};
11179
- this._componentMetasMap.forEach((config, key) => {
11180
- const metaData = config.getMetadata();
11181
- if (metaData.devMode === 'lowCode') {
11182
- maps[key] = metaData.schema;
11551
+ this.entries.forEach((entry, key) => {
11552
+ const metadata = entry.meta.getMetadata();
11553
+ if (metadata.devMode === 'lowCode') {
11554
+ maps[key] = metadata.schema;
11183
11555
  } else {
11184
- const {
11185
- view
11186
- } = config.advanced;
11556
+ const view = entry.meta.advanced?.view ?? entry.component;
11187
11557
  if (view) {
11188
11558
  maps[key] = view;
11189
11559
  }
@@ -11191,12 +11561,127 @@ class Materials {
11191
11561
  });
11192
11562
  return maps;
11193
11563
  }
11564
+ getComponentSnippets() {
11565
+ const snippets = [];
11566
+ this.entries.forEach(entry => {
11567
+ const metaSnippets = entry.meta.snippets;
11568
+ if (metaSnippets) {
11569
+ snippets.push(...metaSnippets);
11570
+ }
11571
+ });
11572
+ return snippets;
11573
+ }
11574
+ dispose() {
11575
+ if (this.disposed) {
11576
+ return;
11577
+ }
11578
+ this.disposed = true;
11579
+ this.entries.forEach(entry => {
11580
+ if (entry.meta.dispose) {
11581
+ entry.meta.dispose();
11582
+ }
11583
+ });
11584
+ this.pendingEntries.forEach(entry => {
11585
+ if (entry.meta.dispose) {
11586
+ entry.meta.dispose();
11587
+ }
11588
+ });
11589
+ this.entries.clear();
11590
+ this.pendingEntries.clear();
11591
+ this.listeners.clear();
11592
+ }
11593
+ }
11594
+
11595
+ let _initProto$4;
11596
+ class Materials {
11597
+ static {
11598
+ [_initProto$4] = _applyDecs2311(this, [], [[action, 2, "createComponentMeta"], [action, 2, "removeComponentMeta"], [computed, 3, "componentMetasMap"], [computed, 3, "componentsMap"]]).e;
11599
+ }
11600
+ _registry = (_initProto$4(this), null);
11601
+ get designer() {
11602
+ return this.editor.get('designer');
11603
+ }
11604
+ get registry() {
11605
+ if (!this._registry) {
11606
+ this._registry = new MaterialRegistry(this.designer);
11607
+ }
11608
+ return this._registry;
11609
+ }
11610
+ get version() {
11611
+ return this.registry.version;
11612
+ }
11613
+ constructor(editor) {
11614
+ this.editor = editor;
11615
+ }
11616
+ buildComponentMetasMap = metas => {
11617
+ for (const meta of metas) {
11618
+ this.createComponentMeta(meta);
11619
+ }
11620
+ };
11621
+ createComponentMeta(data, options) {
11622
+ const key = data.componentName;
11623
+ if (!key) {
11624
+ return null;
11625
+ }
11626
+ return this.registry.register(data, {
11627
+ source: MaterialSource.BUILTIN,
11628
+ ...options
11629
+ });
11630
+ }
11631
+ removeComponentMeta(componentName) {
11632
+ if (!componentName) {
11633
+ return false;
11634
+ }
11635
+ const entry = this.registry.get(componentName);
11636
+ if (!entry) {
11637
+ return false;
11638
+ }
11639
+ if (entry.usageCount > 0) {
11640
+ console.warn(`[Materials] Removing "${componentName}" with ${entry.usageCount} instances in use. ` + 'This may cause rendering errors. Consider using registry.unload() with force option.');
11641
+ }
11642
+ this.registry.unload(componentName, {
11643
+ force: true
11644
+ });
11645
+ return true;
11646
+ }
11647
+ getComponentMeta(componentName, generateMetadata) {
11648
+ return this.registry.getOrCreate(componentName, generateMetadata);
11649
+ }
11650
+ getComponentSnippets() {
11651
+ return this.registry.getComponentSnippets();
11652
+ }
11653
+ getComponentMetasMap() {
11654
+ const map = new Map();
11655
+ this.registry.getAll().forEach((entry, key) => {
11656
+ map.set(key, entry.meta);
11657
+ });
11658
+ return map;
11659
+ }
11660
+ get componentMetasMap() {
11661
+ return this.registry.componentMetasMap;
11662
+ }
11663
+ get componentsMap() {
11664
+ return this.registry.componentsMap;
11665
+ }
11194
11666
  refreshComponentMetasMap() {
11195
- this._componentMetasMap = new Map(this._componentMetasMap);
11667
+ this.registry.refresh();
11668
+ }
11669
+ incrementUsage(componentName) {
11670
+ this.registry.incrementUsage(componentName);
11671
+ }
11672
+ decrementUsage(componentName) {
11673
+ this.registry.decrementUsage(componentName);
11674
+ }
11675
+ canUnload(componentName) {
11676
+ return this.registry.canUnload(componentName);
11196
11677
  }
11197
11678
  isComponentMeta(obj) {
11198
11679
  return isComponentMeta(obj);
11199
11680
  }
11681
+ dispose() {
11682
+ this._registry?.dispose();
11683
+ this._registry = null;
11684
+ }
11200
11685
  }
11201
11686
 
11202
11687
  class PluginContext {
@@ -11471,11 +11956,11 @@ class PluginRuntime {
11471
11956
  if (!this._inited) {
11472
11957
  this.logger.warn('Could not call toProxy before init');
11473
11958
  }
11474
- const exports = this.config.exports?.();
11959
+ const exports$1 = this.config.exports?.();
11475
11960
  return new Proxy(this, {
11476
11961
  get(target, prop, receiver) {
11477
- if ({}.hasOwnProperty.call(exports, prop)) {
11478
- return exports?.[prop];
11962
+ if ({}.hasOwnProperty.call(exports$1, prop)) {
11963
+ return exports$1?.[prop];
11479
11964
  }
11480
11965
  return Reflect.get(target, prop, receiver);
11481
11966
  }
@@ -11713,6 +12198,287 @@ const isRegisterOptions = opts => {
11713
12198
  return opts && ('autoInit' in opts || 'override' in opts);
11714
12199
  };
11715
12200
 
12201
+ let RemoteLoadErrorType = /*#__PURE__*/function (RemoteLoadErrorType) {
12202
+ RemoteLoadErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";
12203
+ RemoteLoadErrorType["PACKAGE_NOT_FOUND"] = "PACKAGE_NOT_FOUND";
12204
+ RemoteLoadErrorType["VERSION_NOT_FOUND"] = "VERSION_NOT_FOUND";
12205
+ RemoteLoadErrorType["SCRIPT_LOAD_FAILED"] = "SCRIPT_LOAD_FAILED";
12206
+ RemoteLoadErrorType["CSS_LOAD_FAILED"] = "CSS_LOAD_FAILED";
12207
+ RemoteLoadErrorType["GLOBAL_NOT_FOUND"] = "GLOBAL_NOT_FOUND";
12208
+ RemoteLoadErrorType["METADATA_INVALID"] = "METADATA_INVALID";
12209
+ RemoteLoadErrorType["CDN_ALL_FAILED"] = "CDN_ALL_FAILED";
12210
+ RemoteLoadErrorType["TIMEOUT"] = "TIMEOUT";
12211
+ return RemoteLoadErrorType;
12212
+ }({});
12213
+ const ERROR_MESSAGES = {
12214
+ [RemoteLoadErrorType.NETWORK_ERROR]: () => '网络连接失败,请检查您的网络设置',
12215
+ [RemoteLoadErrorType.PACKAGE_NOT_FOUND]: (name, type) => `${type === 'material' ? '物料包' : '设置器包'} "${name}" 不存在`,
12216
+ [RemoteLoadErrorType.VERSION_NOT_FOUND]: () => '指定的版本不存在',
12217
+ [RemoteLoadErrorType.SCRIPT_LOAD_FAILED]: (_, type) => `${type === 'material' ? '物料' : '设置器'}脚本加载失败`,
12218
+ [RemoteLoadErrorType.CSS_LOAD_FAILED]: () => '样式加载失败',
12219
+ [RemoteLoadErrorType.GLOBAL_NOT_FOUND]: (_, type) => `${type === 'material' ? '物料' : '设置器'}格式不正确`,
12220
+ [RemoteLoadErrorType.METADATA_INVALID]: () => '元数据格式错误',
12221
+ [RemoteLoadErrorType.CDN_ALL_FAILED]: () => '所有 CDN 加载失败',
12222
+ [RemoteLoadErrorType.TIMEOUT]: () => '加载超时'
12223
+ };
12224
+ class RemoteLoadError extends Error {
12225
+ name = 'RemoteLoadError';
12226
+ constructor(
12227
+ type,
12228
+ resourceName,
12229
+ resourceType,
12230
+ message,
12231
+ originalError) {
12232
+ super(message);
12233
+ this.type = type;
12234
+ this.resourceName = resourceName;
12235
+ this.resourceType = resourceType;
12236
+ this.originalError = originalError;
12237
+ Object.setPrototypeOf(this, RemoteLoadError.prototype);
12238
+ }
12239
+ toUserMessage() {
12240
+ const getMessage = ERROR_MESSAGES[this.type];
12241
+ return getMessage?.(this.resourceName, this.resourceType) || `加载失败: ${this.message}`;
12242
+ }
12243
+ static create(type, resourceName, resourceType, message, originalError) {
12244
+ const defaultMessage = ERROR_MESSAGES[type]?.(resourceName, resourceType) || type;
12245
+ return new RemoteLoadError(type, resourceName, resourceType, message || defaultMessage, originalError);
12246
+ }
12247
+ }
12248
+
12249
+ let LoadingStatus = /*#__PURE__*/function (LoadingStatus) {
12250
+ LoadingStatus["IDLE"] = "idle";
12251
+ LoadingStatus["LOADING"] = "loading";
12252
+ LoadingStatus["LOADED"] = "loaded";
12253
+ LoadingStatus["ERROR"] = "error";
12254
+ return LoadingStatus;
12255
+ }({});
12256
+ const DEFAULT_TIMEOUT = 30000;
12257
+
12258
+ let _initProto$3, _init_states, _init_extra_states;
12259
+ class LoadingStateManager {
12260
+ static {
12261
+ [_init_states, _init_extra_states, _initProto$3] = _applyDecs2311(this, [], [[[observable, observable.shallow], 17, "states"], [computed, 3, "isLoading"], [computed, 3, "loadingResources"], [computed, 3, "errors"], [computed, 3, "loadedResources"], [action, 2, "updateState"], [action, 2, "startLoading"], [action, 2, "updateProgress"], [action, 2, "markLoaded"], [action, 2, "markError"], [action, 2, "clearState"], [action, 2, "clearAll"]]).e;
12262
+ }
12263
+ #A = (_initProto$3(this), _init_states(this, new Map()));
12264
+ get states() {
12265
+ return this.#A;
12266
+ }
12267
+ set states(v) {
12268
+ this.#A = v;
12269
+ }
12270
+ listeners = (_init_extra_states(this), new Set());
12271
+ get isLoading() {
12272
+ for (const state of this.states.values()) {
12273
+ if (state.status === LoadingStatus.LOADING) {
12274
+ return true;
12275
+ }
12276
+ }
12277
+ return false;
12278
+ }
12279
+ get loadingResources() {
12280
+ return Array.from(this.states.values()).filter(s => s.status === LoadingStatus.LOADING);
12281
+ }
12282
+ get errors() {
12283
+ return Array.from(this.states.values()).filter(s => s.status === LoadingStatus.ERROR);
12284
+ }
12285
+ get loadedResources() {
12286
+ return Array.from(this.states.values()).filter(s => s.status === LoadingStatus.LOADED);
12287
+ }
12288
+ isTypeLoading(type) {
12289
+ for (const state of this.states.values()) {
12290
+ if (state.type === type && state.status === LoadingStatus.LOADING) {
12291
+ return true;
12292
+ }
12293
+ }
12294
+ return false;
12295
+ }
12296
+ getState(key) {
12297
+ return this.states.get(key);
12298
+ }
12299
+ updateState(key, state) {
12300
+ const existing = this.states.get(key);
12301
+ if (existing) {
12302
+ this.states.set(key, {
12303
+ ...existing,
12304
+ ...state
12305
+ });
12306
+ } else {
12307
+ this.states.set(key, {
12308
+ type: 'material',
12309
+ name: key,
12310
+ status: LoadingStatus.IDLE,
12311
+ ...state
12312
+ });
12313
+ }
12314
+ this.notifyListeners();
12315
+ }
12316
+ startLoading(key, type, name) {
12317
+ this.states.set(key, {
12318
+ type,
12319
+ name,
12320
+ status: LoadingStatus.LOADING,
12321
+ progress: 0
12322
+ });
12323
+ this.notifyListeners();
12324
+ }
12325
+ updateProgress(key, progress) {
12326
+ const state = this.states.get(key);
12327
+ if (state) {
12328
+ this.states.set(key, {
12329
+ ...state,
12330
+ progress: Math.min(100, Math.max(0, progress))
12331
+ });
12332
+ this.notifyListeners();
12333
+ }
12334
+ }
12335
+ markLoaded(key) {
12336
+ const state = this.states.get(key);
12337
+ if (state) {
12338
+ this.states.set(key, {
12339
+ ...state,
12340
+ status: LoadingStatus.LOADED,
12341
+ progress: 100,
12342
+ loadedAt: Date.now()
12343
+ });
12344
+ this.notifyListeners();
12345
+ }
12346
+ }
12347
+ markError(key, error) {
12348
+ const state = this.states.get(key);
12349
+ if (state) {
12350
+ this.states.set(key, {
12351
+ ...state,
12352
+ status: LoadingStatus.ERROR,
12353
+ error
12354
+ });
12355
+ this.notifyListeners();
12356
+ }
12357
+ }
12358
+ clearState(key) {
12359
+ this.states.delete(key);
12360
+ this.notifyListeners();
12361
+ }
12362
+ clearAll() {
12363
+ this.states.clear();
12364
+ this.notifyListeners();
12365
+ }
12366
+ async waitForAll(timeout = 30000) {
12367
+ return this.waitFor(() => !this.isLoading, timeout);
12368
+ }
12369
+ async waitForType(type, timeout = 30000) {
12370
+ return this.waitFor(() => !this.isTypeLoading(type), timeout);
12371
+ }
12372
+ subscribe(listener) {
12373
+ this.listeners.add(listener);
12374
+ return () => {
12375
+ this.listeners.delete(listener);
12376
+ };
12377
+ }
12378
+ waitFor(condition, timeout) {
12379
+ return new Promise((resolve, reject) => {
12380
+ if (condition()) {
12381
+ resolve();
12382
+ return;
12383
+ }
12384
+ const timeoutId = setTimeout(() => {
12385
+ unsubscribe();
12386
+ reject(new Error(`Wait timeout after ${timeout}ms`));
12387
+ }, timeout);
12388
+ const unsubscribe = this.subscribe(() => {
12389
+ if (condition()) {
12390
+ clearTimeout(timeoutId);
12391
+ unsubscribe();
12392
+ resolve();
12393
+ }
12394
+ });
12395
+ });
12396
+ }
12397
+ notifyListeners() {
12398
+ for (const listener of this.listeners) {
12399
+ try {
12400
+ listener(this.states);
12401
+ } catch (error) {
12402
+ console.error('[LoadingStateManager] Listener error:', error);
12403
+ }
12404
+ }
12405
+ }
12406
+ }
12407
+ const loadingState = new LoadingStateManager();
12408
+
12409
+ let _initProto$2, _init_materials, _init_extra_materials, _init_setters, _init_extra_setters;
12410
+ class ResourceRegistry {
12411
+ static {
12412
+ [_init_materials, _init_extra_materials, _init_setters, _init_extra_setters, _initProto$2] = _applyDecs2311(this, [], [[[observable, observable.shallow], 17, "materials"], [[observable, observable.shallow], 17, "setters"], [computed, 3, "materialCount"], [computed, 3, "setterCount"], [action, 2, "register"], [action, 2, "unload"], [action, 2, "clearType"], [action, 2, "clearAll"]]).e;
12413
+ }
12414
+ constructor() {
12415
+ _init_extra_setters(this);
12416
+ }
12417
+ #A = (_initProto$2(this), _init_materials(this, new Map()));
12418
+ get materials() {
12419
+ return this.#A;
12420
+ }
12421
+ set materials(v) {
12422
+ this.#A = v;
12423
+ }
12424
+ #B = (_init_extra_materials(this), _init_setters(this, new Map()));
12425
+ get setters() {
12426
+ return this.#B;
12427
+ }
12428
+ set setters(v) {
12429
+ this.#B = v;
12430
+ }
12431
+ get materialCount() {
12432
+ return this.materials.size;
12433
+ }
12434
+ get setterCount() {
12435
+ return this.setters.size;
12436
+ }
12437
+ register(resource) {
12438
+ const map = this.getMap(resource.type);
12439
+ map.set(resource.name, resource);
12440
+ }
12441
+ get(type, name) {
12442
+ const map = this.getMap(type);
12443
+ return map.get(name);
12444
+ }
12445
+ has(type, name) {
12446
+ const map = this.getMap(type);
12447
+ return map.has(name);
12448
+ }
12449
+ unload(type, name) {
12450
+ const map = this.getMap(type);
12451
+ return map.delete(name);
12452
+ }
12453
+ getAll(type) {
12454
+ if (type === 'material') {
12455
+ return Array.from(this.materials.values());
12456
+ }
12457
+ if (type === 'setter') {
12458
+ return Array.from(this.setters.values());
12459
+ }
12460
+ return [...Array.from(this.materials.values()), ...Array.from(this.setters.values())];
12461
+ }
12462
+ getMaterialNames() {
12463
+ return Array.from(this.materials.keys());
12464
+ }
12465
+ getSetterNames() {
12466
+ return Array.from(this.setters.keys());
12467
+ }
12468
+ clearType(type) {
12469
+ const map = this.getMap(type);
12470
+ map.clear();
12471
+ }
12472
+ clearAll() {
12473
+ this.materials.clear();
12474
+ this.setters.clear();
12475
+ }
12476
+ getMap(type) {
12477
+ return type === 'material' ? this.materials : this.setters;
12478
+ }
12479
+ }
12480
+ const resourceRegistry = new ResourceRegistry();
12481
+
11716
12482
  let _initProto$1;
11717
12483
  const logger$2 = createLogger('Setters');
11718
12484
  class Setters {
@@ -12068,14 +12834,18 @@ const destroy = async () => {
12068
12834
  logger.info('Engine destruction successfully');
12069
12835
  };
12070
12836
 
12071
- const version = '1.0.1';
12837
+ const version = '1.0.2';
12072
12838
  config.set('VERSION', version);
12073
12839
  console.log(`%c EasyEditor %c v${version} `, 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #5584ff; font-weight: bold;', 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;');
12074
12840
 
12841
+ exports.AssetLevel = AssetLevel;
12842
+ exports.AssetLevels = AssetLevels;
12843
+ exports.AssetType = AssetType;
12075
12844
  exports.AutoFit = AutoFit;
12076
12845
  exports.COMPONENT_META_EVENT = COMPONENT_META_EVENT;
12077
12846
  exports.ComponentMeta = ComponentMeta;
12078
12847
  exports.Config = Config;
12848
+ exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
12079
12849
  exports.DESIGNER_EVENT = DESIGNER_EVENT;
12080
12850
  exports.DETECTING_EVENT = DETECTING_EVENT;
12081
12851
  exports.DOCUMENT_EVENT = DOCUMENT_EVENT;
@@ -12094,9 +12864,14 @@ exports.GLOBAL_EVENT = GLOBAL_EVENT;
12094
12864
  exports.HISTORY_EVENT = HISTORY_EVENT;
12095
12865
  exports.History = History;
12096
12866
  exports.Hotkey = Hotkey;
12867
+ exports.LoadingStateManager = LoadingStateManager;
12868
+ exports.LoadingStatus = LoadingStatus;
12097
12869
  exports.LocationDetailType = LocationDetailType;
12098
12870
  exports.Logger = Logger;
12099
12871
  exports.MOBX_EXTEND_SYMBOL = MOBX_EXTEND_SYMBOL;
12872
+ exports.MaterialRegistry = MaterialRegistry;
12873
+ exports.MaterialSource = MaterialSource;
12874
+ exports.MaterialStatus = MaterialStatus;
12100
12875
  exports.Materials = Materials;
12101
12876
  exports.MobxExtendType = MobxExtendType;
12102
12877
  exports.NODE_CHILDREN_EVENT = NODE_CHILDREN_EVENT;
@@ -12113,6 +12888,10 @@ exports.Project = Project;
12113
12888
  exports.Prop = Prop;
12114
12889
  exports.PropValueChangedType = PropValueChangedType;
12115
12890
  exports.Props = Props;
12891
+ exports.RegistryEventType = RegistryEventType;
12892
+ exports.RemoteLoadError = RemoteLoadError;
12893
+ exports.RemoteLoadErrorType = RemoteLoadErrorType;
12894
+ exports.ResourceRegistry = ResourceRegistry;
12116
12895
  exports.SELECTION_EVENT = SELECTION_EVENT;
12117
12896
  exports.Selection = Selection;
12118
12897
  exports.Session = Session;
@@ -12123,7 +12902,7 @@ exports.SettingTopEntry = SettingTopEntry;
12123
12902
  exports.SettingsManager = SettingsManager;
12124
12903
  exports.Simulator = Simulator;
12125
12904
  exports.TRANSFORM_STAGE = TRANSFORM_STAGE;
12126
- exports.UNSET = UNSET;
12905
+ exports.UNSET = UNSET$1;
12127
12906
  exports.Viewport = Viewport;
12128
12907
  exports.addMobxExtendProperty = addMobxExtendProperty;
12129
12908
  exports.clipboard = clipboard;
@@ -12180,6 +12959,7 @@ exports.isProCodeComponentType = isProCodeComponentType;
12180
12959
  exports.isProp = isProp;
12181
12960
  exports.isPurgeable = isPurgeable;
12182
12961
  exports.isRegisterOptions = isRegisterOptions;
12962
+ exports.isRemoteComponent = isRemoteComponent;
12183
12963
  exports.isSameAs = isSameAs;
12184
12964
  exports.isSetterConfig = isSetterConfig;
12185
12965
  exports.isSettingField = isSettingField;
@@ -12188,6 +12968,7 @@ exports.isSimulator = isSimulator;
12188
12968
  exports.isSimulatorRenderer = isSimulatorRenderer;
12189
12969
  exports.isTextNode = isTextNode;
12190
12970
  exports.isValidArrayIndex = isValidArrayIndex;
12971
+ exports.loadingState = loadingState;
12191
12972
  exports.logger = logger;
12192
12973
  exports.makeEventsHandler = makeEventsHandler;
12193
12974
  exports.materials = materials;
@@ -12199,6 +12980,7 @@ exports.mobxExtendObservable = mobxExtendObservable;
12199
12980
  exports.mobxExtendObservableRef = mobxExtendObservableRef;
12200
12981
  exports.mobxExtendObservableShallow = mobxExtendObservableShallow;
12201
12982
  exports.project = project;
12983
+ exports.resourceRegistry = resourceRegistry;
12202
12984
  exports.setShaken = setShaken;
12203
12985
  exports.setters = setters;
12204
12986
  exports.splitPath = splitPath;