@typemf/core 0.6.0 → 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
@@ -139,6 +139,13 @@ var BasicEList = class {
139
139
  const removed = this.items.splice(0, this.items.length);
140
140
  for (const item of removed) this.onRemoved(item, 0);
141
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
+ }
142
149
  contains(item) {
143
150
  return this.items.includes(item);
144
151
  }
@@ -223,6 +230,24 @@ var BasicEList = class {
223
230
  });
224
231
  }
225
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
+ }
226
251
  };
227
252
  function isReference(feature) {
228
253
  return "isContainment" in feature;
@@ -230,11 +255,24 @@ function isReference(feature) {
230
255
 
231
256
  // src/metamodel/impl/EObjectImpl.ts
232
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
+ }
233
267
  var EObjectImpl = class _EObjectImpl {
234
268
  _eContainer;
235
269
  _eContainingFeature;
236
270
  _eProxy = false;
237
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;
238
276
  /**
239
277
  * Marks this object (and, recursively, everything it contains) as no longer intended to be
240
278
  * mutated. Matches real EMF's own design precisely: a queryable flag, not enforced in every
@@ -272,6 +310,20 @@ var EObjectImpl = class _EObjectImpl {
272
310
  freezeChild(child) {
273
311
  if (child instanceof _EObjectImpl) child.freeze();
274
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
+ }
275
327
  listeners = [];
276
328
  deliverFlag = true;
277
329
  onDidChange(callback, feature) {
@@ -314,6 +366,20 @@ var EObjectImpl = class _EObjectImpl {
314
366
  eContainingFeature() {
315
367
  return this._eContainingFeature;
316
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
+ }
317
383
  /**
318
384
  * Internal - called by BasicEList (for many-valued containment features)
319
385
  * and by single-valued containment setters to update the backpointer.
@@ -388,12 +454,35 @@ var EObjectImpl = class _EObjectImpl {
388
454
  */
389
455
  eInverseAdd(otherEnd, feature) {
390
456
  if (feature.isMany()) {
391
- 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
+ }
392
471
  } else {
393
472
  const oldValue = this.eGet(feature);
394
473
  if (oldValue === otherEnd) return;
474
+ const wasSet = this.eIsSet(feature);
395
475
  this.eBasicSetValue(feature, otherEnd);
396
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
+ });
397
486
  }
398
487
  if (feature.isContainment()) otherEnd.eBasicMoveInto(this, feature);
399
488
  }
@@ -427,11 +516,60 @@ var EObjectImpl = class _EObjectImpl {
427
516
  this.eBasicSetContainer(void 0, void 0);
428
517
  }
429
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
+ */
430
546
  eBasicRemoveValue(feature, value) {
431
547
  if (feature.isMany()) {
432
- 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
+ }
433
561
  } else if (this.eGet(feature) === value) {
562
+ const wasSet = this.eIsSet(feature);
434
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
+ });
435
573
  }
436
574
  }
