marko 6.0.133 → 6.0.135
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/translator/index.js
CHANGED
|
@@ -1028,8 +1028,8 @@ var Sorted = class {
|
|
|
1028
1028
|
return false;
|
|
1029
1029
|
}
|
|
1030
1030
|
for (let i = subLen; i--; ) {
|
|
1031
|
-
const
|
|
1032
|
-
if (
|
|
1031
|
+
const found = findIndexSorted(this.compare, superset, subset[i]);
|
|
1032
|
+
if (found === -1 || supLen - found <= i) return false;
|
|
1033
1033
|
}
|
|
1034
1034
|
return true;
|
|
1035
1035
|
}
|
|
@@ -3460,8 +3460,16 @@ function getBindingGetterIdentifier(binding) {
|
|
|
3460
3460
|
return identifier;
|
|
3461
3461
|
}
|
|
3462
3462
|
function getSignal(section, referencedBindings, name2 = generateSignalName(referencedBindings)) {
|
|
3463
|
-
if (!Array.isArray(referencedBindings)
|
|
3464
|
-
|
|
3463
|
+
if (referencedBindings && !Array.isArray(referencedBindings)) {
|
|
3464
|
+
if (referencedBindings.type === 7 /* constant */) {
|
|
3465
|
+
return getSignal(section, void 0);
|
|
3466
|
+
}
|
|
3467
|
+
if (referencedBindings.type !== 4 /* local */ && referencedBindings.section !== section) {
|
|
3468
|
+
const canonicalReference = getCanonicalBinding(referencedBindings);
|
|
3469
|
+
if (canonicalReference !== referencedBindings) {
|
|
3470
|
+
return getSignal(section, canonicalReference);
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3465
3473
|
}
|
|
3466
3474
|
const signals = getSignals(section);
|
|
3467
3475
|
let signal = signals.get(referencedBindings);
|
|
@@ -3506,9 +3514,9 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
|
3506
3514
|
scopeOffset && getScopeAccessorLiteral(scopeOffset, true)
|
|
3507
3515
|
);
|
|
3508
3516
|
};
|
|
3509
|
-
} else if (referencedBindings.section !== section &&
|
|
3517
|
+
} else if (referencedBindings.section !== section && sectionUtil.has(referencedBindings.closureSections, section)) {
|
|
3510
3518
|
signal.build = () => {
|
|
3511
|
-
const closure =
|
|
3519
|
+
const closure = referencedBindings;
|
|
3512
3520
|
const render = getSignalFn(signal);
|
|
3513
3521
|
const closureSignalBuilder = getClosureSignalBuilder(section);
|
|
3514
3522
|
if (closureSignalBuilder && !isDynamicClosure(section, closure)) {
|
|
@@ -3690,7 +3698,7 @@ function getSignalFn(signal) {
|
|
|
3690
3698
|
)
|
|
3691
3699
|
);
|
|
3692
3700
|
});
|
|
3693
|
-
if (isValue && binding.sources
|
|
3701
|
+
if (isValue && binding.sources) {
|
|
3694
3702
|
let dynamicClosureArgs;
|
|
3695
3703
|
let dynamicClosureSignalIdentifier;
|
|
3696
3704
|
forEach(binding.closureSections, (closureSection) => {
|
|
@@ -4391,23 +4399,20 @@ function replaceAssignedNode(node) {
|
|
|
4391
4399
|
switch (node.left.type) {
|
|
4392
4400
|
case "Identifier": {
|
|
4393
4401
|
const { extra } = node.left;
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
node.operator
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
) || extra?.assignment && withLeadingComment(node.right, getDebugName(extra.assignment));
|
|
4409
|
-
}
|
|
4410
|
-
break;
|
|
4402
|
+
return isAssignedBindingExtra(extra) && getBuildAssignment(extra)?.(
|
|
4403
|
+
extra.section,
|
|
4404
|
+
node.operator === "=" ? node.right : import_compiler22.types.binaryExpression(
|
|
4405
|
+
node.operator.slice(
|
|
4406
|
+
0,
|
|
4407
|
+
-1
|
|
4408
|
+
),
|
|
4409
|
+
createScopeReadExpression(
|
|
4410
|
+
extra.assignment,
|
|
4411
|
+
extra.section
|
|
4412
|
+
),
|
|
4413
|
+
node.right
|
|
4414
|
+
)
|
|
4415
|
+
) || extra?.assignment && withLeadingComment(node.right, getDebugName(extra.assignment));
|
|
4411
4416
|
}
|
|
4412
4417
|
case "ArrayPattern":
|
|
4413
4418
|
case "ObjectPattern": {
|
|
@@ -4435,7 +4440,7 @@ function replaceAssignedNode(node) {
|
|
|
4435
4440
|
(params ||= []).push(import_compiler22.types.identifier(id.name));
|
|
4436
4441
|
}
|
|
4437
4442
|
});
|
|
4438
|
-
if (assignments) {
|
|
4443
|
+
if (assignments || params) {
|
|
4439
4444
|
const resultId = generateUid("result");
|
|
4440
4445
|
return import_compiler22.types.callExpression(
|
|
4441
4446
|
import_compiler22.types.arrowFunctionExpression(
|
|
@@ -4446,7 +4451,7 @@ function replaceAssignedNode(node) {
|
|
|
4446
4451
|
node.left,
|
|
4447
4452
|
import_compiler22.types.identifier(resultId)
|
|
4448
4453
|
),
|
|
4449
|
-
...assignments,
|
|
4454
|
+
...assignments || [],
|
|
4450
4455
|
import_compiler22.types.identifier(resultId)
|
|
4451
4456
|
])
|
|
4452
4457
|
),
|
|
@@ -8477,8 +8482,10 @@ var kIsInvoked = Symbol("hoist is invoked");
|
|
|
8477
8482
|
var kBranchSerializeReason = Symbol("branch serialize reason");
|
|
8478
8483
|
var [getBindings] = createProgramState(() => /* @__PURE__ */ new Set());
|
|
8479
8484
|
var [getNextBindingId, setNextBindingId] = createProgramState(() => 0);
|
|
8480
|
-
function createBinding(name2, type,
|
|
8485
|
+
function createBinding(name2, type, refSection, upstreamAlias, property, excludeProperties, loc = null, refDeclared = false) {
|
|
8481
8486
|
const id = getNextBindingId();
|
|
8487
|
+
const section = upstreamAlias ? upstreamAlias.section : refSection;
|
|
8488
|
+
const declared = refDeclared && refSection === section;
|
|
8482
8489
|
const binding = {
|
|
8483
8490
|
id,
|
|
8484
8491
|
name: name2,
|
|
@@ -8573,6 +8580,7 @@ function trackDomVarReferences(tag, binding) {
|
|
|
8573
8580
|
function trackVarReferences(tag, type, upstreamAlias) {
|
|
8574
8581
|
const tagVar = tag.node.var;
|
|
8575
8582
|
if (tagVar) {
|
|
8583
|
+
const section = getOrCreateSection(tag);
|
|
8576
8584
|
let canonicalUpstreamAlias = upstreamAlias && getCanonicalBinding(upstreamAlias);
|
|
8577
8585
|
if (canonicalUpstreamAlias) {
|
|
8578
8586
|
const { excludeProperties } = canonicalUpstreamAlias;
|
|
@@ -8583,7 +8591,7 @@ function trackVarReferences(tag, type, upstreamAlias) {
|
|
|
8583
8591
|
tagVar,
|
|
8584
8592
|
canonicalUpstreamAlias.type,
|
|
8585
8593
|
tag.scope,
|
|
8586
|
-
|
|
8594
|
+
section,
|
|
8587
8595
|
canonicalUpstreamAlias,
|
|
8588
8596
|
void 0,
|
|
8589
8597
|
excludeProperties
|
|
@@ -8594,7 +8602,7 @@ function trackVarReferences(tag, type, upstreamAlias) {
|
|
|
8594
8602
|
tagVar,
|
|
8595
8603
|
type,
|
|
8596
8604
|
tag.scope,
|
|
8597
|
-
|
|
8605
|
+
section,
|
|
8598
8606
|
void 0,
|
|
8599
8607
|
void 0,
|
|
8600
8608
|
void 0
|
|
@@ -9038,20 +9046,20 @@ function finalizeReferences() {
|
|
|
9038
9046
|
);
|
|
9039
9047
|
for (const { isEffect, section: section2 } of binding.reads) {
|
|
9040
9048
|
if (section2 !== binding.section) {
|
|
9041
|
-
const canonicalUpstreamAlias = getCanonicalBinding(binding);
|
|
9042
|
-
canonicalUpstreamAlias.closureSections = sectionUtil.add(
|
|
9043
|
-
canonicalUpstreamAlias.closureSections,
|
|
9044
|
-
section2
|
|
9045
|
-
);
|
|
9046
9049
|
if (binding.type === 4 /* local */) {
|
|
9047
9050
|
section2.referencedLocalClosures = bindingUtil.add(
|
|
9048
9051
|
section2.referencedLocalClosures,
|
|
9049
9052
|
binding
|
|
9050
9053
|
);
|
|
9051
9054
|
} else {
|
|
9055
|
+
const canonicalUpstreamAlias = getCanonicalBinding(binding);
|
|
9056
|
+
canonicalUpstreamAlias.closureSections = sectionUtil.add(
|
|
9057
|
+
canonicalUpstreamAlias.closureSections,
|
|
9058
|
+
section2
|
|
9059
|
+
);
|
|
9052
9060
|
section2.referencedClosures = bindingUtil.add(
|
|
9053
9061
|
section2.referencedClosures,
|
|
9054
|
-
|
|
9062
|
+
canonicalUpstreamAlias
|
|
9055
9063
|
);
|
|
9056
9064
|
addOwnerSerializeReason(
|
|
9057
9065
|
section2,
|
|
@@ -10286,12 +10294,13 @@ var define_default = {
|
|
|
10286
10294
|
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
10287
10295
|
return;
|
|
10288
10296
|
}
|
|
10289
|
-
trackParamsReferences(tagBody, 3 /* param */);
|
|
10297
|
+
const paramsBinding = trackParamsReferences(tagBody, 3 /* param */);
|
|
10290
10298
|
setTagDownstream(tag, varBinding);
|
|
10291
10299
|
if (bodySection) {
|
|
10292
10300
|
if (import_compiler43.types.isIdentifier(tag.node.var)) {
|
|
10293
10301
|
const babelBinding = tag.scope.getBinding(tag.node.var.name);
|
|
10294
10302
|
let allDirectReferences = true;
|
|
10303
|
+
let allHaveInput = true;
|
|
10295
10304
|
for (const ref of babelBinding.referencePaths) {
|
|
10296
10305
|
if (isReferenceHoisted(babelBinding.path, ref)) {
|
|
10297
10306
|
throw ref.buildCodeFrameError(
|
|
@@ -10300,12 +10309,18 @@ var define_default = {
|
|
|
10300
10309
|
}
|
|
10301
10310
|
if (ref.parent.type === "MarkoTag" && ref.parent.name === ref.node) {
|
|
10302
10311
|
(ref.parent.extra ??= {}).defineBodySection = bodySection;
|
|
10312
|
+
allHaveInput &&= !ref.parent.arguments?.length;
|
|
10303
10313
|
dropNodes(ref.parent.name);
|
|
10304
10314
|
} else {
|
|
10315
|
+
allHaveInput = false;
|
|
10305
10316
|
allDirectReferences = false;
|
|
10306
10317
|
}
|
|
10307
10318
|
}
|
|
10308
10319
|
if (allDirectReferences) {
|
|
10320
|
+
const inputAlias = allHaveInput && paramsBinding?.propertyAliases.get("0");
|
|
10321
|
+
if (inputAlias) {
|
|
10322
|
+
inputAlias.nullable = false;
|
|
10323
|
+
}
|
|
10309
10324
|
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
10310
10325
|
return;
|
|
10311
10326
|
}
|
|
@@ -90,7 +90,7 @@ declare module "@marko/compiler/dist/types" {
|
|
|
90
90
|
interface FunctionExpressionExtra extends FunctionExtra {
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
export declare function createBinding(name: string, type: Binding["type"],
|
|
93
|
+
export declare function createBinding(name: string, type: Binding["type"], refSection: Section, upstreamAlias?: Binding["upstreamAlias"], property?: string, excludeProperties?: Opt<string>, loc?: t.SourceLocation | null, refDeclared?: boolean): Binding;
|
|
94
94
|
export declare function getOrCreatePropertyAlias(binding: Binding, property: string): Binding;
|
|
95
95
|
export declare function trackDomVarReferences(tag: t.NodePath<t.MarkoTag>, binding: Binding): Binding | undefined;
|
|
96
96
|
export declare function trackVarReferences(tag: t.NodePath<t.MarkoTag>, type: BindingType, upstreamAlias?: Binding["upstreamAlias"]): Binding | undefined;
|