@patterkit/compiler 0.4.7 → 0.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/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
  }
@@ -361,6 +362,8 @@ function compileNode(node, foreign) {
361
362
  shared: node.shared,
362
363
  options: node.options,
363
364
  children: node.children.map((c) => compileNode(c, foreign)),
365
+ padAfterDefault: node.padAfterDefault,
366
+ // line padding: the default for the beats inside
364
367
  gameData: node.gameData,
365
368
  tags: node.tags,
366
369
  // author tags (#215), accumulated at runtime
@@ -378,6 +381,8 @@ function compileNode(node, foreign) {
378
381
  beats: node.beats,
379
382
  onEnter: node.onEnter?.map((e) => compileEffect(e, foreign)),
380
383
  onExit: node.onExit?.map((e) => compileEffect(e, foreign)),
384
+ padAfterDefault: node.padAfterDefault,
385
+ // line padding: the default for the beats inside
381
386
  gameData: node.gameData,
382
387
  tags: node.tags,
383
388
  // author tags (#215)
@@ -395,6 +400,8 @@ function compileBlock(block, foreign) {
395
400
  ...block.gameId ? { gameId: block.gameId } : {},
396
401
  // host-facing address; runtime falls back to the name slug
397
402
  children: block.children.map((c) => compileNode(c, foreign)),
403
+ padAfterDefault: block.padAfterDefault,
404
+ // line padding: the default for the beats inside
398
405
  gameData: block.gameData,
399
406
  tags: block.tags
400
407
  // author tags (#215)
@@ -407,6 +414,8 @@ function compileScene(scene, foreign) {
407
414
  name: scene.name,
408
415
  ...scene.gameId ? { gameId: scene.gameId } : {},
409
416
  // host-facing address; runtime falls back to the name slug
417
+ padAfterDefault: scene.padAfterDefault,
418
+ // line padding: the default for the beats inside
410
419
  gameData: scene.gameData,
411
420
  tags: scene.tags,
412
421
  // author tags (#215)
@@ -446,6 +455,7 @@ function exportBundle(input) {
446
455
  const scenesOut = {};
447
456
  for (const scene of scenes) scenesOut[scene.id] = compileScene(scene, compileScopes);
448
457
  const externalScopes = externalScopesIn(scenesOut, /* @__PURE__ */ new Set([...import_dialect3.EXTERNAL_SCOPES, ...gameExternal.map((s) => s.token)]));
458
+ const qualifiers = (0, import_model2.usedQualifiers)(project, scenes).map((q) => ({ gameId: q.gameId, name: q.name }));
449
459
  const strings = {};
450
460
  for (const loc of locales) {
451
461
  if (includeLocales && !includeLocales.includes(loc.locale)) continue;
@@ -464,21 +474,26 @@ function exportBundle(input) {
464
474
  // Binds saves to the content they were taken against, and gates bundle
465
475
  // staleness (schema §10.5). A stable strict-JSON fingerprint - independent
466
476
  // 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).
477
+ // `scopeRegistry` and `qualifiers` are folded in only when present, so projects without them keep
478
+ // their exact prior hash (no ripple to existing bundles / the conformance corpus).
469
479
  hash: (0, import_core.hash32)((0, import_core.canonicalStringify)({
470
480
  scenes: scenesOut,
471
481
  strings,
472
482
  properties: project.properties ?? [],
473
- ...foreignScopes ? { scopeRegistry: foreignScopes } : {}
483
+ ...foreignScopes ? { scopeRegistry: foreignScopes } : {},
484
+ ...qualifiers.length > 0 ? { qualifiers } : {},
485
+ ...typeof project.padAfterDefault === "number" ? { padAfterDefault: project.padAfterDefault } : {}
474
486
  }, { trailingComma: false })),
475
487
  // Structure-only fingerprint (live bundle refresh): the same hash with the string tables left
476
488
  // out. Same structureHash + a different hash = a text-only edit, safe to swap in place with
477
489
  // `engine.replaceStrings()`; a changed structureHash needs the full save/load hot swap.
490
+ // A qualifier's name rides in `qualifiers`, not the string tables, so renaming one is a structure change.
478
491
  structureHash: (0, import_core.hash32)((0, import_core.canonicalStringify)({
479
492
  scenes: scenesOut,
480
493
  properties: project.properties ?? [],
481
- ...foreignScopes ? { scopeRegistry: foreignScopes } : {}
494
+ ...foreignScopes ? { scopeRegistry: foreignScopes } : {},
495
+ ...qualifiers.length > 0 ? { qualifiers } : {},
496
+ ...typeof project.padAfterDefault === "number" ? { padAfterDefault: project.padAfterDefault } : {}
482
497
  }, { trailingComma: false }))
483
498
  },
484
499
  voiced: project.voiced ?? false,
@@ -494,6 +509,9 @@ function exportBundle(input) {
494
509
  if (c.gameData !== void 0) m.gameData = c.gameData;
495
510
  return m;
496
511
  }),
512
+ ...qualifiers.length > 0 ? { qualifiers } : {},
513
+ // The project's own line-padding default, only when it sets one: absent, every runtime uses the built-in one.
514
+ ...typeof project.padAfterDefault === "number" ? { padAfterDefault: project.padAfterDefault } : {},
497
515
  properties: project.properties,
498
516
  scopeRegistry: hostScopes,
499
517
  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
  }
@@ -327,6 +328,8 @@ function compileNode(node, foreign) {
327
328
  shared: node.shared,
328
329
  options: node.options,
329
330
  children: node.children.map((c) => compileNode(c, foreign)),
331
+ padAfterDefault: node.padAfterDefault,
332
+ // line padding: the default for the beats inside
330
333
  gameData: node.gameData,
331
334
  tags: node.tags,
332
335
  // author tags (#215), accumulated at runtime
@@ -344,6 +347,8 @@ function compileNode(node, foreign) {
344
347
  beats: node.beats,
345
348
  onEnter: node.onEnter?.map((e) => compileEffect(e, foreign)),
346
349
  onExit: node.onExit?.map((e) => compileEffect(e, foreign)),
350
+ padAfterDefault: node.padAfterDefault,
351
+ // line padding: the default for the beats inside
347
352
  gameData: node.gameData,
348
353
  tags: node.tags,
349
354
  // author tags (#215)
@@ -361,6 +366,8 @@ function compileBlock(block, foreign) {
361
366
  ...block.gameId ? { gameId: block.gameId } : {},
362
367
  // host-facing address; runtime falls back to the name slug
363
368
  children: block.children.map((c) => compileNode(c, foreign)),
369
+ padAfterDefault: block.padAfterDefault,
370
+ // line padding: the default for the beats inside
364
371
  gameData: block.gameData,
365
372
  tags: block.tags
366
373
  // author tags (#215)
@@ -373,6 +380,8 @@ function compileScene(scene, foreign) {
373
380
  name: scene.name,
374
381
  ...scene.gameId ? { gameId: scene.gameId } : {},
375
382
  // host-facing address; runtime falls back to the name slug
383
+ padAfterDefault: scene.padAfterDefault,
384
+ // line padding: the default for the beats inside
376
385
  gameData: scene.gameData,
377
386
  tags: scene.tags,
378
387
  // author tags (#215)
@@ -412,6 +421,7 @@ function exportBundle(input) {
412
421
  const scenesOut = {};
413
422
  for (const scene of scenes) scenesOut[scene.id] = compileScene(scene, compileScopes);
414
423
  const externalScopes = externalScopesIn(scenesOut, /* @__PURE__ */ new Set([...EXTERNAL_SCOPES, ...gameExternal.map((s) => s.token)]));
424
+ const qualifiers = usedQualifiers(project, scenes).map((q) => ({ gameId: q.gameId, name: q.name }));
415
425
  const strings = {};
416
426
  for (const loc of locales) {
417
427
  if (includeLocales && !includeLocales.includes(loc.locale)) continue;
@@ -430,21 +440,26 @@ function exportBundle(input) {
430
440
  // Binds saves to the content they were taken against, and gates bundle
431
441
  // staleness (schema §10.5). A stable strict-JSON fingerprint - independent
432
442
  // 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).
443
+ // `scopeRegistry` and `qualifiers` are folded in only when present, so projects without them keep
444
+ // their exact prior hash (no ripple to existing bundles / the conformance corpus).
435
445
  hash: hash32(canonicalStringify({
436
446
  scenes: scenesOut,
437
447
  strings,
438
448
  properties: project.properties ?? [],
439
- ...foreignScopes ? { scopeRegistry: foreignScopes } : {}
449
+ ...foreignScopes ? { scopeRegistry: foreignScopes } : {},
450
+ ...qualifiers.length > 0 ? { qualifiers } : {},
451
+ ...typeof project.padAfterDefault === "number" ? { padAfterDefault: project.padAfterDefault } : {}
440
452
  }, { trailingComma: false })),
441
453
  // Structure-only fingerprint (live bundle refresh): the same hash with the string tables left
442
454
  // out. Same structureHash + a different hash = a text-only edit, safe to swap in place with
443
455
  // `engine.replaceStrings()`; a changed structureHash needs the full save/load hot swap.
456
+ // A qualifier's name rides in `qualifiers`, not the string tables, so renaming one is a structure change.
444
457
  structureHash: hash32(canonicalStringify({
445
458
  scenes: scenesOut,
446
459
  properties: project.properties ?? [],
447
- ...foreignScopes ? { scopeRegistry: foreignScopes } : {}
460
+ ...foreignScopes ? { scopeRegistry: foreignScopes } : {},
461
+ ...qualifiers.length > 0 ? { qualifiers } : {},
462
+ ...typeof project.padAfterDefault === "number" ? { padAfterDefault: project.padAfterDefault } : {}
448
463
  }, { trailingComma: false }))
449
464
  },
450
465
  voiced: project.voiced ?? false,
@@ -460,6 +475,9 @@ function exportBundle(input) {
460
475
  if (c.gameData !== void 0) m.gameData = c.gameData;
461
476
  return m;
462
477
  }),
478
+ ...qualifiers.length > 0 ? { qualifiers } : {},
479
+ // The project's own line-padding default, only when it sets one: absent, every runtime uses the built-in one.
480
+ ...typeof project.padAfterDefault === "number" ? { padAfterDefault: project.padAfterDefault } : {},
463
481
  properties: project.properties,
464
482
  scopeRegistry: hostScopes,
465
483
  gameDataFields: project.gameDataFields,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patterkit/compiler",
3
- "version": "0.4.7",
3
+ "version": "0.6.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.1",
39
- "@patterkit/dialect": "0.2.6",
37
+ "@patterkit/model": "0.12.0",
38
+ "@patterkit/core": "0.6.0",
39
+ "@patterkit/dialect": "0.2.8",
40
40
  "@wildwinter/expr": "^0.5.0"
41
41
  },
42
42
  "peerDependencies": {