@patterkit/runtime 0.5.0 → 0.5.1
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/CHANGELOG.md +17 -1
- package/dist/index.cjs +29 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +29 -3
- package/dist/index.js.map +1 -1
- package/dist/patterplay.min.js +2 -2
- package/dist/patterplay.min.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -236,6 +236,8 @@ interface PropertyRow {
|
|
|
236
236
|
value: ScalarValue | undefined;
|
|
237
237
|
default: ScalarValue;
|
|
238
238
|
values?: string[];
|
|
239
|
+
/** A quality's ordered stage ladder (lets an inspector offer stages instead of free text). */
|
|
240
|
+
stages?: string[];
|
|
239
241
|
}
|
|
240
242
|
/** Options for opening a flow. */
|
|
241
243
|
interface OpenFlowOptions {
|
|
@@ -533,6 +535,9 @@ declare class Flow {
|
|
|
533
535
|
private readonly sceneResolver;
|
|
534
536
|
private readonly evalCtx;
|
|
535
537
|
constructor(id: string, host: FlowHost, seed: number);
|
|
538
|
+
/** The stage ladder of `@scope.name` when it is a declared quality, else undefined. Names compare
|
|
539
|
+
* lowercase, as the compiler emits references (the selfBackedResolver lesson). */
|
|
540
|
+
private stagesFor;
|
|
536
541
|
/** Begin this flow at a scene (and optionally a specific block within it). */
|
|
537
542
|
start(sceneId?: string, blockId?: string): void;
|
|
538
543
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -236,6 +236,8 @@ interface PropertyRow {
|
|
|
236
236
|
value: ScalarValue | undefined;
|
|
237
237
|
default: ScalarValue;
|
|
238
238
|
values?: string[];
|
|
239
|
+
/** A quality's ordered stage ladder (lets an inspector offer stages instead of free text). */
|
|
240
|
+
stages?: string[];
|
|
239
241
|
}
|
|
240
242
|
/** Options for opening a flow. */
|
|
241
243
|
interface OpenFlowOptions {
|
|
@@ -533,6 +535,9 @@ declare class Flow {
|
|
|
533
535
|
private readonly sceneResolver;
|
|
534
536
|
private readonly evalCtx;
|
|
535
537
|
constructor(id: string, host: FlowHost, seed: number);
|
|
538
|
+
/** The stage ladder of `@scope.name` when it is a declared quality, else undefined. Names compare
|
|
539
|
+
* lowercase, as the compiler emits references (the selfBackedResolver lesson). */
|
|
540
|
+
private stagesFor;
|
|
536
541
|
/** Begin this flow at a scene (and optionally a specific block within it). */
|
|
537
542
|
start(sceneId?: string, blockId?: string): void;
|
|
538
543
|
/**
|
package/dist/index.js
CHANGED
|
@@ -493,6 +493,7 @@ var Engine = class _Engine {
|
|
|
493
493
|
ref: `@${d.name}`,
|
|
494
494
|
type: d.type,
|
|
495
495
|
values: d.values,
|
|
496
|
+
stages: d.stages,
|
|
496
497
|
value: this.getProperty(`@${d.name}`),
|
|
497
498
|
default: declDefault(d)
|
|
498
499
|
}));
|
|
@@ -625,9 +626,28 @@ var Flow = class {
|
|
|
625
626
|
nextRandom: this.rng,
|
|
626
627
|
visits: (id2) => this.visitCounts.get(id2) ?? 0,
|
|
627
628
|
patterVisits: (id2) => this.host.sharedVisits.get(id2) ?? 0
|
|
628
|
-
}
|
|
629
|
+
},
|
|
630
|
+
// The quality channel (expr 0.4.0): hands the evaluator a property's stage ladder, which is what
|
|
631
|
+
// makes ordering compare by position and advance() step. Wired by hand because this context takes
|
|
632
|
+
// only the registry's SCOPES (the patter/scene resolvers here are the flow's own merged views),
|
|
633
|
+
// and because @scene declarations belong to whichever scene the flow is in RIGHT NOW.
|
|
634
|
+
qualities: (scope, name) => this.stagesFor(scope, name)
|
|
629
635
|
};
|
|
630
636
|
}
|
|
637
|
+
/** The stage ladder of `@scope.name` when it is a declared quality, else undefined. Names compare
|
|
638
|
+
* lowercase, as the compiler emits references (the selfBackedResolver lesson). */
|
|
639
|
+
stagesFor(scope, name) {
|
|
640
|
+
const key = name.toLowerCase();
|
|
641
|
+
const fromDecls = (decls) => decls?.find((d) => d.name.toLowerCase() === key && d.type === "quality")?.stages;
|
|
642
|
+
if (scope === "patter") {
|
|
643
|
+
return fromDecls(this.host.patterSharedDecls) ?? fromDecls(this.host.patterLocalDecls);
|
|
644
|
+
}
|
|
645
|
+
if (scope === "scene") {
|
|
646
|
+
const scene = this.currentSceneId != null ? this.host.bundle.scenes[this.currentSceneId] : void 0;
|
|
647
|
+
return fromDecls(scene?.sceneProps);
|
|
648
|
+
}
|
|
649
|
+
return fromDecls(this.host.bundle.scopeRegistry?.scopes.find((s) => s.token === scope)?.declarations);
|
|
650
|
+
}
|
|
631
651
|
// -- Host API -------------------------------------------------------------
|
|
632
652
|
/** Begin this flow at a scene (and optionally a specific block within it). */
|
|
633
653
|
start(sceneId, blockId) {
|
|
@@ -1389,7 +1409,7 @@ function deserialiseSelectors(rec) {
|
|
|
1389
1409
|
return map;
|
|
1390
1410
|
}
|
|
1391
1411
|
function toDecl(decl) {
|
|
1392
|
-
return { name: decl.name, type: decl.type, values: decl.values, default: decl.default };
|
|
1412
|
+
return { name: decl.name, type: decl.type, values: decl.values, stages: decl.stages, default: decl.default };
|
|
1393
1413
|
}
|
|
1394
1414
|
function declDefault(d) {
|
|
1395
1415
|
if (d.default !== void 0) return d.default;
|
|
@@ -1402,12 +1422,14 @@ function declDefault(d) {
|
|
|
1402
1422
|
return [];
|
|
1403
1423
|
case "enum":
|
|
1404
1424
|
return d.values?.[0] ?? "";
|
|
1425
|
+
case "quality":
|
|
1426
|
+
return d.stages?.[0] ?? "";
|
|
1405
1427
|
default:
|
|
1406
1428
|
return false;
|
|
1407
1429
|
}
|
|
1408
1430
|
}
|
|
1409
1431
|
function toForeignDecl(decl) {
|
|
1410
|
-
return { name: decl.name, type: decl.type, values: decl.values, default: decl.default, writable: decl.writable };
|
|
1432
|
+
return { name: decl.name, type: decl.type, values: decl.values, stages: decl.stages, default: decl.default, writable: decl.writable };
|
|
1411
1433
|
}
|
|
1412
1434
|
function hostScopeDefault(decl) {
|
|
1413
1435
|
if (decl.default !== void 0) return decl.default;
|
|
@@ -1422,6 +1444,8 @@ function hostScopeDefault(decl) {
|
|
|
1422
1444
|
return [];
|
|
1423
1445
|
case "enum":
|
|
1424
1446
|
return decl.values?.[0] ?? "";
|
|
1447
|
+
case "quality":
|
|
1448
|
+
return decl.stages?.[0] ?? "";
|
|
1425
1449
|
}
|
|
1426
1450
|
}
|
|
1427
1451
|
function selfBackedResolver(decls) {
|
|
@@ -1448,6 +1472,8 @@ function sceneDefault(decl) {
|
|
|
1448
1472
|
return [];
|
|
1449
1473
|
case "enum":
|
|
1450
1474
|
return decl.values?.[0] ?? "";
|
|
1475
|
+
case "quality":
|
|
1476
|
+
return decl.stages?.[0] ?? "";
|
|
1451
1477
|
}
|
|
1452
1478
|
}
|
|
1453
1479
|
function truthy(v) {
|