@forgeax/engine-import 0.1.6 → 0.1.19

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.
Files changed (35) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/__tests__/source-package-errors.unit.test.d.ts +2 -0
  3. package/dist/__tests__/source-package-errors.unit.test.d.ts.map +1 -0
  4. package/dist/__tests__/source-package-publication.integration.test.d.ts +2 -0
  5. package/dist/__tests__/source-package-publication.integration.test.d.ts.map +1 -0
  6. package/dist/browser.mjs +5 -2
  7. package/dist/browser.mjs.map +1 -1
  8. package/dist/build-production.d.ts.map +1 -1
  9. package/dist/catalog-inventory.d.ts +1 -1
  10. package/dist/catalog-inventory.d.ts.map +1 -1
  11. package/dist/import-runner.d.ts +9 -0
  12. package/dist/import-runner.d.ts.map +1 -1
  13. package/dist/index.d.ts +2 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.mjs +118 -28
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/scriptable-pack-host.d.ts +1 -1
  18. package/dist/scriptable-pack-host.d.ts.map +1 -1
  19. package/dist/source-package-errors.d.ts +2 -0
  20. package/dist/source-package-errors.d.ts.map +1 -1
  21. package/dist/source-package-publication.d.ts.map +1 -1
  22. package/dist/source-path.d.ts +12 -0
  23. package/dist/source-path.d.ts.map +1 -0
  24. package/package.json +7 -7
  25. package/src/__tests__/import-dependencies.test.ts +34 -0
  26. package/src/__tests__/source-package-errors.unit.test.ts +62 -0
  27. package/src/__tests__/source-package-publication.integration.test.ts +75 -0
  28. package/src/build-production.ts +38 -14
  29. package/src/catalog-inventory.ts +2 -0
  30. package/src/import-runner.ts +15 -2
  31. package/src/index.ts +5 -0
  32. package/src/scriptable-pack-host.ts +6 -2
  33. package/src/source-package-errors.ts +37 -0
  34. package/src/source-package-publication.ts +31 -0
  35. package/src/source-path.ts +36 -0
@@ -0,0 +1,36 @@
1
+ import { resolve } from 'node:path';
2
+ import { catalogSourcePathFor } from '@forgeax/engine-pack/build';
3
+ import type { ScanSourceDeclaration } from '@forgeax/engine-pack/scanner';
4
+
5
+ function normalizeCatalogPath(path: string): string {
6
+ return path.replaceAll('\\', '/').replace(/^\.\//, '');
7
+ }
8
+
9
+ export interface CatalogSourceDeclaration {
10
+ readonly sourcePath: string;
11
+ readonly declaration: ScanSourceDeclaration;
12
+ }
13
+
14
+ /**
15
+ * Resolve a Catalog row's logical source locator back to its physical scanner
16
+ * declaration. Catalog rows are host identities; declaration maps remain
17
+ * physical because production still has to read those files from disk.
18
+ */
19
+ export function sourceDeclarationForCatalogPath(
20
+ sourcePath: string,
21
+ declarations: ReadonlyMap<string, ScanSourceDeclaration>,
22
+ sourceIdentityFor?: (sourcePath: string) => string,
23
+ cwd = process.cwd(),
24
+ ): CatalogSourceDeclaration | undefined {
25
+ const normalized = normalizeCatalogPath(sourcePath);
26
+ const direct = declarations.get(resolve(cwd, sourcePath));
27
+ if (direct !== undefined) {
28
+ return { sourcePath: resolve(cwd, sourcePath), declaration: direct };
29
+ }
30
+ for (const [physicalPath, declaration] of declarations) {
31
+ if (catalogSourcePathFor(cwd, physicalPath, sourceIdentityFor) === normalized) {
32
+ return { sourcePath: physicalPath, declaration };
33
+ }
34
+ }
35
+ return undefined;
36
+ }