marko 6.3.21 → 6.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/debug/html.js +5 -2
- package/dist/debug/html.mjs +5 -3
- package/dist/html/writer.d.ts +1 -0
- package/dist/html.d.ts +1 -1
- package/dist/html.js +4 -1
- package/dist/html.mjs +4 -1
- package/dist/translator/index.js +60 -7
- package/dist/translator/util/references.d.ts +4 -0
- package/dist/translator/visitors/program/index.d.ts +1 -0
- package/package.json +3 -3
package/dist/debug/html.js
CHANGED
|
@@ -28,8 +28,6 @@ const ControlledHandler = "ControlledHandler:";
|
|
|
28
28
|
const ControlledType = "ControlledType:";
|
|
29
29
|
const ControlledValue = "ControlledValue:";
|
|
30
30
|
const EventAttributes = "EventAttributes:";
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/common/constants/accessor-prop.debug.ts
|
|
33
31
|
const BranchAccessor = "#BranchAccessor";
|
|
34
32
|
const CatchContent = "#CatchContent";
|
|
35
33
|
const ClosestBranchId = "#ClosestBranchId";
|
|
@@ -1913,6 +1911,10 @@ function _trailers(html) {
|
|
|
1913
1911
|
function _resume(val, id, scopeId) {
|
|
1914
1912
|
return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
|
|
1915
1913
|
}
|
|
1914
|
+
function _resume_locals(val, id, locals, ownerScopeId) {
|
|
1915
|
+
if (ownerScopeId !== void 0) locals["_"] = _scope_with_id(ownerScopeId);
|
|
1916
|
+
return register(id, val, writeScope(_scope_id(), locals));
|
|
1917
|
+
}
|
|
1916
1918
|
function _el(scopeId, id) {
|
|
1917
1919
|
return _resume(() => _el_read_error(), id, scopeId);
|
|
1918
1920
|
}
|
|
@@ -3508,6 +3510,7 @@ exports._if = _if;
|
|
|
3508
3510
|
exports._peek_scope_id = _peek_scope_id;
|
|
3509
3511
|
exports._resume = _resume;
|
|
3510
3512
|
exports._resume_branch = _resume_branch;
|
|
3513
|
+
exports._resume_locals = _resume_locals;
|
|
3511
3514
|
Object.defineProperty(exports, "_scope", {
|
|
3512
3515
|
enumerable: true,
|
|
3513
3516
|
get: function() {
|
package/dist/debug/html.mjs
CHANGED
|
@@ -26,8 +26,6 @@ const ControlledHandler = "ControlledHandler:";
|
|
|
26
26
|
const ControlledType = "ControlledType:";
|
|
27
27
|
const ControlledValue = "ControlledValue:";
|
|
28
28
|
const EventAttributes = "EventAttributes:";
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/common/constants/accessor-prop.debug.ts
|
|
31
29
|
const BranchAccessor = "#BranchAccessor";
|
|
32
30
|
const CatchContent = "#CatchContent";
|
|
33
31
|
const ClosestBranchId = "#ClosestBranchId";
|
|
@@ -1911,6 +1909,10 @@ function _trailers(html) {
|
|
|
1911
1909
|
function _resume(val, id, scopeId) {
|
|
1912
1910
|
return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
|
|
1913
1911
|
}
|
|
1912
|
+
function _resume_locals(val, id, locals, ownerScopeId) {
|
|
1913
|
+
if (ownerScopeId !== void 0) locals["_"] = _scope_with_id(ownerScopeId);
|
|
1914
|
+
return register(id, val, writeScope(_scope_id(), locals));
|
|
1915
|
+
}
|
|
1914
1916
|
function _el(scopeId, id) {
|
|
1915
1917
|
return _resume(() => _el_read_error(), id, scopeId);
|
|
1916
1918
|
}
|
|
@@ -3453,4 +3455,4 @@ const compat = {
|
|
|
3453
3455
|
};
|
|
3454
3456
|
function NOOP() {}
|
|
3455
3457
|
//#endregion
|
|
3456
|
-
export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _show_end, _show_start, _style_html, _subscribe, _template, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
|
|
3458
|
+
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, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare function writeScript(script: string): void;
|
|
|
38
38
|
export declare function _script(scopeId: number, registryId: string): void;
|
|
39
39
|
export declare function _trailers(html: string): void;
|
|
40
40
|
export declare function _resume<T extends WeakKey>(val: T, id: string, scopeId?: number): T;
|
|
41
|
+
export declare function _resume_locals<T extends WeakKey>(val: T, id: string, locals: Record<string, unknown>, ownerScopeId?: number): T;
|
|
41
42
|
export declare function _el(scopeId: number, id: string): () => void;
|
|
42
43
|
export declare function _hoist(scopeId: number, id: string): {
|
|
43
44
|
(): void;
|
package/dist/html.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export { _escape, _escape_comment, _escape_script, _escape_style, _escape_style_
|
|
|
7
7
|
export { _content, _content_resume, _dynamic_tag } from "./html/dynamic-tag";
|
|
8
8
|
export { forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, } from "./html/for";
|
|
9
9
|
export { _template } from "./html/template";
|
|
10
|
-
export { _attr_content, _await, _el, _el_resume, _existing_scope, _for_in, _for_of, _for_to, _for_until, _hoist, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _show_end, _show_start, _subscribe, _trailers, _try, _var, $global, } from "./html/writer";
|
|
10
|
+
export { _attr_content, _await, _el, _el_resume, _existing_scope, _for_in, _for_of, _for_to, _for_until, _hoist, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _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
|
@@ -1291,6 +1291,9 @@ function _trailers(html) {
|
|
|
1291
1291
|
function _resume(val, id, scopeId) {
|
|
1292
1292
|
return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
|
|
1293
1293
|
}
|
|
1294
|
+
function _resume_locals(val, id, locals, ownerScopeId) {
|
|
1295
|
+
return ownerScopeId !== void 0 && (locals._ = _scope_with_id(ownerScopeId)), register(id, val, writeScope(_scope_id(), locals));
|
|
1296
|
+
}
|
|
1294
1297
|
function _el(scopeId, id) {
|
|
1295
1298
|
return _resume(() => void 0, id, scopeId);
|
|
1296
1299
|
}
|
|
@@ -2192,4 +2195,4 @@ exports.$global = $global, exports._assert_hoist = _assert_hoist, exports._attr
|
|
|
2192
2195
|
get: function() {
|
|
2193
2196
|
return _dynamic_tag;
|
|
2194
2197
|
}
|
|
2195
|
-
}), exports._el = _el, exports._el_read_error = _el_read_error, exports._el_resume = _el_resume, exports._escape = _escape, exports._escape_comment = _escape_comment, exports._escape_script = _escape_script, exports._escape_style = _escape_style, exports._escape_style_value = _escape_style_value, exports._existing_scope = _existing_scope, exports._flush_head = _flush_head, exports._for_in = _for_in, exports._for_of = _for_of, exports._for_to = _for_to, exports._for_until = _for_until, exports._hoist = _hoist, exports._hoist_read_error = _hoist_read_error, exports._html = _html, exports._id = _id, exports._if = _if, exports._peek_scope_id = _peek_scope_id, exports._resume = _resume, exports._resume_branch = _resume_branch, exports._scope = writeScope, exports._scope_id = _scope_id, exports._scope_reason = _scope_reason, exports._scope_with_id = _scope_with_id, exports._script = _script, exports._sep = _sep, exports._serialize_guard = _serialize_guard, exports._serialize_if = _serialize_if, exports._set_serialize_reason = _set_serialize_reason, exports._show_end = _show_end, exports._show_start = _show_start, exports._style_html = _style_html, exports._subscribe = _subscribe, exports._template = _template, exports._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.forInBy = forInBy, exports.forOf = forOf, exports.forOfBy = forOfBy, exports.forStepBy = forStepBy, exports.forTo = forTo, exports.forUntil = forUntil, exports.withLoadAssets = withLoadAssets, exports.withPageAssets = withPageAssets;
|
|
2198
|
+
}), 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.forInBy = forInBy, exports.forOf = forOf, exports.forOfBy = forOfBy, exports.forStepBy = forStepBy, exports.forTo = forTo, exports.forUntil = forUntil, exports.withLoadAssets = withLoadAssets, exports.withPageAssets = withPageAssets;
|
package/dist/html.mjs
CHANGED
|
@@ -1290,6 +1290,9 @@ function _trailers(html) {
|
|
|
1290
1290
|
function _resume(val, id, scopeId) {
|
|
1291
1291
|
return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
|
|
1292
1292
|
}
|
|
1293
|
+
function _resume_locals(val, id, locals, ownerScopeId) {
|
|
1294
|
+
return ownerScopeId !== void 0 && (locals._ = _scope_with_id(ownerScopeId)), register(id, val, writeScope(_scope_id(), locals));
|
|
1295
|
+
}
|
|
1293
1296
|
function _el(scopeId, id) {
|
|
1294
1297
|
return _resume(() => void 0, id, scopeId);
|
|
1295
1298
|
}
|
|
@@ -2187,4 +2190,4 @@ function toObjectExpression(options) {
|
|
|
2187
2190
|
//#region src/html/compat.ts
|
|
2188
2191
|
function NOOP() {}
|
|
2189
2192
|
//#endregion
|
|
2190
|
-
export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _show_end, _show_start, _style_html, _subscribe, _template, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
|
|
2193
|
+
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, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
|
package/dist/translator/index.js
CHANGED
|
@@ -3293,8 +3293,15 @@ function writeRegisteredFns() {
|
|
|
3293
3293
|
if (registeredFns) {
|
|
3294
3294
|
for (const registeredFn of registeredFns) {
|
|
3295
3295
|
let fn;
|
|
3296
|
-
if (registeredFn.referencedBindings || registeredFn.referencesScope
|
|
3297
|
-
|
|
3296
|
+
if (registeredFn.referencedBindings || registeredFn.referencesScope || registeredFn.referencedLocals) {
|
|
3297
|
+
let params;
|
|
3298
|
+
let prologue;
|
|
3299
|
+
if (registeredFn.referencedLocals) {
|
|
3300
|
+
params = [localsIdentifier];
|
|
3301
|
+
if (registeredFn.referencedBindings || registeredFn.referencesScope) prologue = [_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(scopeIdentifier, _marko_compiler.types.memberExpression(localsIdentifier, _marko_compiler.types.identifier(getAccessorProp().Owner)))])];
|
|
3302
|
+
} else params = [scopeIdentifier];
|
|
3303
|
+
fn = _marko_compiler.types.functionDeclaration(_marko_compiler.types.identifier(registeredFn.id), params, _marko_compiler.types.blockStatement(toReturnedFunction(registeredFn.node, prologue)));
|
|
3304
|
+
} else if (registeredFn.node.type === "FunctionDeclaration" && registeredFn.node.id?.name === registeredFn.id) fn = registeredFn.node;
|
|
3298
3305
|
else fn = _marko_compiler.types.functionDeclaration(_marko_compiler.types.identifier(registeredFn.id), registeredFn.node.params, registeredFn.node.body.type === "BlockStatement" ? registeredFn.node.body : _marko_compiler.types.blockStatement([_marko_compiler.types.returnStatement(registeredFn.node.body)]), registeredFn.node.generator, registeredFn.node.async);
|
|
3299
3306
|
statements.push(fn);
|
|
3300
3307
|
}
|
|
@@ -3302,8 +3309,12 @@ function writeRegisteredFns() {
|
|
|
3302
3309
|
(0, _marko_compiler_babel_utils.getProgram)().node.body.push(...statements);
|
|
3303
3310
|
}
|
|
3304
3311
|
}
|
|
3305
|
-
function toReturnedFunction(rawFn) {
|
|
3312
|
+
function toReturnedFunction(rawFn, prologue) {
|
|
3306
3313
|
const fn = simplifyFunction(rawFn);
|
|
3314
|
+
if (prologue) {
|
|
3315
|
+
if (fn.body.type !== "BlockStatement") fn.body = _marko_compiler.types.blockStatement([_marko_compiler.types.returnStatement(fn.body)]);
|
|
3316
|
+
fn.body.body.unshift(...prologue);
|
|
3317
|
+
}
|
|
3307
3318
|
return fn.type === "FunctionDeclaration" ? [fn, _marko_compiler.types.returnStatement(fn.id)] : [_marko_compiler.types.returnStatement(fn)];
|
|
3308
3319
|
}
|
|
3309
3320
|
function addHTMLEffectCall(section, referencedBindings) {
|
|
@@ -3550,6 +3561,7 @@ function getRegisteredFnExpression$1(node) {
|
|
|
3550
3561
|
const id = extra.name;
|
|
3551
3562
|
const referencesScope = extra.referencesScope;
|
|
3552
3563
|
const referencedBindings = extra.referencedBindingsInFunction;
|
|
3564
|
+
const referencedLocals = extra.referencedLocalBindingsInFunction;
|
|
3553
3565
|
let registeredFns = registeredFnsForProgram.get((0, _marko_compiler_babel_utils.getProgram)().node);
|
|
3554
3566
|
if (!registeredFns) registeredFnsForProgram.set((0, _marko_compiler_babel_utils.getProgram)().node, registeredFns = []);
|
|
3555
3567
|
registeredFns.push({
|
|
@@ -3558,9 +3570,17 @@ function getRegisteredFnExpression$1(node) {
|
|
|
3558
3570
|
registerId: extra.registerId,
|
|
3559
3571
|
section: extra.section,
|
|
3560
3572
|
referencesScope,
|
|
3561
|
-
referencedBindings
|
|
3573
|
+
referencedBindings,
|
|
3574
|
+
referencedLocals
|
|
3562
3575
|
});
|
|
3563
|
-
if (
|
|
3576
|
+
if (referencedLocals) {
|
|
3577
|
+
const properties = [];
|
|
3578
|
+
if (referencesScope || referencedBindings) properties.push(_marko_compiler.types.objectProperty(_marko_compiler.types.identifier(getAccessorProp().Owner), scopeIdentifier));
|
|
3579
|
+
forEach(referencedLocals, (binding) => {
|
|
3580
|
+
properties.push(toObjectProperty(getLocalsScopeAccessor(binding), getDeclaredBindingExpression(binding)));
|
|
3581
|
+
});
|
|
3582
|
+
return _marko_compiler.types.callExpression(_marko_compiler.types.identifier(id), [_marko_compiler.types.objectExpression(properties)]);
|
|
3583
|
+
} else if (referencesScope || referencedBindings) return _marko_compiler.types.callExpression(_marko_compiler.types.identifier(id), [scopeIdentifier]);
|
|
3564
3584
|
else return _marko_compiler.types.identifier(id);
|
|
3565
3585
|
}
|
|
3566
3586
|
}
|
|
@@ -3755,7 +3775,17 @@ function addRegisteredDeclarations(body) {
|
|
|
3755
3775
|
}
|
|
3756
3776
|
function getRegisteredFnExpression(node) {
|
|
3757
3777
|
const { extra } = node;
|
|
3758
|
-
if (isRegisteredFnExtra(extra))
|
|
3778
|
+
if (isRegisteredFnExtra(extra)) {
|
|
3779
|
+
const referencedLocals = extra.referencedLocalBindingsInFunction;
|
|
3780
|
+
if (referencedLocals) {
|
|
3781
|
+
const localProperties = [];
|
|
3782
|
+
forEach(referencedLocals, (binding) => {
|
|
3783
|
+
localProperties.push(toObjectProperty(getLocalsScopeAccessor(binding), getDeclaredBindingExpression(binding)));
|
|
3784
|
+
});
|
|
3785
|
+
return callRuntime("_resume_locals", simplifyFunction(node), _marko_compiler.types.stringLiteral(extra.registerId), _marko_compiler.types.objectExpression(localProperties), (extra.referencedBindingsInFunction || extra.referencesScope) && getScopeIdIdentifier(extra.section));
|
|
3786
|
+
}
|
|
3787
|
+
return callRuntime("_resume", simplifyFunction(node), _marko_compiler.types.stringLiteral(extra.registerId), (extra.referencedBindingsInFunction || extra.referencesScope) && getScopeIdIdentifier(extra.section));
|
|
3788
|
+
}
|
|
3759
3789
|
}
|
|
3760
3790
|
//#endregion
|
|
3761
3791
|
//#region src/translator/util/body-to-text-literal.ts
|
|
@@ -5678,6 +5708,7 @@ function buildUndefined() {
|
|
|
5678
5708
|
//#endregion
|
|
5679
5709
|
//#region src/translator/visitors/program/index.ts
|
|
5680
5710
|
let scopeIdentifier;
|
|
5711
|
+
let localsIdentifier;
|
|
5681
5712
|
var program_default = {
|
|
5682
5713
|
migrate: {
|
|
5683
5714
|
enter(program) {
|
|
@@ -5720,6 +5751,7 @@ var program_default = {
|
|
|
5720
5751
|
translate: {
|
|
5721
5752
|
enter(program) {
|
|
5722
5753
|
scopeIdentifier = isOutputDOM() ? generateUidIdentifier("scope") : null;
|
|
5754
|
+
localsIdentifier = isOutputDOM() ? generateUidIdentifier("locals") : null;
|
|
5723
5755
|
{
|
|
5724
5756
|
const markoOpts = getMarkoOpts();
|
|
5725
5757
|
const { output, entry, runtimeId } = markoOpts;
|
|
@@ -5914,7 +5946,9 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
5914
5946
|
const childScopeBinding = tagExtra[kChildScopeBinding];
|
|
5915
5947
|
if (getSerializeReason(section, childScopeBinding)) {
|
|
5916
5948
|
const peekScopeId = generateUidIdentifier(childScopeBinding?.name);
|
|
5917
|
-
|
|
5949
|
+
const peekScopeDeclaration = _marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(peekScopeId, callRuntime("_peek_scope_id"))]);
|
|
5950
|
+
if (tagVar) tag.insertBefore(peekScopeDeclaration);
|
|
5951
|
+
else statements.push(peekScopeDeclaration);
|
|
5918
5952
|
setBindingSerializedValue(section, childScopeBinding, callRuntime("_existing_scope", peekScopeId));
|
|
5919
5953
|
if (tagVar) statements.push(_marko_compiler.types.expressionStatement(callRuntime("_var", getScopeIdIdentifier(section), getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding$1]), peekScopeId, _marko_compiler.types.stringLiteral(getResumeRegisterId(section, tagVar.extra?.binding, "var")))));
|
|
5920
5954
|
}
|
|
@@ -6605,6 +6639,17 @@ function trackReferencesForBinding(babelBinding, binding) {
|
|
|
6605
6639
|
invoked
|
|
6606
6640
|
});
|
|
6607
6641
|
} else if (binding.type !== 4 || refSection !== binding.section) trackReference(ref, binding);
|
|
6642
|
+
else {
|
|
6643
|
+
const fnRoot = getFnRoot(ref);
|
|
6644
|
+
if (fnRoot) {
|
|
6645
|
+
const fnExtra = fnRoot.node.extra ??= {};
|
|
6646
|
+
fnExtra.referencedLocalBindingsInFunction = bindingUtil.add(fnExtra.referencedLocalBindingsInFunction, binding);
|
|
6647
|
+
const refExtra = ref.node.extra ??= {};
|
|
6648
|
+
refExtra.section = refSection;
|
|
6649
|
+
refExtra.read = createRead(binding, void 0);
|
|
6650
|
+
refExtra.read.localFn = fnExtra;
|
|
6651
|
+
}
|
|
6652
|
+
}
|
|
6608
6653
|
}
|
|
6609
6654
|
for (const ref of constantViolations) {
|
|
6610
6655
|
if (ref.type === "MarkoTag") throw ref.get("var").buildCodeFrameError(`Duplicate declaration ${JSON.stringify(binding.name)}`);
|
|
@@ -7229,6 +7274,9 @@ function getScopeAccessor(binding, encoded, includeId) {
|
|
|
7229
7274
|
else if (includeId || canonicalBinding.type === 0) return `${canonicalBinding.name}/${canonicalBinding.id}`;
|
|
7230
7275
|
return canonicalBinding.scopeAccessor ?? canonicalBinding.name;
|
|
7231
7276
|
}
|
|
7277
|
+
function getLocalsScopeAccessor(binding) {
|
|
7278
|
+
return getScopeAccessor(binding, false, true);
|
|
7279
|
+
}
|
|
7232
7280
|
function getPrefixedScopeAccessor(binding, prefix) {
|
|
7233
7281
|
const canonicalBinding = getCanonicalBinding(binding);
|
|
7234
7282
|
if (isOptimize()) switch (prefix) {
|
|
@@ -7303,6 +7351,11 @@ function getReadReplacement(node, signal) {
|
|
|
7303
7351
|
if (read.props === void 0) {
|
|
7304
7352
|
if (read.getter?.invoked) return;
|
|
7305
7353
|
if (isOutputDOM()) {
|
|
7354
|
+
if (read.localFn) {
|
|
7355
|
+
if (isRegisteredFnExtra(read.localFn)) return toMemberExpression(localsIdentifier, getLocalsScopeAccessor(readBinding));
|
|
7356
|
+
if (node.type === "Identifier" && node.name !== readBinding.name) node.name = readBinding.name;
|
|
7357
|
+
return;
|
|
7358
|
+
}
|
|
7306
7359
|
const inlined = getSignals(extra.section).get(readBinding)?.inline?.value;
|
|
7307
7360
|
if (inlined) replacement = _marko_compiler.types.cloneNode(inlined, true);
|
|
7308
7361
|
else if (signal?.referencedBindings === readBinding && !signal.hasSideEffect) replacement = getSignalValueIdentifier(signal);
|
|
@@ -74,6 +74,8 @@ interface ExtraRead {
|
|
|
74
74
|
props: Opt<string>;
|
|
75
75
|
ownVar: boolean;
|
|
76
76
|
getter: Getter | undefined;
|
|
77
|
+
/** Set for same-section local reads: the function root that owns the read. */
|
|
78
|
+
localFn?: ReferencedFunctionExtra;
|
|
77
79
|
}
|
|
78
80
|
declare module "@marko/compiler/dist/types" {
|
|
79
81
|
interface NodeExtra {
|
|
@@ -96,6 +98,7 @@ declare module "@marko/compiler/dist/types" {
|
|
|
96
98
|
interface FunctionExtra {
|
|
97
99
|
referencesScope?: boolean;
|
|
98
100
|
referencedBindingsInFunction?: ReferencedBindings;
|
|
101
|
+
referencedLocalBindingsInFunction?: Opt<Binding>;
|
|
99
102
|
constantBindingsInFunction?: ReferencedBindings;
|
|
100
103
|
name?: string;
|
|
101
104
|
registerId?: string;
|
|
@@ -139,6 +142,7 @@ export declare function getCanonicalBinding(binding: Binding): Binding;
|
|
|
139
142
|
export declare function getAllTagReferenceNodes(tag: t.MarkoTag, referenceNodes?: t.Node[]): t.Node[];
|
|
140
143
|
export declare function getScopeAccessorLiteral(binding: Binding, encoded?: boolean, includeId?: boolean): t.NumericLiteral | t.StringLiteral;
|
|
141
144
|
export declare function getScopeAccessor(binding: Binding, encoded?: boolean, includeId?: boolean): string;
|
|
145
|
+
export declare function getLocalsScopeAccessor(binding: Binding): string;
|
|
142
146
|
export declare function getPrefixedScopeAccessor(binding: Binding, prefix: AccessorPrefix): string;
|
|
143
147
|
export declare function getClosureAccessorId(binding: Binding): number;
|
|
144
148
|
export declare function getDebugScopeAccess(binding: Binding): {
|
|
@@ -2,6 +2,7 @@ import { types as t } from "@marko/compiler";
|
|
|
2
2
|
import { type BindingPropTree } from "../../util/binding-prop-tree";
|
|
3
3
|
import { preAnalyze } from "./pre-analyze";
|
|
4
4
|
export declare let scopeIdentifier: t.Identifier;
|
|
5
|
+
export declare let localsIdentifier: t.Identifier;
|
|
5
6
|
export declare function isScopeIdentifier(node: t.Node): node is t.Identifier;
|
|
6
7
|
declare module "@marko/compiler/dist/types" {
|
|
7
8
|
interface ProgramExtra {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marko",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.22",
|
|
4
4
|
"description": "Optimized runtime for Marko templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@marko/compiler": "^5.41.
|
|
51
|
+
"@marko/compiler": "^5.41.8",
|
|
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.
|
|
57
|
+
"@marko/runtime-tags": "npm:marko@6.3.22",
|
|
58
58
|
"marko": "5.39.27"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|