@patterkit/runtime 0.25.0 → 0.26.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 +10 -0
- package/dist/index.cjs +31 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -33,6 +33,16 @@ version number always means the same runtime behaviour. This package is versione
|
|
|
33
33
|
|
|
34
34
|
## [Unreleased]
|
|
35
35
|
|
|
36
|
+
## [0.26.0] - 2026-10-14
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- **`flow.stepFor(beatId)`**: the step this flow would deliver for a beat right now, built by the same function
|
|
41
|
+
`advance` uses, so it carries the text in the active locale (interpolated, unless the project is voiced, with
|
|
42
|
+
closed captions applied) and the speaker's names and label, its pause, Game Data, and tags. It doesn't move the
|
|
43
|
+
flow, count a visit, or run an effect. Undefined for an id that is neither a beat nor an option's prompt. The
|
|
44
|
+
conformance corpus pins it on every runtime.
|
|
45
|
+
|
|
36
46
|
## [0.25.0] - 2026-10-14
|
|
37
47
|
|
|
38
48
|
### Added
|
package/dist/index.cjs
CHANGED
|
@@ -134,6 +134,25 @@ function padIndexFor(bundle) {
|
|
|
134
134
|
}
|
|
135
135
|
return index;
|
|
136
136
|
}
|
|
137
|
+
var beatIndexCache = /* @__PURE__ */ new WeakMap();
|
|
138
|
+
function beatIndexFor(bundle) {
|
|
139
|
+
let index = beatIndexCache.get(bundle);
|
|
140
|
+
if (index) return index;
|
|
141
|
+
index = /* @__PURE__ */ new Map();
|
|
142
|
+
for (const scene of Object.values(bundle.scenes)) {
|
|
143
|
+
for (const block of scene.blocks) {
|
|
144
|
+
(0, import_model2.walkNodes)(block.children, (n) => {
|
|
145
|
+
if (n.type === "group") {
|
|
146
|
+
if (n.prompt) index.set(n.prompt.id, n.prompt);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
for (const beat of n.beats ?? []) index.set(beat.id, beat);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
beatIndexCache.set(bundle, index);
|
|
154
|
+
return index;
|
|
155
|
+
}
|
|
137
156
|
function tagsOf(host, id) {
|
|
138
157
|
return host.tagIndex.get(id)?.slice();
|
|
139
158
|
}
|
|
@@ -1386,6 +1405,18 @@ var Flow = class {
|
|
|
1386
1405
|
getVisitCounts() {
|
|
1387
1406
|
return Object.fromEntries(this.visitCounts);
|
|
1388
1407
|
}
|
|
1408
|
+
/**
|
|
1409
|
+
* The step this flow would deliver for beat `beatId` right now, as `advance` would give it: its text in the
|
|
1410
|
+
* active locale, interpolated against this flow's values (unless the project is voiced), closed captions
|
|
1411
|
+
* applied, and the speaker's names and label, its pause, Game Data, and tags. Built by the same function that
|
|
1412
|
+
* builds a delivered step, so the two can't differ. It doesn't move the flow, count a visit, or run an effect.
|
|
1413
|
+
* Undefined for an id that is neither a beat nor an option's prompt. For a game that keeps lines by id and
|
|
1414
|
+
* shows them again (after a load, or a language switch).
|
|
1415
|
+
*/
|
|
1416
|
+
stepFor(beatId) {
|
|
1417
|
+
const beat = beatIndexFor(this.host.bundle).get(beatId);
|
|
1418
|
+
return beat ? this.beatResult(beat) : void 0;
|
|
1419
|
+
}
|
|
1389
1420
|
/** The options of a pending choice (empty when not at a choice point). */
|
|
1390
1421
|
getChoices() {
|
|
1391
1422
|
return this.pendingChoice?.options ?? [];
|