@patterkit/runtime 0.12.0 → 0.13.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/CHANGELOG.md +23 -0
- package/dist/index.cjs +18 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -525,7 +525,13 @@ declare class Engine {
|
|
|
525
525
|
reset(): void;
|
|
526
526
|
/** Read a shared (`@patter` / foreign) property by ref. `@scene` refs are rejected (flow-level). */
|
|
527
527
|
getProperty(ref: string): ScalarValue | undefined;
|
|
528
|
-
/** Write a shared (`@patter` / foreign) property by ref. `@scene` refs are rejected (flow-level).
|
|
528
|
+
/** Write a shared (`@patter` / foreign) property by ref. `@scene` refs are rejected (flow-level).
|
|
529
|
+
*
|
|
530
|
+
* This is the GAME's surface, so it writes with host authority: a host-scope declaration's
|
|
531
|
+
* `writable: false` is the story's promise not to write the value, never a lock on the game that
|
|
532
|
+
* owns it. The story's own writes come through `Flow.runEffects`, which never claims it. (Ruled
|
|
533
|
+
* across the family 2026-09-05, after a Storylets venue clock and this project's coverage driver
|
|
534
|
+
* were each refused the one property they existed to move.) */
|
|
529
535
|
setProperty(ref: string, value: ScalarValue): void;
|
|
530
536
|
/** The shared `@patter` properties, for a live state inspector: each with its ref, type, current
|
|
531
537
|
* value, declared default (for reset), and enum options. Mirrors the Unity / Godot ports. */
|
|
@@ -668,8 +674,13 @@ declare class Flow {
|
|
|
668
674
|
isEnded(): boolean;
|
|
669
675
|
/** Read a property by ref - `@patter` / `@scene` (each routed by its `shared` flag) or foreign. */
|
|
670
676
|
getProperty(ref: string): ScalarValue | undefined;
|
|
671
|
-
/** Write a property by ref (routed by scope, then by the property's `shared` flag).
|
|
677
|
+
/** Write a property by ref (routed by scope, then by the property's `shared` flag). The GAME's
|
|
678
|
+
* surface: it writes with host authority, so a `writable: false` host declaration does not refuse
|
|
679
|
+
* it (see `Engine.setProperty`). The story's writes go through `writeProperty` instead. */
|
|
672
680
|
setProperty(ref: string, value: ScalarValue): void;
|
|
681
|
+
/** The write itself. `host` says WHO is writing, which is the only thing `writable: false` cares
|
|
682
|
+
* about: the story is refused, the game is not. */
|
|
683
|
+
private writeProperty;
|
|
673
684
|
/** @internal Snapshot this flow's cursor + per-flow scopes (not-shared `@patter`/`@scene`) + PRNG. */
|
|
674
685
|
snapshot(): FlowSnapshot;
|
|
675
686
|
/** @internal Restore this flow from a snapshot. */
|
package/dist/index.d.ts
CHANGED
|
@@ -525,7 +525,13 @@ declare class Engine {
|
|
|
525
525
|
reset(): void;
|
|
526
526
|
/** Read a shared (`@patter` / foreign) property by ref. `@scene` refs are rejected (flow-level). */
|
|
527
527
|
getProperty(ref: string): ScalarValue | undefined;
|
|
528
|
-
/** Write a shared (`@patter` / foreign) property by ref. `@scene` refs are rejected (flow-level).
|
|
528
|
+
/** Write a shared (`@patter` / foreign) property by ref. `@scene` refs are rejected (flow-level).
|
|
529
|
+
*
|
|
530
|
+
* This is the GAME's surface, so it writes with host authority: a host-scope declaration's
|
|
531
|
+
* `writable: false` is the story's promise not to write the value, never a lock on the game that
|
|
532
|
+
* owns it. The story's own writes come through `Flow.runEffects`, which never claims it. (Ruled
|
|
533
|
+
* across the family 2026-09-05, after a Storylets venue clock and this project's coverage driver
|
|
534
|
+
* were each refused the one property they existed to move.) */
|
|
529
535
|
setProperty(ref: string, value: ScalarValue): void;
|
|
530
536
|
/** The shared `@patter` properties, for a live state inspector: each with its ref, type, current
|
|
531
537
|
* value, declared default (for reset), and enum options. Mirrors the Unity / Godot ports. */
|
|
@@ -668,8 +674,13 @@ declare class Flow {
|
|
|
668
674
|
isEnded(): boolean;
|
|
669
675
|
/** Read a property by ref - `@patter` / `@scene` (each routed by its `shared` flag) or foreign. */
|
|
670
676
|
getProperty(ref: string): ScalarValue | undefined;
|
|
671
|
-
/** Write a property by ref (routed by scope, then by the property's `shared` flag).
|
|
677
|
+
/** Write a property by ref (routed by scope, then by the property's `shared` flag). The GAME's
|
|
678
|
+
* surface: it writes with host authority, so a `writable: false` host declaration does not refuse
|
|
679
|
+
* it (see `Engine.setProperty`). The story's writes go through `writeProperty` instead. */
|
|
672
680
|
setProperty(ref: string, value: ScalarValue): void;
|
|
681
|
+
/** The write itself. `host` says WHO is writing, which is the only thing `writable: false` cares
|
|
682
|
+
* about: the story is refused, the game is not. */
|
|
683
|
+
private writeProperty;
|
|
673
684
|
/** @internal Snapshot this flow's cursor + per-flow scopes (not-shared `@patter`/`@scene`) + PRNG. */
|
|
674
685
|
snapshot(): FlowSnapshot;
|
|
675
686
|
/** @internal Restore this flow from a snapshot. */
|
package/dist/index.js
CHANGED
|
@@ -504,10 +504,16 @@ var Engine = class _Engine {
|
|
|
504
504
|
const { scope, name } = this.splitShared(ref);
|
|
505
505
|
return this.host.shared.get(scope, name);
|
|
506
506
|
}
|
|
507
|
-
/** Write a shared (`@patter` / foreign) property by ref. `@scene` refs are rejected (flow-level).
|
|
507
|
+
/** Write a shared (`@patter` / foreign) property by ref. `@scene` refs are rejected (flow-level).
|
|
508
|
+
*
|
|
509
|
+
* This is the GAME's surface, so it writes with host authority: a host-scope declaration's
|
|
510
|
+
* `writable: false` is the story's promise not to write the value, never a lock on the game that
|
|
511
|
+
* owns it. The story's own writes come through `Flow.runEffects`, which never claims it. (Ruled
|
|
512
|
+
* across the family 2026-09-05, after a Storylets venue clock and this project's coverage driver
|
|
513
|
+
* were each refused the one property they existed to move.) */
|
|
508
514
|
setProperty(ref, value) {
|
|
509
515
|
const { scope, name } = this.splitShared(ref);
|
|
510
|
-
this.host.shared.set(scope, name, value);
|
|
516
|
+
this.host.shared.set(scope, name, value, { host: true });
|
|
511
517
|
}
|
|
512
518
|
/** The shared `@patter` properties, for a live state inspector: each with its ref, type, current
|
|
513
519
|
* value, declared default (for reset), and enum options. Mirrors the Unity / Godot ports. */
|
|
@@ -974,8 +980,15 @@ var Flow = class {
|
|
|
974
980
|
if (scope === "scene") return this.sceneResolver.get(name);
|
|
975
981
|
return this.host.shared.get(scope, name);
|
|
976
982
|
}
|
|
977
|
-
/** Write a property by ref (routed by scope, then by the property's `shared` flag).
|
|
983
|
+
/** Write a property by ref (routed by scope, then by the property's `shared` flag). The GAME's
|
|
984
|
+
* surface: it writes with host authority, so a `writable: false` host declaration does not refuse
|
|
985
|
+
* it (see `Engine.setProperty`). The story's writes go through `writeProperty` instead. */
|
|
978
986
|
setProperty(ref, value) {
|
|
987
|
+
this.writeProperty(ref, value, true);
|
|
988
|
+
}
|
|
989
|
+
/** The write itself. `host` says WHO is writing, which is the only thing `writable: false` cares
|
|
990
|
+
* about: the story is refused, the game is not. */
|
|
991
|
+
writeProperty(ref, value, host) {
|
|
979
992
|
const { scope, name } = this.splitRef(ref);
|
|
980
993
|
if (scope === "patter") {
|
|
981
994
|
this.patterResolver.set(name, value);
|
|
@@ -983,7 +996,7 @@ var Flow = class {
|
|
|
983
996
|
if (this.currentSceneId === null) throw new Error(`'${ref}': the flow has not entered a scene yet`);
|
|
984
997
|
this.sceneResolver.set(name, value);
|
|
985
998
|
} else {
|
|
986
|
-
this.host.shared.set(scope, name, value);
|
|
999
|
+
this.host.shared.set(scope, name, value, host ? { host: true } : void 0);
|
|
987
1000
|
}
|
|
988
1001
|
}
|
|
989
1002
|
// -- Save / restore (engine-driven) --------------------------------------
|
|
@@ -1327,7 +1340,7 @@ var Flow = class {
|
|
|
1327
1340
|
for (const e of effects ?? []) {
|
|
1328
1341
|
const value = this.evalExpr(e.value);
|
|
1329
1342
|
const prev = this.host.logEnabled ? this.getProperty(e.target) : void 0;
|
|
1330
|
-
this.
|
|
1343
|
+
this.writeProperty(e.target, value, false);
|
|
1331
1344
|
this.emit({ type: "write", target: e.target, value, ...prev !== void 0 ? { prev } : {} });
|
|
1332
1345
|
}
|
|
1333
1346
|
}
|