@forgeax/engine-import 0.1.20 → 0.1.23

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 (91) hide show
  1. package/README.md +91 -3
  2. package/dist/__tests__/ies-contract.unit.test.d.ts +2 -0
  3. package/dist/__tests__/ies-contract.unit.test.d.ts.map +1 -0
  4. package/dist/__tests__/ies-producer.unit.test.d.ts +2 -0
  5. package/dist/__tests__/ies-producer.unit.test.d.ts.map +1 -0
  6. package/dist/__tests__/mesh-lod-contract.unit.test.d.ts +2 -0
  7. package/dist/__tests__/mesh-lod-contract.unit.test.d.ts.map +1 -0
  8. package/dist/__tests__/mesh-lod-reimport.integration.test.d.ts +2 -0
  9. package/dist/__tests__/mesh-lod-reimport.integration.test.d.ts.map +1 -0
  10. package/dist/__tests__/parameterized-scriptable-pack.unit.test.d.ts +2 -0
  11. package/dist/__tests__/parameterized-scriptable-pack.unit.test.d.ts.map +1 -0
  12. package/dist/__tests__/scriptable-pack-file-snapshot.unit.test.d.ts +2 -0
  13. package/dist/__tests__/scriptable-pack-file-snapshot.unit.test.d.ts.map +1 -0
  14. package/dist/__tests__/source-package-publication-lod.integration.test.d.ts +2 -0
  15. package/dist/__tests__/source-package-publication-lod.integration.test.d.ts.map +1 -0
  16. package/dist/browser.d.ts +1 -0
  17. package/dist/browser.d.ts.map +1 -1
  18. package/dist/browser.mjs +230 -3
  19. package/dist/browser.mjs.map +1 -1
  20. package/dist/build-production.d.ts +1 -8
  21. package/dist/build-production.d.ts.map +1 -1
  22. package/dist/ies/ies-importer.d.ts +4 -0
  23. package/dist/ies/ies-importer.d.ts.map +1 -0
  24. package/dist/ies/parse-lm63.d.ts +13 -0
  25. package/dist/ies/parse-lm63.d.ts.map +1 -0
  26. package/dist/ies/resample-type-c.d.ts +4 -0
  27. package/dist/ies/resample-type-c.d.ts.map +1 -0
  28. package/dist/import-runner.d.ts.map +1 -1
  29. package/dist/index.d.ts +11 -6
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.mjs +2550 -1029
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/mesh-bin.d.ts.map +1 -1
  34. package/dist/mesh-bin.mjs +29 -1
  35. package/dist/mesh-bin.mjs.map +1 -1
  36. package/dist/mesh-lod.d.ts +60 -0
  37. package/dist/mesh-lod.d.ts.map +1 -0
  38. package/dist/parameterized-scriptable-pack.d.ts +68 -0
  39. package/dist/parameterized-scriptable-pack.d.ts.map +1 -0
  40. package/dist/scriptable-pack-file-snapshot.d.ts +71 -0
  41. package/dist/scriptable-pack-file-snapshot.d.ts.map +1 -0
  42. package/dist/scriptable-pack-host.d.ts +70 -39
  43. package/dist/scriptable-pack-host.d.ts.map +1 -1
  44. package/dist/scriptable-pack-output-producers.d.ts +1 -0
  45. package/dist/scriptable-pack-output-producers.d.ts.map +1 -1
  46. package/dist/scriptable-pack-staged-snapshot.d.ts +2 -2
  47. package/dist/scriptable-pack-staged-snapshot.d.ts.map +1 -1
  48. package/dist/scriptable-pack.d.ts +13 -26
  49. package/dist/scriptable-pack.d.ts.map +1 -1
  50. package/dist/source-package-errors.d.ts.map +1 -1
  51. package/dist/source-package-publication.d.ts.map +1 -1
  52. package/package.json +8 -7
  53. package/src/__tests__/ies-contract.unit.test.ts +31 -0
  54. package/src/__tests__/ies-producer.unit.test.ts +104 -0
  55. package/src/__tests__/mesh-bin.test.ts +69 -0
  56. package/src/__tests__/mesh-lod-contract.unit.test.ts +92 -0
  57. package/src/__tests__/mesh-lod-reimport.integration.test.ts +15 -0
  58. package/src/__tests__/parameterized-scriptable-pack.unit.test.ts +270 -0
  59. package/src/__tests__/scriptable-pack-file-snapshot.unit.test.ts +177 -0
  60. package/src/__tests__/scriptable-pack-host.unit.test.ts +196 -4
  61. package/src/__tests__/scriptable-pack-production-producers.unit.test.ts +7 -1
  62. package/src/__tests__/scriptable-pack-staged-snapshot.unit.test.ts +43 -12
  63. package/src/__tests__/source-package-publication-lod.integration.test.ts +29 -0
  64. package/src/__tests__/source-package-publication.integration.test.ts +26 -1
  65. package/src/browser.ts +5 -0
  66. package/src/build-production.ts +498 -141
  67. package/src/ies/ies-importer.ts +126 -0
  68. package/src/ies/parse-lm63.ts +98 -0
  69. package/src/ies/resample-type-c.ts +108 -0
  70. package/src/import-runner.ts +58 -0
  71. package/src/index.ts +49 -19
  72. package/src/mesh-bin.ts +38 -0
  73. package/src/mesh-lod.ts +265 -0
  74. package/src/parameterized-scriptable-pack.ts +725 -0
  75. package/src/scriptable-pack-file-snapshot.ts +346 -0
  76. package/src/scriptable-pack-host.ts +790 -343
  77. package/src/scriptable-pack-output-producers.ts +58 -1
  78. package/src/scriptable-pack-staged-snapshot.ts +12 -11
  79. package/src/scriptable-pack.ts +16 -485
  80. package/src/source-package-errors.ts +6 -0
  81. package/src/source-package-publication.ts +32 -2
  82. package/dist/.tsbuildinfo +0 -1
  83. package/dist/__tests__/scriptable-pack-product.contract.test.d.ts +0 -2
  84. package/dist/__tests__/scriptable-pack-product.contract.test.d.ts.map +0 -1
  85. package/dist/__tests__/scriptable-pack.integration.test.d.ts +0 -2
  86. package/dist/__tests__/scriptable-pack.integration.test.d.ts.map +0 -1
  87. package/dist/scriptable-source-package.d.ts +0 -14
  88. package/dist/scriptable-source-package.d.ts.map +0 -1
  89. package/src/__tests__/scriptable-pack-product.contract.test.ts +0 -46
  90. package/src/__tests__/scriptable-pack.integration.test.ts +0 -435
  91. package/src/scriptable-source-package.ts +0 -88
