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