@storylet-studio/runtime 0.2.0 → 0.3.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 +44 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -8
- package/dist/index.d.ts +4 -8
- package/dist/index.js +44 -17
- package/dist/index.js.map +1 -1
- package/dist/storyletengine.min.js +1 -1
- package/dist/storyletengine.min.js.map +1 -1
- package/package.json +7 -2
package/dist/index.cjs
CHANGED
|
@@ -453,8 +453,12 @@ var PropertyBag = class _PropertyBag {
|
|
|
453
453
|
* long-standing contract); a product whose names are case-significant
|
|
454
454
|
* passes identity. */
|
|
455
455
|
norm;
|
|
456
|
+
/** The address prefix this bag's rows carry, separator included (`@`,
|
|
457
|
+
* `@scene.`, `world.`, `deck.<id>.`). Empty means a row's path is its name. */
|
|
458
|
+
pathPrefix;
|
|
456
459
|
constructor(declarations = [], opts) {
|
|
457
460
|
this.norm = opts?.normalise ?? ((n) => n.toLowerCase());
|
|
461
|
+
this.pathPrefix = opts?.pathPrefix ?? "";
|
|
458
462
|
this.seed(declarations);
|
|
459
463
|
}
|
|
460
464
|
seed(declarations) {
|
|
@@ -498,7 +502,7 @@ var PropertyBag = class _PropertyBag {
|
|
|
498
502
|
/** Examiner rows: the declared surface only (stray values are storage,
|
|
499
503
|
* not surface). */
|
|
500
504
|
rows() {
|
|
501
|
-
return [...this.decls.entries()].map(([name, d]) => rowFor(d, this.get(name), void 0, name));
|
|
505
|
+
return [...this.decls.entries()].map(([name, d]) => rowFor(d, this.get(name), void 0, name, this.pathPrefix));
|
|
502
506
|
}
|
|
503
507
|
declarations() {
|
|
504
508
|
return [...this.decls.values()];
|
|
@@ -507,7 +511,7 @@ var PropertyBag = class _PropertyBag {
|
|
|
507
511
|
* duplicated, the normalisation policy carried, subscriptions NOT
|
|
508
512
|
* carried. */
|
|
509
513
|
clone() {
|
|
510
|
-
const c = new _PropertyBag([], { normalise: this.norm });
|
|
514
|
+
const c = new _PropertyBag([], { normalise: this.norm, pathPrefix: this.pathPrefix });
|
|
511
515
|
c.decls = new Map(this.decls);
|
|
512
516
|
Object.assign(c.values, structuredClone(this.values));
|
|
513
517
|
return c;
|
|
@@ -530,13 +534,19 @@ var PropertyBag = class _PropertyBag {
|
|
|
530
534
|
for (const [k, v] of Object.entries(values)) this.values[this.norm(k)] = v;
|
|
531
535
|
}
|
|
532
536
|
};
|
|
533
|
-
function rowFor(d, value, writable, name) {
|
|
537
|
+
function rowFor(d, value, writable, name, pathPrefix = "") {
|
|
538
|
+
const rowName = name ?? d.name.toLowerCase();
|
|
534
539
|
return {
|
|
535
|
-
name:
|
|
540
|
+
name: rowName,
|
|
541
|
+
path: pathPrefix + rowName,
|
|
536
542
|
type: d.type,
|
|
537
543
|
value,
|
|
538
544
|
default: d.default ?? defaultFor(d),
|
|
539
545
|
...d.values !== void 0 ? { values: d.values } : {},
|
|
546
|
+
// `stages` was added to the row so an examiner could offer a quality's ladder
|
|
547
|
+
// instead of a free-text box, and then never populated here: every quality row
|
|
548
|
+
// this function built came out without one. Fixed 2026-09-02.
|
|
549
|
+
...d.stages !== void 0 ? { stages: d.stages } : {},
|
|
540
550
|
writable: writable ?? d.writable ?? true
|
|
541
551
|
};
|
|
542
552
|
}
|
|
@@ -556,6 +566,13 @@ function defaultFor(d) {
|
|
|
556
566
|
// A quality starts at the first rung of its ladder.
|
|
557
567
|
case "quality":
|
|
558
568
|
return d.stages?.[0] ?? "";
|
|
569
|
+
// Unreachable for a well-typed declaration, and deliberately present anyway: a bundle
|
|
570
|
+
// is DATA, and a hand-edited or newer-than-this-build one can carry a type string the
|
|
571
|
+
// union does not have. Falling off the switch would seed `undefined`, which is not a
|
|
572
|
+
// ScalarValue and travels a long way before it fails. Patterplay's copy of this had the
|
|
573
|
+
// guard and this one did not, which is the drift you only find by removing a duplicate.
|
|
574
|
+
default:
|
|
575
|
+
return false;
|
|
559
576
|
}
|
|
560
577
|
}
|
|
561
578
|
|
|
@@ -563,7 +580,7 @@ function defaultFor(d) {
|
|
|
563
580
|
var tagKey = (groupId, tagId) => `${groupId}${tagId}`;
|
|
564
581
|
var cardIsShared = (card, deckShared) => card.shared ?? deckShared;
|
|
565
582
|
var sharedCap = (card) => card.sharedCopies ?? card.copies ?? 1;
|
|
566
|
-
var bagFromDecls = (decls) => new PropertyBag(decls, { normalise: (n) => n });
|
|
583
|
+
var bagFromDecls = (decls, pathPrefix) => new PropertyBag(decls, { normalise: (n) => n, pathPrefix });
|
|
567
584
|
function conditionPasses(v) {
|
|
568
585
|
if (typeof v === "boolean") return v;
|
|
569
586
|
if (typeof v === "number") return v !== 0;
|
|
@@ -583,18 +600,18 @@ var handDeclsOf = (internals, hand) => {
|
|
|
583
600
|
var buildPartition = (internals, half) => {
|
|
584
601
|
const b = internals.bundle;
|
|
585
602
|
return {
|
|
586
|
-
story: bagFromDecls(half("story", b.story.properties)),
|
|
587
|
-
box: new Map(b.boxes.map((box) => [box.id, bagFromDecls(half("box", box.properties))])),
|
|
603
|
+
story: bagFromDecls(half("story", b.story.properties), "story."),
|
|
604
|
+
box: new Map(b.boxes.map((box) => [box.id, bagFromDecls(half("box", box.properties), `box.${box.id}.`)])),
|
|
588
605
|
deck: new Map(b.boxes.flatMap((box) => box.decks.map(
|
|
589
|
-
(deck) => [deck.id, bagFromDecls(half("deck", deck.properties))]
|
|
606
|
+
(deck) => [deck.id, bagFromDecls(half("deck", deck.properties), `deck.${deck.id}.`)]
|
|
590
607
|
))),
|
|
591
608
|
// A template instance inherits the template's property declarations;
|
|
592
609
|
// a standalone hand declares its own (schema 2.6).
|
|
593
610
|
hand: new Map(b.boxes.flatMap((box) => box.hands.map(
|
|
594
|
-
(hand) => [hand.id, bagFromDecls(half("hand", handDeclsOf(internals, hand)))]
|
|
611
|
+
(hand) => [hand.id, bagFromDecls(half("hand", handDeclsOf(internals, hand)), `hand.${hand.id}.`)]
|
|
595
612
|
))),
|
|
596
613
|
value: new Map(b.boxes.flatMap((box) => box.tagGroups.flatMap((group) => group.tags.map(
|
|
597
|
-
(tag) => [tag.id, bagFromDecls(half("value", tag.properties ?? []))]
|
|
614
|
+
(tag) => [tag.id, bagFromDecls(half("value", tag.properties ?? []), `value.${tag.id}.`)]
|
|
598
615
|
))))
|
|
599
616
|
};
|
|
600
617
|
};
|
|
@@ -704,7 +721,7 @@ var Engine = class {
|
|
|
704
721
|
if (hostWorld !== void 0) {
|
|
705
722
|
internals.worldResolver = hostWorld;
|
|
706
723
|
} else {
|
|
707
|
-
const bag = bagFromDecls(internals.bundle.world.properties);
|
|
724
|
+
const bag = bagFromDecls(internals.bundle.world.properties, "world.");
|
|
708
725
|
internals.worldResolver = {
|
|
709
726
|
get: (n) => bag.get(n),
|
|
710
727
|
set: (n, v) => {
|
|
@@ -880,11 +897,16 @@ var Engine = class {
|
|
|
880
897
|
value: value ?? d.default,
|
|
881
898
|
default: d.default,
|
|
882
899
|
...d.values !== void 0 ? { values: d.values } : {},
|
|
883
|
-
...d.stages !== void 0 ? { stages: d.stages } : {}
|
|
900
|
+
...d.stages !== void 0 ? { stages: d.stages } : {},
|
|
901
|
+
// @world is FOREIGN - a host resolver backs it - so writability is whether that
|
|
902
|
+
// resolver can be written at all, which is the shared registry's own rule for a
|
|
903
|
+
// foreign scope. The `as PropertyView` cast this replaced was hiding the field's
|
|
904
|
+
// absence: the row type has always required it, and these rows shipped without one.
|
|
905
|
+
writable: this.internals.worldResolver.set !== void 0
|
|
884
906
|
});
|
|
885
907
|
}
|
|
886
|
-
const add = (
|
|
887
|
-
for (const row of bag.rows()) out.push(
|
|
908
|
+
const add = (_prefix, bag) => {
|
|
909
|
+
for (const row of bag.rows()) out.push(row);
|
|
888
910
|
};
|
|
889
911
|
add("story", this.internals.shared.story);
|
|
890
912
|
for (const [id, bag] of this.internals.shared.box) add(`box.${id}`, bag);
|
|
@@ -1776,13 +1798,18 @@ var Flow = class {
|
|
|
1776
1798
|
value: value ?? d.default,
|
|
1777
1799
|
default: d.default,
|
|
1778
1800
|
...d.values !== void 0 ? { values: d.values } : {},
|
|
1779
|
-
...d.stages !== void 0 ? { stages: d.stages } : {}
|
|
1801
|
+
...d.stages !== void 0 ? { stages: d.stages } : {},
|
|
1802
|
+
// @world is FOREIGN - a host resolver backs it - so writability is whether that
|
|
1803
|
+
// resolver can be written at all, which is the shared registry's own rule for a
|
|
1804
|
+
// foreign scope. The `as PropertyView` cast this replaced was hiding the field's
|
|
1805
|
+
// absence: the row type has always required it, and these rows shipped without one.
|
|
1806
|
+
writable: this.internals.worldResolver.set !== void 0
|
|
1780
1807
|
});
|
|
1781
1808
|
}
|
|
1782
|
-
const add = (
|
|
1809
|
+
const add = (_prefix, shared, own) => {
|
|
1783
1810
|
for (const bag of [shared, own]) {
|
|
1784
1811
|
if (bag === void 0) continue;
|
|
1785
|
-
for (const row of bag.rows()) out.push(
|
|
1812
|
+
for (const row of bag.rows()) out.push(row);
|
|
1786
1813
|
}
|
|
1787
1814
|
};
|
|
1788
1815
|
add("story", this.internals.shared.story, this.stores.story);
|