marko 6.1.24 → 6.2.1
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 +61 -2
- package/dist/debug/dom.mjs +59 -3
- package/dist/debug/html.js +42 -14
- package/dist/debug/html.mjs +39 -15
- 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 +35 -3
- package/dist/dom.mjs +35 -3
- 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 +8 -5
- package/dist/html.d.ts +3 -3
- package/dist/html.js +28 -9
- package/dist/html.mjs +28 -9
- 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 +600 -75
- package/dist/translator/util/known-tag.d.ts +1 -1
- package/dist/translator/util/references.d.ts +5 -0
- package/dist/translator/util/serialize-reasons.d.ts +2 -0
- package/dist/translator/util/setup-statements.d.ts +5 -0
- package/dist/translator/util/signals.d.ts +1 -0
- package/dist/translator/util/style-interpolation.d.ts +3 -0
- package/dist/translator/visitors/program/index.d.ts +1 -0
- package/package.json +1 -1
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, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
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
|
}
|
|
@@ -176,6 +181,10 @@ function forUntil(until, from, step, cb) {
|
|
|
176
181
|
function toArray(opt) {
|
|
177
182
|
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
178
183
|
}
|
|
184
|
+
function forEach(opt, cb) {
|
|
185
|
+
if (opt) if (Array.isArray(opt)) for (let item of opt) cb(item);
|
|
186
|
+
else cb(opt);
|
|
187
|
+
}
|
|
179
188
|
function push(opt, item) {
|
|
180
189
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
181
190
|
}
|
|
@@ -491,8 +500,8 @@ function init(runtimeId = "M") {
|
|
|
491
500
|
for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
|
|
492
501
|
if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
|
|
493
502
|
for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
|
|
494
|
-
branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
|
|
495
|
-
} else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
503
|
+
branch._ ??= visitScope, branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
|
|
504
|
+
} else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, forEach(curBranchScopes, (scope) => scope._ ??= visitScope), curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
496
505
|
for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
|
|
497
506
|
for (; j && deferredOwners[--j].L > branchId;) {
|
|
498
507
|
let owner = deferredOwners.pop();
|
|
@@ -762,6 +771,14 @@ function _attr_style_items(element, items) {
|
|
|
762
771
|
function _attr_style_item(element, name, value) {
|
|
763
772
|
element.style.setProperty(name, _to_text(value));
|
|
764
773
|
}
|
|
774
|
+
function _style_shell(scope, nodeAccessor) {
|
|
775
|
+
let element = scope[nodeAccessor], id = _id(scope);
|
|
776
|
+
_attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
|
|
777
|
+
}
|
|
778
|
+
function _style_rule_item(element, name, value) {
|
|
779
|
+
let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
|
|
780
|
+
~start || (start = text.indexOf(";" + name + ":")), _text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
781
|
+
}
|
|
765
782
|
function _attr_nonce(scope, nodeAccessor) {
|
|
766
783
|
_attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
|
|
767
784
|
}
|
|
@@ -1012,6 +1029,21 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
1012
1029
|
newBranch !== (scope[branchAccessor] ?? (scope["A" + nodeAccessor] && 0)) && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
1013
1030
|
};
|
|
1014
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
|
+
}
|
|
1015
1047
|
function patchDynamicTag(fn) {
|
|
1016
1048
|
_dynamic_tag = fn(_dynamic_tag);
|
|
1017
1049
|
}
|
|
@@ -1315,4 +1347,4 @@ exports.$signal = $signal, exports.$signalReset = $signalReset, exports._assert_
|
|
|
1315
1347
|
get: function() {
|
|
1316
1348
|
return _dynamic_tag;
|
|
1317
1349
|
}
|
|
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;
|
|
1350
|
+
}), 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, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
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
|
}
|
|
@@ -175,6 +180,10 @@ function forUntil(until, from, step, cb) {
|
|
|
175
180
|
function toArray(opt) {
|
|
176
181
|
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
177
182
|
}
|
|
183
|
+
function forEach(opt, cb) {
|
|
184
|
+
if (opt) if (Array.isArray(opt)) for (let item of opt) cb(item);
|
|
185
|
+
else cb(opt);
|
|
186
|
+
}
|
|
178
187
|
function push(opt, item) {
|
|
179
188
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
180
189
|
}
|
|
@@ -490,8 +499,8 @@ function init(runtimeId = "M") {
|
|
|
490
499
|
for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
|
|
491
500
|
if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
|
|
492
501
|
for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
|
|
493
|
-
branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
|
|
494
|
-
} else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
502
|
+
branch._ ??= visitScope, branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
|
|
503
|
+
} else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, forEach(curBranchScopes, (scope) => scope._ ??= visitScope), curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
495
504
|
for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
|
|
496
505
|
for (; j && deferredOwners[--j].L > branchId;) {
|
|
497
506
|
let owner = deferredOwners.pop();
|
|
@@ -761,6 +770,14 @@ function _attr_style_items(element, items) {
|
|
|
761
770
|
function _attr_style_item(element, name, value) {
|
|
762
771
|
element.style.setProperty(name, _to_text(value));
|
|
763
772
|
}
|
|
773
|
+
function _style_shell(scope, nodeAccessor) {
|
|
774
|
+
let element = scope[nodeAccessor], id = _id(scope);
|
|
775
|
+
_attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
|
|
776
|
+
}
|
|
777
|
+
function _style_rule_item(element, name, value) {
|
|
778
|
+
let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
|
|
779
|
+
~start || (start = text.indexOf(";" + name + ":")), _text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
780
|
+
}
|
|
764
781
|
function _attr_nonce(scope, nodeAccessor) {
|
|
765
782
|
_attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
|
|
766
783
|
}
|
|
@@ -1011,6 +1028,21 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
1011
1028
|
newBranch !== (scope[branchAccessor] ?? (scope["A" + nodeAccessor] && 0)) && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
1012
1029
|
};
|
|
1013
1030
|
}
|
|
1031
|
+
function _show(nodeAccessor, startNodeAccessor) {
|
|
1032
|
+
nodeAccessor = decodeAccessor(nodeAccessor), startNodeAccessor !== void 0 && (startNodeAccessor = decodeAccessor(startNodeAccessor));
|
|
1033
|
+
let rangeAccessor = "A" + nodeAccessor;
|
|
1034
|
+
return enableBranches(), (scope, display) => {
|
|
1035
|
+
let referenceNode = scope[nodeAccessor], onlyChild = referenceNode.nodeType === 1, parentNode = onlyChild ? referenceNode : referenceNode.parentNode, range = scope[rangeAccessor];
|
|
1036
|
+
range || (range = scope[rangeAccessor] = {}, range.S = onlyChild ? parentNode.firstChild : scope[startNodeAccessor], range.K = onlyChild ? parentNode.lastChild : referenceNode.previousSibling);
|
|
1037
|
+
let startNode = range.S;
|
|
1038
|
+
if (range.L && startNode === range.K && startNode.tagName === "T") {
|
|
1039
|
+
let wrapper = startNode;
|
|
1040
|
+
wrapper.firstChild || wrapper.appendChild(new Text()), range = scope[rangeAccessor] = {}, range.S = startNode = wrapper.firstChild, range.K = wrapper.lastChild, wrapper.replaceWith(...wrapper.childNodes);
|
|
1041
|
+
}
|
|
1042
|
+
let inDom = startNode.parentNode === parentNode;
|
|
1043
|
+
display ? inDom || insertBranchBefore(range, parentNode, onlyChild ? null : referenceNode) : inDom && tempDetachBranch(range);
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1014
1046
|
function patchDynamicTag(fn) {
|
|
1015
1047
|
_dynamic_tag = fn(_dynamic_tag);
|
|
1016
1048
|
}
|
|
@@ -1310,4 +1342,4 @@ function getSelectorOrResolve(selector, resolve) {
|
|
|
1310
1342
|
return document.querySelector(selector) || resolve();
|
|
1311
1343
|
}
|
|
1312
1344
|
//#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 };
|
|
1345
|
+
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;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const WALKER_RUNTIME_CODE = "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))";
|
|
2
|
-
export declare const REORDER_RUNTIME_CODE = "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.
|
|
2
|
+
export declare const REORDER_RUNTIME_CODE = "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const WALKER_RUNTIME_CODE = "((runtimeId) => (self[runtimeId] ||= (\n renderId,\n prefix = runtimeId + renderId,\n prefixLen = prefix.length,\n lookup = {},\n visits = [],\n doc = document,\n walker = doc.createTreeWalker(\n doc,\n 129 /* NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_ELEMENT */,\n ),\n) =>\n doc = (self[runtimeId][renderId] = {\n i: prefix,\n d: doc,\n l: lookup,\n v: visits,\n x() {},\n w(node, op, id) {\n while ((node = walker.nextNode())) {\n doc.x(\n (op =\n (op = node.data) &&\n !op.indexOf(prefix) &&\n ((lookup[(id = op.slice(prefixLen + 1))] = node), op[prefixLen])),\n id,\n node,\n );\n\n if (op > \"#\") {\n visits.push(node);\n }\n }\n },\n })\n, self[runtimeId]))";
|
|
2
|
-
export declare const REORDER_RUNTIME_CODE = "((runtime) => {\n if (runtime.j) return;\n let onNextSibling,\n placeholder,\n nextSibling,\n placeholders = runtime.p = {},\n replace = (id, container) => runtime.l[id].replaceWith(...container.childNodes);\n runtime.
|
|
2
|
+
export declare const REORDER_RUNTIME_CODE = "((runtime) => {\n if (runtime.j) return;\n let onNextSibling,\n placeholder,\n nextSibling,\n placeholders = runtime.p = {},\n replace = (id, container) => runtime.l[id].replaceWith(...container.childNodes);\n runtime.j = {};\n runtime.x = (op, id, node, placeholderRoot, placeholderCb) => {\n if (node == nextSibling) {\n onNextSibling();\n }\n\n if (op == \"#\") {\n (placeholders[id] = placeholder).i++;\n } else if (op == \"!\") {\n if (runtime.l[id] && placeholders[id]) {\n nextSibling = node.nextSibling;\n onNextSibling = () => placeholders[id].c();\n }\n } else if (node.tagName == \"T\" && (id = node.getAttribute(runtime.i))) {\n nextSibling = node.nextSibling;\n onNextSibling = () => {\n node.remove();\n placeholderRoot || replace(id, node);\n placeholder.c();\n };\n placeholder =\n placeholders[id] ||\n (placeholderRoot = placeholders[id] =\n {\n i: runtime.l[id] ? 1 : 2,\n c(start = runtime.l[\"^\" + id]) {\n if (--placeholderRoot.i) return 1;\n for (\n ;\n (nextSibling =\n runtime.l[id].previousSibling || start).remove(),\n start != nextSibling;\n\n );\n replace(id, node);\n },\n });\n // repurpose \"op\" for callbacks ...carefully\n if ((op = runtime.j[id])) {\n placeholderCb = placeholder.c;\n placeholder.c = () => placeholderCb() || op(runtime.r);\n }\n }\n };\n})";
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -37,10 +37,11 @@ export declare function _id(): string;
|
|
|
37
37
|
export declare function _scope_id(): number;
|
|
38
38
|
export declare function _peek_scope_id(): number;
|
|
39
39
|
export declare function getScopeById(scopeId: number | undefined): ScopeInternals | undefined;
|
|
40
|
-
export
|
|
41
|
-
export declare function
|
|
42
|
-
export declare function
|
|
43
|
-
export declare function
|
|
40
|
+
export type SerializeReasonValue = undefined | number | Partial<Record<string, 0 | 1>>;
|
|
41
|
+
export declare function _set_serialize_reason(reason: SerializeReasonValue): void;
|
|
42
|
+
export declare function _scope_reason(): SerializeReasonValue;
|
|
43
|
+
export declare function _serialize_if(condition: SerializeReasonValue, key: number): 1 | undefined;
|
|
44
|
+
export declare function _serialize_guard(condition: SerializeReasonValue, key: number): 0 | 1;
|
|
44
45
|
export declare function _el_resume(scopeId: number, accessor: Accessor, shouldResume?: 0 | 1): string;
|
|
45
46
|
export declare function _sep(shouldResume: 0 | 1): "" | "<!>";
|
|
46
47
|
export declare function _el(scopeId: number, id: string): () => void;
|
|
@@ -56,6 +57,8 @@ export declare function _for_in(obj: Falsy | {}, cb: (key: string, value: unknow
|
|
|
56
57
|
export declare function _for_to(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
|
|
57
58
|
export declare function _for_until(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
|
|
58
59
|
export declare function _if(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
|
|
60
|
+
export declare function _show_start(display: unknown, mark?: unknown): void;
|
|
61
|
+
export declare function _show_end(scopeId: number, accessor: Accessor, display: unknown, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1 | 0): void;
|
|
59
62
|
declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
|
|
60
63
|
export { writeScope as _scope };
|
|
61
64
|
export declare function _existing_scope(scopeId: number): ScopeInternals;
|
|
@@ -98,7 +101,7 @@ export declare class State implements SerializeState {
|
|
|
98
101
|
flushScopes: boolean;
|
|
99
102
|
writeScopes: Record<number, PartialScope>;
|
|
100
103
|
readyIds: Set<string> | null;
|
|
101
|
-
serializeReason:
|
|
104
|
+
serializeReason: SerializeReasonValue;
|
|
102
105
|
constructor($global: $Global & {
|
|
103
106
|
renderId: string;
|
|
104
107
|
runtimeId: string;
|
package/dist/html.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { attrTag, attrTags } from "./common/attr-tag";
|
|
2
2
|
export { _assert_hoist, _el_read_error, _hoist_read_error, } from "./common/errors";
|
|
3
3
|
export { _flush_head, withLoadAssets, withPageAssets } from "./html/assets";
|
|
4
|
-
export { _attr, _attr_and, _attr_class, _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, } from "./html/attrs";
|
|
4
|
+
export { _attr, _attr_and, _attr_class, _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, _style_html, } from "./html/attrs";
|
|
5
5
|
export { compat } from "./html/compat";
|
|
6
|
-
export { _escape, _escape_comment, _escape_script, _escape_style, _to_text, _unescaped, } from "./html/content";
|
|
6
|
+
export { _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _to_text, _unescaped, } from "./html/content";
|
|
7
7
|
export { _content, _content_resume, _dynamic_tag } from "./html/dynamic-tag";
|
|
8
8
|
export { forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, } from "./html/for";
|
|
9
9
|
export { _template } from "./html/template";
|
|
10
|
-
export { _attr_content, _await, _el, _el_resume, _existing_scope, _for_in, _for_of, _for_to, _for_until, _hoist, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _subscribe, _trailers, _try, _var, $global, } from "./html/writer";
|
|
10
|
+
export { _attr_content, _await, _el, _el_resume, _existing_scope, _for_in, _for_of, _for_to, _for_until, _hoist, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _show_end, _show_start, _subscribe, _trailers, _try, _var, $global, } from "./html/writer";
|
package/dist/html.js
CHANGED
|
@@ -375,6 +375,11 @@ function stringifyClassObject(name, value) {
|
|
|
375
375
|
function stringifyStyleObject(name, value) {
|
|
376
376
|
return value || value === 0 ? name + ":" + value : "";
|
|
377
377
|
}
|
|
378
|
+
function escapeStyleValue(str) {
|
|
379
|
+
let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
380
|
+
for (let c of result) c === "(" ? closers = ")" + closers : c === "[" ? closers = "]" + closers : c === closers[0] && (closers = closers.slice(1));
|
|
381
|
+
return result + closers;
|
|
382
|
+
}
|
|
378
383
|
function isEventHandler(name) {
|
|
379
384
|
return /^on[A-Z-]/.test(name);
|
|
380
385
|
}
|
|
@@ -419,6 +424,9 @@ function _escape_script(val) {
|
|
|
419
424
|
function _escape_style(val) {
|
|
420
425
|
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
|
421
426
|
}
|
|
427
|
+
function _escape_style_value(val) {
|
|
428
|
+
return val || val === 0 ? escapeStyleValue(val + "") : "";
|
|
429
|
+
}
|
|
422
430
|
function _escape_comment(val) {
|
|
423
431
|
return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
|
|
424
432
|
}
|
|
@@ -1137,7 +1145,7 @@ function _scope_reason() {
|
|
|
1137
1145
|
return $chunk.boundary.state.serializeReason = void 0, reason;
|
|
1138
1146
|
}
|
|
1139
1147
|
function _serialize_if(condition, key) {
|
|
1140
|
-
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
|
1148
|
+
return condition && (condition === 1 || (typeof condition == "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
|
|
1141
1149
|
}
|
|
1142
1150
|
function _serialize_guard(condition, key) {
|
|
1143
1151
|
return _serialize_if(condition, key) || 0;
|
|
@@ -1231,6 +1239,13 @@ function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, p
|
|
|
1231
1239
|
} else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
1232
1240
|
else $chunk.writeHTML(endTag);
|
|
1233
1241
|
}
|
|
1242
|
+
function _show_start(display, mark) {
|
|
1243
|
+
display ? mark && $chunk.writeHTML($chunk.boundary.state.mark("[", "")) : $chunk.writeHTML("<t hidden>");
|
|
1244
|
+
}
|
|
1245
|
+
function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1246
|
+
let branchId = _scope_id(), wrap = !display;
|
|
1247
|
+
wrap && $chunk.writeHTML("</t>"), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
1248
|
+
}
|
|
1234
1249
|
function _existing_scope(scopeId) {
|
|
1235
1250
|
return writeScope(scopeId, {});
|
|
1236
1251
|
}
|
|
@@ -1480,7 +1495,7 @@ var State = class {
|
|
|
1480
1495
|
return scripts;
|
|
1481
1496
|
}
|
|
1482
1497
|
flushScript() {
|
|
1483
|
-
let { boundary } = this, { state } = boundary, { $global, runtimePrefix
|
|
1498
|
+
let { boundary } = this, { state } = boundary, { $global, runtimePrefix } = state, needsWalk = state.walkOnNextFlush;
|
|
1484
1499
|
needsWalk && (state.walkOnNextFlush = !1);
|
|
1485
1500
|
let readyResumeScripts = this.flushReadyScripts();
|
|
1486
1501
|
for (let channel; channel = state.serializer.pendingReadyChannel();) {
|
|
@@ -1488,9 +1503,9 @@ var State = class {
|
|
|
1488
1503
|
state.needsMainRuntime = !0, readyResumeScripts = concatScripts(readyResumeScripts, state.writeReady(channel.readyId, concatSequence(depsMarker(deps), resumes)));
|
|
1489
1504
|
}
|
|
1490
1505
|
readyResumeScripts && (needsWalk = !0);
|
|
1491
|
-
let
|
|
1506
|
+
let effects = this.async ? "" : this.effects, { html, scripts } = this;
|
|
1492
1507
|
if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\""), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(scripts, runtimePrefix + ".r.push(" + state.resumes + ")") : (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]"))), state.writeReorders) {
|
|
1493
|
-
needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0,
|
|
1508
|
+
needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
|
|
1494
1509
|
for (let reorderedChunk of state.writeReorders) {
|
|
1495
1510
|
let { reorderId } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
|
|
1496
1511
|
for (reorderedChunk.reorderId = null;;) {
|
|
@@ -1501,11 +1516,11 @@ var State = class {
|
|
|
1501
1516
|
}
|
|
1502
1517
|
reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[]")), reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")"));
|
|
1503
1518
|
for (let reservation of readyReservations) scripts = concatScripts(scripts, reservation);
|
|
1504
|
-
scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
1519
|
+
scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
1505
1520
|
}
|
|
1506
1521
|
state.writeReorders = null;
|
|
1507
1522
|
}
|
|
1508
|
-
return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.effects = this.lastEffect = state.resumes = "", this;
|
|
1523
|
+
return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
|
|
1509
1524
|
}
|
|
1510
1525
|
flushHTML() {
|
|
1511
1526
|
let { boundary } = this, { state } = boundary;
|
|
@@ -1644,6 +1659,10 @@ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, s
|
|
|
1644
1659
|
function _attr_nonce() {
|
|
1645
1660
|
return getChunk().boundary.state.nonceAttr;
|
|
1646
1661
|
}
|
|
1662
|
+
function _style_html(decls) {
|
|
1663
|
+
let id = _id();
|
|
1664
|
+
return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
|
|
1665
|
+
}
|
|
1647
1666
|
function _attr(name, value) {
|
|
1648
1667
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
1649
1668
|
}
|
|
@@ -1781,8 +1800,8 @@ function render(input = {}) {
|
|
|
1781
1800
|
}
|
|
1782
1801
|
function getDefaultRenderId(template) {
|
|
1783
1802
|
if (template.i) {
|
|
1784
|
-
let ENCODE_CHARS = "
|
|
1785
|
-
for (n = n /
|
|
1803
|
+
let ENCODE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789", n = Math.random() * 4294967296 >>> 0, r = ENCODE_CHARS[n % 52];
|
|
1804
|
+
for (n = n / 52 | 0; n; n = n / 63 | 0) r += ENCODE_CHARS[n % 63];
|
|
1786
1805
|
return r;
|
|
1787
1806
|
}
|
|
1788
1807
|
return "_";
|
|
@@ -1984,4 +2003,4 @@ exports.$global = $global, exports._assert_hoist = _assert_hoist, exports._attr
|
|
|
1984
2003
|
get: function() {
|
|
1985
2004
|
return _dynamic_tag;
|
|
1986
2005
|
}
|
|
1987
|
-
}), exports._el = _el, exports._el_read_error = _el_read_error, exports._el_resume = _el_resume, exports._escape = _escape, exports._escape_comment = _escape_comment, exports._escape_script = _escape_script, exports._escape_style = _escape_style, exports._existing_scope = _existing_scope, exports._flush_head = _flush_head, exports._for_in = _for_in, exports._for_of = _for_of, exports._for_to = _for_to, exports._for_until = _for_until, exports._hoist = _hoist, exports._hoist_read_error = _hoist_read_error, exports._html = _html, exports._id = _id, exports._if = _if, exports._peek_scope_id = _peek_scope_id, exports._resume = _resume, exports._resume_branch = _resume_branch, exports._scope = writeScope, exports._scope_id = _scope_id, exports._scope_reason = _scope_reason, exports._scope_with_id = _scope_with_id, exports._script = _script, exports._sep = _sep, exports._serialize_guard = _serialize_guard, exports._serialize_if = _serialize_if, exports._set_serialize_reason = _set_serialize_reason, exports._subscribe = _subscribe, exports._template = _template, exports._to_text = _to_text, exports._trailers = _trailers, exports._try = _try, exports._unescaped = _unescaped, exports._var = _var, exports.attrTag = attrTag, exports.attrTags = attrTags, exports.compat = compat, exports.forIn = forIn, exports.forInBy = forInBy, exports.forOf = forOf, exports.forOfBy = forOfBy, exports.forStepBy = forStepBy, exports.forTo = forTo, exports.forUntil = forUntil, exports.withLoadAssets = withLoadAssets, exports.withPageAssets = withPageAssets;
|
|
2006
|
+
}), exports._el = _el, exports._el_read_error = _el_read_error, exports._el_resume = _el_resume, exports._escape = _escape, exports._escape_comment = _escape_comment, exports._escape_script = _escape_script, exports._escape_style = _escape_style, exports._escape_style_value = _escape_style_value, exports._existing_scope = _existing_scope, exports._flush_head = _flush_head, exports._for_in = _for_in, exports._for_of = _for_of, exports._for_to = _for_to, exports._for_until = _for_until, exports._hoist = _hoist, exports._hoist_read_error = _hoist_read_error, exports._html = _html, exports._id = _id, exports._if = _if, exports._peek_scope_id = _peek_scope_id, exports._resume = _resume, exports._resume_branch = _resume_branch, exports._scope = writeScope, exports._scope_id = _scope_id, exports._scope_reason = _scope_reason, exports._scope_with_id = _scope_with_id, exports._script = _script, exports._sep = _sep, exports._serialize_guard = _serialize_guard, exports._serialize_if = _serialize_if, exports._set_serialize_reason = _set_serialize_reason, exports._show_end = _show_end, exports._show_start = _show_start, exports._style_html = _style_html, exports._subscribe = _subscribe, exports._template = _template, exports._to_text = _to_text, exports._trailers = _trailers, exports._try = _try, exports._unescaped = _unescaped, exports._var = _var, exports.attrTag = attrTag, exports.attrTags = attrTags, exports.compat = compat, exports.forIn = forIn, exports.forInBy = forInBy, exports.forOf = forOf, exports.forOfBy = forOfBy, exports.forStepBy = forStepBy, exports.forTo = forTo, exports.forUntil = forUntil, exports.withLoadAssets = withLoadAssets, exports.withPageAssets = withPageAssets;
|
package/dist/html.mjs
CHANGED
|
@@ -374,6 +374,11 @@ function stringifyClassObject(name, value) {
|
|
|
374
374
|
function stringifyStyleObject(name, value) {
|
|
375
375
|
return value || value === 0 ? name + ":" + value : "";
|
|
376
376
|
}
|
|
377
|
+
function escapeStyleValue(str) {
|
|
378
|
+
let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
379
|
+
for (let c of result) c === "(" ? closers = ")" + closers : c === "[" ? closers = "]" + closers : c === closers[0] && (closers = closers.slice(1));
|
|
380
|
+
return result + closers;
|
|
381
|
+
}
|
|
377
382
|
function isEventHandler(name) {
|
|
378
383
|
return /^on[A-Z-]/.test(name);
|
|
379
384
|
}
|
|
@@ -418,6 +423,9 @@ function _escape_script(val) {
|
|
|
418
423
|
function _escape_style(val) {
|
|
419
424
|
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
|
420
425
|
}
|
|
426
|
+
function _escape_style_value(val) {
|
|
427
|
+
return val || val === 0 ? escapeStyleValue(val + "") : "";
|
|
428
|
+
}
|
|
421
429
|
function _escape_comment(val) {
|
|
422
430
|
return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
|
|
423
431
|
}
|
|
@@ -1136,7 +1144,7 @@ function _scope_reason() {
|
|
|
1136
1144
|
return $chunk.boundary.state.serializeReason = void 0, reason;
|
|
1137
1145
|
}
|
|
1138
1146
|
function _serialize_if(condition, key) {
|
|
1139
|
-
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
|
1147
|
+
return condition && (condition === 1 || (typeof condition == "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
|
|
1140
1148
|
}
|
|
1141
1149
|
function _serialize_guard(condition, key) {
|
|
1142
1150
|
return _serialize_if(condition, key) || 0;
|
|
@@ -1230,6 +1238,13 @@ function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, p
|
|
|
1230
1238
|
} else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
1231
1239
|
else $chunk.writeHTML(endTag);
|
|
1232
1240
|
}
|
|
1241
|
+
function _show_start(display, mark) {
|
|
1242
|
+
display ? mark && $chunk.writeHTML($chunk.boundary.state.mark("[", "")) : $chunk.writeHTML("<t hidden>");
|
|
1243
|
+
}
|
|
1244
|
+
function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1245
|
+
let branchId = _scope_id(), wrap = !display;
|
|
1246
|
+
wrap && $chunk.writeHTML("</t>"), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
1247
|
+
}
|
|
1233
1248
|
function _existing_scope(scopeId) {
|
|
1234
1249
|
return writeScope(scopeId, {});
|
|
1235
1250
|
}
|
|
@@ -1479,7 +1494,7 @@ var State = class {
|
|
|
1479
1494
|
return scripts;
|
|
1480
1495
|
}
|
|
1481
1496
|
flushScript() {
|
|
1482
|
-
let { boundary } = this, { state } = boundary, { $global, runtimePrefix
|
|
1497
|
+
let { boundary } = this, { state } = boundary, { $global, runtimePrefix } = state, needsWalk = state.walkOnNextFlush;
|
|
1483
1498
|
needsWalk && (state.walkOnNextFlush = !1);
|
|
1484
1499
|
let readyResumeScripts = this.flushReadyScripts();
|
|
1485
1500
|
for (let channel; channel = state.serializer.pendingReadyChannel();) {
|
|
@@ -1487,9 +1502,9 @@ var State = class {
|
|
|
1487
1502
|
state.needsMainRuntime = !0, readyResumeScripts = concatScripts(readyResumeScripts, state.writeReady(channel.readyId, concatSequence(depsMarker(deps), resumes)));
|
|
1488
1503
|
}
|
|
1489
1504
|
readyResumeScripts && (needsWalk = !0);
|
|
1490
|
-
let
|
|
1505
|
+
let effects = this.async ? "" : this.effects, { html, scripts } = this;
|
|
1491
1506
|
if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\""), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(scripts, runtimePrefix + ".r.push(" + state.resumes + ")") : (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]"))), state.writeReorders) {
|
|
1492
|
-
needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0,
|
|
1507
|
+
needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
|
|
1493
1508
|
for (let reorderedChunk of state.writeReorders) {
|
|
1494
1509
|
let { reorderId } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
|
|
1495
1510
|
for (reorderedChunk.reorderId = null;;) {
|
|
@@ -1500,11 +1515,11 @@ var State = class {
|
|
|
1500
1515
|
}
|
|
1501
1516
|
reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[]")), reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")"));
|
|
1502
1517
|
for (let reservation of readyReservations) scripts = concatScripts(scripts, reservation);
|
|
1503
|
-
scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
1518
|
+
scripts = concatScripts(scripts, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
1504
1519
|
}
|
|
1505
1520
|
state.writeReorders = null;
|
|
1506
1521
|
}
|
|
1507
|
-
return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.effects = this.lastEffect = state.resumes = "", this;
|
|
1522
|
+
return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
|
|
1508
1523
|
}
|
|
1509
1524
|
flushHTML() {
|
|
1510
1525
|
let { boundary } = this, { state } = boundary;
|
|
@@ -1643,6 +1658,10 @@ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, s
|
|
|
1643
1658
|
function _attr_nonce() {
|
|
1644
1659
|
return getChunk().boundary.state.nonceAttr;
|
|
1645
1660
|
}
|
|
1661
|
+
function _style_html(decls) {
|
|
1662
|
+
let id = _id();
|
|
1663
|
+
return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
|
|
1664
|
+
}
|
|
1646
1665
|
function _attr(name, value) {
|
|
1647
1666
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
1648
1667
|
}
|
|
@@ -1780,8 +1799,8 @@ function render(input = {}) {
|
|
|
1780
1799
|
}
|
|
1781
1800
|
function getDefaultRenderId(template) {
|
|
1782
1801
|
if (template.i) {
|
|
1783
|
-
let ENCODE_CHARS = "
|
|
1784
|
-
for (n = n /
|
|
1802
|
+
let ENCODE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789", n = Math.random() * 4294967296 >>> 0, r = ENCODE_CHARS[n % 52];
|
|
1803
|
+
for (n = n / 52 | 0; n; n = n / 63 | 0) r += ENCODE_CHARS[n % 63];
|
|
1785
1804
|
return r;
|
|
1786
1805
|
}
|
|
1787
1806
|
return "_";
|
|
@@ -1979,4 +1998,4 @@ function toObjectExpression(options) {
|
|
|
1979
1998
|
//#region src/html/compat.ts
|
|
1980
1999
|
function NOOP() {}
|
|
1981
2000
|
//#endregion
|
|
1982
|
-
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 };
|
|
2001
|
+
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 };
|
|
@@ -106,6 +106,7 @@ declare const _default: {
|
|
|
106
106
|
"<return>": import("@marko/compiler/babel-utils").Tag;
|
|
107
107
|
"<script>": import("@marko/compiler/babel-utils").Tag;
|
|
108
108
|
"<server>": import("@marko/compiler/babel-utils").Tag;
|
|
109
|
+
"<show>": import("@marko/compiler/babel-utils").Tag;
|
|
109
110
|
"<static>": import("@marko/compiler/babel-utils").Tag;
|
|
110
111
|
"<style>": import("@marko/compiler/babel-utils").Tag;
|
|
111
112
|
"<try>": import("@marko/compiler/babel-utils").Tag;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { types as t } from "@marko/compiler";
|
|
2
|
+
import { type Tag } from "@marko/compiler/babel-utils";
|
|
3
|
+
import { type Binding } from "../util/references";
|
|
4
|
+
declare const kStartBinding: unique symbol;
|
|
5
|
+
declare const kStaticDisplay: unique symbol;
|
|
6
|
+
declare const kSingleNodeBody: unique symbol;
|
|
7
|
+
declare const kDisplayRef: unique symbol;
|
|
8
|
+
declare module "@marko/compiler/dist/types" {
|
|
9
|
+
interface NodeExtra {
|
|
10
|
+
[kStartBinding]?: Binding;
|
|
11
|
+
[kStaticDisplay]?: boolean;
|
|
12
|
+
[kSingleNodeBody]?: boolean;
|
|
13
|
+
[kDisplayRef]?: t.Expression;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
declare const _default: Tag;
|
|
17
|
+
export default _default;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { type Tag } from "@marko/compiler/babel-utils";
|
|
2
|
+
import { type Binding } from "../util/references";
|
|
3
|
+
interface DynamicStyle {
|
|
4
|
+
names: string[];
|
|
5
|
+
binding: Binding;
|
|
6
|
+
}
|
|
2
7
|
declare module "@marko/compiler/dist/types" {
|
|
3
8
|
interface NodeExtra {
|
|
4
9
|
styleImportPath?: string | null;
|
|
10
|
+
dynamicStyle?: DynamicStyle;
|
|
5
11
|
}
|
|
6
12
|
}
|
|
7
13
|
declare const _default: Tag;
|
|
@@ -113,6 +113,7 @@ export declare const taglibs: (string | {
|
|
|
113
113
|
"<return>": import("@marko/compiler/babel-utils").Tag;
|
|
114
114
|
"<script>": import("@marko/compiler/babel-utils").Tag;
|
|
115
115
|
"<server>": import("@marko/compiler/babel-utils").Tag;
|
|
116
|
+
"<show>": import("@marko/compiler/babel-utils").Tag;
|
|
116
117
|
"<static>": import("@marko/compiler/babel-utils").Tag;
|
|
117
118
|
"<style>": import("@marko/compiler/babel-utils").Tag;
|
|
118
119
|
"<try>": import("@marko/compiler/babel-utils").Tag;
|