marko 6.3.32 → 6.3.33
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 +4 -1
- package/dist/debug/html.js +35 -7
- package/dist/debug/html.mjs +36 -5
- package/dist/html/compat.d.ts +3 -1
- package/dist/html/writer.d.ts +3 -0
- package/dist/html.d.ts +1 -1
- package/dist/html.js +31 -11
- package/dist/html.mjs +31 -11
- package/dist/translator/index.js +54 -51
- package/dist/translator/util/branch-tag.d.ts +5 -0
- package/dist/translator/util/signals.d.ts +1 -3
- package/index.d.ts +19 -1
- package/package.json +4 -4
package/cheatsheet.md
CHANGED
|
@@ -7,7 +7,7 @@ Marko 6 = HTML superset. NOT JSX, NOT old Marko 4/5. `.marko` files are componen
|
|
|
7
7
|
1. Text interpolation: `${expr}` inside tag bodies. A bare line at the template root parses as a TAG (concise mode): `Welcome aboard` fails to compile, but `p is a tag` compiles SILENTLY to `<p is a tag></p>` — any line starting with a real tag name loses its words to attributes. Wrap text in an element (`<p>Welcome aboard</p>`) or prefix the line with `--` and a space (`-- Welcome ${name}`). Attributes take raw JS after `=` with NO braces/quotes: `<div title=user.name data-n=1 + 1>`.
|
|
8
8
|
2. A top-level `>` in an attribute value **ENDS THE TAG**: the value truncates there, the rest of the line becomes body text, and it usually still compiles clean. `<button disabled=count>=8 onClick() {…}>More</button>` is `disabled=count` plus the TEXT `=8 onClick() {…}>`, so the handler never binds; spaces don't help (`disabled=a > b` closes too). Parenthesize the value — `disabled=(count >= 8)`, `hidden=(a > b)`, and for a TS type argument `<let/s=(new Set<string>())>`. Do NOT move the type onto the tag variable instead: `<let/s:Set<string>=new Set()>` compiles but fails type-check with TS2322 (the annotation does not flow into the initializer). A `>` nested inside `(…)`/`{…}`/`[…]` is safe (`class={ big: n > 1 }`, `of=list.filter(x => x > 1)`), but an arrow BODY is not nested: `<const/f=(a, b) => a > b>` truncates to `(a, b) => a`. `<` never closes a tag (`disabled=count<=1` is fine).
|
|
9
9
|
3. State: `<let/name=initial>` (slash then var name!). Update by plain assignment in an event handler: `count++`, `text = "hi"`. No setState, no hooks.
|
|
10
|
-
4. Derived values: `<const/total=items.length * price>` — auto-recomputes. Never use an effect to derive state. Updates batch: mid-handler a reassigned `<let>` reads current but its derived `<const>` reads stale — recompute from the `<let>`.
|
|
10
|
+
4. Derived values: `<const/total=items.length * price>` — auto-recomputes. Never use an effect to derive state. `<let>` is deliberately different: its value is an INITIAL value, so `<let/draft=input.text>` seeds from a reactive value and then de-syncs — that de-sync is the point of an editable copy. So pick by intent: recomputes → `<const>`, seeds then diverges → `<let>`. A `<let>` you never assign is just a frozen `<const>`. Updates batch: mid-handler a reassigned `<let>` reads current but its derived `<const>` reads stale — recompute from the `<let>`.
|
|
11
11
|
5. NEVER mutate state in place. `items.push(x)` will NOT update the UI. Always reassign:
|
|
12
12
|
- add: `items = items.concat(x)`
|
|
13
13
|
- remove: `items = items.toSpliced(i, 1)`
|
|
@@ -17,6 +17,7 @@ Marko 6 = HTML superset. NOT JSX, NOT old Marko 4/5. `.marko` files are componen
|
|
|
17
17
|
7. Native inputs are UNCONTROLLED by default: `value=` only sets the initial value. Adding the matching `*Change` handler is what makes them controlled — `valueChange` on `<input>`/`<textarea>`/`<select>`, `checkedChange` on checkboxes/radios, `openChange` on `<details>`/`<dialog>`. `value:=text` is the shorthand for `value=text valueChange(v) { text = v }`. (`<textarea value:=text/>` — value attribute, not body.)
|
|
18
18
|
8. Transform in the handler when needed — number inputs give STRINGS: `<input type="number" value=n valueChange(v) { n = +v }>`, or `value:parseFloat:=n`.
|
|
19
19
|
9. Radio/checkbox groups: `checkedValue:=picked` on each input (shared var, distinct `value=`) — the match is checked; array var for multi-checkbox. Dropdown: `<select value:=picked>`.
|
|
20
|
+
10. Module-level values and helpers need `static`: `static const LIMIT = 10`, `static function fmt(n) {…}`. Without it `function fmt(n) {` parses as a TAG — ``Unable to find entry point for custom tag `<function>` ``, an error that never says `static`. Prefer it to `<const>` for anything that never changes: `<const/LIMIT=10>` emits a per-instance signal plus a `$setup` call.
|
|
20
21
|
|
|
21
22
|
## Canonical component (copy this shape)
|
|
22
23
|
|
|
@@ -195,6 +196,8 @@ export interface Input<T> {
|
|
|
195
196
|
| `onClick={() => ...}` / `@click` / `on-click("name")` | `onClick() { ... }` |
|
|
196
197
|
| `const [x, setX] = useState()` / `state` / `class {}` block | `<let/x=0>` then `x = 1` |
|
|
197
198
|
| `$ const y = x * 2;` (scriptlets are removed) | `<const/y=x * 2>` |
|
|
199
|
+
| `<let/n=a + b>` when you want it to recompute | `<const/n=a + b>` — `<let>` seeds an initial value, then de-syncs by design |
|
|
200
|
+
| `function fmt(n) {…}` / `const LIMIT = 10` at module level | `static function fmt(n) {…}` / `static const LIMIT = 10` |
|
|
198
201
|
| `<let x=0>` | `<let/x=0>` |
|
|
199
202
|
| `<if(cond)>` | `<if=cond>` |
|
|
200
203
|
| `items.push(x)` | `items = items.concat(x)` |
|
package/dist/debug/html.js
CHANGED
|
@@ -1844,6 +1844,15 @@ let $chunk;
|
|
|
1844
1844
|
function getChunk() {
|
|
1845
1845
|
return $chunk;
|
|
1846
1846
|
}
|
|
1847
|
+
function withChunk(chunk, cb) {
|
|
1848
|
+
const prev = $chunk;
|
|
1849
|
+
$chunk = chunk;
|
|
1850
|
+
try {
|
|
1851
|
+
return cb();
|
|
1852
|
+
} finally {
|
|
1853
|
+
$chunk = prev;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1847
1856
|
function getContext(key) {
|
|
1848
1857
|
return $chunk.context?.[key];
|
|
1849
1858
|
}
|
|
@@ -2041,19 +2050,28 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
|
|
|
2041
2050
|
writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
2042
2051
|
}
|
|
2043
2052
|
function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
2044
|
-
const { state } = $chunk.boundary;
|
|
2045
2053
|
const resumeBranch = serializeBranch !== 0;
|
|
2046
2054
|
const resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0);
|
|
2047
2055
|
const branchId = _peek_scope_id();
|
|
2048
|
-
|
|
2056
|
+
const chunk = $chunk;
|
|
2057
|
+
const beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0;
|
|
2049
2058
|
const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
|
|
2050
2059
|
const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
2060
|
+
if (beforeBranch !== void 0) applyBranchStart(chunk, beforeBranch, shouldWriteBranch);
|
|
2051
2061
|
if (shouldWriteBranch && (branchIndex || !resumeMarker)) writeScope(scopeId, {
|
|
2052
2062
|
[ConditionalRenderer + accessor]: branchIndex || void 0,
|
|
2053
2063
|
[BranchScopes + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
2054
2064
|
});
|
|
2055
2065
|
writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
2056
2066
|
}
|
|
2067
|
+
function deferBranchStart(chunk) {
|
|
2068
|
+
const beforeBranch = chunk.html;
|
|
2069
|
+
chunk.html = "";
|
|
2070
|
+
return beforeBranch;
|
|
2071
|
+
}
|
|
2072
|
+
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
2073
|
+
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
2074
|
+
}
|
|
2057
2075
|
function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, branchIds) {
|
|
2058
2076
|
const endTag = parentEndTag || "";
|
|
2059
2077
|
if (serializeMarker !== 0) if (!parentEndTag || serializeStateful !== 0) {
|
|
@@ -2981,7 +2999,8 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2981
2999
|
};
|
|
2982
3000
|
renderNative();
|
|
2983
3001
|
} else {
|
|
2984
|
-
|
|
3002
|
+
const chunk = getChunk();
|
|
3003
|
+
const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
|
|
2985
3004
|
const render = () => {
|
|
2986
3005
|
if (renderer) try {
|
|
2987
3006
|
_set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0);
|
|
@@ -2996,7 +3015,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2996
3015
|
};
|
|
2997
3016
|
result = shouldResume ? withBranchId(branchId, render) : render();
|
|
2998
3017
|
rendered = _peek_scope_id() !== branchId;
|
|
2999
|
-
if (
|
|
3018
|
+
if (beforeBranch !== void 0) {
|
|
3019
|
+
applyBranchStart(chunk, beforeBranch, rendered);
|
|
3020
|
+
_html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
|
|
3021
|
+
}
|
|
3000
3022
|
}
|
|
3001
3023
|
if (rendered) {
|
|
3002
3024
|
if (shouldResume) writeScope(scopeId, { [ConditionalRenderer + accessor]: renderer?.["id"] || renderer });
|
|
@@ -3147,6 +3169,8 @@ var ServerRendered = class {
|
|
|
3147
3169
|
}, (err) => {
|
|
3148
3170
|
const socket = "socket" in stream && stream.socket;
|
|
3149
3171
|
if (socket && typeof socket.destroySoon === "function") socket.destroySoon();
|
|
3172
|
+
else if (stream.destroy) stream.destroy();
|
|
3173
|
+
else stream.end();
|
|
3150
3174
|
if (!stream.emit?.("error", err)) throw err;
|
|
3151
3175
|
}, () => {
|
|
3152
3176
|
stream.end();
|
|
@@ -3360,6 +3384,7 @@ const compat = {
|
|
|
3360
3384
|
nextScopeId: _scope_id,
|
|
3361
3385
|
peekNextScopeId: _peek_scope_id,
|
|
3362
3386
|
isInResumedBranch,
|
|
3387
|
+
withChunk,
|
|
3363
3388
|
ensureState($global) {
|
|
3364
3389
|
let state = $global[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
|
3365
3390
|
if (!state) {
|
|
@@ -3454,6 +3479,12 @@ const compat = {
|
|
|
3454
3479
|
register,
|
|
3455
3480
|
registerRenderBody(fn) {
|
|
3456
3481
|
register(RENDER_BODY_ID, fn);
|
|
3482
|
+
},
|
|
3483
|
+
registerClassFunctions(input) {
|
|
3484
|
+
for (const key in input) {
|
|
3485
|
+
const value = input[key];
|
|
3486
|
+
if (typeof value === "function" && !getRegistered(value)) register(RENDER_BODY_ID, value);
|
|
3487
|
+
}
|
|
3457
3488
|
}
|
|
3458
3489
|
};
|
|
3459
3490
|
function NOOP() {}
|
|
@@ -3541,10 +3572,7 @@ exports.attrTag = attrTag;
|
|
|
3541
3572
|
exports.attrTags = attrTags;
|
|
3542
3573
|
exports.compat = compat;
|
|
3543
3574
|
exports.forIn = forIn;
|
|
3544
|
-
exports.forInBy = forInBy;
|
|
3545
3575
|
exports.forOf = forOf;
|
|
3546
|
-
exports.forOfBy = forOfBy;
|
|
3547
|
-
exports.forStepBy = forStepBy;
|
|
3548
3576
|
exports.forTo = forTo;
|
|
3549
3577
|
exports.forUntil = forUntil;
|
|
3550
3578
|
exports.withLoadAssets = withLoadAssets;
|
package/dist/debug/html.mjs
CHANGED
|
@@ -1842,6 +1842,15 @@ let $chunk;
|
|
|
1842
1842
|
function getChunk() {
|
|
1843
1843
|
return $chunk;
|
|
1844
1844
|
}
|
|
1845
|
+
function withChunk(chunk, cb) {
|
|
1846
|
+
const prev = $chunk;
|
|
1847
|
+
$chunk = chunk;
|
|
1848
|
+
try {
|
|
1849
|
+
return cb();
|
|
1850
|
+
} finally {
|
|
1851
|
+
$chunk = prev;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1845
1854
|
function getContext(key) {
|
|
1846
1855
|
return $chunk.context?.[key];
|
|
1847
1856
|
}
|
|
@@ -2039,19 +2048,28 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
|
|
|
2039
2048
|
writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
2040
2049
|
}
|
|
2041
2050
|
function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
2042
|
-
const { state } = $chunk.boundary;
|
|
2043
2051
|
const resumeBranch = serializeBranch !== 0;
|
|
2044
2052
|
const resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0);
|
|
2045
2053
|
const branchId = _peek_scope_id();
|
|
2046
|
-
|
|
2054
|
+
const chunk = $chunk;
|
|
2055
|
+
const beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0;
|
|
2047
2056
|
const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
|
|
2048
2057
|
const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
2058
|
+
if (beforeBranch !== void 0) applyBranchStart(chunk, beforeBranch, shouldWriteBranch);
|
|
2049
2059
|
if (shouldWriteBranch && (branchIndex || !resumeMarker)) writeScope(scopeId, {
|
|
2050
2060
|
[ConditionalRenderer + accessor]: branchIndex || void 0,
|
|
2051
2061
|
[BranchScopes + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
2052
2062
|
});
|
|
2053
2063
|
writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
2054
2064
|
}
|
|
2065
|
+
function deferBranchStart(chunk) {
|
|
2066
|
+
const beforeBranch = chunk.html;
|
|
2067
|
+
chunk.html = "";
|
|
2068
|
+
return beforeBranch;
|
|
2069
|
+
}
|
|
2070
|
+
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
2071
|
+
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
2072
|
+
}
|
|
2055
2073
|
function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, branchIds) {
|
|
2056
2074
|
const endTag = parentEndTag || "";
|
|
2057
2075
|
if (serializeMarker !== 0) if (!parentEndTag || serializeStateful !== 0) {
|
|
@@ -2979,7 +2997,8 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2979
2997
|
};
|
|
2980
2998
|
renderNative();
|
|
2981
2999
|
} else {
|
|
2982
|
-
|
|
3000
|
+
const chunk = getChunk();
|
|
3001
|
+
const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
|
|
2983
3002
|
const render = () => {
|
|
2984
3003
|
if (renderer) try {
|
|
2985
3004
|
_set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0);
|
|
@@ -2994,7 +3013,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2994
3013
|
};
|
|
2995
3014
|
result = shouldResume ? withBranchId(branchId, render) : render();
|
|
2996
3015
|
rendered = _peek_scope_id() !== branchId;
|
|
2997
|
-
if (
|
|
3016
|
+
if (beforeBranch !== void 0) {
|
|
3017
|
+
applyBranchStart(chunk, beforeBranch, rendered);
|
|
3018
|
+
_html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
|
|
3019
|
+
}
|
|
2998
3020
|
}
|
|
2999
3021
|
if (rendered) {
|
|
3000
3022
|
if (shouldResume) writeScope(scopeId, { [ConditionalRenderer + accessor]: renderer?.["id"] || renderer });
|
|
@@ -3145,6 +3167,8 @@ var ServerRendered = class {
|
|
|
3145
3167
|
}, (err) => {
|
|
3146
3168
|
const socket = "socket" in stream && stream.socket;
|
|
3147
3169
|
if (socket && typeof socket.destroySoon === "function") socket.destroySoon();
|
|
3170
|
+
else if (stream.destroy) stream.destroy();
|
|
3171
|
+
else stream.end();
|
|
3148
3172
|
if (!stream.emit?.("error", err)) throw err;
|
|
3149
3173
|
}, () => {
|
|
3150
3174
|
stream.end();
|
|
@@ -3358,6 +3382,7 @@ const compat = {
|
|
|
3358
3382
|
nextScopeId: _scope_id,
|
|
3359
3383
|
peekNextScopeId: _peek_scope_id,
|
|
3360
3384
|
isInResumedBranch,
|
|
3385
|
+
withChunk,
|
|
3361
3386
|
ensureState($global) {
|
|
3362
3387
|
let state = $global[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
|
3363
3388
|
if (!state) {
|
|
@@ -3452,8 +3477,14 @@ const compat = {
|
|
|
3452
3477
|
register,
|
|
3453
3478
|
registerRenderBody(fn) {
|
|
3454
3479
|
register(RENDER_BODY_ID, fn);
|
|
3480
|
+
},
|
|
3481
|
+
registerClassFunctions(input) {
|
|
3482
|
+
for (const key in input) {
|
|
3483
|
+
const value = input[key];
|
|
3484
|
+
if (typeof value === "function" && !getRegistered(value)) register(RENDER_BODY_ID, value);
|
|
3485
|
+
}
|
|
3455
3486
|
}
|
|
3456
3487
|
};
|
|
3457
3488
|
function NOOP() {}
|
|
3458
3489
|
//#endregion
|
|
3459
|
-
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, _resume_locals, 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, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn,
|
|
3490
|
+
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, _resume_locals, 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, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, withLoadAssets, withPageAssets };
|
package/dist/html/compat.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { register } from "./serializer";
|
|
2
2
|
import type { ServerRenderer } from "./template";
|
|
3
|
-
import { _await, _html, _peek_scope_id, _scope_id, $global, Chunk, isInResumedBranch, State, writeScript } from "./writer";
|
|
3
|
+
import { _await, _html, _peek_scope_id, _scope_id, $global, Chunk, isInResumedBranch, State, withChunk, writeScript } from "./writer";
|
|
4
4
|
export declare const compat: {
|
|
5
5
|
$global: typeof $global;
|
|
6
6
|
fork: typeof _await;
|
|
@@ -9,6 +9,7 @@ export declare const compat: {
|
|
|
9
9
|
nextScopeId: typeof _scope_id;
|
|
10
10
|
peekNextScopeId: typeof _peek_scope_id;
|
|
11
11
|
isInResumedBranch: typeof isInResumedBranch;
|
|
12
|
+
withChunk: typeof withChunk;
|
|
12
13
|
ensureState($global: any): State;
|
|
13
14
|
isTagsAPI(fn: any): boolean;
|
|
14
15
|
onFlush(fn: (chunk: Chunk) => void): void;
|
|
@@ -19,4 +20,5 @@ export declare const compat: {
|
|
|
19
20
|
render(renderer: ServerRenderer, willRerender: boolean, classAPIOut: any, component: any, input: any, completeChunks: Chunk[], registerChildScope?: boolean): void;
|
|
20
21
|
register: typeof register;
|
|
21
22
|
registerRenderBody(fn: any): void;
|
|
23
|
+
registerClassFunctions(input: any): void;
|
|
22
24
|
};
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ type ScopeInternals = PartialScope & {
|
|
|
18
18
|
[K_SCOPE_ID]?: number;
|
|
19
19
|
};
|
|
20
20
|
export declare function getChunk(): Chunk | undefined;
|
|
21
|
+
export declare function withChunk<T>(chunk: Chunk, cb: () => T): T;
|
|
21
22
|
export declare function getContext(key: keyof NonNullable<Chunk["context"]>): unknown;
|
|
22
23
|
export declare function getState(): State;
|
|
23
24
|
export declare function getScopeId(scope: unknown): number | undefined;
|
|
@@ -56,6 +57,8 @@ export declare function _for_in(obj: Falsy | {}, cb: (key: string, value: unknow
|
|
|
56
57
|
export declare function _for_to(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: number, serializeMarker?: number, serializeStateful?: number, parentEndTag?: string | 0, singleNode?: 1): void;
|
|
57
58
|
export declare function _for_until(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: number, serializeMarker?: number, serializeStateful?: number, parentEndTag?: string | 0, singleNode?: 1): void;
|
|
58
59
|
export declare function _if(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: number, serializeMarker?: number, serializeStateful?: number, parentEndTag?: string | 0, singleNode?: 1): void;
|
|
60
|
+
export declare function deferBranchStart(chunk: Chunk): string;
|
|
61
|
+
export declare function applyBranchStart(chunk: Chunk, beforeBranch: string, rendered: boolean): void;
|
|
59
62
|
declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
|
|
60
63
|
export { writeScope as _scope };
|
|
61
64
|
export declare function _existing_scope(scopeId: number): ScopeInternals;
|
package/dist/html.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export { _attr, _attr_and, _attr_class, _attr_details_or_dialog_open as _attr_de
|
|
|
5
5
|
export { compat } from "./html/compat";
|
|
6
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
|
-
export { forIn,
|
|
8
|
+
export { forIn, forOf, forTo, forUntil } from "./html/for";
|
|
9
9
|
export { _template } from "./html/template";
|
|
10
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, _resume_locals, _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
|
@@ -265,8 +265,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
265
265
|
needsScript && _script(branchId, "d"), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
266
266
|
})();
|
|
267
267
|
} else {
|
|
268
|
-
shouldResume
|
|
269
|
-
let render = () => {
|
|
268
|
+
let chunk = getChunk(), beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0, render = () => {
|
|
270
269
|
if (renderer) try {
|
|
271
270
|
return _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0), inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
|
|
272
271
|
...inputOrArgs,
|
|
@@ -277,7 +276,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
277
276
|
}
|
|
278
277
|
else if (content) return content();
|
|
279
278
|
};
|
|
280
|
-
result = shouldResume ? withBranchId(branchId, render) : render(), rendered = _peek_scope_id() !== branchId,
|
|
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 : ""))));
|
|
281
280
|
}
|
|
282
281
|
return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: renderer?.a || renderer }) : _scope_id(), result;
|
|
283
282
|
}, patchDynamicTag = ((originalDynamicTag) => (patch) => {
|
|
@@ -285,7 +284,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
285
284
|
let patched = patch(tag, scopeId, accessor);
|
|
286
285
|
return patched !== tag && (patched.a = tag), originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, resume);
|
|
287
286
|
};
|
|
288
|
-
})(_dynamic_tag), CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result", _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), kAssets = Symbol(), kBlockIndex = Symbol(), kDeferIndex = Symbol(), assetFlush, SET_SCOPE_REGISTER_ID = "$C_s", K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
|
|
287
|
+
})(_dynamic_tag), CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result", _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), kAssets = Symbol(), kBlockIndex = Symbol(), kDeferIndex = Symbol(), assetFlush, SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_ID = "$C_b", K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
|
|
289
288
|
$global,
|
|
290
289
|
fork: _await,
|
|
291
290
|
write: _html,
|
|
@@ -293,6 +292,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
293
292
|
nextScopeId: _scope_id,
|
|
294
293
|
peekNextScopeId: _peek_scope_id,
|
|
295
294
|
isInResumedBranch,
|
|
295
|
+
withChunk,
|
|
296
296
|
ensureState($global) {
|
|
297
297
|
let state = $global[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
|
298
298
|
return state || ($global.runtimeId ||= "M", $global.renderId ||= $global.componentIdPrefix || $global.widgetIdPrefix || "_", $global[K_TAGS_API_STATE] = state = new State($global)), state;
|
|
@@ -361,7 +361,13 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
361
361
|
},
|
|
362
362
|
register,
|
|
363
363
|
registerRenderBody(fn) {
|
|
364
|
-
register(
|
|
364
|
+
register(RENDER_BODY_ID, fn);
|
|
365
|
+
},
|
|
366
|
+
registerClassFunctions(input) {
|
|
367
|
+
for (let key in input) {
|
|
368
|
+
let value = input[key];
|
|
369
|
+
typeof value == "function" && !getRegistered(value) && register(RENDER_BODY_ID, value);
|
|
370
|
+
}
|
|
365
371
|
}
|
|
366
372
|
};
|
|
367
373
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -1230,6 +1236,15 @@ function forStepBy(by, index) {
|
|
|
1230
1236
|
function getChunk() {
|
|
1231
1237
|
return $chunk;
|
|
1232
1238
|
}
|
|
1239
|
+
function withChunk(chunk, cb) {
|
|
1240
|
+
let prev = $chunk;
|
|
1241
|
+
$chunk = chunk;
|
|
1242
|
+
try {
|
|
1243
|
+
return cb();
|
|
1244
|
+
} finally {
|
|
1245
|
+
$chunk = prev;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1233
1248
|
function getContext(key) {
|
|
1234
1249
|
return $chunk.context?.[key];
|
|
1235
1250
|
}
|
|
@@ -1382,14 +1397,19 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
|
|
|
1382
1397
|
}), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes }), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
1383
1398
|
}
|
|
1384
1399
|
function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1385
|
-
let
|
|
1386
|
-
|
|
1387
|
-
let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
1388
|
-
shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
|
|
1400
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), branchId = _peek_scope_id(), chunk = $chunk, beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0, branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
1401
|
+
beforeBranch !== void 0 && applyBranchStart(chunk, beforeBranch, shouldWriteBranch), shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
|
|
1389
1402
|
["D" + accessor]: branchIndex || void 0,
|
|
1390
1403
|
["A" + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
1391
1404
|
}), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
1392
1405
|
}
|
|
1406
|
+
function deferBranchStart(chunk) {
|
|
1407
|
+
let beforeBranch = chunk.html;
|
|
1408
|
+
return chunk.html = "", beforeBranch;
|
|
1409
|
+
}
|
|
1410
|
+
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
1411
|
+
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
1412
|
+
}
|
|
1393
1413
|
function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, branchIds) {
|
|
1394
1414
|
let endTag = parentEndTag || "";
|
|
1395
1415
|
if (serializeMarker !== 0) if (!parentEndTag || serializeStateful !== 0) {
|
|
@@ -2050,7 +2070,7 @@ var ServerRendered = class {
|
|
|
2050
2070
|
stream.write(html), stream.flush?.();
|
|
2051
2071
|
}, (err) => {
|
|
2052
2072
|
let socket = "socket" in stream && stream.socket;
|
|
2053
|
-
if (socket && typeof socket.destroySoon == "function"
|
|
2073
|
+
if (socket && typeof socket.destroySoon == "function" ? socket.destroySoon() : stream.destroy ? stream.destroy() : stream.end(), !stream.emit?.("error", err)) throw err;
|
|
2054
2074
|
}, () => {
|
|
2055
2075
|
stream.end();
|
|
2056
2076
|
});
|
|
@@ -2193,4 +2213,4 @@ exports.$global = $global, exports._assert_hoist = _assert_hoist, exports._attr
|
|
|
2193
2213
|
get: function() {
|
|
2194
2214
|
return _dynamic_tag;
|
|
2195
2215
|
}
|
|
2196
|
-
}), 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._resume_locals = _resume_locals, 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._textarea_value = _textarea_value, 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.
|
|
2216
|
+
}), 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._resume_locals = _resume_locals, 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._textarea_value = _textarea_value, 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.forOf = forOf, exports.forTo = forTo, exports.forUntil = forUntil, exports.withLoadAssets = withLoadAssets, exports.withPageAssets = withPageAssets;
|
package/dist/html.mjs
CHANGED
|
@@ -265,8 +265,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
265
265
|
needsScript && _script(branchId, "d"), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
266
266
|
})();
|
|
267
267
|
} else {
|
|
268
|
-
shouldResume
|
|
269
|
-
let render = () => {
|
|
268
|
+
let chunk = getChunk(), beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0, render = () => {
|
|
270
269
|
if (renderer) try {
|
|
271
270
|
return _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0), inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
|
|
272
271
|
...inputOrArgs,
|
|
@@ -277,7 +276,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
277
276
|
}
|
|
278
277
|
else if (content) return content();
|
|
279
278
|
};
|
|
280
|
-
result = shouldResume ? withBranchId(branchId, render) : render(), rendered = _peek_scope_id() !== branchId,
|
|
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 : ""))));
|
|
281
280
|
}
|
|
282
281
|
return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: renderer?.a || renderer }) : _scope_id(), result;
|
|
283
282
|
}, patchDynamicTag = ((originalDynamicTag) => (patch) => {
|
|
@@ -285,7 +284,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
285
284
|
let patched = patch(tag, scopeId, accessor);
|
|
286
285
|
return patched !== tag && (patched.a = tag), originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, resume);
|
|
287
286
|
};
|
|
288
|
-
})(_dynamic_tag), CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result", _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), kAssets = Symbol(), kBlockIndex = Symbol(), kDeferIndex = Symbol(), assetFlush, SET_SCOPE_REGISTER_ID = "$C_s", K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
|
|
287
|
+
})(_dynamic_tag), CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result", _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), kAssets = Symbol(), kBlockIndex = Symbol(), kDeferIndex = Symbol(), assetFlush, SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_ID = "$C_b", K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
|
|
289
288
|
$global,
|
|
290
289
|
fork: _await,
|
|
291
290
|
write: _html,
|
|
@@ -293,6 +292,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
293
292
|
nextScopeId: _scope_id,
|
|
294
293
|
peekNextScopeId: _peek_scope_id,
|
|
295
294
|
isInResumedBranch,
|
|
295
|
+
withChunk,
|
|
296
296
|
ensureState($global) {
|
|
297
297
|
let state = $global[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
|
298
298
|
return state || ($global.runtimeId ||= "M", $global.renderId ||= $global.componentIdPrefix || $global.widgetIdPrefix || "_", $global[K_TAGS_API_STATE] = state = new State($global)), state;
|
|
@@ -361,7 +361,13 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
361
361
|
},
|
|
362
362
|
register,
|
|
363
363
|
registerRenderBody(fn) {
|
|
364
|
-
register(
|
|
364
|
+
register(RENDER_BODY_ID, fn);
|
|
365
|
+
},
|
|
366
|
+
registerClassFunctions(input) {
|
|
367
|
+
for (let key in input) {
|
|
368
|
+
let value = input[key];
|
|
369
|
+
typeof value == "function" && !getRegistered(value) && register(RENDER_BODY_ID, value);
|
|
370
|
+
}
|
|
365
371
|
}
|
|
366
372
|
};
|
|
367
373
|
//#region src/common/attr-tag.ts
|
|
@@ -1229,6 +1235,15 @@ function forStepBy(by, index) {
|
|
|
1229
1235
|
function getChunk() {
|
|
1230
1236
|
return $chunk;
|
|
1231
1237
|
}
|
|
1238
|
+
function withChunk(chunk, cb) {
|
|
1239
|
+
let prev = $chunk;
|
|
1240
|
+
$chunk = chunk;
|
|
1241
|
+
try {
|
|
1242
|
+
return cb();
|
|
1243
|
+
} finally {
|
|
1244
|
+
$chunk = prev;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1232
1247
|
function getContext(key) {
|
|
1233
1248
|
return $chunk.context?.[key];
|
|
1234
1249
|
}
|
|
@@ -1381,14 +1396,19 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
|
|
|
1381
1396
|
}), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes }), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
1382
1397
|
}
|
|
1383
1398
|
function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1384
|
-
let
|
|
1385
|
-
|
|
1386
|
-
let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
1387
|
-
shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
|
|
1399
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), branchId = _peek_scope_id(), chunk = $chunk, beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0, branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
1400
|
+
beforeBranch !== void 0 && applyBranchStart(chunk, beforeBranch, shouldWriteBranch), shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
|
|
1388
1401
|
["D" + accessor]: branchIndex || void 0,
|
|
1389
1402
|
["A" + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
1390
1403
|
}), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
1391
1404
|
}
|
|
1405
|
+
function deferBranchStart(chunk) {
|
|
1406
|
+
let beforeBranch = chunk.html;
|
|
1407
|
+
return chunk.html = "", beforeBranch;
|
|
1408
|
+
}
|
|
1409
|
+
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
1410
|
+
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
1411
|
+
}
|
|
1392
1412
|
function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, branchIds) {
|
|
1393
1413
|
let endTag = parentEndTag || "";
|
|
1394
1414
|
if (serializeMarker !== 0) if (!parentEndTag || serializeStateful !== 0) {
|
|
@@ -2049,7 +2069,7 @@ var ServerRendered = class {
|
|
|
2049
2069
|
stream.write(html), stream.flush?.();
|
|
2050
2070
|
}, (err) => {
|
|
2051
2071
|
let socket = "socket" in stream && stream.socket;
|
|
2052
|
-
if (socket && typeof socket.destroySoon == "function"
|
|
2072
|
+
if (socket && typeof socket.destroySoon == "function" ? socket.destroySoon() : stream.destroy ? stream.destroy() : stream.end(), !stream.emit?.("error", err)) throw err;
|
|
2053
2073
|
}, () => {
|
|
2054
2074
|
stream.end();
|
|
2055
2075
|
});
|
|
@@ -2188,4 +2208,4 @@ function toObjectExpression(options) {
|
|
|
2188
2208
|
//#region src/html/compat.ts
|
|
2189
2209
|
function NOOP() {}
|
|
2190
2210
|
//#endregion
|
|
2191
|
-
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, _resume_locals, 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, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn,
|
|
2211
|
+
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, _resume_locals, 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, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, withLoadAssets, withPageAssets };
|
package/dist/translator/index.js
CHANGED
|
@@ -1976,6 +1976,14 @@ function _resume_branch(scopeId) {
|
|
|
1976
1976
|
const branchId = $chunk.context?.[kBranchId];
|
|
1977
1977
|
if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [ClosestBranchId$1]: branchId });
|
|
1978
1978
|
}
|
|
1979
|
+
function deferBranchStart(chunk) {
|
|
1980
|
+
const beforeBranch = chunk.html;
|
|
1981
|
+
chunk.html = "";
|
|
1982
|
+
return beforeBranch;
|
|
1983
|
+
}
|
|
1984
|
+
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
1985
|
+
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
1986
|
+
}
|
|
1979
1987
|
let writeScope = (scopeId, partialScope) => {
|
|
1980
1988
|
const { state } = $chunk.boundary;
|
|
1981
1989
|
const target = $chunk.serializeState;
|
|
@@ -2196,7 +2204,8 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2196
2204
|
};
|
|
2197
2205
|
renderNative();
|
|
2198
2206
|
} else {
|
|
2199
|
-
|
|
2207
|
+
const chunk = void 0;
|
|
2208
|
+
const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
|
|
2200
2209
|
const render = () => {
|
|
2201
2210
|
if (renderer) try {
|
|
2202
2211
|
_set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0);
|
|
@@ -2211,7 +2220,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2211
2220
|
};
|
|
2212
2221
|
result = shouldResume ? withBranchId(branchId, render) : render();
|
|
2213
2222
|
rendered = _peek_scope_id() !== branchId;
|
|
2214
|
-
if (
|
|
2223
|
+
if (beforeBranch !== void 0) {
|
|
2224
|
+
applyBranchStart(chunk, beforeBranch, rendered);
|
|
2225
|
+
_html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
|
|
2226
|
+
}
|
|
2215
2227
|
}
|
|
2216
2228
|
if (rendered) {
|
|
2217
2229
|
if (shouldResume) writeScope(scopeId, { [ConditionalRenderer$1 + accessor]: renderer?.["id"] || renderer });
|
|
@@ -2987,9 +2999,7 @@ function getSignal(section, referencedBindings, name) {
|
|
|
2987
2999
|
values: [],
|
|
2988
3000
|
intersection: void 0,
|
|
2989
3001
|
render: [],
|
|
2990
|
-
renderReferencedBindings: void 0,
|
|
2991
3002
|
effect: [],
|
|
2992
|
-
effectReferencedBindings: void 0,
|
|
2993
3003
|
hasHTMLEffect: false,
|
|
2994
3004
|
build: void 0,
|
|
2995
3005
|
export: !!exportName,
|
|
@@ -3228,25 +3238,15 @@ function replaceNullishAndEmptyFunctionsWith0(args) {
|
|
|
3228
3238
|
args.length = finalLen || 0;
|
|
3229
3239
|
return args;
|
|
3230
3240
|
}
|
|
3231
|
-
function addStatement(type, targetSection, referencedBindings, statement,
|
|
3241
|
+
function addStatement(type, targetSection, referencedBindings, statement, isPure) {
|
|
3232
3242
|
const signal = getSignal(targetSection, referencedBindings);
|
|
3233
3243
|
const statements = signal[type] ??= [];
|
|
3234
|
-
const add = type === "effect" ? addEffectReferences : addRenderReferences;
|
|
3235
3244
|
if (Array.isArray(statement)) statements.push(...statement);
|
|
3236
3245
|
else statements.push(statement);
|
|
3237
|
-
if (usedReferences !== false) if (usedReferences) for (const ref of usedReferences) add(signal, ref);
|
|
3238
|
-
else add(signal, referencedBindings);
|
|
3239
3246
|
if (!isPure || type === "effect") signal.hasSideEffect = true;
|
|
3240
3247
|
}
|
|
3241
|
-
function addEffectReferences(signal, referencedBindings) {
|
|
3242
|
-
signal.effectReferencedBindings = bindingUtil.union(signal.effectReferencedBindings, referencedBindings);
|
|
3243
|
-
}
|
|
3244
|
-
function addRenderReferences(signal, referencedBindings) {
|
|
3245
|
-
signal.renderReferencedBindings = bindingUtil.union(signal.renderReferencedBindings, referencedBindings);
|
|
3246
|
-
}
|
|
3247
3248
|
function addValue(targetSection, referencedBindings, signal, value) {
|
|
3248
3249
|
const parentSignal = getSignal(targetSection, referencedBindings);
|
|
3249
|
-
addRenderReferences(parentSignal, referencedBindings);
|
|
3250
3250
|
parentSignal.values.push({
|
|
3251
3251
|
signal,
|
|
3252
3252
|
value
|
|
@@ -4093,6 +4093,22 @@ function templateElement(value, tail) {
|
|
|
4093
4093
|
}, tail);
|
|
4094
4094
|
}
|
|
4095
4095
|
//#endregion
|
|
4096
|
+
//#region src/translator/util/branch-tag.ts
|
|
4097
|
+
function getBranchSectionAccessor(nodeBinding) {
|
|
4098
|
+
return {
|
|
4099
|
+
binding: nodeBinding,
|
|
4100
|
+
prefix: getAccessorPrefix().BranchScopes
|
|
4101
|
+
};
|
|
4102
|
+
}
|
|
4103
|
+
function initBranchSection(bodySection, upstreamExpression, sectionAccessor) {
|
|
4104
|
+
bodySection.isBranch = true;
|
|
4105
|
+
bodySection.upstreamExpression = upstreamExpression;
|
|
4106
|
+
bodySection.sectionAccessor = sectionAccessor;
|
|
4107
|
+
}
|
|
4108
|
+
function resumeOwnerByMarkerWhenStatic(tagSection, bodySection, nodeBinding, statefulReasonKey) {
|
|
4109
|
+
if (isStateSerializeReason(getSerializeReason(tagSection, statefulReasonKey)) && isStaticSerializeReason(getSerializeReason(bodySection, kBranchSerializeReason)) && isStaticSerializeReason(getSerializeReason(tagSection, nodeBinding))) setSectionOwnerResumedByMarker(bodySection);
|
|
4110
|
+
}
|
|
4111
|
+
//#endregion
|
|
4096
4112
|
//#region src/translator/util/is-event-or-change-handler.ts
|
|
4097
4113
|
function isEventOrChangeHandler(prop) {
|
|
4098
4114
|
return /^on[-A-Z][a-zA-Z0-9_$]|[a-zA-Z_$][a-zA-Z0-9_$]*Change$/.test(prop);
|
|
@@ -4180,12 +4196,7 @@ var for_default = {
|
|
|
4180
4196
|
onFinalizeReferences(() => detectForSelector(bodySection, keyBinding));
|
|
4181
4197
|
}
|
|
4182
4198
|
}
|
|
4183
|
-
bodySection
|
|
4184
|
-
binding: nodeBinding,
|
|
4185
|
-
prefix: getAccessorPrefix().BranchScopes
|
|
4186
|
-
};
|
|
4187
|
-
bodySection.upstreamExpression = tagExtra;
|
|
4188
|
-
bodySection.isBranch = true;
|
|
4199
|
+
initBranchSection(bodySection, tagExtra, getBranchSectionAccessor(nodeBinding));
|
|
4189
4200
|
if (!isAttrTag && !getOnlyChildParentTagName(tag)) {
|
|
4190
4201
|
visit(tag, 37);
|
|
4191
4202
|
enterShallow(tag);
|
|
@@ -4219,7 +4230,7 @@ var for_default = {
|
|
|
4219
4230
|
const singleChild = bodySection.content?.singleChild && bodySection.content.startType !== 4;
|
|
4220
4231
|
const branchSerializeReason = getSerializeReason(bodySection, kBranchSerializeReason);
|
|
4221
4232
|
const markerSerializeReason = getSerializeReason(tagSection, nodeBinding);
|
|
4222
|
-
|
|
4233
|
+
resumeOwnerByMarkerWhenStatic(tagSection, bodySection, nodeBinding, kStatefulReason$2);
|
|
4223
4234
|
flushInto(tag);
|
|
4224
4235
|
writeHTMLResumeStatements(tagBody);
|
|
4225
4236
|
const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
|
|
@@ -4987,7 +4998,7 @@ var native_tag_default = {
|
|
|
4987
4998
|
const isOpenOnly = !!(tagDef && tagDef.parseOptions?.openTagOnly);
|
|
4988
4999
|
const isTextOnly = isTextOnlyNativeTag(tag);
|
|
4989
5000
|
const hasChildren = !!tag.node.body.body.length;
|
|
4990
|
-
if (injectNonce) addStatement("render", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_attr_nonce", scopeIdentifier, getScopeAccessorLiteral(nodeBinding))),
|
|
5001
|
+
if (injectNonce) addStatement("render", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_attr_nonce", scopeIdentifier, getScopeAccessorLiteral(nodeBinding))), true);
|
|
4991
5002
|
if (staticControllable) {
|
|
4992
5003
|
const hasChangeHandler = !!staticControllable.attrs[1];
|
|
4993
5004
|
const defaultHelper = getDOMControllableDefaultHelper(staticControllable);
|
|
@@ -5030,14 +5041,14 @@ var native_tag_default = {
|
|
|
5030
5041
|
stmt = _marko_compiler.types.expressionStatement(callRuntime(`_attr_${name}_items`, nodeExpr, _marko_compiler.types.objectExpression(props)));
|
|
5031
5042
|
}
|
|
5032
5043
|
}
|
|
5033
|
-
if (stmt) addStatement("render", tagSection, valueReferences, stmt,
|
|
5044
|
+
if (stmt) addStatement("render", tagSection, valueReferences, stmt, !!meta.dynamicItems);
|
|
5034
5045
|
}
|
|
5035
5046
|
break;
|
|
5036
5047
|
}
|
|
5037
5048
|
default:
|
|
5038
5049
|
if (confident) break;
|
|
5039
5050
|
else if (isEventHandler(name)) addStatement("effect", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_on", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(getEventHandlerName(name)), value)));
|
|
5040
|
-
else addStatement("render", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_attr", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(name), value)),
|
|
5051
|
+
else addStatement("render", tagSection, valueReferences, _marko_compiler.types.expressionStatement(callRuntime("_attr", createScopeReadExpression(nodeBinding), _marko_compiler.types.stringLiteral(name), value)), true);
|
|
5041
5052
|
break;
|
|
5042
5053
|
}
|
|
5043
5054
|
}
|
|
@@ -5049,9 +5060,9 @@ var native_tag_default = {
|
|
|
5049
5060
|
if (skipExpression) addStatement("render", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime(canHaveAttrContent ? "_attrs_partial_content" : "_attrs_partial", scopeIdentifier, visitAccessor, spreadExpression, skipExpression, controllable && importRuntime(controllable))));
|
|
5050
5061
|
else addStatement("render", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime(canHaveAttrContent ? "_attrs_content" : "_attrs", scopeIdentifier, visitAccessor, spreadExpression, controllable && importRuntime(controllable))));
|
|
5051
5062
|
enableControllable(controllableFeatureFor(staticName));
|
|
5052
|
-
addStatement("effect", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_attrs_script", scopeIdentifier, visitAccessor))
|
|
5063
|
+
addStatement("effect", tagSection, tagExtra.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_attrs_script", scopeIdentifier, visitAccessor)));
|
|
5053
5064
|
}
|
|
5054
|
-
if (staticContentAttr) addStatement("render", tagSection, staticContentAttr.value.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_attr_content", scopeIdentifier, visitAccessor, staticContentAttr.value)),
|
|
5065
|
+
if (staticContentAttr) addStatement("render", tagSection, staticContentAttr.value.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_attr_content", scopeIdentifier, visitAccessor, staticContentAttr.value)), true);
|
|
5055
5066
|
},
|
|
5056
5067
|
exit(tag) {
|
|
5057
5068
|
const nodeBinding = tag.node.extra[kNativeTagBinding];
|
|
@@ -5059,7 +5070,7 @@ var native_tag_default = {
|
|
|
5059
5070
|
const tagName = getCanonicalTagName(tag);
|
|
5060
5071
|
if (!openTagOnly) if (tagName !== "textarea" && isTextOnlyNativeTag(tag)) {
|
|
5061
5072
|
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
5062
|
-
if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", getSection(tag), textLiteral.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text_content", createScopeReadExpression(nodeBinding), textLiteral)),
|
|
5073
|
+
if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", getSection(tag), textLiteral.extra?.referencedBindings, _marko_compiler.types.expressionStatement(callRuntime("_text_content", createScopeReadExpression(nodeBinding), textLiteral)), true);
|
|
5063
5074
|
} else tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
|
|
5064
5075
|
tag.remove();
|
|
5065
5076
|
}
|
|
@@ -5529,16 +5540,9 @@ const IfTag = {
|
|
|
5529
5540
|
visit(ifTag, 37);
|
|
5530
5541
|
enterShallow(ifTag);
|
|
5531
5542
|
}
|
|
5532
|
-
const sectionAccessor =
|
|
5533
|
-
binding: getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection, branches.length),
|
|
5534
|
-
prefix: getAccessorPrefix().BranchScopes
|
|
5535
|
-
};
|
|
5543
|
+
const sectionAccessor = getBranchSectionAccessor(getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection, branches.length));
|
|
5536
5544
|
for (const [branchTag, branchBodySection] of branches) {
|
|
5537
|
-
if (branchBodySection)
|
|
5538
|
-
branchBodySection.isBranch = true;
|
|
5539
|
-
branchBodySection.upstreamExpression = ifTagExtra;
|
|
5540
|
-
branchBodySection.sectionAccessor = sectionAccessor;
|
|
5541
|
-
}
|
|
5545
|
+
if (branchBodySection) initBranchSection(branchBodySection, ifTagExtra, sectionAccessor);
|
|
5542
5546
|
if (branchTag.node.attributes.length) mergeReferenceNodes.push(branchTag.node.attributes[0].value);
|
|
5543
5547
|
}
|
|
5544
5548
|
mergeReferences(ifTagSection, ifTag.node, mergeReferenceNodes);
|
|
@@ -5560,7 +5564,7 @@ const IfTag = {
|
|
|
5560
5564
|
if (bodySection) {
|
|
5561
5565
|
const [[ifTag]] = getBranches(tag);
|
|
5562
5566
|
const ifTagSection = getSection(ifTag);
|
|
5563
|
-
|
|
5567
|
+
resumeOwnerByMarkerWhenStatic(ifTagSection, bodySection, getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection), kStatefulReason$1);
|
|
5564
5568
|
flushInto(tag);
|
|
5565
5569
|
writeHTMLResumeStatements(tagBody);
|
|
5566
5570
|
}
|
|
@@ -6555,7 +6559,7 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
6555
6559
|
const argExport = propTree.props[i];
|
|
6556
6560
|
if (argExport) {
|
|
6557
6561
|
const argExportIdentifier = info.getBindingIdentifier(argExport.binding, `${importAlias}_param_${i}`);
|
|
6558
|
-
addStatement("render", info.tagSection, arg.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(argExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), arg])),
|
|
6562
|
+
addStatement("render", info.tagSection, arg.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(argExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), arg])), true);
|
|
6559
6563
|
}
|
|
6560
6564
|
i++;
|
|
6561
6565
|
}
|
|
@@ -6581,7 +6585,7 @@ function applyAttrObject(tag, propTree, tagInputIdentifier, info) {
|
|
|
6581
6585
|
} else attrTagCallsForTag.set(attrTagName, translatedProps = _marko_compiler.types.parenthesizedExpression(callRuntime("attrTag", translatedProps)));
|
|
6582
6586
|
} else translatedProps = callRuntime("attrTag", translatedProps);
|
|
6583
6587
|
}
|
|
6584
|
-
addStatement("render", info.tagSection, referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(tagInputIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), translatedProps])),
|
|
6588
|
+
addStatement("render", info.tagSection, referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(tagInputIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), translatedProps])), true);
|
|
6585
6589
|
}
|
|
6586
6590
|
function translateAttrTag(tag, attrTagMeta, info, statements) {
|
|
6587
6591
|
const translatedAttrs = translateAttrs(tag, true, void 0, statements);
|
|
@@ -6691,7 +6695,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
6691
6695
|
else {
|
|
6692
6696
|
remaining.delete("content");
|
|
6693
6697
|
const directContent = !bodySection.params;
|
|
6694
|
-
addStatement("render", info.tagSection, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(contentExport.binding, `${importAlias}_content`, directContent), [createScopeReadExpression(info.childScopeBinding, info.tagSection), bodyValue])),
|
|
6698
|
+
addStatement("render", info.tagSection, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(contentExport.binding, `${importAlias}_content`, directContent), [createScopeReadExpression(info.childScopeBinding, info.tagSection), bodyValue])), true);
|
|
6695
6699
|
}
|
|
6696
6700
|
}
|
|
6697
6701
|
}
|
|
@@ -6719,13 +6723,13 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
6719
6723
|
const childAttrExports = getKnownFromPropTree(propTree, attr.name);
|
|
6720
6724
|
const attrExportIdentifier = info.getBindingIdentifier(childAttrExports.binding, `${importAlias}_${attr.name}`);
|
|
6721
6725
|
remaining.delete(attr.name);
|
|
6722
|
-
addStatement("render", info.tagSection, attr.value.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), attr.value])),
|
|
6726
|
+
addStatement("render", info.tagSection, attr.value.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), attr.value])), true);
|
|
6723
6727
|
}
|
|
6724
6728
|
if (knownSpread) for (const prop of remaining) {
|
|
6725
6729
|
const childAttrExports = getKnownFromPropTree(propTree, prop);
|
|
6726
6730
|
const attrExportIdentifier = info.getBindingIdentifier(childAttrExports.binding, `${importAlias}_${prop}`);
|
|
6727
6731
|
const propBinding = knownSpread.binding.propertyAliases.get(prop);
|
|
6728
|
-
addStatement("render", info.tagSection, propBinding, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), createScopeReadExpression(propBinding, info.tagSection)])),
|
|
6732
|
+
addStatement("render", info.tagSection, propBinding, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection), createScopeReadExpression(propBinding, info.tagSection)])), true);
|
|
6729
6733
|
}
|
|
6730
6734
|
else if (spreadProps && (remaining.size || propTree.rest && !propTree.rest.props)) {
|
|
6731
6735
|
const spreadExpr = propsToExpression(spreadProps.reverse());
|
|
@@ -6748,7 +6752,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
6748
6752
|
props.push(_marko_compiler.types.objectProperty(propId, shorthand ? propId : generateUidIdentifier(name), false, shorthand));
|
|
6749
6753
|
});
|
|
6750
6754
|
props.push(_marko_compiler.types.restElement(restId));
|
|
6751
|
-
addStatement("render", info.tagSection, tagReferencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(propTree.rest.binding, importAlias + "_$rest"), [createScopeReadExpression(info.childScopeBinding, info.tagSection), _marko_compiler.types.callExpression(_marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.objectPattern(props)], restId), [spreadId])])),
|
|
6755
|
+
addStatement("render", info.tagSection, tagReferencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(propTree.rest.binding, importAlias + "_$rest"), [createScopeReadExpression(info.childScopeBinding, info.tagSection), _marko_compiler.types.callExpression(_marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.objectPattern(props)], restId), [spreadId])])), true);
|
|
6752
6756
|
}
|
|
6753
6757
|
} else {
|
|
6754
6758
|
for (const name of remaining) {
|
|
@@ -6756,7 +6760,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
6756
6760
|
const attrExportIdentifier = info.getBindingIdentifier(childAttrExports.binding, `${importAlias}_${name}`);
|
|
6757
6761
|
addStatement("render", info.tagSection, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(attrExportIdentifier, [createScopeReadExpression(info.childScopeBinding, info.tagSection)])));
|
|
6758
6762
|
}
|
|
6759
|
-
if (propTree.rest && !propTree.rest.props) addStatement("render", info.tagSection, tagReferencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(propTree.rest.binding, importAlias + "_$rest"), [createScopeReadExpression(info.childScopeBinding, info.tagSection), _marko_compiler.types.objectExpression(restProps || [])])),
|
|
6763
|
+
if (propTree.rest && !propTree.rest.props) addStatement("render", info.tagSection, tagReferencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(propTree.rest.binding, importAlias + "_$rest"), [createScopeReadExpression(info.childScopeBinding, info.tagSection), _marko_compiler.types.objectExpression(restProps || [])])), true);
|
|
6760
6764
|
}
|
|
6761
6765
|
}
|
|
6762
6766
|
function mapParamReasonToExpr(exprs, reason) {
|
|
@@ -6872,7 +6876,6 @@ function getOrCreatePropertyAlias(binding, property) {
|
|
|
6872
6876
|
function trackDomVarReferences(tag, binding) {
|
|
6873
6877
|
const tagVar = tag.node.var;
|
|
6874
6878
|
if (!tagVar) return;
|
|
6875
|
-
if (!_marko_compiler.types.isIdentifier(tagVar)) throw tag.get("var").buildCodeFrameError("Tag variables on native elements cannot be destructured.");
|
|
6876
6879
|
const babelBinding = tag.scope.getBinding(tagVar.name);
|
|
6877
6880
|
const section = getOrCreateSection(tag);
|
|
6878
6881
|
binding.originalName = tagVar.name;
|
|
@@ -9148,7 +9151,7 @@ function checkDynamicStylePlacement(tag) {
|
|
|
9148
9151
|
for (const sibling of tag.getAllPrevSiblings()) {
|
|
9149
9152
|
if (isCoreTagName(sibling, "style")) continue;
|
|
9150
9153
|
if (sibling.isMarkoText() ? /\S/.test(sibling.node.value) : getNodeContentType(sibling, "startType") !== null) {
|
|
9151
|
-
(0, _marko_compiler_babel_utils.diagnosticWarn)(tag, { label: "The `${...}` values of a [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) only apply to
|
|
9154
|
+
(0, _marko_compiler_babel_utils.diagnosticWarn)(tag, { label: "The `${...}` values of a [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) only apply to the subsequent siblings of the `<style>` tag and their descendants, so the content before this tag will not receive them. Move the `<style>` tag above the content it styles." });
|
|
9152
9155
|
return;
|
|
9153
9156
|
}
|
|
9154
9157
|
}
|
|
@@ -9180,10 +9183,10 @@ function translateDOM$1(tag) {
|
|
|
9180
9183
|
const { names, binding } = dynamic;
|
|
9181
9184
|
const section = getSection(tag);
|
|
9182
9185
|
const readEl = () => createScopeReadExpression(binding);
|
|
9183
|
-
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(callRuntime("_style_shell", scopeIdentifier, getScopeAccessorLiteral(binding))),
|
|
9186
|
+
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(callRuntime("_style_shell", scopeIdentifier, getScopeAccessorLiteral(binding))), true);
|
|
9184
9187
|
dynamicStyleValues(node).forEach((value, i) => {
|
|
9185
9188
|
const valueRef = value.extra?.referencedBindings;
|
|
9186
|
-
addStatement("render", section, valueRef, _marko_compiler.types.expressionStatement(callRuntime("_style_rule_item", readEl(), _marko_compiler.types.stringLiteral(names[i]), value)),
|
|
9189
|
+
addStatement("render", section, valueRef, _marko_compiler.types.expressionStatement(callRuntime("_style_rule_item", readEl(), _marko_compiler.types.stringLiteral(names[i]), value)), !valueRef);
|
|
9187
9190
|
});
|
|
9188
9191
|
}
|
|
9189
9192
|
emitStyleImport(tag);
|
|
@@ -9640,7 +9643,7 @@ function translateExit(placeholder) {
|
|
|
9640
9643
|
if (isHTML) {
|
|
9641
9644
|
write`${method === "_escape" ? buildEscapedTextExpression(value) : callRuntime(method, value)}`;
|
|
9642
9645
|
if (nodeBinding) markNode(placeholder, nodeBinding, markerSerializeReason);
|
|
9643
|
-
} else addStatement("render", section, valueExtra.referencedBindings, _marko_compiler.types.expressionStatement(method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding))),
|
|
9646
|
+
} else addStatement("render", section, valueExtra.referencedBindings, _marko_compiler.types.expressionStatement(method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding))), true);
|
|
9644
9647
|
}
|
|
9645
9648
|
placeholder.remove();
|
|
9646
9649
|
}
|
|
@@ -9761,7 +9764,7 @@ var referenced_identifier_default = {
|
|
|
9761
9764
|
const resetEmitted = getAbortResetEmitted(section);
|
|
9762
9765
|
if (!resetEmitted.has(exprRoot)) {
|
|
9763
9766
|
resetEmitted.add(exprRoot);
|
|
9764
|
-
addStatement("render", section, exprRoot.node.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importRuntime("$signalReset"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)]))
|
|
9767
|
+
addStatement("render", section, exprRoot.node.extra?.referencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importRuntime("$signalReset"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)])));
|
|
9765
9768
|
}
|
|
9766
9769
|
identifier.replaceWith(_marko_compiler.types.callExpression(importRuntime("$signal"), [scopeIdentifier, _marko_compiler.types.numericLiteral(exprId)]));
|
|
9767
9770
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Binding } from "./references";
|
|
2
|
+
import type { Section } from "./sections";
|
|
3
|
+
export declare function getBranchSectionAccessor(nodeBinding: Binding): NonNullable<Section["sectionAccessor"]>;
|
|
4
|
+
export declare function initBranchSection(bodySection: Section, upstreamExpression: Section["upstreamExpression"], sectionAccessor: Section["sectionAccessor"]): void;
|
|
5
|
+
export declare function resumeOwnerByMarkerWhenStatic(tagSection: Section, bodySection: Section, nodeBinding: Binding, statefulReasonKey: symbol): void;
|
|
@@ -15,9 +15,7 @@ export interface Signal {
|
|
|
15
15
|
}>;
|
|
16
16
|
intersection: Opt<Signal>;
|
|
17
17
|
render: t.Statement[];
|
|
18
|
-
renderReferencedBindings: ReferencedBindings;
|
|
19
18
|
effect: t.Statement[];
|
|
20
|
-
effectReferencedBindings: ReferencedBindings;
|
|
21
19
|
hasHTMLEffect: boolean;
|
|
22
20
|
hasSideEffect: boolean;
|
|
23
21
|
forcePersist: boolean;
|
|
@@ -46,7 +44,7 @@ export declare function signalHasStatements(signal: Signal): boolean;
|
|
|
46
44
|
export declare function getSignalFn(signal: Signal): t.Expression;
|
|
47
45
|
export declare function getSignalValueIdentifier(signal: Signal): t.Identifier;
|
|
48
46
|
export declare function replaceNullishAndEmptyFunctionsWith0(args: (t.Expression | undefined | false)[]): t.Expression[];
|
|
49
|
-
export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[],
|
|
47
|
+
export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], isPure?: boolean): void;
|
|
50
48
|
export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal, value: t.Expression): void;
|
|
51
49
|
export declare function getResumeRegisterId(section: Section, referencedBindings: string | ReferencedBindings, type?: string): string;
|
|
52
50
|
export declare function writeSignals(section: Section): Set<Signal>;
|
package/index.d.ts
CHANGED
|
@@ -11,7 +11,25 @@ declare global {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
namespace Marko {
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* A mutable global object for the current render.
|
|
16
|
+
*
|
|
17
|
+
* The open index signature means an unaugmented `$global` is unchecked. To
|
|
18
|
+
* type your own keys, merge into this interface:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* declare global {
|
|
22
|
+
* namespace Marko {
|
|
23
|
+
* interface Global {
|
|
24
|
+
* data?: MyRouteContext;
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Declare merged members OPTIONAL — a required one makes every
|
|
31
|
+
* `render({ $global: {} })` call fail with TS2741.
|
|
32
|
+
*/
|
|
15
33
|
export interface Global {
|
|
16
34
|
[x: PropertyKey]: unknown;
|
|
17
35
|
/** An AbortSignal instance that, when aborted, stops further streamed content. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marko",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.33",
|
|
4
4
|
"description": "Optimized runtime for Marko templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@marko/compiler": "^5.41.
|
|
51
|
+
"@marko/compiler": "^5.41.17",
|
|
52
52
|
"csstype": "^3.2.3",
|
|
53
53
|
"fastest-levenshtein": "^1.0.16",
|
|
54
54
|
"magic-string": "^0.30.21"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@marko/runtime-tags": "npm:marko@6.3.
|
|
58
|
-
"marko": "5.39.
|
|
57
|
+
"@marko/runtime-tags": "npm:marko@6.3.33",
|
|
58
|
+
"marko": "5.39.31"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=22"
|