marko 6.3.34 → 6.3.36
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/cheatsheet.md +2 -2
- package/dist/common/constants/accessor-prefix.d.ts +1 -0
- package/dist/common/constants/accessor-prefix.debug.d.ts +1 -0
- package/dist/common/errors.d.ts +1 -0
- package/dist/common/meta.d.ts +1 -0
- package/dist/common/types.d.ts +10 -0
- package/dist/debug/dom/catch.feat.js +1 -1
- package/dist/debug/dom/catch.feat.mjs +1 -1
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +1 -1
- package/dist/debug/dom/controllable.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.js +7 -0
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +6 -0
- package/dist/debug/{dom-Bj58jt8y.js → dom-BbFAdZEB.js} +54 -17
- package/dist/debug/{dom-klf8Ec_o.mjs → dom-ClMc0GK9.mjs} +43 -18
- package/dist/debug/dom.js +1 -1
- package/dist/debug/dom.mjs +1 -1
- package/dist/debug/html.js +94 -25
- package/dist/debug/html.mjs +94 -25
- package/dist/dom/catch.feat.js +4 -4
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/control-flow.d.ts +3 -0
- package/dist/dom/controllable-input.feat.js +2 -2
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +2 -2
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +2 -2
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +2 -2
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +2 -2
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.d.ts +1 -0
- package/dist/dom/dynamic-tag-var.feat.js +3 -0
- package/dist/dom/dynamic-tag-var.feat.mjs +4 -0
- package/dist/dom/signals.d.ts +3 -3
- package/dist/{dom-B-XpL2_H.js → dom-59H9kVUF.js} +133 -118
- package/dist/{dom-6hBvZW7X.mjs → dom-BKDjlXIl.mjs} +25 -15
- package/dist/dom.js +34 -34
- package/dist/dom.mjs +1 -1
- package/dist/html/dynamic-tag.d.ts +1 -1
- package/dist/html/serializer.d.ts +9 -1
- package/dist/html/template.d.ts +1 -0
- package/dist/html/writer.d.ts +1 -0
- package/dist/html.js +19 -13
- package/dist/html.mjs +19 -13
- package/dist/translator/index.js +287 -101
- package/dist/translator/util/references.d.ts +1 -0
- package/dist/translator/util/runtime.d.ts +1 -1
- package/dist/translator/util/signals.d.ts +2 -0
- package/dist/translator/util/translate-var.d.ts +1 -1
- package/dist/translator/util/traverse.d.ts +2 -0
- package/dist/translator/visitors/export-declaration.d.ts +8 -0
- package/package.json +4 -4
- package/tags/let.d.marko +3 -4
|
@@ -52,7 +52,7 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
|
|
|
52
52
|
let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
|
|
53
53
|
return (scope, newRenderer, getInput) => {
|
|
54
54
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
|
55
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer
|
|
55
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) if (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer), getTagVar && (scope[childScopeAccessor] ? (scope[childScopeAccessor].T = (value) => getTagVar()(scope, value), typeof normalizedRenderer == "string" && bindNativeTagVar?.(scope[childScopeAccessor])) : getTagVar()(scope, void 0)), typeof normalizedRenderer == "string") {
|
|
56
56
|
if (getContent) {
|
|
57
57
|
let content = getContent(scope);
|
|
58
58
|
setConditionalRenderer(scope[childScopeAccessor], "a", content, createAndSetupBranch), content.f && subscribeToScopeSet(content.e, content.f, scope[childScopeAccessor].Aa);
|
|
@@ -78,9 +78,9 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
|
|
|
78
78
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
79
79
|
let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
|
|
80
80
|
return (scope, renderer) => {
|
|
81
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = renderer
|
|
81
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(renderer)) && (setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch), renderer?.f && subscribeToScopeSet(renderer.e, renderer.f, scope[childScopeAccessor])), renderer) for (let accessor in renderer.g) renderer.g[accessor](scope[childScopeAccessor], renderer.h[accessor]);
|
|
82
82
|
};
|
|
83
|
-
}), _resume_dynamic_tag = /*@__PURE__*/ withBranches(() => _resume("d", dynamicTagScript)), loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, walks, setup, params) => {
|
|
83
|
+
}), bindNativeTagVar, _resume_dynamic_tag = /*@__PURE__*/ withBranches(() => _resume("d", dynamicTagScript)), loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, walks, setup, params) => {
|
|
84
84
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
85
85
|
let scopesAccessor = "A" + nodeAccessor, keyedScopesAccessor = "O" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
86
86
|
return (scope, value) => {
|
|
@@ -462,9 +462,13 @@ function _var(scope, childAccessor, signal) {
|
|
|
462
462
|
function _return_change(scope, changeHandler) {
|
|
463
463
|
scope.U = changeHandler || void 0;
|
|
464
464
|
}
|
|
465
|
-
function _id(
|
|
466
|
-
let id =
|
|
467
|
-
|
|
465
|
+
function _id(scope, accessor) {
|
|
466
|
+
let id = accessor !== void 0 && scope[accessor];
|
|
467
|
+
if (!id) {
|
|
468
|
+
let $global = scope.$, n = tagIdsByGlobal.get($global) || 0;
|
|
469
|
+
tagIdsByGlobal.set($global, n + 1), id = "c" + $global.runtimeId + $global.renderId + n.toString(36), accessor !== void 0 && (scope[accessor] = id);
|
|
470
|
+
}
|
|
471
|
+
return id;
|
|
468
472
|
}
|
|
469
473
|
function _script(id, fn) {
|
|
470
474
|
return _resume(id, fn), (scope) => {
|
|
@@ -474,17 +478,17 @@ function _script(id, fn) {
|
|
|
474
478
|
function _el_read(value) {
|
|
475
479
|
return value;
|
|
476
480
|
}
|
|
477
|
-
function* traverse(scope, path, i = path.length - 1) {
|
|
478
|
-
if (scope) if (Symbol.iterator in scope) for (let childScope of scope.values()) yield* traverse(childScope, path, i);
|
|
481
|
+
function* traverse(scope, path, args, i = path.length - 1) {
|
|
482
|
+
if (scope) if (Symbol.iterator in scope) for (let childScope of scope.values()) yield* traverse(childScope, path, args, i);
|
|
479
483
|
else {
|
|
480
484
|
let item = scope[path[i]];
|
|
481
|
-
i ? yield* traverse(item, path, i - 1) : yield typeof item == "function" ? item() : item;
|
|
485
|
+
i ? yield* traverse(item, path, args, i - 1) : yield typeof item == "function" ? item(...args) : item;
|
|
482
486
|
}
|
|
483
487
|
}
|
|
484
488
|
function _hoist(...path) {
|
|
485
489
|
return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
|
|
486
|
-
let fn = () => traverse(scope, path).next().value;
|
|
487
|
-
return fn[Symbol.iterator] = () => traverse(scope, path), fn;
|
|
490
|
+
let fn = (...args) => traverse(scope, path, args).next().value;
|
|
491
|
+
return fn[Symbol.iterator] = () => traverse(scope, path, []), fn;
|
|
488
492
|
};
|
|
489
493
|
}
|
|
490
494
|
function _hoist_resume(id, ...path) {
|
|
@@ -689,7 +693,7 @@ function _attr_style_item(element, name, value) {
|
|
|
689
693
|
}
|
|
690
694
|
function _style_shell(scope, nodeAccessor) {
|
|
691
695
|
let element = scope[nodeAccessor], id = _id(scope);
|
|
692
|
-
_attr_nonce(scope, nodeAccessor), element
|
|
696
|
+
_attr_nonce(scope, nodeAccessor), _attr(element, "class", id), _text_content(element, "." + id + "~*{}");
|
|
693
697
|
}
|
|
694
698
|
function _style_rule_item(element, name, value) {
|
|
695
699
|
let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
|
|
@@ -756,7 +760,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
|
|
|
756
760
|
}
|
|
757
761
|
function _attr_content(scope, nodeAccessor, value) {
|
|
758
762
|
let content = normalizeClientRender(value);
|
|
759
|
-
scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = content
|
|
763
|
+
scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = rendererKey(content)) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
|
|
760
764
|
for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
|
|
761
765
|
}
|
|
762
766
|
function _attrs_script(scope, nodeAccessor) {
|
|
@@ -874,7 +878,7 @@ function _attr_input_value_dynamic_default(scope, nodeAccessor, value) {
|
|
|
874
878
|
}
|
|
875
879
|
function _attr_input_value(scope, nodeAccessor, value, valueChange, setDefault = _attr_input_value_default) {
|
|
876
880
|
let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
|
|
877
|
-
scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange && scope.H < runId ? setInputValue(el, normalizedValue) : setDefault(scope, nodeAccessor,
|
|
881
|
+
scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange && scope.H < runId ? setInputValue(el, normalizedValue) : setDefault(scope, nodeAccessor, value);
|
|
878
882
|
}
|
|
879
883
|
function _attr_input_value_attribute_default(scope, nodeAccessor, value) {
|
|
880
884
|
_attr(scope[nodeAccessor], "value", value);
|
|
@@ -1119,9 +1123,15 @@ function renderCatch(scope, error) {
|
|
|
1119
1123
|
placeholderBranch && (tryWithCatch.O && (tryWithCatch.O.i = 0), owner["A" + tryWithCatch.C] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(owner, tryWithCatch.C, tryWithCatch.E, createAndSetupBranch), tryWithCatch.E?.d?.(owner["A" + tryWithCatch.C], [error]);
|
|
1120
1124
|
} else throw error;
|
|
1121
1125
|
}
|
|
1126
|
+
function rendererKey(renderer) {
|
|
1127
|
+
return renderer?.e ? renderer.a + " " + renderer.e.L : renderer?.a || renderer;
|
|
1128
|
+
}
|
|
1122
1129
|
function patchDynamicTag(fn) {
|
|
1123
1130
|
_dynamic_tag = fn(_dynamic_tag);
|
|
1124
1131
|
}
|
|
1132
|
+
function installDynamicTagVar(bind) {
|
|
1133
|
+
bindNativeTagVar = bind;
|
|
1134
|
+
}
|
|
1125
1135
|
function dynamicTagScript(branch) {
|
|
1126
1136
|
_attrs_script(branch, "a");
|
|
1127
1137
|
}
|
|
@@ -1140,4 +1150,4 @@ function byFirstArg(name) {
|
|
|
1140
1150
|
return name;
|
|
1141
1151
|
}
|
|
1142
1152
|
//#endregion
|
|
1143
|
-
export {
|
|
1153
|
+
export { _attrs_script as $, queueAsyncRender as $t, _attr_input_value_script as A, _hoist_resume as At, _attr as B, _var_change as Bt, _attr_input_checkedValue_script as C, _closure as Ct, _attr_input_value_attribute_default as D, _for_closure as Dt, _attr_input_value as E, _el_read as Et, _controllable_open as F, _or as Ft, _attr_nonce as G, syncGen as Gt, _attr_class_item as H, destroyBranch as Ht, _controllable_select as I, _return as It, _attr_style_items as J, $signalReset as Jt, _attr_style as K, _on as Kt, _controllable_textarea as L, _return_change as Lt, _attr_select_value_default as M, _if_closure as Mt, _attr_select_value_script as N, _let as Nt, _attr_input_value_default as O, _for_selector as Ot, _controllable_input as P, _let_change as Pt, _attrs_partial_content as Q, prepareEffects as Qt, controllableRenders as R, _script as Rt, _attr_input_checkedValue_default as S, _child_setup as St, _attr_input_checked_script as T, _const as Tt, _attr_class_items as U, insertBranchBefore as Ut, _attr_class as V, _assert_init as Vt, _attr_content as W, removeAndDestroyBranch as Wt, _attrs_content as X, installCatch as Xt, _attrs as Y, caughtError as Yt, _attrs_partial as Z, placeholderShown as Zt, _attr_details_or_dialog_open as _, _var_resume as _t, _for_in as a, forOf as an, _text_content as at, _attr_input_checked as b, initEmbedded as bt, _for_until as c, _assert_hoist as cn, toInsertNode as ct, _show as d, _content_resume as dt, queueEffect as en, _html as et, _try as f, createAndSetupBranch as ft, renderCatch as g, _resume as gt, patchDynamicTag as h, _el as ht, _dynamic_tag_content as i, forIn as in, _text as it, _attr_select_value as j, _id as jt, _attr_input_value_dynamic_default as k, _hoist as kt, _if as l, _call as ln, _content as lt, installDynamicTagVar as m, setupBranch as mt, _await_promise as n, runEffects as nn, _style_rule_item as nt, _for_of as o, forTo as on, _to_text as ot, addAwaitCounter as p, createBranch as pt, _attr_style_item as q, $signal as qt, _dynamic_tag as r, runId as rn, _style_shell as rt, _for_to as s, forUntil as sn, insertChildNodes as st, _await_content as t, run as tn, _lifecycle as tt, _resume_dynamic_tag as u, decodeAccessor as un, _content_closures as ut, _attr_details_or_dialog_open_default as v, getRegisteredWithScope as vt, _attr_input_checked_default as w, _closure_get as wt, _attr_input_checkedValue as x, ready as xt, _attr_details_or_dialog_open_script as y, init as yt, controllableScripts as z, _var as zt };
|
package/dist/dom.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
let require_control_flow = require("./dom-
|
|
2
|
-
require_control_flow.
|
|
1
|
+
let require_control_flow = require("./dom-59H9kVUF.js"), empty = [], rest = Symbol(), classIdToBranch = /* @__PURE__ */ new Map(), classEventResolver, scopesByRender = /* @__PURE__ */ new WeakMap(), getRenderScopes = ($global) => {
|
|
2
|
+
require_control_flow.yt($global.runtimeId);
|
|
3
3
|
let render = self[$global.runtimeId]?.[$global.renderId], scopes = render && scopesByRender.get(render);
|
|
4
4
|
return render && !scopes && scopesByRender.set(render, scopes = {}), scopes;
|
|
5
5
|
}, compat = {
|
|
6
|
-
patchDynamicTag: require_control_flow.
|
|
7
|
-
queueEffect: require_control_flow
|
|
6
|
+
patchDynamicTag: require_control_flow.h,
|
|
7
|
+
queueEffect: require_control_flow.en,
|
|
8
8
|
init(warp10Noop) {
|
|
9
|
-
require_control_flow.
|
|
9
|
+
require_control_flow.gt("$C_s", (scope) => {
|
|
10
10
|
if (getRenderScopes(scope.$)[scope.L] = scope, scope.m5c && classIdToBranch.set(scope.m5c, scope), classEventResolver) for (let key in scope) {
|
|
11
11
|
let resolved = classEventResolver(scope[key], scope);
|
|
12
12
|
resolved !== scope[key] && (scope[key] = resolved);
|
|
13
13
|
}
|
|
14
|
-
}), require_control_flow.
|
|
14
|
+
}), require_control_flow.gt("$C_b", warp10Noop);
|
|
15
15
|
},
|
|
16
16
|
setClassEventResolver(fn) {
|
|
17
17
|
classEventResolver = fn;
|
|
@@ -35,35 +35,35 @@ let require_control_flow = require("./dom-B-XpL2_H.js"), empty = [], rest = Symb
|
|
|
35
35
|
branch.S = startNode, branch.K = endNode;
|
|
36
36
|
},
|
|
37
37
|
runComponentEffects() {
|
|
38
|
-
this.effects && require_control_flow.
|
|
38
|
+
this.effects && require_control_flow.nn(this.effects);
|
|
39
39
|
},
|
|
40
40
|
runComponentDestroy() {
|
|
41
|
-
this.scope && require_control_flow.
|
|
41
|
+
this.scope && require_control_flow.Ht(this.scope);
|
|
42
42
|
},
|
|
43
43
|
resolveRegistered(value, $global) {
|
|
44
|
-
return Array.isArray(value) && typeof value[0] == "string" ? require_control_flow.
|
|
44
|
+
return Array.isArray(value) && typeof value[0] == "string" ? require_control_flow.vt(value[0], getRenderScopes($global)?.[value[1]]) : value;
|
|
45
45
|
},
|
|
46
46
|
createRenderer(params, clone) {
|
|
47
|
-
let renderer = require_control_flow.
|
|
47
|
+
let renderer = require_control_flow.lt("", 0, 0, 0, params)();
|
|
48
48
|
return renderer.b = (branch) => {
|
|
49
49
|
let cloned = clone();
|
|
50
50
|
branch.S = cloned.startNode, branch.K = cloned.endNode;
|
|
51
51
|
}, renderer;
|
|
52
52
|
},
|
|
53
53
|
render(out, component, renderer, args) {
|
|
54
|
-
require_control_flow.
|
|
54
|
+
require_control_flow.yt(out.global.runtimeId);
|
|
55
55
|
let branch = component.scope, created = 0;
|
|
56
56
|
if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), args[0] && typeof args[0] == "object" && "renderBody" in args[0]) {
|
|
57
57
|
let input = args[0], normalizedInput = args[0] = {};
|
|
58
58
|
for (let key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
|
59
59
|
}
|
|
60
|
-
if (component.effects = require_control_flow.
|
|
61
|
-
branch ||= (created = 1, component.scope = require_control_flow.
|
|
62
|
-
}), created) return require_control_flow.
|
|
60
|
+
if (component.effects = require_control_flow.Qt(() => {
|
|
61
|
+
branch ||= (created = 1, component.scope = require_control_flow.ft(out.global, renderer, renderer.e, document.body)), renderer.d?.(branch, renderer._ ? args[0] : args);
|
|
62
|
+
}), created) return require_control_flow.ct(branch.S, branch.K);
|
|
63
63
|
}
|
|
64
64
|
}, _template = (id, template, walks, setup, inputSignal) => {
|
|
65
|
-
let renderer = require_control_flow.
|
|
66
|
-
return renderer.mount = mount, renderer._ = renderer, require_control_flow.
|
|
65
|
+
let renderer = require_control_flow.lt(id, template, walks, setup, inputSignal)();
|
|
66
|
+
return renderer.mount = mount, renderer._ = renderer, require_control_flow.gt(id, renderer);
|
|
67
67
|
};
|
|
68
68
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
69
69
|
//#region src/common/attr-tag.ts
|
|
@@ -102,25 +102,25 @@ function mount(input = {}, reference, position) {
|
|
|
102
102
|
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
|
103
103
|
break;
|
|
104
104
|
}
|
|
105
|
-
let curValue, args = this.d, effects = require_control_flow.
|
|
106
|
-
branch = require_control_flow.
|
|
105
|
+
let curValue, args = this.d, effects = require_control_flow.Qt(() => {
|
|
106
|
+
branch = require_control_flow.pt($global, this, void 0, parentNode), branch.T = (newValue) => {
|
|
107
107
|
curValue = newValue;
|
|
108
108
|
}, this.c?.(branch), args?.(branch, input);
|
|
109
109
|
});
|
|
110
|
-
return require_control_flow.
|
|
110
|
+
return require_control_flow.st(parentNode, nextSibling, branch.S, branch.K), require_control_flow.nn(effects), {
|
|
111
111
|
get value() {
|
|
112
112
|
return curValue;
|
|
113
113
|
},
|
|
114
114
|
set value(newValue) {
|
|
115
|
-
require_control_flow.
|
|
115
|
+
require_control_flow.Bt(branch, newValue);
|
|
116
116
|
},
|
|
117
117
|
update(newInput = {}) {
|
|
118
|
-
args && (newInput.$global && ({$global, ...newInput} = newInput), require_control_flow.
|
|
118
|
+
args && (newInput.$global && ({$global, ...newInput} = newInput), require_control_flow.nn(require_control_flow.Qt(() => {
|
|
119
119
|
args(branch, newInput);
|
|
120
120
|
})));
|
|
121
121
|
},
|
|
122
122
|
destroy() {
|
|
123
|
-
require_control_flow.
|
|
123
|
+
require_control_flow.Wt(branch);
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
}
|
|
@@ -130,13 +130,13 @@ function _load_template(id, load) {
|
|
|
130
130
|
let pending, lazyTemplate = _template(id, 0, 0, (branch) => {
|
|
131
131
|
let awaitCounter = require_control_flow.p(branch);
|
|
132
132
|
branch.X ||= /* @__PURE__ */ new Map(), (pending ||= load()).then((renderer) => {
|
|
133
|
-
Object.assign(lazyTemplate, renderer), require_control_flow
|
|
133
|
+
Object.assign(lazyTemplate, renderer), require_control_flow.$t(branch, (branch) => insertLoaded(renderer, branch, branch.S, awaitCounter));
|
|
134
134
|
}, loadFailed(branch, awaitCounter));
|
|
135
135
|
}, _load_signal(() => (pending ||= load()).then((r) => ({ _: r.d }))));
|
|
136
136
|
return lazyTemplate;
|
|
137
137
|
}
|
|
138
138
|
function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
139
|
-
nodeAccessor = require_control_flow.
|
|
139
|
+
nodeAccessor = require_control_flow.un(nodeAccessor), childScopeAccessor = require_control_flow.un(childScopeAccessor);
|
|
140
140
|
let pending, renderer;
|
|
141
141
|
return (owner) => {
|
|
142
142
|
let child = owner[childScopeAccessor];
|
|
@@ -144,33 +144,33 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
|
144
144
|
else {
|
|
145
145
|
let awaitCounter = require_control_flow.p(owner);
|
|
146
146
|
child.X ||= /* @__PURE__ */ new Map(), (pending ||= load()).then((mod) => {
|
|
147
|
-
renderer = require_control_flow.
|
|
147
|
+
renderer = require_control_flow.lt("", ...mod._)(), require_control_flow.$t(child, (child) => insertLoaded(renderer, child, owner[nodeAccessor], awaitCounter));
|
|
148
148
|
}, loadFailed(child, awaitCounter));
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
function insertLoaded(renderer, branch, marker, awaitCounter) {
|
|
153
153
|
let parent = marker.parentNode, values = branch.X, insert = () => {
|
|
154
|
-
require_control_flow.
|
|
154
|
+
require_control_flow.Ut(branch, parent, marker), marker.remove(), awaitCounter?.c();
|
|
155
155
|
}, remaining;
|
|
156
|
-
if (require_control_flow.
|
|
156
|
+
if (require_control_flow.Gt(branch), renderer.b(branch, parent.namespaceURI), branch.X = 0, remaining = values?.size) {
|
|
157
157
|
let fail = loadFailed(branch, awaitCounter);
|
|
158
158
|
for (let [promise, entry] of values) promise.then((signal) => {
|
|
159
|
-
entry.b = signal, --remaining || require_control_flow
|
|
160
|
-
require_control_flow.
|
|
159
|
+
entry.b = signal, --remaining || require_control_flow.$t(branch, (branch) => {
|
|
160
|
+
require_control_flow.Gt(branch), renderer.c?.(branch), values.forEach((e) => e.b._(branch, e.a)), insert();
|
|
161
161
|
});
|
|
162
162
|
}, (error) => remaining > 0 && (remaining = 0, fail(error)));
|
|
163
|
-
} else require_control_flow.
|
|
163
|
+
} else require_control_flow.mt(renderer, branch), insert();
|
|
164
164
|
}
|
|
165
165
|
function loadFailed(scope, awaitCounter) {
|
|
166
166
|
return (error) => {
|
|
167
|
-
awaitCounter && (awaitCounter.m ? awaitCounter.i = 0 : awaitCounter.c()), require_control_flow
|
|
167
|
+
awaitCounter && (awaitCounter.m ? awaitCounter.i = 0 : awaitCounter.c()), require_control_flow.$t(scope, require_control_flow.g, error);
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
function _load_signal(load) {
|
|
171
171
|
let pending, signal;
|
|
172
172
|
return (scope, value) => {
|
|
173
|
-
pending ||= load(), scope.X || !("X" in scope) && scope.H === require_control_flow.
|
|
173
|
+
pending ||= load(), scope.X || !("X" in scope) && scope.H === require_control_flow.rn ? (scope.X ||= /* @__PURE__ */ new Map()).set(pending, { a: value }) : signal ? signal(scope, value) : pending.then((mod) => require_control_flow.$t(scope, signal = mod._, value), () => 0);
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
function _load_visible_trigger(selector, options) {
|
|
@@ -196,9 +196,9 @@ function _load_race_trigger(...triggers) {
|
|
|
196
196
|
function getSelectorOrResolve(selector, resolve) {
|
|
197
197
|
return document.querySelector(selector) || resolve();
|
|
198
198
|
}
|
|
199
|
-
exports.$signal = require_control_flow.
|
|
199
|
+
exports.$signal = require_control_flow.qt, exports.$signalReset = require_control_flow.Jt, exports._assert_hoist = require_control_flow.cn, exports._assert_init = require_control_flow.Vt, exports._attr = require_control_flow.B, exports._attr_class = require_control_flow.V, exports._attr_class_item = require_control_flow.H, exports._attr_class_items = require_control_flow.U, exports._attr_content = require_control_flow.W, exports._attr_details_open = require_control_flow._, exports._attr_dialog_open = require_control_flow._, exports._attr_details_open_default = require_control_flow.v, exports._attr_dialog_open_default = require_control_flow.v, exports._attr_details_open_script = require_control_flow.y, exports._attr_dialog_open_script = require_control_flow.y, exports._attr_input_checked = require_control_flow.b, exports._attr_input_checkedValue = require_control_flow.x, exports._attr_input_checkedValue_default = require_control_flow.S, exports._attr_input_checkedValue_script = require_control_flow.C, exports._attr_input_checked_default = require_control_flow.w, exports._attr_input_checked_script = require_control_flow.T, exports._attr_input_value = require_control_flow.E, exports._attr_textarea_value = require_control_flow.E, exports._attr_input_value_attribute_default = require_control_flow.D, exports._attr_input_value_default = require_control_flow.O, exports._attr_textarea_value_default = require_control_flow.O, exports._attr_input_value_dynamic_default = require_control_flow.k, exports._attr_input_value_script = require_control_flow.A, exports._attr_textarea_value_script = require_control_flow.A, exports._attr_nonce = require_control_flow.G, exports._attr_select_value = require_control_flow.j, exports._attr_select_value_default = require_control_flow.M, exports._attr_select_value_script = require_control_flow.N, exports._attr_style = require_control_flow.K, exports._attr_style_item = require_control_flow.q, exports._attr_style_items = require_control_flow.J, exports._attrs = require_control_flow.Y, exports._attrs_content = require_control_flow.X, exports._attrs_partial = require_control_flow.Z, exports._attrs_partial_content = require_control_flow.Q, exports._attrs_script = require_control_flow.$, exports._await_content = require_control_flow.t, exports._await_promise = require_control_flow.n, exports._call = require_control_flow.ln, exports._child_setup = require_control_flow.St, exports._closure = require_control_flow.Ct, exports._closure_get = require_control_flow.wt, exports._const = require_control_flow.Tt, exports._content = require_control_flow.lt, exports._content_closures = require_control_flow.ut, exports._content_resume = require_control_flow.dt, exports._controllable_input = require_control_flow.P, exports._controllable_open = require_control_flow.F, exports._controllable_select = require_control_flow.I, exports._controllable_textarea = require_control_flow.L, Object.defineProperty(exports, "_dynamic_tag", {
|
|
200
200
|
enumerable: !0,
|
|
201
201
|
get: function() {
|
|
202
202
|
return require_control_flow.r;
|
|
203
203
|
}
|
|
204
|
-
}), exports._dynamic_tag_content = require_control_flow.i, exports._el = require_control_flow.
|
|
204
|
+
}), exports._dynamic_tag_content = require_control_flow.i, exports._el = require_control_flow.ht, exports._el_read = require_control_flow.Et, exports._for_closure = require_control_flow.Dt, exports._for_in = require_control_flow.a, exports._for_of = require_control_flow.o, exports._for_selector = require_control_flow.Ot, exports._for_to = require_control_flow.s, exports._for_until = require_control_flow.c, exports._hoist = require_control_flow.kt, exports._hoist_resume = require_control_flow.At, exports._html = require_control_flow.et, exports._id = require_control_flow.jt, exports._if = require_control_flow.l, exports._if_closure = require_control_flow.Mt, exports._let = require_control_flow.Nt, exports._let_change = require_control_flow.Pt, exports._lifecycle = require_control_flow.tt, 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 = require_control_flow.Kt, exports._or = require_control_flow.Ft, exports._resume = require_control_flow.gt, exports._resume_dynamic_tag = require_control_flow.u, exports._return = require_control_flow.It, exports._return_change = require_control_flow.Lt, exports._script = require_control_flow.Rt, exports._show = require_control_flow.d, exports._style_rule_item = require_control_flow.nt, exports._style_shell = require_control_flow.rt, exports._template = _template, exports._text = require_control_flow.it, exports._text_content = require_control_flow.at, exports._to_text = require_control_flow.ot, exports._try = require_control_flow.f, exports._var = require_control_flow.zt, exports._var_change = require_control_flow.Bt, exports._var_resume = require_control_flow._t, exports.attrTag = attrTag, exports.attrTags = attrTags, exports.compat = compat, exports.forIn = require_control_flow.in, exports.forOf = require_control_flow.an, exports.forTo = require_control_flow.on, exports.forUntil = require_control_flow.sn, exports.init = require_control_flow.yt, exports.initEmbedded = require_control_flow.bt, exports.ready = require_control_flow.xt, exports.run = require_control_flow.tn;
|
package/dist/dom.mjs
CHANGED
|
@@ -65,7 +65,7 @@ let empty = [], rest = Symbol(), classIdToBranch = /* @__PURE__ */ new Map(), cl
|
|
|
65
65
|
let renderer = _content(id, template, walks, setup, inputSignal)();
|
|
66
66
|
return renderer.mount = mount, renderer._ = renderer, _resume(id, renderer);
|
|
67
67
|
};
|
|
68
|
-
import { $ as
|
|
68
|
+
import { $ as _attrs_script, $t as queueAsyncRender, A as _attr_input_value_script, At as _hoist_resume, B as _attr, Bt as _var_change, C as _attr_input_checkedValue_script, Ct as _closure, D as _attr_input_value_attribute_default, Dt as _for_closure, E as _attr_input_value, Et as _el_read, F as _controllable_open, Ft as _or, G as _attr_nonce, Gt as syncGen, H as _attr_class_item, Ht as destroyBranch, I as _controllable_select, It as _return, J as _attr_style_items, Jt as $signalReset, K as _attr_style, Kt as _on, L as _controllable_textarea, Lt as _return_change, M as _attr_select_value_default, Mt as _if_closure, N as _attr_select_value_script, Nt as _let, O as _attr_input_value_default, Ot as _for_selector, P as _controllable_input, Pt as _let_change, Q as _attrs_partial_content, Qt as prepareEffects, Rt as _script, S as _attr_input_checkedValue_default, St as _child_setup, T as _attr_input_checked_script, Tt as _const, U as _attr_class_items, Ut as insertBranchBefore, V as _attr_class, Vt as _assert_init, W as _attr_content, Wt as removeAndDestroyBranch, X as _attrs_content, Y as _attrs, Z as _attrs_partial, _ as _attr_details_or_dialog_open, _t as _var_resume, a as _for_in, an as forOf, at as _text_content, b as _attr_input_checked, bt as initEmbedded, c as _for_until, cn as _assert_hoist, ct as toInsertNode, d as _show, dt as _content_resume, en as queueEffect, et as _html, f as _try, ft as createAndSetupBranch, g as renderCatch, gt as _resume, h as patchDynamicTag, ht as _el, i as _dynamic_tag_content, in as forIn, it as _text, j as _attr_select_value, jt as _id, k as _attr_input_value_dynamic_default, kt as _hoist, l as _if, ln as _call, lt as _content, mt as setupBranch, n as _await_promise, nn as runEffects, nt as _style_rule_item, o as _for_of, on as forTo, ot as _to_text, p as addAwaitCounter, pt as createBranch, q as _attr_style_item, qt as $signal, r as _dynamic_tag, rn as runId, rt as _style_shell, s as _for_to, sn as forUntil, st as insertChildNodes, t as _await_content, tn as run, tt as _lifecycle, u as _resume_dynamic_tag, un as decodeAccessor, ut as _content_closures, v as _attr_details_or_dialog_open_default, vt as getRegisteredWithScope, w as _attr_input_checked_default, wt as _closure_get, x as _attr_input_checkedValue, xt as ready, y as _attr_details_or_dialog_open_script, yt as init, zt as _var } from "./dom-BKDjlXIl.mjs";
|
|
69
69
|
//#region src/common/attr-tag.ts
|
|
70
70
|
function attrTag(attrs) {
|
|
71
71
|
return attrs[Symbol.iterator] = attrTagIterator, attrs[rest] = empty, attrs;
|
|
@@ -5,7 +5,7 @@ interface BodyContentObject {
|
|
|
5
5
|
content: ServerRenderer;
|
|
6
6
|
}
|
|
7
7
|
export declare let _dynamic_tag: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, inputOrArgs: unknown, content?: (() => void) | 0, inputIsArgs?: 1, serializeReason?: 1 | 0) => unknown;
|
|
8
|
-
export declare function _content(id: string, fn: ServerRenderer): ServerRenderer;
|
|
8
|
+
export declare function _content(id: string, fn: ServerRenderer, scopeId?: number): ServerRenderer;
|
|
9
9
|
export declare function _content_resume(id: string, fn: ServerRenderer, scopeId?: number): ServerRenderer;
|
|
10
10
|
export declare const patchDynamicTag: (patch: (tag: unknown, scopeId: number, accessor: Accessor) => unknown) => void;
|
|
11
11
|
export {};
|
|
@@ -5,7 +5,14 @@ export interface SerializeChannel {
|
|
|
5
5
|
readyId?: string;
|
|
6
6
|
parent?: SerializeChannel;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
interface Debug {
|
|
9
|
+
file: string;
|
|
10
|
+
loc: string | 0;
|
|
11
|
+
vars: Record<string, string | [name: string, loc?: string]> | undefined;
|
|
12
|
+
slots?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
export declare function setDebugInfo(obj: WeakKey, file: string, loc: string | 0, vars?: Debug["vars"]): void;
|
|
15
|
+
export declare function setDebugSlotName(obj: WeakKey, accessor: string, name: string): void;
|
|
9
16
|
export declare class Serializer {
|
|
10
17
|
#private;
|
|
11
18
|
pending(channel?: SerializeChannel): boolean;
|
|
@@ -23,3 +30,4 @@ export declare function getRegistered(val: WeakKey): {
|
|
|
23
30
|
export declare function toObjectKey(name: string): string;
|
|
24
31
|
export declare function toAccess(accessor: string): string;
|
|
25
32
|
export declare function quote(str: string, startPos: number): string;
|
|
33
|
+
export {};
|
package/dist/html/template.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RendererProp, type Template } from "../common/types";
|
|
2
2
|
export type ServerRenderer = ((...args: unknown[]) => unknown) & {
|
|
3
3
|
[RendererProp.Id]?: string;
|
|
4
|
+
[RendererProp.Owner]?: number;
|
|
4
5
|
[RendererProp.Embed]?: boolean;
|
|
5
6
|
};
|
|
6
7
|
export declare const _template: (templateId: string, renderer: ServerRenderer, page?: 1) => Template;
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare function getChunk(): Chunk | undefined;
|
|
|
21
21
|
export declare function withChunk<T>(chunk: Chunk, cb: () => T): T;
|
|
22
22
|
export declare function getContext(key: keyof NonNullable<Chunk["context"]>): unknown;
|
|
23
23
|
export declare function getState(): State;
|
|
24
|
+
export declare function rendererKey(renderer: unknown): unknown;
|
|
24
25
|
export declare function getScopeId(scope: unknown): number | undefined;
|
|
25
26
|
export declare function getScopeById(scopeId: number | undefined): ScopeInternals | undefined;
|
|
26
27
|
export declare function $global(): $Global & {
|
package/dist/html.js
CHANGED
|
@@ -4,7 +4,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
4
4
|
else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
5
5
|
else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
6
6
|
return str;
|
|
7
|
-
}, unsafeXMLReg = /[
|
|
7
|
+
}, unsafeXMLReg = /[<&\r]/g, replaceUnsafeXML = (c) => c === "&" ? "&" : c === "<" ? "<" : " ", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<(\/?script|!--)/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str, unsafeStyleReg = /<(\/style)/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str, unsafeCommentReg = />/g, escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, ">") : str, K_SCOPE_ID = Symbol("Scope ID"), kTouchedIterator = Symbol.for("marko.touchedIterator"), { hasOwnProperty } = {}, objectProto = Object.prototype, arrayProto = Array.prototype, Generator = (function* () {})().constructor, AsyncGenerator = (async function* () {})().constructor, REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
8
8
|
let KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
|
|
9
9
|
for (let name of Object.getOwnPropertyNames(Symbol)) {
|
|
10
10
|
let symbol = Symbol[name];
|
|
@@ -255,15 +255,15 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
255
255
|
if (_scope_id(), _html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`), !voidElementsReg.test(renderer)) {
|
|
256
256
|
let renderContent = content || normalizeDynamicRenderer(input.content);
|
|
257
257
|
if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange, 1));
|
|
258
|
-
else
|
|
259
|
-
if (typeof renderContent != "function") throw Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
260
|
-
renderer === "select" && ("value" in input || "valueChange" in input) ? _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent, 1) : _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
|
|
258
|
+
else {
|
|
259
|
+
if (renderContent && typeof renderContent != "function") throw Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
260
|
+
renderer === "select" && ("value" in input || "valueChange" in input) ? _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason) : void 0, 1) : renderContent && _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
|
|
261
261
|
}
|
|
262
262
|
_html(`</${renderer}>`);
|
|
263
263
|
}
|
|
264
264
|
let childScope = getScopeById(branchId), needsScript = childScope && (childScope.Ia || childScope.Ea);
|
|
265
265
|
needsScript && _script(branchId, "d"), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
266
|
-
})();
|
|
266
|
+
})(), result = _el(branchId, "e");
|
|
267
267
|
} else {
|
|
268
268
|
let chunk = getChunk(), beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0, render = () => {
|
|
269
269
|
if (renderer) try {
|
|
@@ -278,7 +278,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
278
278
|
};
|
|
279
279
|
result = shouldResume ? withBranchId(branchId, render) : render(), rendered = _peek_scope_id() !== branchId, beforeBranch !== void 0 && (applyBranchStart(chunk, beforeBranch, rendered), _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : ""))));
|
|
280
280
|
}
|
|
281
|
-
return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: renderer
|
|
281
|
+
return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: rendererKey(renderer) }) : _scope_id(), result;
|
|
282
282
|
}, patchDynamicTag = ((originalDynamicTag) => (patch) => {
|
|
283
283
|
_dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
|
284
284
|
let patched = patch(tag, scopeId, accessor);
|
|
@@ -1264,6 +1264,9 @@ function getContext(key) {
|
|
|
1264
1264
|
function getState() {
|
|
1265
1265
|
return $chunk.boundary.state;
|
|
1266
1266
|
}
|
|
1267
|
+
function rendererKey(renderer) {
|
|
1268
|
+
return renderer?.e === void 0 ? renderer?.a || renderer : renderer.a + " " + renderer.e;
|
|
1269
|
+
}
|
|
1267
1270
|
function getScopeId(scope) {
|
|
1268
1271
|
return scope[K_SCOPE_ID];
|
|
1269
1272
|
}
|
|
@@ -1342,7 +1345,7 @@ function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
|
|
|
1342
1345
|
let shouldResume = serializeReason !== 0, render = normalizeServerRender(content), branchId = _peek_scope_id();
|
|
1343
1346
|
render && (shouldResume ? withBranchId(branchId, render) : render()), _peek_scope_id() === branchId ? _scope_id() : shouldResume && writeScope(scopeId, {
|
|
1344
1347
|
["A" + nodeAccessor]: writeScope(branchId, {}),
|
|
1345
|
-
["D" + nodeAccessor]: render
|
|
1348
|
+
["D" + nodeAccessor]: rendererKey(render)
|
|
1346
1349
|
});
|
|
1347
1350
|
}
|
|
1348
1351
|
function normalizeServerRender(value) {
|
|
@@ -1857,7 +1860,7 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, seriali
|
|
|
1857
1860
|
}
|
|
1858
1861
|
function _textarea_value(value) {
|
|
1859
1862
|
let escaped = _escape(normalizeStrAttrValue(value));
|
|
1860
|
-
return escaped[0] === "\n"
|
|
1863
|
+
return escaped[0] === "\n" ? "\n" + escaped : escaped;
|
|
1861
1864
|
}
|
|
1862
1865
|
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1863
1866
|
return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _attr("value", value);
|
|
@@ -1994,11 +1997,11 @@ function normalizeStrAttrValue(value) {
|
|
|
1994
1997
|
}
|
|
1995
1998
|
//#endregion
|
|
1996
1999
|
//#region src/html/dynamic-tag.ts
|
|
1997
|
-
function _content(id, fn) {
|
|
1998
|
-
return fn.a = id, fn;
|
|
2000
|
+
function _content(id, fn, scopeId) {
|
|
2001
|
+
return fn.a = id, fn.e = scopeId, fn;
|
|
1999
2002
|
}
|
|
2000
2003
|
function _content_resume(id, fn, scopeId) {
|
|
2001
|
-
return _resume(_content(id, fn), id, scopeId);
|
|
2004
|
+
return _resume(_content(id, fn, scopeId), id, scopeId);
|
|
2002
2005
|
}
|
|
2003
2006
|
//#endregion
|
|
2004
2007
|
//#region src/html/template.ts
|
|
@@ -2209,14 +2212,17 @@ function writeTriggerScript(html, triggers) {
|
|
|
2209
2212
|
let htmlStr = _escape_script(JSON.stringify(html)), exprs = triggers.map((trigger) => {
|
|
2210
2213
|
let options = trigger.options && toObjectExpression(trigger.options);
|
|
2211
2214
|
switch (trigger.type) {
|
|
2212
|
-
case "visible": return `(e=>e&&new IntersectionObserver((e,i)=>e.some(e=>e.isIntersecting)&&i.disconnect()+l()${options ? `,${options}` : ""}).observe(e))(
|
|
2215
|
+
case "visible": return `(e=>e&&new IntersectionObserver((e,i)=>e.some(e=>e.isIntersecting)&&i.disconnect()+l()${options ? `,${options}` : ""}).observe(e))(${querySelectorOrLoad(trigger.selector)})`;
|
|
2213
2216
|
case "idle": return `(self.requestIdleCallback||l)(l${options ? `,${options}` : ""})`;
|
|
2214
2217
|
case "media": return `(m=>m.matches?l():m.addEventListener("change",l,{once:1}))(matchMedia(${JSON.stringify(trigger.selector)}))`;
|
|
2215
|
-
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(
|
|
2218
|
+
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(${querySelectorOrLoad(trigger.selector)})`;
|
|
2216
2219
|
}
|
|
2217
2220
|
});
|
|
2218
2221
|
writeScript(`((p,h,d,l=$=>{d||p.after(new Range().createContextualFragment(d=h))})=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
|
|
2219
2222
|
}
|
|
2223
|
+
function querySelectorOrLoad(selector) {
|
|
2224
|
+
return `document.querySelector(${JSON.stringify(selector)})||l()`;
|
|
2225
|
+
}
|
|
2220
2226
|
function toObjectExpression(options) {
|
|
2221
2227
|
let result = "{", sep = "";
|
|
2222
2228
|
for (let key in options) Object.hasOwn(options, key) && (result += sep + toObjectKey(key) + ":" + JSON.stringify(options[key]), sep = ",");
|
package/dist/html.mjs
CHANGED
|
@@ -4,7 +4,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
4
4
|
else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
5
5
|
else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
6
6
|
return str;
|
|
7
|
-
}, unsafeXMLReg = /[
|
|
7
|
+
}, unsafeXMLReg = /[<&\r]/g, replaceUnsafeXML = (c) => c === "&" ? "&" : c === "<" ? "<" : " ", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<(\/?script|!--)/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str, unsafeStyleReg = /<(\/style)/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str, unsafeCommentReg = />/g, escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, ">") : str, K_SCOPE_ID = Symbol("Scope ID"), kTouchedIterator = Symbol.for("marko.touchedIterator"), { hasOwnProperty } = {}, objectProto = Object.prototype, arrayProto = Array.prototype, Generator = (function* () {})().constructor, AsyncGenerator = (async function* () {})().constructor, REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
8
8
|
let KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
|
|
9
9
|
for (let name of Object.getOwnPropertyNames(Symbol)) {
|
|
10
10
|
let symbol = Symbol[name];
|
|
@@ -255,15 +255,15 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
255
255
|
if (_scope_id(), _html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`), !voidElementsReg.test(renderer)) {
|
|
256
256
|
let renderContent = content || normalizeDynamicRenderer(input.content);
|
|
257
257
|
if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange, 1));
|
|
258
|
-
else
|
|
259
|
-
if (typeof renderContent != "function") throw Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
260
|
-
renderer === "select" && ("value" in input || "valueChange" in input) ? _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent, 1) : _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
|
|
258
|
+
else {
|
|
259
|
+
if (renderContent && typeof renderContent != "function") throw Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
260
|
+
renderer === "select" && ("value" in input || "valueChange" in input) ? _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason) : void 0, 1) : renderContent && _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
|
|
261
261
|
}
|
|
262
262
|
_html(`</${renderer}>`);
|
|
263
263
|
}
|
|
264
264
|
let childScope = getScopeById(branchId), needsScript = childScope && (childScope.Ia || childScope.Ea);
|
|
265
265
|
needsScript && _script(branchId, "d"), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
266
|
-
})();
|
|
266
|
+
})(), result = _el(branchId, "e");
|
|
267
267
|
} else {
|
|
268
268
|
let chunk = getChunk(), beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0, render = () => {
|
|
269
269
|
if (renderer) try {
|
|
@@ -278,7 +278,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
278
278
|
};
|
|
279
279
|
result = shouldResume ? withBranchId(branchId, render) : render(), rendered = _peek_scope_id() !== branchId, beforeBranch !== void 0 && (applyBranchStart(chunk, beforeBranch, rendered), _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : ""))));
|
|
280
280
|
}
|
|
281
|
-
return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: renderer
|
|
281
|
+
return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: rendererKey(renderer) }) : _scope_id(), result;
|
|
282
282
|
}, patchDynamicTag = ((originalDynamicTag) => (patch) => {
|
|
283
283
|
_dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
|
284
284
|
let patched = patch(tag, scopeId, accessor);
|
|
@@ -1263,6 +1263,9 @@ function getContext(key) {
|
|
|
1263
1263
|
function getState() {
|
|
1264
1264
|
return $chunk.boundary.state;
|
|
1265
1265
|
}
|
|
1266
|
+
function rendererKey(renderer) {
|
|
1267
|
+
return renderer?.e === void 0 ? renderer?.a || renderer : renderer.a + " " + renderer.e;
|
|
1268
|
+
}
|
|
1266
1269
|
function getScopeId(scope) {
|
|
1267
1270
|
return scope[K_SCOPE_ID];
|
|
1268
1271
|
}
|
|
@@ -1341,7 +1344,7 @@ function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
|
|
|
1341
1344
|
let shouldResume = serializeReason !== 0, render = normalizeServerRender(content), branchId = _peek_scope_id();
|
|
1342
1345
|
render && (shouldResume ? withBranchId(branchId, render) : render()), _peek_scope_id() === branchId ? _scope_id() : shouldResume && writeScope(scopeId, {
|
|
1343
1346
|
["A" + nodeAccessor]: writeScope(branchId, {}),
|
|
1344
|
-
["D" + nodeAccessor]: render
|
|
1347
|
+
["D" + nodeAccessor]: rendererKey(render)
|
|
1345
1348
|
});
|
|
1346
1349
|
}
|
|
1347
1350
|
function normalizeServerRender(value) {
|
|
@@ -1856,7 +1859,7 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, seriali
|
|
|
1856
1859
|
}
|
|
1857
1860
|
function _textarea_value(value) {
|
|
1858
1861
|
let escaped = _escape(normalizeStrAttrValue(value));
|
|
1859
|
-
return escaped[0] === "\n"
|
|
1862
|
+
return escaped[0] === "\n" ? "\n" + escaped : escaped;
|
|
1860
1863
|
}
|
|
1861
1864
|
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1862
1865
|
return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _attr("value", value);
|
|
@@ -1993,11 +1996,11 @@ function normalizeStrAttrValue(value) {
|
|
|
1993
1996
|
}
|
|
1994
1997
|
//#endregion
|
|
1995
1998
|
//#region src/html/dynamic-tag.ts
|
|
1996
|
-
function _content(id, fn) {
|
|
1997
|
-
return fn.a = id, fn;
|
|
1999
|
+
function _content(id, fn, scopeId) {
|
|
2000
|
+
return fn.a = id, fn.e = scopeId, fn;
|
|
1998
2001
|
}
|
|
1999
2002
|
function _content_resume(id, fn, scopeId) {
|
|
2000
|
-
return _resume(_content(id, fn), id, scopeId);
|
|
2003
|
+
return _resume(_content(id, fn, scopeId), id, scopeId);
|
|
2001
2004
|
}
|
|
2002
2005
|
//#endregion
|
|
2003
2006
|
//#region src/html/template.ts
|
|
@@ -2208,14 +2211,17 @@ function writeTriggerScript(html, triggers) {
|
|
|
2208
2211
|
let htmlStr = _escape_script(JSON.stringify(html)), exprs = triggers.map((trigger) => {
|
|
2209
2212
|
let options = trigger.options && toObjectExpression(trigger.options);
|
|
2210
2213
|
switch (trigger.type) {
|
|
2211
|
-
case "visible": return `(e=>e&&new IntersectionObserver((e,i)=>e.some(e=>e.isIntersecting)&&i.disconnect()+l()${options ? `,${options}` : ""}).observe(e))(
|
|
2214
|
+
case "visible": return `(e=>e&&new IntersectionObserver((e,i)=>e.some(e=>e.isIntersecting)&&i.disconnect()+l()${options ? `,${options}` : ""}).observe(e))(${querySelectorOrLoad(trigger.selector)})`;
|
|
2212
2215
|
case "idle": return `(self.requestIdleCallback||l)(l${options ? `,${options}` : ""})`;
|
|
2213
2216
|
case "media": return `(m=>m.matches?l():m.addEventListener("change",l,{once:1}))(matchMedia(${JSON.stringify(trigger.selector)}))`;
|
|
2214
|
-
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(
|
|
2217
|
+
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(${querySelectorOrLoad(trigger.selector)})`;
|
|
2215
2218
|
}
|
|
2216
2219
|
});
|
|
2217
2220
|
writeScript(`((p,h,d,l=$=>{d||p.after(new Range().createContextualFragment(d=h))})=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
|
|
2218
2221
|
}
|
|
2222
|
+
function querySelectorOrLoad(selector) {
|
|
2223
|
+
return `document.querySelector(${JSON.stringify(selector)})||l()`;
|
|
2224
|
+
}
|
|
2219
2225
|
function toObjectExpression(options) {
|
|
2220
2226
|
let result = "{", sep = "";
|
|
2221
2227
|
for (let key in options) Object.hasOwn(options, key) && (result += sep + toObjectKey(key) + ":" + JSON.stringify(options[key]), sep = ",");
|