marko 6.0.10 → 6.0.12
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/dom.js +97 -84
- package/dist/debug/dom.mjs +97 -84
- package/dist/dom/resume.d.ts +0 -1
- package/dist/dom.js +95 -104
- package/dist/dom.mjs +95 -104
- package/dist/translator/index.js +183 -181
- package/dist/translator/util/get-defined-binding-expression.d.ts +1 -1
- package/dist/translator/util/signals.d.ts +2 -14
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
@@ -2909,25 +2909,27 @@ var return_default = {
|
|
2909
2909
|
const section = getSection(tag);
|
2910
2910
|
const attrs2 = getKnownAttrValues(tag.node);
|
2911
2911
|
if (attrs2.value) {
|
2912
|
-
|
2912
|
+
addStatement(
|
2913
|
+
"render",
|
2913
2914
|
section,
|
2914
2915
|
attrs2.value.extra?.referencedBindings,
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
},
|
2919
|
-
attrs2.value
|
2916
|
+
import_compiler17.types.expressionStatement(
|
2917
|
+
callRuntime("tagVarSignal", scopeIdentifier, attrs2.value)
|
2918
|
+
)
|
2920
2919
|
);
|
2921
2920
|
}
|
2922
2921
|
if (attrs2.valueChange) {
|
2923
|
-
|
2922
|
+
addStatement(
|
2923
|
+
"render",
|
2924
2924
|
section,
|
2925
2925
|
attrs2.valueChange.extra?.referencedBindings,
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2926
|
+
import_compiler17.types.expressionStatement(
|
2927
|
+
callRuntime(
|
2928
|
+
"setTagVarChange",
|
2929
|
+
scopeIdentifier,
|
2930
|
+
attrs2.valueChange
|
2931
|
+
)
|
2932
|
+
)
|
2931
2933
|
);
|
2932
2934
|
}
|
2933
2935
|
tag.remove();
|
@@ -2950,16 +2952,17 @@ var return_default = {
|
|
2950
2952
|
// src/translator/util/get-defined-binding-expression.ts
|
2951
2953
|
var import_compiler18 = require("@marko/compiler");
|
2952
2954
|
function getDeclaredBindingExpression(binding) {
|
2953
|
-
|
2954
|
-
|
2955
|
-
|
2955
|
+
const canonicalBinding = getCanonicalBinding(binding);
|
2956
|
+
if (canonicalBinding.declared || !canonicalBinding.upstreamAlias) {
|
2957
|
+
return import_compiler18.types.identifier(canonicalBinding.name);
|
2958
|
+
} else if (canonicalBinding.property !== void 0) {
|
2956
2959
|
return toMemberExpression(
|
2957
|
-
getDeclaredBindingExpression(
|
2958
|
-
|
2959
|
-
|
2960
|
+
getDeclaredBindingExpression(canonicalBinding.upstreamAlias),
|
2961
|
+
canonicalBinding.property,
|
2962
|
+
canonicalBinding.upstreamAlias.nullable
|
2960
2963
|
);
|
2961
2964
|
} else {
|
2962
|
-
return getDeclaredBindingExpression(
|
2965
|
+
return getDeclaredBindingExpression(canonicalBinding.upstreamAlias);
|
2963
2966
|
}
|
2964
2967
|
}
|
2965
2968
|
|
@@ -3066,37 +3069,6 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
3066
3069
|
effect: [],
|
3067
3070
|
effectReferencedBindings: void 0,
|
3068
3071
|
subscribers: [],
|
3069
|
-
hasDownstreamIntersections: () => {
|
3070
|
-
let hasDownstreamIntersections = !!signal.intersection;
|
3071
|
-
if (!hasDownstreamIntersections) {
|
3072
|
-
for (const value of signal.values) {
|
3073
|
-
if (value.signal.hasDownstreamIntersections()) {
|
3074
|
-
hasDownstreamIntersections = true;
|
3075
|
-
break;
|
3076
|
-
}
|
3077
|
-
}
|
3078
|
-
}
|
3079
|
-
if (!hasDownstreamIntersections) {
|
3080
|
-
if (!Array.isArray(referencedBindings) && referencedBindings) {
|
3081
|
-
for (const alias of referencedBindings.aliases) {
|
3082
|
-
if (getSignal(section, alias).hasDownstreamIntersections()) {
|
3083
|
-
hasDownstreamIntersections = true;
|
3084
|
-
break;
|
3085
|
-
}
|
3086
|
-
}
|
3087
|
-
if (!hasDownstreamIntersections) {
|
3088
|
-
for (const [, alias] of referencedBindings.propertyAliases) {
|
3089
|
-
if (getSignal(section, alias).hasDownstreamIntersections()) {
|
3090
|
-
hasDownstreamIntersections = true;
|
3091
|
-
break;
|
3092
|
-
}
|
3093
|
-
}
|
3094
|
-
}
|
3095
|
-
}
|
3096
|
-
}
|
3097
|
-
signal.hasDownstreamIntersections = () => hasDownstreamIntersections;
|
3098
|
-
return hasDownstreamIntersections;
|
3099
|
-
},
|
3100
3072
|
build: unimplementedBuild,
|
3101
3073
|
export: !!exportName
|
3102
3074
|
}
|
@@ -3119,17 +3091,18 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
3119
3091
|
};
|
3120
3092
|
} else if (referencedBindings.section !== section && bindingUtil.find(section.referencedClosures, referencedBindings)) {
|
3121
3093
|
signal.build = () => {
|
3094
|
+
const canonicalClosure = getCanonicalBinding(referencedBindings);
|
3122
3095
|
const render = getSignalFn(signal);
|
3123
3096
|
const closureSignalBuilder = getClosureSignalBuilder(section);
|
3124
|
-
return !closureSignalBuilder || isDynamicClosure(section,
|
3097
|
+
return !closureSignalBuilder || isDynamicClosure(section, canonicalClosure) ? callRuntime(
|
3125
3098
|
"dynamicClosureRead",
|
3126
|
-
getScopeAccessorLiteral(
|
3099
|
+
getScopeAccessorLiteral(canonicalClosure),
|
3127
3100
|
render,
|
3128
|
-
isImmediateOwner(section,
|
3101
|
+
isImmediateOwner(section, canonicalClosure) ? void 0 : import_compiler20.types.arrowFunctionExpression(
|
3129
3102
|
[scopeIdentifier],
|
3130
|
-
getScopeExpression(section,
|
3103
|
+
getScopeExpression(section, canonicalClosure.section)
|
3131
3104
|
)
|
3132
|
-
) : getClosureSignalBuilder(section)(
|
3105
|
+
) : getClosureSignalBuilder(section)(canonicalClosure, render);
|
3133
3106
|
};
|
3134
3107
|
}
|
3135
3108
|
}
|
@@ -3142,7 +3115,7 @@ function initValue(binding, runtimeHelper = "value") {
|
|
3142
3115
|
const fn = getSignalFn(signal);
|
3143
3116
|
const isParamBinding = !binding.upstreamAlias && (binding.type === 3 /* param */ || binding.type === 2 /* input */);
|
3144
3117
|
const isNakedAlias = binding.upstreamAlias && !binding.property;
|
3145
|
-
const needsGuard = !isNakedAlias && (binding.downstreamExpressions.size || fn.type === "ArrowFunctionExpression" && fn.body.body.length > 0);
|
3118
|
+
const needsGuard = !isNakedAlias && (binding.closureSections || binding.downstreamExpressions.size || fn.type === "ArrowFunctionExpression" && fn.body.body.length > 0);
|
3146
3119
|
const needsCache = needsGuard || signal.intersection;
|
3147
3120
|
const needsMarks = isParamBinding || signal.intersection;
|
3148
3121
|
if (needsCache || needsMarks || binding.hoists.size) {
|
@@ -3171,7 +3144,6 @@ function getSignalFn(signal) {
|
|
3171
3144
|
const isIntersection = Array.isArray(binding);
|
3172
3145
|
const isBinding = binding && !isIntersection;
|
3173
3146
|
const isValue = isBinding && binding.section === section;
|
3174
|
-
let canUseCalleeDirectly = !signal.render.length;
|
3175
3147
|
if (isBinding && (signal.renderReferencedBindings || binding.aliases.size || binding.propertyAliases.size)) {
|
3176
3148
|
const valueParam = import_compiler20.types.identifier(binding.name);
|
3177
3149
|
if (binding.loc) {
|
@@ -3184,15 +3156,17 @@ function getSignalFn(signal) {
|
|
3184
3156
|
if (isValue) {
|
3185
3157
|
for (const alias of binding.aliases) {
|
3186
3158
|
const aliasSignal = getSignal(alias.section, alias);
|
3187
|
-
|
3188
|
-
|
3189
|
-
import_compiler20.types.
|
3190
|
-
|
3191
|
-
|
3192
|
-
|
3193
|
-
|
3194
|
-
|
3195
|
-
|
3159
|
+
if (aliasSignal.render.length || aliasSignal.values.length || aliasSignal.effect.length) {
|
3160
|
+
signal.render.push(
|
3161
|
+
import_compiler20.types.expressionStatement(
|
3162
|
+
import_compiler20.types.callExpression(aliasSignal.identifier, [
|
3163
|
+
scopeIdentifier,
|
3164
|
+
import_compiler20.types.identifier(binding.name),
|
3165
|
+
...getTranslatedExtraArgs(aliasSignal)
|
3166
|
+
])
|
3167
|
+
)
|
3168
|
+
);
|
3169
|
+
}
|
3196
3170
|
}
|
3197
3171
|
for (const [key, alias] of binding.propertyAliases) {
|
3198
3172
|
const aliasSignal = getSignal(alias.section, alias);
|
@@ -3212,26 +3186,31 @@ function getSignalFn(signal) {
|
|
3212
3186
|
}
|
3213
3187
|
}
|
3214
3188
|
for (const value of signal.values) {
|
3215
|
-
signal
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
value.
|
3220
|
-
|
3221
|
-
|
3222
|
-
|
3223
|
-
|
3189
|
+
const valSignal = value.signal;
|
3190
|
+
if (!valSignal.referencedBindings || Array.isArray(valSignal.referencedBindings) || !valSignal.referencedBindings.upstreamAlias || valSignal.referencedBindings.property || valSignal.effect.length || valSignal.render.length || valSignal.values.length) {
|
3191
|
+
signal.render.push(
|
3192
|
+
import_compiler20.types.expressionStatement(
|
3193
|
+
import_compiler20.types.callExpression(value.signal.identifier, [
|
3194
|
+
scopeIdentifier,
|
3195
|
+
value.value,
|
3196
|
+
...getTranslatedExtraArgs(value.signal)
|
3197
|
+
])
|
3198
|
+
)
|
3199
|
+
);
|
3200
|
+
} else {
|
3201
|
+
signal.render.push(import_compiler20.types.expressionStatement(value.value));
|
3202
|
+
}
|
3224
3203
|
}
|
3225
3204
|
forEach(signal.intersection, (intersection) => {
|
3226
3205
|
signal.render.push(
|
3227
3206
|
import_compiler20.types.expressionStatement(import_compiler20.types.callExpression(intersection, [scopeIdentifier]))
|
3228
3207
|
);
|
3229
3208
|
});
|
3230
|
-
if (isValue) {
|
3209
|
+
if (isValue && binding.sources) {
|
3231
3210
|
let dynamicClosureArgs;
|
3232
3211
|
let dynamicClosureSignalIdentifier;
|
3233
|
-
|
3234
|
-
|
3212
|
+
if (binding.sources) {
|
3213
|
+
forEach(binding.closureSections, (closureSection) => {
|
3235
3214
|
if (isDynamicClosure(closureSection, binding)) {
|
3236
3215
|
if (!dynamicClosureArgs) {
|
3237
3216
|
dynamicClosureArgs = [];
|
@@ -3258,17 +3237,17 @@ function getSignalFn(signal) {
|
|
3258
3237
|
)
|
3259
3238
|
);
|
3260
3239
|
}
|
3240
|
+
});
|
3241
|
+
if (dynamicClosureSignalIdentifier) {
|
3242
|
+
(signal.prependStatements ||= []).push(
|
3243
|
+
import_compiler20.types.variableDeclaration("const", [
|
3244
|
+
import_compiler20.types.variableDeclarator(
|
3245
|
+
dynamicClosureSignalIdentifier,
|
3246
|
+
callRuntime("dynamicClosure", ...dynamicClosureArgs)
|
3247
|
+
)
|
3248
|
+
])
|
3249
|
+
);
|
3261
3250
|
}
|
3262
|
-
});
|
3263
|
-
if (dynamicClosureSignalIdentifier) {
|
3264
|
-
(signal.prependStatements ||= []).push(
|
3265
|
-
import_compiler20.types.variableDeclaration("const", [
|
3266
|
-
import_compiler20.types.variableDeclarator(
|
3267
|
-
dynamicClosureSignalIdentifier,
|
3268
|
-
callRuntime("dynamicClosure", ...dynamicClosureArgs)
|
3269
|
-
)
|
3270
|
-
])
|
3271
|
-
);
|
3272
3251
|
}
|
3273
3252
|
}
|
3274
3253
|
if (signal.effect.length) {
|
@@ -3289,22 +3268,22 @@ function getSignalFn(signal) {
|
|
3289
3268
|
])
|
3290
3269
|
);
|
3291
3270
|
}
|
3292
|
-
if (
|
3271
|
+
if (signal.render.length === 1) {
|
3293
3272
|
const render = signal.render[0];
|
3294
3273
|
if (render.type === "ExpressionStatement") {
|
3295
3274
|
const { expression } = render;
|
3296
3275
|
if (expression.type === "CallExpression") {
|
3297
3276
|
const args = expression.arguments;
|
3298
3277
|
if (params.length >= args.length) {
|
3299
|
-
|
3278
|
+
let i = args.length;
|
3279
|
+
for (; i--; ) {
|
3300
3280
|
const param = params[i];
|
3301
3281
|
const arg = args[i];
|
3302
3282
|
if (arg.type !== "Identifier" || param.name !== arg.name) {
|
3303
|
-
canUseCalleeDirectly = false;
|
3304
3283
|
break;
|
3305
3284
|
}
|
3306
3285
|
}
|
3307
|
-
if (
|
3286
|
+
if (i === -1) {
|
3308
3287
|
return expression.callee;
|
3309
3288
|
}
|
3310
3289
|
}
|
@@ -3404,13 +3383,12 @@ function addRenderReferences(signal, referencedBindings) {
|
|
3404
3383
|
referencedBindings
|
3405
3384
|
);
|
3406
3385
|
}
|
3407
|
-
function addValue(targetSection, referencedBindings, signal, value
|
3386
|
+
function addValue(targetSection, referencedBindings, signal, value) {
|
3408
3387
|
const parentSignal = getSignal(targetSection, referencedBindings);
|
3409
3388
|
addRenderReferences(parentSignal, referencedBindings);
|
3410
3389
|
parentSignal.values.push({
|
3411
3390
|
signal,
|
3412
|
-
value
|
3413
|
-
scope
|
3391
|
+
value
|
3414
3392
|
});
|
3415
3393
|
}
|
3416
3394
|
function getResumeRegisterId(section, referencedBindings, type) {
|
@@ -3535,6 +3513,14 @@ function writeSignals(section) {
|
|
3535
3513
|
);
|
3536
3514
|
}
|
3537
3515
|
let value = signal.build();
|
3516
|
+
if (
|
3517
|
+
// It's possible for aliases to render nothing
|
3518
|
+
// if they're only consumed in effects/closures.
|
3519
|
+
// This ignores writing out those signals in that case.
|
3520
|
+
signal.referencedBindings && !Array.isArray(signal.referencedBindings) && signal.referencedBindings.upstreamAlias && !signal.referencedBindings.property && import_compiler20.types.isFunction(value) && import_compiler20.types.isBlockStatement(value.body) && !value.body.body.length
|
3521
|
+
) {
|
3522
|
+
continue;
|
3523
|
+
}
|
3538
3524
|
if (import_compiler20.types.isCallExpression(value)) {
|
3539
3525
|
replaceNullishAndEmptyFunctionsWith0(value.arguments);
|
3540
3526
|
}
|
@@ -4403,14 +4389,24 @@ function createBinding(name2, type, section, upstreamAlias, property, loc = null
|
|
4403
4389
|
function trackVarReferences(tag, type, upstreamAlias) {
|
4404
4390
|
const tagVar = tag.node.var;
|
4405
4391
|
if (tagVar) {
|
4406
|
-
const section = getOrCreateSection(tag);
|
4407
4392
|
const canonicalUpstreamAlias = getCanonicalBinding(upstreamAlias);
|
4393
|
+
if (canonicalUpstreamAlias) {
|
4394
|
+
createBindingsAndTrackReferences(
|
4395
|
+
tagVar,
|
4396
|
+
canonicalUpstreamAlias.type,
|
4397
|
+
tag.scope,
|
4398
|
+
canonicalUpstreamAlias.section,
|
4399
|
+
canonicalUpstreamAlias,
|
4400
|
+
void 0
|
4401
|
+
);
|
4402
|
+
return canonicalUpstreamAlias;
|
4403
|
+
}
|
4408
4404
|
createBindingsAndTrackReferences(
|
4409
4405
|
tagVar,
|
4410
|
-
|
4406
|
+
type,
|
4411
4407
|
tag.scope,
|
4412
|
-
|
4413
|
-
|
4408
|
+
getOrCreateSection(tag),
|
4409
|
+
void 0,
|
4414
4410
|
void 0
|
4415
4411
|
);
|
4416
4412
|
return tagVar.extra?.binding;
|
@@ -4419,13 +4415,19 @@ function trackVarReferences(tag, type, upstreamAlias) {
|
|
4419
4415
|
function trackParamsReferences(body, type, upstreamAlias) {
|
4420
4416
|
const params = body.node.params;
|
4421
4417
|
if (body.node.body.length && params.length) {
|
4422
|
-
const section = getOrCreateSection(body);
|
4423
4418
|
const canonicalUpstreamAlias = getCanonicalBinding(upstreamAlias);
|
4419
|
+
let section;
|
4420
|
+
if (canonicalUpstreamAlias) {
|
4421
|
+
section = canonicalUpstreamAlias.section;
|
4422
|
+
type = canonicalUpstreamAlias.type;
|
4423
|
+
} else {
|
4424
|
+
section = getOrCreateSection(body);
|
4425
|
+
}
|
4424
4426
|
const paramsBinding = canonicalUpstreamAlias || ((body.node.extra ??= {}).binding = createBinding(
|
4425
4427
|
generateUid("params"),
|
4426
4428
|
type,
|
4427
4429
|
section,
|
4428
|
-
|
4430
|
+
void 0,
|
4429
4431
|
void 0
|
4430
4432
|
));
|
4431
4433
|
section.params = paramsBinding;
|
@@ -4774,8 +4776,9 @@ function finalizeReferences() {
|
|
4774
4776
|
section: section2
|
4775
4777
|
} of binding.downstreamExpressions) {
|
4776
4778
|
if (section2 !== binding.section) {
|
4777
|
-
|
4778
|
-
|
4779
|
+
const canonicalUpstreamAlias = getCanonicalBinding(binding);
|
4780
|
+
canonicalUpstreamAlias.closureSections = sectionUtil.add(
|
4781
|
+
canonicalUpstreamAlias.closureSections,
|
4779
4782
|
section2
|
4780
4783
|
);
|
4781
4784
|
section2.referencedClosures = bindingUtil.add(
|
@@ -4784,8 +4787,8 @@ function finalizeReferences() {
|
|
4784
4787
|
);
|
4785
4788
|
addOwnersSerializeReason(
|
4786
4789
|
section2,
|
4787
|
-
|
4788
|
-
|
4790
|
+
canonicalUpstreamAlias.section,
|
4791
|
+
!!isEffect || canonicalUpstreamAlias.sources,
|
4789
4792
|
getAccessorProp().Owner
|
4790
4793
|
);
|
4791
4794
|
}
|
@@ -5130,18 +5133,20 @@ function getAllTagReferenceNodes(tag, referenceNodes = []) {
|
|
5130
5133
|
return referenceNodes;
|
5131
5134
|
}
|
5132
5135
|
function getScopeAccessorLiteral(binding, includeId) {
|
5136
|
+
const canonicalBinding = getCanonicalBinding(binding);
|
5133
5137
|
if (isOptimize()) {
|
5134
|
-
return import_compiler24.types.numericLiteral(
|
5138
|
+
return import_compiler24.types.numericLiteral(canonicalBinding.id);
|
5135
5139
|
}
|
5136
5140
|
return import_compiler24.types.stringLiteral(
|
5137
|
-
|
5141
|
+
canonicalBinding.name + (includeId || canonicalBinding.type === 0 /* dom */ ? `/${canonicalBinding.id}` : "")
|
5138
5142
|
);
|
5139
5143
|
}
|
5140
5144
|
function getScopeAccessor(binding, includeId) {
|
5145
|
+
const canonicalBinding = getCanonicalBinding(binding);
|
5141
5146
|
if (isOptimize()) {
|
5142
|
-
return
|
5147
|
+
return canonicalBinding.id + "";
|
5143
5148
|
}
|
5144
|
-
return
|
5149
|
+
return canonicalBinding.name + (includeId || canonicalBinding.type === 0 /* dom */ ? `/${canonicalBinding.id}` : "");
|
5145
5150
|
}
|
5146
5151
|
function getDebugScopeAccess(binding) {
|
5147
5152
|
let root = binding;
|
@@ -6786,25 +6791,6 @@ var for_default = {
|
|
6786
6791
|
import_compiler33.types.identifier(bodySection.name)
|
6787
6792
|
);
|
6788
6793
|
};
|
6789
|
-
const params = node.body.params;
|
6790
|
-
signal.hasDownstreamIntersections = () => {
|
6791
|
-
for (const param of params) {
|
6792
|
-
const binding = param.extra?.binding;
|
6793
|
-
if (binding) {
|
6794
|
-
for (const {
|
6795
|
-
referencedBindings: referencedBindings2
|
6796
|
-
} of binding.downstreamExpressions) {
|
6797
|
-
if (getSignal(
|
6798
|
-
bodySection,
|
6799
|
-
referencedBindings2
|
6800
|
-
).hasDownstreamIntersections()) {
|
6801
|
-
return true;
|
6802
|
-
}
|
6803
|
-
}
|
6804
|
-
}
|
6805
|
-
}
|
6806
|
-
return false;
|
6807
|
-
};
|
6808
6794
|
const forAttrs = getKnownAttrValues(node);
|
6809
6795
|
const loopArgs = getBaseArgsInForTag(forType, forAttrs);
|
6810
6796
|
if (forAttrs.by) {
|
@@ -9531,7 +9517,6 @@ var try_default = {
|
|
9531
9517
|
signal,
|
9532
9518
|
propsToExpression(translatedAttrs.properties)
|
9533
9519
|
);
|
9534
|
-
signal.hasDownstreamIntersections = () => true;
|
9535
9520
|
tag.remove();
|
9536
9521
|
}
|
9537
9522
|
}
|
@@ -10298,20 +10283,6 @@ function translateDOM(tag) {
|
|
10298
10283
|
tagName
|
10299
10284
|
);
|
10300
10285
|
const inputExport = childExports.input;
|
10301
|
-
if (inputExport) {
|
10302
|
-
writeAttrsToExports(tag, inputExport, `${getTagName(tag) || "tag"}_input`, {
|
10303
|
-
circular: childFile.opts.filename === file.opts.filename,
|
10304
|
-
tagSection,
|
10305
|
-
relativePath,
|
10306
|
-
childScopeBinding,
|
10307
|
-
attrTagCallsByTag: void 0
|
10308
|
-
});
|
10309
|
-
}
|
10310
|
-
write2`${(0, import_babel_utils47.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
10311
|
-
injectWalks(
|
10312
|
-
tag,
|
10313
|
-
(0, import_babel_utils47.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
10314
|
-
);
|
10315
10286
|
if (node.var) {
|
10316
10287
|
const source = initValue(
|
10317
10288
|
// TODO: support destructuring
|
@@ -10348,6 +10319,20 @@ function translateDOM(tag) {
|
|
10348
10319
|
])
|
10349
10320
|
)
|
10350
10321
|
);
|
10322
|
+
if (inputExport) {
|
10323
|
+
writeAttrsToExports(tag, inputExport, `${getTagName(tag) || "tag"}_input`, {
|
10324
|
+
circular: childFile.opts.filename === file.opts.filename,
|
10325
|
+
tagSection,
|
10326
|
+
relativePath,
|
10327
|
+
childScopeBinding,
|
10328
|
+
attrTagCallsByTag: void 0
|
10329
|
+
});
|
10330
|
+
}
|
10331
|
+
write2`${(0, import_babel_utils47.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
10332
|
+
injectWalks(
|
10333
|
+
tag,
|
10334
|
+
(0, import_babel_utils47.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
10335
|
+
);
|
10351
10336
|
tag.remove();
|
10352
10337
|
}
|
10353
10338
|
function getTagRelativePath(tag) {
|
@@ -10502,14 +10487,18 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
10502
10487
|
templateExport.id,
|
10503
10488
|
importAlias
|
10504
10489
|
);
|
10505
|
-
|
10490
|
+
addStatement(
|
10491
|
+
"render",
|
10506
10492
|
info.tagSection,
|
10507
10493
|
// technically this should be `arg.extra?.referencedBindings`
|
10508
10494
|
// but we should probably ensure all other references are dropped in this case before we do that.
|
10509
10495
|
tag.node.extra?.referencedBindings,
|
10510
|
-
|
10511
|
-
|
10512
|
-
|
10496
|
+
import_compiler56.types.expressionStatement(
|
10497
|
+
import_compiler56.types.callExpression(tagInputIdentifier, [
|
10498
|
+
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
10499
|
+
import_compiler56.types.isSpreadElement(arg) ? import_compiler56.types.memberExpression(arg.argument, import_compiler56.types.numericLiteral(0), true) : arg
|
10500
|
+
])
|
10501
|
+
)
|
10513
10502
|
);
|
10514
10503
|
return;
|
10515
10504
|
}
|
@@ -10565,12 +10554,16 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
10565
10554
|
translatedProps = callRuntime("attrTag", translatedProps);
|
10566
10555
|
}
|
10567
10556
|
}
|
10568
|
-
|
10557
|
+
addStatement(
|
10558
|
+
"render",
|
10569
10559
|
info.tagSection,
|
10570
10560
|
referencedBindings,
|
10571
|
-
|
10572
|
-
|
10573
|
-
|
10561
|
+
import_compiler56.types.expressionStatement(
|
10562
|
+
import_compiler56.types.callExpression(tagInputIdentifier, [
|
10563
|
+
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
10564
|
+
translatedProps
|
10565
|
+
])
|
10566
|
+
)
|
10574
10567
|
);
|
10575
10568
|
return;
|
10576
10569
|
}
|
@@ -10642,18 +10635,25 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
10642
10635
|
`${importAlias}_${attrTagMeta.name}`
|
10643
10636
|
);
|
10644
10637
|
decls.push(import_compiler56.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
10645
|
-
|
10638
|
+
addStatement("render", info.tagSection, referencedBindings, [
|
10639
|
+
import_compiler56.types.variableDeclaration("let", decls),
|
10640
|
+
...statements
|
10641
|
+
]);
|
10642
|
+
addStatement(
|
10643
|
+
"render",
|
10646
10644
|
info.tagSection,
|
10647
10645
|
referencedBindings,
|
10648
|
-
|
10649
|
-
|
10650
|
-
|
10646
|
+
import_compiler56.types.expressionStatement(
|
10647
|
+
import_compiler56.types.callExpression(attrExportIdentifier, [
|
10648
|
+
createScopeReadExpression(
|
10649
|
+
info.tagSection,
|
10650
|
+
info.childScopeBinding
|
10651
|
+
),
|
10652
|
+
getAttrTagIdentifier(attrTagMeta)
|
10653
|
+
])
|
10654
|
+
)
|
10651
10655
|
);
|
10652
10656
|
}
|
10653
|
-
addStatement("render", info.tagSection, referencedBindings, [
|
10654
|
-
import_compiler56.types.variableDeclaration("let", decls),
|
10655
|
-
...statements
|
10656
|
-
]);
|
10657
10657
|
}
|
10658
10658
|
}
|
10659
10659
|
const bodySection = tag.node.body.extra?.section;
|
@@ -10666,13 +10666,17 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
10666
10666
|
templateExport.props.content.id,
|
10667
10667
|
`${importAlias}_content`
|
10668
10668
|
);
|
10669
|
-
|
10669
|
+
addStatement(
|
10670
|
+
"render",
|
10670
10671
|
info.tagSection,
|
10671
10672
|
void 0,
|
10672
10673
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
10673
|
-
|
10674
|
-
|
10675
|
-
|
10674
|
+
import_compiler56.types.expressionStatement(
|
10675
|
+
import_compiler56.types.callExpression(contentExportIdentifier, [
|
10676
|
+
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
10677
|
+
import_compiler56.types.callExpression(import_compiler56.types.identifier(bodySection.name), [scopeIdentifier])
|
10678
|
+
])
|
10679
|
+
)
|
10676
10680
|
);
|
10677
10681
|
}
|
10678
10682
|
}
|
@@ -10704,12 +10708,16 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
10704
10708
|
childAttrExports.id,
|
10705
10709
|
`${importAlias}_${attr2.name}`
|
10706
10710
|
);
|
10707
|
-
|
10711
|
+
addStatement(
|
10712
|
+
"render",
|
10708
10713
|
info.tagSection,
|
10709
10714
|
attr2.value.extra?.referencedBindings,
|
10710
|
-
|
10711
|
-
|
10712
|
-
|
10715
|
+
import_compiler56.types.expressionStatement(
|
10716
|
+
import_compiler56.types.callExpression(attrExportIdentifier, [
|
10717
|
+
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
10718
|
+
attr2.value
|
10719
|
+
])
|
10720
|
+
)
|
10713
10721
|
);
|
10714
10722
|
}
|
10715
10723
|
const missing = new Set(Object.keys(templateExport.props));
|
@@ -10735,12 +10743,16 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
10735
10743
|
childAttrExports.id,
|
10736
10744
|
`${importAlias}_${name2}`
|
10737
10745
|
);
|
10738
|
-
|
10746
|
+
addStatement(
|
10747
|
+
"render",
|
10739
10748
|
info.tagSection,
|
10740
10749
|
referencedBindings,
|
10741
|
-
|
10742
|
-
|
10743
|
-
|
10750
|
+
import_compiler56.types.expressionStatement(
|
10751
|
+
import_compiler56.types.callExpression(attrExportIdentifier, [
|
10752
|
+
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
10753
|
+
getMissingPropValue(name2)
|
10754
|
+
])
|
10755
|
+
)
|
10744
10756
|
);
|
10745
10757
|
}
|
10746
10758
|
}
|
@@ -10791,18 +10803,9 @@ function callStatement(id, ...args) {
|
|
10791
10803
|
function callExpression(id, ...args) {
|
10792
10804
|
return import_compiler56.types.callExpression(id, args.filter(Boolean));
|
10793
10805
|
}
|
10794
|
-
function identifierToSignal(identifier) {
|
10795
|
-
return {
|
10796
|
-
identifier,
|
10797
|
-
hasDownstreamIntersections: always
|
10798
|
-
};
|
10799
|
-
}
|
10800
10806
|
function buildUndefined2() {
|
10801
10807
|
return import_compiler56.types.unaryExpression("void", import_compiler56.types.numericLiteral(0));
|
10802
10808
|
}
|
10803
|
-
function always() {
|
10804
|
-
return true;
|
10805
|
-
}
|
10806
10809
|
|
10807
10810
|
// src/translator/visitors/tag/dynamic-tag.ts
|
10808
10811
|
var import_compiler57 = require("@marko/compiler");
|
@@ -11031,7 +11034,6 @@ var dynamic_tag_default = {
|
|
11031
11034
|
];
|
11032
11035
|
}
|
11033
11036
|
}
|
11034
|
-
signal.hasDownstreamIntersections = () => true;
|
11035
11037
|
addValue(section, tagExtra.referencedBindings, signal, tagExpression);
|
11036
11038
|
tag.remove();
|
11037
11039
|
}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
2
|
-
import type
|
2
|
+
import { type Binding } from "./references";
|
3
3
|
export declare function getDeclaredBindingExpression(binding: Binding): t.Identifier | t.OptionalMemberExpression | t.MemberExpression;
|
@@ -11,21 +11,14 @@ export type Signal = {
|
|
11
11
|
build: () => t.Expression;
|
12
12
|
register?: boolean;
|
13
13
|
values: Array<{
|
14
|
-
signal:
|
15
|
-
identifier: t.Identifier | t.MemberExpression;
|
16
|
-
hasDownstreamIntersections: () => boolean;
|
17
|
-
buildDeclaration?: () => t.VariableDeclaration;
|
18
|
-
extraArgs?: t.Expression[];
|
19
|
-
};
|
14
|
+
signal: Signal;
|
20
15
|
value: t.Expression;
|
21
|
-
scope: t.Expression;
|
22
16
|
}>;
|
23
17
|
intersection: Opt<t.Expression>;
|
24
18
|
render: t.Statement[];
|
25
19
|
renderReferencedBindings: ReferencedBindings;
|
26
20
|
effect: t.Statement[];
|
27
21
|
effectReferencedBindings: ReferencedBindings;
|
28
|
-
hasDownstreamIntersections: () => boolean;
|
29
22
|
hasDynamicSubscribers?: true;
|
30
23
|
export: boolean;
|
31
24
|
extraArgs?: t.Expression[];
|
@@ -41,15 +34,10 @@ export declare const getHTMLSectionStatements: (section: Section) => t.Statement
|
|
41
34
|
export declare function getHoistFunctionIdentifier(hoistedBinding: Binding): t.Identifier;
|
42
35
|
export declare function getSignal(section: Section, referencedBindings: ReferencedBindings, name?: string): Signal;
|
43
36
|
export declare function initValue(binding: Binding, runtimeHelper?: "value" | "state"): Signal;
|
44
|
-
export declare function getDestructureSignal(bindingIdentifiersByName: Record<string, t.Identifier> | t.Identifier[], destructurePattern: t.LVal): {
|
45
|
-
readonly identifier: t.Identifier;
|
46
|
-
build(canCallOnlyWhenDirty?: boolean): t.ArrowFunctionExpression;
|
47
|
-
hasDownstreamIntersections(): boolean;
|
48
|
-
} | undefined;
|
49
37
|
export declare function subscribe(provider: ReferencedBindings, subscriber: Signal): void;
|
50
38
|
export declare function replaceNullishAndEmptyFunctionsWith0(args: (t.Expression | undefined | false)[]): t.Expression[];
|
51
39
|
export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], usedReferences?: ReferencedBindings[] | false): void;
|
52
|
-
export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal["values"][number]["signal"], value: t.Expression
|
40
|
+
export declare function addValue(targetSection: Section, referencedBindings: ReferencedBindings, signal: Signal["values"][number]["signal"], value: t.Expression): void;
|
53
41
|
export declare function getResumeRegisterId(section: Section, referencedBindings: string | ReferencedBindings, type?: string): string;
|
54
42
|
export declare function getRegisterUID(section: Section, name: string): string;
|
55
43
|
export declare function writeSignals(section: Section): void;
|