@typemf/core 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -47,7 +47,6 @@ __export(index_exports, {
47
47
  EcoreFactoryImpl: () => EcoreFactoryImpl,
48
48
  EcorePackageImpl: () => EcorePackageImpl,
49
49
  Ids: () => Ids,
50
- ProxyEObjectImpl: () => ProxyEObjectImpl,
51
50
  ResourceFactoryRegistryImpl: () => ResourceFactoryRegistryImpl,
52
51
  ResourceImpl: () => ResourceImpl,
53
52
  ResourceSetImpl: () => ResourceSetImpl,
@@ -56,8 +55,10 @@ __export(index_exports, {
56
55
  associateRoot: () => associateRoot,
57
56
  computeFragment: () => computeFragment,
58
57
  createInstanceOf: () => createInstanceOf,
58
+ createProxy: () => createProxy,
59
59
  detailValue: () => detailValue,
60
60
  dissociateRoot: () => dissociateRoot,
61
+ getProxyURI: () => getProxyURI,
61
62
  getResourceOf: () => getResourceOf,
62
63
  isEAnnotation: () => isEAnnotation,
63
64
  isEAttribute: () => isEAttribute,
@@ -138,6 +139,13 @@ var BasicEList = class {
138
139
  const removed = this.items.splice(0, this.items.length);
139
140
  for (const item of removed) this.onRemoved(item, 0);
140
141
  }
142
+ move(fromIndex, toIndex) {
143
+ const item = this.get(fromIndex);
144
+ this.items.splice(fromIndex, 1);
145
+ this.items.splice(toIndex, 0, item);
146
+ this.onMoved(item, fromIndex, toIndex);
147
+ return item;
148
+ }
141
149
  contains(item) {
142
150
  return this.items.includes(item);
143
151
  }
@@ -222,6 +230,24 @@ var BasicEList = class {
222
230
  });
223
231
  }
224
232
  }
233
+ /**
234
+ * CORE-12: the element stays in the list throughout - no containment/opposite change, so
235
+ * unlike onAdded/onRemoved there's no eDidAdd/eDidRemove to call, only the notification
236
+ * (real EMF's own MOVE: oldValue is the OLD position, newValue is the moved element, position
237
+ * is the NEW position).
238
+ */
239
+ onMoved(item, fromIndex, toIndex) {
240
+ if (!this.owner || !this.feature) return;
241
+ this.owner.eNotify({
242
+ eventType: "MOVE",
243
+ notifier: this.owner,
244
+ feature: this.feature,
245
+ oldValue: fromIndex,
246
+ newValue: item,
247
+ position: toIndex,
248
+ wasSet: true
249
+ });
250
+ }
225
251
  };
