@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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/__tests__/source-package-errors.unit.test.d.ts +2 -0
- package/dist/__tests__/source-package-errors.unit.test.d.ts.map +1 -0
- package/dist/__tests__/source-package-publication.integration.test.d.ts +2 -0
- package/dist/__tests__/source-package-publication.integration.test.d.ts.map +1 -0
- package/dist/browser.mjs +5 -2
- package/dist/browser.mjs.map +1 -1
- package/dist/build-production.d.ts.map +1 -1
- package/dist/catalog-inventory.d.ts +1 -1
- package/dist/catalog-inventory.d.ts.map +1 -1
- package/dist/import-runner.d.ts +9 -0
- package/dist/import-runner.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +118 -28
- package/dist/index.mjs.map +1 -1
- package/dist/scriptable-pack-host.d.ts +1 -1
- package/dist/scriptable-pack-host.d.ts.map +1 -1
- package/dist/source-package-errors.d.ts +2 -0
- package/dist/source-package-errors.d.ts.map +1 -1
- package/dist/source-package-publication.d.ts.map +1 -1
- package/dist/source-path.d.ts +12 -0
- package/dist/source-path.d.ts.map +1 -0
- package/package.json +7 -7
- package/src/__tests__/import-dependencies.test.ts +34 -0
- package/src/__tests__/source-package-errors.unit.test.ts +62 -0
- package/src/__tests__/source-package-publication.integration.test.ts +75 -0
- package/src/build-production.ts +38 -14
- package/src/catalog-inventory.ts +2 -0
- package/src/import-runner.ts +15 -2
- package/src/index.ts +5 -0
- package/src/scriptable-pack-host.ts +6 -2
- package/src/source-package-errors.ts +37 -0
- package/src/source-package-publication.ts +31 -0
- 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
|
+
}
|