@constela/runtime 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +56 -9
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2421,12 +2421,12 @@ function createDOMPurify() {
|
|
|
2421
2421
|
let URI_SAFE_ATTRIBUTES = null;
|
|
2422
2422
|
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
|
|
2423
2423
|
const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
2424
|
-
const
|
|
2424
|
+
const SVG_NAMESPACE2 = "http://www.w3.org/2000/svg";
|
|
2425
2425
|
const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
2426
2426
|
let NAMESPACE = HTML_NAMESPACE;
|
|
2427
2427
|
let IS_EMPTY_INPUT = false;
|
|
2428
2428
|
let ALLOWED_NAMESPACES = null;
|
|
2429
|
-
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE,
|
|
2429
|
+
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE2, HTML_NAMESPACE], stringToString);
|
|
2430
2430
|
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
|
|
2431
2431
|
let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
|
|
2432
2432
|
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
|
|
@@ -2600,7 +2600,7 @@ function createDOMPurify() {
|
|
|
2600
2600
|
if (!ALLOWED_NAMESPACES[element2.namespaceURI]) {
|
|
2601
2601
|
return false;
|
|
2602
2602
|
}
|
|
2603
|
-
if (element2.namespaceURI ===
|
|
2603
|
+
if (element2.namespaceURI === SVG_NAMESPACE2) {
|
|
2604
2604
|
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
2605
2605
|
return tagName === "svg";
|
|
2606
2606
|
}
|
|
@@ -2613,13 +2613,13 @@ function createDOMPurify() {
|
|
|
2613
2613
|
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
2614
2614
|
return tagName === "math";
|
|
2615
2615
|
}
|
|
2616
|
-
if (parent.namespaceURI ===
|
|
2616
|
+
if (parent.namespaceURI === SVG_NAMESPACE2) {
|
|
2617
2617
|
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
2618
2618
|
}
|
|
2619
2619
|
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
2620
2620
|
}
|
|
2621
2621
|
if (element2.namespaceURI === HTML_NAMESPACE) {
|
|
2622
|
-
if (parent.namespaceURI ===
|
|
2622
|
+
if (parent.namespaceURI === SVG_NAMESPACE2 && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
2623
2623
|
return false;
|
|
2624
2624
|
}
|
|
2625
2625
|
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
@@ -12831,6 +12831,40 @@ async function highlightCode(code, language) {
|
|
|
12831
12831
|
}
|
|
12832
12832
|
|
|
12833
12833
|
// src/renderer/index.ts
|
|
12834
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
12835
|
+
var SVG_TAGS = /* @__PURE__ */ new Set([
|
|
12836
|
+
"svg",
|
|
12837
|
+
"path",
|
|
12838
|
+
"line",
|
|
12839
|
+
"circle",
|
|
12840
|
+
"rect",
|
|
12841
|
+
"ellipse",
|
|
12842
|
+
"polyline",
|
|
12843
|
+
"polygon",
|
|
12844
|
+
"g",
|
|
12845
|
+
"defs",
|
|
12846
|
+
"use",
|
|
12847
|
+
"text",
|
|
12848
|
+
"tspan",
|
|
12849
|
+
"clipPath",
|
|
12850
|
+
"mask",
|
|
12851
|
+
"linearGradient",
|
|
12852
|
+
"radialGradient",
|
|
12853
|
+
"stop",
|
|
12854
|
+
"pattern",
|
|
12855
|
+
"symbol",
|
|
12856
|
+
"marker",
|
|
12857
|
+
"image",
|
|
12858
|
+
"filter",
|
|
12859
|
+
"foreignObject",
|
|
12860
|
+
"animate",
|
|
12861
|
+
"animateTransform",
|
|
12862
|
+
"desc",
|
|
12863
|
+
"title"
|
|
12864
|
+
]);
|
|
12865
|
+
function isSvgTag(tag) {
|
|
12866
|
+
return SVG_TAGS.has(tag);
|
|
12867
|
+
}
|
|
12834
12868
|
function isEventHandler(value) {
|
|
12835
12869
|
return typeof value === "object" && value !== null && "event" in value && "action" in value;
|
|
12836
12870
|
}
|
|
@@ -12853,7 +12887,10 @@ function render(node, ctx) {
|
|
|
12853
12887
|
}
|
|
12854
12888
|
}
|
|
12855
12889
|
function renderElement(node, ctx) {
|
|
12856
|
-
const
|
|
12890
|
+
const tag = node.tag;
|
|
12891
|
+
const inSvgContext = ctx.inSvg || tag === "svg";
|
|
12892
|
+
const useSvgNamespace = inSvgContext && isSvgTag(tag);
|
|
12893
|
+
const el = useSvgNamespace ? document.createElementNS(SVG_NAMESPACE, tag) : document.createElement(tag);
|
|
12857
12894
|
if (node.ref && ctx.refs) {
|
|
12858
12895
|
if (typeof process !== "undefined" && process.env?.["NODE_ENV"] !== "production" && ctx.refs[node.ref]) {
|
|
12859
12896
|
console.warn(`Duplicate ref name "${node.ref}" detected. The later element will overwrite the earlier one.`);
|
|
@@ -12896,21 +12933,31 @@ function renderElement(node, ctx) {
|
|
|
12896
12933
|
} else {
|
|
12897
12934
|
const cleanup = createEffect(() => {
|
|
12898
12935
|
const value = evaluate(propValue, { state: ctx.state, locals: ctx.locals, ...ctx.imports && { imports: ctx.imports } });
|
|
12899
|
-
applyProp(el, propName, value);
|
|
12936
|
+
applyProp(el, propName, value, useSvgNamespace);
|
|
12900
12937
|
});
|
|
12901
12938
|
ctx.cleanups?.push(cleanup);
|
|
12902
12939
|
}
|
|
12903
12940
|
}
|
|
12904
12941
|
}
|
|
12905
12942
|
if (node.children) {
|
|
12943
|
+
const childInSvg = tag === "foreignObject" ? false : inSvgContext;
|
|
12944
|
+
const childCtx = childInSvg !== ctx.inSvg ? { ...ctx, inSvg: childInSvg } : ctx;
|
|
12906
12945
|
for (const child of node.children) {
|
|
12907
|
-
const childNode = render(child,
|
|
12946
|
+
const childNode = render(child, childCtx);
|
|
12908
12947
|
el.appendChild(childNode);
|
|
12909
12948
|
}
|
|
12910
12949
|
}
|
|
12911
12950
|
return el;
|
|
12912
12951
|
}
|
|
12913
|
-
function applyProp(el, propName, value) {
|
|
12952
|
+
function applyProp(el, propName, value, isSvg = false) {
|
|
12953
|
+
if (isSvg && propName === "className") {
|
|
12954
|
+
if (value) {
|
|
12955
|
+
el.setAttribute("class", String(value));
|
|
12956
|
+
} else {
|
|
12957
|
+
el.removeAttribute("class");
|
|
12958
|
+
}
|
|
12959
|
+
return;
|
|
12960
|
+
}
|
|
12914
12961
|
if (propName === "className") {
|
|
12915
12962
|
el.className = String(value ?? "");
|
|
12916
12963
|
} else if (propName === "style" && typeof value === "string") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/runtime",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "Runtime DOM renderer for Constela UI framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"dompurify": "^3.3.1",
|
|
19
19
|
"marked": "^17.0.1",
|
|
20
20
|
"shiki": "^3.20.0",
|
|
21
|
-
"@constela/
|
|
22
|
-
"@constela/
|
|
21
|
+
"@constela/compiler": "0.7.1",
|
|
22
|
+
"@constela/core": "0.7.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/dompurify": "^3.2.0",
|