226
252
  function isReference(feature) {
227
253
  return "isContainment" in feature;
@@ -229,10 +255,24 @@ function isReference(feature) {
229
255
 
230
256
  // src/metamodel/impl/EObjectImpl.ts
231
257
  var fallbackIdCounter = 0;
258
+ function findRoot(obj) {
259
+ let current = obj;
260
+ let container = current.eContainer();
261
+ while (container) {
262
+ current = container;
263
+ container = current.eContainer();
264
+ }
265
+ return current;
266
+ }
232
267
  var EObjectImpl = class _EObjectImpl {
233
268
  _eContainer;
234
269
  _eContainingFeature;
270
+ _eProxy = false;
235
271
  frozen = false;
272
+ /** Only ever set on a root (see eSetDirectResource) - a non-root's eResource() is found by
273
+ * walking up to its root via eContainer() instead, exactly like real EMF's own
274
+ * eDirectResource field. */
275
+ _eDirectResource;
236
276
  /**
237
277
  * Marks this object (and, recursively, everything it contains) as no longer intended to be
238
278
  * mutated. Matches real EMF's own design precisely: a queryable flag, not enforced in every
@@ -270,6 +310,20 @@ var EObjectImpl = class _EObjectImpl {
270
310
  freezeChild(child) {
271
311
  if (child instanceof _EObjectImpl) child.freeze();
272
312
  }
313
+ /**
314
+ * EMF rejects a feature that doesn't belong to this object's own class outright, rather than
315
+ * dispatching on `feature.getFeatureID()` alone - two unrelated classes' features can share the
316
+ * same id (each is only unique within its own declaring class, or - for a dynamic class with
317
+ * multiple supertypes, see CORE-05 - within `getEAllStructuralFeatures()`'s own position-based
318
+ * scheme), so reading or writing by id alone silently hits the wrong field when a caller passes
319
+ * a feature from some other EClass entirely. Every generated eGet/eSet/eIsSet/eUnset
320
+ * (eclass.njk) and DynamicEObjectImpl call this first, before dispatching on the id.
321
+ */
322
+ requireOwnFeature(feature) {
323
+ if (!this.eClass().getEAllStructuralFeatures().contains(feature)) {
324
+ throw new Error(`The feature '${feature.getName()}' is not a valid feature`);
325
+ }
326
+ }
273
327
  listeners = [];
274
328
  deliverFlag = true;
275
329
  onDidChange(callback, feature) {
@@ -312,6 +366,20 @@ var EObjectImpl = class _EObjectImpl {
312
366
  eContainingFeature() {
313
367
  return this._eContainingFeature;
314
368
  }
369
+ eResource() {
370
+ return findRoot(this)._eDirectResource;
371
+ }
372
+ /**
373
+ * Internal - not part of the public EObject API, same as eBasicSetContainer/eSetProxy. Called
374
+ * by Resource's own contents list (resource/resource-impl.ts) as an object enters/leaves
375
+ * getContents() - the only time an object's OWN eResource() is ever set directly; every other
376
+ * object's eResource() is found by walking up to its root instead (see eResource() above).
377
+ * Resetting a former root's own direct resource when it becomes contained elsewhere, or leaves
378
+ * a resource's contents, is resource-impl.ts's responsibility, not this method's.
379
+ */
380
+ eSetDirectResource(resource) {
381
+ this._eDirectResource = resource;
382
+ }
315
383
  /**
316
384
  * Internal - called by BasicEList (for many-valued containment features)
317
385
  * and by single-valued containment setters to update the backpointer.
@@ -386,12 +454,35 @@ var EObjectImpl = class _EObjectImpl {
386
454
  */
387
455
  eInverseAdd(otherEnd, feature) {
388
456
  if (feature.isMany()) {
389
- this.eBasicList(feature).basicAdd(otherEnd);
457
+ const list = this.eBasicList(feature);
458
+ const sizeBefore = list.size();
459
+ list.basicAdd(otherEnd);
460
+ if (list.size() > sizeBefore) {
461
+ this.eNotify({
462
+ eventType: "ADD",
463
+ notifier: this,
464
+ feature,
465
+ oldValue: void 0,
466
+ newValue: otherEnd,
467
+ position: list.size() - 1,
468
+ wasSet: true
469
+ });
470
+ }
390
471
  } else {
391
472
  const oldValue = this.eGet(feature);
392
473
  if (oldValue === otherEnd) return;
474
+ const wasSet = this.eIsSet(feature);
393
475
  this.eBasicSetValue(feature, otherEnd);
394
476
  this.eDidRemove(feature, oldValue);
477
+ this.eNotify({
478
+ eventType: "SET",
479
+ notifier: this,
480
+ feature,
481
+ oldValue,
482
+ newValue: otherEnd,
483
+ position: void 0,
484
+ wasSet
485
+ });
395
486
  }
396
487
  if (feature.isContainment()) otherEnd.eBasicMoveInto(this, feature);
397
488
  }
@@ -425,11 +516,60 @@ var EObjectImpl = class _EObjectImpl {
425
516
  this.eBasicSetContainer(void 0, void 0);
426
517
  }
427
518
  }
519
+ /**
520
+ * Internal - detaches `this` from whatever containment feature currently holds it (clearing the
521
+ * old container's own feature value and opposite, same cleanup eBasicMoveInto does for a move
522
+ * into a new container), without moving it anywhere new. Not part of the public EObject API;
523
+ * used by Resource's own contents list (resource/resource-impl.ts) when an already-contained
524
+ * object becomes a document root instead - EMF semantics: adding moves the object, it never
525
+ * belongs to a container and a resource's roots at the same time.
526
+ */
527
+ eBasicDetachFromContainer() {
528
+ const oldContainer = this._eContainer;
529
+ const oldFeature = this._eContainingFeature;
530
+ if (oldContainer instanceof _EObjectImpl && oldFeature && isReference2(oldFeature)) {
531
+ oldContainer.eBasicRemoveValue(oldFeature, this);
532
+ const oldOpposite = oldFeature.getEOpposite();
533
+ if (oldOpposite) this.eBasicRemoveValue(oldOpposite, oldContainer);
534
+ }
535
+ this.eBasicSetContainer(void 0, void 0);
536
+ }
537
+ /**
538
+ * CORE-09: every caller of this (eInverseRemove's own "opposite stopped referencing me", and
539
+ * eBasicMoveInto/eBasicDetachFromContainer clearing an old container or its opposite) silently
540
+ * mutated storage with no notification - the affected object's own listeners (and the instance
541
+ * editor's webview relay) never found out, even though a real change happened. Fires the same
542
+ * REMOVE/SET a plain eSet()/BasicEList.remove() would have, for whichever of those the normal
543
+ * path this bypasses (deliberately, to avoid re-triggering containment/opposite bookkeeping
544
+ * recursively) would otherwise have fired.
545
+ */
428
546
  eBasicRemoveValue(feature, value) {
429
547
  if (feature.isMany()) {
430
- this.eBasicList(feature).basicRemove(value);
548
+ const list = this.eBasicList(feature);
549
+ const position = list.indexOf(value);
550
+ if (list.basicRemove(value)) {
551
+ this.eNotify({
552
+ eventType: "REMOVE",
553
+ notifier: this,
554
+ feature,
555
+ oldValue: value,
556
+ newValue: void 0,
557
+ position,
558
+ wasSet: true
559
+ });
560
+ }
431
561
  } else if (this.eGet(feature) === value) {
562
+ const wasSet = this.eIsSet(feature);
432
563
  this.eBasicSetValue(feature, void 0);
564
+ this.eNotify({
565
+ eventType: "SET",
566
+ notifier: this,
567
+ feature,
568
+ oldValue: value,
569
+ newValue: void 0,
570
+ position: void 0,
571
+ wasSet
572
+ });
433
573
  }
434
574
  }
435
575
  eBasicList(feature) {
@@ -463,7 +603,17 @@ var EObjectImpl = class _EObjectImpl {
463
603
  return result;
464
604
  }
465
605
  eIsProxy() {
466
- return false;
606
+ return this._eProxy;
607
+ }
608
+ /**
609
+ * Internal - flips the proxy flag. Not part of the public EObject interface, same as
610
+ * eBasicSetContainer/eBasicSetValue; only `resource/proxy.ts`'s createProxy() calls this, right
611
+ * after constructing a real instance of the target EClass through its own factory - a proxy is
612
+ * not a separate class, just an ordinary, freshly-constructed instance flagged as a stand-in
613
+ * until something resolves it.
614
+ */
615
+ eSetProxy(flag) {
616
+ this._eProxy = flag;
467
617
  }
468
618
  fullId() {
469
619
  const className = this.eClass().getName();
@@ -489,12 +639,27 @@ function isEListOfEObject(value) {
489
639
 
490
640
  // src/metamodel/impl/EcorePackageRef.ts
491
641
  var ref;
642
+ var initializer;
643
+ var initializing = false;
492
644
  function setEcorePackageRef(pkg) {
493
645
  ref = pkg;
494
646
  }
647
+ function registerEcorePackageInitializer(init) {
648
+ initializer = init;
649
+ }
495
650
  function getEcorePackageRef() {
651
+ if (!ref && initializer && !initializing) {
652
+ initializing = true;
653
+ try {
654
+ initializer();
655
+ } finally {
656
+ initializing = false;
657
+ }
658
+ }
496
659
  if (!ref) {
497
- throw new Error("getEcorePackageRef() called before the EcorePackage singleton finished constructing itself.");
660
+ throw new Error(
661
+ "getEcorePackageRef() called before the EcorePackage singleton finished constructing itself, and no initializer was registered to construct it on demand - this means EcorePackageImpl.ts's own module was never evaluated at all (an unusual bundler/tree-shaking setup). Call EcorePackageImpl.eINSTANCE or .init() yourself first, or check that this package is marked side-effectful."
662
+ );
498
663
  }
499
664
  return ref;
500
665
  }
@@ -519,6 +684,7 @@ var EStringToStringMapEntryImpl = class extends EObjectImpl {
519
684
  this.eSet(getEcorePackageRef().getEStringToStringMapEntry_Value(), value);
520
685
  }
521
686
  eGet(feature) {
687
+ this.requireOwnFeature(feature);
522
688
  switch (feature.getFeatureID()) {
523
689
  case 0:
524
690
  return this._key;
@@ -529,6 +695,7 @@ var EStringToStringMapEntryImpl = class extends EObjectImpl {
529
695
  }
530
696
  }
531
697
  eSet(feature, value) {
698
+ this.requireOwnFeature(feature);
532
699
  switch (feature.getFeatureID()) {
533
700
  case 0: {
534
701
  const oldValue = this.eGet(feature);
@@ -590,6 +757,7 @@ var EStringToStringMapEntryImpl = class extends EObjectImpl {
590
757
  }
591
758
  }
592
759
  eIsSet(feature) {
760
+ this.requireOwnFeature(feature);
593
761
  switch (feature.getFeatureID()) {
594
762
  case 0:
595
763
  return this._key !== void 0;
@@ -600,6 +768,7 @@ var EStringToStringMapEntryImpl = class extends EObjectImpl {
600
768
  }
601
769
  }
602
770
  eUnset(feature) {
771
+ this.requireOwnFeature(feature);
603
772
  switch (feature.getFeatureID()) {
604
773
  case 0: {
605
774
  const wasSet = this.eIsSet(feature);
@@ -672,7 +841,7 @@ var DynamicEObjectImpl = class extends EObjectImpl {
672
841
  this.dynamicEClass = dynamicEClass;
673
842
  for (const feature of dynamicEClass.getEAllStructuralFeatures()) {
674
843
  if (feature.isMany()) {
675
- this.values.set(feature.getFeatureID(), new BasicEList(this, feature));
844
+ this.values.set(this.dynamicEClass.getFeatureID(feature), new BasicEList(this, feature));
676
845
  }
677
846
  }
678
847
  }
@@ -682,10 +851,12 @@ var DynamicEObjectImpl = class extends EObjectImpl {
682
851
  return this.dynamicEClass;
683
852
  }
684
853
  eGet(feature) {
685
- return this.values.get(feature.getFeatureID());
854
+ this.requireOwnFeature(feature);
855
+ return this.values.get(this.dynamicEClass.getFeatureID(feature));
686
856
  }
687
857
  eSet(feature, value) {
688
- const id = feature.getFeatureID();
858
+ this.requireOwnFeature(feature);
859
+ const id = this.dynamicEClass.getFeatureID(feature);
689
860
  if (feature.isMany()) {
690
861
  const list = this.requireList(feature);
691
862
  const items = value === void 0 || value === null ? [] : [...value];
@@ -702,14 +873,16 @@ var DynamicEObjectImpl = class extends EObjectImpl {
702
873
  this.eNotify({ eventType: "SET", notifier: this, feature, oldValue, newValue: value, position: void 0, wasSet });
703
874
  }
704
875
  eIsSet(feature) {
705
- const id = feature.getFeatureID();
876
+ this.requireOwnFeature(feature);
877
+ const id = this.dynamicEClass.getFeatureID(feature);
706
878
  if (feature.isMany()) {
707
879
  return this.values.get(id)?.size() !== 0;
708
880
  }
709
881
  return this.values.has(id) && this.values.get(id) !== void 0;
710
882
  }
711
883
  eUnset(feature) {
712
- const id = feature.getFeatureID();
884
+ this.requireOwnFeature(feature);
885
+ const id = this.dynamicEClass.getFeatureID(feature);
713
886
  if (feature.isMany()) {
714
887
  this.requireList(feature).clear();
715
888
  return;
@@ -729,14 +902,15 @@ var DynamicEObjectImpl = class extends EObjectImpl {
729
902
  });
730
903
  }
731
904
  eBasicSetValue(feature, value) {
905
+ const id = this.dynamicEClass.getFeatureID(feature);
732
906
  if (value === void 0) {
733
- this.values.delete(feature.getFeatureID());
907
+ this.values.delete(id);
734
908
  } else {
735
- this.values.set(feature.getFeatureID(), value);
909
+ this.values.set(id, value);
736
910
  }
737
911
  }
738
912
  requireList(feature) {
739
- const list = this.values.get(feature.getFeatureID());
913
+ const list = this.values.get(this.dynamicEClass.getFeatureID(feature));
740
914
  if (!(list instanceof BasicEList)) {
741
915
  throw new Error(
742
916
  `Feature '${feature.getName()}' is many-valued but has no backing EList - this DynamicEObjectImpl may have been constructed against a stale EClass (its structural features changed after construction).`
@@ -763,6 +937,7 @@ var EModelElementImpl = class extends EObjectImpl {
763
937
  return this.getEAnnotations().filter((ann) => ann.getSource() === source).at(0);
764
938
  }
765
939
  eGet(feature) {
940
+ this.requireOwnFeature(feature);
766
941
  switch (feature.getFeatureID()) {
767
942
  case 0:
768
943
  return this._eAnnotations;
@@ -771,6 +946,7 @@ var EModelElementImpl = class extends EObjectImpl {
771
946
  }
772
947
  }
773
948
  eSet(feature, value) {
949
+ this.requireOwnFeature(feature);
774
950
  switch (feature.getFeatureID()) {
775
951
  case 0: {
776
952
  const list = this._eAnnotations;
@@ -800,6 +976,7 @@ var EModelElementImpl = class extends EObjectImpl {
800
976
  }
801
977
  }
802
978
  eIsSet(feature) {
979
+ this.requireOwnFeature(feature);
803
980
  switch (feature.getFeatureID()) {
804
981
  case 0:
805
982
  return this._eAnnotationsCache !== void 0 && this._eAnnotationsCache.size() !== 0;
@@ -808,6 +985,7 @@ var EModelElementImpl = class extends EObjectImpl {
808
985
  }
809
986
  }
810
987
  eUnset(feature) {
988
+ this.requireOwnFeature(feature);
811
989
  switch (feature.getFeatureID()) {
812
990
  case 0:
813
991
  this._eAnnotationsCache?.clear();
@@ -883,6 +1061,7 @@ var EFactoryImpl = class extends EModelElementImpl {
883
1061
  return String(instanceValue);
884
1062
  }
885
1063
  eGet(feature) {
1064
+ this.requireOwnFeature(feature);
886
1065
  switch (feature.getFeatureID()) {
887
1066
  case 1:
888
1067
  return this._ePackage;
@@ -891,6 +1070,7 @@ var EFactoryImpl = class extends EModelElementImpl {
891
1070
  }
892
1071
  }
893
1072
  eSet(feature, value) {
1073
+ this.requireOwnFeature(feature);
894
1074
  switch (feature.getFeatureID()) {
895
1075
  case 1: {
896
1076
  const oldValue = this.eGet(feature);
@@ -933,6 +1113,7 @@ var EFactoryImpl = class extends EModelElementImpl {
933
1113
  }
934
1114
  }
935
1115
  eIsSet(feature) {
1116
+ this.requireOwnFeature(feature);
936
1117
  switch (feature.getFeatureID()) {
937
1118
  case 1:
938
1119
  return this._ePackage !== void 0;
@@ -941,6 +1122,7 @@ var EFactoryImpl = class extends EModelElementImpl {
941
1122
  }
942
1123
  }
943
1124
  eUnset(feature) {
1125
+ this.requireOwnFeature(feature);
944
1126
  switch (feature.getFeatureID()) {
945
1127
  case 1: {
946
1128
  const wasSet = this.eIsSet(feature);
@@ -1019,6 +1201,7 @@ var EAnnotationImpl = class extends EModelElementImpl {
1019
1201
  return this._references;
1020
1202
  }
1021
1203
  eGet(feature) {
1204
+ this.requireOwnFeature(feature);
1022
1205
  switch (feature.getFeatureID()) {
1023
1206
  case 1:
1024
1207
  return this._source;
@@ -1035,6 +1218,7 @@ var EAnnotationImpl = class extends EModelElementImpl {
1035
1218
  }
1036
1219
  }
1037
1220
  eSet(feature, value) {
1221
+ this.requireOwnFeature(feature);
1038
1222
  switch (feature.getFeatureID()) {
1039
1223
  case 1: {
1040
1224
  const oldValue = this.eGet(feature);
@@ -1128,6 +1312,7 @@ var EAnnotationImpl = class extends EModelElementImpl {
1128
1312
  }
1129
1313
  }
1130
1314
  eIsSet(feature) {
1315
+ this.requireOwnFeature(feature);
1131
1316
  switch (feature.getFeatureID()) {
1132
1317
  case 1:
1133
1318
  return this._source !== void 0;
@@ -1144,6 +1329,7 @@ var EAnnotationImpl = class extends EModelElementImpl {
1144
1329
  }
1145
1330
  }
1146
1331
  eUnset(feature) {
1332
+ this.requireOwnFeature(feature);
1147
1333
  switch (feature.getFeatureID()) {
1148
1334
  case 1: {
1149
1335
  const wasSet = this.eIsSet(feature);
@@ -1206,6 +1392,7 @@ var ENamedElementImpl = class extends EModelElementImpl {
1206
1392
  this.eSet(getEcorePackageRef().getENamedElement_Name(), value);
1207
1393
  }
1208
1394
  eGet(feature) {
1395
+ this.requireOwnFeature(feature);
1209
1396
  switch (feature.getFeatureID()) {
1210
1397
  case 1:
1211
1398
  return this._name;
@@ -1214,6 +1401,7 @@ var ENamedElementImpl = class extends EModelElementImpl {
1214
1401
  }
1215
1402
  }
1216
1403
  eSet(feature, value) {
1404
+ this.requireOwnFeature(feature);
1217
1405
  switch (feature.getFeatureID()) {
1218
1406
  case 1: {
1219
1407
  const oldValue = this.eGet(feature);
@@ -1256,6 +1444,7 @@ var ENamedElementImpl = class extends EModelElementImpl {
1256
1444
  }
1257
1445
  }
1258
1446
  eIsSet(feature) {
1447
+ this.requireOwnFeature(feature);
1259
1448
  switch (feature.getFeatureID()) {
1260
1449
  case 1:
1261
1450
  return this._name !== void 0;
@@ -1264,6 +1453,7 @@ var ENamedElementImpl = class extends EModelElementImpl {
1264
1453
  }
1265
1454
  }
1266
1455
  eUnset(feature) {
1456
+ this.requireOwnFeature(feature);
1267
1457
  switch (feature.getFeatureID()) {
1268
1458
  case 1: {
1269
1459
  const wasSet = this.eIsSet(feature);
@@ -1369,6 +1559,7 @@ var ETypedElementImpl = class extends ENamedElementImpl {
1369
1559
  });
1370
1560
  }
1371
1561
  eGet(feature) {
1562
+ this.requireOwnFeature(feature);
1372
1563
  switch (feature.getFeatureID()) {
1373
1564
  case 2:
1374
1565
  return this._ordered;
@@ -1391,6 +1582,7 @@ var ETypedElementImpl = class extends ENamedElementImpl {
1391
1582
  }
1392
1583
  }
1393
1584
  eSet(feature, value) {
1585
+ this.requireOwnFeature(feature);
1394
1586
  switch (feature.getFeatureID()) {
1395
1587
  case 2: {
1396
1588
  const oldValue = this.eGet(feature);
@@ -1516,6 +1708,7 @@ var ETypedElementImpl = class extends ENamedElementImpl {
1516
1708
  }
1517
1709
  }
1518
1710
  eIsSet(feature) {
1711
+ this.requireOwnFeature(feature);
1519
1712
  switch (feature.getFeatureID()) {
1520
1713
  case 2:
1521
1714
  return this._ordered !== true;
@@ -1538,6 +1731,7 @@ var ETypedElementImpl = class extends ENamedElementImpl {
1538
1731
  }
1539
1732
  }
1540
1733
  eUnset(feature) {
1734
+ this.requireOwnFeature(feature);
1541
1735
  switch (feature.getFeatureID()) {
1542
1736
  case 2: {
1543
1737
  const wasSet = this.eIsSet(feature);
@@ -1750,6 +1944,7 @@ var EStructuralFeatureImpl = class extends ETypedElementImpl {
1750
1944
  this._eContainingClass = value;
1751
1945
  }
1752
1946
  eGet(feature) {
1947
+ this.requireOwnFeature(feature);
1753
1948
  switch (feature.getFeatureID()) {
1754
1949
  case 10:
1755
1950
  return this._changeable;
@@ -1772,6 +1967,7 @@ var EStructuralFeatureImpl = class extends ETypedElementImpl {
1772
1967
  }
1773
1968
  }
1774
1969
  eSet(feature, value) {
1970
+ this.requireOwnFeature(feature);
1775
1971
  switch (feature.getFeatureID()) {
1776
1972
  case 10: {
1777
1973
  const oldValue = this.eGet(feature);
@@ -1925,6 +2121,7 @@ var EStructuralFeatureImpl = class extends ETypedElementImpl {
1925
2121
  }
1926
2122
  }
1927
2123
  eIsSet(feature) {
2124
+ this.requireOwnFeature(feature);
1928
2125
  switch (feature.getFeatureID()) {
1929
2126
  case 10:
1930
2127
  return this._changeable !== true;
@@ -1947,6 +2144,7 @@ var EStructuralFeatureImpl = class extends ETypedElementImpl {
1947
2144
  }
1948
2145
  }
1949
2146
  eUnset(feature) {
2147
+ this.requireOwnFeature(feature);
1950
2148
  switch (feature.getFeatureID()) {
1951
2149
  case 10: {
1952
2150
  const wasSet = this.eIsSet(feature);
@@ -2100,6 +2298,7 @@ var EAttributeImpl = class extends EStructuralFeatureImpl {
2100
2298
  return this.getEType();
2101
2299
  }
2102
2300
  eGet(feature) {
2301
+ this.requireOwnFeature(feature);
2103
2302
  switch (feature.getFeatureID()) {
2104
2303
  case 18:
2105
2304
  return this._iD;
@@ -2110,6 +2309,7 @@ var EAttributeImpl = class extends EStructuralFeatureImpl {
2110
2309
  }
2111
2310
  }
2112
2311
  eSet(feature, value) {
2312
+ this.requireOwnFeature(feature);
2113
2313
  switch (feature.getFeatureID()) {
2114
2314
  case 18: {
2115
2315
  const oldValue = this.eGet(feature);
@@ -2155,6 +2355,7 @@ var EAttributeImpl = class extends EStructuralFeatureImpl {
2155
2355
  }
2156
2356
  }
2157
2357
  eIsSet(feature) {
2358
+ this.requireOwnFeature(feature);
2158
2359
  switch (feature.getFeatureID()) {
2159
2360
  case 18:
2160
2361
  return this._iD !== false;
@@ -2165,6 +2366,7 @@ var EAttributeImpl = class extends EStructuralFeatureImpl {
2165
2366
  }
2166
2367
  }
2167
2368
  eUnset(feature) {
2369
+ this.requireOwnFeature(feature);
2168
2370
  switch (feature.getFeatureID()) {
2169
2371
  case 18: {
2170
2372
  const wasSet = this.eIsSet(feature);
@@ -2264,9 +2466,42 @@ var EClassifierImpl = class extends ENamedElementImpl {
2264
2466
  return this._eTypeParameters;
2265
2467
  }
2266
2468
  isInstance(object) {
2267
- return object instanceof EObjectImpl;
2469
+ switch (this.eClass().getName()) {
2470
+ case "EClass":
2471
+ return object instanceof EObjectImpl && this.isSuperTypeOf(object.eClass());
2472
+ default:
2473
+ switch (this.getName()) {
2474
+ case "EString":
2475
+ case "EChar":
2476
+ case "ECharacterObject":
2477
+ return typeof object === "string";
2478
+ case "EInt":
2479
+ case "EIntegerObject":
2480
+ case "ELong":
2481
+ case "ELongObject":
2482
+ case "EDouble":
2483
+ case "EDoubleObject":
2484
+ case "EFloat":
2485
+ case "EFloatObject":
2486
+ case "EShort":
2487
+ case "EShortObject":
2488
+ case "EByte":
2489
+ case "EByteObject":
2490
+ return typeof object === "number";
2491
+ case "EBigInteger":
2492
+ return typeof object === "bigint";
2493
+ case "EBoolean":
2494
+ case "EBooleanObject":
2495
+ return typeof object === "boolean";
2496
+ case "EDate":
2497
+ return object instanceof Date;
2498
+ default:
2499
+ return object !== void 0 && object !== null;
2500
+ }
2501
+ }
2268
2502
  }
2269
2503
  eGet(feature) {
2504
+ this.requireOwnFeature(feature);
2270
2505
  switch (feature.getFeatureID()) {
2271
2506
  case 2:
2272
2507
  return this._instanceClassName;
@@ -2285,6 +2520,7 @@ var EClassifierImpl = class extends ENamedElementImpl {
2285
2520
  }
2286
2521
  }
2287
2522
  eSet(feature, value) {
2523
+ this.requireOwnFeature(feature);
2288
2524
  switch (feature.getFeatureID()) {
2289
2525
  case 2: {
2290
2526
  const oldValue = this.eGet(feature);
@@ -2367,6 +2603,7 @@ var EClassifierImpl = class extends ENamedElementImpl {
2367
2603
  }
2368
2604
  }
2369
2605
  eIsSet(feature) {
2606
+ this.requireOwnFeature(feature);
2370
2607
  switch (feature.getFeatureID()) {
2371
2608
  case 2:
2372
2609
  return this._instanceClassName !== void 0;
@@ -2385,6 +2622,7 @@ var EClassifierImpl = class extends ENamedElementImpl {
2385
2622
  }
2386
2623
  }
2387
2624
  eUnset(feature) {
2625
+ this.requireOwnFeature(feature);
2388
2626
  switch (feature.getFeatureID()) {
2389
2627
  case 2: {
2390
2628
  const wasSet = this.eIsSet(feature);
@@ -2602,6 +2840,7 @@ var EGenericTypeImpl = class extends EObjectImpl {
2602
2840
  this.eSet(getEcorePackageRef().getEGenericType_EClassifier(), value);
2603
2841
  }
2604
2842
  eGet(feature) {
2843
+ this.requireOwnFeature(feature);
2605
2844
  switch (feature.getFeatureID()) {
2606
2845
  case 0:
2607
2846
  return this._eUpperBound;
@@ -2620,6 +2859,7 @@ var EGenericTypeImpl = class extends EObjectImpl {
2620
2859
  }
2621
2860
  }
2622
2861
  eSet(feature, value) {
2862
+ this.requireOwnFeature(feature);
2623
2863
  switch (feature.getFeatureID()) {
2624
2864
  case 0: {
2625
2865
  const oldValue = this.eGet(feature);
@@ -2733,6 +2973,7 @@ var EGenericTypeImpl = class extends EObjectImpl {
2733
2973
  }
2734
2974
  }
2735
2975
  eIsSet(feature) {
2976
+ this.requireOwnFeature(feature);
2736
2977
  switch (feature.getFeatureID()) {
2737
2978
  case 0:
2738
2979
  return this._eUpperBound !== void 0;
@@ -2751,6 +2992,7 @@ var EGenericTypeImpl = class extends EObjectImpl {
2751
2992
  }
2752
2993
  }
2753
2994
  eUnset(feature) {
2995
+ this.requireOwnFeature(feature);
2754
2996
  switch (feature.getFeatureID()) {
2755
2997
  case 0: {
2756
2998
  const wasSet = this.eIsSet(feature);
@@ -3098,7 +3340,8 @@ var EClassImpl = class extends EClassifierImpl {
3098
3340
  }
3099
3341
  getEStructuralFeature(featureIDOrFeatureName) {
3100
3342
  if (typeof featureIDOrFeatureName === "number") {
3101
- return this.getEAllStructuralFeatures().filter((feature) => this.getFeatureID(feature) === featureIDOrFeatureName).at(0);
3343
+ const features = this.getEAllStructuralFeatures();
3344
+ return featureIDOrFeatureName >= 0 && featureIDOrFeatureName < features.size() ? features.get(featureIDOrFeatureName) : void 0;
3102
3345
  }
3103
3346
  if (typeof featureIDOrFeatureName === "string") {
3104
3347
  return this.getEAllStructuralFeatures().filter((feature) => feature.getName() === featureIDOrFeatureName).at(0);
@@ -3106,7 +3349,7 @@ var EClassImpl = class extends EClassifierImpl {
3106
3349
  throw new Error("EClass.getEStructuralFeature(): no overload matches the given arguments.");
3107
3350
  }
3108
3351
  getFeatureID(feature) {
3109
- return feature.getFeatureID();
3352
+ return this.getEAllStructuralFeatures().indexOf(feature);
3110
3353
  }
3111
3354
  getOperationCount() {
3112
3355
  return this.getEAllOperations().size();
@@ -3125,6 +3368,7 @@ var EClassImpl = class extends EClassifierImpl {
3125
3368
  return void 0;
3126
3369
  }
3127
3370
  eGet(feature) {
3371
+ this.requireOwnFeature(feature);
3128
3372
  switch (feature.getFeatureID()) {
3129
3373
  case 8:
3130
3374
  return this._abstract;
@@ -3163,6 +3407,7 @@ var EClassImpl = class extends EClassifierImpl {
3163
3407
  }
3164
3408
  }
3165
3409
  eSet(feature, value) {
3410
+ this.requireOwnFeature(feature);
3166
3411
  switch (feature.getFeatureID()) {
3167
3412
  case 8: {
3168
3413
  const oldValue = this.eGet(feature);
@@ -3266,6 +3511,7 @@ var EClassImpl = class extends EClassifierImpl {
3266
3511
  }
3267
3512
  }
3268
3513
  eIsSet(feature) {
3514
+ this.requireOwnFeature(feature);
3269
3515
  switch (feature.getFeatureID()) {
3270
3516
  case 8:
3271
3517
  return this._abstract !== false;
@@ -3304,6 +3550,7 @@ var EClassImpl = class extends EClassifierImpl {
3304
3550
  }
3305
3551
  }
3306
3552
  eUnset(feature) {
3553
+ this.requireOwnFeature(feature);
3307
3554
  switch (feature.getFeatureID()) {
3308
3555
  case 8: {
3309
3556
  const wasSet = this.eIsSet(feature);
@@ -3369,6 +3616,7 @@ var EDataTypeImpl = class extends EClassifierImpl {
3369
3616
  this.eSet(getEcorePackageRef().getEDataType_Serializable(), value);
3370
3617
  }
3371
3618
  eGet(feature) {
3619
+ this.requireOwnFeature(feature);
3372
3620
  switch (feature.getFeatureID()) {
3373
3621
  case 8:
3374
3622
  return this._serializable;
@@ -3377,6 +3625,7 @@ var EDataTypeImpl = class extends EClassifierImpl {
3377
3625
  }
3378
3626
  }
3379
3627
  eSet(feature, value) {
3628
+ this.requireOwnFeature(feature);
3380
3629
  switch (feature.getFeatureID()) {
3381
3630
  case 8: {
3382
3631
  const oldValue = this.eGet(feature);
@@ -3419,6 +3668,7 @@ var EDataTypeImpl = class extends EClassifierImpl {
3419
3668
  }
3420
3669
  }
3421
3670
  eIsSet(feature) {
3671
+ this.requireOwnFeature(feature);
3422
3672
  switch (feature.getFeatureID()) {
3423
3673
  case 8:
3424
3674
  return this._serializable !== true;
@@ -3427,6 +3677,7 @@ var EDataTypeImpl = class extends EClassifierImpl {
3427
3677
  }
3428
3678
  }
3429
3679
  eUnset(feature) {
3680
+ this.requireOwnFeature(feature);
3430
3681
  switch (feature.getFeatureID()) {
3431
3682
  case 8: {
3432
3683
  const wasSet = this.eIsSet(feature);
@@ -3479,6 +3730,7 @@ var EEnumImpl = class extends EDataTypeImpl {
3479
3730
  return this.getELiterals().find((candidate) => candidate.getLiteral() === literal);
3480
3731
  }
3481
3732
  eGet(feature) {
3733
+ this.requireOwnFeature(feature);
3482
3734
  switch (feature.getFeatureID()) {
3483
3735
  case 9:
3484
3736
  return this._eLiterals;
@@ -3487,6 +3739,7 @@ var EEnumImpl = class extends EDataTypeImpl {
3487
3739
  }
3488
3740
  }
3489
3741
  eSet(feature, value) {
3742
+ this.requireOwnFeature(feature);
3490
3743
  switch (feature.getFeatureID()) {
3491
3744
  case 9: {
3492
3745
  const list = this._eLiterals;
@@ -3518,6 +3771,7 @@ var EEnumImpl = class extends EDataTypeImpl {
3518
3771
  }
3519
3772
  }
3520
3773
  eIsSet(feature) {
3774
+ this.requireOwnFeature(feature);
3521
3775
  switch (feature.getFeatureID()) {
3522
3776
  case 9:
3523
3777
  return this._eLiteralsCache !== void 0 && this._eLiteralsCache.size() !== 0;
@@ -3526,6 +3780,7 @@ var EEnumImpl = class extends EDataTypeImpl {
3526
3780
  }
3527
3781
  }
3528
3782
  eUnset(feature) {
3783
+ this.requireOwnFeature(feature);
3529
3784
  switch (feature.getFeatureID()) {
3530
3785
  case 9:
3531
3786
  this._eLiteralsCache?.clear();
@@ -3578,6 +3833,7 @@ var EEnumLiteralImpl = class extends ENamedElementImpl {
3578
3833
  this._eEnum = value;
3579
3834
  }
3580
3835
  eGet(feature) {
3836
+ this.requireOwnFeature(feature);
3581
3837
  switch (feature.getFeatureID()) {
3582
3838
  case 2:
3583
3839
  return this._value;
@@ -3592,6 +3848,7 @@ var EEnumLiteralImpl = class extends ENamedElementImpl {
3592
3848
  }
3593
3849
  }
3594
3850
  eSet(feature, value) {
3851
+ this.requireOwnFeature(feature);
3595
3852
  switch (feature.getFeatureID()) {
3596
3853
  case 2: {
3597
3854
  const oldValue = this.eGet(feature);
@@ -3662,6 +3919,7 @@ var EEnumLiteralImpl = class extends ENamedElementImpl {
3662
3919
  }
3663
3920
  }
3664
3921
  eIsSet(feature) {
3922
+ this.requireOwnFeature(feature);
3665
3923
  switch (feature.getFeatureID()) {
3666
3924
  case 2:
3667
3925
  return this._value !== 0;
@@ -3676,6 +3934,7 @@ var EEnumLiteralImpl = class extends ENamedElementImpl {
3676
3934
  }
3677
3935
  }
3678
3936
  eUnset(feature) {
3937
+ this.requireOwnFeature(feature);
3679
3938
  switch (feature.getFeatureID()) {
3680
3939
  case 2: {
3681
3940
  const wasSet = this.eIsSet(feature);
@@ -3822,6 +4081,7 @@ var EOperationImpl = class extends ETypedElementImpl {
3822
4081
  return true;
3823
4082
  }
3824
4083
  eGet(feature) {
4084
+ this.requireOwnFeature(feature);
3825
4085
  switch (feature.getFeatureID()) {
3826
4086
  case 10:
3827
4087
  return this._eContainingClass;
@@ -3838,6 +4098,7 @@ var EOperationImpl = class extends ETypedElementImpl {
3838
4098
  }
3839
4099
  }
3840
4100
  eSet(feature, value) {
4101
+ this.requireOwnFeature(feature);
3841
4102
  switch (feature.getFeatureID()) {
3842
4103
  case 11: {
3843
4104
  const list = this._eTypeParameters;
@@ -3902,6 +4163,7 @@ var EOperationImpl = class extends ETypedElementImpl {
3902
4163
  }
3903
4164
  }
3904
4165
  eIsSet(feature) {
4166
+ this.requireOwnFeature(feature);
3905
4167
  switch (feature.getFeatureID()) {
3906
4168
  case 10:
3907
4169
  return this._eContainingClass !== void 0;
@@ -3918,6 +4180,7 @@ var EOperationImpl = class extends ETypedElementImpl {
3918
4180
  }
3919
4181
  }
3920
4182
  eUnset(feature) {
4183
+ this.requireOwnFeature(feature);
3921
4184
  switch (feature.getFeatureID()) {
3922
4185
  case 10: {
3923
4186
  const wasSet = this.eIsSet(feature);
@@ -4007,6 +4270,7 @@ var EPackageImpl = class extends ENamedElementImpl {
4007
4270
  return this.getEClassifiers().filter((cl) => cl.getName() === name).at(0);
4008
4271
  }
4009
4272
  eGet(feature) {
4273
+ this.requireOwnFeature(feature);
4010
4274
  switch (feature.getFeatureID()) {
4011
4275
  case 2:
4012
4276
  return this._nsURI;
@@ -4025,6 +4289,7 @@ var EPackageImpl = class extends ENamedElementImpl {
4025
4289
  }
4026
4290
  }
4027
4291
  eSet(feature, value) {
4292
+ this.requireOwnFeature(feature);
4028
4293
  switch (feature.getFeatureID()) {
4029
4294
  case 2: {
4030
4295
  const oldValue = this.eGet(feature);
@@ -4132,6 +4397,7 @@ var EPackageImpl = class extends ENamedElementImpl {
4132
4397
  }
4133
4398
  }
4134
4399
  eIsSet(feature) {
4400
+ this.requireOwnFeature(feature);
4135
4401
  switch (feature.getFeatureID()) {
4136
4402
  case 2:
4137
4403
  return this._nsURI !== void 0;
@@ -4150,6 +4416,7 @@ var EPackageImpl = class extends ENamedElementImpl {
4150
4416
  }
4151
4417
  }
4152
4418
  eUnset(feature) {
4419
+ this.requireOwnFeature(feature);
4153
4420
  switch (feature.getFeatureID()) {
4154
4421
  case 2: {
4155
4422
  const wasSet = this.eIsSet(feature);
@@ -4241,6 +4508,7 @@ var EParameterImpl = class extends ETypedElementImpl {
4241
4508
  this._eOperation = value;
4242
4509
  }
4243
4510
  eGet(feature) {
4511
+ this.requireOwnFeature(feature);
4244
4512
  switch (feature.getFeatureID()) {
4245
4513
  case 10:
4246
4514
  return this._eOperation;
@@ -4249,6 +4517,7 @@ var EParameterImpl = class extends ETypedElementImpl {
4249
4517
  }
4250
4518
  }
4251
4519
  eSet(feature, value) {
4520
+ this.requireOwnFeature(feature);
4252
4521
  switch (feature.getFeatureID()) {
4253
4522
  default:
4254
4523
  super.eSet(feature, value);
@@ -4273,6 +4542,7 @@ var EParameterImpl = class extends ETypedElementImpl {
4273
4542
  }
4274
4543
  }
4275
4544
  eIsSet(feature) {
4545
+ this.requireOwnFeature(feature);
4276
4546
  switch (feature.getFeatureID()) {
4277
4547
  case 10:
4278
4548
  return this._eOperation !== void 0;
@@ -4281,6 +4551,7 @@ var EParameterImpl = class extends ETypedElementImpl {
4281
4551
  }
4282
4552
  }
4283
4553
  eUnset(feature) {
4554
+ this.requireOwnFeature(feature);
4284
4555
  switch (feature.getFeatureID()) {
4285
4556
  case 10: {
4286
4557
  const wasSet = this.eIsSet(feature);
@@ -4348,6 +4619,7 @@ var EReferenceImpl = class extends EStructuralFeatureImpl {
4348
4619
  return this._eKeys;
4349
4620
  }
4350
4621
  eGet(feature) {
4622
+ this.requireOwnFeature(feature);
4351
4623
  switch (feature.getFeatureID()) {
4352
4624
  case 18:
4353
4625
  return this._containment;
@@ -4366,6 +4638,7 @@ var EReferenceImpl = class extends EStructuralFeatureImpl {
4366
4638
  }
4367
4639
  }
4368
4640
  eSet(feature, value) {
4641
+ this.requireOwnFeature(feature);
4369
4642
  switch (feature.getFeatureID()) {
4370
4643
  case 18: {
4371
4644
  const oldValue = this.eGet(feature);
@@ -4466,6 +4739,7 @@ var EReferenceImpl = class extends EStructuralFeatureImpl {
4466
4739
  }
4467
4740
  }
4468
4741
  eIsSet(feature) {
4742
+ this.requireOwnFeature(feature);
4469
4743
  switch (feature.getFeatureID()) {
4470
4744
  case 18:
4471
4745
  return this._containment !== false;
@@ -4484,6 +4758,7 @@ var EReferenceImpl = class extends EStructuralFeatureImpl {
4484
4758
  }
4485
4759
  }
4486
4760
  eUnset(feature) {
4761
+ this.requireOwnFeature(feature);
4487
4762
  switch (feature.getFeatureID()) {
4488
4763
  case 18: {
4489
4764
  const wasSet = this.eIsSet(feature);
@@ -4589,6 +4864,7 @@ var ETypeParameterImpl = class extends ENamedElementImpl {
4589
4864
  return this._eBounds;
4590
4865
  }
4591
4866
  eGet(feature) {
4867
+ this.requireOwnFeature(feature);
4592
4868
  switch (feature.getFeatureID()) {
4593
4869
  case 2:
4594
4870
  return this._eBounds;
@@ -4597,6 +4873,7 @@ var ETypeParameterImpl = class extends ENamedElementImpl {
4597
4873
  }
4598
4874
  }
4599
4875
  eSet(feature, value) {
4876
+ this.requireOwnFeature(feature);
4600
4877
  switch (feature.getFeatureID()) {
4601
4878
  case 2: {
4602
4879
  const list = this._eBounds;
@@ -4628,6 +4905,7 @@ var ETypeParameterImpl = class extends ENamedElementImpl {
4628
4905
  }
4629
4906
  }
4630
4907
  eIsSet(feature) {
4908
+ this.requireOwnFeature(feature);
4631
4909
  switch (feature.getFeatureID()) {
4632
4910
  case 2:
4633
4911
  return this._eBoundsCache !== void 0 && this._eBoundsCache.size() !== 0;
@@ -4636,6 +4914,7 @@ var ETypeParameterImpl = class extends ENamedElementImpl {
4636
4914
  }
4637
4915
  }
4638
4916
  eUnset(feature) {
4917
+ this.requireOwnFeature(feature);
4639
4918
  switch (feature.getFeatureID()) {
4640
4919
  case 2:
4641
4920
  this._eBoundsCache?.clear();
@@ -4779,59 +5058,23 @@ function resolvePositionalPath(path, roots) {
4779
5058
  return current;
4780
5059
  }
4781
5060
 
4782
- // src/resource/proxy-eobject-impl.ts
4783
- var ProxyEObjectImpl = class extends EObjectImpl {
4784
- constructor(proxyEClass, proxyURI) {
4785
- super();
4786
- this.proxyEClass = proxyEClass;
4787
- this.proxyURI = proxyURI;
4788
- }
4789
- proxyEClass;
4790
- proxyURI;
4791
- eClass() {
4792
- return this.proxyEClass;
4793
- }
4794
- eIsProxy() {
4795
- return true;
4796
- }
4797
- getProxyURI() {
4798
- return this.proxyURI;
4799
- }
4800
- eContents() {
4801
- return new BasicEList();
4802
- }
4803
- eAllContents() {
4804
- return [];
4805
- }
4806
- fullId() {
4807
- return `Proxy(${this.proxyEClass.getName()}, ${this.proxyURI.toString()})`;
4808
- }
4809
- eGet(_feature) {
4810
- throw new Error(
4811
- `Cannot read a feature of an unresolved proxy (${this.fullId()}) - resolve it via ResourceSet.resolve() first.`
4812
- );
4813
- }
4814
- eSet(_feature, _value) {
4815
- throw new Error(
4816
- `Cannot set a feature of an unresolved proxy (${this.fullId()}) - resolve it via ResourceSet.resolve() first.`
4817
- );
4818
- }
4819
- eBasicSetValue(_feature, _value) {
4820
- throw new Error(
4821
- `Cannot set a feature of an unresolved proxy (${this.fullId()}) - resolve it via ResourceSet.resolve() first.`
4822
- );
4823
- }
4824
- eIsSet(_feature) {
4825
- throw new Error(
4826
- `Cannot check a feature of an unresolved proxy (${this.fullId()}) - resolve it via ResourceSet.resolve() first.`
4827
- );
4828
- }
4829
- eUnset(_feature) {
4830
- throw new Error(
4831
- `Cannot unset a feature of an unresolved proxy (${this.fullId()}) - resolve it via ResourceSet.resolve() first.`
4832
- );
4833
- }
4834
- };
5061
+ // src/resource/proxy.ts
5062
+ var proxyURIs = /* @__PURE__ */ new WeakMap();
5063
+ function createProxy(eClass, uri) {
5064
+ const factory = eClass.getEPackage()?.getEFactoryInstance();
5065
+ let obj;
5066
+ try {
5067
+ obj = factory ? factory.create(eClass) : new DynamicEObjectImpl(eClass);
5068
+ } catch {
5069
+ obj = new DynamicEObjectImpl(eClass);
5070
+ }
5071
+ obj.eSetProxy(true);
5072
+ proxyURIs.set(obj, uri);
5073
+ return obj;
5074
+ }
5075
+ function getProxyURI(obj) {
5076
+ return proxyURIs.get(obj);
5077
+ }
4835
5078
 
4836
5079
  // src/resource/resource-factory-registry-impl.ts
4837
5080
  var ResourceFactoryRegistryImpl = class {
@@ -4849,26 +5092,20 @@ var ResourceFactoryRegistryImpl = class {
4849
5092
  const byExtension = this.factoriesByExtension.get(extension);
4850
5093
  if (byExtension) return byExtension;
4851
5094
  }
4852
- return this.factoriesByProtocol.get(uri.getScheme());
5095
+ const scheme = uri.getScheme();
5096
+ return scheme === void 0 ? void 0 : this.factoriesByProtocol.get(scheme);
4853
5097
  }
4854
5098
  };
4855
5099
 
4856
5100
  // src/resource/resource-utils.ts
4857
- var resourceByRoot = /* @__PURE__ */ new WeakMap();
4858
5101
  function associateRoot(root, resource) {
4859
- resourceByRoot.set(root, resource);
5102
+ root.eSetDirectResource(resource);
4860
5103
  }
4861
5104
  function dissociateRoot(root) {
4862
- resourceByRoot.delete(root);
5105
+ root.eSetDirectResource(void 0);
4863
5106
  }
4864
5107
  function getResourceOf(obj) {
4865
- let current = obj;
4866
- let container = current.eContainer();
4867
- while (container) {
4868
- current = container;
4869
- container = current.eContainer();
4870
- }
4871
- return resourceByRoot.get(current);
5108
+ return obj.eResource();
4872
5109
  }
4873
5110
 
4874
5111
  // src/resource/resource-impl.ts
@@ -4879,13 +5116,28 @@ var ResourceContentsList = class extends BasicEList {
4879
5116
  }
4880
5117
  owningResource;
4881
5118
  add(item) {
5119
+ if (this.contains(item)) return;
5120
+ this.detachFromCurrentOwner(item);
4882
5121
  super.add(item);
4883
5122
  associateRoot(item, this.owningResource);
4884
5123
  }
4885
5124
  addAt(index, item) {
5125
+ if (this.contains(item)) return;
5126
+ this.detachFromCurrentOwner(item);
4886
5127
  super.addAt(index, item);
4887
5128
  associateRoot(item, this.owningResource);
4888
5129
  }
5130
+ detachFromCurrentOwner(item) {
5131
+ const container = item.eContainer();
5132
+ if (container) {
5133
+ item.eBasicDetachFromContainer();
5134
+ return;
5135
+ }
5136
+ const oldResource = getResourceOf(item);
5137
+ if (oldResource && oldResource !== this.owningResource) {
5138
+ oldResource.getContents().remove(item);
5139
+ }
5140
+ }
4889
5141
  addAll(items) {
4890
5142
  for (const item of items) this.add(item);
4891
5143
  }
@@ -5078,24 +5330,27 @@ var ResourceSetImpl = class {
5078
5330
  }
5079
5331
  async resolve(proxy) {
5080
5332
  if (!proxy.eIsProxy()) return proxy;
5081
- if (!(proxy instanceof ProxyEObjectImpl)) {
5082
- throw new Error("eIsProxy() is true but the object is not a ProxyEObjectImpl - cannot resolve it.");
5333
+ const proxyURI = getProxyURI(proxy);
5334
+ if (!proxyURI) {
5335
+ throw new Error(
5336
+ `eIsProxy() is true but no proxy URI is on record for this ${proxy.eClass().getName()} - it was not created via createProxy().`
5337
+ );
5083
5338
  }
5084
- const proxyURI = proxy.getProxyURI();
5339
+ const proxyLabel = `${proxy.eClass().getName()} (${proxyURI.toString()})`;
5085
5340
  const registeredPackage = this.packageRegistry.getPackage(proxyURI.trimFragment().toString());
5086
5341
  if (registeredPackage) {
5087
5342
  const fragment2 = proxyURI.getFragment();
5088
5343
  const resolved = fragment2 ? resolveAgainstPackage(registeredPackage, fragment2) : void 0;
5089
5344
  if (!resolved) {
5090
5345
  throw new Error(
5091
- `Could not resolve proxy '${proxy.fullId()}': fragment '${fragment2 ?? "<none>"}' did not match anything in the registered package '${registeredPackage.getNsURI() ?? "<no nsURI>"}'.`
5346
+ `Could not resolve proxy '${proxyLabel}': fragment '${fragment2 ?? "<none>"}' did not match anything in the registered package '${registeredPackage.getNsURI() ?? "<no nsURI>"}'.`
5092
5347
  );
5093
5348
  }
5094
5349
  return resolved;
5095
5350
  }
5096
5351
  const targetResource = await this.getResource(proxyURI.trimFragment(), true);
5097
5352
  if (!targetResource) {
5098
- throw new Error(`Could not resolve proxy '${proxy.fullId()}': its resource could not be loaded.`);
5353
+ throw new Error(`Could not resolve proxy '${proxyLabel}': its resource could not be loaded.`);
5099
5354
  }
5100
5355
  const fragment = proxyURI.getFragment();
5101
5356
  const roots = targetResource.getContents().toArray();
@@ -5104,12 +5359,33 @@ var ResourceSetImpl = class {
5104
5359
  const found = fragment ? resolver(fragment, roots) : void 0;
5105
5360
  if (!found) {
5106
5361
  throw new Error(
5107
- `Could not resolve proxy '${proxy.fullId()}': fragment '${fragment ?? "<none>"}' did not match any object in '${targetResource.getURI().toString()}'.`
5362
+ `Could not resolve proxy '${proxyLabel}': fragment '${fragment ?? "<none>"}' did not match any object in '${targetResource.getURI().toString()}'.`
5108
5363
  );
5109
5364
  }
5110
5365
  return found;
5111
5366
  }
5367
+ async resolveFeature(container, feature) {
5368
+ const current = container.eGet(feature);
5369
+ if (!isUnresolvedProxy(current)) return current;
5370
+ const resolved = await this.resolve(current);
5371
+ if (resolved !== current) {
5372
+ container.eBasicSetValue(feature, resolved);
5373
+ container.eNotify({
5374
+ eventType: "RESOLVE",
5375
+ notifier: container,
5376
+ feature,
5377
+ oldValue: current,
5378
+ newValue: resolved,
5379
+ position: void 0,
5380
+ wasSet: true
5381
+ });
5382
+ }
5383
+ return resolved;
5384
+ }
5112
5385
  };
5386
+ function isUnresolvedProxy(value) {
5387
+ return typeof value === "object" && value !== null && typeof value.eIsProxy === "function" && value.eIsProxy();
5388
+ }
5113
5389
  function resolveAgainstPackage(pkg, fragment) {
5114
5390
  const segments = fragment.replace(/^\/+/, "").split("/").filter((s) => s.length > 0);
5115
5391
  if (segments.length === 0) return void 0;
@@ -5131,22 +5407,46 @@ var URI = class _URI {
5131
5407
  hasAuthority;
5132
5408
  path;
5133
5409
  fragment;
5410
+ /** Parses an absolute URI ("scheme:path" / "scheme://path") or a relative reference (anything
5411
+ * else - a bare path, with no scheme). Never throws: a string with no recognizable scheme is
5412
+ * relative, not invalid - resolve() against a base URI before using it as a document location. */
5134
5413
  static parse(uriString) {
5135
- const match = /^([a-zA-Z][a-zA-Z0-9+.-]*):(\/\/)?([^#]*)(?:#(.*))?$/.exec(uriString);
5136
- if (!match) {
5137
- throw new Error(`Not a valid absolute URI: '${uriString}' (expected "scheme:path" or "scheme://path")`);
5414
+ const absolute = /^([a-zA-Z][a-zA-Z0-9+.-]*):(\/\/)?([^#]*)(?:#(.*))?$/.exec(uriString);
5415
+ if (absolute) {
5416
+ const [, scheme, authorityMarker, path2, fragment2] = absolute;
5417
+ return new _URI(scheme, authorityMarker === "//", path2, fragment2);
5138
5418
  }
5139
- const [, scheme, authorityMarker, path, fragment] = match;
5140
- return new _URI(scheme, authorityMarker === "//", path, fragment);
5419
+ const [, path, fragment] = /^([^#]*)(?:#(.*))?$/.exec(uriString);
5420
+ return new _URI(void 0, false, path, fragment);
5141
5421
  }
5142
- /** Convenience for the common case of wrapping a filesystem path. */
5422
+ /**
5423
+ * Convenience for the common case of wrapping a filesystem path (CORE-06). Backslashes become
5424
+ * forward slashes first - a Windows `fsPath` ("C:\Users\a b\m.xmi") has none of its own, so this
5425
+ * is purely "native path -> URI path" translation, matching real EMF's own `URI.createFileURI`;
5426
+ * it naturally also makes a drive-letter path absolute, the same way a POSIX path already was,
5427
+ * with no separate case needed (`C:/...` doesn't start with "/" yet, so it gets one prepended,
5428
+ * same as any other non-absolute input). Each path segment is then percent-encoded (a reserved
5429
+ * character - most commonly a space in a real file path - would otherwise corrupt `resolve`/
5430
+ * `deresolve`'s own segment splitting, or the URI text once serialized into an `href`); `:` is
5431
+ * deliberately left unescaped (valid unencoded in a URI path segment, and this is exactly what
5432
+ * keeps a drive letter readable as "C:" rather than "C%3A", matching Eclipse's own Windows file
5433
+ * URIs). `getPath()`/`toString()` return this encoded form - decoding back to a native path is
5434
+ * `@typemf/node`'s own job (NODE-01's `fileURLToPath`), not this class's.
5435
+ */
5143
5436
  static createFileURI(path) {
5144
- const normalized = path.startsWith("/") ? path : `/${path}`;
5145
- return new _URI("file", true, normalized, void 0);
5437
+ const normalized = path.replace(/\\/g, "/");
5438
+ const absolute = normalized.startsWith("/") ? normalized : `/${normalized}`;
5439
+ const encoded = absolute.split("/").map(encodePathSegment).join("/");
5440
+ return new _URI("file", true, encoded, void 0);
5146
5441
  }
5442
+ /** Undefined for a relative reference - see the class doc comment. */
5147
5443
  getScheme() {
5148
5444
  return this.scheme;
5149
5445
  }
5446
+ /** A relative reference, as opposed to one naming an absolute document location. */
5447
+ isRelative() {
5448
+ return this.scheme === void 0;
5449
+ }
5150
5450
  getPath() {
5151
5451
  return this.path;
5152
5452
  }
@@ -5166,15 +5466,62 @@ var URI = class _URI {
5166
5466
  trimFragment() {
5167
5467
  return this.fragment === void 0 ? this : this.withFragment(void 0);
5168
5468
  }
5469
+ /**
5470
+ * This URI, made absolute against `base` if it is relative; returned unchanged otherwise.
5471
+ * `base`'s own fragment is irrelevant and ignored - only its scheme/authority/path (i.e. "which
5472
+ * document") anchor the result; this URI's own fragment (if any) is kept as-is.
5473
+ */
5474
+ resolve(base) {
5475
+ if (!this.isRelative()) return this;
5476
+ const baseDir = base.path.slice(0, base.path.lastIndexOf("/") + 1);
5477
+ const merged = this.path.startsWith("/") ? this.path : baseDir + this.path;
5478
+ return new _URI(base.scheme, base.hasAuthority, normalizePath(merged), this.fragment);
5479
+ }
5480
+ /**
5481
+ * The shortest relative reference from `base` to this URI, when both share a scheme and
5482
+ * authority (the common, same-workspace case this is actually for) - this URI unchanged
5483
+ * otherwise, since there is then nothing meaningful to make relative against. Already-relative
5484
+ * stays unchanged either way. The inverse of resolve(): `uri.deresolve(base).resolve(base)`
5485
+ * reconstructs the original absolute path.
5486
+ */
5487
+ deresolve(base) {
5488
+ if (this.isRelative() || this.scheme !== base.scheme || this.hasAuthority !== base.hasAuthority) return this;
5489
+ const baseDirSegments = base.path.split("/").slice(0, -1);
5490
+ const targetSegments = this.path.split("/");
5491
+ let common = 0;
5492
+ while (common < baseDirSegments.length && common < targetSegments.length && baseDirSegments[common] === targetSegments[common]) {
5493
+ common++;
5494
+ }
5495
+ const upSegments = baseDirSegments.slice(common).map(() => "..");
5496
+ const relativePath = [...upSegments, ...targetSegments.slice(common)].join("/");
5497
+ return new _URI(void 0, false, relativePath, this.fragment);
5498
+ }
5169
5499
  toString() {
5500
+ const schemePart = this.scheme !== void 0 ? `${this.scheme}:` : "";
5170
5501
  const authority = this.hasAuthority ? "//" : "";
5171
5502
  const fragmentPart = this.fragment !== void 0 ? `#${this.fragment}` : "";
5172
- return `${this.scheme}:${authority}${this.path}${fragmentPart}`;
5503
+ return `${schemePart}${authority}${this.path}${fragmentPart}`;
5173
5504
  }
5174
5505
  equals(other) {
5175
5506
  return this.toString() === other.toString();
5176
5507
  }
5177
5508
  };
5509
+ function normalizePath(path) {
5510
+ const segments = path.split("/");
5511
+ const result = [];
5512
+ for (const segment of segments) {
5513
+ if (segment === ".") continue;
5514
+ if (segment === ".." && result.length > 0 && result[result.length - 1] !== "" && result.at(-1) !== "..") {
5515
+ result.pop();
5516
+ } else {
5517
+ result.push(segment);
5518
+ }
5519
+ }
5520
+ return result.join("/");
5521
+ }
5522
+ function encodePathSegment(segment) {
5523
+ return segment.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]/g, (ch) => encodeURIComponent(ch));
5524
+ }
5178
5525
 
5179
5526
  // src/metamodel/EcorePackage.ts
5180
5527
  var Ids = {
@@ -5327,6 +5674,13 @@ var Ids = {
5327
5674
 
5328
5675
  // src/metamodel/impl/EcoreFactoryImpl.ts
5329
5676
  var EcoreFactoryImpl = class extends EFactoryImpl {
5677
+ /** The one canonical factory instance - real EMF's own `EcoreFactory.eINSTANCE`, which this project
5678
+ * ports onto the Impl class rather than the interface (TypeScript interfaces have no statics).
5679
+ * Reading this also constructs the package singleton on first use (CORE-01), via the same
5680
+ * lazy initializer EcorePackageImpl.eINSTANCE itself goes through. */
5681
+ static get eINSTANCE() {
5682
+ return getEcorePackageRef().getEFactoryInstance();
5683
+ }
5330
5684
  createEAttribute() {
5331
5685
  return new EAttributeImpl();
5332
5686
  }
@@ -8872,7 +9226,7 @@ var EcorePackageImpl = class _EcorePackageImpl extends EPackageImpl {
8872
9226
  entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "body");
8873
9227
  entry.eBasicSetValue(
8874
9228
  Ids.EStringToStringMapEntry.value,
8875
- "return this.getEAllStructuralFeatures().filter(feature => this.getFeatureID(feature) === featureIDOrFeatureName).at(0);"
9229
+ "const features = this.getEAllStructuralFeatures(); return featureIDOrFeatureName >= 0 && featureIDOrFeatureName < features.size() ? features.get(featureIDOrFeatureName) : undefined;"
8876
9230
  );
8877
9231
  annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
8878
9232
  }
@@ -8899,35 +9253,12 @@ var EcorePackageImpl = class _EcorePackageImpl extends EPackageImpl {
8899
9253
  entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "body");
8900
9254
  entry.eBasicSetValue(
8901
9255
  Ids.EStringToStringMapEntry.value,
8902
- "return (feature as EStructuralFeatureImpl).getFeatureID();"
9256
+ "return this.getEAllStructuralFeatures().indexOf(feature);"
8903
9257
  );
8904
9258
  annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
8905
9259
  }
8906
9260
  this._EClass_op3.eBootstrapList(Ids.EModelElement.eAnnotations).add(annotation);
8907
9261
  }
8908
- {
8909
- const annotation = new EAnnotationImpl();
8910
- annotation.eBasicSetValue(Ids.EAnnotation.source, "https://typemf.dev/generator/import");
8911
- {
8912
- const entry = new EStringToStringMapEntryImpl();
8913
- entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "type");
8914
- entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "EStructuralFeatureImpl");
8915
- annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
8916
- }
8917
- {
8918
- const entry = new EStringToStringMapEntryImpl();
8919
- entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "from");
8920
- entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "@typemf/core");
8921
- annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
8922
- }
8923
- {
8924
- const entry = new EStringToStringMapEntryImpl();
8925
- entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "internal-from");
8926
- entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "./impl/EStructuralFeatureImpl");
8927
- annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
8928
- }
8929
- this._EClass_op3.eBootstrapList(Ids.EModelElement.eAnnotations).add(annotation);
8930
- }
8931
9262
  this._EClass.eBootstrapList(Ids.EClass.eOperations).add(this._EClass_op3);
8932
9263
  this._EClass_op4 = new EOperationImpl();
8933
9264
  this._EClass_op4.eBasicSetValue(Ids.ENamedElement.name, "getEStructuralFeature");
@@ -9095,15 +9426,35 @@ var EcorePackageImpl = class _EcorePackageImpl extends EPackageImpl {
9095
9426
  {
9096
9427
  const entry = new EStringToStringMapEntryImpl();
9097
9428
  entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "body");
9098
- entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "return object instanceof EObjectImpl;");
9429
+ entry.eBasicSetValue(
9430
+ Ids.EStringToStringMapEntry.value,
9431
+ "switch (this.eClass().getName()) {\n case 'EClass':\n return object instanceof EObjectImpl && (this as unknown as EClass).isSuperTypeOf((object as EObject).eClass());\n default:\n switch (this.getName()) {\n case 'EString':\n case 'EChar':\n case 'ECharacterObject':\n return typeof object === 'string';\n case 'EInt':\n case 'EIntegerObject':\n case 'ELong':\n case 'ELongObject':\n case 'EDouble':\n case 'EDoubleObject':\n case 'EFloat':\n case 'EFloatObject':\n case 'EShort':\n case 'EShortObject':\n case 'EByte':\n case 'EByteObject':\n return typeof object === 'number';\n case 'EBigInteger':\n return typeof object === 'bigint';\n case 'EBoolean':\n case 'EBooleanObject':\n return typeof object === 'boolean';\n case 'EDate':\n return object instanceof Date;\n default:\n return object !== undefined && object !== null;\n }\n}"
9432
+ );
9099
9433
  annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
9100
9434
  }
9435
+ this._EClassifier_op0.eBootstrapList(Ids.EModelElement.eAnnotations).add(annotation);
9436
+ }
9437
+ {
9438
+ const annotation = new EAnnotationImpl();
9439
+ annotation.eBasicSetValue(Ids.EAnnotation.source, "https://typemf.dev/generator/import");
9101
9440
  {
9102
9441
  const entry = new EStringToStringMapEntryImpl();
9103
- entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "use-type-name");
9442
+ entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "type");
9104
9443
  entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "EObjectImpl");
9105
9444
  annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
9106
9445
  }
9446
+ {
9447
+ const entry = new EStringToStringMapEntryImpl();
9448
+ entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "from");
9449
+ entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "@typemf/core");
9450
+ annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
9451
+ }
9452
+ {
9453
+ const entry = new EStringToStringMapEntryImpl();
9454
+ entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "internal-from");
9455
+ entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "./impl/EObjectImpl");
9456
+ annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
9457
+ }
9107
9458
  this._EClassifier_op0.eBootstrapList(Ids.EModelElement.eAnnotations).add(annotation);
9108
9459
  }
9109
9460
  {
@@ -9112,7 +9463,7 @@ var EcorePackageImpl = class _EcorePackageImpl extends EPackageImpl {
9112
9463
  {
9113
9464
  const entry = new EStringToStringMapEntryImpl();
9114
9465
  entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "type");
9115
- entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "EObjectImpl");
9466
+ entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "EObject");
9116
9467
  annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
9117
9468
  }
9118
9469
  {
@@ -9124,7 +9475,7 @@ var EcorePackageImpl = class _EcorePackageImpl extends EPackageImpl {
9124
9475
  {
9125
9476
  const entry = new EStringToStringMapEntryImpl();
9126
9477
  entry.eBasicSetValue(Ids.EStringToStringMapEntry.key, "internal-from");
9127
- entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "./impl/EObjectImpl");
9478
+ entry.eBasicSetValue(Ids.EStringToStringMapEntry.value, "./types/EObject");
9128
9479
  annotation.eBootstrapList(Ids.EAnnotation.details).add(entry);
9129
9480
  }
9130
9481
  this._EClassifier_op0.eBootstrapList(Ids.EModelElement.eAnnotations).add(annotation);
@@ -9929,6 +10280,9 @@ var EcorePackageImpl = class _EcorePackageImpl extends EPackageImpl {
9929
10280
  return this._EInvocationTargetException;
9930
10281
  }
9931
10282
  };
10283
+ registerEcorePackageInitializer(() => {
10284
+ void EcorePackageImpl.eINSTANCE;
10285
+ });
9932
10286
  // Annotate the CommonJS export names for ESM import in node:
9933
10287
  0 && (module.exports = {
9934
10288
  BasicEList,
@@ -9958,7 +10312,6 @@ var EcorePackageImpl = class _EcorePackageImpl extends EPackageImpl {
9958
10312
  EcoreFactoryImpl,
9959
10313
  EcorePackageImpl,
9960
10314
  Ids,
9961
- ProxyEObjectImpl,
9962
10315
  ResourceFactoryRegistryImpl,
9963
10316
  ResourceImpl,
9964
10317
  ResourceSetImpl,
@@ -9967,8 +10320,10 @@ var EcorePackageImpl = class _EcorePackageImpl extends EPackageImpl {
9967
10320
  associateRoot,
9968
10321
  computeFragment,
9969
10322
  createInstanceOf,
10323
+ createProxy,
9970
10324
  detailValue,
9971
10325
  dissociateRoot,
10326
+ getProxyURI,
9972
10327
  getResourceOf,
9973
10328
  isEAnnotation,
9974
10329
  isEAttribute,