@rohal12/spindle 0.64.22 → 0.64.24
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/pkg/format.js +1 -1
- package/dist/pkg/headless.js +166 -72
- package/package.json +1 -1
- package/src/components/Passage.tsx +103 -55
- package/src/components/macros/Computed.tsx +8 -3
- package/src/components/macros/Goto.tsx +5 -0
- package/src/components/macros/Include.tsx +6 -2
- package/src/components/macros/MacroError.tsx +7 -2
- package/src/components/macros/PassageDisplay.tsx +31 -15
- package/src/components/macros/SaveManager.tsx +79 -3
- package/src/hooks/use-story-fields.ts +13 -0
- package/src/styles.css +19 -0
package/dist/pkg/headless.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, createContext, createPortal, h, render } from "preact";
|
|
2
2
|
import { useCallback, useContext, useEffect, useErrorBoundary, useId, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
3
|
-
import { useSyncExternalStore } from "preact/compat";
|
|
3
|
+
import { memo, useSyncExternalStore } from "preact/compat";
|
|
4
4
|
import { createStore } from "zustand/vanilla";
|
|
5
5
|
import { immer } from "zustand/middleware/immer";
|
|
6
6
|
import { Immer, current, enableMapSet, enablePatches, freeze, isDraft, original } from "immer";
|
|
@@ -13633,17 +13633,17 @@ function lenientClose(input, i, onRunOut) {
|
|
|
13633
13633
|
function lenientRead(input, i) {
|
|
13634
13634
|
if (memoInput !== input) {
|
|
13635
13635
|
memoInput = input;
|
|
13636
|
-
memo.clear();
|
|
13636
|
+
memo$1.clear();
|
|
13637
13637
|
}
|
|
13638
|
-
let read = memo.get(i);
|
|
13638
|
+
let read = memo$1.get(i);
|
|
13639
13639
|
if (read === void 0) {
|
|
13640
13640
|
read = scanLenient(input, i);
|
|
13641
|
-
memo.set(i, read);
|
|
13641
|
+
memo$1.set(i, read);
|
|
13642
13642
|
}
|
|
13643
13643
|
return read;
|
|
13644
13644
|
}
|
|
13645
13645
|
var memoInput = "";
|
|
13646
|
-
var memo = /* @__PURE__ */ new Map();
|
|
13646
|
+
var memo$1 = /* @__PURE__ */ new Map();
|
|
13647
13647
|
function scanLenient(input, start) {
|
|
13648
13648
|
const codeFrame = (start) => ({
|
|
13649
13649
|
kind: "code",
|
|
@@ -13663,7 +13663,7 @@ function scanLenient(input, start) {
|
|
|
13663
13663
|
end,
|
|
13664
13664
|
ranOut
|
|
13665
13665
|
};
|
|
13666
|
-
if (frame.kind === "code") memo.set(frame.start, result);
|
|
13666
|
+
if (frame.kind === "code") memo$1.set(frame.start, result);
|
|
13667
13667
|
const parent = frames[frames.length - 1];
|
|
13668
13668
|
if (!parent) return;
|
|
13669
13669
|
parent.ranOut ||= ranOut;
|
|
@@ -13684,7 +13684,7 @@ function scanLenient(input, start) {
|
|
|
13684
13684
|
else if (c === frame.quote) finish(i + 1, ranOut);
|
|
13685
13685
|
else if (frame.quote !== "`" && c === "\n") finish(-1, ranOut);
|
|
13686
13686
|
else if (frame.quote === "`" && c === "$" && input[i + 1] === "{") {
|
|
13687
|
-
const cached = memo.get(i + 2);
|
|
13687
|
+
const cached = memo$1.get(i + 2);
|
|
13688
13688
|
if (cached) {
|
|
13689
13689
|
frame.ranOut ||= cached.ranOut;
|
|
13690
13690
|
frame.i = cached.end === -1 ? input.length : cached.end + 1;
|
|
@@ -15648,6 +15648,18 @@ var PendingIterationContext = createContext(null);
|
|
|
15648
15648
|
*/
|
|
15649
15649
|
var OutgoingContext = createContext(null);
|
|
15650
15650
|
/**
|
|
15651
|
+
* Tells the macros that run code as they mount ({set}, {do}, {unset},
|
|
15652
|
+
* {goto}, {computed}, the count of an {include}) whether they come too late: the
|
|
15653
|
+
* passage they belong to was on the page and has been left since. State
|
|
15654
|
+
* that changed before the navigation can still render new content into the
|
|
15655
|
+
* passage on its way out, and its code would run against the destination's
|
|
15656
|
+
* state (#352, as #410 for timers). The macros that mount while the passage
|
|
15657
|
+
* is first rendered are never late, whatever that render navigates. Null
|
|
15658
|
+
* outside a displayed passage, and in a click body, which renders apart
|
|
15659
|
+
* from the passage and runs as part of the click.
|
|
15660
|
+
*/
|
|
15661
|
+
var LateMountContext = createContext(null);
|
|
15662
|
+
/**
|
|
15651
15663
|
* Story state fields `keys`, re-rendering when any of them changes (as one
|
|
15652
15664
|
* useStoryStore() selector per field would). The result keeps its identity
|
|
15653
15665
|
* while the fields don't change, as the store's snapshot must.
|
|
@@ -16120,14 +16132,17 @@ function logMacroError(label, error, location = currentSourceLocation()) {
|
|
|
16120
16132
|
console.error(`spindle: Error in {${label}}${location}:`, error);
|
|
16121
16133
|
}
|
|
16122
16134
|
/**
|
|
16123
|
-
* Run `effect` once, during the macro's first render
|
|
16135
|
+
* Run `effect` once, during the macro's first render, unless that is in a
|
|
16136
|
+
* passage already left (see LateMountContext). If it throws, the
|
|
16124
16137
|
* error is logged under `{macro rawArgs}` and shown in place of the macro
|
|
16125
16138
|
* from then on; otherwise the macro renders nothing.
|
|
16126
16139
|
*/
|
|
16127
16140
|
function useRunOnce(macro, rawArgs, effect) {
|
|
16128
16141
|
const failure = useRef(void 0);
|
|
16142
|
+
const lateMount = useContext(LateMountContext);
|
|
16129
16143
|
if (failure.current === void 0) {
|
|
16130
16144
|
failure.current = null;
|
|
16145
|
+
if (lateMount?.()) return null;
|
|
16131
16146
|
const location = currentSourceLocation();
|
|
16132
16147
|
try {
|
|
16133
16148
|
effect();
|
|
@@ -23669,19 +23684,58 @@ function renderPassageContent(passage) {
|
|
|
23669
23684
|
return renderNodes(parsePassage(passage), passage.tags.includes("nobr") ? { nobr: true } : void 0);
|
|
23670
23685
|
}
|
|
23671
23686
|
/**
|
|
23672
|
-
*
|
|
23673
|
-
*
|
|
23674
|
-
*
|
|
23687
|
+
* A passage's rendered content, drawn again only when the passage or its
|
|
23688
|
+
* text changes (the props are compared shallowly, so a parent re-rendering
|
|
23689
|
+
* with the same passage skips it).
|
|
23690
|
+
*
|
|
23691
|
+
* It is a component and not a vnode kept by `useMemo`. A kept vnode that is
|
|
23692
|
+
* placed again carries Preact's links (its parent, its rendered children) to
|
|
23693
|
+
* the tree it was first placed in. A navigation's tree reaches the kept vnode
|
|
23694
|
+
* of the passage on its way out, so every tree held the one before it and
|
|
23695
|
+
* none was ever freed. The `content` prop is only here so that an edit of
|
|
23696
|
+
* the passage text in place draws it again.
|
|
23697
|
+
*/
|
|
23698
|
+
var PassageBody = memo(function PassageBody({ passage }) {
|
|
23699
|
+
try {
|
|
23700
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: renderPassageContent(passage) });
|
|
23701
|
+
} catch (err) {
|
|
23702
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
23703
|
+
class: "error",
|
|
23704
|
+
children: [
|
|
23705
|
+
"Error parsing passage “",
|
|
23706
|
+
passage.name,
|
|
23707
|
+
"”",
|
|
23708
|
+
sourceLocationOf(passage),
|
|
23709
|
+
": ",
|
|
23710
|
+
errorMessage(err)
|
|
23711
|
+
]
|
|
23712
|
+
});
|
|
23713
|
+
}
|
|
23714
|
+
});
|
|
23715
|
+
/**
|
|
23716
|
+
* A special passage shown with every passage (PassageHeader, PassageFooter,
|
|
23717
|
+
* PassageDone), in its wrapper; nothing if it has no content. One that fails
|
|
23718
|
+
* to render is logged and left out, so it can't take the passage down with
|
|
23719
|
+
* it. Memoized like PassageBody.
|
|
23675
23720
|
*/
|
|
23676
|
-
function
|
|
23677
|
-
|
|
23721
|
+
var SpecialPassage = memo(function SpecialPassage({ passage, kind }) {
|
|
23722
|
+
let content;
|
|
23678
23723
|
try {
|
|
23679
|
-
|
|
23724
|
+
content = renderPassageContent(passage);
|
|
23680
23725
|
} catch (err) {
|
|
23681
23726
|
console.error(`spindle: Error in ${passage.name}:`, err);
|
|
23682
23727
|
return null;
|
|
23683
23728
|
}
|
|
23684
|
-
|
|
23729
|
+
if (!content) return null;
|
|
23730
|
+
if (kind === "done") return /* @__PURE__ */ jsx(EntryRenderBoundary, { children: /* @__PURE__ */ jsx("div", {
|
|
23731
|
+
hidden: true,
|
|
23732
|
+
children: content
|
|
23733
|
+
}) });
|
|
23734
|
+
return /* @__PURE__ */ jsx("div", {
|
|
23735
|
+
class: `passage-${kind}`,
|
|
23736
|
+
children: content
|
|
23737
|
+
});
|
|
23738
|
+
});
|
|
23685
23739
|
var CODE_PASSAGES = /* @__PURE__ */ new Set([
|
|
23686
23740
|
"PassageReady",
|
|
23687
23741
|
"PassageHeader",
|
|
@@ -23703,34 +23757,20 @@ function Passage({ passage, dataTransition, navigationId }) {
|
|
|
23703
23757
|
const { storyData } = useStoryFields("storyData");
|
|
23704
23758
|
const isCodePassage = CODE_PASSAGES.has(passage.name);
|
|
23705
23759
|
const [doneReady, setDoneReady] = useState(false);
|
|
23706
|
-
const content = useMemo(() => {
|
|
23707
|
-
try {
|
|
23708
|
-
return renderPassageContent(passage);
|
|
23709
|
-
} catch (err) {
|
|
23710
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
23711
|
-
class: "error",
|
|
23712
|
-
children: [
|
|
23713
|
-
"Error parsing passage “",
|
|
23714
|
-
passage.name,
|
|
23715
|
-
"”",
|
|
23716
|
-
sourceLocationOf(passage),
|
|
23717
|
-
": ",
|
|
23718
|
-
errorMessage(err)
|
|
23719
|
-
]
|
|
23720
|
-
});
|
|
23721
|
-
}
|
|
23722
|
-
}, [passage.content, passage.name]);
|
|
23723
23760
|
const special = (name) => isCodePassage ? void 0 : storyData?.passages.get(name);
|
|
23724
|
-
const
|
|
23725
|
-
|
|
23761
|
+
const specialPassage = (name, kind) => {
|
|
23762
|
+
const found = special(name);
|
|
23763
|
+
return found ? /* @__PURE__ */ jsx(SpecialPassage, {
|
|
23764
|
+
passage: found,
|
|
23765
|
+
content: found.content,
|
|
23766
|
+
kind
|
|
23767
|
+
}) : null;
|
|
23768
|
+
};
|
|
23726
23769
|
const donePassage = special("PassageDone");
|
|
23727
|
-
const headerContent = useMemo(() => renderSpecialPassage(headerPassage), [headerPassage?.content]);
|
|
23728
|
-
const footerContent = useMemo(() => renderSpecialPassage(footerPassage), [footerPassage?.content]);
|
|
23729
23770
|
useEffect(() => {
|
|
23730
23771
|
if (donePassage) setDoneReady(true);
|
|
23731
23772
|
return () => setDoneReady(false);
|
|
23732
23773
|
}, [passage.name]);
|
|
23733
|
-
const doneContent = useMemo(() => doneReady ? renderSpecialPassage(donePassage) : null, [doneReady, donePassage?.content]);
|
|
23734
23774
|
const elRef = useRef(null);
|
|
23735
23775
|
useLayoutEffect(() => {
|
|
23736
23776
|
if (navigationId !== void 0) markPassageRendered(navigationId);
|
|
@@ -23741,33 +23781,36 @@ function Passage({ passage, dataTransition, navigationId }) {
|
|
|
23741
23781
|
else emit();
|
|
23742
23782
|
}
|
|
23743
23783
|
}, [passage.name, navigationId]);
|
|
23784
|
+
const hasLeft = useContext(OutgoingContext);
|
|
23785
|
+
const committed = useRef(false);
|
|
23786
|
+
useLayoutEffect(() => {
|
|
23787
|
+
committed.current = true;
|
|
23788
|
+
}, []);
|
|
23789
|
+
const lateMount = useCallback(() => committed.current && !!hasLeft?.(), [hasLeft]);
|
|
23744
23790
|
const nobr = passage.tags.includes("nobr");
|
|
23745
23791
|
const viewScope = useViewScope();
|
|
23746
23792
|
const inner = /* @__PURE__ */ jsx(InterfaceContext.Provider, {
|
|
23747
23793
|
value: false,
|
|
23748
23794
|
children: /* @__PURE__ */ jsx(ViewScopeContext.Provider, {
|
|
23749
23795
|
value: viewScope,
|
|
23750
|
-
children: /* @__PURE__ */
|
|
23751
|
-
|
|
23752
|
-
|
|
23753
|
-
|
|
23754
|
-
|
|
23755
|
-
|
|
23756
|
-
|
|
23757
|
-
|
|
23758
|
-
|
|
23759
|
-
|
|
23760
|
-
|
|
23761
|
-
|
|
23762
|
-
|
|
23763
|
-
|
|
23764
|
-
|
|
23765
|
-
|
|
23766
|
-
|
|
23767
|
-
|
|
23768
|
-
children: doneContent
|
|
23769
|
-
}) })
|
|
23770
|
-
]
|
|
23796
|
+
children: /* @__PURE__ */ jsx(LateMountContext.Provider, {
|
|
23797
|
+
value: lateMount,
|
|
23798
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
23799
|
+
ref: elRef,
|
|
23800
|
+
class: "passage",
|
|
23801
|
+
"data-passage": passage.name,
|
|
23802
|
+
"data-tags": passage.tags.join(" "),
|
|
23803
|
+
"data-transition": dataTransition,
|
|
23804
|
+
children: [
|
|
23805
|
+
specialPassage("PassageHeader", "header"),
|
|
23806
|
+
/* @__PURE__ */ jsx(PassageBody, {
|
|
23807
|
+
passage,
|
|
23808
|
+
content: passage.content
|
|
23809
|
+
}),
|
|
23810
|
+
specialPassage("PassageFooter", "footer"),
|
|
23811
|
+
doneReady && specialPassage("PassageDone", "done")
|
|
23812
|
+
]
|
|
23813
|
+
})
|
|
23771
23814
|
})
|
|
23772
23815
|
})
|
|
23773
23816
|
});
|
|
@@ -24325,7 +24368,7 @@ defineMacro({
|
|
|
24325
24368
|
const displayedId = displayed.id;
|
|
24326
24369
|
const isOutgoing = useCallback((state) => state.navigationId !== displayedId, [displayedId]);
|
|
24327
24370
|
const hasLeft = useCallback(() => isOutgoing(useStoryStore.getState()), [isOutgoing]);
|
|
24328
|
-
const
|
|
24371
|
+
const lastShown = useRef(null);
|
|
24329
24372
|
const containerRef = useRef(null);
|
|
24330
24373
|
const timeoutsRef = useRef([]);
|
|
24331
24374
|
const scrollAfterCleanup = useRef(false);
|
|
@@ -24433,12 +24476,16 @@ defineMacro({
|
|
|
24433
24476
|
]
|
|
24434
24477
|
});
|
|
24435
24478
|
const readyPassage = storyData?.passages.get("PassageReady");
|
|
24436
|
-
const
|
|
24437
|
-
|
|
24438
|
-
|
|
24439
|
-
|
|
24440
|
-
|
|
24441
|
-
|
|
24479
|
+
const shown = !renderDeferred && displayed.id !== navigationId && lastShown.current ? lastShown.current : effectivePassage ? {
|
|
24480
|
+
key: renderDeferred ? "loading" : `nav-${displayed.id}`,
|
|
24481
|
+
props: {
|
|
24482
|
+
passage: effectivePassage,
|
|
24483
|
+
dataTransition: renderDeferred ? "none" : resolvedTypeRef.current,
|
|
24484
|
+
navigationId: renderDeferred ? void 0 : displayed.id
|
|
24485
|
+
}
|
|
24486
|
+
} : null;
|
|
24487
|
+
const passageElement = shown && /* @__PURE__ */ jsx(Passage, { ...shown.props }, shown.key);
|
|
24488
|
+
lastShown.current = shown;
|
|
24442
24489
|
return /* @__PURE__ */ jsxs("div", {
|
|
24443
24490
|
id: ctx.id ?? "story",
|
|
24444
24491
|
class: ctx.className ?? "story",
|
|
@@ -24590,16 +24637,17 @@ defineMacro({
|
|
|
24590
24637
|
const name = target.slice(1);
|
|
24591
24638
|
const localsUpdate = isLocal ? ctx.update : null;
|
|
24592
24639
|
const pendingIteration = ctx.hooks.useContext(PendingIterationContext);
|
|
24640
|
+
const tooLate = ctx.hooks.useContext(LateMountContext)?.() ?? false;
|
|
24593
24641
|
const prevOutput = ctx.hooks.useRef(UNSET);
|
|
24594
24642
|
const lastNavigation = ctx.hooks.useRef(-1);
|
|
24595
24643
|
const compute = () => computeAndApply(expr, name, isTemp, isLocal, ctx.getValues, rawArgs, prevOutput, lastNavigation, localsUpdate);
|
|
24596
24644
|
const ran = ctx.hooks.useRef(false);
|
|
24597
24645
|
if (!ran.current) {
|
|
24598
24646
|
ran.current = true;
|
|
24599
|
-
compute();
|
|
24647
|
+
if (!tooLate) compute();
|
|
24600
24648
|
}
|
|
24601
24649
|
ctx.hooks.useLayoutEffect(() => {
|
|
24602
|
-
if (!pendingIteration?.(useStoryStore.getState())) compute();
|
|
24650
|
+
if (!tooLate && !pendingIteration?.(useStoryStore.getState())) compute();
|
|
24603
24651
|
}, [ctx.merged, pendingIteration]);
|
|
24604
24652
|
return null;
|
|
24605
24653
|
}
|
|
@@ -25537,6 +25585,10 @@ defineMacro({
|
|
|
25537
25585
|
}
|
|
25538
25586
|
});
|
|
25539
25587
|
// src/components/macros/SaveManager.tsx
|
|
25588
|
+
/** How long a Delete button stays armed without a second press. */
|
|
25589
|
+
var ARMED_DELETE_MS = 5e3;
|
|
25590
|
+
var ARMED_DELETE_LABEL = "Press again to delete";
|
|
25591
|
+
var ARMED_DELETE_HINT = "Press again to delete this save";
|
|
25540
25592
|
function relativeTime(iso) {
|
|
25541
25593
|
const diff = Date.now() - new Date(iso).getTime();
|
|
25542
25594
|
const secs = Math.floor(diff / 1e3);
|
|
@@ -25563,6 +25615,7 @@ function SaveManagerContent({ className, id }) {
|
|
|
25563
25615
|
const [status, setStatus] = useState(null);
|
|
25564
25616
|
const [collapsed, setCollapsed] = useState(() => /* @__PURE__ */ new Set());
|
|
25565
25617
|
const [renamingId, setRenamingId] = useState(null);
|
|
25618
|
+
const [armedId, setArmedId] = useState(null);
|
|
25566
25619
|
const renameCancelled = useRef(false);
|
|
25567
25620
|
const [renameValue, setRenameValue] = useState("");
|
|
25568
25621
|
const renameInputRef = useRef(null);
|
|
@@ -25608,6 +25661,29 @@ function SaveManagerContent({ className, id }) {
|
|
|
25608
25661
|
clearTimeout(closeTimer.current);
|
|
25609
25662
|
};
|
|
25610
25663
|
}, []);
|
|
25664
|
+
useEffect(() => {
|
|
25665
|
+
if (armedId === null) return;
|
|
25666
|
+
const disarm = () => setArmedId(null);
|
|
25667
|
+
const onArmedButton = (e) => e.target instanceof Element && !!e.target.closest("[data-armed]");
|
|
25668
|
+
const onPointerDown = (e) => {
|
|
25669
|
+
if (!onArmedButton(e)) disarm();
|
|
25670
|
+
};
|
|
25671
|
+
const onKeyDown = (e) => {
|
|
25672
|
+
if (e.key === "Escape") {
|
|
25673
|
+
e.preventDefault();
|
|
25674
|
+
e.stopPropagation();
|
|
25675
|
+
disarm();
|
|
25676
|
+
} else if (!onArmedButton(e)) disarm();
|
|
25677
|
+
};
|
|
25678
|
+
const timer = window.setTimeout(disarm, ARMED_DELETE_MS);
|
|
25679
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
25680
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
25681
|
+
return () => {
|
|
25682
|
+
clearTimeout(timer);
|
|
25683
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
25684
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
25685
|
+
};
|
|
25686
|
+
}, [armedId]);
|
|
25611
25687
|
const toggleCollapse = (id) => {
|
|
25612
25688
|
setCollapsed((prev) => {
|
|
25613
25689
|
const next = new Set(prev);
|
|
@@ -25667,8 +25743,13 @@ function SaveManagerContent({ className, id }) {
|
|
|
25667
25743
|
showStatus(failed, "error");
|
|
25668
25744
|
}
|
|
25669
25745
|
};
|
|
25746
|
+
/** The first press arms the button; a second press on it deletes. */
|
|
25670
25747
|
const handleDelete = async (saveId) => {
|
|
25671
|
-
if (
|
|
25748
|
+
if (armedId !== saveId) {
|
|
25749
|
+
setArmedId(saveId);
|
|
25750
|
+
return;
|
|
25751
|
+
}
|
|
25752
|
+
setArmedId(null);
|
|
25672
25753
|
await runAction("Save deleted", "Failed to delete save", async () => {
|
|
25673
25754
|
await deleteSaveById(saveId);
|
|
25674
25755
|
const known = await populateKnownSaves(ifid);
|
|
@@ -25865,9 +25946,13 @@ function SaveManagerContent({ className, id }) {
|
|
|
25865
25946
|
}),
|
|
25866
25947
|
/* @__PURE__ */ jsx("button", {
|
|
25867
25948
|
type: "button",
|
|
25868
|
-
class: "save-slot-action danger",
|
|
25949
|
+
class: armedId === save.meta.id ? "save-slot-action danger is-armed" : "save-slot-action danger",
|
|
25950
|
+
"data-armed": armedId === save.meta.id ? "true" : void 0,
|
|
25951
|
+
"aria-label": armedId === save.meta.id ? ARMED_DELETE_HINT : void 0,
|
|
25952
|
+
title: armedId === save.meta.id ? ARMED_DELETE_HINT : void 0,
|
|
25869
25953
|
onClick: () => handleDelete(save.meta.id),
|
|
25870
|
-
|
|
25954
|
+
onBlur: () => setArmedId((id) => id === save.meta.id ? null : id),
|
|
25955
|
+
children: armedId === save.meta.id ? ARMED_DELETE_LABEL : "Delete"
|
|
25871
25956
|
})
|
|
25872
25957
|
]
|
|
25873
25958
|
})]
|
|
@@ -25892,6 +25977,12 @@ function SaveManagerContent({ className, id }) {
|
|
|
25892
25977
|
})
|
|
25893
25978
|
})]
|
|
25894
25979
|
}),
|
|
25980
|
+
/* @__PURE__ */ jsx("div", {
|
|
25981
|
+
class: "saves-sr-only",
|
|
25982
|
+
role: "status",
|
|
25983
|
+
"aria-live": "polite",
|
|
25984
|
+
children: armedId !== null ? ARMED_DELETE_HINT : ""
|
|
25985
|
+
}),
|
|
25895
25986
|
status && /* @__PURE__ */ jsx("div", {
|
|
25896
25987
|
class: `saves-status ${status.type === "error" ? "error" : ""}`,
|
|
25897
25988
|
children: status.text
|
|
@@ -26007,6 +26098,7 @@ defineMacro({
|
|
|
26007
26098
|
parameters: INCLUDE_PARAMETERS,
|
|
26008
26099
|
render(_props, ctx) {
|
|
26009
26100
|
const displayOnly = ctx.hooks.useContext(DisplayOnlyContext);
|
|
26101
|
+
const tooLate = ctx.hooks.useContext(LateMountContext)?.() ?? false;
|
|
26010
26102
|
const { storyData } = useStoryFields("storyData");
|
|
26011
26103
|
const { inline } = ctx.args;
|
|
26012
26104
|
let passageName = "";
|
|
@@ -26020,7 +26112,7 @@ defineMacro({
|
|
|
26020
26112
|
const ast = ctx.hooks.useMemo(() => passage ? parseMarkup(passage.content) : null, [passage]);
|
|
26021
26113
|
const included = !failure && !!passage;
|
|
26022
26114
|
ctx.hooks.useEffect(() => {
|
|
26023
|
-
if (included && !displayOnly) useStoryStore.getState().trackRender(passageName);
|
|
26115
|
+
if (included && !displayOnly && !tooLate) useStoryStore.getState().trackRender(passageName);
|
|
26024
26116
|
}, [
|
|
26025
26117
|
included,
|
|
26026
26118
|
passageName,
|
|
@@ -26059,7 +26151,9 @@ defineMacro({
|
|
|
26059
26151
|
}],
|
|
26060
26152
|
render(_props, ctx) {
|
|
26061
26153
|
const [failure, setFailure] = ctx.hooks.useState();
|
|
26154
|
+
const tooLate = ctx.hooks.useContext(LateMountContext)?.() ?? false;
|
|
26062
26155
|
ctx.hooks.useLayoutEffect(() => {
|
|
26156
|
+
if (tooLate) return;
|
|
26063
26157
|
const location = ctx.sourceLocation();
|
|
26064
26158
|
try {
|
|
26065
26159
|
const store = useStoryStore.getState();
|
|
@@ -26358,7 +26452,7 @@ defineMacro({
|
|
|
26358
26452
|
}
|
|
26359
26453
|
});
|
|
26360
26454
|
// src/styles.css?inline
|
|
26361
|
-
var styles_default = "*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\nhtml {\n font-size: 16px;\n -webkit-text-size-adjust: 100%;\n}\n\nbody {\n margin: 0;\n padding: 0;\n font-family: Georgia, 'Times New Roman', serif;\n line-height: 1.75;\n color: #e0e0e0;\n background-color: #1a1a2e;\n min-height: 100vh;\n}\n\ntw-storydata {\n display: none !important;\n}\n\n#story {\n max-width: 42em;\n margin: 0 auto;\n padding: 2em 1.5em;\n}\n\n/* Passage transitions */\n\n.passage-container {\n position: relative;\n}\n\n.passage-container--crossfading {\n display: grid;\n}\n\n.passage-container--crossfading > * {\n grid-area: 1 / 1;\n}\n\n.passage {\n animation: passage-fade-in var(--passage-in-duration, 0.3s) ease;\n}\n\n.passage[data-transition='none'] {\n animation: none;\n}\n\n.passage-snapshot {\n animation: passage-fade-out var(--passage-out-duration, 0.3s) ease forwards;\n pointer-events: none;\n user-select: none;\n}\n\n@keyframes passage-fade-in {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes passage-fade-out {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(-8px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .passage,\n .passage-snapshot {\n animation-duration: 0.01s !important;\n }\n}\n\n.macro-button {\n background: rgba(100, 181, 246, 0.15);\n color: #64b5f6;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 4px;\n padding: 0.25em 0.75em;\n font: inherit;\n font-size: 0.95em;\n cursor: pointer;\n transition:\n background 0.2s,\n border-color 0.2s;\n}\n\n.macro-button:hover {\n background: rgba(100, 181, 246, 0.25);\n border-color: #90caf9;\n}\n\n.macro-button:active {\n background: rgba(100, 181, 246, 0.35);\n}\n\n.error {\n color: #ef5350;\n font-family: monospace;\n padding: 1em;\n border: 1px solid #ef5350;\n border-radius: 4px;\n background: rgba(239, 83, 80, 0.1);\n}\n\n/* Runtime errors shown on the page (see src/components/RuntimeErrors.tsx) */\n.spindle-error-banners {\n position: fixed;\n top: 0.75em;\n left: 50%;\n z-index: 300;\n display: flex;\n flex-direction: column;\n gap: 0.5em;\n width: min(42em, calc(100% - 1.5em));\n transform: translateX(-50%);\n}\n\n.spindle-error-banner {\n position: relative;\n padding: 0.75em 2.75em 0.75em 1em;\n border: 1px solid #ef5350;\n border-radius: 4px;\n background: #2b1a1e;\n color: #ffcdd2;\n font-size: 0.9em;\n line-height: 1.5;\n box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);\n}\n\n.spindle-error-banner-message {\n font-family: monospace;\n color: #ef9a9a;\n}\n\n.spindle-error-banner-dismiss {\n position: absolute;\n top: 0.5em;\n right: 0.5em;\n background: transparent;\n border: none;\n color: inherit;\n font-size: 1em;\n cursor: pointer;\n}\n\n.spindle-error-banner-dismiss:hover {\n color: #fff;\n}\n\n.loading {\n text-align: center;\n padding: 2em;\n opacity: 0.6;\n}\n\n/* Menu bar */\n\n.story-menubar {\n position: sticky;\n top: 0;\n z-index: 100;\n display: flex;\n align-items: center;\n gap: 0.5em;\n padding: 0.5em 1.5em;\n background: #16213e;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n font-family: system-ui, sans-serif;\n font-size: 0.9em;\n}\n\n@media (max-width: 600px) {\n .story-menubar {\n flex-wrap: wrap;\n padding: 0.5em 0.75em;\n }\n\n .story-menubar .story-title {\n flex: 1 1 100%;\n }\n}\n\n.story-title {\n flex: 1;\n font-weight: 600;\n color: #e0e0e0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.menubar-button {\n background: transparent;\n color: #9e9e9e;\n border: 1px solid transparent;\n padding: 0.35em 0.7em;\n border-radius: 4px;\n cursor: pointer;\n font: inherit;\n transition:\n color 0.2s,\n background 0.2s;\n}\n\n.menubar-button:hover {\n color: #e0e0e0;\n background: rgba(255, 255, 255, 0.08);\n}\n\n.menubar-button:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.menubar-button:disabled:hover {\n color: #9e9e9e;\n background: transparent;\n}\n\n/* Generic dialog */\n\n.dialog-overlay {\n position: fixed;\n inset: 0;\n z-index: 200;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(0, 0, 0, 0.6);\n}\n\n.dialog-panel {\n background: #16213e;\n border: 1px solid rgba(255, 255, 255, 0.1);\n border-radius: 8px;\n width: 90%;\n max-width: 500px;\n max-height: 80vh;\n display: flex;\n flex-direction: column;\n color: #e0e0e0;\n font-family: system-ui, sans-serif;\n position: relative;\n}\n\n/* Focused programmatically when the dialog has no focusable content */\n.dialog-panel:focus {\n outline: none;\n}\n\n.dialog-saves {\n max-width: 550px;\n}\n\n.dialog-settings {\n max-width: 400px;\n}\n\n/* Keep the first control clear of the close button above it */\n.dialog-settings .dialog-body {\n padding-top: 2.25em;\n}\n\n.dialog-close {\n position: absolute;\n top: 0.75em;\n right: 0.75em;\n z-index: 1;\n background: transparent;\n border: none;\n color: #9e9e9e;\n font-size: 1.1em;\n cursor: pointer;\n padding: 0.25em;\n line-height: 1;\n}\n\n.dialog-close:hover {\n color: #e0e0e0;\n}\n\n.dialog-body {\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n\n/* Settings controls */\n\n.settings-controls {\n padding: 1em 1.25em;\n display: flex;\n flex-direction: column;\n gap: 1em;\n}\n\n.settings-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 1em;\n}\n\n.settings-item {\n display: flex;\n flex-direction: column;\n gap: 0.25em;\n}\n\n.settings-description {\n margin: 0;\n font-size: 0.85em;\n color: #9e9e9e;\n}\n\n.settings-row select,\n.settings-row input[type='range'] {\n accent-color: #64b5f6;\n}\n\n.settings-row select {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n.settings-row input[type='checkbox'] {\n accent-color: #64b5f6;\n width: 1.1em;\n height: 1.1em;\n}\n\n/* Save manager */\n\n.save-manager {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n}\n\n.saves-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 1em 1.25em;\n padding-right: 3em;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n font-weight: 600;\n flex-shrink: 0;\n}\n\n.saves-header-left {\n display: flex;\n align-items: center;\n gap: 0.75em;\n}\n\n.saves-mode-toggle {\n display: flex;\n gap: 0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n overflow: hidden;\n}\n\n.saves-mode-toggle button {\n background: transparent;\n color: #9e9e9e;\n border: none;\n padding: 0.3em 0.8em;\n font: inherit;\n font-size: 0.85em;\n font-weight: 600;\n cursor: pointer;\n transition:\n background 0.2s,\n color 0.2s;\n}\n\n.saves-mode-toggle button.active {\n background: rgba(100, 181, 246, 0.2);\n color: #64b5f6;\n}\n\n.saves-mode-toggle button:hover:not(.active) {\n color: #e0e0e0;\n}\n\n.saves-body {\n padding: 0.75em 1.25em;\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n\n.saves-empty {\n text-align: center;\n padding: 2em 1em;\n opacity: 0.5;\n font-size: 0.9em;\n}\n\n.saves-toolbar {\n display: flex;\n gap: 0.5em;\n padding: 0.5em 1.25em;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n flex-shrink: 0;\n}\n\n.saves-toolbar-button {\n background: rgba(255, 255, 255, 0.05);\n color: #9e9e9e;\n border: 1px solid rgba(255, 255, 255, 0.1);\n border-radius: 4px;\n padding: 0.3em 0.7em;\n font: inherit;\n font-size: 0.8em;\n cursor: pointer;\n transition:\n background 0.2s,\n color 0.2s;\n}\n\n.saves-toolbar-button:hover {\n background: rgba(255, 255, 255, 0.1);\n color: #e0e0e0;\n}\n\n.playthrough-group {\n margin-bottom: 0.75em;\n}\n\n.playthrough-header {\n display: flex;\n width: 100%;\n border: 0;\n background: none;\n font-family: inherit;\n text-align: left;\n align-items: center;\n gap: 0.5em;\n padding: 0.4em 0;\n cursor: pointer;\n user-select: none;\n font-size: 0.85em;\n color: #9e9e9e;\n transition: color 0.2s;\n}\n\n.playthrough-header:hover {\n color: #e0e0e0;\n}\n\n.playthrough-chevron {\n display: inline-block;\n font-size: 0.7em;\n transition: transform 0.2s;\n}\n\n.playthrough-chevron.open {\n transform: rotate(90deg);\n}\n\n.playthrough-label {\n font-weight: 600;\n}\n\n.playthrough-date {\n opacity: 0.6;\n font-size: 0.9em;\n}\n\n.playthrough-saves {\n display: flex;\n flex-direction: column;\n gap: 0.4em;\n padding-left: 0.25em;\n}\n\n.save-slot {\n display: flex;\n align-items: center;\n gap: 0.75em;\n padding: 0.5em 0.6em;\n background: rgba(255, 255, 255, 0.03);\n border: 1px solid rgba(255, 255, 255, 0.06);\n border-radius: 6px;\n transition: background 0.15s;\n}\n\n.save-slot:hover {\n background: rgba(255, 255, 255, 0.06);\n}\n\n.save-slot-info {\n flex: 1;\n min-width: 0;\n}\n\n.save-slot-title {\n font-weight: 500;\n font-size: 0.9em;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.save-slot-meta {\n font-size: 0.75em;\n color: #9e9e9e;\n display: flex;\n gap: 0.75em;\n}\n\n.save-slot-actions {\n display: flex;\n gap: 0.3em;\n flex-shrink: 0;\n}\n\n.save-slot-action {\n background: transparent;\n color: #9e9e9e;\n border: 1px solid transparent;\n border-radius: 3px;\n padding: 0.2em 0.5em;\n font: inherit;\n font-size: 0.75em;\n cursor: pointer;\n transition:\n color 0.2s,\n background 0.2s;\n white-space: nowrap;\n}\n\n.save-slot-action:hover {\n color: #e0e0e0;\n background: rgba(255, 255, 255, 0.08);\n}\n\n.save-slot-action.primary {\n color: #64b5f6;\n border-color: rgba(100, 181, 246, 0.3);\n}\n\n.save-slot-action.primary:hover {\n background: rgba(100, 181, 246, 0.15);\n}\n\n.save-slot-action.danger:hover {\n color: #ef5350;\n background: rgba(239, 83, 80, 0.1);\n}\n\n.save-slot-new {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0.5em;\n margin-top: 0.25em;\n border: 1px dashed rgba(255, 255, 255, 0.12);\n border-radius: 6px;\n color: #9e9e9e;\n font: inherit;\n font-size: 0.8em;\n background: transparent;\n cursor: pointer;\n width: 100%;\n transition:\n color 0.2s,\n border-color 0.2s,\n background 0.2s;\n}\n\n.save-slot-new:hover {\n color: #64b5f6;\n border-color: rgba(100, 181, 246, 0.3);\n background: rgba(100, 181, 246, 0.05);\n}\n\n.saves-notice {\n padding: 0.5em 1.25em;\n font-size: 0.8em;\n color: #ffb74d;\n border-bottom: 1px solid rgba(255, 183, 77, 0.3);\n background: rgba(255, 183, 77, 0.08);\n flex-shrink: 0;\n}\n\n.saves-status {\n padding: 0.5em 1.25em;\n font-size: 0.8em;\n color: #81c784;\n border-top: 1px solid rgba(255, 255, 255, 0.08);\n flex-shrink: 0;\n text-align: center;\n}\n\n.saves-status.error {\n color: #ef5350;\n border: none;\n border-radius: 0;\n padding: 0.5em 1.25em;\n font-family: inherit;\n background: transparent;\n}\n\n.save-rename-input {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 3px;\n padding: 0.15em 0.4em;\n font: inherit;\n font-size: 0.9em;\n width: 100%;\n}\n\n.save-rename-input:focus {\n outline: none;\n border-color: #64b5f6;\n}\n\n/* Macro: link */\n\n.macro-link {\n color: #64b5f6;\n text-decoration: none;\n border-bottom: 1px solid rgba(100, 181, 246, 0.3);\n transition:\n color 0.2s,\n border-color 0.2s;\n cursor: pointer;\n}\n\n.macro-link:hover {\n color: #90caf9;\n border-bottom-color: #90caf9;\n}\n\n.macro-link:active {\n color: #42a5f5;\n}\n\n/* Macro: form inputs */\n\n.macro-textbox,\n.macro-numberbox,\n.macro-textarea {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n.macro-textbox:focus,\n.macro-numberbox:focus,\n.macro-textarea:focus {\n outline: none;\n border-color: #64b5f6;\n}\n\n.macro-textarea {\n min-height: 3em;\n resize: vertical;\n}\n\n.macro-checkbox,\n.macro-radiobutton {\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 0.3em;\n}\n\n.macro-checkbox input,\n.macro-radiobutton input {\n accent-color: #64b5f6;\n}\n\n/* Macro: listbox */\n\n.macro-listbox {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n/* Macro: cycle */\n\n.macro-cycle {\n background: rgba(100, 181, 246, 0.15);\n color: #64b5f6;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 4px;\n padding: 0.25em 0.75em;\n font: inherit;\n cursor: pointer;\n transition:\n background 0.2s,\n border-color 0.2s;\n}\n\n.macro-cycle:hover {\n background: rgba(100, 181, 246, 0.25);\n border-color: #90caf9;\n}\n\n/* Macro: meter */\n\n.macro-meter {\n position: relative;\n width: 100%;\n height: 1.4em;\n background: #2a2a3e;\n border-radius: 0.3em;\n overflow: hidden;\n border: 1px solid #444;\n}\n\n.macro-meter-fill {\n height: 100%;\n background: #64b5f6;\n transition: width 0.3s ease;\n}\n\n.macro-meter-label {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 0.85em;\n color: #e0e0e0;\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);\n pointer-events: none;\n}\n\n/* Markdown wrapper — invisible to layout */\n\n.md {\n display: contents;\n}\n\n/* Markdown block elements inside passages */\n\n.passage p {\n margin: 0.6em 0;\n}\n\n.passage p:first-child {\n margin-top: 0;\n}\n\n.passage p:last-child {\n margin-bottom: 0;\n}\n\n.passage h1,\n.passage h2,\n.passage h3,\n.passage h4,\n.passage h5,\n.passage h6 {\n margin: 1em 0 0.4em;\n line-height: 1.3;\n color: #f0f0f0;\n}\n\n.passage h1 {\n font-size: 1.8em;\n}\n.passage h2 {\n font-size: 1.5em;\n}\n.passage h3 {\n font-size: 1.25em;\n}\n.passage h4 {\n font-size: 1.1em;\n}\n.passage h5 {\n font-size: 1em;\n}\n.passage h6 {\n font-size: 0.9em;\n opacity: 0.8;\n}\n\n.passage code {\n font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;\n font-size: 0.9em;\n background: rgba(255, 255, 255, 0.08);\n padding: 0.15em 0.35em;\n border-radius: 3px;\n}\n\n.passage pre {\n background: rgba(0, 0, 0, 0.3);\n border: 1px solid rgba(255, 255, 255, 0.08);\n border-radius: 6px;\n padding: 1em;\n overflow-x: auto;\n margin: 0.8em 0;\n}\n\n.passage pre code {\n background: none;\n padding: 0;\n border-radius: 0;\n font-size: 0.85em;\n}\n\n.passage blockquote {\n border-left: 3px solid rgba(100, 181, 246, 0.5);\n margin: 0.8em 0;\n padding: 0.4em 1em;\n color: #b0b0b0;\n}\n\n.passage blockquote p {\n margin: 0.3em 0;\n}\n\n.passage ul,\n.passage ol {\n margin: 0.6em 0;\n padding-left: 1.8em;\n}\n\n.passage li {\n margin: 0.2em 0;\n}\n\n.passage hr {\n border: none;\n border-top: 1px solid rgba(255, 255, 255, 0.12);\n margin: 1.2em 0;\n}\n\n.passage table {\n border-collapse: collapse;\n width: 100%;\n margin: 0.8em 0;\n}\n\n.passage th,\n.passage td {\n border: 1px solid rgba(255, 255, 255, 0.12);\n padding: 0.5em 0.75em;\n text-align: left;\n}\n\n.passage th {\n background: rgba(255, 255, 255, 0.06);\n font-weight: 600;\n}\n\n.passage tr:nth-child(even) {\n background: rgba(255, 255, 255, 0.02);\n}\n\n.passage del {\n opacity: 0.5;\n}\n\n.passage strong {\n color: #f0f0f0;\n}\n\n/* Macro: type (typewriter) */\n\n.macro-type-cursor::after {\n content: '\\2588';\n animation: type-blink 0.7s step-end infinite;\n color: #64b5f6;\n}\n\n.macro-type-done .macro-type-cursor::after {\n display: none;\n}\n\n@keyframes type-blink {\n 50% {\n opacity: 0;\n }\n}\n";
|
|
26455
|
+
var styles_default = "*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\nhtml {\n font-size: 16px;\n -webkit-text-size-adjust: 100%;\n}\n\nbody {\n margin: 0;\n padding: 0;\n font-family: Georgia, 'Times New Roman', serif;\n line-height: 1.75;\n color: #e0e0e0;\n background-color: #1a1a2e;\n min-height: 100vh;\n}\n\ntw-storydata {\n display: none !important;\n}\n\n#story {\n max-width: 42em;\n margin: 0 auto;\n padding: 2em 1.5em;\n}\n\n/* Passage transitions */\n\n.passage-container {\n position: relative;\n}\n\n.passage-container--crossfading {\n display: grid;\n}\n\n.passage-container--crossfading > * {\n grid-area: 1 / 1;\n}\n\n.passage {\n animation: passage-fade-in var(--passage-in-duration, 0.3s) ease;\n}\n\n.passage[data-transition='none'] {\n animation: none;\n}\n\n.passage-snapshot {\n animation: passage-fade-out var(--passage-out-duration, 0.3s) ease forwards;\n pointer-events: none;\n user-select: none;\n}\n\n@keyframes passage-fade-in {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes passage-fade-out {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(-8px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .passage,\n .passage-snapshot {\n animation-duration: 0.01s !important;\n }\n}\n\n.macro-button {\n background: rgba(100, 181, 246, 0.15);\n color: #64b5f6;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 4px;\n padding: 0.25em 0.75em;\n font: inherit;\n font-size: 0.95em;\n cursor: pointer;\n transition:\n background 0.2s,\n border-color 0.2s;\n}\n\n.macro-button:hover {\n background: rgba(100, 181, 246, 0.25);\n border-color: #90caf9;\n}\n\n.macro-button:active {\n background: rgba(100, 181, 246, 0.35);\n}\n\n.error {\n color: #ef5350;\n font-family: monospace;\n padding: 1em;\n border: 1px solid #ef5350;\n border-radius: 4px;\n background: rgba(239, 83, 80, 0.1);\n}\n\n/* Runtime errors shown on the page (see src/components/RuntimeErrors.tsx) */\n.spindle-error-banners {\n position: fixed;\n top: 0.75em;\n left: 50%;\n z-index: 300;\n display: flex;\n flex-direction: column;\n gap: 0.5em;\n width: min(42em, calc(100% - 1.5em));\n transform: translateX(-50%);\n}\n\n.spindle-error-banner {\n position: relative;\n padding: 0.75em 2.75em 0.75em 1em;\n border: 1px solid #ef5350;\n border-radius: 4px;\n background: #2b1a1e;\n color: #ffcdd2;\n font-size: 0.9em;\n line-height: 1.5;\n box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);\n}\n\n.spindle-error-banner-message {\n font-family: monospace;\n color: #ef9a9a;\n}\n\n.spindle-error-banner-dismiss {\n position: absolute;\n top: 0.5em;\n right: 0.5em;\n background: transparent;\n border: none;\n color: inherit;\n font-size: 1em;\n cursor: pointer;\n}\n\n.spindle-error-banner-dismiss:hover {\n color: #fff;\n}\n\n.loading {\n text-align: center;\n padding: 2em;\n opacity: 0.6;\n}\n\n/* Menu bar */\n\n.story-menubar {\n position: sticky;\n top: 0;\n z-index: 100;\n display: flex;\n align-items: center;\n gap: 0.5em;\n padding: 0.5em 1.5em;\n background: #16213e;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n font-family: system-ui, sans-serif;\n font-size: 0.9em;\n}\n\n@media (max-width: 600px) {\n .story-menubar {\n flex-wrap: wrap;\n padding: 0.5em 0.75em;\n }\n\n .story-menubar .story-title {\n flex: 1 1 100%;\n }\n}\n\n.story-title {\n flex: 1;\n font-weight: 600;\n color: #e0e0e0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.menubar-button {\n background: transparent;\n color: #9e9e9e;\n border: 1px solid transparent;\n padding: 0.35em 0.7em;\n border-radius: 4px;\n cursor: pointer;\n font: inherit;\n transition:\n color 0.2s,\n background 0.2s;\n}\n\n.menubar-button:hover {\n color: #e0e0e0;\n background: rgba(255, 255, 255, 0.08);\n}\n\n.menubar-button:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.menubar-button:disabled:hover {\n color: #9e9e9e;\n background: transparent;\n}\n\n/* Generic dialog */\n\n.dialog-overlay {\n position: fixed;\n inset: 0;\n z-index: 200;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(0, 0, 0, 0.6);\n}\n\n.dialog-panel {\n background: #16213e;\n border: 1px solid rgba(255, 255, 255, 0.1);\n border-radius: 8px;\n width: 90%;\n max-width: 500px;\n max-height: 80vh;\n display: flex;\n flex-direction: column;\n color: #e0e0e0;\n font-family: system-ui, sans-serif;\n position: relative;\n}\n\n/* Focused programmatically when the dialog has no focusable content */\n.dialog-panel:focus {\n outline: none;\n}\n\n.dialog-saves {\n max-width: 550px;\n}\n\n.dialog-settings {\n max-width: 400px;\n}\n\n/* Keep the first control clear of the close button above it */\n.dialog-settings .dialog-body {\n padding-top: 2.25em;\n}\n\n.dialog-close {\n position: absolute;\n top: 0.75em;\n right: 0.75em;\n z-index: 1;\n background: transparent;\n border: none;\n color: #9e9e9e;\n font-size: 1.1em;\n cursor: pointer;\n padding: 0.25em;\n line-height: 1;\n}\n\n.dialog-close:hover {\n color: #e0e0e0;\n}\n\n.dialog-body {\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n\n/* Settings controls */\n\n.settings-controls {\n padding: 1em 1.25em;\n display: flex;\n flex-direction: column;\n gap: 1em;\n}\n\n.settings-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 1em;\n}\n\n.settings-item {\n display: flex;\n flex-direction: column;\n gap: 0.25em;\n}\n\n.settings-description {\n margin: 0;\n font-size: 0.85em;\n color: #9e9e9e;\n}\n\n.settings-row select,\n.settings-row input[type='range'] {\n accent-color: #64b5f6;\n}\n\n.settings-row select {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n.settings-row input[type='checkbox'] {\n accent-color: #64b5f6;\n width: 1.1em;\n height: 1.1em;\n}\n\n/* Save manager */\n\n.save-manager {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n}\n\n.saves-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 1em 1.25em;\n padding-right: 3em;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n font-weight: 600;\n flex-shrink: 0;\n}\n\n.saves-header-left {\n display: flex;\n align-items: center;\n gap: 0.75em;\n}\n\n.saves-mode-toggle {\n display: flex;\n gap: 0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n overflow: hidden;\n}\n\n.saves-mode-toggle button {\n background: transparent;\n color: #9e9e9e;\n border: none;\n padding: 0.3em 0.8em;\n font: inherit;\n font-size: 0.85em;\n font-weight: 600;\n cursor: pointer;\n transition:\n background 0.2s,\n color 0.2s;\n}\n\n.saves-mode-toggle button.active {\n background: rgba(100, 181, 246, 0.2);\n color: #64b5f6;\n}\n\n.saves-mode-toggle button:hover:not(.active) {\n color: #e0e0e0;\n}\n\n.saves-body {\n padding: 0.75em 1.25em;\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n\n.saves-empty {\n text-align: center;\n padding: 2em 1em;\n opacity: 0.5;\n font-size: 0.9em;\n}\n\n.saves-toolbar {\n display: flex;\n gap: 0.5em;\n padding: 0.5em 1.25em;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n flex-shrink: 0;\n}\n\n.saves-toolbar-button {\n background: rgba(255, 255, 255, 0.05);\n color: #9e9e9e;\n border: 1px solid rgba(255, 255, 255, 0.1);\n border-radius: 4px;\n padding: 0.3em 0.7em;\n font: inherit;\n font-size: 0.8em;\n cursor: pointer;\n transition:\n background 0.2s,\n color 0.2s;\n}\n\n.saves-toolbar-button:hover {\n background: rgba(255, 255, 255, 0.1);\n color: #e0e0e0;\n}\n\n.playthrough-group {\n margin-bottom: 0.75em;\n}\n\n.playthrough-header {\n display: flex;\n width: 100%;\n border: 0;\n background: none;\n font-family: inherit;\n text-align: left;\n align-items: center;\n gap: 0.5em;\n padding: 0.4em 0;\n cursor: pointer;\n user-select: none;\n font-size: 0.85em;\n color: #9e9e9e;\n transition: color 0.2s;\n}\n\n.playthrough-header:hover {\n color: #e0e0e0;\n}\n\n.playthrough-chevron {\n display: inline-block;\n font-size: 0.7em;\n transition: transform 0.2s;\n}\n\n.playthrough-chevron.open {\n transform: rotate(90deg);\n}\n\n.playthrough-label {\n font-weight: 600;\n}\n\n.playthrough-date {\n opacity: 0.6;\n font-size: 0.9em;\n}\n\n.playthrough-saves {\n display: flex;\n flex-direction: column;\n gap: 0.4em;\n padding-left: 0.25em;\n}\n\n.save-slot {\n display: flex;\n align-items: center;\n gap: 0.75em;\n padding: 0.5em 0.6em;\n background: rgba(255, 255, 255, 0.03);\n border: 1px solid rgba(255, 255, 255, 0.06);\n border-radius: 6px;\n transition: background 0.15s;\n}\n\n.save-slot:hover {\n background: rgba(255, 255, 255, 0.06);\n}\n\n.save-slot-info {\n flex: 1;\n min-width: 0;\n}\n\n.save-slot-title {\n font-weight: 500;\n font-size: 0.9em;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.save-slot-meta {\n font-size: 0.75em;\n color: #9e9e9e;\n display: flex;\n gap: 0.75em;\n}\n\n.save-slot-actions {\n display: flex;\n gap: 0.3em;\n flex-shrink: 0;\n}\n\n.save-slot-action {\n background: transparent;\n color: #9e9e9e;\n border: 1px solid transparent;\n border-radius: 3px;\n padding: 0.2em 0.5em;\n font: inherit;\n font-size: 0.75em;\n cursor: pointer;\n transition:\n color 0.2s,\n background 0.2s;\n white-space: nowrap;\n}\n\n.save-slot-action:hover {\n color: #e0e0e0;\n background: rgba(255, 255, 255, 0.08);\n}\n\n.save-slot-action.primary {\n color: #64b5f6;\n border-color: rgba(100, 181, 246, 0.3);\n}\n\n.save-slot-action.primary:hover {\n background: rgba(100, 181, 246, 0.15);\n}\n\n.save-slot-action.danger:hover {\n color: #ef5350;\n background: rgba(239, 83, 80, 0.1);\n}\n\n.save-slot-action.danger.is-armed {\n color: #ef5350;\n background: rgba(239, 83, 80, 0.15);\n border-color: rgba(239, 83, 80, 0.5);\n}\n\n/* Read by screen readers, not shown: announces an armed Delete button */\n.saves-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n\n.save-slot-new {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0.5em;\n margin-top: 0.25em;\n border: 1px dashed rgba(255, 255, 255, 0.12);\n border-radius: 6px;\n color: #9e9e9e;\n font: inherit;\n font-size: 0.8em;\n background: transparent;\n cursor: pointer;\n width: 100%;\n transition:\n color 0.2s,\n border-color 0.2s,\n background 0.2s;\n}\n\n.save-slot-new:hover {\n color: #64b5f6;\n border-color: rgba(100, 181, 246, 0.3);\n background: rgba(100, 181, 246, 0.05);\n}\n\n.saves-notice {\n padding: 0.5em 1.25em;\n font-size: 0.8em;\n color: #ffb74d;\n border-bottom: 1px solid rgba(255, 183, 77, 0.3);\n background: rgba(255, 183, 77, 0.08);\n flex-shrink: 0;\n}\n\n.saves-status {\n padding: 0.5em 1.25em;\n font-size: 0.8em;\n color: #81c784;\n border-top: 1px solid rgba(255, 255, 255, 0.08);\n flex-shrink: 0;\n text-align: center;\n}\n\n.saves-status.error {\n color: #ef5350;\n border: none;\n border-radius: 0;\n padding: 0.5em 1.25em;\n font-family: inherit;\n background: transparent;\n}\n\n.save-rename-input {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 3px;\n padding: 0.15em 0.4em;\n font: inherit;\n font-size: 0.9em;\n width: 100%;\n}\n\n.save-rename-input:focus {\n outline: none;\n border-color: #64b5f6;\n}\n\n/* Macro: link */\n\n.macro-link {\n color: #64b5f6;\n text-decoration: none;\n border-bottom: 1px solid rgba(100, 181, 246, 0.3);\n transition:\n color 0.2s,\n border-color 0.2s;\n cursor: pointer;\n}\n\n.macro-link:hover {\n color: #90caf9;\n border-bottom-color: #90caf9;\n}\n\n.macro-link:active {\n color: #42a5f5;\n}\n\n/* Macro: form inputs */\n\n.macro-textbox,\n.macro-numberbox,\n.macro-textarea {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n.macro-textbox:focus,\n.macro-numberbox:focus,\n.macro-textarea:focus {\n outline: none;\n border-color: #64b5f6;\n}\n\n.macro-textarea {\n min-height: 3em;\n resize: vertical;\n}\n\n.macro-checkbox,\n.macro-radiobutton {\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 0.3em;\n}\n\n.macro-checkbox input,\n.macro-radiobutton input {\n accent-color: #64b5f6;\n}\n\n/* Macro: listbox */\n\n.macro-listbox {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n/* Macro: cycle */\n\n.macro-cycle {\n background: rgba(100, 181, 246, 0.15);\n color: #64b5f6;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 4px;\n padding: 0.25em 0.75em;\n font: inherit;\n cursor: pointer;\n transition:\n background 0.2s,\n border-color 0.2s;\n}\n\n.macro-cycle:hover {\n background: rgba(100, 181, 246, 0.25);\n border-color: #90caf9;\n}\n\n/* Macro: meter */\n\n.macro-meter {\n position: relative;\n width: 100%;\n height: 1.4em;\n background: #2a2a3e;\n border-radius: 0.3em;\n overflow: hidden;\n border: 1px solid #444;\n}\n\n.macro-meter-fill {\n height: 100%;\n background: #64b5f6;\n transition: width 0.3s ease;\n}\n\n.macro-meter-label {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 0.85em;\n color: #e0e0e0;\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);\n pointer-events: none;\n}\n\n/* Markdown wrapper — invisible to layout */\n\n.md {\n display: contents;\n}\n\n/* Markdown block elements inside passages */\n\n.passage p {\n margin: 0.6em 0;\n}\n\n.passage p:first-child {\n margin-top: 0;\n}\n\n.passage p:last-child {\n margin-bottom: 0;\n}\n\n.passage h1,\n.passage h2,\n.passage h3,\n.passage h4,\n.passage h5,\n.passage h6 {\n margin: 1em 0 0.4em;\n line-height: 1.3;\n color: #f0f0f0;\n}\n\n.passage h1 {\n font-size: 1.8em;\n}\n.passage h2 {\n font-size: 1.5em;\n}\n.passage h3 {\n font-size: 1.25em;\n}\n.passage h4 {\n font-size: 1.1em;\n}\n.passage h5 {\n font-size: 1em;\n}\n.passage h6 {\n font-size: 0.9em;\n opacity: 0.8;\n}\n\n.passage code {\n font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;\n font-size: 0.9em;\n background: rgba(255, 255, 255, 0.08);\n padding: 0.15em 0.35em;\n border-radius: 3px;\n}\n\n.passage pre {\n background: rgba(0, 0, 0, 0.3);\n border: 1px solid rgba(255, 255, 255, 0.08);\n border-radius: 6px;\n padding: 1em;\n overflow-x: auto;\n margin: 0.8em 0;\n}\n\n.passage pre code {\n background: none;\n padding: 0;\n border-radius: 0;\n font-size: 0.85em;\n}\n\n.passage blockquote {\n border-left: 3px solid rgba(100, 181, 246, 0.5);\n margin: 0.8em 0;\n padding: 0.4em 1em;\n color: #b0b0b0;\n}\n\n.passage blockquote p {\n margin: 0.3em 0;\n}\n\n.passage ul,\n.passage ol {\n margin: 0.6em 0;\n padding-left: 1.8em;\n}\n\n.passage li {\n margin: 0.2em 0;\n}\n\n.passage hr {\n border: none;\n border-top: 1px solid rgba(255, 255, 255, 0.12);\n margin: 1.2em 0;\n}\n\n.passage table {\n border-collapse: collapse;\n width: 100%;\n margin: 0.8em 0;\n}\n\n.passage th,\n.passage td {\n border: 1px solid rgba(255, 255, 255, 0.12);\n padding: 0.5em 0.75em;\n text-align: left;\n}\n\n.passage th {\n background: rgba(255, 255, 255, 0.06);\n font-weight: 600;\n}\n\n.passage tr:nth-child(even) {\n background: rgba(255, 255, 255, 0.02);\n}\n\n.passage del {\n opacity: 0.5;\n}\n\n.passage strong {\n color: #f0f0f0;\n}\n\n/* Macro: type (typewriter) */\n\n.macro-type-cursor::after {\n content: '\\2588';\n animation: type-blink 0.7s step-end infinite;\n color: #64b5f6;\n}\n\n.macro-type-done .macro-type-cursor::after {\n display: none;\n}\n\n@keyframes type-blink {\n 50% {\n opacity: 0;\n }\n}\n";
|
|
26362
26456
|
// src/index.tsx
|
|
26363
26457
|
function renderErrors(root, errors) {
|
|
26364
26458
|
root.innerHTML = "";
|