marko 6.1.21 → 6.1.23
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 +12 -0
- package/dist/debug/html.mjs +10 -1
- package/dist/html/attrs.d.ts +3 -0
- package/dist/html.d.ts +1 -1
- package/dist/html.js +10 -1
- package/dist/html.mjs +10 -1
- package/dist/translator/index.js +108 -11
- package/dist/translator/util/references.d.ts +1 -0
- package/package.json +1 -1
package/dist/debug/html.js
CHANGED
|
@@ -2526,6 +2526,15 @@ function _attr_nonce() {
|
|
|
2526
2526
|
function _attr(name, value) {
|
|
2527
2527
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
2528
2528
|
}
|
|
2529
|
+
function _attr_and(name, value, attr) {
|
|
2530
|
+
return value ? attr : _attr(name, value);
|
|
2531
|
+
}
|
|
2532
|
+
function _attr_or(name, value, attr) {
|
|
2533
|
+
return value ? _attr(name, value) : attr;
|
|
2534
|
+
}
|
|
2535
|
+
function _attr_nullish(name, value, attr) {
|
|
2536
|
+
return value == null ? attr : _attr(name, value);
|
|
2537
|
+
}
|
|
2529
2538
|
function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
2530
2539
|
let result = "";
|
|
2531
2540
|
let skip = /[\s/>"'=]/;
|
|
@@ -3153,6 +3162,7 @@ function NOOP() {}
|
|
|
3153
3162
|
exports.$global = $global;
|
|
3154
3163
|
exports._assert_hoist = _assert_hoist;
|
|
3155
3164
|
exports._attr = _attr;
|
|
3165
|
+
exports._attr_and = _attr_and;
|
|
3156
3166
|
exports._attr_class = _attr_class;
|
|
3157
3167
|
exports._attr_content = _attr_content;
|
|
3158
3168
|
exports._attr_details_open = _attr_details_or_dialog_open;
|
|
@@ -3161,7 +3171,9 @@ exports._attr_input_checked = _attr_input_checked;
|
|
|
3161
3171
|
exports._attr_input_checkedValue = _attr_input_checkedValue;
|
|
3162
3172
|
exports._attr_input_value = _attr_input_value;
|
|
3163
3173
|
exports._attr_nonce = _attr_nonce;
|
|
3174
|
+
exports._attr_nullish = _attr_nullish;
|
|
3164
3175
|
exports._attr_option_value = _attr_option_value;
|
|
3176
|
+
exports._attr_or = _attr_or;
|
|
3165
3177
|
exports._attr_select_value = _attr_select_value;
|
|
3166
3178
|
exports._attr_style = _attr_style;
|
|
3167
3179
|
exports._attr_textarea_value = _attr_textarea_value;
|
package/dist/debug/html.mjs
CHANGED
|
@@ -2524,6 +2524,15 @@ function _attr_nonce() {
|
|
|
2524
2524
|
function _attr(name, value) {
|
|
2525
2525
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
2526
2526
|
}
|
|
2527
|
+
function _attr_and(name, value, attr) {
|
|
2528
|
+
return value ? attr : _attr(name, value);
|
|
2529
|
+
}
|
|
2530
|
+
function _attr_or(name, value, attr) {
|
|
2531
|
+
return value ? _attr(name, value) : attr;
|
|
2532
|
+
}
|
|
2533
|
+
function _attr_nullish(name, value, attr) {
|
|
2534
|
+
return value == null ? attr : _attr(name, value);
|
|
2535
|
+
}
|
|
2527
2536
|
function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
2528
2537
|
let result = "";
|
|
2529
2538
|
let skip = /[\s/>"'=]/;
|
|
@@ -3148,4 +3157,4 @@ const compat = {
|
|
|
3148
3157
|
};
|
|
3149
3158
|
function NOOP() {}
|
|
3150
3159
|
//#endregion
|
|
3151
|
-
export { $global, _assert_hoist, _attr, _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_option_value, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _subscribe, _template, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
|
|
3160
|
+
export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _subscribe, _template, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
|
package/dist/html/attrs.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export declare function _attr_input_checkedValue(scopeId: number, nodeAccessor:
|
|
|
10
10
|
export declare function _attr_details_or_dialog_open(scopeId: number, nodeAccessor: Accessor, open: unknown, openChange: unknown, serializeType?: 1): "" | " open";
|
|
11
11
|
export declare function _attr_nonce(): string;
|
|
12
12
|
export declare function _attr(name: string, value: unknown): string;
|
|
13
|
+
export declare function _attr_and(name: string, value: unknown, attr: string): string;
|
|
14
|
+
export declare function _attr_or(name: string, value: unknown, attr: string): string;
|
|
15
|
+
export declare function _attr_nullish(name: string, value: unknown, attr: string): string;
|
|
13
16
|
export declare function _attrs(data: Record<string, unknown>, nodeAccessor: Accessor, scopeId: number, tagName: string): string;
|
|
14
17
|
export declare function _attrs_content(data: Record<string, unknown>, nodeAccessor: Accessor, scopeId: number, tagName: string, serializeReason?: 1 | 0): void;
|
|
15
18
|
export declare function _attrs_partial(data: Record<string, unknown>, skip: Record<string, 1>, nodeAccessor: Accessor, scopeId: number, tagName: string): string;
|
package/dist/html.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { attrTag, attrTags } from "./common/attr-tag";
|
|
2
2
|
export { _assert_hoist, _el_read_error, _hoist_read_error, } from "./common/errors";
|
|
3
3
|
export { _flush_head, withLoadAssets, withPageAssets } from "./html/assets";
|
|
4
|
-
export { _attr, _attr_class, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_option_value, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, } from "./html/attrs";
|
|
4
|
+
export { _attr, _attr_and, _attr_class, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, } from "./html/attrs";
|
|
5
5
|
export { compat } from "./html/compat";
|
|
6
6
|
export { _escape, _escape_comment, _escape_script, _escape_style, _to_text, _unescaped, } from "./html/content";
|
|
7
7
|
export { _content, _content_resume, _dynamic_tag } from "./html/dynamic-tag";
|
package/dist/html.js
CHANGED
|
@@ -1647,6 +1647,15 @@ function _attr_nonce() {
|
|
|
1647
1647
|
function _attr(name, value) {
|
|
1648
1648
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
1649
1649
|
}
|
|
1650
|
+
function _attr_and(name, value, attr) {
|
|
1651
|
+
return value ? attr : _attr(name, value);
|
|
1652
|
+
}
|
|
1653
|
+
function _attr_or(name, value, attr) {
|
|
1654
|
+
return value ? _attr(name, value) : attr;
|
|
1655
|
+
}
|
|
1656
|
+
function _attr_nullish(name, value, attr) {
|
|
1657
|
+
return value == null ? attr : _attr(name, value);
|
|
1658
|
+
}
|
|
1650
1659
|
function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
1651
1660
|
let result = "", skip = /[\s/>"'=]/, events;
|
|
1652
1661
|
switch (tagName) {
|
|
@@ -1970,7 +1979,7 @@ function toObjectExpression(options) {
|
|
|
1970
1979
|
//#endregion
|
|
1971
1980
|
//#region src/html/compat.ts
|
|
1972
1981
|
function NOOP() {}
|
|
1973
|
-
exports.$global = $global, exports._assert_hoist = _assert_hoist, exports._attr = _attr, exports._attr_class = _attr_class, exports._attr_content = _attr_content, exports._attr_details_open = _attr_details_or_dialog_open, exports._attr_dialog_open = _attr_details_or_dialog_open, exports._attr_input_checked = _attr_input_checked, exports._attr_input_checkedValue = _attr_input_checkedValue, exports._attr_input_value = _attr_input_value, exports._attr_nonce = _attr_nonce, exports._attr_option_value = _attr_option_value, exports._attr_select_value = _attr_select_value, exports._attr_style = _attr_style, exports._attr_textarea_value = _attr_textarea_value, exports._attrs = _attrs, exports._attrs_content = _attrs_content, exports._attrs_partial = _attrs_partial, exports._attrs_partial_content = _attrs_partial_content, exports._await = _await, exports._content = _content, exports._content_resume = _content_resume, Object.defineProperty(exports, "_dynamic_tag", {
|
|
1982
|
+
exports.$global = $global, exports._assert_hoist = _assert_hoist, exports._attr = _attr, exports._attr_and = _attr_and, exports._attr_class = _attr_class, exports._attr_content = _attr_content, exports._attr_details_open = _attr_details_or_dialog_open, exports._attr_dialog_open = _attr_details_or_dialog_open, exports._attr_input_checked = _attr_input_checked, exports._attr_input_checkedValue = _attr_input_checkedValue, exports._attr_input_value = _attr_input_value, exports._attr_nonce = _attr_nonce, exports._attr_nullish = _attr_nullish, exports._attr_option_value = _attr_option_value, exports._attr_or = _attr_or, exports._attr_select_value = _attr_select_value, exports._attr_style = _attr_style, exports._attr_textarea_value = _attr_textarea_value, exports._attrs = _attrs, exports._attrs_content = _attrs_content, exports._attrs_partial = _attrs_partial, exports._attrs_partial_content = _attrs_partial_content, exports._await = _await, exports._content = _content, exports._content_resume = _content_resume, Object.defineProperty(exports, "_dynamic_tag", {
|
|
1974
1983
|
enumerable: !0,
|
|
1975
1984
|
get: function() {
|
|
1976
1985
|
return _dynamic_tag;
|
package/dist/html.mjs
CHANGED
|
@@ -1646,6 +1646,15 @@ function _attr_nonce() {
|
|
|
1646
1646
|
function _attr(name, value) {
|
|
1647
1647
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
1648
1648
|
}
|
|
1649
|
+
function _attr_and(name, value, attr) {
|
|
1650
|
+
return value ? attr : _attr(name, value);
|
|
1651
|
+
}
|
|
1652
|
+
function _attr_or(name, value, attr) {
|
|
1653
|
+
return value ? _attr(name, value) : attr;
|
|
1654
|
+
}
|
|
1655
|
+
function _attr_nullish(name, value, attr) {
|
|
1656
|
+
return value == null ? attr : _attr(name, value);
|
|
1657
|
+
}
|
|
1649
1658
|
function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
1650
1659
|
let result = "", skip = /[\s/>"'=]/, events;
|
|
1651
1660
|
switch (tagName) {
|
|
@@ -1970,4 +1979,4 @@ function toObjectExpression(options) {
|
|
|
1970
1979
|
//#region src/html/compat.ts
|
|
1971
1980
|
function NOOP() {}
|
|
1972
1981
|
//#endregion
|
|
1973
|
-
export { $global, _assert_hoist, _attr, _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_option_value, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _subscribe, _template, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
|
|
1982
|
+
export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _subscribe, _template, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, withLoadAssets, withPageAssets };
|
package/dist/translator/index.js
CHANGED
|
@@ -1757,6 +1757,7 @@ function isClientAssetImport(file, request) {
|
|
|
1757
1757
|
const kDirectContent = Symbol("direct content");
|
|
1758
1758
|
function getBindingPropTree(binding) {
|
|
1759
1759
|
if (pruneBinding(binding)) return;
|
|
1760
|
+
binding.exposed = true;
|
|
1760
1761
|
const props = {
|
|
1761
1762
|
binding,
|
|
1762
1763
|
props: void 0,
|
|
@@ -3007,6 +3008,7 @@ function initValue(binding, isLet = false) {
|
|
|
3007
3008
|
const section = binding.section;
|
|
3008
3009
|
const signal = getSignal(section, binding);
|
|
3009
3010
|
signal.build = () => {
|
|
3011
|
+
if (isPureMemberForwarder(binding)) return;
|
|
3010
3012
|
const fn = getSignalFn(signal);
|
|
3011
3013
|
if (binding.upstreamAlias && binding.property === void 0 && binding.excludeProperties === void 0 || !signal.hasSideEffect || !signalHasStatements(signal)) return fn;
|
|
3012
3014
|
return callRuntime(isLet ? signal.extraArgs ? "_let_change" : "_let" : "_const", getScopeAccessorLiteral(binding, true, isLet), fn);
|
|
@@ -3023,6 +3025,23 @@ function signalHasStatements(signal) {
|
|
|
3023
3025
|
} else if (signal.section.referencedClosures) return true;
|
|
3024
3026
|
return false;
|
|
3025
3027
|
}
|
|
3028
|
+
function isPureMemberForwarder(binding) {
|
|
3029
|
+
if (binding.property === void 0 || binding.reads.size || binding.exposed || binding.aliases.size || binding.assignmentSections || getSerializeReason(binding.section, binding) || getSignal(binding.section, binding).hasSideEffect) return false;
|
|
3030
|
+
for (const alias of binding.propertyAliases.values()) if (alias.type !== 6) return true;
|
|
3031
|
+
return false;
|
|
3032
|
+
}
|
|
3033
|
+
function pushMemberForwards(renderStatements, value, alias) {
|
|
3034
|
+
if (isPureMemberForwarder(alias)) {
|
|
3035
|
+
for (const [key, child] of alias.propertyAliases) if (child.type !== 6) pushMemberForwards(renderStatements, toMemberExpression(_marko_compiler.types.cloneNode(value, true), key, alias.nullable), child);
|
|
3036
|
+
} else {
|
|
3037
|
+
const aliasSignal = getSignal(alias.section, alias);
|
|
3038
|
+
renderStatements.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(aliasSignal.identifier, [
|
|
3039
|
+
scopeIdentifier,
|
|
3040
|
+
value,
|
|
3041
|
+
...getTranslatedExtraArgs(aliasSignal)
|
|
3042
|
+
])));
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3026
3045
|
function getSignalFn(signal) {
|
|
3027
3046
|
const section = signal.section;
|
|
3028
3047
|
const binding = signal.referencedBindings;
|
|
@@ -3056,14 +3075,7 @@ function getSignalFn(signal) {
|
|
|
3056
3075
|
...getTranslatedExtraArgs(aliasSignal)
|
|
3057
3076
|
])));
|
|
3058
3077
|
}
|
|
3059
|
-
for (const [key, alias] of binding.propertyAliases) if (alias.type !== 6)
|
|
3060
|
-
const aliasSignal = getSignal(alias.section, alias);
|
|
3061
|
-
signal.render.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(aliasSignal.identifier, [
|
|
3062
|
-
scopeIdentifier,
|
|
3063
|
-
toMemberExpression(createScopeReadExpression(binding), key, binding.nullable),
|
|
3064
|
-
...getTranslatedExtraArgs(aliasSignal)
|
|
3065
|
-
])));
|
|
3066
|
-
}
|
|
3078
|
+
for (const [key, alias] of binding.propertyAliases) if (alias.type !== 6) pushMemberForwards(signal.render, toMemberExpression(createScopeReadExpression(binding), key, binding.nullable), alias);
|
|
3067
3079
|
if (assertsHoists) signal.render.push(_marko_compiler.types.expressionStatement(callRuntime("_assert_hoist", createScopeReadExpression(binding))));
|
|
3068
3080
|
}
|
|
3069
3081
|
for (const value of signal.values) if (signalHasStatements(value.signal)) signal.render.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(value.signal.identifier, [
|
|
@@ -4459,13 +4471,19 @@ var native_tag_default = {
|
|
|
4459
4471
|
case "style": {
|
|
4460
4472
|
const helper = `_attr_${name}`;
|
|
4461
4473
|
if (confident) write`${getHTMLRuntime()[helper](computed)}`;
|
|
4462
|
-
else write`${
|
|
4474
|
+
else write`${factorAttrConditional(buildAttrExpression(value, (branch) => {
|
|
4475
|
+
const { confident, computed } = evaluate(branch);
|
|
4476
|
+
return confident ? getHTMLRuntime()[helper](computed) : void 0;
|
|
4477
|
+
}, (branch) => buildStringAttrAnd(helper, branch) || name === "class" && buildClassAttrExpression(branch) || callRuntime(helper, branch)))}`;
|
|
4463
4478
|
break;
|
|
4464
4479
|
}
|
|
4465
4480
|
default:
|
|
4466
4481
|
if (confident) write`${getHTMLRuntime()._attr(name, computed)}`;
|
|
4467
4482
|
else if (isEventHandler(name)) addHTMLEffectCall(tagSection, valueReferences);
|
|
4468
|
-
else write`${
|
|
4483
|
+
else write`${factorAttrConditional(buildAttrExpression(value, (branch) => {
|
|
4484
|
+
const { confident, computed } = evaluate(branch);
|
|
4485
|
+
return confident ? getHTMLRuntime()._attr(name, computed) : void 0;
|
|
4486
|
+
}, (branch) => buildLogicalAttr(name, branch) || callRuntime("_attr", _marko_compiler.types.stringLiteral(name), branch)))}`;
|
|
4469
4487
|
break;
|
|
4470
4488
|
}
|
|
4471
4489
|
}
|
|
@@ -4796,6 +4814,84 @@ function getTextOnlyEscapeHelper(tagName) {
|
|
|
4796
4814
|
default: return "_escape";
|
|
4797
4815
|
}
|
|
4798
4816
|
}
|
|
4817
|
+
function buildAttrExpression(value, serialize, dynamic) {
|
|
4818
|
+
if (value.type === "ConditionalExpression") return _marko_compiler.types.conditionalExpression(value.test, buildAttrExpression(value.consequent, serialize, dynamic), buildAttrExpression(value.alternate, serialize, dynamic));
|
|
4819
|
+
const serialized = serialize(value);
|
|
4820
|
+
return serialized === void 0 ? dynamic(value) : _marko_compiler.types.stringLiteral(serialized);
|
|
4821
|
+
}
|
|
4822
|
+
function factorAttrConditional(value) {
|
|
4823
|
+
if (value.type !== "ConditionalExpression") return value;
|
|
4824
|
+
const consequent = factorAttrConditional(value.consequent);
|
|
4825
|
+
const alternate = factorAttrConditional(value.alternate);
|
|
4826
|
+
if (consequent.type === "StringLiteral" && alternate.type === "StringLiteral") {
|
|
4827
|
+
const a = consequent.value;
|
|
4828
|
+
const b = alternate.value;
|
|
4829
|
+
const end = commonAttrPrefixEnd([a, b]);
|
|
4830
|
+
if (end) return normalizeStringExpression([a.slice(0, end), _marko_compiler.types.conditionalExpression(value.test, _marko_compiler.types.stringLiteral(a.slice(end)), _marko_compiler.types.stringLiteral(b.slice(end)))]);
|
|
4831
|
+
}
|
|
4832
|
+
return _marko_compiler.types.conditionalExpression(value.test, consequent, alternate);
|
|
4833
|
+
}
|
|
4834
|
+
function commonAttrPrefixEnd(strings) {
|
|
4835
|
+
let prefix = strings[0];
|
|
4836
|
+
for (let i = 1; i < strings.length && prefix; i++) {
|
|
4837
|
+
const s = strings[i];
|
|
4838
|
+
const len = Math.min(prefix.length, s.length);
|
|
4839
|
+
let j = 0;
|
|
4840
|
+
while (j < len && prefix[j] === s[j]) j++;
|
|
4841
|
+
prefix = prefix.slice(0, j);
|
|
4842
|
+
}
|
|
4843
|
+
return prefix.lastIndexOf("=") + 1;
|
|
4844
|
+
}
|
|
4845
|
+
function buildLogicalAttr(name, value) {
|
|
4846
|
+
if (value.type !== "LogicalExpression") return;
|
|
4847
|
+
const { confident, computed } = evaluate(value.right);
|
|
4848
|
+
if (!confident) return;
|
|
4849
|
+
const attr = getHTMLRuntime()._attr(name, computed);
|
|
4850
|
+
return callRuntime(value.operator === "&&" ? "_attr_and" : value.operator === "||" ? "_attr_or" : "_attr_nullish", _marko_compiler.types.stringLiteral(name), value.left, _marko_compiler.types.stringLiteral(attr));
|
|
4851
|
+
}
|
|
4852
|
+
function buildStringAttrAnd(helper, value) {
|
|
4853
|
+
if (value.type === "LogicalExpression" && value.operator === "&&") {
|
|
4854
|
+
const { confident, computed } = evaluate(value.right);
|
|
4855
|
+
if (confident) return _marko_compiler.types.conditionalExpression(value.left, _marko_compiler.types.stringLiteral(getHTMLRuntime()[helper](computed)), _marko_compiler.types.stringLiteral(""));
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4858
|
+
const MAX_PRECOMPUTED_CLASS_TOGGLES = 4;
|
|
4859
|
+
function buildClassAttrExpression(value) {
|
|
4860
|
+
if (value.type !== "ObjectExpression" && value.type !== "ArrayExpression") return;
|
|
4861
|
+
const meta = {
|
|
4862
|
+
staticItems: void 0,
|
|
4863
|
+
dynamicItems: void 0,
|
|
4864
|
+
dynamicValues: void 0
|
|
4865
|
+
};
|
|
4866
|
+
trackDelimitedAttrValue(value, meta);
|
|
4867
|
+
if (meta.dynamicItems || !meta.staticItems || !meta.dynamicValues) return;
|
|
4868
|
+
const base = toDelimitedString(meta.staticItems, " ", stringifyClassObject);
|
|
4869
|
+
if (!base) return;
|
|
4870
|
+
const { _attr_class } = getHTMLRuntime();
|
|
4871
|
+
const keys = Object.keys(meta.dynamicValues);
|
|
4872
|
+
if (keys.length === 1) {
|
|
4873
|
+
const [key] = keys;
|
|
4874
|
+
return _marko_compiler.types.conditionalExpression(meta.dynamicValues[key], _marko_compiler.types.stringLiteral(_attr_class(base + " " + key)), _marko_compiler.types.stringLiteral(_attr_class(base)));
|
|
4875
|
+
}
|
|
4876
|
+
if (keys.length <= MAX_PRECOMPUTED_CLASS_TOGGLES) {
|
|
4877
|
+
const combos = [];
|
|
4878
|
+
for (let mask = 0; mask < 1 << keys.length; mask++) {
|
|
4879
|
+
let classes = base;
|
|
4880
|
+
for (let i = 0; i < keys.length; i++) if (mask & 1 << i) classes += " " + keys[i];
|
|
4881
|
+
combos.push(_attr_class(classes));
|
|
4882
|
+
}
|
|
4883
|
+
const end = commonAttrPrefixEnd(combos);
|
|
4884
|
+
const table = generateUidIdentifier("class");
|
|
4885
|
+
(0, _marko_compiler_babel_utils.getProgram)().node.body.push(_marko_compiler.types.markoScriptlet([_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(table, _marko_compiler.types.arrayExpression(combos.map((combo) => _marko_compiler.types.stringLiteral(combo.slice(end)))))])], true));
|
|
4886
|
+
let index = _marko_compiler.types.conditionalExpression(meta.dynamicValues[keys[0]], _marko_compiler.types.numericLiteral(1), _marko_compiler.types.numericLiteral(0));
|
|
4887
|
+
for (let i = 1; i < keys.length; i++) index = _marko_compiler.types.binaryExpression("+", index, _marko_compiler.types.conditionalExpression(meta.dynamicValues[keys[i]], _marko_compiler.types.numericLiteral(1 << i), _marko_compiler.types.numericLiteral(0)));
|
|
4888
|
+
const lookup = _marko_compiler.types.memberExpression(_marko_compiler.types.cloneNode(table), index, true);
|
|
4889
|
+
return normalizeStringExpression([combos[0].slice(0, end), lookup]);
|
|
4890
|
+
}
|
|
4891
|
+
let classes = _marko_compiler.types.stringLiteral(base);
|
|
4892
|
+
for (const key of keys) classes = _marko_compiler.types.binaryExpression("+", classes, _marko_compiler.types.conditionalExpression(meta.dynamicValues[key], _marko_compiler.types.stringLiteral(" " + key), _marko_compiler.types.stringLiteral("")));
|
|
4893
|
+
return callRuntime("_attr_class", classes);
|
|
4894
|
+
}
|
|
4799
4895
|
function trackDelimitedAttrValue(expr, meta) {
|
|
4800
4896
|
switch (expr.type) {
|
|
4801
4897
|
case "ObjectExpression":
|
|
@@ -6190,7 +6286,8 @@ function createBinding(name, type, refSection, upstreamAlias, property, excludeP
|
|
|
6190
6286
|
export: void 0,
|
|
6191
6287
|
directContentExport: void 0,
|
|
6192
6288
|
nullable: !sameSection || excludeProperties === void 0,
|
|
6193
|
-
pruned: void 0
|
|
6289
|
+
pruned: void 0,
|
|
6290
|
+
exposed: false
|
|
6194
6291
|
};
|
|
6195
6292
|
if (property) {
|
|
6196
6293
|
if (declared) upstreamAlias.nullable = false;
|