@storylet-studio/play-helpers 0.6.0 → 0.8.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 +13 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -11
- package/dist/index.d.ts +10 -11
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/storyletengine.min.js +4 -4
- package/dist/storyletengine.min.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -136,6 +136,13 @@ var PropertyBag = class _PropertyBag {
|
|
|
136
136
|
get(name) {
|
|
137
137
|
return this.values[this.norm(name)];
|
|
138
138
|
}
|
|
139
|
+
/** A name as this bag keys it: its normalisation policy applied. The registry
|
|
140
|
+
* uses it to key quality ladders and the validation schema the bag's own way,
|
|
141
|
+
* so a case-significant (identity) bag is not quietly folded to lower case
|
|
142
|
+
* one layer up. */
|
|
143
|
+
normalise(name) {
|
|
144
|
+
return this.norm(name);
|
|
145
|
+
}
|
|
139
146
|
/** Write a property. Engine writes (the default) notify subscribers;
|
|
140
147
|
* pass `silent: true` for a host write, which reaches only the audit
|
|
141
148
|
* hook. Throws on a read-only property unless the caller says it is the
|
|
@@ -277,7 +284,8 @@ function createStateLogger2(engine, flow, opts = {}) {
|
|
|
277
284
|
}
|
|
278
285
|
|
|
279
286
|
// ../model/src/index.ts
|
|
280
|
-
var SAVE_SCHEMA = "storylets/save@
|
|
287
|
+
var SAVE_SCHEMA = "storylets/save@2";
|
|
288
|
+
var SAVE_SCHEMA_V1 = "storylets/save@1";
|
|
281
289
|
var SAVEFILE_SCHEMA = "storylets/savefile@1";
|
|
282
290
|
|
|
283
291
|
// src/save.ts
|
|
@@ -292,7 +300,7 @@ function saveState(engine, world) {
|
|
|
292
300
|
};
|
|
293
301
|
}
|
|
294
302
|
function loadState(engine, file) {
|
|
295
|
-
if (!file || typeof file !== "object" || file.schema !== SAVEFILE_SCHEMA || file.engine?.schema !== SAVE_SCHEMA) {
|
|
303
|
+
if (!file || typeof file !== "object" || file.schema !== SAVEFILE_SCHEMA || file.engine?.schema !== SAVE_SCHEMA && file.engine?.schema !== SAVE_SCHEMA_V1) {
|
|
296
304
|
throw new Error(`not a storylets save (expected schema "${SAVEFILE_SCHEMA}")`);
|
|
297
305
|
}
|
|
298
306
|
engine.loadGame(file.engine);
|
|
@@ -376,8 +384,9 @@ function formatLogBody(e, flow) {
|
|
|
376
384
|
}
|
|
377
385
|
case "evict":
|
|
378
386
|
return `${stamp}evict ${e.card} from ${e.hand} (${e.reason})`;
|
|
387
|
+
// A card played with none ("") has no outcome to name.
|
|
379
388
|
case "play":
|
|
380
|
-
return `${stamp}play ${e.card} -> ${e.outcome}`;
|
|
389
|
+
return `${stamp}play ${e.card}${e.outcome === "" ? "" : ` -> ${e.outcome}`}`;
|
|
381
390
|
case "write":
|
|
382
391
|
return `${stamp}write ${e.path}: ${showVal(e.prev)} -> ${showVal(e.value)}`;
|
|
383
392
|
case "turns":
|
|
@@ -996,8 +1005,7 @@ function applyLiveBundle(engine, bundleJson, opts = {}) {
|
|
|
996
1005
|
return { ok: false, error: "pushed bundle is not valid JSON" };
|
|
997
1006
|
}
|
|
998
1007
|
try {
|
|
999
|
-
const next =
|
|
1000
|
-
next.loadGame(engine.saveGame());
|
|
1008
|
+
const { engine: next } = engine.hotSwap(bundle, opts);
|
|
1001
1009
|
return { ok: true, engine: next, bundle };
|
|
1002
1010
|
} catch (e) {
|
|
1003
1011
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|