@@ -44,7 +44,14 @@ describe('ScriptablePack staged asset snapshot source', () => {
44
44
  guids: [DEPENDENCY],
45
45
  async build() {
46
46
  builds.push('dependency');
47
- return ok([{ guid: DEPENDENCY, asset: mesh(2), digest: 'sha256:dependency' }]);
47
+ return ok([
48
+ {
49
+ guid: DEPENDENCY,
50
+ sourceKey: 'dependency',
51
+ asset: mesh(2),
52
+ digest: 'sha256:dependency',
53
+ },
54
+ ]);
48
55
  },
49
56
  },
50
57
  {
@@ -56,7 +63,7 @@ describe('ScriptablePack staged asset snapshot source', () => {
56
63
  if (!dependency.ok) return dependency;
57
64
  builds.push('root:end');
58
65
  const value = dependency.value.asset as MeshAsset;
59
- return ok([{ guid: ROOT, asset: mesh(value.vertices[0] ?? 0) }]);
66
+ return ok([{ guid: ROOT, sourceKey: 'root', asset: mesh(value.vertices[0] ?? 0) }]);
60
67
  },
61
68
  },
62
69
  ];
@@ -81,7 +88,9 @@ describe('ScriptablePack staged asset snapshot source', () => {
81
88
  guids: [ROOT],
82
89
  async build(source) {
83
90
  const result = await source.readByGuid(DEPENDENCY);
84
- return result.ok ? ok([{ guid: ROOT, asset: result.value.asset }]) : result;
91
+ return result.ok
92
+ ? ok([{ guid: ROOT, sourceKey: 'root', asset: result.value.asset }])
93
+ : result;
85
94
  },
86
95
  },
87
96
  {
@@ -89,7 +98,9 @@ describe('ScriptablePack staged asset snapshot source', () => {
89
98
  guids: [DEPENDENCY],
90
99
  async build(source) {
91
100
  const result = await source.readByGuid(ROOT);
92
- return result.ok ? ok([{ guid: DEPENDENCY, asset: result.value.asset }]) : result;
101
+ return result.ok
102
+ ? ok([{ guid: DEPENDENCY, sourceKey: 'dependency', asset: result.value.asset }])
103
+ : result;
93
104
  },
94
105
  },
95
106
  ];
@@ -101,8 +112,11 @@ describe('ScriptablePack staged asset snapshot source', () => {
101
112
  expect(result).toMatchObject({
102
113
  ok: false,
103
114
  error: {
104
- code: 'pack-source-build-cycle',
105
- actual: 'a.pack.ts -> b.pack.ts -> a.pack.ts',
115
+ code: 'pack-content-dependency-stalled',
116
+ detail: {
117
+ waitingGuids: [AssetGuid.format(ROOT)],
118
+ pendingSubjects: ['a.pack.ts', 'b.pack.ts', 'a.pack.ts'],
119
+ },
106
120
  },
107
121
  });
108
122
  });
@@ -116,7 +130,9 @@ describe('ScriptablePack staged asset snapshot source', () => {
116
130
  guids: [ROOT],
117
131
  async build(ownerSource) {
118
132
  const result = await ownerSource.readByGuid(DEPENDENCY);
119
- return result.ok ? ok([{ guid: ROOT, asset: result.value.asset }]) : result;
133
+ return result.ok
134
+ ? ok([{ guid: ROOT, sourceKey: 'root', asset: result.value.asset }])
135
+ : result;
120
136
  },
121
137
  },
122
138
  ],
@@ -134,7 +150,7 @@ describe('ScriptablePack staged asset snapshot source', () => {
134
150
  it('resolves declared direct Pack outputs in the same generation', async () => {
135
151
  const source = createScriptablePackStagedAssetSnapshotSource({
136
152
  generation: 3,
137
- declaredExternalOutputs: [{ guid: DEPENDENCY, asset: mesh(7) }],
153
+ declaredExternalOutputs: [{ guid: DEPENDENCY, sourceKey: 'dependency', asset: mesh(7) }],
138
154
  owners: [
139
155
  {
140
156
  id: 'root.pack.ts',
@@ -145,6 +161,7 @@ describe('ScriptablePack staged asset snapshot source', () => {
145
161
  ? ok([
146
162
  {
147
163
  guid: ROOT,
164
+ sourceKey: 'root',
148
165
  asset: mesh((dependency.value.asset as MeshAsset).vertices[0] ?? 0),
149
166
  },
150
167
  ])
@@ -178,7 +195,14 @@ describe('ScriptablePack staged asset snapshot source', () => {
178
195
  guids: [DEPENDENCY],
179
196
  async build() {
180
197
  dependencyBuilds += 1;
181
- return ok([{ guid: DEPENDENCY, asset: mesh(2), digest: 'sha256:dependency' }]);
198
+ return ok([
199
+ {
200
+ guid: DEPENDENCY,
201
+ sourceKey: 'dependency',
202
+ asset: mesh(2),
203
+ digest: 'sha256:dependency',
204
+ },
205
+ ]);
182
206
  },
183
207
  },
184
208
  {
@@ -192,7 +216,12 @@ describe('ScriptablePack staged asset snapshot source', () => {
192
216
  await repairBuildGate;
193
217
  const value = dependency.value.asset as MeshAsset;
194
218
  return ok([
195
- { guid: ROOT, asset: mesh((value.vertices[0] ?? 0) + 1), digest: 'sha256:root' },
219
+ {
220
+ guid: ROOT,
221
+ sourceKey: 'root',
222
+ asset: mesh((value.vertices[0] ?? 0) + 1),
223
+ digest: 'sha256:root',
224
+ },
196
225
  ]);
197
226
  },
198
227
  },
@@ -201,7 +230,9 @@ describe('ScriptablePack staged asset snapshot source', () => {
201
230
  guids: [HEALTHY],
202
231
  async build() {
203
232
  healthyBuilds += 1;
204
- return ok([{ guid: HEALTHY, asset: mesh(7), digest: 'sha256:healthy' }]);
233
+ return ok([
234
+ { guid: HEALTHY, sourceKey: 'healthy', asset: mesh(7), digest: 'sha256:healthy' },
235
+ ]);
205
236
  },
206
237
  },
207
238
  ];
@@ -272,7 +303,7 @@ describe('ScriptablePack staged asset snapshot source', () => {
272
303
  id: 'mesh.pack.ts',
273
304
  guids: [ROOT],
274
305
  async build() {
275
- return ok([{ guid: ROOT, asset: mesh(3), digest: 'sha256:mesh' }]);
306
+ return ok([{ guid: ROOT, sourceKey: 'mesh', asset: mesh(3), digest: 'sha256:mesh' }]);
276
307
  },
277
308
  };
278
309
  const first = await createScriptablePackStagedAssetSnapshotSource({
@@ -0,0 +1,29 @@
1
+ import { mkdtemp, rm } from 'node:fs/promises';
2
+ import { tmpdir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { afterEach, describe, expect, it } from 'vitest';
5
+ import { publishImportPublication } from '../source-package-publication.js';
6
+
7
+ describe('LOD publication boundary', () => {
8
+ const roots: string[] = [];
9
+
10
+ afterEach(async () => {
11
+ await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })));
12
+ });
13
+
14
+ it('publishes the complete root package through the shared host', async () => {
15
+ const root = await mkdtemp(join(tmpdir(), 'forgeax-lod-publication-'));
16
+ roots.push(root);
17
+ const guid = '019e3969-1d48-7c3b-ac24-6d68f457065f';
18
+ const result = await publishImportPublication({
19
+ root,
20
+ guid,
21
+ desiredKey: 'a'.repeat(64),
22
+ pack: { lods: [{ meshGuid: 'lod-1', screenCoverage: 0.5 }] },
23
+ previousCatalog: [],
24
+ nextCatalog: [],
25
+ publishedGuids: [guid, 'lod-1'],
26
+ });
27
+ expect(result.ok).toBe(true);
28
+ });
29
+ });
@@ -1,4 +1,4 @@
1
- import { mkdtemp, rm } from 'node:fs/promises';
1
+ import { mkdtemp, readdir, readFile, rm } from 'node:fs/promises';
2
2
  import { tmpdir } from 'node:os';
3
3
  import { join } from 'node:path';
4
4
  import { afterEach, describe, expect, it } from 'vitest';
@@ -72,4 +72,29 @@ describe('source package publication concurrency', () => {
72
72
  error: { code: 'source-package-ddc-failed', detail: 'DDC lifecycle commit returned stale' },
73
73
  });
74
74
  });
75
+
76
+ it('persists concurrent equivalent transports without sharing a temporary path', async () => {
77
+ const root = await mkdtemp(join(tmpdir(), 'forgeax-source-publication-'));
78
+ roots.push(root);
79
+ const transport = {
80
+ path: join(root, 'runtime', `${GUID}.pack.json`),
81
+ body: JSON.stringify({ guid: GUID, value: 'concurrent' }),
82
+ };
83
+ const staged = await Promise.all(
84
+ Array.from({ length: 8 }, () => stageImportPublication({ ...input(root), transport })),
85
+ );
86
+ expect(staged.every((candidate) => candidate.ok)).toBe(true);
87
+ if (staged.some((candidate) => !candidate.ok)) return;
88
+
89
+ const results = await Promise.all(
90
+ staged.map((candidate) =>
91
+ candidate.ok ? commitImportPublication(candidate.candidate) : Promise.resolve(candidate),
92
+ ),
93
+ );
94
+ expect(results.every((result) => result.ok && result.transportPersisted)).toBe(true);
95
+ expect(await readFile(transport.path, 'utf8')).toBe(transport.body);
96
+ expect((await readdir(join(root, 'runtime'))).some((name) => name.includes('.tmp'))).toBe(
97
+ false,
98
+ );
99
+ });
75
100
  });
package/src/browser.ts CHANGED
@@ -12,3 +12,8 @@ export {
12
12
  } from './import-runner.js';
13
13
  export { ImporterRegistry } from './importer-registry.js';
14
14
  export { packMeshBinV4 } from './mesh-bin.js';
15
+ export {
16
+ deriveDefaultLodScreenCoverages,
17
+ reconcileMeshLodMeta,
18
+ validateMeshLodContract,
19
+ } from './mesh-lod.js';