@typemf/core 0.8.1 → 0.9.1

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
@@ -5435,10 +5435,26 @@ function isUnresolvedProxy(value) {
5435
5435
  function resolveAgainstPackage(pkg, fragment) {
5436
5436
  const segments = fragment.replace(/^\/+/, "").split("/").filter((s) => s.length > 0);
5437
5437
  if (segments.length === 0) return void 0;
5438
- const classifier = pkg.getEClassifier(segments[0]);
5439
- if (segments.length === 1) return classifier;
5440
- if (!classifier || !isEClass(classifier)) return void 0;
5441
- return classifier.getEStructuralFeature(segments[1]);
5438
+ let current = pkg;
5439
+ for (const segment of segments) {
5440
+ const container = current;
5441
+ current = namedContent(container, segment) ?? (isEClass(container) ? container.getEStructuralFeature(segment) : void 0);
5442
+ if (!current) return void 0;
5443
+ }
5444
+ return current;
5445
+ }
5446
+ function namedContent(container, segment) {
5447
+ const counted = /^(.*)\.(\d+)$/.exec(segment);
5448
+ return counted && nthNamedContent(container, counted[1], Number(counted[2])) || nthNamedContent(container, segment, 0);
5449
+ }
5450
+ function nthNamedContent(container, name, n) {
5451
+ let remaining = n;
5452
+ for (const child of container.eContents()) {
5453
+ if (!isENamedElement(child) || child.getName() !== name) continue;
5454
+ if (remaining === 0) return child;
5455
+ remaining--;
5456
+ }
5457
+ return void 0;
5442
5458
  }
5443
5459
 
5444
5460
  // src/resource/uri.ts