@forgeax/engine-preview 0.1.4 → 0.1.7

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.
@@ -1,6 +1,5 @@
1
1
  import { type Plugin, type ToolPlugin } from '@forgeax/engine-plugin';
2
2
  import { type ArtifactRef, type SnapshotRef } from '@forgeax/engine-tool-runtime';
3
- import type { AssetKind } from '@forgeax/engine-types';
4
3
  export interface PreviewAssetLoadResult<TAsset = unknown> {
5
4
  readonly ok: true;
6
5
  readonly value: TAsset;
@@ -12,7 +11,7 @@ export interface PreviewAssetLoadFailure {
12
11
  readonly error: unknown;
13
12
  }
14
13
  export interface PreviewAssetRegistry {
15
- readonly load: <TAsset, TKind extends string>(guid: string, kind: AssetKind<TAsset, TKind>) => Promise<PreviewAssetLoadResult<TAsset> | PreviewAssetLoadFailure>;
14
+ readonly loadByGuid: <TAsset = unknown>(guid: string) => Promise<PreviewAssetLoadResult<TAsset> | PreviewAssetLoadFailure>;
16
15
  }
17
16
  export interface PreviewRenderRuntime {
18
17
  readonly rendererReady: boolean;
package/dist/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import { defineToolPlugin } from '@forgeax/engine-plugin';
2
2
  import { defineToolCapability, defineTool, validatePreviewArtifactManifest, createPreviewArtifactManifest } from '@forgeax/engine-tool-runtime';
3
3
  export { createPreviewArtifactManifest, validatePreviewArtifactManifest } from '@forgeax/engine-tool-runtime';
4
- import { builtinAssetKind } from '@forgeax/engine-runtime';
5
4
 
6
5
  // src/domains/subject.ts
7
6
  var previewHostCapability = defineToolCapability("preview.host");
@@ -97,7 +96,7 @@ function subjectFailure(code, expected, detail) {
97
96
  error: {
98
97
  code,
99
98
  expected,
100
- hint: "Load the requested GUID through AssetRegistry.load(guid, kind) and repair the owner facts before retrying.",
99
+ hint: "Load the requested GUID through AssetRegistry.loadByGuid and repair the owner facts before retrying.",
101
100
  detail
102
101
  }
103
102
  };
@@ -601,6 +600,8 @@ function validateCanonicalKitReceipt(value) {
601
600
  return invalid("transport");
602
601
  return { ok: true, value };
603
602
  }
603
+
604
+ // src/domains/material.ts
604
605
  function isRecord4(value) {
605
606
  return typeof value === "object" && value !== null;
606
607
  }
@@ -680,10 +681,10 @@ async function executeMaterialPreview(args, input) {
680
681
  "resource preview host to expose the existing AssetRegistry",
681
682
  { phase: "asset-registry", runId: input.runId }
682
683
  );
683
- const loaded = await input.assets.load(args.guid, builtinAssetKind("material"));
684
+ const loaded = await input.assets.loadByGuid(args.guid);
684
685
  if (!loaded.ok)
685
686
  return assetLoadFailure(
686
- "AssetRegistry.load(guid, materialAssetKind) to resolve the requested material",
687
+ "AssetRegistry.loadByGuid to resolve the requested material",
687
688
  input.runId,
688
689
  loaded.error
689
690
  );
@@ -815,6 +816,8 @@ var materialPreview = defineTool(
815
816
  })()
816
817
  );
817
818
  nativePreviewPlugin("material", materialPreview);
819
+
820
+ // src/domains/mesh.ts
818
821
  function isRecord5(value) {
819
822
  return typeof value === "object" && value !== null;
820
823
  }
@@ -940,10 +943,10 @@ async function executeMeshPreview(args, input) {
940
943
  "resource preview host to expose the existing AssetRegistry",
941
944
  { phase: "asset-registry", runId: input.runId }
942
945
  );
943
- const loaded = await input.assets.load(args.guid, builtinAssetKind("mesh"));
946
+ const loaded = await input.assets.loadByGuid(args.guid);
944
947
  if (!loaded.ok)
945
948
  return assetLoadFailure(
946
- "AssetRegistry.load(guid, meshAssetKind) to resolve the requested mesh",
949
+ "AssetRegistry.loadByGuid to resolve the requested mesh",
947
950
  input.runId,
948
951
  loaded.error
949
952
  );
@@ -1089,6 +1092,8 @@ var meshPreview = defineTool(
1089
1092
  })()
1090
1093
  );
1091
1094
  nativePreviewPlugin("mesh", meshPreview);
1095
+
1096
+ // src/domains/texture.ts
1092
1097
  function isRecord6(value) {
1093
1098
  return typeof value === "object" && value !== null;
1094
1099
  }
@@ -1190,10 +1195,10 @@ async function executeTexturePreview(args, input) {
1190
1195
  runId: input.runId
1191
1196
  }
1192
1197
  );
1193
- const loaded = await input.assets.load(args.guid, builtinAssetKind("texture"));
1198
+ const loaded = await input.assets.loadByGuid(args.guid);
1194
1199
  if (!loaded.ok)
1195
1200
  return assetLoadFailure(
1196
- "AssetRegistry.load(guid, textureAssetKind) to resolve the texture",
1201
+ "AssetRegistry.loadByGuid to resolve the texture",
1197
1202
  input.runId,
1198
1203
  loaded.error
1199
1204
  );
@@ -1346,6 +1351,8 @@ var texturePreview = defineTool(subjectDescriptor("texture"), (args, context) =>
1346
1351
  );
1347
1352
  });
1348
1353
  nativePreviewPlugin("texture", texturePreview);
1354
+
1355
+ // src/domains/vfx.ts
1349
1356
  function isRecord7(value) {
1350
1357
  return typeof value === "object" && value !== null;
1351
1358
  }
@@ -1534,10 +1541,10 @@ async function executeVfxPreview(args, input) {
1534
1541
  runId: input.runId
1535
1542
  }
1536
1543
  );
1537
- const loaded = await input.assets.load(args.guid, builtinAssetKind("particle-effect"));
1544
+ const loaded = await input.assets.loadByGuid(args.guid);
1538
1545
  if (!loaded.ok)
1539
1546
  return assetLoadFailure(
1540
- "AssetRegistry.load(guid, particleEffectAssetKind) to resolve the VFX",
1547
+ "AssetRegistry.loadByGuid to resolve the VFX",
1541
1548
  input.runId,
1542
1549
  loaded.error
1543
1550
  );
@@ -1717,12 +1724,12 @@ function materialBindingFromPayload(guid, payload) {
1717
1724
  if (payload.kind !== "material" || payload.passes === void 0 || payload.passes.length === 0)
1718
1725
  return void 0;
1719
1726
  const program = payload.passes[0]?.program;
1720
- if (!program?.module || program.moduleSlots === void 0 || Object.keys(program.moduleSlots).length === 0)
1727
+ if (!program?.module || payload.parameters === void 0 || payload.parameters.length === 0)
1721
1728
  return void 0;
1722
1729
  return {
1723
1730
  guid,
1724
1731
  programDigest: `material-program:${program.module}`,
1725
- bindings: Object.keys(program.moduleSlots)
1732
+ bindings: payload.parameters.map((parameter) => parameter.name)
1726
1733
  };
1727
1734
  }
1728
1735
  function meshBindingFromPayload(guid, payload) {