@patterkit/compiler 0.4.6 → 0.5.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/dist/index.cjs CHANGED
@@ -348,6 +348,7 @@ var import_dialect4 = require("@patterkit/dialect");
348
348
  // src/export.ts
349
349
  var import_core = require("@patterkit/core");
350
350
  var import_dialect3 = require("@patterkit/dialect");
351
+ var import_model2 = require("@patterkit/model");
351
352
  function compileEffect(e, foreign) {
352
353
  return { kind: "set", target: e.target, value: compileExpression(e.value, foreign) };
353
354
  }
@@ -446,6 +447,7 @@ function exportBundle(input) {
446
447
  const scenesOut = {};
447
448
  for (const scene of scenes) scenesOut[scene.id] = compileScene(scene, compileScopes);
448
449
  const externalScopes = externalScopesIn(scenesOut, /* @__PURE__ */ new Set([...import_dialect3.EXTERNAL_SCOPES, ...gameExternal.map((s) => s.token)]));
450
+ const qualifiers = (0, import_model2.usedQualifiers)(project, scenes).map((q) => ({ gameId: q.gameId, name: q.name }));
449
451
  const strings = {};
450
452
  for (const loc of locales) {
451
453
  if (includeLocales && !includeLocales.includes(loc.locale)) continue;
@@ -464,21 +466,24 @@ function exportBundle(input) {
464
466
  // Binds saves to the content they were taken against, and gates bundle
465
467
  // staleness (schema §10.5). A stable strict-JSON fingerprint - independent
466
468
  // of the source-form trailing-comma policy.
467
- // `scopeRegistry` is folded in only when present, so projects without host scopes keep their exact
468
- // prior hash (no ripple to existing bundles / the conformance corpus).
469
+ // `scopeRegistry` and `qualifiers` are folded in only when present, so projects without them keep
470
+ // their exact prior hash (no ripple to existing bundles / the conformance corpus).
469
471
  hash: (0, import_core.hash32)((0, import_core.canonicalStringify)({
470
472
  scenes: scenesOut,
471
473
  strings,
472
474
  properties: project.properties ?? [],
473
- ...foreignScopes ? { scopeRegistry: foreignScopes } : {}
475
+ ...foreignScopes ? { scopeRegistry: foreignScopes } : {},
476
+ ...qualifiers.length > 0 ? { qualifiers } : {}
474
477
  }, { trailingComma: false })),
475
478
  // Structure-only fingerprint (live bundle refresh): the same hash with the string tables left
476
479
  // out. Same structureHash + a different hash = a text-only edit, safe to swap in place with
477
480
  // `engine.replaceStrings()`; a changed structureHash needs the full save/load hot swap.
481
+ // A qualifier's name rides in `qualifiers`, not the string tables, so renaming one is a structure change.
478
482
  structureHash: (0, import_core.hash32)((0, import_core.canonicalStringify)({
479
483
  scenes: scenesOut,
480
484
  properties: project.properties ?? [],
481
- ...foreignScopes ? { scopeRegistry: foreignScopes } : {}
485
+ ...foreignScopes ? { scopeRegistry: foreignScopes } : {},
486
+ ...qualifiers.length > 0 ? { qualifiers } : {}
482
487
  }, { trailingComma: false }))
483
488
  },
484
489
  voiced: project.voiced ?? false,
@@ -494,6 +499,7 @@ function exportBundle(input) {
494
499
  if (c.gameData !== void 0) m.gameData = c.gameData;
495
500
  return m;
496
501
  }),
502
+ ...qualifiers.length > 0 ? { qualifiers } : {},
497
503
  properties: project.properties,
498
504
  scopeRegistry: hostScopes,
499
505
  gameDataFields: project.gameDataFields,
package/dist/index.js CHANGED
@@ -314,6 +314,7 @@ import { hostScopesToSpec as hostScopesToSpec4, EXTERNAL_SCOPES as EXTERNAL_SCOP
314
314
  // src/export.ts
315
315
  import { canonicalStringify, hash32 } from "@patterkit/core";
316
316
  import { hostScopesToSpec as hostScopesToSpec3, withEngineScopes as withEngineScopes2, EXTERNAL_SCOPES } from "@patterkit/dialect";
317
+ import { usedQualifiers } from "@patterkit/model";
317
318
  function compileEffect(e, foreign) {
318
319
  return { kind: "set", target: e.target, value: compileExpression(e.value, foreign) };
319
320
  }
@@ -412,6 +413,7 @@ function exportBundle(input) {
412
413
  const scenesOut = {};
413
414
  for (const scene of scenes) scenesOut[scene.id] = compileScene(scene, compileScopes);
414
415
  const externalScopes = externalScopesIn(scenesOut, /* @__PURE__ */ new Set([...EXTERNAL_SCOPES, ...gameExternal.map((s) => s.token)]));
416
+ const qualifiers = usedQualifiers(project, scenes).map((q) => ({ gameId: q.gameId, name: q.name }));
415
417
  const strings = {};
416
418
  for (const loc of locales) {
417
419
  if (includeLocales && !includeLocales.includes(loc.locale)) continue;
@@ -430,21 +432,24 @@ function exportBundle(input) {
430
432
  // Binds saves to the content they were taken against, and gates bundle
431
433
  // staleness (schema §10.5). A stable strict-JSON fingerprint - independent
432
434
  // of the source-form trailing-comma policy.
433
- // `scopeRegistry` is folded in only when present, so projects without host scopes keep their exact
434
- // prior hash (no ripple to existing bundles / the conformance corpus).
435
+ // `scopeRegistry` and `qualifiers` are folded in only when present, so projects without them keep
436
+ // their exact prior hash (no ripple to existing bundles / the conformance corpus).
435
437
  hash: hash32(canonicalStringify({
436
438
  scenes: scenesOut,
437
439
  strings,
438
440
  properties: project.properties ?? [],
439
- ...foreignScopes ? { scopeRegistry: foreignScopes } : {}
441
+ ...foreignScopes ? { scopeRegistry: foreignScopes } : {},
442
+ ...qualifiers.length > 0 ? { qualifiers } : {}
440
443
  }, { trailingComma: false })),
441
444
  // Structure-only fingerprint (live bundle refresh): the same hash with the string tables left
442
445
  // out. Same structureHash + a different hash = a text-only edit, safe to swap in place with
443
446
  // `engine.replaceStrings()`; a changed structureHash needs the full save/load hot swap.
447
+ // A qualifier's name rides in `qualifiers`, not the string tables, so renaming one is a structure change.
444
448
  structureHash: hash32(canonicalStringify({
445
449
  scenes: scenesOut,
446
450
  properties: project.properties ?? [],
447
- ...foreignScopes ? { scopeRegistry: foreignScopes } : {}
451
+ ...foreignScopes ? { scopeRegistry: foreignScopes } : {},
452
+ ...qualifiers.length > 0 ? { qualifiers } : {}
448
453
  }, { trailingComma: false }))
449
454
  },
450
455
  voiced: project.voiced ?? false,
@@ -460,6 +465,7 @@ function exportBundle(input) {
460
465
  if (c.gameData !== void 0) m.gameData = c.gameData;
461
466
  return m;
462
467
  }),
468
+ ...qualifiers.length > 0 ? { qualifiers } : {},
463
469
  properties: project.properties,
464
470
  scopeRegistry: hostScopes,
465
471
  gameDataFields: project.gameDataFields,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patterkit/compiler",
3
- "version": "0.4.6",
3
+ "version": "0.5.0",
4
4
  "description": "Patter compiler: compile condition/effect expressions, validate them, and export source to the runtime bundle.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,9 +34,9 @@
34
34
  "build": "tsup src/index.ts --format esm,cjs --dts --clean"
35
35
  },
36
36
  "dependencies": {
37
- "@patterkit/model": "0.10.0",
38
- "@patterkit/core": "0.4.0",
39
- "@patterkit/dialect": "0.2.6",
37
+ "@patterkit/model": "0.11.0",
38
+ "@patterkit/core": "0.5.0",
39
+ "@patterkit/dialect": "0.2.7",
40
40
  "@wildwinter/expr": "^0.5.0"
41
41
  },
42
42
  "peerDependencies": {