@rohal12/spindle 0.64.10 → 0.64.11
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 +169 -84
- package/dist/pkg/play.js +2 -1
- package/dist/pkg/story-variables.js +256 -128
- package/dist/pkg/tooling.js +2 -0
- package/package.json +1 -1
- package/src/completion-context.ts +111 -23
- package/src/js-lexer.ts +178 -63
- package/src/markup/html-integration.tsx +101 -0
- package/src/markup/render.tsx +67 -30
- package/src/play/session.ts +9 -1
- package/src/tooling.ts +63 -19
- package/src/twine-editor/highlight.ts +10 -11
- package/types/tooling.d.ts +42 -0
package/dist/pkg/headless.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fragment, createContext, h, render } from "preact";
|
|
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
3
|
import { useSyncExternalStore } from "preact/compat";
|
|
4
4
|
import { createStore } from "zustand/vanilla";
|
|
@@ -5546,9 +5546,7 @@ var SigilParser = class extends Parser {
|
|
|
5546
5546
|
if (name) {
|
|
5547
5547
|
const end = at + 1 + name.length;
|
|
5548
5548
|
const afterPrefix = self.type === types$1.incDec && (this.operandBeforeLast || this.breakBeforeLast);
|
|
5549
|
-
|
|
5550
|
-
if (code === 64 || (forced ?? (self.exprAllowed || afterPrefix || this.lookahead && transientAssignment(self, end)))) {
|
|
5551
|
-
if (code === 37) this.transientsRead?.add(at);
|
|
5549
|
+
if (code === 64 || self.exprAllowed || afterPrefix || this.lookahead && transientAssignment(self, end)) {
|
|
5552
5550
|
self.pos = end;
|
|
5553
5551
|
self.finishToken(types$1.name, self.input.charAt(at) + name);
|
|
5554
5552
|
return;
|
|
@@ -5571,16 +5569,31 @@ var SigilParser = class extends Parser {
|
|
|
5571
5569
|
}
|
|
5572
5570
|
const self = this;
|
|
5573
5571
|
const prevType = self.type;
|
|
5572
|
+
const beforePreviousValue = this.prevValue;
|
|
5574
5573
|
this.prevValue = isMemberDot(this.typeBeforeLast) ? void 0 : self.value;
|
|
5575
5574
|
const property = type.keyword !== void 0 && isMemberDot(prevType) || (type === types$1._function || type === types$1._class) && notABody(self.input, self.pos);
|
|
5576
5575
|
if (!property && (type === types$1._function || type === types$1._class)) {
|
|
5577
|
-
const
|
|
5578
|
-
|
|
5576
|
+
const afterAsync = type === types$1._function && prevType === types$1.name && this.prevValue === "async" && !this.breakHere;
|
|
5577
|
+
const before = afterAsync ? this.typeBeforeLast : prevType;
|
|
5578
|
+
const contextualOperand = before === types$1.name && (afterAsync ? this.operandBeforeLast : self.exprAllowed) && ((afterAsync ? beforePreviousValue : this.prevValue) !== "yield" || !(afterAsync ? this.breakBeforeLast : this.breakHere));
|
|
5579
|
+
self.type = before === types$1.colon && this.colonEndsTernary || contextualOperand ? types$1.parenL : before;
|
|
5579
5580
|
}
|
|
5580
5581
|
this.typeBeforeLast = prevType;
|
|
5581
5582
|
super.finishToken(property ? types$1.name : type, value);
|
|
5582
5583
|
if (type === types$1.name && (isMemberDot(prevType) || value === "of" && (prevType === types$1._const || prevType === types$1._var || this.prevValue === "let"))) self.exprAllowed = false;
|
|
5583
5584
|
}
|
|
5585
|
+
parseIdent(liberal) {
|
|
5586
|
+
this.exprAllowed = false;
|
|
5587
|
+
return super.parseIdent(liberal);
|
|
5588
|
+
}
|
|
5589
|
+
parseForIn(node, init) {
|
|
5590
|
+
this.exprAllowed = true;
|
|
5591
|
+
return super.parseForIn(node, init);
|
|
5592
|
+
}
|
|
5593
|
+
parseAwait(forInit) {
|
|
5594
|
+
this.exprAllowed = true;
|
|
5595
|
+
return super.parseAwait(forInit);
|
|
5596
|
+
}
|
|
5584
5597
|
braceIsBlock(prevType) {
|
|
5585
5598
|
if (prevType === types$1.colon && this.colonEndsTernary) return false;
|
|
5586
5599
|
if (prevType === types$1.braceR && this.closedBlock) return true;
|
|
@@ -5765,29 +5778,17 @@ function parseCode(src, goal = "expression") {
|
|
|
5765
5778
|
}
|
|
5766
5779
|
/** What parseCode finds in `src`, and the syntax tree it is in. */
|
|
5767
5780
|
function parseWithAst(src, goal) {
|
|
5768
|
-
const
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
return {
|
|
5780
|
-
out,
|
|
5781
|
-
ast
|
|
5782
|
-
};
|
|
5783
|
-
} catch (error) {
|
|
5784
|
-
const pos = error.pos ?? -1;
|
|
5785
|
-
if (!(error instanceof SyntaxError) || percentAt.has(pos)) throw error;
|
|
5786
|
-
TRANS_NAME_RE.lastIndex = pos + 1;
|
|
5787
|
-
if (src.charAt(pos) !== "%" || !TRANS_NAME_RE.test(src)) throw error;
|
|
5788
|
-
percentAt.set(pos, !transientsRead.has(pos));
|
|
5789
|
-
}
|
|
5790
|
-
}
|
|
5781
|
+
const ast = parseAst(src, goal);
|
|
5782
|
+
const out = {
|
|
5783
|
+
refs: [],
|
|
5784
|
+
strings: []
|
|
5785
|
+
};
|
|
5786
|
+
walk(ast, src, out, false, false);
|
|
5787
|
+
out.refs.sort((a, b) => a.start - b.start);
|
|
5788
|
+
return {
|
|
5789
|
+
out,
|
|
5790
|
+
ast
|
|
5791
|
+
};
|
|
5791
5792
|
}
|
|
5792
5793
|
/**
|
|
5793
5794
|
* Read `src` as a reference path: a variable with any number of `.name` and
|
|
@@ -5845,15 +5846,10 @@ function readMemberPath(src, end) {
|
|
|
5845
5846
|
end
|
|
5846
5847
|
};
|
|
5847
5848
|
}
|
|
5848
|
-
/**
|
|
5849
|
-
|
|
5850
|
-
* noting where it read a transient in `transientsRead`.
|
|
5851
|
-
*/
|
|
5852
|
-
function parseAst(src, goal, percentAt, transientsRead) {
|
|
5849
|
+
/** Parse `src` as `goal`, using the parser's context for `%name`. */
|
|
5850
|
+
function parseAst(src, goal) {
|
|
5853
5851
|
try {
|
|
5854
5852
|
const p = tokenizerAt(src, 0, goal);
|
|
5855
|
-
p.percentAt = percentAt;
|
|
5856
|
-
p.transientsRead = transientsRead;
|
|
5857
5853
|
if (goal === "statements") return p.parse();
|
|
5858
5854
|
p.nextToken();
|
|
5859
5855
|
const ast = p.parseExpression();
|
|
@@ -6066,33 +6062,54 @@ var WORDS_BEFORE_STRING = /* @__PURE__ */ new Set([
|
|
|
6066
6062
|
* what in it is no JavaScript.
|
|
6067
6063
|
*/
|
|
6068
6064
|
function findCodeEnd(src, start, { goal = "expression", stop, onRunOut } = {}) {
|
|
6069
|
-
|
|
6070
|
-
|
|
6065
|
+
let verifyStop = false;
|
|
6066
|
+
const end = scanCodeEnd(src, start, goal, stop, onRunOut, () => {
|
|
6067
|
+
verifyStop = true;
|
|
6068
|
+
});
|
|
6069
|
+
if (end < 0 || verifyStop) {
|
|
6070
|
+
const parsed = parsedCodeEnd(src, start, goal, stop);
|
|
6071
|
+
if (parsed >= 0) return parsed;
|
|
6072
|
+
}
|
|
6073
|
+
return end;
|
|
6071
6074
|
}
|
|
6072
6075
|
/**
|
|
6073
6076
|
* Where the code from `start` ends, as the parser finds it: the `}` it
|
|
6074
|
-
* stops at, or -1. The token scan of
|
|
6075
|
-
* opens a regex from the tokens before
|
|
6076
|
-
*
|
|
6077
|
-
*
|
|
6077
|
+
* stops at (or the `{` matching `stop`), or -1. The token scan of
|
|
6078
|
+
* `findCodeEnd` guesses whether a `/` opens a regex from the tokens before
|
|
6079
|
+
* it, and class fields inside template literals can mislead it. The parser
|
|
6080
|
+
* knows the context. Asked when the scan finds no end or a stop that might
|
|
6081
|
+
* still be template text.
|
|
6078
6082
|
*/
|
|
6079
|
-
function parsedCodeEnd(src, start, goal) {
|
|
6083
|
+
function parsedCodeEnd(src, start, goal, stop) {
|
|
6080
6084
|
const p = tokenizerAt(src, start, goal);
|
|
6085
|
+
const stopped = {};
|
|
6086
|
+
let stoppedAt = -1;
|
|
6087
|
+
if (stop) {
|
|
6088
|
+
const nextToken = p.nextToken;
|
|
6089
|
+
p.nextToken = () => {
|
|
6090
|
+
nextToken.call(p);
|
|
6091
|
+
if (p.type === types$1.braceL && stop(p.start)) {
|
|
6092
|
+
stoppedAt = p.start;
|
|
6093
|
+
throw stopped;
|
|
6094
|
+
}
|
|
6095
|
+
};
|
|
6096
|
+
}
|
|
6081
6097
|
try {
|
|
6082
6098
|
if (goal === "statements") p.parse();
|
|
6083
6099
|
else {
|
|
6084
6100
|
p.nextToken();
|
|
6085
6101
|
p.parseExpression();
|
|
6086
|
-
if (p.type === types$1.braceR) return p.start;
|
|
6102
|
+
if (!stop && p.type === types$1.braceR) return p.start;
|
|
6087
6103
|
}
|
|
6088
6104
|
} catch (error) {
|
|
6105
|
+
if (error === stopped) return stoppedAt;
|
|
6089
6106
|
const pos = error.pos ?? -1;
|
|
6090
|
-
if (src.charAt(pos) === "}") return pos;
|
|
6107
|
+
if (!stop && src.charAt(pos) === "}") return pos;
|
|
6091
6108
|
}
|
|
6092
6109
|
return -1;
|
|
6093
6110
|
}
|
|
6094
6111
|
/** `findCodeEnd` by the tokens: see there. */
|
|
6095
|
-
function scanCodeEnd(src, start, goal, stop, onRunOut) {
|
|
6112
|
+
function scanCodeEnd(src, start, goal, stop, onRunOut, onTemplateStop) {
|
|
6096
6113
|
/** No end: the code runs to the end of `src`. */
|
|
6097
6114
|
const ranOut = () => {
|
|
6098
6115
|
onRunOut?.();
|
|
@@ -6104,6 +6121,7 @@ function scanCodeEnd(src, start, goal, stop, onRunOut) {
|
|
|
6104
6121
|
let from = start;
|
|
6105
6122
|
let afterOperand = false;
|
|
6106
6123
|
let templateSlip = false;
|
|
6124
|
+
let interpolated = false;
|
|
6107
6125
|
for (;;) {
|
|
6108
6126
|
let resumeAt = -1;
|
|
6109
6127
|
for (const tok of tokens(src, from, goal, { afterOperand })) {
|
|
@@ -6132,10 +6150,15 @@ function scanCodeEnd(src, start, goal, stop, onRunOut) {
|
|
|
6132
6150
|
prevWord = t === types$1.name && !WORDS_BEFORE_STRING.has(tok.value) || t === types$1.num;
|
|
6133
6151
|
prevEnd = tok.end;
|
|
6134
6152
|
if (t === types$1.braceL) {
|
|
6135
|
-
if (stop?.(tok.start))
|
|
6153
|
+
if (stop?.(tok.start)) {
|
|
6154
|
+
if (interpolated) onTemplateStop();
|
|
6155
|
+
return tok.start;
|
|
6156
|
+
}
|
|
6136
6157
|
stack.push("{");
|
|
6137
|
-
} else if (t === types$1.dollarBraceL)
|
|
6138
|
-
|
|
6158
|
+
} else if (t === types$1.dollarBraceL) {
|
|
6159
|
+
interpolated = true;
|
|
6160
|
+
stack.push("${");
|
|
6161
|
+
} else if (t === types$1.parenL) stack.push("(");
|
|
6139
6162
|
else if (t === types$1.bracketL) stack.push("[");
|
|
6140
6163
|
else if (t === types$1.parenR || t === types$1.bracketR) {
|
|
6141
6164
|
if (last$1(stack) === (t === types$1.parenR ? "(" : "[")) stack.pop();
|
|
@@ -6213,7 +6236,8 @@ function* tokens(src, start, goal, options = {}) {
|
|
|
6213
6236
|
type: p.type,
|
|
6214
6237
|
start: p.start,
|
|
6215
6238
|
end: p.end,
|
|
6216
|
-
value: p.value
|
|
6239
|
+
value: p.value,
|
|
6240
|
+
operand: p.operandHere
|
|
6217
6241
|
};
|
|
6218
6242
|
if (p.type === types$1.eof) return;
|
|
6219
6243
|
}
|
|
@@ -16688,6 +16712,53 @@ function unclosedHtml(text) {
|
|
|
16688
16712
|
}
|
|
16689
16713
|
} } };
|
|
16690
16714
|
}
|
|
16715
|
+
// src/markup/html-integration.tsx
|
|
16716
|
+
function isHtmlEncoding(value) {
|
|
16717
|
+
return typeof value === "string" && /^(?:text\/html|application\/xhtml\+xml)$/i.test(value);
|
|
16718
|
+
}
|
|
16719
|
+
function authorElement(tag, attributes, children, math) {
|
|
16720
|
+
return math && tag === "annotation-xml" ? /* @__PURE__ */ jsx(HtmlAnnotation, {
|
|
16721
|
+
attributes,
|
|
16722
|
+
children
|
|
16723
|
+
}, attributes.key) : h(tag, attributes, children);
|
|
16724
|
+
}
|
|
16725
|
+
/**
|
|
16726
|
+
* Preact handles MathML text integration points, but does not yet switch the
|
|
16727
|
+
* namespace for HTML-encoded annotation-xml. A portal's container can supply
|
|
16728
|
+
* that namespace without adding a wrapper or changing the MathML element.
|
|
16729
|
+
*/
|
|
16730
|
+
function HtmlAnnotation({ attributes, children }) {
|
|
16731
|
+
const elementRef = useRef(null);
|
|
16732
|
+
const [container, setContainer] = useState(null);
|
|
16733
|
+
useLayoutEffect(() => {
|
|
16734
|
+
const element = elementRef.current;
|
|
16735
|
+
setContainer({
|
|
16736
|
+
nodeType: 1,
|
|
16737
|
+
namespaceURI: "http://www.w3.org/1999/xhtml",
|
|
16738
|
+
ownerDocument: element.ownerDocument,
|
|
16739
|
+
get parentNode() {
|
|
16740
|
+
return element.parentNode;
|
|
16741
|
+
},
|
|
16742
|
+
get firstChild() {
|
|
16743
|
+
return element.firstChild;
|
|
16744
|
+
},
|
|
16745
|
+
get childNodes() {
|
|
16746
|
+
return element.childNodes;
|
|
16747
|
+
},
|
|
16748
|
+
insertBefore: element.insertBefore.bind(element),
|
|
16749
|
+
appendChild: element.appendChild.bind(element),
|
|
16750
|
+
removeChild: element.removeChild.bind(element)
|
|
16751
|
+
});
|
|
16752
|
+
}, []);
|
|
16753
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [h("annotation-xml", {
|
|
16754
|
+
...attributes,
|
|
16755
|
+
ref: (element) => {
|
|
16756
|
+
elementRef.current = element;
|
|
16757
|
+
const forwarded = attributes.ref;
|
|
16758
|
+
if (forwarded) forwarded.current = element;
|
|
16759
|
+
}
|
|
16760
|
+
}, isHtmlEncoding(attributes.encoding) ? void 0 : children), container && isHtmlEncoding(attributes.encoding) && createPortal(children, container)] });
|
|
16761
|
+
}
|
|
16691
16762
|
// src/markup/render.tsx
|
|
16692
16763
|
var defaultUpdater = {
|
|
16693
16764
|
update: (key) => {
|
|
@@ -16714,7 +16785,7 @@ var InlineContext = createContext(false);
|
|
|
16714
16785
|
*/
|
|
16715
16786
|
var StructuralContext = createContext(false);
|
|
16716
16787
|
/**
|
|
16717
|
-
* True while rendering inside an element whose content is not markdown: SVG
|
|
16788
|
+
* True while rendering inside an element whose content is not markdown: SVG/MathML
|
|
16718
16789
|
* (whose namespace `<p>` wrappers would break) and the preformatted `<pre>`
|
|
16719
16790
|
* `<textarea>`, `<style>` and `<script>`, whose text is literal.
|
|
16720
16791
|
* Macro and widget bodies read it so their content stays literal too.
|
|
@@ -16734,11 +16805,19 @@ function useViewScope() {
|
|
|
16734
16805
|
return useState(() => `v${++viewScopes}`)[0];
|
|
16735
16806
|
}
|
|
16736
16807
|
/**
|
|
16737
|
-
*
|
|
16738
|
-
*
|
|
16808
|
+
* The foreign namespace containing author elements. SVG and MathML attributes
|
|
16809
|
+
* are case-sensitive and have no live HTML form properties.
|
|
16739
16810
|
*/
|
|
16740
|
-
var
|
|
16811
|
+
var ForeignContext = createContext(void 0);
|
|
16741
16812
|
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
16813
|
+
var MATH_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
16814
|
+
var MATH_TEXT_ELEMENTS = /* @__PURE__ */ new Set([
|
|
16815
|
+
"mi",
|
|
16816
|
+
"mo",
|
|
16817
|
+
"mn",
|
|
16818
|
+
"ms",
|
|
16819
|
+
"mtext"
|
|
16820
|
+
]);
|
|
16742
16821
|
/**
|
|
16743
16822
|
* Elements whose children must be elements of particular types: markdown
|
|
16744
16823
|
* paragraphs between them would pull the children out of the structure (#423).
|
|
@@ -16808,7 +16887,7 @@ function expandPlaceholderText(text, ph) {
|
|
|
16808
16887
|
* evaluated as text against the store and locals, so it follows its
|
|
16809
16888
|
* variables as the component would.
|
|
16810
16889
|
*/
|
|
16811
|
-
function PlaceholderAttributes({ tag, attributes, placeholders,
|
|
16890
|
+
function PlaceholderAttributes({ tag, attributes, placeholders, foreign, math, children }) {
|
|
16812
16891
|
const scope = useTextScope();
|
|
16813
16892
|
const errors = [];
|
|
16814
16893
|
const { props, direct } = splitAttributes(attributes.map(([name, value, written]) => {
|
|
@@ -16827,20 +16906,20 @@ function PlaceholderAttributes({ tag, attributes, placeholders, svg, children })
|
|
|
16827
16906
|
written,
|
|
16828
16907
|
true
|
|
16829
16908
|
];
|
|
16830
|
-
}),
|
|
16909
|
+
}), foreign, tag);
|
|
16831
16910
|
const ref = useDirectAttributes(direct);
|
|
16832
|
-
return withAttributeErrors(errors,
|
|
16911
|
+
return withAttributeErrors(errors, authorElement(tag, ref ? {
|
|
16833
16912
|
...props,
|
|
16834
16913
|
ref
|
|
16835
|
-
} : props, children));
|
|
16914
|
+
} : props, children, math));
|
|
16836
16915
|
}
|
|
16837
16916
|
/** An element of markdown output with attributes to set directly. */
|
|
16838
|
-
function DirectAttributes({ tag, props, direct, children }) {
|
|
16917
|
+
function DirectAttributes({ tag, props, direct, math, children }) {
|
|
16839
16918
|
const ref = useDirectAttributes(direct);
|
|
16840
|
-
return
|
|
16919
|
+
return authorElement(tag, {
|
|
16841
16920
|
...props,
|
|
16842
16921
|
ref
|
|
16843
|
-
}, children);
|
|
16922
|
+
}, children, math);
|
|
16844
16923
|
}
|
|
16845
16924
|
/**
|
|
16846
16925
|
* Show the errors met in an element's attributes in front of it, the way a
|
|
@@ -16898,7 +16977,7 @@ function convertDomNode(node, key, ph) {
|
|
|
16898
16977
|
const tag = el.localName;
|
|
16899
16978
|
const idx = placeholderIndex(el, ph);
|
|
16900
16979
|
if (idx !== -1) return ph.components[idx];
|
|
16901
|
-
const
|
|
16980
|
+
const foreign = el.namespaceURI === SVG_NAMESPACE || el.namespaceURI === MATH_NAMESPACE;
|
|
16902
16981
|
const attributes = [];
|
|
16903
16982
|
let placeholders;
|
|
16904
16983
|
for (const { name, value } of Array.from(el.attributes)) {
|
|
@@ -16921,20 +17000,22 @@ function convertDomNode(node, key, ph) {
|
|
|
16921
17000
|
tag,
|
|
16922
17001
|
attributes,
|
|
16923
17002
|
placeholders,
|
|
16924
|
-
|
|
17003
|
+
foreign,
|
|
17004
|
+
math: el.namespaceURI === MATH_NAMESPACE,
|
|
16925
17005
|
children
|
|
16926
17006
|
}, key);
|
|
16927
|
-
const { props, direct } = splitAttributes(attributes,
|
|
17007
|
+
const { props, direct } = splitAttributes(attributes, foreign, tag);
|
|
16928
17008
|
if (direct.length > 0) return /* @__PURE__ */ jsx(DirectAttributes, {
|
|
16929
17009
|
tag,
|
|
16930
17010
|
props,
|
|
16931
17011
|
direct,
|
|
17012
|
+
math: el.namespaceURI === MATH_NAMESPACE,
|
|
16932
17013
|
children
|
|
16933
17014
|
}, key);
|
|
16934
|
-
return
|
|
17015
|
+
return authorElement(tag, {
|
|
16935
17016
|
...props,
|
|
16936
17017
|
key
|
|
16937
|
-
}, children);
|
|
17018
|
+
}, children, el.namespaceURI === MATH_NAMESPACE);
|
|
16938
17019
|
}
|
|
16939
17020
|
return null;
|
|
16940
17021
|
}
|
|
@@ -17043,7 +17124,7 @@ var BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
17043
17124
|
"selected"
|
|
17044
17125
|
]);
|
|
17045
17126
|
/** Names set directly on SVG elements (see splitAttributes). */
|
|
17046
|
-
var
|
|
17127
|
+
var FOREIGN_DIRECT = /* @__PURE__ */ new Set([
|
|
17047
17128
|
.../* @__PURE__ */ new Set([
|
|
17048
17129
|
"key",
|
|
17049
17130
|
"ref",
|
|
@@ -17096,18 +17177,18 @@ function isNativeDefault(tag, name) {
|
|
|
17096
17177
|
* and `className` compat rewrites (dropping an empty `class`, turning
|
|
17097
17178
|
* `className` into `class`) are set directly instead.
|
|
17098
17179
|
*/
|
|
17099
|
-
function splitAttributes(attributes,
|
|
17180
|
+
function splitAttributes(attributes, foreign, tag) {
|
|
17100
17181
|
const props = {};
|
|
17101
17182
|
const direct = [];
|
|
17102
17183
|
const defaults = [];
|
|
17103
17184
|
for (const [name, value, written, bound] of attributes) {
|
|
17104
17185
|
const lower = name.toLowerCase();
|
|
17105
17186
|
if (BOOLEAN_ATTRIBUTES.has(lower) && written !== "" && value === "") continue;
|
|
17106
|
-
else if (!
|
|
17187
|
+
else if (!foreign && LIVE_PROPERTIES.has(lower)) {
|
|
17107
17188
|
if (!bound && isNativeDefault(tag, lower)) defaults.push([name.toUpperCase(), lower === "value" ? value : ""]);
|
|
17108
17189
|
else props[lower] = lower !== "value" && written === "" ? true : value;
|
|
17109
|
-
} else if (!SETTABLE_NAME.test(name) || lower.startsWith("on") || lower === "translate" ||
|
|
17110
|
-
else props[
|
|
17190
|
+
} else if (!SETTABLE_NAME.test(name) || lower.startsWith("on") || lower === "translate" || foreign && (FOREIGN_DIRECT.has(name) || name === "__proto__")) direct.push([name, value]);
|
|
17191
|
+
else props[foreign ? name : name.toUpperCase()] = value;
|
|
17111
17192
|
}
|
|
17112
17193
|
for (const [name, value] of defaults) props[name] = value;
|
|
17113
17194
|
return {
|
|
@@ -17234,19 +17315,23 @@ function leadingPartIndex(tag, nodes) {
|
|
|
17234
17315
|
function HtmlNodeRenderer({ node }) {
|
|
17235
17316
|
const scope = useTextScope();
|
|
17236
17317
|
const { nobr, locals, raw: inRaw, inline: parentInline, structural: parentStructural } = useRenderOptions();
|
|
17237
|
-
const
|
|
17318
|
+
const parentNamespace = useContext(ForeignContext);
|
|
17238
17319
|
const tag = node.tag.toLowerCase();
|
|
17239
|
-
const
|
|
17240
|
-
const isHtmlRoot = inSvg && tag === "foreignobject";
|
|
17241
|
-
const rawContent = inRaw && !isHtmlRoot;
|
|
17242
|
-
const isRawRoot = !inRaw && (isSvgRoot || PREFORMATTED_ELEMENTS.has(tag));
|
|
17320
|
+
const namespace = tag === "svg" || tag === "math" ? tag : parentNamespace;
|
|
17243
17321
|
const errors = [];
|
|
17244
|
-
const
|
|
17322
|
+
const resolved = Object.entries(node.attributes).map(([k, v]) => [
|
|
17245
17323
|
k,
|
|
17246
17324
|
resolveAttributeValue(k, v, scope, errors),
|
|
17247
17325
|
v,
|
|
17248
17326
|
hasInterpolation(v)
|
|
17249
|
-
])
|
|
17327
|
+
]);
|
|
17328
|
+
const htmlAnnotation = namespace === "math" && tag === "annotation-xml" && isHtmlEncoding(resolved.find(([name]) => name === "encoding")?.[1]);
|
|
17329
|
+
const mathText = namespace === "math" && MATH_TEXT_ELEMENTS.has(tag);
|
|
17330
|
+
const isHtmlRoot = namespace === "svg" && tag === "foreignobject" || htmlAnnotation;
|
|
17331
|
+
const childNamespace = isHtmlRoot || mathText ? void 0 : namespace;
|
|
17332
|
+
const rawContent = inRaw && !isHtmlRoot;
|
|
17333
|
+
const isRawRoot = !inRaw && (namespace !== void 0 || PREFORMATTED_ELEMENTS.has(tag));
|
|
17334
|
+
const { props, direct } = splitAttributes(resolved, namespace !== void 0, tag);
|
|
17250
17335
|
const ref = useDirectAttributes(direct);
|
|
17251
17336
|
if (ref) props.ref = ref;
|
|
17252
17337
|
const isInline = INLINE_ELEMENTS.has(tag);
|
|
@@ -17278,18 +17363,18 @@ function HtmlNodeRenderer({ node }) {
|
|
|
17278
17363
|
});
|
|
17279
17364
|
}
|
|
17280
17365
|
}
|
|
17281
|
-
if (isHtmlRoot && children) children = /* @__PURE__ */ jsx(
|
|
17282
|
-
value:
|
|
17366
|
+
if (isHtmlRoot && children) children = /* @__PURE__ */ jsx(ForeignContext.Provider, {
|
|
17367
|
+
value: void 0,
|
|
17283
17368
|
children: /* @__PURE__ */ jsx(RawTextContext.Provider, {
|
|
17284
17369
|
value: false,
|
|
17285
17370
|
children
|
|
17286
17371
|
})
|
|
17287
17372
|
});
|
|
17288
|
-
|
|
17289
|
-
|
|
17290
|
-
|
|
17291
|
-
children: element
|
|
17373
|
+
if (childNamespace !== parentNamespace) children = /* @__PURE__ */ jsx(ForeignContext.Provider, {
|
|
17374
|
+
value: childNamespace,
|
|
17375
|
+
children
|
|
17292
17376
|
});
|
|
17377
|
+
const element = authorElement(node.tag, props, children, namespace === "math");
|
|
17293
17378
|
return withAttributeErrors(errors, isRawRoot ? /* @__PURE__ */ jsx(RawTextContext.Provider, {
|
|
17294
17379
|
value: true,
|
|
17295
17380
|
children: element
|
package/dist/pkg/play.js
CHANGED
|
@@ -283,9 +283,10 @@ function openPlaySessionWith(options, urls) {
|
|
|
283
283
|
reject(/* @__PURE__ */ new Error(CLOSED_MESSAGE));
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
|
+
const snapshot = structuredClone(args);
|
|
286
287
|
queue.push({
|
|
287
288
|
op,
|
|
288
|
-
args,
|
|
289
|
+
args: snapshot,
|
|
289
290
|
resolve,
|
|
290
291
|
reject
|
|
291
292
|
});
|