marko 6.0.94 → 6.0.95
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
|
@@ -4207,7 +4207,7 @@ function replaceAssignedNode(node) {
|
|
|
4207
4207
|
return getBuildAssignment(extra)?.(
|
|
4208
4208
|
extra.section,
|
|
4209
4209
|
bindingUtil.has(
|
|
4210
|
-
extra.
|
|
4210
|
+
extra.assignmentFunction.referencedBindingsInFunction,
|
|
4211
4211
|
extra.assignment
|
|
4212
4212
|
) ? node : node.operator === "=" ? node.right : import_compiler22.types.binaryExpression(
|
|
4213
4213
|
node.operator.slice(
|
|
@@ -4237,7 +4237,7 @@ function replaceAssignedNode(node) {
|
|
|
4237
4237
|
);
|
|
4238
4238
|
if (builtAssignment) {
|
|
4239
4239
|
if (!bindingUtil.has(
|
|
4240
|
-
extra.
|
|
4240
|
+
extra.assignmentFunction.referencedBindingsInFunction,
|
|
4241
4241
|
extra.assignment
|
|
4242
4242
|
)) {
|
|
4243
4243
|
id.name = uid;
|
|
@@ -7992,12 +7992,24 @@ function trackReferencesForBinding(babelBinding, binding) {
|
|
|
7992
7992
|
}
|
|
7993
7993
|
function trackAssignment(assignment, binding) {
|
|
7994
7994
|
const fnRoot = getFnRoot(assignment);
|
|
7995
|
-
const fnExtra = fnRoot && (fnRoot.node.extra ??= {});
|
|
7996
7995
|
const section = getOrCreateSection(assignment);
|
|
7997
7996
|
setReferencesScope(assignment);
|
|
7998
7997
|
forEachIdentifierPath(assignment, (id) => {
|
|
7999
7998
|
if (id.node.name === binding.name) {
|
|
8000
|
-
|
|
7999
|
+
if (!fnRoot) {
|
|
8000
|
+
throw id.buildCodeFrameError(
|
|
8001
|
+
`Assignments to a tag ${binding.type === 3 /* param */ ? "parameter" : "variable"} must be within a script or function.`
|
|
8002
|
+
);
|
|
8003
|
+
}
|
|
8004
|
+
const fnExtra = fnRoot && (fnRoot.node.extra ??= {});
|
|
8005
|
+
const idExtra = id.node.extra ??= {};
|
|
8006
|
+
idExtra.assignment = binding;
|
|
8007
|
+
idExtra.assignmentFunction = fnExtra;
|
|
8008
|
+
fnExtra.section = idExtra.section = section;
|
|
8009
|
+
binding.assignmentSections = sectionUtil.add(
|
|
8010
|
+
binding.assignmentSections,
|
|
8011
|
+
section
|
|
8012
|
+
);
|
|
8001
8013
|
if (binding.upstreamAlias && binding.property !== void 0) {
|
|
8002
8014
|
const changePropName = binding.property + "Change";
|
|
8003
8015
|
const changeBinding = binding.upstreamAlias.propertyAliases.get(changePropName) || createBinding(
|
|
@@ -8010,16 +8022,9 @@ function trackAssignment(assignment, binding) {
|
|
|
8010
8022
|
id.node.loc,
|
|
8011
8023
|
true
|
|
8012
8024
|
);
|
|
8013
|
-
|
|
8025
|
+
idExtra.assignmentTo = changeBinding;
|
|
8014
8026
|
addReadToExpression(id, changeBinding);
|
|
8015
8027
|
}
|
|
8016
|
-
binding.assignmentSections = sectionUtil.add(
|
|
8017
|
-
binding.assignmentSections,
|
|
8018
|
-
section
|
|
8019
|
-
);
|
|
8020
|
-
extra.assignment = binding;
|
|
8021
|
-
extra.section = section;
|
|
8022
|
-
extra.fnExtra = fnExtra;
|
|
8023
8028
|
}
|
|
8024
8029
|
});
|
|
8025
8030
|
}
|
|
@@ -8199,12 +8204,13 @@ function compareIntersections(a, b) {
|
|
|
8199
8204
|
function finalizeReferences() {
|
|
8200
8205
|
const bindings = getBindings();
|
|
8201
8206
|
const readsByExpression = getReadsByExpression();
|
|
8202
|
-
const
|
|
8207
|
+
const fnReadsByExpression = getFunctionReadsByExpression();
|
|
8203
8208
|
const mergedReferences = getMergedReferences();
|
|
8204
8209
|
if (mergedReferences.size) {
|
|
8205
8210
|
for (const [target, nodes] of mergedReferences) {
|
|
8206
8211
|
const targetExtra = target.extra;
|
|
8207
8212
|
let reads = readsByExpression.get(targetExtra);
|
|
8213
|
+
let exprFnReads = fnReadsByExpression.get(targetExtra);
|
|
8208
8214
|
let { isEffect } = targetExtra;
|
|
8209
8215
|
for (const node of nodes) {
|
|
8210
8216
|
const extra = node?.extra;
|
|
@@ -8212,11 +8218,24 @@ function finalizeReferences() {
|
|
|
8212
8218
|
setCanonicalExtra(extra, targetExtra);
|
|
8213
8219
|
if (isReferencedExtra(extra)) {
|
|
8214
8220
|
const additionalReads = readsByExpression.get(extra);
|
|
8221
|
+
const additionalExprFnReads = fnReadsByExpression.get(extra);
|
|
8215
8222
|
isEffect ||= extra.isEffect;
|
|
8216
8223
|
if (additionalReads) {
|
|
8217
8224
|
reads = concat(reads, additionalReads);
|
|
8218
8225
|
readsByExpression.delete(extra);
|
|
8219
8226
|
}
|
|
8227
|
+
if (additionalExprFnReads) {
|
|
8228
|
+
if (exprFnReads) {
|
|
8229
|
+
for (const [key, value] of additionalExprFnReads) {
|
|
8230
|
+
exprFnReads.set(key, value);
|
|
8231
|
+
}
|
|
8232
|
+
} else {
|
|
8233
|
+
fnReadsByExpression.set(
|
|
8234
|
+
targetExtra,
|
|
8235
|
+
exprFnReads = new Map(additionalExprFnReads)
|
|
8236
|
+
);
|
|
8237
|
+
}
|
|
8238
|
+
}
|
|
8220
8239
|
}
|
|
8221
8240
|
}
|
|
8222
8241
|
}
|
|
@@ -8227,14 +8246,25 @@ function finalizeReferences() {
|
|
|
8227
8246
|
const intersectionsBySection = /* @__PURE__ */ new Map();
|
|
8228
8247
|
for (const [expr, reads] of readsByExpression) {
|
|
8229
8248
|
if (isReferencedExtra(expr)) {
|
|
8230
|
-
expr.referencedBindings = resolveReferencedBindings(
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8249
|
+
const referencedBindings = expr.referencedBindings = resolveReferencedBindings(expr, reads, intersectionsBySection);
|
|
8250
|
+
if (referencedBindings) {
|
|
8251
|
+
forEach(referencedBindings, (binding) => {
|
|
8252
|
+
binding.downstreamExpressions.add(expr);
|
|
8253
|
+
});
|
|
8254
|
+
const exprFnReads = fnReadsByExpression.get(expr);
|
|
8255
|
+
if (exprFnReads) {
|
|
8256
|
+
for (const [fn, fnReads] of exprFnReads) {
|
|
8257
|
+
if (fn === expr) {
|
|
8258
|
+
expr.referencedBindingsInFunction = referencedBindings;
|
|
8259
|
+
} else {
|
|
8260
|
+
fn.referencedBindingsInFunction = resolveReferencedBindingsInFunction(
|
|
8261
|
+
referencedBindings,
|
|
8262
|
+
fnReads
|
|
8263
|
+
);
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8266
|
+
}
|
|
8267
|
+
}
|
|
8238
8268
|
}
|
|
8239
8269
|
}
|
|
8240
8270
|
for (const binding of bindings) {
|
|
@@ -8404,20 +8434,29 @@ function finalizeReferences() {
|
|
|
8404
8434
|
});
|
|
8405
8435
|
});
|
|
8406
8436
|
finalizeFunctionRegistry();
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
if (
|
|
8418
|
-
|
|
8437
|
+
const referencedExprs = /* @__PURE__ */ new Set();
|
|
8438
|
+
for (const binding of bindings) {
|
|
8439
|
+
for (const expr of binding.downstreamExpressions) {
|
|
8440
|
+
referencedExprs.add(expr);
|
|
8441
|
+
}
|
|
8442
|
+
}
|
|
8443
|
+
for (const expr of referencedExprs) {
|
|
8444
|
+
const exprFnReads = fnReadsByExpression.get(expr);
|
|
8445
|
+
if (exprFnReads) {
|
|
8446
|
+
for (const fn of exprFnReads.keys()) {
|
|
8447
|
+
if (fn.registerReason) {
|
|
8448
|
+
forEach(fn.referencedBindingsInFunction, (binding) => {
|
|
8449
|
+
addSerializeReason(binding.section, fn.registerReason, binding);
|
|
8450
|
+
if (binding.section !== fn.section) {
|
|
8451
|
+
addOwnerSerializeReason(
|
|
8452
|
+
fn.section,
|
|
8453
|
+
binding.section,
|
|
8454
|
+
fn.registerReason
|
|
8455
|
+
);
|
|
8456
|
+
}
|
|
8457
|
+
});
|
|
8419
8458
|
}
|
|
8420
|
-
}
|
|
8459
|
+
}
|
|
8421
8460
|
}
|
|
8422
8461
|
}
|
|
8423
8462
|
forEachSectionReverse((section) => {
|
|
@@ -8458,7 +8497,7 @@ function finalizeReferences() {
|
|
|
8458
8497
|
}
|
|
8459
8498
|
mergedReferences.clear();
|
|
8460
8499
|
readsByExpression.clear();
|
|
8461
|
-
|
|
8500
|
+
fnReadsByExpression.clear();
|
|
8462
8501
|
}
|
|
8463
8502
|
function getMaxOwnSourceOffset(intersection, section) {
|
|
8464
8503
|
let scopeOffset;
|
|
@@ -8612,7 +8651,7 @@ var propsUtil = new Sorted(function compareProps(a, b) {
|
|
|
8612
8651
|
var [getReadsByExpression] = createProgramState(
|
|
8613
8652
|
() => /* @__PURE__ */ new Map()
|
|
8614
8653
|
);
|
|
8615
|
-
var [
|
|
8654
|
+
var [getFunctionReadsByExpression] = createProgramState(
|
|
8616
8655
|
() => /* @__PURE__ */ new Map()
|
|
8617
8656
|
);
|
|
8618
8657
|
function addReadToExpression(root, binding) {
|
|
@@ -8628,11 +8667,14 @@ function addReadToExpression(root, binding) {
|
|
|
8628
8667
|
push(readsByExpression.get(exprExtra), read)
|
|
8629
8668
|
);
|
|
8630
8669
|
if (fnRoot) {
|
|
8631
|
-
const
|
|
8670
|
+
const fnReadsByExpr = getFunctionReadsByExpression();
|
|
8671
|
+
let exprFnReads = fnReadsByExpr.get(exprExtra);
|
|
8672
|
+
if (!exprFnReads) {
|
|
8673
|
+
fnReadsByExpr.set(exprExtra, exprFnReads = /* @__PURE__ */ new Map());
|
|
8674
|
+
}
|
|
8632
8675
|
const fnExtra = fnRoot.node.extra ??= {};
|
|
8633
|
-
exprExtra.fnExtra = fnExtra;
|
|
8634
8676
|
fnExtra.section = section;
|
|
8635
|
-
|
|
8677
|
+
exprFnReads.set(fnExtra, push(exprFnReads.get(fnExtra), read));
|
|
8636
8678
|
}
|
|
8637
8679
|
}
|
|
8638
8680
|
function dropReferences(node) {
|
|
@@ -8804,6 +8846,45 @@ function pruneBinding(bindings, binding) {
|
|
|
8804
8846
|
}
|
|
8805
8847
|
return shouldPrune;
|
|
8806
8848
|
}
|
|
8849
|
+
function resolveReferencedBindingsInFunction(refs, reads) {
|
|
8850
|
+
if (reads) {
|
|
8851
|
+
if (Array.isArray(reads)) {
|
|
8852
|
+
let referencedBindings;
|
|
8853
|
+
for (const read of reads) {
|
|
8854
|
+
referencedBindings = bindingUtil.add(
|
|
8855
|
+
referencedBindings,
|
|
8856
|
+
findClosestReference(read.binding, refs)
|
|
8857
|
+
);
|
|
8858
|
+
}
|
|
8859
|
+
return referencedBindings;
|
|
8860
|
+
} else {
|
|
8861
|
+
return findClosestReference(reads.binding, refs);
|
|
8862
|
+
}
|
|
8863
|
+
}
|
|
8864
|
+
}
|
|
8865
|
+
function findClosestReference(from, refs) {
|
|
8866
|
+
if (Array.isArray(refs)) {
|
|
8867
|
+
if (bindingUtil.has(refs, from)) {
|
|
8868
|
+
return from;
|
|
8869
|
+
}
|
|
8870
|
+
for (const ref of refs) {
|
|
8871
|
+
const closest = findClosestUpstream(from, ref);
|
|
8872
|
+
if (closest) return closest;
|
|
8873
|
+
}
|
|
8874
|
+
} else {
|
|
8875
|
+
const closest = findClosestUpstream(from, refs);
|
|
8876
|
+
if (closest) return closest;
|
|
8877
|
+
}
|
|
8878
|
+
throw new Error("Unable to resolve closest binding reference.");
|
|
8879
|
+
}
|
|
8880
|
+
function findClosestUpstream(from, to) {
|
|
8881
|
+
let closest = from;
|
|
8882
|
+
do {
|
|
8883
|
+
if (closest === to) {
|
|
8884
|
+
return closest;
|
|
8885
|
+
}
|
|
8886
|
+
} while (closest = closest.upstreamAlias);
|
|
8887
|
+
}
|
|
8807
8888
|
function resolveReferencedBindings(expr, reads, intersectionsBySection) {
|
|
8808
8889
|
let referencedBindings;
|
|
8809
8890
|
if (Array.isArray(reads)) {
|
|
@@ -49,9 +49,8 @@ export interface ParamBinding extends Binding {
|
|
|
49
49
|
}
|
|
50
50
|
export type ReferencedBindings = Opt<Binding>;
|
|
51
51
|
export type Intersection = Many<Binding>;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
52
|
+
interface ReferencedFunctionExtra extends t.FunctionExtra, ReferencedExtra {
|
|
53
|
+
}
|
|
55
54
|
declare module "@marko/compiler/dist/types" {
|
|
56
55
|
interface NodeExtra {
|
|
57
56
|
section?: Section;
|
|
@@ -69,7 +68,11 @@ declare module "@marko/compiler/dist/types" {
|
|
|
69
68
|
[kIsInvoked]?: true;
|
|
70
69
|
}
|
|
71
70
|
interface FunctionExtra {
|
|
71
|
+
referencesScope?: boolean;
|
|
72
72
|
referencedBindingsInFunction?: ReferencedBindings;
|
|
73
|
+
name?: string;
|
|
74
|
+
registerId?: string;
|
|
75
|
+
registerReason?: SerializeReason;
|
|
73
76
|
}
|
|
74
77
|
interface ArrowFunctionExpressionExtra extends FunctionExtra {
|
|
75
78
|
}
|
|
@@ -112,19 +115,17 @@ export declare function getSectionInstancesAccessorLiteral(section: Section): t.
|
|
|
112
115
|
export declare function getReadReplacement(node: t.Identifier | t.MemberExpression | t.OptionalMemberExpression): t.Node | undefined;
|
|
113
116
|
export interface ReferencedExtra extends t.NodeExtra {
|
|
114
117
|
section: Section;
|
|
115
|
-
fnExtra?: FnExtra;
|
|
116
118
|
}
|
|
117
119
|
export declare function isReferencedExtra(extra: t.NodeExtra | undefined): extra is ReferencedExtra;
|
|
118
120
|
export interface AssignedBindingExtra extends ReferencedExtra {
|
|
119
121
|
assignment: Binding;
|
|
122
|
+
assignmentFunction: ReferencedFunctionExtra;
|
|
120
123
|
}
|
|
121
124
|
export declare function isAssignedBindingExtra(extra: t.NodeExtra | undefined): extra is AssignedBindingExtra;
|
|
122
|
-
export interface RegisteredFnExtra extends ReferencedExtra {
|
|
125
|
+
export interface RegisteredFnExtra extends ReferencedExtra, t.FunctionExtra {
|
|
126
|
+
name: string;
|
|
123
127
|
registerId: string;
|
|
124
128
|
registerReason: SerializeReason;
|
|
125
|
-
name: string;
|
|
126
|
-
referencesScope?: boolean;
|
|
127
|
-
referencedBindingsInFunction: ReferencedBindings;
|
|
128
129
|
}
|
|
129
130
|
export declare function isRegisteredFnExtra(extra: t.NodeExtra | undefined): extra is RegisteredFnExtra;
|
|
130
131
|
export declare function getCanonicalExtra<T extends t.NodeExtra>(extra: T): T;
|
|
@@ -1,22 +1,4 @@
|
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
|
2
|
-
import { type SerializeReason } from "../util/serialize-reasons";
|
|
3
|
-
declare module "@marko/compiler/dist/types" {
|
|
4
|
-
interface FunctionDeclarationExtra {
|
|
5
|
-
registerId?: string;
|
|
6
|
-
registerReason?: SerializeReason;
|
|
7
|
-
name?: string;
|
|
8
|
-
}
|
|
9
|
-
interface FunctionExpressionExtra {
|
|
10
|
-
registerId?: string;
|
|
11
|
-
registerReason?: SerializeReason;
|
|
12
|
-
name?: string;
|
|
13
|
-
}
|
|
14
|
-
interface ArrowFunctionExpressionExtra {
|
|
15
|
-
registerId?: string;
|
|
16
|
-
registerReason?: SerializeReason;
|
|
17
|
-
name?: string;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
2
|
declare const _default: {
|
|
21
3
|
analyze(this: unknown, fn: t.NodePath<t.Function>): void;
|
|
22
4
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marko",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.95",
|
|
4
4
|
"description": "Optimized runtime for Marko templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"build": "node -r ~ts ./scripts/bundle.ts"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@marko/compiler": "^5.39.
|
|
51
|
+
"@marko/compiler": "^5.39.41",
|
|
52
52
|
"csstype": "^3.1.3",
|
|
53
53
|
"magic-string": "^0.30.17"
|
|
54
54
|
},
|