marko 6.1.23 → 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/accessor.d.ts +4 -0
- package/dist/common/accessor.debug.d.ts +4 -0
- package/dist/common/helpers.d.ts +1 -0
- package/dist/common/types.d.ts +1 -1
- package/dist/debug/dom.js +100 -2
- package/dist/debug/dom.mjs +97 -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/signals.d.ts +1 -0
- package/dist/dom.d.ts +3 -3
- package/dist/dom.js +68 -3
- package/dist/dom.mjs +68 -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 +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 +587 -76
- package/dist/translator/util/for-selector.d.ts +5 -0
- package/dist/translator/util/references.d.ts +4 -0
- package/dist/translator/util/signals.d.ts +5 -0
- package/dist/translator/util/style-interpolation.d.ts +3 -0
- package/dist/translator/util/to-property-name.d.ts +1 -0
- package/package.json +1 -1
package/dist/dom.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ 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";
|
|
13
13
|
export { _content, _content_closures, _content_resume } from "./dom/renderer";
|
|
14
14
|
export { _el, _resume, _var_resume, init, initEmbedded, ready, } from "./dom/resume";
|
|
15
15
|
export { _assert_init } from "./dom/scope";
|
|
16
|
-
export { _child_setup, _closure, _closure_get, _const, _el_read, _for_closure, _hoist, _hoist_resume, _id, _if_closure, _let, _let_change, _or, _return, _return_change, _script, _var, _var_change, } from "./dom/signals";
|
|
16
|
+
export { _child_setup, _closure, _closure_get, _const, _el_read, _for_closure, _for_selector, _hoist, _hoist_resume, _id, _if_closure, _let, _let_change, _or, _return, _return_change, _script, _var, _var_change, } from "./dom/signals";
|
|
17
17
|
export { _template } from "./dom/template";
|
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
|
}
|
|
@@ -303,6 +308,36 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
303
308
|
};
|
|
304
309
|
return ownerSignal._ = fn, ownerSignal;
|
|
305
310
|
}
|
|
311
|
+
function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, keyValueAccessor, fn) {
|
|
312
|
+
ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor), ownerValueAccessor = decodeAccessor(ownerValueAccessor), keyValueAccessor !== "M" && (keyValueAccessor = decodeAccessor(keyValueAccessor));
|
|
313
|
+
let scopeAccessor = "A" + ownerLoopNodeAccessor, mapAccessor = "O" + ownerLoopNodeAccessor, prevKeyProp = `_${ownerValueAccessor}`, ownerSignal = (ownerScope) => {
|
|
314
|
+
let scopes = toArray(ownerScope[scopeAccessor]);
|
|
315
|
+
if (ownerScope.H < runId && scopes.length) {
|
|
316
|
+
let nextKey = ownerScope[ownerValueAccessor];
|
|
317
|
+
queueRender(ownerScope, () => {
|
|
318
|
+
let map = keyedScopes(ownerScope, scopeAccessor, mapAccessor, keyValueAccessor);
|
|
319
|
+
if (map && prevKeyProp in map) {
|
|
320
|
+
let prevScope = map.get(map[prevKeyProp]), nextScope = map.get(nextKey);
|
|
321
|
+
prevScope !== nextScope && (runLiveBranch(prevScope, fn), runLiveBranch(nextScope, fn));
|
|
322
|
+
} else for (let scope of toArray(ownerScope[scopeAccessor])) runLiveBranch(scope, fn);
|
|
323
|
+
map && (map[prevKeyProp] = nextKey);
|
|
324
|
+
}, -1, 0, scopes[0].L);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
return ownerSignal._ = fn, ownerSignal;
|
|
328
|
+
}
|
|
329
|
+
function keyedScopes(ownerScope, scopeAccessor, mapAccessor, keyValueAccessor) {
|
|
330
|
+
let map = ownerScope[mapAccessor] ||= /* @__PURE__ */ new Map();
|
|
331
|
+
if (!map.size) for (let scope of toArray(ownerScope[scopeAccessor])) {
|
|
332
|
+
let key = scope.M ?? scope[keyValueAccessor];
|
|
333
|
+
if (key === void 0) return ownerScope[mapAccessor] = null;
|
|
334
|
+
scope.M = key, map.set(key, scope);
|
|
335
|
+
}
|
|
336
|
+
return map;
|
|
337
|
+
}
|
|
338
|
+
function runLiveBranch(scope, fn) {
|
|
339
|
+
scope && scope.H > 0 && scope.H < runId && fn(scope);
|
|
340
|
+
}
|
|
306
341
|
function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
307
342
|
ownerConditionalNodeAccessor = decodeAccessor(ownerConditionalNodeAccessor);
|
|
308
343
|
let scopeAccessor = "A" + ownerConditionalNodeAccessor, branchAccessor = "D" + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
|
@@ -732,6 +767,19 @@ function _attr_style_items(element, items) {
|
|
|
732
767
|
function _attr_style_item(element, name, value) {
|
|
733
768
|
element.style.setProperty(name, _to_text(value));
|
|
734
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
|
+
}
|
|
735
783
|
function _attr_nonce(scope, nodeAccessor) {
|
|
736
784
|
_attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
|
|
737
785
|
}
|
|
@@ -982,6 +1030,21 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
982
1030
|
newBranch !== (scope[branchAccessor] ?? (scope["A" + nodeAccessor] && 0)) && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
983
1031
|
};
|
|
984
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
|
+
}
|
|
985
1048
|
function patchDynamicTag(fn) {
|
|
986
1049
|
_dynamic_tag = fn(_dynamic_tag);
|
|
987
1050
|
}
|
|
@@ -1006,9 +1069,11 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch)
|
|
|
1006
1069
|
function loop(forEach) {
|
|
1007
1070
|
return (nodeAccessor, template, walks, setup, params) => {
|
|
1008
1071
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1009
|
-
let scopesAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
1072
|
+
let scopesAccessor = "A" + nodeAccessor, keyedScopesAccessor = "O" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
1010
1073
|
return enableBranches(), (scope, value) => {
|
|
1011
|
-
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), newScopes = scope[scopesAccessor] = []
|
|
1074
|
+
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), newScopes = scope[scopesAccessor] = [];
|
|
1075
|
+
scope[keyedScopesAccessor] = null;
|
|
1076
|
+
let oldLen = oldScopes.length, parentNode = referenceNode.nodeType > 1 ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode, oldScopesByKey, hasPotentialMoves;
|
|
1012
1077
|
forEach(value, (key, args) => {
|
|
1013
1078
|
let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce((map, scope, i) => map.set(scope.M ?? i, scope), /* @__PURE__ */ new Map())).get(key);
|
|
1014
1079
|
branch ? hasPotentialMoves = oldScopesByKey.delete(key) : branch = createAndSetupBranch(scope.$, renderer, scope, parentNode), branch.M = key, newScopes.push(branch), params?.(branch, args);
|
|
@@ -1283,4 +1348,4 @@ exports.$signal = $signal, exports.$signalReset = $signalReset, exports._assert_
|
|
|
1283
1348
|
get: function() {
|
|
1284
1349
|
return _dynamic_tag;
|
|
1285
1350
|
}
|
|
1286
|
-
}), 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_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
|
}
|
|
@@ -302,6 +307,36 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
302
307
|
};
|
|
303
308
|
return ownerSignal._ = fn, ownerSignal;
|
|
304
309
|
}
|
|
310
|
+
function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, keyValueAccessor, fn) {
|
|
311
|
+
ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor), ownerValueAccessor = decodeAccessor(ownerValueAccessor), keyValueAccessor !== "M" && (keyValueAccessor = decodeAccessor(keyValueAccessor));
|
|
312
|
+
let scopeAccessor = "A" + ownerLoopNodeAccessor, mapAccessor = "O" + ownerLoopNodeAccessor, prevKeyProp = `_${ownerValueAccessor}`, ownerSignal = (ownerScope) => {
|
|
313
|
+
let scopes = toArray(ownerScope[scopeAccessor]);
|
|
314
|
+
if (ownerScope.H < runId && scopes.length) {
|
|
315
|
+
let nextKey = ownerScope[ownerValueAccessor];
|
|
316
|
+
queueRender(ownerScope, () => {
|
|
317
|
+
let map = keyedScopes(ownerScope, scopeAccessor, mapAccessor, keyValueAccessor);
|
|
318
|
+
if (map && prevKeyProp in map) {
|
|
319
|
+
let prevScope = map.get(map[prevKeyProp]), nextScope = map.get(nextKey);
|
|
320
|
+
prevScope !== nextScope && (runLiveBranch(prevScope, fn), runLiveBranch(nextScope, fn));
|
|
321
|
+
} else for (let scope of toArray(ownerScope[scopeAccessor])) runLiveBranch(scope, fn);
|
|
322
|
+
map && (map[prevKeyProp] = nextKey);
|
|
323
|
+
}, -1, 0, scopes[0].L);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
return ownerSignal._ = fn, ownerSignal;
|
|
327
|
+
}
|
|
328
|
+
function keyedScopes(ownerScope, scopeAccessor, mapAccessor, keyValueAccessor) {
|
|
329
|
+
let map = ownerScope[mapAccessor] ||= /* @__PURE__ */ new Map();
|
|
330
|
+
if (!map.size) for (let scope of toArray(ownerScope[scopeAccessor])) {
|
|
331
|
+
let key = scope.M ?? scope[keyValueAccessor];
|
|
332
|
+
if (key === void 0) return ownerScope[mapAccessor] = null;
|
|
333
|
+
scope.M = key, map.set(key, scope);
|
|
334
|
+
}
|
|
335
|
+
return map;
|
|
336
|
+
}
|
|
337
|
+
function runLiveBranch(scope, fn) {
|
|
338
|
+
scope && scope.H > 0 && scope.H < runId && fn(scope);
|
|
339
|
+
}
|
|
305
340
|
function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
306
341
|
ownerConditionalNodeAccessor = decodeAccessor(ownerConditionalNodeAccessor);
|
|
307
342
|
let scopeAccessor = "A" + ownerConditionalNodeAccessor, branchAccessor = "D" + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
|
@@ -731,6 +766,19 @@ function _attr_style_items(element, items) {
|
|
|
731
766
|
function _attr_style_item(element, name, value) {
|
|
732
767
|
element.style.setProperty(name, _to_text(value));
|
|
733
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
|
+
}
|
|
734
782
|
function _attr_nonce(scope, nodeAccessor) {
|
|
735
783
|
_attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
|
|
736
784
|
}
|
|
@@ -981,6 +1029,21 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
981
1029
|
newBranch !== (scope[branchAccessor] ?? (scope["A" + nodeAccessor] && 0)) && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
982
1030
|
};
|
|
983
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
|
+
}
|
|
984
1047
|
function patchDynamicTag(fn) {
|
|
985
1048
|
_dynamic_tag = fn(_dynamic_tag);
|
|
986
1049
|
}
|
|
@@ -1005,9 +1068,11 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch)
|
|
|
1005
1068
|
function loop(forEach) {
|
|
1006
1069
|
return (nodeAccessor, template, walks, setup, params) => {
|
|
1007
1070
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1008
|
-
let scopesAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
1071
|
+
let scopesAccessor = "A" + nodeAccessor, keyedScopesAccessor = "O" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
1009
1072
|
return enableBranches(), (scope, value) => {
|
|
1010
|
-
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), newScopes = scope[scopesAccessor] = []
|
|
1073
|
+
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), newScopes = scope[scopesAccessor] = [];
|
|
1074
|
+
scope[keyedScopesAccessor] = null;
|
|
1075
|
+
let oldLen = oldScopes.length, parentNode = referenceNode.nodeType > 1 ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode, oldScopesByKey, hasPotentialMoves;
|
|
1011
1076
|
forEach(value, (key, args) => {
|
|
1012
1077
|
let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce((map, scope, i) => map.set(scope.M ?? i, scope), /* @__PURE__ */ new Map())).get(key);
|
|
1013
1078
|
branch ? hasPotentialMoves = oldScopesByKey.delete(key) : branch = createAndSetupBranch(scope.$, renderer, scope, parentNode), branch.M = key, newScopes.push(branch), params?.(branch, args);
|
|
@@ -1278,4 +1343,4 @@ function getSelectorOrResolve(selector, resolve) {
|
|
|
1278
1343
|
return document.querySelector(selector) || resolve();
|
|
1279
1344
|
}
|
|
1280
1345
|
//#endregion
|
|
1281
|
-
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_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;
|
|
@@ -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
|
@@ -56,6 +56,8 @@ export declare function _for_in(obj: Falsy | {}, cb: (key: string, value: unknow
|
|
|
56
56
|
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
57
|
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
58
|
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;
|
|
59
|
+
export declare function _show_start(display: unknown, mark?: unknown): void;
|
|
60
|
+
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
61
|
declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
|
|
60
62
|
export { writeScope as _scope };
|
|
61
63
|
export declare function _existing_scope(scopeId: number): ScopeInternals;
|
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, "\\$&").replace(/</g, "\\3C ");
|
|
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
|
}
|
|
@@ -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();) {
|
|
@@ -1490,7 +1505,7 @@ var State = class {
|
|
|
1490
1505
|
readyResumeScripts && (needsWalk = !0);
|
|
1491
1506
|
let { effects } = this, { 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,7 +1516,7 @@ 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
|
}
|
|
@@ -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, "\\$&").replace(/</g, "\\3C ");
|
|
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
|
}
|
|
@@ -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();) {
|
|
@@ -1489,7 +1504,7 @@ var State = class {
|
|
|
1489
1504
|
readyResumeScripts && (needsWalk = !0);
|
|
1490
1505
|
let { effects } = this, { 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,7 +1515,7 @@ 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
|
}
|
|
@@ -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;
|