@rohal12/spindle 0.62.4 → 0.62.6

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.
@@ -53,6 +53,10 @@ function randomUUID() {
53
53
  }
54
54
  //#endregion
55
55
  //#region src/utils/element-visibility.ts
56
+ /** The parent in the rendered tree, including slots and shadow hosts. */
57
+ function composedParent(el) {
58
+ return el.assignedSlot ?? el.parentElement ?? el.getRootNode().host ?? null;
59
+ }
56
60
  /** Elements whose content is never text the reader reads. */
57
61
  var NOT_TEXT = /* @__PURE__ */ new Set([
58
62
  "SCRIPT",
@@ -72,10 +76,14 @@ function isHidden(el) {
72
76
  * toggles it: the browser renders none of that content (#389).
73
77
  */
74
78
  function inClosedDetails(el, root) {
75
- const stop = root?.parentElement;
76
- for (let e = el.parentElement; e && e !== stop; e = e.parentElement) {
77
- if (e.localName !== "details" || e.hasAttribute("open")) continue;
78
- if (!Array.from(e.children).find((c) => c.localName === "summary")?.contains(el)) return true;
79
+ for (let child = el; child !== root;) {
80
+ const parent = composedParent(child);
81
+ if (!parent) break;
82
+ if (parent.localName === "details" && !parent.hasAttribute("open")) {
83
+ const summary = Array.from(parent.children).find((c) => c.localName === "summary");
84
+ if (child !== summary) return true;
85
+ }
86
+ child = parent;
79
87
  }
80
88
  return false;
81
89
  }
@@ -90,7 +98,7 @@ function isRendered(el, root) {
90
98
  const style = (e) => e.ownerDocument.defaultView?.getComputedStyle(e);
91
99
  const visibility = style(el)?.visibility;
92
100
  if (visibility === "hidden" || visibility === "collapse") return false;
93
- for (let e = el; e; e = e.parentElement) {
101
+ for (let e = el; e; e = composedParent(e)) {
94
102
  if (style(e)?.display === "none") return false;
95
103
  if (e === root) break;
96
104
  }
@@ -99,7 +107,7 @@ function isRendered(el, root) {
99
107
  /** Visibility shared by reader observations and native control handling. */
100
108
  function isReaderVisible(el) {
101
109
  if (!el.isConnected || !isRendered(el)) return false;
102
- for (let at = el; at; at = at.parentElement) if (isHidden(at) || at.hasAttribute("inert")) return false;
110
+ for (let at = el; at; at = composedParent(at)) if (isHidden(at) || at.hasAttribute("inert")) return false;
103
111
  return true;
104
112
  }
105
113
  //#endregion
@@ -4328,6 +4336,7 @@ function branchParents(name, macros) {
4328
4336
  function getMacroParameters(name) {
4329
4337
  return metadataRegistry.get(name)?.parameters;
4330
4338
  }
4339
+ getMacroParameters.source = (name) => metadataRegistry.get(name)?.source;
4331
4340
  function getMacroRegistry() {
4332
4341
  return Array.from(metadataRegistry.values());
4333
4342
  }
@@ -4446,6 +4455,8 @@ function pairMarkup(tokens, options = {}) {
4446
4455
  };
4447
4456
  const root = [];
4448
4457
  const stack = [];
4458
+ const openPositions = /* @__PURE__ */ new Map();
4459
+ const tagKey = (tag) => `${tag.type}:${lowerName(tag)}`;
4449
4460
  const add = (node) => (last$1(stack)?.into ?? root).push(node);
4450
4461
  /**
4451
4462
  * End the element on top of the stack, with `close` if it has one: its
@@ -4454,6 +4465,10 @@ function pairMarkup(tokens, options = {}) {
4454
4465
  const end = (ending, close, owns = ending === "closed") => {
4455
4466
  const { node, body } = stack.pop();
4456
4467
  const open = node.token;
4468
+ const key = tagKey(open);
4469
+ const positions = openPositions.get(key);
4470
+ positions.pop();
4471
+ if (positions.length === 0) openPositions.delete(key);
4457
4472
  const noticedAt = close ? close.end : noticedAtEnd;
4458
4473
  for (const { tag } of body.branches) if (open.type !== "macro" || !parentsOf(tag.name).includes(lowerName(open))) misplaced(tag, open, noticedAt);
4459
4474
  if (ending === "unclosed") report("unclosed-block", open, `Unclosed ${tagLabel(open)}: no ${closerOf(open)} closes it`, noticedAt, { name: nameOf(open) });
@@ -4472,8 +4487,7 @@ function pairMarkup(tokens, options = {}) {
4472
4487
  if (!top) report("stray-closer", token, `${tagLabel(token)} closes nothing: no ${token.type === "html" ? `<${token.tag}>` : `{${token.name}}`} is open here`, token.start, { name: nameOf(token) });
4473
4488
  else if (closes(top.node.token, token)) end("closed", token);
4474
4489
  else {
4475
- let outer = stack.length - 1;
4476
- while (outer >= 0 && !closes(stack[outer].node.token, token)) outer--;
4490
+ const outer = last$1(openPositions.get(tagKey(token)) ?? []) ?? -1;
4477
4491
  end("mismatch", token, outer === -1);
4478
4492
  if (outer !== -1) {
4479
4493
  while (stack.length > outer + 1) end("cut", token);
@@ -4517,6 +4531,10 @@ function pairMarkup(tokens, options = {}) {
4517
4531
  branches: []
4518
4532
  };
4519
4533
  node.body = body;
4534
+ const key = tagKey(token);
4535
+ const positions = openPositions.get(key) ?? [];
4536
+ positions.push(stack.length);
4537
+ openPositions.set(key, positions);
4520
4538
  stack.push({
4521
4539
  node,
4522
4540
  body,
@@ -10747,6 +10765,44 @@ function jsCodeEnd(onOpenEnd) {
10747
10765
  }
10748
10766
  /** The JavaScript reader Spindle uses today: js-lexer, then a lenient scan. */
10749
10767
  var defaultCodeEnd = jsCodeEnd();
10768
+ /**
10769
+ * Index possible brace ends for repeated recovery attempts in one template.
10770
+ * Within plain code, nested braces must close first. At a quote, slash or
10771
+ * escape we stop making lexical assumptions, but the remaining raw `}`s
10772
+ * still bound how many pending braces could close. Indexing visits each
10773
+ * opener once, so unmatched plain-code openers can skip suffix scans.
10774
+ */
10775
+ function indexCodeEnds(input) {
10776
+ const possible = /* @__PURE__ */ new Set();
10777
+ const pending = [];
10778
+ let remaining = 0;
10779
+ let lastBrace = -1;
10780
+ for (let i = 0; i < input.length; i++) if (input[i] === "}") {
10781
+ remaining++;
10782
+ lastBrace = i;
10783
+ }
10784
+ const uncertain = () => {
10785
+ for (let i = Math.max(0, pending.length - remaining); i < pending.length; i++) possible.add(pending[i]);
10786
+ pending.length = 0;
10787
+ };
10788
+ for (let i = 0; i < input.length; i++) {
10789
+ const c = input[i];
10790
+ if (c === "{") pending.push(i);
10791
+ else if (c === "}") {
10792
+ remaining--;
10793
+ const open = pending.pop();
10794
+ if (open !== void 0) possible.add(open);
10795
+ } else if (/['"`/\\]/.test(c)) uncertain();
10796
+ }
10797
+ return (start, codeStart = start, limit = input.length) => {
10798
+ if (start > lastBrace || codeStart >= limit) return -1;
10799
+ const source = limit === input.length ? input : input.slice(0, limit);
10800
+ if (input[start - 1] !== "{" || possible.has(start - 1) || input.slice(start, codeStart).includes("{")) return defaultCodeEnd.closeBrace(source, codeStart, start);
10801
+ const base = Math.max(0, codeStart - 1);
10802
+ const end = parsedCodeEnd(source.slice(base), codeStart - base, "expression");
10803
+ return end < 0 ? -1 : base + end;
10804
+ };
10805
+ }
10750
10806
  //#endregion
10751
10807
  //#region src/markup/code-attributes.ts
10752
10808
  /**
@@ -10772,6 +10828,7 @@ function splitSigilTemplate(template, incomplete = false) {
10772
10828
  const parts = [];
10773
10829
  let text = "";
10774
10830
  let i = 0;
10831
+ const closeBrace = indexCodeEnds(template);
10775
10832
  while (i < template.length) {
10776
10833
  const brace = template.indexOf("{", i);
10777
10834
  if (brace === -1) {
@@ -10780,7 +10837,7 @@ function splitSigilTemplate(template, incomplete = false) {
10780
10837
  }
10781
10838
  text += template.slice(i, brace);
10782
10839
  i = brace + 1;
10783
- let end = isSigil(template[i]) ? defaultCodeEnd.closeBrace(template, i, i) : -1;
10840
+ let end = isSigil(template[i]) ? closeBrace(i) : -1;
10784
10841
  if (end === -1 && incomplete && isSigil(template[i])) end = template.length;
10785
10842
  if (end === -1) {
10786
10843
  text += "{";
@@ -10823,10 +10880,14 @@ var MarkupError = class extends Error {
10823
10880
  }
10824
10881
  };
10825
10882
  function run$2(source, startRule, options, completion = false) {
10826
- const hooks = options.hooks ? {
10883
+ const hooks = {
10827
10884
  ...defaultHooks,
10828
10885
  ...options.hooks
10829
- } : defaultHooks;
10886
+ };
10887
+ if (!options.hooks?.closeBrace) {
10888
+ const codeEnd = indexCodeEnds(source);
10889
+ hooks.closeBrace = (_input, codeStart, lenientStart) => codeEnd(lenientStart, codeStart);
10890
+ }
10830
10891
  try {
10831
10892
  return peg$parse(source, {
10832
10893
  startRule,
@@ -10926,16 +10987,19 @@ function scanMarkupTolerant(source, options = {}, completion = false) {
10926
10987
  const errors = [];
10927
10988
  const damage = [];
10928
10989
  let position;
10990
+ const codeEnd = indexCodeEnds(source);
10991
+ const customCloseBrace = options.hooks?.closeBrace;
10929
10992
  const lastBrace = source.lastIndexOf("}");
10930
- const { closeBrace } = {
10931
- ...defaultHooks,
10932
- ...options.hooks
10933
- };
10934
10993
  /** `text` shifted by `base`, tokenized: the tokens or the error. */
10935
10994
  const attempt = (text, base) => {
10936
10995
  const hooks = {
10937
10996
  ...options.hooks,
10938
- closeBrace: (input, codeStart, lenientStart) => base + Math.min(codeStart, lenientStart) > lastBrace ? -1 : closeBrace(input, codeStart, lenientStart)
10997
+ closeBrace: (input, codeStart, lenientStart) => {
10998
+ if (base + Math.min(codeStart, lenientStart) > lastBrace) return -1;
10999
+ if (customCloseBrace) return customCloseBrace(input, codeStart, lenientStart);
11000
+ const end = codeEnd(base + lenientStart, base + codeStart, base + text.length);
11001
+ return end < 0 ? -1 : end - base;
11002
+ }
10939
11003
  };
10940
11004
  try {
10941
11005
  return run$2(text, "Tokens", {
@@ -11822,6 +11886,14 @@ function widgetParameters(params, holds = {}) {
11822
11886
  ...hasOwn(holds, name) ? { holds: holds[name] } : {}
11823
11887
  }));
11824
11888
  }
11889
+ /** Whether builtin-only interpretation still belongs to this implementation. */
11890
+ function usesBuiltinSemantics(name, parametersOf) {
11891
+ return parametersOf.widget?.(name) === void 0 && parametersOf.source?.(name) !== "user";
11892
+ }
11893
+ /** A raw body is executable only while the builtin implementation owns it. */
11894
+ function executesRawBody(name, parametersOf) {
11895
+ return isRawMacro(name, false) && usesBuiltinSemantics(name, parametersOf);
11896
+ }
11825
11897
  /**
11826
11898
  * `params` with each `string` and `text` parameter (options too) saying
11827
11899
  * what it holds: what it declares, else `holds`.
@@ -11849,20 +11921,24 @@ function withHolds(params, holds) {
11849
11921
  function parameterLookup(macros) {
11850
11922
  const parameters = new NameMap();
11851
11923
  const widgets = new NameMap();
11852
- for (const { name, parameters: params, interpolate, widget } of macros) {
11924
+ const sources = new NameMap();
11925
+ for (const { name, parameters: params, interpolate, widget, source } of macros) {
11926
+ sources.set(name, source ?? "user");
11853
11927
  if (params) parameters.set(name, withHolds(params, holdsByDefault(interpolate)));
11928
+ else parameters.delete(name);
11854
11929
  if (widget) widgets.set(name, widgetParameters(widget.params, widget.holds) ?? []);
11855
11930
  }
11856
11931
  const lookup = (name) => {
11857
11932
  if (widgets.has(name)) return void 0;
11858
11933
  let params = parameters.get(name);
11859
- if (!params) {
11934
+ if (!params && sources.get(name) !== "user") {
11860
11935
  const sub = subMacroParameters(name);
11861
11936
  if (sub) parameters.set(name, params = withHolds(sub, "text"));
11862
11937
  }
11863
11938
  return params;
11864
11939
  };
11865
11940
  if (widgets.size > 0) lookup.widget = (name) => widgets.get(name);
11941
+ lookup.source = (name) => sources.get(name);
11866
11942
  return lookup;
11867
11943
  }
11868
11944
  /** What a `string` or `text` argument holds when its parameter doesn't say. */
@@ -11928,7 +12004,7 @@ function* codeAndText(src, tokens, parametersOf) {
11928
12004
  else if (token.type === "macro" && !token.isClose) {
11929
12005
  const name = token.name.toLowerCase();
11930
12006
  const widget = parametersOf.widget?.(name);
11931
- if (name === "do" && !widget) {
12007
+ if (executesRawBody(name, parametersOf)) {
11932
12008
  const close = closeOfTextBody(t, name);
11933
12009
  if (close < 0) continue;
11934
12010
  yield {
@@ -11942,7 +12018,7 @@ function* codeAndText(src, tokens, parametersOf) {
11942
12018
  continue;
11943
12019
  }
11944
12020
  const args = token.rawArgs;
11945
- if (PASSAGE_BODIES.has(name) && !widget) {
12021
+ if (PASSAGE_BODIES.has(name) && usesBuiltinSemantics(name, parametersOf)) {
11946
12022
  const close = closeOfTextBody(t, name);
11947
12023
  if (close > t + 1) {
11948
12024
  const text = src.slice(token.end, tokens[close].start);
@@ -11960,7 +12036,7 @@ function* codeAndText(src, tokens, parametersOf) {
11960
12036
  if (!args) continue;
11961
12037
  const label = `{${token.name} ${args}}`;
11962
12038
  const argsAt = token.argsStart;
11963
- if (CONDITION_MACROS.has(name) && !widget) {
12039
+ if (CONDITION_MACROS.has(name) && usesBuiltinSemantics(name, parametersOf)) {
11964
12040
  yield {
11965
12041
  kind: "code",
11966
12042
  code: args,
@@ -12289,6 +12365,7 @@ function locate(text, part, from) {
12289
12365
  //#region src/widgets/ast-scanner.ts
12290
12366
  /** The declared parameters of the macros registered so far. */
12291
12367
  var registeredParameters = (name) => parameterLookup(getMacroRegistry())(name);
12368
+ registeredParameters.source = getMacroParameters.source;
12292
12369
  /**
12293
12370
  * Whether the text of an attribute value or macro label renders a
12294
12371
  * `{@children}`: it is markup, parsed as the renderer parses it.
@@ -13144,7 +13221,6 @@ var TextEvaluator = class {
13144
13221
  }, depth + 1);
13145
13222
  }
13146
13223
  macro(node, scope, depth) {
13147
- if (isSubMacro(node.name)) return "";
13148
13224
  const widget = getWidget(node.name);
13149
13225
  if (widget) {
13150
13226
  let locals = scope.locals;
@@ -13167,6 +13243,7 @@ var TextEvaluator = class {
13167
13243
  widgetChildren: widgetChildrenOf(node.children, scope.widgetChildren)
13168
13244
  });
13169
13245
  }
13246
+ if (isSubMacro(node.name)) return "";
13170
13247
  const text = getMacroText(node.name);
13171
13248
  if (!text) {
13172
13249
  const message = getMacro(node.name) ? `{${node.name}} has no text form, so it can't be used in an attribute value or label` : `unknown macro {${node.name}}`;
@@ -14377,7 +14454,6 @@ function nodeKey(node) {
14377
14454
  return key;
14378
14455
  }
14379
14456
  function renderMacro(node, key) {
14380
- if (isSubMacro(node.name)) return null;
14381
14457
  const invocation = {
14382
14458
  rawArgs: node.rawArgs,
14383
14459
  className: node.className,
@@ -14390,6 +14466,7 @@ function renderMacro(node, key) {
14390
14466
  params: widget.params,
14391
14467
  invocationChildren: node.children
14392
14468
  }, key);
14469
+ if (isSubMacro(node.name)) return null;
14393
14470
  const Component = getMacro(node.name);
14394
14471
  if (Component) return /* @__PURE__ */ jsx(Component, {
14395
14472
  ...invocation,
@@ -14437,7 +14514,7 @@ function renderInlineNodes(nodes) {
14437
14514
  * line ending (`\r\n` or `\r`) also takes the full pipeline, which reads
14438
14515
  * it as micromark does.
14439
14516
  */
14440
- var MARKDOWN_SYNTAX_RE = /[*_`#|~\[>\\\-+=\r]|!\[|\d+[.)]|&#?[a-zA-Z0-9]+;| {2}\n|<[!?]/;
14517
+ var MARKDOWN_SYNTAX_RE = /[*_`#|~\[>\\\-+=\r]|!\[|\d{1,9}[.)]|&#?[a-zA-Z0-9]+;| {2}\n|<[!?]/;
14441
14518
  /** Two line endings (LF, CRLF or CR) with only whitespace between them. */
14442
14519
  var BLANK_LINE_RE = /(?:\r\n|\r(?!\n)|\n)\s*[\r\n]/;
14443
14520
  var PLACEHOLDER_STRIP_RE = /<span data-tw=[0-9a-z]+:\d+><\/span>/g;
@@ -18334,8 +18411,14 @@ function establishPlaythrough(ifid) {
18334
18411
  function saveWithHooks(slot, custom, beginCapture, write) {
18335
18412
  try {
18336
18413
  const capture = beginCapture();
18337
- withoutDraws(() => emit("beforesave", slot, custom));
18338
- return write(capture()).then((result) => {
18414
+ let payload;
18415
+ try {
18416
+ withoutDraws(() => emit("beforesave", slot, custom));
18417
+ payload = capture();
18418
+ } finally {
18419
+ capture.dispose();
18420
+ }
18421
+ return write(payload).then((result) => {
18339
18422
  withoutDraws(() => emit("aftersave", slot));
18340
18423
  return result;
18341
18424
  });
@@ -19255,6 +19338,7 @@ function freshTransients(defaults) {
19255
19338
  function enterStart(state, passage, variables, transientDefaults) {
19256
19339
  state.currentPassage = passage;
19257
19340
  state.navigationId++;
19341
+ state.replacementNavigationId = state.navigationId;
19258
19342
  state.variables = variables;
19259
19343
  state.transient = freshTransients(transientDefaults);
19260
19344
  state.temporary = createNamespace();
@@ -19527,10 +19611,10 @@ function loadedEntryMoment(payload) {
19527
19611
  return moment;
19528
19612
  }
19529
19613
  /** The variable paths `Story.set` writes while a save's hooks run. */
19530
- var hookWrites = null;
19614
+ var hookWrites = /* @__PURE__ */ new Set();
19531
19615
  /** Note that `path` of the variables was written (see keepHookWrites). */
19532
19616
  function recordHookWrite(path) {
19533
- hookWrites?.set(pathKey(path), path);
19617
+ for (const writes of hookWrites) writes.set(pathKey(path), path);
19534
19618
  }
19535
19619
  /**
19536
19620
  * Write the changes between `before` and `after` (the live variables around
@@ -19773,6 +19857,7 @@ var useStoryStore = create()(storyStore((set, get) => ({
19773
19857
  storyData: null,
19774
19858
  currentPassage: "",
19775
19859
  navigationId: 0,
19860
+ replacementNavigationId: 0,
19776
19861
  variables: createNamespace(),
19777
19862
  variableDefaults: {},
19778
19863
  transient: createNamespace(),
@@ -20088,14 +20173,17 @@ var useStoryStore = create()(storyStore((set, get) => ({
20088
20173
  const before = get().variables;
20089
20174
  const replaced = latestStateApplied;
20090
20175
  const writes = /* @__PURE__ */ new Map();
20091
- hookWrites = writes;
20092
- return () => {
20093
- if (hookWrites === writes) hookWrites = null;
20176
+ hookWrites.add(writes);
20177
+ const dispose = () => {
20178
+ hookWrites.delete(writes);
20179
+ };
20180
+ return Object.assign(() => {
20181
+ dispose();
20094
20182
  if (latestStateApplied !== replaced) throw new Error("spindle: a beforesave handler restarted or loaded the game, so the save was not made");
20095
20183
  const payload = get().getSavePayload();
20096
20184
  keepHookWrites(payload, before, get().variables, [...writes.values()]);
20097
20185
  return payload;
20098
- };
20186
+ }, { dispose });
20099
20187
  },
20100
20188
  loadFromPayload: (payload, slot, playthroughId, issued) => {
20101
20189
  const applying = slotLoadApplying ?? issued;
@@ -20139,6 +20227,7 @@ var useStoryStore = create()(storyStore((set, get) => ({
20139
20227
  set((state) => {
20140
20228
  state.currentPassage = payload.passage;
20141
20229
  state.navigationId++;
20230
+ state.replacementNavigationId = state.navigationId;
20142
20231
  state.variables = createNamespace(deepClone(entry?.variables ?? payload.variables));
20143
20232
  state.history = retained.map((m) => ({
20144
20233
  passage: m.passage,
@@ -20233,10 +20322,6 @@ var FOCUSABLE = [
20233
20322
  "[contenteditable]",
20234
20323
  "[tabindex]"
20235
20324
  ].join(",");
20236
- /** The parent in the rendered tree, including slots and shadow hosts. */
20237
- function composedParent(el) {
20238
- return el.assignedSlot ?? el.parentElement ?? el.getRootNode().host ?? null;
20239
- }
20240
20325
  function composedChildren(root) {
20241
20326
  if (root.localName === "slot") return root.assignedNodes({ flatten: true }).filter((node) => node.nodeType === 1);
20242
20327
  return Array.from(root.children);
@@ -23136,7 +23221,7 @@ function collectTokenRefs(content, tokens, at, emit, options) {
23136
23221
  });
23137
23222
  } else if (!/^["'`]/.test(first)) scanCode(first, (i) => at(token.argsStart + lead + i), emit);
23138
23223
  }
23139
- if (token.name.toLowerCase() === "do" && !parametersOf.widget?.(token.name)) {
23224
+ if (executesRawBody(token.name, parametersOf)) {
23140
23225
  let close = t + 1;
23141
23226
  while (close < tokens.length) {
23142
23227
  const c = tokens[close];
@@ -23887,7 +23972,6 @@ defineMacro({
23887
23972
  id: navigationId
23888
23973
  });
23889
23974
  const resolvedTypeRef = useRef("fade");
23890
- const prevHistoryLenRef = useRef(0);
23891
23975
  const displayedId = displayed.id;
23892
23976
  const isOutgoing = useCallback((state) => state.navigationId !== displayedId, [displayedId]);
23893
23977
  const hasLeft = useCallback(() => isOutgoing(useStoryStore.getState()), [isOutgoing]);
@@ -23911,12 +23995,9 @@ defineMacro({
23911
23995
  }, [cancelTransition]);
23912
23996
  useEffect(() => {
23913
23997
  const store = useStoryStore.getState();
23914
- const { history, historyIndex, transitionConfig } = store;
23915
- const prevLen = prevHistoryLenRef.current;
23916
- prevHistoryLenRef.current = history.length;
23998
+ const { replacementNavigationId, transitionConfig } = store;
23917
23999
  const isFirstLoad = !displayedPassage;
23918
- const isRestart = history.length === 1 && historyIndex === 0 && prevLen > 1;
23919
- const isLoad = history.length > 1 && historyIndex === history.length - 1 && prevLen > 1 && Math.abs(history.length - prevLen) > 1;
24000
+ const isReplacement = navigationId === replacementNavigationId;
23920
24001
  if (navigationId === displayed.id) return;
23921
24002
  const next = store.consumeNextTransition();
23922
24003
  cancelTransition();
@@ -23926,7 +24007,7 @@ defineMacro({
23926
24007
  setDisplayedPassage(currentPassage);
23927
24008
  return;
23928
24009
  }
23929
- if (isFirstLoad || isRestart || isLoad) {
24010
+ if (isFirstLoad || isReplacement) {
23930
24011
  resolvedTypeRef.current = "fade";
23931
24012
  setDisplayedPassage(currentPassage);
23932
24013
  return;
@@ -24494,8 +24575,9 @@ var SETTLING_MACROS = new NameSet([
24494
24575
  function settlesAfterRender(nodes) {
24495
24576
  return nodes.every((n) => {
24496
24577
  switch (n.type) {
24497
- case "macro": return SETTLING_MACROS.has(n.name) && settlesAfterRender(n.children) && (n.branches ?? []).every((b) => settlesAfterRender(b.children));
24578
+ case "macro": return SETTLING_MACROS.has(n.name) && !getWidget(n.name) && getMacroParameters.source(n.name) === "builtin" && settlesAfterRender(n.children) && (n.branches ?? []).every((b) => settlesAfterRender(b.children));
24498
24579
  case "html": return settlesAfterRender(n.children);
24580
+ case "variable": return n.scope !== "local" || n.name !== "children";
24499
24581
  default: return true;
24500
24582
  }
24501
24583
  });