437
575
  eBasicList(feature) {
@@ -501,12 +639,27 @@ function isEListOfEObject(value) {
501
639
 
502
640
  // src/metamodel/impl/EcorePackageRef.ts
503
641
  var ref;
642
+ var initializer;
643
+ var initializing = false;
504
644
  function setEcorePackageRef(pkg) {
505
645
  ref = pkg;
506
646
  }
647
+ function registerEcorePackageInitializer(init) {
648
+ initializer = init;
649
+ }
507
650
  function getEcorePackageRef() {
651
+ if (!ref && initializer && !initializing) {
652
+ initializing = true;
653
+ try {
654
+ initializer();
655
+ } finally {
656
+ initializing = false;
657
+ }
658
+ }
508
659
  if (!ref) {
509
- 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
+ );
510
663
  }
511
664
  return ref;
512
665
  }
@@ -531,6 +684,7 @@ var EStringToStringMapEntryImpl = class extends EObjectImpl {
531
684
  this.eSet(getEcorePackageRef().getEStringToStringMapEntry_Value(), value);
532
685
  }
533
686
  eGet(feature) {
687
+ this.requireOwnFeature(feature);
534
688
  switch (feature.getFeatureID()) {
535
689
  case 0:
536
690
  return this._key;
@@ -541,6 +695,7 @@ var EStringToStringMapEntryImpl = class extends EObjectImpl {
541
695
  }
542
696
  }
543
697
  eSet(feature, value) {
698
+ this.requireOwnFeature(feature);
544
699
  switch (feature.getFeatureID()) {
545
700
  case 0: {
546
701
  const oldValue = this.eGet(feature);
@@ -602,6 +757,7 @@ var EStringToStringMapEntryImpl = class extends EObjectImpl {
602
757
  }
603
758
  }
604
759
  eIsSet(feature) {
760
+ this.requireOwnFeature(feature);
605
761
  switch (feature.getFeatureID()) {
606
762
  case 0:
607
763
  return this._key !== void 0;
@@ -612,6 +768,7 @@ var EStringToStringMapEntryImpl = class extends EObjectImpl {
612
768
  }
613
769
  }
614
770
  eUnset(feature) {
771
+ this.requireOwnFeature(feature);
615
772
  switch (feature.getFeatureID()) {
616
773
  case 0: {
617
774
  const wasSet = this.eIsSet(feature);
@@ -684,7 +841,7 @@ var DynamicEObjectImpl = class extends EObjectImpl {
684
841
  this.dynamicEClass = dynamicEClass;
685
842
  for (const feature of dynamicEClass.getEAllStructuralFeatures()) {
686
843
  if (feature.isMany()) {
687
- this.values.set(feature.getFeatureID(), new BasicEList(this, feature));
844
+ this.values.set(this.dynamicEClass.getFeatureID(feature), new BasicEList(this, feature));
688
845
  }
689
846
  }
690
847
  }
@@ -694,10 +851,12 @@ var DynamicEObjectImpl = class extends EObjectImpl {
694
851
  return this.dynamicEClass;
695
852
  }
696
853
  eGet(feature) {
697
- return this.values.get(feature.getFeatureID());
854
+ this.requireOwnFeature(feature);
855
+ return this.values.get(this.dynamicEClass.getFeatureID(feature));
698
856
  }
699
857
  eSet(feature, value) {
700
- const id = feature.getFeatureID();
858
+ this.requireOwnFeature(feature);
859
+ const id = this.dynamicEClass.getFeatureID(feature);
701
860
  if (feature.isMany()) {
702
861
  const list = this.requireList(feature);
703
862
  const items = value === void 0 || value === null ? [] : [...value];
@@ -714,14 +873,16 @@ var DynamicEObjectImpl = class extends EObjectImpl {
714
873
  this.eNotify({ eventType: "SET", notifier: this, feature, oldValue, newValue: value, position: void 0, wasSet });
715
874
  }
716
875
  eIsSet(feature) {
717
- const id = feature.getFeatureID();
876
+ this.requireOwnFeature(feature);
877
+ const id = this.dynamicEClass.getFeatureID(feature);
718
878
  if (feature.isMany()) {
719
879
  return this.values.get(id)?.size() !== 0;
720
880
  }
721
881
  return this.values.has(id) && this.values.get(id) !== void 0;
722
882
  }
723
883
  eUnset(feature) {
724
- const id = feature.getFeatureID();
884
+ this.requireOwnFeature(feature);
885
+ const id = this.dynamicEClass.getFeatureID(feature);
725
886
  if (feature.isMany()) {
726
887
  this.requireList(feature).clear();
727
888
  return;
@@ -741,14 +902,15 @@ var DynamicEObjectImpl = class extends EObjectImpl {
741
902
  });
742
903
  }
743
904
  eBasicSetValue(feature, value) {
905
+ const id = this.dynamicEClass.getFeatureID(feature);
744
906
  if (value === void 0) {
745
- this.values.delete(feature.getFeatureID());
907
+ this.values.delete(id);
746
908
  } else {
747
- this.values.set(feature.getFeatureID(), value);
909
+ this.values.set(id, value);
748
910
  }
749
911
  }
750
912
  requireList(feature) {
751
- const list = this.values.get(feature.getFeatureID());
913
+ const list = this.values.get(this.dynamicEClass.getFeatureID(feature));
752
914
  if (!(list instanceof BasicEList)) {
753
915
  throw new Error(
754
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).`
@@ -775,6 +937,7 @@ var EModelElementImpl = class extends EObjectImpl {
775
937
  return this.getEAnnotations().filter((ann) => ann.getSource() === source).at(0);
776
938
  }
777
939
  eGet(feature) {
940
+ this.requireOwnFeature(feature);
778
941
  switch (feature.getFeatureID()) {
779
942
  case 0:
780
943
  return this._eAnnotations;
@@ -783,6 +946,7 @@ var EModelElementImpl = class extends EObjectImpl {
783
946
  }
784
947
  }
785
948
  eSet(feature, value) {
949
+ this.requireOwnFeature(feature);
786
950
  switch (feature.getFeatureID()) {
787
951
  case 0: {
788
952
  const list = this._eAnnotations;
@@ -812,6 +976,7 @@ var EModelElementImpl = class extends EObjectImpl {
812
976
  }
813
977
  }
814
978
  eIsSet(feature) {
979
+ this.requireOwnFeature(feature);
815
980
  switch (feature.getFeatureID()) {
816
981
  case 0:
817
982
  return this._eAnnotationsCache !== void 0 && this._eAnnotationsCache.size() !== 0;
@@ -820,6 +985,7 @@ var EModelElementImpl = class extends EObjectImpl {
820
985
  }
821
986
  }
822
987
  eUnset(feature) {
988
+ this.requireOwnFeature(feature);
823
989
  switch (feature.getFeatureID()) {
824
990
  case 0:
825
991
  this._eAnnotationsCache?.clear();
@@ -895,6 +1061,7 @@ var EFactoryImpl = class extends EModelElementImpl {
895
1061
  return String(instanceValue);
896
1062
  }
897
1063
  eGet(feature) {
1064
+ this.requireOwnFeature(feature);
898
1065
  switch (feature.getFeatureID()) {
899
1066
  case 1:
900
1067
  return this._ePackage;
@@ -903,6 +1070,7 @@ var EFactoryImpl = class extends EModelElementImpl {
903
1070
  }
904
1071
  }
905
1072
  eSet(feature, value) {
1073
+ this.requireOwnFeature(feature);
906
1074
  switch (feature.getFeatureID()) {
907
1075
  case 1: {
908
1076
  const oldValue = this.eGet(feature);
@@ -945,6 +1113,7 @@ var EFactoryImpl = class extends EModelElementImpl {
945
1113
  }
946
1114
  }
947
1115
  eIsSet(feature) {
1116
+ this.requireOwnFeature(feature);
948
1117
  switch (feature.getFeatureID()) {
949
1118
  case 1:
950
1119
  return this._ePackage !== void 0;
@@ -953,6 +1122,7 @@ var EFactoryImpl = class extends EModelElementImpl {
953
1122
  }
954
1123
  }
955
1124
  eUnset(feature) {
1125
+ this.requireOwnFeature(feature);
956
1126
  switch (feature.getFeatureID()) {
957
1127
  case 1: {
958
1128
  const wasSet = this.eIsSet(feature);
@@ -1031,6 +1201,7 @@ var EAnnotationImpl = class extends EModelElementImpl {
1031
1201
  return this._references;
1032
1202
  }
1033
1203
  eGet(feature) {
1204
+ this.requireOwnFeature(feature);
1034
1205
  switch (feature.getFeatureID()) {
1035
1206
  case 1:
1036
1207
  return this._source;
@@ -1047,6 +1218,7 @@ var EAnnotationImpl = class extends EModelElementImpl {
1047
1218
  }
1048
1219
  }
1049
1220
  eSet(feature, value) {
1221
+ this.requireOwnFeature(feature);
1050
1222
  switch (feature.getFeatureID()) {
1051
1223
  case 1: {
1052
1224
  const oldValue = this.eGet(feature);
@@ -1140,6 +1312,7 @@ var EAnnotationImpl = class extends EModelElementImpl {
1140
1312
  }
1141
1313
  }
1142
1314
  eIsSet(feature) {
1315
+ this.requireOwnFeature(feature);
1143
1316
  switch (feature.getFeatureID()) {
1144
1317
  case 1:
1145
1318
  return this._source !== void 0;
@@ -1156,6 +1329,7 @@ var EAnnotationImpl = class extends EModelElementImpl {
1156
1329
  }
1157
1330
  }
1158
1331
  eUnset(feature) {
1332
+ this.requireOwnFeature(feature);
1159
1333
  switch (feature.getFeatureID()) {
1160
1334
  case 1: {
1161
1335
  const wasSet = this.eIsSet(feature);
@@ -1218,6 +1392,7 @@ var ENamedElementImpl = class extends EModelElementImpl {
1218
1392
  this.eSet(getEcorePackageRef().getENamedElement_Name(), value);
1219
1393
  }
1220
1394
  eGet(feature) {
1395
+ this.requireOwnFeature(feature);
1221
1396
  switch (feature.getFeatureID()) {
1222
1397
  case 1:
1223
1398
  return this._name;
@@ -1226,6 +1401,7 @@ var ENamedElementImpl = class extends EModelElementImpl {
1226
1401
  }
1227
1402
  }
1228
1403
  eSet(feature, value) {
1404
+ this.requireOwnFeature(feature);
1229
1405
  switch (feature.getFeatureID()) {
1230
1406
  case 1: {
1231
1407
  const oldValue = this.eGet(feature);
@@ -1268,6 +1444,7 @@ var ENamedElementImpl = class extends EModelElementImpl {
1268
1444
  }
1269
1445
  }
1270
1446
  eIsSet(feature) {
1447
+ this.requireOwnFeature(feature);
1271
1448
  switch (feature.getFeatureID()) {
1272
1449
  case 1:
1273
1450
  return this._name !== void 0;
@@ -1276,6 +1453,7 @@ var ENamedElementImpl = class extends EModelElementImpl {
1276
1453
  }
1277
1454
  }
1278
1455
  eUnset(feature) {
1456
+ this.requireOwnFeature(feature);
1279
1457
  switch (feature.getFeatureID()) {
1280
1458
  case 1: {
1281
1459
  const wasSet = this.eIsSet(feature);
@@ -1381,6 +1559,7 @@ var ETypedElementImpl = class extends ENamedElementImpl {
1381
1559
  });
1382
1560
  }
1383
1561
  eGet(feature) {
1562
+ this.requireOwnFeature(feature);
1384
1563
  switch (feature.getFeatureID()) {
1385
1564
  case 2:
1386
1565
  return this._ordered;
@@ -1403,6 +1582,7 @@ var ETypedElementImpl = class extends ENamedElementImpl {
1403
1582
  }
1404
1583
  }
1405
1584
  eSet(feature, value) {
1585
+ this.requireOwnFeature(feature);
1406
1586
  switch (feature.getFeatureID()) {
1407
1587
  case 2: {
1408
1588
  const oldValue = this.eGet(feature);
@@ -1528,6 +1708,7 @@ var ETypedElementImpl = class extends ENamedElementImpl {
1528
1708
  }
1529
1709
  }
1530
1710
  eIsSet(feature) {
1711
+ this.requireOwnFeature(feature);
1531
1712
  switch (feature.getFeatureID()) {
1532
1713
  case 2:
1533
1714
  return this._ordered !== true;
@@ -1550,6 +1731,7 @@ var ETypedElementImpl = class extends ENamedElementImpl {
1550
1731
  }
1551
1732
  }
1552
1733
  eUnset(feature) {
1734
+ this.requireOwnFeature(feature);
1553
1735
  switch (feature.getFeatureID()) {
1554
1736
  case 2: {
1555
1737
  const wasSet = this.eIsSet(feature);
@@ -1762,6 +1944,7 @@ var EStructuralFeatureImpl = class extends ETypedElementImpl {
1762
1944
  this._eContainingClass = value;
1763
1945
  }
1764
1946
  eGet(feature) {
1947
+ this.requireOwnFeature(feature);
1765
1948
  switch (feature.getFeatureID()) {
1766
1949
  case 10:
1767
1950
  return this._changeable;
@@ -1784,6 +1967,7 @@ var EStructuralFeatureImpl = class extends ETypedElementImpl {
1784
1967
  }
1785
1968
  }
1786
1969
  eSet(feature, value) {
1970
+ this.requireOwnFeature(feature);
1787
1971
  switch (feature.getFeatureID()) {
1788
1972
  case 10: {
1789
1973
  const oldValue = this.eGet(feature);
@@ -1937,6 +2121,7 @@ var EStructuralFeatureImpl = class extends ETypedElementImpl {
1937
2121
  }
1938
2122
  }
1939
2123
  eIsSet(feature) {
2124
+ this.requireOwnFeature(feature);
1940
2125
  switch (feature.getFeatureID()) {
1941
2126
  case 10:
1942
2127
  return this._changeable !== true;
@@ -1959,6 +2144,7 @@ var EStructuralFeatureImpl = class extends ETypedElementImpl {
1959
2144
  }
1960
2145
  }
1961
2146
  eUnset(feature) {
2147
+ this.requireOwnFeature(feature);
1962
2148
  switch (feature.getFeatureID()) {
1963
2149
  case 10: {
1964
2150
  const wasSet = this.eIsSet(feature);
@@ -2112,6 +2298,7 @@ var EAttributeImpl = class extends EStructuralFeatureImpl {
2112
2298
  return this.getEType();
2113
2299
  }
2114
2300
  eGet(feature) {
2301
+ this.requireOwnFeature(feature);
2115
2302
  switch (feature.getFeatureID()) {
2116
2303
  case 18:
2117
2304
  return this._iD;
@@ -2122,6 +2309,7 @@ var EAttributeImpl = class extends EStructuralFeatureImpl {
2122
2309
  }
2123
2310
  }
2124
2311
  eSet(feature, value) {
2312
+ this.requireOwnFeature(feature);
2125
2313
  switch (feature.getFeatureID()) {
2126
2314
  case 18: {
2127
2315
  const oldValue = this.eGet(feature);
@@ -2167,6 +2355,7 @@ var EAttributeImpl = class extends EStructuralFeatureImpl {
2167
2355
  }
2168
2356
  }
2169
2357
  eIsSet(feature) {
2358
+ this.requireOwnFeature(feature);
2170
2359
  switch (feature.getFeatureID()) {
2171
2360
  case 18:
2172
2361
  return this._iD !== false;
@@ -2177,6 +2366,7 @@ var EAttributeImpl = class extends EStructuralFeatureImpl {
2177
2366
  }
2178
2367
  }
2179
2368
  eUnset(feature) {
2369
+ this.requireOwnFeature(feature);
2180
2370
  switch (feature.getFeatureID()) {
2181
2371
  case 18: {
2182
2372
  const wasSet = this.eIsSet(feature);
@@ -2276,9 +2466,42 @@ var EClassifierImpl = class extends ENamedElementImpl {
2276
2466
  return this._eTypeParameters;
2277
2467
  }
2278
2468
  isInstance(object) {
2279
- 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
+ }
2280
2502
  }
2281
2503
  eGet(feature) {
2504
+ this.requireOwnFeature(feature);
2282
2505
  switch (feature.getFeatureID()) {
2283
2506
  case 2:
2284
2507
  return this._instanceClassName;
@@ -2297,6 +2520,7 @@ var EClassifierImpl = class extends ENamedElementImpl {
2297
2520
  }
2298
2521
  }
2299
2522
  eSet(feature, value) {
2523
+ this.requireOwnFeature(feature);
2300
2524
  switch (feature.getFeatureID()) {
2301
2525
  case 2: {
2302
2526
  const oldValue = this.eGet(feature);
@@ -2379,6 +2603,7 @@ var EClassifierImpl = class extends ENamedElementImpl {
2379
2603
  }
2380
2604
  }
2381
2605
  eIsSet(feature) {
2606
+ this.requireOwnFeature(feature);
2382
2607
  switch (feature.getFeatureID()) {
2383
2608
  case 2:
2384
2609
  return this._instanceClassName !== void 0;
@@ -2397,6 +2622,7 @@ var EClassifierImpl = class extends ENamedElementImpl {
2397
2622
  }
2398
2623
  }
2399
2624
  eUnset(feature) {
2625
+ this.requireOwnFeature(feature);
2400
2626
  switch (feature.getFeatureID()) {
2401
2627
  case 2: {
2402
2628
  const wasSet = this.eIsSet(feature);
@@ -2614,6 +2840,7 @@ var EGenericTypeImpl = class extends EObjectImpl {
2614
2840
  this.eSet(getEcorePackageRef().getEGenericType_EClassifier(), value);
2615
2841
  }
2616
2842
  eGet(feature) {
2843
+ this.requireOwnFeature(feature);
2617
2844
  switch (feature.getFeatureID()) {
2618
2845
  case 0:
2619
2846
  return this._eUpperBound;
@@ -2632,6 +2859,7 @@ var EGenericTypeImpl = class extends EObjectImpl {
2632
2859
  }
2633
2860
  }
2634
2861
  eSet(feature, value) {
2862
+ this.requireOwnFeature(feature);
2635
2863
  switch (feature.getFeatureID()) {
2636
2864
  case 0: {
2637
2865
  const oldValue = this.eGet(feature);
@@ -2745,6 +2973,7 @@ var EGenericTypeImpl = class extends EObjectImpl {
2745
2973
  }
2746
2974
  }
2747
2975
  eIsSet(feature) {
2976
+ this.requireOwnFeature(feature);
2748
2977
  switch (feature.getFeatureID()) {
2749
2978
  case 0:
2750
2979
  return this._eUpperBound !== void 0;
@@ -2763,6 +2992,7 @@ var EGenericTypeImpl = class extends EObjectImpl {
2763
2992
  }
2764
2993
  }
2765
2994
  eUnset(feature) {
2995
+ this.requireOwnFeature(feature);
2766
2996
  switch (feature.getFeatureID()) {
2767
2997
  case 0: {
2768
2998
  const wasSet = this.eIsSet(feature);
@@ -3110,7 +3340,8 @@ var EClassImpl = class extends EClassifierImpl {
3110
3340
  }
3111
3341
  getEStructuralFeature(featureIDOrFeatureName) {
3112
3342
  if (typeof featureIDOrFeatureName === "number") {
3113
- 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;
3114
3345
  }
3115
3346
  if (typeof featureIDOrFeatureName === "string") {
3116
3347
  return this.getEAllStructuralFeatures().filter((feature) => feature.getName() === featureIDOrFeatureName).at(0);
@@ -3118,7 +3349,7 @@ var EClassImpl = class extends EClassifierImpl {
3118
3349
  throw new Error("EClass.getEStructuralFeature(): no overload matches the given arguments.");
3119
3350
  }
3120
3351
  getFeatureID(feature) {
3121
- return feature.getFeatureID();
3352
+ return this.getEAllStructuralFeatures().indexOf(feature);
3122
3353
  }
3123
3354
  getOperationCount() {
3124
3355
  return this.getEAllOperations().size();
@@ -3137,6 +3368,7 @@ var EClassImpl = class extends EClassifierImpl {
3137
3368
  return void 0;
3138
3369
  }
3139
3370
  eGet(feature) {
3371
+ this.requireOwnFeature(feature);
3140
3372
  switch (feature.getFeatureID()) {
3141
3373
  case 8:
3142
3374
  return this._abstract;
@@ -3175,6 +3407,7 @@ var EClassImpl = class extends EClassifierImpl {
3175
3407
  }
3176
3408
  }
3177
3409
  eSet(feature, value) {
3410
+ this.requireOwnFeature(feature);
3178
3411
  switch (feature.getFeatureID()) {
3179
3412
  case 8: {
3180
3413
  const oldValue = this.eGet(feature);
@@ -3278,6 +3511,7 @@ var EClassImpl = class extends EClassifierImpl {
3278
3511
  }
3279
3512
  }
3280
3513
  eIsSet(feature) {
3514
+ this.requireOwnFeature(feature);
3281
3515
  switch (feature.getFeatureID()) {
3282
3516
  case 8:
3283
3517
  return this._abstract !== false;
@@ -3316,6 +3550,7 @@ var EClassImpl = class extends EClassifierImpl {
3316
3550
  }
3317
3551
  }
3318
3552
  eUnset(feature) {
3553
+ this.requireOwnFeature(feature);
3319
3554
  switch (feature.getFeatureID()) {
3320
3555
  case 8: {
3321
3556
  const wasSet = this.eIsSet(feature);
@@ -3381,6 +3616,7 @@ var EDataTypeImpl = class extends EClassifierImpl {
3381
3616
  this.eSet(getEcorePackageRef().getEDataType_Serializable(), value);
3382
3617
  }
3383
3618
  eGet(feature) {
3619
+ this.requireOwnFeature(feature);
3384
3620
  switch (feature.getFeatureID()) {
3385
3621
  case 8:
3386
3622
  return this._serializable;
@@ -3389,6 +3625,7 @@ var EDataTypeImpl = class extends EClassifierImpl {
3389
3625
  }
3390
3626
  }
3391
3627
  eSet(feature, value) {
3628
+ this.requireOwnFeature(feature);
3392
3629
  switch (feature.getFeatureID()) {
3393
3630
  case 8: {
3394
3631
  const oldValue = this.eGet(feature);
@@ -3431,6 +3668,7 @@ var EDataTypeImpl = class extends EClassifierImpl {
3431
3668
  }
3432
3669
  }
3433
3670
  eIsSet(feature) {
3671
+ this.requireOwnFeature(feature);
3434
3672
  switch (feature.getFeatureID()) {
3435
3673
  case 8:
3436
3674
  return this._serializable !== true;
@@ -3439,6 +3677,7 @@ var EDataTypeImpl = class extends EClassifierImpl {
3439
3677
  }
3440
3678
  }
3441
3679
  eUnset(feature) {
3680
+ this.requireOwnFeature(feature);
3442
3681
  switch (feature.getFeatureID()) {
3443
3682
  case 8: {
3444
3683
  const wasSet = this.eIsSet(feature);
@@ -3491,6 +3730,7 @@ var EEnumImpl = class extends EDataTypeImpl {
3491
3730
  return this.getELiterals().find((candidate) => candidate.getLiteral() === literal);
3492
3731
  }
3493
3732
  eGet(feature) {
3733
+ this.requireOwnFeature(feature);
3494
3734
  switch (feature.getFeatureID()) {
3495
3735
  case 9:
3496
3736
  return this._eLiterals;
@@ -3499,6 +3739,7 @@ var EEnumImpl = class extends EDataTypeImpl {
3499
3739
  }
3500
3740
  }
3501
3741
  eSet(feature, value) {
3742
+ this.requireOwnFeature(feature);
3502
3743
  switch (feature.getFeatureID()) {
3503
3744
  case 9: {
3504
3745
  const list = this._eLiterals;
@@ -3530,6 +3771,7 @@ var EEnumImpl = class extends EDataTypeImpl {
3530
3771
  }
3531
3772
  }
3532
3773
  eIsSet(feature) {
3774
+ this.requireOwnFeature(feature);
3533
3775
  switch (feature.getFeatureID()) {
3534
3776
  case 9:
3535
3777
  return this._eLiteralsCache !== void 0 && this._eLiteralsCache.size() !== 0;
@@ -3538,6 +3780,7 @@ var EEnumImpl = class extends EDataTypeImpl {
3538
3780
  }
3539
3781
  }
3540
3782
  eUnset(feature) {
3783
+ this.requireOwnFeature(feature);
3541
3784
  switch (feature.getFeatureID()) {
3542
3785
  case 9:
3543
3786
  this._eLiteralsCache?.clear();
@@ -3590,6 +3833,7 @@ var EEnumLiteralImpl = class extends ENamedElementImpl {
3590
3833
  this._eEnum = value;
3591
3834
  }
3592
3835
  eGet(feature) {
3836
+ this.requireOwnFeature(feature);
3593
3837
  switch (feature.getFeatureID()) {
3594
3838
  case 2:
3595
3839
  return this._value;
@@ -3604,6 +3848,7 @@ var EEnumLiteralImpl = class extends ENamedElementImpl {
3604
3848
  }
3605
3849
  }
3606
3850
  eSet(feature, value) {
3851
+ this.requireOwnFeature(feature);
3607
3852
  switch (feature.getFeatureID()) {
3608
3853
  case 2: {
3609
3854
  const oldValue = this.eGet(feature);
@@ -3674,6 +3919,7 @@ var EEnumLiteralImpl = class extends ENamedElementImpl {
3674
3919
  }
3675
3920
  }
3676
3921
  eIsSet(feature) {
3922
+ this.requireOwnFeature(feature);
3677
3923
  switch (feature.getFeatureID()) {
3678
3924
  case 2:
3679
3925
  return this._value !== 0;
@@ -3688,6 +3934,7 @@ var EEnumLiteralImpl = class extends ENamedElementImpl {
3688
3934
  }
3689
3935
  }
3690
3936
  eUnset(feature) {
3937
+ this.requireOwnFeature(feature);
3691
3938
  switch (feature.getFeatureID()) {
3692
3939
  case 2: {
3693
3940
  const wasSet = this.eIsSet(feature);
@@ -3834,6 +4081,7 @@ var EOperationImpl = class extends ETypedElementImpl {
3834
4081
  return true;
3835
4082
  }
3836
4083
  eGet(feature) {
4084
+ this.requireOwnFeature(feature);
3837
4085
  switch (feature.getFeatureID()) {
3838
4086
  case 10:
3839
4087
  return this._eContainingClass;
@@ -3850,6 +4098,7 @@ var EOperationImpl = class extends ETypedElementImpl {
3850
4098
  }
3851
4099
  }
3852
4100
  eSet(feature, value) {
4101
+ this.requireOwnFeature(feature);
3853
4102
  switch (feature.getFeatureID()) {
3854
4103
  case 11: {
3855
4104
  const list = this._eTypeParameters;
@@ -3914,6 +4163,7 @@ var EOperationImpl = class extends ETypedElementImpl {
3914
4163
  }
3915
4164
  }
3916
4165
  eIsSet(feature) {
4166
+ this.requireOwnFeature(feature);
3917
4167
  switch (feature.getFeatureID()) {
3918
4168
  case 10:
3919
4169
  return this._eContainingClass !== void 0;
@@ -3930,6 +4180,7 @@ var EOperationImpl = class extends ETypedElementImpl {
3930
4180
  }
3931
4181
  }
3932
4182
  eUnset(feature) {
4183
+ this.requireOwnFeature(feature);
3933
4184
  switch (feature.getFeatureID()) {
3934
4185
  case 10: {
3935
4186
  const wasSet = this.eIsSet(feature);
@@ -4019,6 +4270,7 @@ var EPackageImpl = class extends ENamedElementImpl {
4019
4270
  return this.getEClassifiers().filter((cl) => cl.getName() === name).at(0);
4020
4271
  }
4021
4272
  eGet(feature) {
4273
+ this.requireOwnFeature(feature);
4022
4274
  switch (feature.getFeatureID()) {
4023
4275
  case 2:
4024
4276
  return this._nsURI;
@@ -4037,6 +4289,7 @@ var EPackageImpl = class extends ENamedElementImpl {
4037
4289
  }
4038
4290
  }
4039
4291
  eSet(feature, value) {
4292
+ this.requireOwnFeature(feature);
4040
4293
  switch (feature.getFeatureID()) {
4041
4294
  case 2: {
4042
4295
  const oldValue = this.eGet(feature);
@@ -4144,6 +4397,7 @@ var EPackageImpl = class extends ENamedElementImpl {
4144
4397
  }
4145
4398
  }
4146
4399
  eIsSet(feature) {
4400
+ this.requireOwnFeature(feature);
4147
4401
  switch (feature.getFeatureID()) {
4148
4402
  case 2:
4149
4403
  return this._nsURI !== void 0;
@@ -4162,6 +4416,7 @@ var EPackageImpl = class extends ENamedElementImpl {
4162
4416
  }
4163
4417
  }
4164
4418
  eUnset(feature) {
4419
+ this.requireOwnFeature(feature);
4165
4420
  switch (feature.getFeatureID()) {
4166
4421
  case 2: {
4167
4422
  const wasSet = this.eIsSet(feature);
@@ -4253,6 +4508,7 @@ var EParameterImpl = class extends ETypedElementImpl {
4253
4508
  this._eOperation = value;
4254
4509
  }
4255
4510
  eGet(feature) {
4511
+ this.requireOwnFeature(feature);
4256
4512
  switch (feature.getFeatureID()) {
4257
4513
  case 10:
4258
4514
  return this._eOperation;
@@ -4261,6 +4517,7 @@ var EParameterImpl = class extends ETypedElementImpl {
4261
4517
  }
4262
4518
  }
4263
4519
  eSet(feature, value) {
4520
+ this.requireOwnFeature(feature);
4264
4521
  switch (feature.getFeatureID()) {
4265
4522
  default:
4266
4523
  super.eSet(feature, value);
@@ -4285,6 +4542,7 @@ var EParameterImpl = class extends ETypedElementImpl {
4285
4542
  }
4286
4543
  }
4287
4544
  eIsSet(feature) {
4545
+ this.requireOwnFeature(feature);
4288
4546
  switch (feature.getFeatureID()) {
4289
4547
  case 10:
4290
4548
  return this._eOperation !== void 0;
@@ -4293,6 +4551,7 @@ var EParameterImpl = class extends ETypedElementImpl {
4293
4551
  }
4294
4552
  }
4295
4553
  eUnset(feature) {
4554
+ this.requireOwnFeature(feature);
4296
4555
  switch (feature.getFeatureID()) {
4297
4556
  case 10: {
4298
4557
  const wasSet = this.eIsSet(feature);
@@ -4360,6 +4619,7 @@ var EReferenceImpl = class extends EStructuralFeatureImpl {
4360
4619
  return this._eKeys;
4361
4620
  }
4362
4621
  eGet(feature) {
4622
+ this.requireOwnFeature(feature);
4363
4623
  switch (feature.getFeatureID()) {
4364
4624
  case 18:
4365
4625
  return this._containment;
@@ -4378,6 +4638,7 @@ var EReferenceImpl = class extends EStructuralFeatureImpl {
4378
4638
  }
4379
4639
  }
4380
4640
  eSet(feature, value) {
4641
+ this.requireOwnFeature(feature);
4381
4642
  switch (feature.getFeatureID()) {
4382
4643
  case 18: {
4383
4644
  const oldValue = this.eGet(feature);
@@ -4478,6 +4739,7 @@ var EReferenceImpl = class extends EStructuralFeatureImpl {
4478
4739
  }
4479
4740
  }
4480
4741
  eIsSet(feature) {
4742
+ this.requireOwnFeature(feature);
4481
4743
  switch (feature.getFeatureID()) {
4482
4744
  case 18:
4483
4745
  return this._containment !== false;
@@ -4496,6 +4758,7 @@ var EReferenceImpl = class extends EStructuralFeatureImpl {
4496
4758
  }
4497
4759
  }
4498
4760
  eUnset(feature) {
4761
+ this.requireOwnFeature(feature);
4499
4762
  switch (feature.getFeatureID()) {
4500
4763
  case 18: {
4501
4764
  const wasSet = this.eIsSet(feature);
@@ -4601,6 +4864,7 @@ var ETypeParameterImpl = class extends ENamedElementImpl {
4601
4864
  return this._eBounds;
4602
4865
  }
4603
4866
  eGet(feature) {
4867
+ this.requireOwnFeature(feature);
4604
4868
  switch (feature.getFeatureID()) {
4605
4869
  case 2:
4606
4870
  return this._eBounds;
@@ -4609,6 +4873,7 @@ var ETypeParameterImpl = class extends ENamedElementImpl {
4609
4873
  }
4610
4874
  }
4611
4875
  eSet(feature, value) {
4876
+ this.requireOwnFeature(feature);
4612
4877
  switch (feature.getFeatureID()) {
4613
4878
  case 2: {
4614
4879
  const list = this._eBounds;
@@ -4640,6 +4905,7 @@ var ETypeParameterImpl = class extends ENamedElementImpl {
4640
4905
  }
4641
4906
  }
4642
4907
  eIsSet(feature) {
4908
+ this.requireOwnFeature(feature);
4643
4909
  switch (feature.getFeatureID()) {
4644
4910
  case 2:
4645
4911
  return this._eBoundsCache !== void 0 && this._eBoundsCache.size() !== 0;
@@ -4648,6 +4914,7 @@ var ETypeParameterImpl = class extends ENamedElementImpl {
4648
4914
  }
4649
4915
  }
4650
4916
  eUnset(feature) {
4917
+ this.requireOwnFeature(feature);
4651
4918
  switch (feature.getFeatureID()) {
4652
4919
  case 2:
4653
4920
  this._eBoundsCache?.clear();
@@ -4825,26 +5092,20 @@ var ResourceFactoryRegistryImpl = class {
4825
5092
  const byExtension = this.factoriesByExtension.get(extension);
4826
5093
  if (byExtension) return byExtension;
4827
5094
  }
4828
- return this.factoriesByProtocol.get(uri.getScheme());
5095
+ const scheme = uri.getScheme();
5096
+ return scheme === void 0 ? void 0 : this.factoriesByProtocol.get(scheme);
4829
5097
  }
4830
5098
  };
4831
5099
 
4832
5100
  // src/resource/resource-utils.ts
4833
- var resourceByRoot = /* @__PURE__ */ new WeakMap();
4834
5101
  function associateRoot(root, resource) {
4835
- resourceByRoot.set(root, resource);
5102
+ root.eSetDirectResource(resource);
4836
5103
  }
4837
5104
  function dissociateRoot(root) {
4838
- resourceByRoot.delete(root);
5105
+ root.eSetDirectResource(void 0);
4839
5106
  }
4840
5107
  function getResourceOf(obj) {
4841
- let current = obj;
4842
- let container = current.eContainer();
4843
- while (container) {
4844
- current = container;
4845
- container = current.eContainer();
4846
- }
4847
- return resourceByRoot.get(current);
5108
+ return obj.eResource();
4848
5109
  }
4849
5110
 
4850
5111
  // src/resource/resource-impl.ts
@@ -4855,13 +5116,28 @@ var ResourceContentsList = class extends BasicEList {
4855
5116
  }
4856
5117
  owningResource;
4857
5118
  add(item) {
5119
+ if (this.contains(item)) return;
5120
+ this.detachFromCurrentOwner(item);
4858
5121
  super.add(item);
4859
5122
  associateRoot(item, this.owningResource);
4860
5123
  }
4861
5124
  addAt(index, item) {
5125
+ if (this.contains(item)) return;
5126
+ this.detachFromCurrentOwner(item);
4862
5127
  super.addAt(index, item);
4863
5128
  associateRoot(item, this.owningResource);
4864
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
+ }
4865
5141
  addAll(items) {
4866
5142
  for (const item of items) this.add(item);
4867
5143
  }
@@ -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,