@tokenoftrust/storefront-runner 6.5.3 → 6.6.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "6.5.3",
3
+ "version": "6.6.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
6
6
  "packageManager": "pnpm@11.9.0",
@@ -45,6 +45,7 @@ export function imageTypeOf(path: string): ImageType {
45
45
 
46
46
  export function imageCensusByType(input: {
47
47
  artifacts: readonly ImageDependencyArtifact[]; tenantId: string; tenantOrigins: readonly string[]; skipped?: readonly string[];
48
+ declaredCustomProperties?: Iterable<string>;
48
49
  }): ImageTypeCounts {
49
50
  if (!Array.isArray(input.tenantOrigins)) throw new TypeError("tenantOrigins is required");
50
51
  const out = {} as ImageTypeCounts;
@@ -58,7 +59,10 @@ export function imageCensusByType(input: {
58
59
  }
59
60
  // One scan of the whole set. A custom property declared in one type and used in another is
60
61
  // resolved only when both files are visible; scanning each type alone defers that use.
61
- const scanned = scanImageDependencies(input.artifacts, { tenantId: input.tenantId, tenantOrigins: input.tenantOrigins });
62
+ const scanned = scanImageDependencies(input.artifacts, {
63
+ tenantId: input.tenantId, tenantOrigins: input.tenantOrigins,
64
+ ...(input.declaredCustomProperties ? { declaredCustomProperties: input.declaredCustomProperties } : {}),
65
+ });
62
66
  const indexed = input.artifacts.filter((artifact) => !isDurableAssetsDeclarationPath(artifact.path));
63
67
  for (const dependency of scanned.dependencies) {
64
68
  const path = indexed[dependency.artifactIndex]?.path;
@@ -100,6 +104,12 @@ export interface ImageDependencyScanOptions {
100
104
  */
101
105
  tenantOrigins: readonly string[];
102
106
  platformHosted?: PlatformHostedImageConfig;
107
+ /**
108
+ * Custom properties declared elsewhere in the revision. A scan of a subset of the revision (one
109
+ * file at a time) passes the whole revision's declarations so a `var()` use resolves exactly as
110
+ * it does when the whole set is scanned together.
111
+ */
112
+ declaredCustomProperties?: Iterable<string>;
103
113
  }
104
114
 
105
115
  export type ImageDependencyDisposition =
@@ -1485,7 +1495,7 @@ function rawCssChunksInHtml(html: string): Array<{ css: string; kind: "styleshee
1485
1495
  * reference to a declared custom property is never deferred — its image, if any, was already
1486
1496
  * captured at the declaration itself.
1487
1497
  */
1488
- function collectDeclaredCustomProperties(artifacts: readonly ImageDependencyArtifact[]): Set<string> {
1498
+ export function collectDeclaredCustomProperties(artifacts: readonly ImageDependencyArtifact[]): Set<string> {
1489
1499
  const declared = new Set<string>();
1490
1500
  for (const artifact of artifacts) {
1491
1501
  const kind = inferKind(artifact);
@@ -1512,6 +1522,7 @@ export function scanImageDependencies(
1512
1522
  const platformHosted = preparePlatformHostedConfig(options.platformHosted);
1513
1523
  const tenantOrigins = prepareTenantOrigins(options.tenantOrigins);
1514
1524
  const declaredCustomProperties = collectDeclaredCustomProperties(artifacts);
1525
+ for (const name of options.declaredCustomProperties ?? []) declaredCustomProperties.add(name);
1515
1526
  let occurrence = 0;
1516
1527
  for (const [artifactIndex, artifact] of artifacts.entries()) {
1517
1528
  const kind = inferKind(artifact);