marko 6.1.24 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/helpers.d.ts +1 -0
- package/dist/debug/dom.js +59 -2
- package/dist/debug/dom.mjs +57 -3
- package/dist/debug/html.js +38 -11
- package/dist/debug/html.mjs +35 -12
- package/dist/dom/control-flow.d.ts +1 -0
- package/dist/dom/dom.d.ts +2 -0
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +34 -1
- package/dist/dom.mjs +34 -1
- package/dist/html/attrs.d.ts +1 -0
- package/dist/html/content.d.ts +1 -0
- package/dist/html/inlined-runtimes.d.ts +1 -1
- package/dist/html/inlined-runtimes.debug.d.ts +1 -1
- package/dist/html/writer.d.ts +2 -0
- package/dist/html.d.ts +3 -3
- package/dist/html.js +25 -6
- package/dist/html.mjs +25 -6
- package/dist/translator/core/index.d.ts +1 -0
- package/dist/translator/core/show.d.ts +17 -0
- package/dist/translator/core/style.d.ts +6 -0
- package/dist/translator/index.d.ts +1 -0
- package/dist/translator/index.js +400 -42
- package/dist/translator/util/style-interpolation.d.ts +3 -0
- package/package.json +1 -1
package/dist/common/helpers.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare function getWrongAttrSuggestion(name: string): string | undefined
|
|
|
4
4
|
export declare function _call<T>(fn: (v: T) => unknown, v: T): T;
|
|
5
5
|
export declare function stringifyClassObject(name: string, value: unknown): string;
|
|
6
6
|
export declare function stringifyStyleObject(name: string, value: unknown): string;
|
|
7
|
+
export declare function escapeStyleValue(str: string): string;
|
|
7
8
|
export declare const toDelimitedString: (val: unknown, delimiter: string, stringify: (n: string, v: unknown) => string | undefined) => string;
|
|
8
9
|
export declare function isEventHandler(name: string): name is `on${string}`;
|
|
9
10
|
export declare function getEventHandlerName(name: `on${string}`): string;
|
package/dist/debug/dom.js
CHANGED
|
@@ -71,6 +71,14 @@ function stringifyClassObject(name, value) {
|
|
|
71
71
|
function stringifyStyleObject(name, value) {
|
|
72
72
|
return value || value === 0 ? name + ":" + value : "";
|
|
73
73
|
}
|
|
74
|
+
function escapeStyleValue(str) {
|
|
75
|
+
let closers = "";
|
|
76
|
+
const result = str.replace(/[\\"'{};>]|\/(?=\*)/g, "\\$&").replace(/</g, "\\3C ");
|
|
77
|
+
for (const c of result) if (c === "(") closers = ")" + closers;
|
|
78
|
+
else if (c === "[") closers = "]" + closers;
|
|
79
|
+
else if (c === closers[0]) closers = closers.slice(1);
|
|
80
|
+
return result + closers;
|
|
81
|
+
}
|
|
74
82
|
const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
|
|
75
83
|
let str = "";
|
|
76
84
|
let sep = "";
|
|
@@ -1175,6 +1183,24 @@ function _attr_style_items(element, items) {
|
|
|
1175
1183
|
function _attr_style_item(element, name, value) {
|
|
1176
1184
|
element.style.setProperty(name, _to_text(value));
|
|
1177
1185
|
}
|
|
1186
|
+
function _style_shell(scope, nodeAccessor) {
|
|
1187
|
+
const element = scope[nodeAccessor];
|
|
1188
|
+
const id = _id(scope);
|
|
1189
|
+
element.className = id;
|
|
1190
|
+
_text_content(element, "." + id + " ~ *{}");
|
|
1191
|
+
}
|
|
1192
|
+
function _style_rule_item(element, name, value) {
|
|
1193
|
+
const text = element.textContent;
|
|
1194
|
+
const decl = name + ":" + escapeStyleValue(_to_text(value)) + ";";
|
|
1195
|
+
let start = text.indexOf("{" + name + ":");
|
|
1196
|
+
if (start === -1) start = text.indexOf(";" + name + ":");
|
|
1197
|
+
if (start === -1) element.textContent = text.slice(0, -1) + decl + "}";
|
|
1198
|
+
else {
|
|
1199
|
+
let end = ++start;
|
|
1200
|
+
for (let c; (c = text[end]) && c !== ";"; end++) if (c === "\\") end++;
|
|
1201
|
+
element.textContent = text.slice(0, start) + decl + text.slice(end + 1);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1178
1204
|
function _attr_nonce(scope, nodeAccessor) {
|
|
1179
1205
|
_attr(scope[nodeAccessor], "nonce", scope["$global"].cspNonce);
|
|
1180
1206
|
}
|
|
@@ -1546,6 +1572,34 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
1546
1572
|
if (newBranch !== (scope[branchAccessor] ?? (scope["BranchScopes:" + nodeAccessor] && 0))) setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
1547
1573
|
};
|
|
1548
1574
|
}
|
|
1575
|
+
function _show(nodeAccessor, startNodeAccessor) {
|
|
1576
|
+
const rangeAccessor = "BranchScopes:" + nodeAccessor;
|
|
1577
|
+
enableBranches();
|
|
1578
|
+
return (scope, display) => {
|
|
1579
|
+
const referenceNode = scope[nodeAccessor];
|
|
1580
|
+
const onlyChild = referenceNode.nodeType === 1;
|
|
1581
|
+
const parentNode = onlyChild ? referenceNode : referenceNode.parentNode;
|
|
1582
|
+
let range = scope[rangeAccessor];
|
|
1583
|
+
if (!range) {
|
|
1584
|
+
range = scope[rangeAccessor] = {};
|
|
1585
|
+
range["#StartNode"] = onlyChild ? parentNode.firstChild : scope[startNodeAccessor];
|
|
1586
|
+
range["#EndNode"] = onlyChild ? parentNode.lastChild : referenceNode.previousSibling;
|
|
1587
|
+
}
|
|
1588
|
+
let startNode = range["#StartNode"];
|
|
1589
|
+
if (range["#Id"] && startNode === range["#EndNode"] && startNode.tagName === "T") {
|
|
1590
|
+
const wrapper = startNode;
|
|
1591
|
+
if (!wrapper.firstChild) wrapper.appendChild(new Text());
|
|
1592
|
+
range = scope[rangeAccessor] = {};
|
|
1593
|
+
range["#StartNode"] = startNode = wrapper.firstChild;
|
|
1594
|
+
range["#EndNode"] = wrapper.lastChild;
|
|
1595
|
+
wrapper.replaceWith(...wrapper.childNodes);
|
|
1596
|
+
}
|
|
1597
|
+
const inDom = startNode.parentNode === parentNode;
|
|
1598
|
+
if (display) {
|
|
1599
|
+
if (!inDom) insertBranchBefore(range, parentNode, onlyChild ? null : referenceNode);
|
|
1600
|
+
} else if (inDom) tempDetachBranch(range);
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1549
1603
|
function patchDynamicTag(fn) {
|
|
1550
1604
|
_dynamic_tag = fn(_dynamic_tag);
|
|
1551
1605
|
}
|
|
@@ -2017,8 +2071,8 @@ function mount(input = {}, reference, position) {
|
|
|
2017
2071
|
renderId: "_",
|
|
2018
2072
|
...$global
|
|
2019
2073
|
};
|
|
2020
|
-
if (!String($global.runtimeId).match(/^[
|
|
2021
|
-
if (!String($global.renderId).match(/^[
|
|
2074
|
+
if (!String($global.runtimeId).match(/^[_a-z][_a-z0-9]*$/i)) throw new Error(`Invalid runtimeId: "${$global.runtimeId}". The runtimeId must start with a letter or underscore and only contain letters, numbers, and underscores.`);
|
|
2075
|
+
if (!String($global.renderId).match(/^[_a-z][_a-z0-9]*$/i)) throw new Error(`Invalid renderId: "${$global.renderId}". The renderId must start with a letter or underscore and only contain letters, numbers, and underscores.`);
|
|
2022
2076
|
} else $global = {
|
|
2023
2077
|
runtimeId: "M",
|
|
2024
2078
|
renderId: "_"
|
|
@@ -2253,6 +2307,9 @@ exports._resume_dynamic_tag = _resume_dynamic_tag;
|
|
|
2253
2307
|
exports._return = _return;
|
|
2254
2308
|
exports._return_change = _return_change;
|
|
2255
2309
|
exports._script = _script;
|
|
2310
|
+
exports._show = _show;
|
|
2311
|
+
exports._style_rule_item = _style_rule_item;
|
|
2312
|
+
exports._style_shell = _style_shell;
|
|
2256
2313
|
exports._template = _template;
|
|
2257
2314
|
exports._text = _text;
|
|
2258
2315
|
exports._text_content = _text_content;
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -69,6 +69,14 @@ function stringifyClassObject(name, value) {
|
|
|
69
69
|
function stringifyStyleObject(name, value) {
|
|
70
70
|
return value || value === 0 ? name + ":" + value : "";
|
|
71
71
|
}
|
|
72
|
+
function escapeStyleValue(str) {
|
|
73
|
+
let closers = "";
|
|
74
|
+
const result = str.replace(/[\\"'{};>]|\/(?=\*)/g, "\\$&").replace(/</g, "\\3C ");
|
|
75
|
+
for (const c of result) if (c === "(") closers = ")" + closers;
|
|
76
|
+
else if (c === "[") closers = "]" + closers;
|
|
77
|
+
else if (c === closers[0]) closers = closers.slice(1);
|
|
78
|
+
return result + closers;
|
|
79
|
+
}
|
|
72
80
|
const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
|
|
73
81
|
let str = "";
|
|
74
82
|
let sep = "";
|
|
@@ -1173,6 +1181,24 @@ function _attr_style_items(element, items) {
|
|
|
1173
1181
|
function _attr_style_item(element, name, value) {
|
|
1174
1182
|
element.style.setProperty(name, _to_text(value));
|
|
1175
1183
|
}
|
|
1184
|
+
function _style_shell(scope, nodeAccessor) {
|
|
1185
|
+
const element = scope[nodeAccessor];
|
|
1186
|
+
const id = _id(scope);
|
|
1187
|
+
element.className = id;
|
|
1188
|
+
_text_content(element, "." + id + " ~ *{}");
|
|
1189
|
+
}
|
|
1190
|
+
function _style_rule_item(element, name, value) {
|
|
1191
|
+
const text = element.textContent;
|
|
1192
|
+
const decl = name + ":" + escapeStyleValue(_to_text(value)) + ";";
|
|
1193
|
+
let start = text.indexOf("{" + name + ":");
|
|
1194
|
+
if (start === -1) start = text.indexOf(";" + name + ":");
|
|
1195
|
+
if (start === -1) element.textContent = text.slice(0, -1) + decl + "}";
|
|
1196
|
+
else {
|
|
1197
|
+
let end = ++start;
|
|
1198
|
+
for (let c; (c = text[end]) && c !== ";"; end++) if (c === "\\") end++;
|
|
1199
|
+
element.textContent = text.slice(0, start) + decl + text.slice(end + 1);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1176
1202
|
function _attr_nonce(scope, nodeAccessor) {
|
|
1177
1203
|
_attr(scope[nodeAccessor], "nonce", scope["$global"].cspNonce);
|
|
1178
1204
|
}
|
|
@@ -1544,6 +1570,34 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
1544
1570
|
if (newBranch !== (scope[branchAccessor] ?? (scope["BranchScopes:" + nodeAccessor] && 0))) setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
1545
1571
|
};
|
|
1546
1572
|
}
|
|
1573
|
+
function _show(nodeAccessor, startNodeAccessor) {
|
|
1574
|
+
const rangeAccessor = "BranchScopes:" + nodeAccessor;
|
|
1575
|
+
enableBranches();
|
|
1576
|
+
return (scope, display) => {
|
|
1577
|
+
const referenceNode = scope[nodeAccessor];
|
|
1578
|
+
const onlyChild = referenceNode.nodeType === 1;
|
|
1579
|
+
const parentNode = onlyChild ? referenceNode : referenceNode.parentNode;
|
|
1580
|
+
let range = scope[rangeAccessor];
|
|
1581
|
+
if (!range) {
|
|
1582
|
+
range = scope[rangeAccessor] = {};
|
|
1583
|
+
range["#StartNode"] = onlyChild ? parentNode.firstChild : scope[startNodeAccessor];
|
|
1584
|
+
range["#EndNode"] = onlyChild ? parentNode.lastChild : referenceNode.previousSibling;
|
|
1585
|
+
}
|
|
1586
|
+
let startNode = range["#StartNode"];
|
|
1587
|
+
if (range["#Id"] && startNode === range["#EndNode"] && startNode.tagName === "T") {
|
|
1588
|
+
const wrapper = startNode;
|
|
1589
|
+
if (!wrapper.firstChild) wrapper.appendChild(new Text());
|
|
1590
|
+
range = scope[rangeAccessor] = {};
|
|
1591
|
+
range["#StartNode"] = startNode = wrapper.firstChild;
|
|
1592
|
+
range["#EndNode"] = wrapper.lastChild;
|
|
1593
|
+
wrapper.replaceWith(...wrapper.childNodes);
|
|
1594
|
+
}
|
|
1595
|
+
const inDom = startNode.parentNode === parentNode;
|
|
1596
|
+
if (display) {
|
|
1597
|
+
if (!inDom) insertBranchBefore(range, parentNode, onlyChild ? null : referenceNode);
|
|
1598
|
+
} else if (inDom) tempDetachBranch(range);
|
|
1599
|
+
};
|
|
1600
|
+
}
|
|
1547
1601
|
function patchDynamicTag(fn) {
|
|
1548
1602
|
_dynamic_tag = fn(_dynamic_tag);
|
|
1549
1603
|
}
|
|
@@ -2015,8 +2069,8 @@ function mount(input = {}, reference, position) {
|
|
|
2015
2069
|
renderId: "_",
|
|
2016
2070
|
...$global
|
|
2017
2071
|
};
|
|
2018
|
-
if (!String($global.runtimeId).match(/^[
|
|
2019
|
-
if (!String($global.renderId).match(/^[
|
|
2072
|
+
if (!String($global.runtimeId).match(/^[_a-z][_a-z0-9]*$/i)) throw new Error(`Invalid runtimeId: "${$global.runtimeId}". The runtimeId must start with a letter or underscore and only contain letters, numbers, and underscores.`);
|
|
2073
|
+
if (!String($global.renderId).match(/^[_a-z][_a-z0-9]*$/i)) throw new Error(`Invalid renderId: "${$global.renderId}". The renderId must start with a letter or underscore and only contain letters, numbers, and underscores.`);
|
|
2020
2074
|
} else $global = {
|
|
2021
2075
|
runtimeId: "M",
|
|
2022
2076
|
renderId: "_"
|
|
@@ -2162,4 +2216,4 @@ function getSelectorOrResolve(selector, resolve) {
|
|
|
2162
2216
|
return document.querySelector(selector) || (console.warn(`A lazy load trigger could not find an element matching "${selector}". The module was loaded immediately.`), resolve());
|
|
2163
2217
|
}
|
|
2164
2218
|
//#endregion
|
|
2165
|
-
export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _enable_catch, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };
|
|
2219
|
+
export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _enable_catch, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };
|
package/dist/debug/html.js
CHANGED
|
@@ -67,6 +67,14 @@ function stringifyClassObject(name, value) {
|
|
|
67
67
|
function stringifyStyleObject(name, value) {
|
|
68
68
|
return value || value === 0 ? name + ":" + value : "";
|
|
69
69
|
}
|
|
70
|
+
function escapeStyleValue(str) {
|
|
71
|
+
let closers = "";
|
|
72
|
+
const result = str.replace(/[\\"'{};>]|\/(?=\*)/g, "\\$&").replace(/</g, "\\3C ");
|
|
73
|
+
for (const c of result) if (c === "(") closers = ")" + closers;
|
|
74
|
+
else if (c === "[") closers = "]" + closers;
|
|
75
|
+
else if (c === closers[0]) closers = closers.slice(1);
|
|
76
|
+
return result + closers;
|
|
77
|
+
}
|
|
70
78
|
const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
|
|
71
79
|
let str = "";
|
|
72
80
|
let sep = "";
|
|
@@ -227,6 +235,10 @@ function _escape_style(val) {
|
|
|
227
235
|
assertValidTextValue(val);
|
|
228
236
|
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
|
229
237
|
}
|
|
238
|
+
function _escape_style_value(val) {
|
|
239
|
+
assertValidTextValue(val);
|
|
240
|
+
return val || val === 0 ? escapeStyleValue(val + "") : "";
|
|
241
|
+
}
|
|
230
242
|
const unsafeCommentReg = />/g;
|
|
231
243
|
const escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, ">") : str;
|
|
232
244
|
function _escape_comment(val) {
|
|
@@ -1549,9 +1561,6 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
|
|
|
1549
1561
|
nextSibling,
|
|
1550
1562
|
placeholders = runtime.p = {},
|
|
1551
1563
|
replace = (id, container) => runtime.l[id].replaceWith(...container.childNodes);
|
|
1552
|
-
runtime.d.head.append(
|
|
1553
|
-
runtime.d.querySelector("style[" + runtime.i + "]") || ""
|
|
1554
|
-
);
|
|
1555
1564
|
runtime.j = {};
|
|
1556
1565
|
runtime.x = (op, id, node, placeholderRoot, placeholderCb) => {
|
|
1557
1566
|
if (node == nextSibling) {
|
|
@@ -1836,6 +1845,17 @@ function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, p
|
|
|
1836
1845
|
} else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
1837
1846
|
else $chunk.writeHTML(endTag);
|
|
1838
1847
|
}
|
|
1848
|
+
function _show_start(display, mark) {
|
|
1849
|
+
if (display) {
|
|
1850
|
+
if (mark) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
1851
|
+
} else $chunk.writeHTML("<t hidden>");
|
|
1852
|
+
}
|
|
1853
|
+
function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1854
|
+
const branchId = _scope_id();
|
|
1855
|
+
const wrap = !display;
|
|
1856
|
+
if (wrap) $chunk.writeHTML("</t>");
|
|
1857
|
+
writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
1858
|
+
}
|
|
1839
1859
|
let writeScope = (scopeId, partialScope) => {
|
|
1840
1860
|
const { state } = $chunk.boundary;
|
|
1841
1861
|
const target = $chunk.serializeState;
|
|
@@ -2240,7 +2260,7 @@ var Chunk = class Chunk {
|
|
|
2240
2260
|
flushScript() {
|
|
2241
2261
|
const { boundary } = this;
|
|
2242
2262
|
const { state } = boundary;
|
|
2243
|
-
const { $global, runtimePrefix
|
|
2263
|
+
const { $global, runtimePrefix } = state;
|
|
2244
2264
|
let needsWalk = state.walkOnNextFlush;
|
|
2245
2265
|
if (needsWalk) state.walkOnNextFlush = false;
|
|
2246
2266
|
let readyResumeScripts = this.flushReadyScripts();
|
|
@@ -2271,7 +2291,6 @@ var Chunk = class Chunk {
|
|
|
2271
2291
|
needsWalk = true;
|
|
2272
2292
|
if (!state.hasReorderRuntime) {
|
|
2273
2293
|
state.hasReorderRuntime = true;
|
|
2274
|
-
html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>";
|
|
2275
2294
|
scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
|
|
2276
2295
|
}
|
|
2277
2296
|
for (const reorderedChunk of state.writeReorders) {
|
|
@@ -2308,7 +2327,7 @@ var Chunk = class Chunk {
|
|
|
2308
2327
|
}
|
|
2309
2328
|
for (const reservation of readyReservations) scripts = concatScripts(scripts, reservation);
|
|
2310
2329
|
scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
|
|
2311
|
-
html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
2330
|
+
html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
2312
2331
|
}
|
|
2313
2332
|
state.writeReorders = null;
|
|
2314
2333
|
}
|
|
@@ -2523,6 +2542,10 @@ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, s
|
|
|
2523
2542
|
function _attr_nonce() {
|
|
2524
2543
|
return getChunk().boundary.state.nonceAttr;
|
|
2525
2544
|
}
|
|
2545
|
+
function _style_html(decls) {
|
|
2546
|
+
const id = _id();
|
|
2547
|
+
return `<style${_attr_nonce()} class=${id}>.${id} ~ *{${decls}}</style>`;
|
|
2548
|
+
}
|
|
2526
2549
|
function _attr(name, value) {
|
|
2527
2550
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
2528
2551
|
}
|
|
@@ -2758,8 +2781,8 @@ function render(input = {}) {
|
|
|
2758
2781
|
renderId: getDefaultRenderId(this),
|
|
2759
2782
|
...$global
|
|
2760
2783
|
};
|
|
2761
|
-
if (!String($global.runtimeId).match(/^[
|
|
2762
|
-
if (!String($global.renderId).match(/^[
|
|
2784
|
+
if (!String($global.runtimeId).match(/^[_a-z][_a-z0-9]*$/i)) throw new Error(`Invalid runtimeId: "${$global.runtimeId}". The runtimeId must start with a letter or underscore and only contain letters, numbers, and underscores.`);
|
|
2785
|
+
if (!String($global.renderId).match(/^[_a-z][_a-z0-9]*$/i)) throw new Error(`Invalid renderId: "${$global.renderId}". The renderId must start with a letter or underscore and only contain letters, numbers, and underscores.`);
|
|
2763
2786
|
} else $global = {
|
|
2764
2787
|
runtimeId: "M",
|
|
2765
2788
|
renderId: getDefaultRenderId(this)
|
|
@@ -2772,10 +2795,10 @@ function render(input = {}) {
|
|
|
2772
2795
|
}
|
|
2773
2796
|
function getDefaultRenderId(template) {
|
|
2774
2797
|
if (template["embed"]) {
|
|
2775
|
-
const ENCODE_CHARS = "
|
|
2798
|
+
const ENCODE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
2776
2799
|
let n = Math.random() * 4294967296 >>> 0;
|
|
2777
|
-
let r = ENCODE_CHARS[n %
|
|
2778
|
-
for (n = n /
|
|
2800
|
+
let r = ENCODE_CHARS[n % 52];
|
|
2801
|
+
for (n = n / 52 | 0; n; n = n / 63 | 0) r += ENCODE_CHARS[n % 63];
|
|
2779
2802
|
return r;
|
|
2780
2803
|
}
|
|
2781
2804
|
return "_";
|
|
@@ -3197,6 +3220,7 @@ exports._escape = _escape;
|
|
|
3197
3220
|
exports._escape_comment = _escape_comment;
|
|
3198
3221
|
exports._escape_script = _escape_script;
|
|
3199
3222
|
exports._escape_style = _escape_style;
|
|
3223
|
+
exports._escape_style_value = _escape_style_value;
|
|
3200
3224
|
exports._existing_scope = _existing_scope;
|
|
3201
3225
|
exports._flush_head = _flush_head;
|
|
3202
3226
|
exports._for_in = _for_in;
|
|
@@ -3225,6 +3249,9 @@ exports._sep = _sep;
|
|
|
3225
3249
|
exports._serialize_guard = _serialize_guard;
|
|
3226
3250
|
exports._serialize_if = _serialize_if;
|
|
3227
3251
|
exports._set_serialize_reason = _set_serialize_reason;
|
|
3252
|
+
exports._show_end = _show_end;
|
|
3253
|
+
exports._show_start = _show_start;
|
|
3254
|
+
exports._style_html = _style_html;
|
|
3228
3255
|
exports._subscribe = _subscribe;
|
|
3229
3256
|
exports._template = _template;
|
|
3230
3257
|
exports._to_text = _to_text;
|
package/dist/debug/html.mjs
CHANGED
|
@@ -65,6 +65,14 @@ function stringifyClassObject(name, value) {
|
|
|
65
65
|
function stringifyStyleObject(name, value) {
|
|
66
66
|
return value || value === 0 ? name + ":" + value : "";
|
|
67
67
|
}
|
|
68
|
+
function escapeStyleValue(str) {
|
|
69
|
+
let closers = "";
|
|
70
|
+
const result = str.replace(/[\\"'{};>]|\/(?=\*)/g, "\\$&").replace(/</g, "\\3C ");
|
|
71
|
+
for (const c of result) if (c === "(") closers = ")" + closers;
|
|
72
|
+
else if (c === "[") closers = "]" + closers;
|
|
73
|
+
else if (c === closers[0]) closers = closers.slice(1);
|
|
74
|
+
return result + closers;
|
|
75
|
+
}
|
|
68
76
|
const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
|
|
69
77
|
let str = "";
|
|
70
78
|
let sep = "";
|
|
@@ -225,6 +233,10 @@ function _escape_style(val) {
|
|
|
225
233
|
assertValidTextValue(val);
|
|
226
234
|
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
|
227
235
|
}
|
|
236
|
+
function _escape_style_value(val) {
|
|
237
|
+
assertValidTextValue(val);
|
|
238
|
+
return val || val === 0 ? escapeStyleValue(val + "") : "";
|
|
239
|
+
}
|
|
228
240
|
const unsafeCommentReg = />/g;
|
|
229
241
|
const escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, ">") : str;
|
|
230
242
|
function _escape_comment(val) {
|
|
@@ -1547,9 +1559,6 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
|
|
|
1547
1559
|
nextSibling,
|
|
1548
1560
|
placeholders = runtime.p = {},
|
|
1549
1561
|
replace = (id, container) => runtime.l[id].replaceWith(...container.childNodes);
|
|
1550
|
-
runtime.d.head.append(
|
|
1551
|
-
runtime.d.querySelector("style[" + runtime.i + "]") || ""
|
|
1552
|
-
);
|
|
1553
1562
|
runtime.j = {};
|
|
1554
1563
|
runtime.x = (op, id, node, placeholderRoot, placeholderCb) => {
|
|
1555
1564
|
if (node == nextSibling) {
|
|
@@ -1834,6 +1843,17 @@ function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, p
|
|
|
1834
1843
|
} else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
1835
1844
|
else $chunk.writeHTML(endTag);
|
|
1836
1845
|
}
|
|
1846
|
+
function _show_start(display, mark) {
|
|
1847
|
+
if (display) {
|
|
1848
|
+
if (mark) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
1849
|
+
} else $chunk.writeHTML("<t hidden>");
|
|
1850
|
+
}
|
|
1851
|
+
function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1852
|
+
const branchId = _scope_id();
|
|
1853
|
+
const wrap = !display;
|
|
1854
|
+
if (wrap) $chunk.writeHTML("</t>");
|
|
1855
|
+
writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
1856
|
+
}
|
|
1837
1857
|
let writeScope = (scopeId, partialScope) => {
|
|
1838
1858
|
const { state } = $chunk.boundary;
|
|
1839
1859
|
const target = $chunk.serializeState;
|
|
@@ -2238,7 +2258,7 @@ var Chunk = class Chunk {
|
|
|
2238
2258
|
flushScript() {
|
|
2239
2259
|
const { boundary } = this;
|
|
2240
2260
|
const { state } = boundary;
|
|
2241
|
-
const { $global, runtimePrefix
|
|
2261
|
+
const { $global, runtimePrefix } = state;
|
|
2242
2262
|
let needsWalk = state.walkOnNextFlush;
|
|
2243
2263
|
if (needsWalk) state.walkOnNextFlush = false;
|
|
2244
2264
|
let readyResumeScripts = this.flushReadyScripts();
|
|
@@ -2269,7 +2289,6 @@ var Chunk = class Chunk {
|
|
|
2269
2289
|
needsWalk = true;
|
|
2270
2290
|
if (!state.hasReorderRuntime) {
|
|
2271
2291
|
state.hasReorderRuntime = true;
|
|
2272
|
-
html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>";
|
|
2273
2292
|
scripts = concatScripts(scripts, REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")");
|
|
2274
2293
|
}
|
|
2275
2294
|
for (const reorderedChunk of state.writeReorders) {
|
|
@@ -2306,7 +2325,7 @@ var Chunk = class Chunk {
|
|
|
2306
2325
|
}
|
|
2307
2326
|
for (const reservation of readyReservations) scripts = concatScripts(scripts, reservation);
|
|
2308
2327
|
scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
|
|
2309
|
-
html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
2328
|
+
html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
2310
2329
|
}
|
|
2311
2330
|
state.writeReorders = null;
|
|
2312
2331
|
}
|
|
@@ -2521,6 +2540,10 @@ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, s
|
|
|
2521
2540
|
function _attr_nonce() {
|
|
2522
2541
|
return getChunk().boundary.state.nonceAttr;
|
|
2523
2542
|
}
|
|
2543
|
+
function _style_html(decls) {
|
|
2544
|
+
const id = _id();
|
|
2545
|
+
return `<style${_attr_nonce()} class=${id}>.${id} ~ *{${decls}}</style>`;
|
|
2546
|
+
}
|
|
2524
2547
|
function _attr(name, value) {
|
|
2525
2548
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
2526
2549
|
}
|
|
@@ -2756,8 +2779,8 @@ function render(input = {}) {
|
|
|
2756
2779
|
renderId: getDefaultRenderId(this),
|
|
2757
2780
|
...$global
|
|
2758
2781
|
};
|
|
2759
|
-
if (!String($global.runtimeId).match(/^[
|
|
2760
|
-
if (!String($global.renderId).match(/^[
|
|
2782
|
+
if (!String($global.runtimeId).match(/^[_a-z][_a-z0-9]*$/i)) throw new Error(`Invalid runtimeId: "${$global.runtimeId}". The runtimeId must start with a letter or underscore and only contain letters, numbers, and underscores.`);
|
|
2783
|
+
if (!String($global.renderId).match(/^[_a-z][_a-z0-9]*$/i)) throw new Error(`Invalid renderId: "${$global.renderId}". The renderId must start with a letter or underscore and only contain letters, numbers, and underscores.`);
|
|
2761
2784
|
} else $global = {
|
|
2762
2785
|
runtimeId: "M",
|
|
2763
2786
|
renderId: getDefaultRenderId(this)
|
|
@@ -2770,10 +2793,10 @@ function render(input = {}) {
|
|
|
2770
2793
|
}
|
|
2771
2794
|
function getDefaultRenderId(template) {
|
|
2772
2795
|
if (template["embed"]) {
|
|
2773
|
-
const ENCODE_CHARS = "
|
|
2796
|
+
const ENCODE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
2774
2797
|
let n = Math.random() * 4294967296 >>> 0;
|
|
2775
|
-
let r = ENCODE_CHARS[n %
|
|
2776
|
-
for (n = n /
|
|
2798
|
+
let r = ENCODE_CHARS[n % 52];
|
|
2799
|
+
for (n = n / 52 | 0; n; n = n / 63 | 0) r += ENCODE_CHARS[n % 63];
|
|
2777
2800
|
return r;
|
|
2778
2801
|
}
|
|
2779
2802
|
return "_";
|
|
@@ -3157,4 +3180,4 @@ const compat = {
|
|
|
3157
3180
|
};
|
|
3158
3181
|
function NOOP() {}
|
|
3159
3182
|
//#endregion
|
|
3160
|
-
export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _subscribe, _template, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
|
|
3183
|
+
export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _show_end, _show_start, _style_html, _subscribe, _template, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
|
|
@@ -10,6 +10,7 @@ export declare function _try(nodeAccessor: EncodedAccessor, template?: string |
|
|
|
10
10
|
}) => void;
|
|
11
11
|
export declare function renderCatch(scope: Scope, error: unknown): void;
|
|
12
12
|
export declare function _if(nodeAccessor: EncodedAccessor, ...branchesArgs: (string | SetupFn | 0)[]): (scope: Scope, newBranch: number) => void;
|
|
13
|
+
export declare function _show(nodeAccessor: EncodedAccessor, startNodeAccessor?: EncodedAccessor): (scope: Scope, display: unknown) => void;
|
|
13
14
|
export declare function patchDynamicTag(fn: <T extends typeof _dynamic_tag>(cond: T) => T): void;
|
|
14
15
|
export declare let _dynamic_tag: (nodeAccessor: EncodedAccessor, getContent?: ((scope: Scope) => Renderer) | 0, getTagVar?: (() => Signal<unknown>) | 0, inputIsArgs?: 1) => Signal<Renderer | string | undefined>;
|
|
15
16
|
export declare function _dynamic_tag_content(nodeAccessor: EncodedAccessor): Signal<Renderer | undefined>;
|
package/dist/dom/dom.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export declare function _attr_class_item(element: Element, name: string, value:
|
|
|
7
7
|
export declare function _attr_style(element: Element, value: unknown): void;
|
|
8
8
|
export declare function _attr_style_items(element: HTMLElement, items: Record<string, unknown>): void;
|
|
9
9
|
export declare function _attr_style_item(element: HTMLElement, name: string, value: unknown): void;
|
|
10
|
+
export declare function _style_shell(scope: Scope, nodeAccessor: Accessor): void;
|
|
11
|
+
export declare function _style_rule_item(element: HTMLStyleElement, name: string, value: unknown): void;
|
|
10
12
|
export declare function _attr_nonce(scope: Scope, nodeAccessor: Accessor): void;
|
|
11
13
|
export declare function _text(node: Text | Comment, value: unknown): void;
|
|
12
14
|
export declare function _text_content(node: ParentNode, value: unknown): void;
|
package/dist/dom.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export { forIn, forOf, forTo, forUntil } from "./common/for";
|
|
|
4
4
|
export { _call } from "./common/helpers";
|
|
5
5
|
export { $signal, $signalReset } from "./dom/abort-signal";
|
|
6
6
|
export { compat } from "./dom/compat";
|
|
7
|
-
export { _await_content, _await_promise, _dynamic_tag, _dynamic_tag_content, _for_in, _for_of, _for_to, _for_until, _if, _resume_dynamic_tag, _try, } from "./dom/control-flow";
|
|
7
|
+
export { _await_content, _await_promise, _dynamic_tag, _dynamic_tag_content, _for_in, _for_of, _for_to, _for_until, _if, _resume_dynamic_tag, _show, _try, } from "./dom/control-flow";
|
|
8
8
|
export { _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checked_default, _attr_input_checked_script, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_value, _attr_input_value_default, _attr_input_value_script, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_input_value as _attr_textarea_value, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script as _attr_textarea_value_script, } from "./dom/controllable";
|
|
9
|
-
export { _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_nonce, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _html, _lifecycle, _text, _text_content, _to_text, } from "./dom/dom";
|
|
9
|
+
export { _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_nonce, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _html, _lifecycle, _style_rule_item, _style_shell, _text, _text_content, _to_text, } from "./dom/dom";
|
|
10
10
|
export { _on } from "./dom/event";
|
|
11
11
|
export { _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, } from "./dom/load";
|
|
12
12
|
export { _enable_catch, run } from "./dom/queue";
|
package/dist/dom.js
CHANGED
|
@@ -132,6 +132,11 @@ function stringifyClassObject(name, value) {
|
|
|
132
132
|
function stringifyStyleObject(name, value) {
|
|
133
133
|
return value || value === 0 ? name + ":" + value : "";
|
|
134
134
|
}
|
|
135
|
+
function escapeStyleValue(str) {
|
|
136
|
+
let closers = "", result = str.replace(/[\\"'{};>]|\/(?=\*)/g, "\\$&").replace(/</g, "\\3C ");
|
|
137
|
+
for (let c of result) c === "(" ? closers = ")" + closers : c === "[" ? closers = "]" + closers : c === closers[0] && (closers = closers.slice(1));
|
|
138
|
+
return result + closers;
|
|
139
|
+
}
|
|
135
140
|
function isEventHandler(name) {
|
|
136
141
|
return /^on[A-Z-]/.test(name);
|
|
137
142
|
}
|
|
@@ -762,6 +767,19 @@ function _attr_style_items(element, items) {
|
|
|
762
767
|
function _attr_style_item(element, name, value) {
|
|
763
768
|
element.style.setProperty(name, _to_text(value));
|
|
764
769
|
}
|
|
770
|
+
function _style_shell(scope, nodeAccessor) {
|
|
771
|
+
let element = scope[nodeAccessor], id = _id(scope);
|
|
772
|
+
element.className = id, _text_content(element, "." + id + " ~ *{}");
|
|
773
|
+
}
|
|
774
|
+
function _style_rule_item(element, name, value) {
|
|
775
|
+
let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
|
|
776
|
+
if (start === -1 && (start = text.indexOf(";" + name + ":")), start === -1) element.textContent = text.slice(0, -1) + decl + "}";
|
|
777
|
+
else {
|
|
778
|
+
let end = ++start;
|
|
779
|
+
for (let c; (c = text[end]) && c !== ";"; end++) c === "\\" && end++;
|
|
780
|
+
element.textContent = text.slice(0, start) + decl + text.slice(end + 1);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
765
783
|
function _attr_nonce(scope, nodeAccessor) {
|
|
766
784
|
_attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
|
|
767
785
|
}
|
|
@@ -1012,6 +1030,21 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
1012
1030
|
newBranch !== (scope[branchAccessor] ?? (scope["A" + nodeAccessor] && 0)) && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
1013
1031
|
};
|
|
1014
1032
|
}
|
|
1033
|
+
function _show(nodeAccessor, startNodeAccessor) {
|
|
1034
|
+
nodeAccessor = decodeAccessor(nodeAccessor), startNodeAccessor !== void 0 && (startNodeAccessor = decodeAccessor(startNodeAccessor));
|
|
1035
|
+
let rangeAccessor = "A" + nodeAccessor;
|
|
1036
|
+
return enableBranches(), (scope, display) => {
|
|
1037
|
+
let referenceNode = scope[nodeAccessor], onlyChild = referenceNode.nodeType === 1, parentNode = onlyChild ? referenceNode : referenceNode.parentNode, range = scope[rangeAccessor];
|
|
1038
|
+
range || (range = scope[rangeAccessor] = {}, range.S = onlyChild ? parentNode.firstChild : scope[startNodeAccessor], range.K = onlyChild ? parentNode.lastChild : referenceNode.previousSibling);
|
|
1039
|
+
let startNode = range.S;
|
|
1040
|
+
if (range.L && startNode === range.K && startNode.tagName === "T") {
|
|
1041
|
+
let wrapper = startNode;
|
|
1042
|
+
wrapper.firstChild || wrapper.appendChild(new Text()), range = scope[rangeAccessor] = {}, range.S = startNode = wrapper.firstChild, range.K = wrapper.lastChild, wrapper.replaceWith(...wrapper.childNodes);
|
|
1043
|
+
}
|
|
1044
|
+
let inDom = startNode.parentNode === parentNode;
|
|
1045
|
+
display ? inDom || insertBranchBefore(range, parentNode, onlyChild ? null : referenceNode) : inDom && tempDetachBranch(range);
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1015
1048
|
function patchDynamicTag(fn) {
|
|
1016
1049
|
_dynamic_tag = fn(_dynamic_tag);
|
|
1017
1050
|
}
|
|
@@ -1315,4 +1348,4 @@ exports.$signal = $signal, exports.$signalReset = $signalReset, exports._assert_
|
|
|
1315
1348
|
get: function() {
|
|
1316
1349
|
return _dynamic_tag;
|
|
1317
1350
|
}
|
|
1318
|
-
}), exports._dynamic_tag_content = _dynamic_tag_content, exports._el = _el, exports._el_read = _el_read, exports._enable_catch = _enable_catch, exports._for_closure = _for_closure, exports._for_in = _for_in, exports._for_of = _for_of, exports._for_selector = _for_selector, exports._for_to = _for_to, exports._for_until = _for_until, exports._hoist = _hoist, exports._hoist_resume = _hoist_resume, exports._html = _html, exports._id = _id, exports._if = _if, exports._if_closure = _if_closure, exports._let = _let, exports._let_change = _let_change, exports._lifecycle = _lifecycle, exports._load_event_trigger = _load_event_trigger, exports._load_idle_trigger = _load_idle_trigger, exports._load_media_trigger = _load_media_trigger, exports._load_race_trigger = _load_race_trigger, exports._load_setup = _load_setup, exports._load_signal = _load_signal, exports._load_template = _load_template, exports._load_visible_trigger = _load_visible_trigger, exports._on = _on, exports._or = _or, exports._resume = _resume, exports._resume_dynamic_tag = _resume_dynamic_tag, exports._return = _return, exports._return_change = _return_change, exports._script = _script, exports._template = _template, exports._text = _text, exports._text_content = _text_content, exports._to_text = _to_text, exports._try = _try, exports._var = _var, exports._var_change = _var_change, exports._var_resume = _var_resume, exports.attrTag = attrTag, exports.attrTags = attrTags, exports.compat = compat, exports.forIn = forIn, exports.forOf = forOf, exports.forTo = forTo, exports.forUntil = forUntil, exports.init = init, exports.initEmbedded = initEmbedded, exports.ready = ready, exports.run = run;
|
|
1351
|
+
}), exports._dynamic_tag_content = _dynamic_tag_content, exports._el = _el, exports._el_read = _el_read, exports._enable_catch = _enable_catch, exports._for_closure = _for_closure, exports._for_in = _for_in, exports._for_of = _for_of, exports._for_selector = _for_selector, exports._for_to = _for_to, exports._for_until = _for_until, exports._hoist = _hoist, exports._hoist_resume = _hoist_resume, exports._html = _html, exports._id = _id, exports._if = _if, exports._if_closure = _if_closure, exports._let = _let, exports._let_change = _let_change, exports._lifecycle = _lifecycle, exports._load_event_trigger = _load_event_trigger, exports._load_idle_trigger = _load_idle_trigger, exports._load_media_trigger = _load_media_trigger, exports._load_race_trigger = _load_race_trigger, exports._load_setup = _load_setup, exports._load_signal = _load_signal, exports._load_template = _load_template, exports._load_visible_trigger = _load_visible_trigger, exports._on = _on, exports._or = _or, exports._resume = _resume, exports._resume_dynamic_tag = _resume_dynamic_tag, exports._return = _return, exports._return_change = _return_change, exports._script = _script, exports._show = _show, exports._style_rule_item = _style_rule_item, exports._style_shell = _style_shell, exports._template = _template, exports._text = _text, exports._text_content = _text_content, exports._to_text = _to_text, exports._try = _try, exports._var = _var, exports._var_change = _var_change, exports._var_resume = _var_resume, exports.attrTag = attrTag, exports.attrTags = attrTags, exports.compat = compat, exports.forIn = forIn, exports.forOf = forOf, exports.forTo = forTo, exports.forUntil = forUntil, exports.init = init, exports.initEmbedded = initEmbedded, exports.ready = ready, exports.run = run;
|
package/dist/dom.mjs
CHANGED
|
@@ -131,6 +131,11 @@ function stringifyClassObject(name, value) {
|
|
|
131
131
|
function stringifyStyleObject(name, value) {
|
|
132
132
|
return value || value === 0 ? name + ":" + value : "";
|
|
133
133
|
}
|
|
134
|
+
function escapeStyleValue(str) {
|
|
135
|
+
let closers = "", result = str.replace(/[\\"'{};>]|\/(?=\*)/g, "\\$&").replace(/</g, "\\3C ");
|
|
136
|
+
for (let c of result) c === "(" ? closers = ")" + closers : c === "[" ? closers = "]" + closers : c === closers[0] && (closers = closers.slice(1));
|
|
137
|
+
return result + closers;
|
|
138
|
+
}
|
|
134
139
|
function isEventHandler(name) {
|
|
135
140
|
return /^on[A-Z-]/.test(name);
|
|
136
141
|
}
|
|
@@ -761,6 +766,19 @@ function _attr_style_items(element, items) {
|
|
|
761
766
|
function _attr_style_item(element, name, value) {
|
|
762
767
|
element.style.setProperty(name, _to_text(value));
|
|
763
768
|
}
|
|
769
|
+
function _style_shell(scope, nodeAccessor) {
|
|
770
|
+
let element = scope[nodeAccessor], id = _id(scope);
|
|
771
|
+
element.className = id, _text_content(element, "." + id + " ~ *{}");
|
|
772
|
+
}
|
|
773
|
+
function _style_rule_item(element, name, value) {
|
|
774
|
+
let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
|
|
775
|
+
if (start === -1 && (start = text.indexOf(";" + name + ":")), start === -1) element.textContent = text.slice(0, -1) + decl + "}";
|
|
776
|
+
else {
|
|
777
|
+
let end = ++start;
|
|
778
|
+
for (let c; (c = text[end]) && c !== ";"; end++) c === "\\" && end++;
|
|
779
|
+
element.textContent = text.slice(0, start) + decl + text.slice(end + 1);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
764
782
|
function _attr_nonce(scope, nodeAccessor) {
|
|
765
783
|
_attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
|
|
766
784
|
}
|
|
@@ -1011,6 +1029,21 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
1011
1029
|
newBranch !== (scope[branchAccessor] ?? (scope["A" + nodeAccessor] && 0)) && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
1012
1030
|
};
|
|
1013
1031
|
}
|
|
1032
|
+
function _show(nodeAccessor, startNodeAccessor) {
|
|
1033
|
+
nodeAccessor = decodeAccessor(nodeAccessor), startNodeAccessor !== void 0 && (startNodeAccessor = decodeAccessor(startNodeAccessor));
|
|
1034
|
+
let rangeAccessor = "A" + nodeAccessor;
|
|
1035
|
+
return enableBranches(), (scope, display) => {
|
|
1036
|
+
let referenceNode = scope[nodeAccessor], onlyChild = referenceNode.nodeType === 1, parentNode = onlyChild ? referenceNode : referenceNode.parentNode, range = scope[rangeAccessor];
|
|
1037
|
+
range || (range = scope[rangeAccessor] = {}, range.S = onlyChild ? parentNode.firstChild : scope[startNodeAccessor], range.K = onlyChild ? parentNode.lastChild : referenceNode.previousSibling);
|
|
1038
|
+
let startNode = range.S;
|
|
1039
|
+
if (range.L && startNode === range.K && startNode.tagName === "T") {
|
|
1040
|
+
let wrapper = startNode;
|
|
1041
|
+
wrapper.firstChild || wrapper.appendChild(new Text()), range = scope[rangeAccessor] = {}, range.S = startNode = wrapper.firstChild, range.K = wrapper.lastChild, wrapper.replaceWith(...wrapper.childNodes);
|
|
1042
|
+
}
|
|
1043
|
+
let inDom = startNode.parentNode === parentNode;
|
|
1044
|
+
display ? inDom || insertBranchBefore(range, parentNode, onlyChild ? null : referenceNode) : inDom && tempDetachBranch(range);
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1014
1047
|
function patchDynamicTag(fn) {
|
|
1015
1048
|
_dynamic_tag = fn(_dynamic_tag);
|
|
1016
1049
|
}
|
|
@@ -1310,4 +1343,4 @@ function getSelectorOrResolve(selector, resolve) {
|
|
|
1310
1343
|
return document.querySelector(selector) || resolve();
|
|
1311
1344
|
}
|
|
1312
1345
|
//#endregion
|
|
1313
|
-
export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _enable_catch, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };
|
|
1346
|
+
export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _enable_catch, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };
|
package/dist/html/attrs.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare function _attr_input_checked(scopeId: number, nodeAccessor: Acces
|
|
|
9
9
|
export declare function _attr_input_checkedValue(scopeId: number, nodeAccessor: Accessor, checkedValue: unknown, checkedValueChange: unknown, value: unknown, serializeType?: 1): string;
|
|
10
10
|
export declare function _attr_details_or_dialog_open(scopeId: number, nodeAccessor: Accessor, open: unknown, openChange: unknown, serializeType?: 1): "" | " open";
|
|
11
11
|
export declare function _attr_nonce(): string;
|
|
12
|
+
export declare function _style_html(decls: string): string;
|
|
12
13
|
export declare function _attr(name: string, value: unknown): string;
|
|
13
14
|
export declare function _attr_and(name: string, value: unknown, attr: string): string;
|
|
14
15
|
export declare function _attr_or(name: string, value: unknown, attr: string): string;
|
package/dist/html/content.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export declare function _unescaped(val: unknown): string;
|
|
|
3
3
|
export declare function _escape(val: unknown): string;
|
|
4
4
|
export declare function _escape_script(val: unknown): string;
|
|
5
5
|
export declare function _escape_style(val: unknown): string;
|
|
6
|
+
export declare function _escape_style_value(val: unknown): string;
|
|
6
7
|
export declare function _escape_comment(val: unknown): string;
|