@storylet-studio/play-helpers 0.7.0 → 0.8.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/dist/index.cjs +11 -4
- 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 +12 -5
- 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);
|
|
@@ -997,8 +1005,7 @@ function applyLiveBundle(engine, bundleJson, opts = {}) {
|
|
|
997
1005
|
return { ok: false, error: "pushed bundle is not valid JSON" };
|
|
998
1006
|
}
|
|
999
1007
|
try {
|
|
1000
|
-
const next =
|
|
1001
|
-
next.loadGame(engine.saveGame());
|
|
1008
|
+
const { engine: next } = engine.hotSwap(bundle, opts);
|
|
1002
1009
|
return { ok: true, engine: next, bundle };
|
|
1003
1010
|
} catch (e) {
|
|
1004
1011
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|