marko 6.3.20 → 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/cheatsheet.md +29 -3
- package/dist/common/accessor.d.ts +21 -75
- package/dist/common/accessor.debug.d.ts +21 -75
- package/dist/common/constants/accessor-prefix.d.ts +16 -0
- package/dist/common/constants/accessor-prefix.debug.d.ts +16 -0
- package/dist/common/constants/accessor-prop.d.ts +30 -0
- package/dist/common/constants/accessor-prop.debug.d.ts +30 -0
- package/dist/common/constants/closure-signal-prop.d.ts +6 -0
- package/dist/common/constants/closure-signal-prop.debug.d.ts +6 -0
- package/dist/common/constants/controlled-type.d.ts +9 -0
- package/dist/common/constants/keyed-scopes-prop.d.ts +4 -0
- package/dist/common/constants/keyed-scopes-prop.debug.d.ts +4 -0
- package/dist/common/constants/load-signal-value.d.ts +5 -0
- package/dist/common/constants/load-signal-value.debug.d.ts +5 -0
- package/dist/common/constants/node-type.d.ts +7 -0
- package/dist/common/constants/pending-render-prop.d.ts +9 -0
- package/dist/common/constants/pending-render-prop.debug.d.ts +9 -0
- package/dist/common/constants/renderer-prop.d.ts +12 -0
- package/dist/common/constants/renderer-prop.debug.d.ts +12 -0
- package/dist/common/constants/resume-symbol.d.ts +10 -0
- package/dist/common/constants/walk-code.d.ts +17 -0
- package/dist/common/constants/walk-range-size.d.ts +7 -0
- package/dist/common/types.d.ts +15 -45
- package/dist/debug/dom.js +291 -225
- package/dist/debug/dom.mjs +291 -225
- package/dist/debug/html.js +187 -41
- package/dist/debug/html.mjs +187 -42
- package/dist/dom/compat.d.ts +1 -1
- package/dist/dom/control-flow.d.ts +1 -1
- package/dist/dom/renderer.d.ts +2 -2
- package/dist/dom/scope.d.ts +1 -1
- package/dist/dom.js +8 -6
- package/dist/dom.mjs +8 -6
- package/dist/html/constants/char.d.ts +11 -0
- package/dist/html/constants/flush-status.d.ts +6 -0
- package/dist/html/constants/mark.d.ts +6 -0
- package/dist/html/constants/runtime-key.d.ts +7 -0
- package/dist/html/writer.d.ts +20 -23
- package/dist/html.d.ts +1 -1
- package/dist/html.js +131 -29
- package/dist/html.mjs +131 -29
- package/dist/translator/core/if.d.ts +7 -7
- package/dist/translator/core/index.d.ts +7 -7
- package/dist/translator/index.d.ts +9 -9
- package/dist/translator/index.js +245 -139
- package/dist/translator/interop/constants/feature-type.d.ts +5 -0
- package/dist/translator/interop/index.d.ts +2 -2
- package/dist/translator/util/body-to-text-literal.d.ts +2 -2
- package/dist/translator/util/constants/binding-type.d.ts +10 -0
- package/dist/translator/util/constants/compile-stage.d.ts +8 -0
- package/dist/translator/util/constants/content-type.d.ts +8 -0
- package/dist/translator/util/constants/step.d.ts +5 -0
- package/dist/translator/util/constants/tag-name-type.d.ts +7 -0
- package/dist/translator/util/is-static.d.ts +1 -1
- package/dist/translator/util/references.d.ts +9 -12
- package/dist/translator/util/sections.d.ts +4 -8
- package/dist/translator/util/signals.d.ts +1 -0
- package/dist/translator/util/tag-name-type.d.ts +4 -7
- package/dist/translator/util/walks.d.ts +4 -6
- package/dist/translator/visitors/constants/sibling-text.d.ts +7 -0
- package/dist/translator/visitors/placeholder.d.ts +2 -6
- package/dist/translator/visitors/program/index.d.ts +1 -0
- package/dist/translator/visitors/tag/constants/class-hydration.d.ts +5 -0
- package/dist/translator/visitors/tag/dynamic-tag.d.ts +2 -4
- package/package.json +16 -16
- package/tags-html.d.ts +98 -22
package/dist/translator/index.js
CHANGED
|
@@ -7,6 +7,15 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
7
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __exportAll = (all, no_symbols) => {
|
|
11
|
+
let target = {};
|
|
12
|
+
for (var name in all) __defProp(target, name, {
|
|
13
|
+
get: all[name],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
10
19
|
var __copyProps = (to, from, except, desc) => {
|
|
11
20
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
21
|
key = keys[i];
|
|
@@ -23,21 +32,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
32
|
}) : target, mod));
|
|
24
33
|
//#endregion
|
|
25
34
|
let package_json = require("../../package.json");
|
|
35
|
+
package_json = __toESM(package_json, 1);
|
|
26
36
|
let _marko_compiler = require("@marko/compiler");
|
|
27
37
|
let _marko_compiler_babel_utils = require("@marko/compiler/babel-utils");
|
|
28
38
|
let node_path = require("node:path");
|
|
29
|
-
node_path = __toESM(node_path);
|
|
39
|
+
node_path = __toESM(node_path, 1);
|
|
30
40
|
let path = require("path");
|
|
31
|
-
path = __toESM(path);
|
|
41
|
+
path = __toESM(path, 1);
|
|
32
42
|
let magic_string = require("magic-string");
|
|
33
|
-
magic_string = __toESM(magic_string);
|
|
43
|
+
magic_string = __toESM(magic_string, 1);
|
|
34
44
|
let fastest_levenshtein = require("fastest-levenshtein");
|
|
35
45
|
let _marko_compiler_internal_babel = require("@marko/compiler/internal/babel");
|
|
36
46
|
let _marko_compiler_modules = require("@marko/compiler/modules");
|
|
37
|
-
_marko_compiler_modules = __toESM(_marko_compiler_modules);
|
|
47
|
+
_marko_compiler_modules = __toESM(_marko_compiler_modules, 1);
|
|
38
48
|
//#region src/translator/util/runtime-info.ts
|
|
39
49
|
var runtime_info_default = {
|
|
40
|
-
name: package_json.name,
|
|
50
|
+
name: package_json.default.name,
|
|
41
51
|
taglibId: "marko-core"
|
|
42
52
|
};
|
|
43
53
|
//#endregion
|
|
@@ -93,53 +103,91 @@ var attrs_default = {
|
|
|
93
103
|
}]
|
|
94
104
|
};
|
|
95
105
|
//#endregion
|
|
96
|
-
//#region src/common/accessor.debug.ts
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
106
|
+
//#region src/common/constants/accessor-prefix.debug.ts
|
|
107
|
+
var accessor_prefix_debug_exports = /* @__PURE__ */ __exportAll({
|
|
108
|
+
BranchScopes: () => BranchScopes$3,
|
|
109
|
+
ClosureScopes: () => ClosureScopes$1,
|
|
110
|
+
ClosureSignalIndex: () => ClosureSignalIndex$1,
|
|
111
|
+
ConditionalRenderer: () => ConditionalRenderer$1,
|
|
112
|
+
ControlledHandler: () => ControlledHandler$1,
|
|
113
|
+
ControlledType: () => ControlledType$1,
|
|
114
|
+
ControlledValue: () => ControlledValue$1,
|
|
115
|
+
DynamicHTMLLastChild: () => DynamicHTMLLastChild$1,
|
|
116
|
+
EventAttributes: () => EventAttributes$1,
|
|
117
|
+
KeyedScopes: () => KeyedScopes$1,
|
|
118
|
+
Lifecycle: () => Lifecycle$1,
|
|
119
|
+
Promise: () => Promise$2,
|
|
120
|
+
TagVariableChange: () => TagVariableChange$3
|
|
121
|
+
});
|
|
122
|
+
const BranchScopes$3 = "BranchScopes:";
|
|
123
|
+
const ClosureScopes$1 = "ClosureScopes:";
|
|
124
|
+
const ClosureSignalIndex$1 = "ClosureSignalIndex:";
|
|
125
|
+
const ConditionalRenderer$1 = "ConditionalRenderer:";
|
|
126
|
+
const ControlledHandler$1 = "ControlledHandler:";
|
|
127
|
+
const ControlledType$1 = "ControlledType:";
|
|
128
|
+
const ControlledValue$1 = "ControlledValue:";
|
|
129
|
+
const DynamicHTMLLastChild$1 = "DynamicHTMLLastChild:";
|
|
130
|
+
const EventAttributes$1 = "EventAttributes:";
|
|
131
|
+
const KeyedScopes$1 = "KeyedScopes:";
|
|
132
|
+
const Lifecycle$1 = "Lifecycle:";
|
|
133
|
+
const Promise$2 = "Promise:";
|
|
134
|
+
const TagVariableChange$3 = "TagVariableChange:";
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/common/constants/accessor-prop.debug.ts
|
|
137
|
+
var accessor_prop_debug_exports = /* @__PURE__ */ __exportAll({
|
|
138
|
+
AbortControllers: () => AbortControllers$1,
|
|
139
|
+
AbortScopes: () => AbortScopes$1,
|
|
140
|
+
AwaitCounter: () => AwaitCounter$1,
|
|
141
|
+
BranchAccessor: () => BranchAccessor$1,
|
|
142
|
+
BranchScopes: () => BranchScopes$2,
|
|
143
|
+
CatchContent: () => CatchContent$1,
|
|
144
|
+
ClosestBranch: () => ClosestBranch$1,
|
|
145
|
+
ClosestBranchId: () => ClosestBranchId$1,
|
|
146
|
+
DetachedAwait: () => DetachedAwait$1,
|
|
147
|
+
EndNode: () => EndNode$1,
|
|
148
|
+
Gen: () => Gen$1,
|
|
149
|
+
Global: () => Global$1,
|
|
150
|
+
Id: () => "#Id",
|
|
151
|
+
Load: () => Load$1,
|
|
152
|
+
LoopIndex: () => LoopIndex$1,
|
|
153
|
+
LoopKey: () => LoopKey$1,
|
|
154
|
+
Owner: () => "_",
|
|
155
|
+
ParentBranch: () => ParentBranch$1,
|
|
156
|
+
PendingEffects: () => PendingEffects$1,
|
|
157
|
+
PendingRenders: () => PendingRenders$1,
|
|
158
|
+
PendingScopes: () => PendingScopes$1,
|
|
159
|
+
PlaceholderBranch: () => PlaceholderBranch$1,
|
|
160
|
+
PlaceholderContent: () => PlaceholderContent$1,
|
|
161
|
+
Renderer: () => Renderer$1,
|
|
162
|
+
StartNode: () => StartNode$1,
|
|
163
|
+
TagVariable: () => TagVariable$1,
|
|
164
|
+
TagVariableChange: () => TagVariableChange$2
|
|
165
|
+
});
|
|
166
|
+
const Global$1 = "$global";
|
|
167
|
+
const AbortControllers$1 = "#AbortControllers";
|
|
168
|
+
const AbortScopes$1 = "#AbortScopes";
|
|
169
|
+
const AwaitCounter$1 = "#AwaitCounter";
|
|
170
|
+
const BranchAccessor$1 = "#BranchAccessor";
|
|
171
|
+
const BranchScopes$2 = "#BranchScopes";
|
|
172
|
+
const CatchContent$1 = "#CatchContent";
|
|
173
|
+
const ClosestBranch$1 = "#ClosestBranch";
|
|
174
|
+
const ClosestBranchId$1 = "#ClosestBranchId";
|
|
175
|
+
const Gen$1 = "#Gen";
|
|
176
|
+
const DetachedAwait$1 = "#DetachedAwait";
|
|
177
|
+
const EndNode$1 = "#EndNode";
|
|
178
|
+
const Load$1 = "#Load";
|
|
179
|
+
const LoopKey$1 = "#LoopKey";
|
|
180
|
+
const LoopIndex$1 = "#LoopIndex";
|
|
181
|
+
const ParentBranch$1 = "#ParentBranch";
|
|
182
|
+
const PendingEffects$1 = "#PendingEffects";
|
|
183
|
+
const PendingRenders$1 = "#PendingRenders";
|
|
184
|
+
const PendingScopes$1 = "#PendingScopes";
|
|
185
|
+
const PlaceholderBranch$1 = "#PlaceholderBranch";
|
|
186
|
+
const PlaceholderContent$1 = "#PlaceholderContent";
|
|
187
|
+
const Renderer$1 = "#Renderer";
|
|
188
|
+
const StartNode$1 = "#StartNode";
|
|
189
|
+
const TagVariable$1 = "#TagVariable";
|
|
190
|
+
const TagVariableChange$2 = "#TagVariableChange";
|
|
143
191
|
//#endregion
|
|
144
192
|
//#region src/translator/util/evaluate.ts
|
|
145
193
|
function evaluate(value) {
|
|
@@ -335,9 +383,12 @@ function patchIteratorNext(proto) {
|
|
|
335
383
|
proto.next[kTouchedIterator] = true;
|
|
336
384
|
}
|
|
337
385
|
//#endregion
|
|
386
|
+
//#region src/translator/util/constants/compile-stage.ts
|
|
387
|
+
const translate$1 = "translate";
|
|
388
|
+
//#endregion
|
|
338
389
|
//#region src/translator/util/get-compile-stage.ts
|
|
339
390
|
function isTranslate() {
|
|
340
|
-
return getCompileStage() ===
|
|
391
|
+
return getCompileStage() === translate$1;
|
|
341
392
|
}
|
|
342
393
|
function getCompileStage() {
|
|
343
394
|
return (0, _marko_compiler_babel_utils.getFile)().___compileStage;
|
|
@@ -850,53 +901,53 @@ function joinRepeatable(compare, a, b) {
|
|
|
850
901
|
return compareResult === 0 ? a : compareResult < 0 ? [a, b] : [b, a];
|
|
851
902
|
}
|
|
852
903
|
//#endregion
|
|
853
|
-
//#region src/common/accessor.ts
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
}
|
|
904
|
+
//#region src/common/constants/accessor-prefix.ts
|
|
905
|
+
var accessor_prefix_exports = /* @__PURE__ */ __exportAll({
|
|
906
|
+
BranchScopes: () => "A",
|
|
907
|
+
ClosureScopes: () => "B",
|
|
908
|
+
ClosureSignalIndex: () => "C",
|
|
909
|
+
ConditionalRenderer: () => "D",
|
|
910
|
+
ControlledHandler: () => "E",
|
|
911
|
+
ControlledType: () => "F",
|
|
912
|
+
ControlledValue: () => "G",
|
|
913
|
+
DynamicHTMLLastChild: () => "H",
|
|
914
|
+
EventAttributes: () => "I",
|
|
915
|
+
KeyedScopes: () => "O",
|
|
916
|
+
Lifecycle: () => "K",
|
|
917
|
+
Promise: () => "L",
|
|
918
|
+
TagVariableChange: () => "M"
|
|
919
|
+
});
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region src/common/constants/accessor-prop.ts
|
|
922
|
+
var accessor_prop_exports = /* @__PURE__ */ __exportAll({
|
|
923
|
+
AbortControllers: () => "A",
|
|
924
|
+
AbortScopes: () => "B",
|
|
925
|
+
AwaitCounter: () => "O",
|
|
926
|
+
BranchAccessor: () => "C",
|
|
927
|
+
BranchScopes: () => "D",
|
|
928
|
+
CatchContent: () => "E",
|
|
929
|
+
ClosestBranch: () => "F",
|
|
930
|
+
ClosestBranchId: () => "G",
|
|
931
|
+
DetachedAwait: () => "V",
|
|
932
|
+
EndNode: () => "K",
|
|
933
|
+
Gen: () => "H",
|
|
934
|
+
Global: () => "$",
|
|
935
|
+
Id: () => "L",
|
|
936
|
+
Load: () => "X",
|
|
937
|
+
LoopIndex: () => "I",
|
|
938
|
+
LoopKey: () => "M",
|
|
939
|
+
Owner: () => "_",
|
|
940
|
+
ParentBranch: () => "N",
|
|
941
|
+
PendingEffects: () => "J",
|
|
942
|
+
PendingRenders: () => "W",
|
|
943
|
+
PendingScopes: () => "Y",
|
|
944
|
+
PlaceholderBranch: () => "P",
|
|
945
|
+
PlaceholderContent: () => "Q",
|
|
946
|
+
Renderer: () => "R",
|
|
947
|
+
StartNode: () => "S",
|
|
948
|
+
TagVariable: () => "T",
|
|
949
|
+
TagVariableChange: () => "U"
|
|
950
|
+
});
|
|
900
951
|
//#endregion
|
|
901
952
|
//#region src/translator/util/marko-config.ts
|
|
902
953
|
function isOutputHTML() {
|
|
@@ -919,10 +970,10 @@ function getReadyId(file = (0, _marko_compiler_babel_utils.getFile)()) {
|
|
|
919
970
|
//#endregion
|
|
920
971
|
//#region src/translator/util/get-accessor-char.ts
|
|
921
972
|
function getAccessorPrefix() {
|
|
922
|
-
return isOptimize() ?
|
|
973
|
+
return isOptimize() ? accessor_prefix_exports : accessor_prefix_debug_exports;
|
|
923
974
|
}
|
|
924
975
|
function getAccessorProp() {
|
|
925
|
-
return isOptimize() ?
|
|
976
|
+
return isOptimize() ? accessor_prop_exports : accessor_prop_debug_exports;
|
|
926
977
|
}
|
|
927
978
|
//#endregion
|
|
928
979
|
//#region src/translator/util/serialize-reasons.ts
|
|
@@ -1804,7 +1855,7 @@ function _script(scopeId, registryId) {
|
|
|
1804
1855
|
}
|
|
1805
1856
|
function _resume_branch(scopeId) {
|
|
1806
1857
|
const branchId = $chunk.context?.[kBranchId];
|
|
1807
|
-
if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [
|
|
1858
|
+
if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [ClosestBranchId$1]: branchId });
|
|
1808
1859
|
}
|
|
1809
1860
|
let writeScope = (scopeId, partialScope) => {
|
|
1810
1861
|
const { state } = $chunk.boundary;
|
|
@@ -1934,7 +1985,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
1934
1985
|
if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) if (isEventHandler(name)) {
|
|
1935
1986
|
if (!events) {
|
|
1936
1987
|
events = {};
|
|
1937
|
-
writeScope(scopeId, { [
|
|
1988
|
+
writeScope(scopeId, { [EventAttributes$1 + nodeAccessor]: events });
|
|
1938
1989
|
}
|
|
1939
1990
|
events[getEventHandlerName(name)] = value;
|
|
1940
1991
|
} else result += nonVoidAttr(name, value);
|
|
@@ -1945,12 +1996,12 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
1945
1996
|
}
|
|
1946
1997
|
function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1947
1998
|
writeScope(scopeId, serializeType ? {
|
|
1948
|
-
[
|
|
1949
|
-
[
|
|
1950
|
-
[
|
|
1999
|
+
[ControlledType$1 + nodeAccessor]: type,
|
|
2000
|
+
[ControlledValue$1 + nodeAccessor]: value,
|
|
2001
|
+
[ControlledHandler$1 + nodeAccessor]: valueChange
|
|
1951
2002
|
} : {
|
|
1952
|
-
[
|
|
1953
|
-
[
|
|
2003
|
+
[ControlledValue$1 + nodeAccessor]: value,
|
|
2004
|
+
[ControlledHandler$1 + nodeAccessor]: valueChange
|
|
1954
2005
|
});
|
|
1955
2006
|
}
|
|
1956
2007
|
function stringAttr(name, value) {
|
|
@@ -2021,7 +2072,7 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2021
2072
|
const childScope = getScopeById(branchId);
|
|
2022
2073
|
const needsScript = childScope && (childScope["EventAttributes:a"] || childScope["ControlledHandler:a"]);
|
|
2023
2074
|
if (needsScript) {
|
|
2024
|
-
writeScope(branchId, { [
|
|
2075
|
+
writeScope(branchId, { [Renderer$1]: renderer });
|
|
2025
2076
|
_script(branchId, "d");
|
|
2026
2077
|
}
|
|
2027
2078
|
if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
@@ -2046,7 +2097,7 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2046
2097
|
if (shouldResume) _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
|
|
2047
2098
|
}
|
|
2048
2099
|
if (rendered) {
|
|
2049
|
-
if (shouldResume) writeScope(scopeId, { [
|
|
2100
|
+
if (shouldResume) writeScope(scopeId, { [ConditionalRenderer$1 + accessor]: renderer?.["id"] || renderer });
|
|
2050
2101
|
} else _scope_id();
|
|
2051
2102
|
return result;
|
|
2052
2103
|
};
|
|
@@ -2906,6 +2957,7 @@ function getSignal(section, referencedBindings, name) {
|
|
|
2906
2957
|
renderReferencedBindings: void 0,
|
|
2907
2958
|
effect: [],
|
|
2908
2959
|
effectReferencedBindings: void 0,
|
|
2960
|
+
hasHTMLEffect: false,
|
|
2909
2961
|
build: void 0,
|
|
2910
2962
|
export: !!exportName,
|
|
2911
2963
|
hasSideEffect: !!(referencedBindings && (Array.isArray(referencedBindings) || referencedBindings.type === 0 || referencedBindings.type === 1 || referencedBindings.section !== section || referencedBindings.closureSections || referencedBindings.hoists)),
|
|
@@ -2967,7 +3019,7 @@ function initValue(binding, isLet = false) {
|
|
|
2967
3019
|
return signal;
|
|
2968
3020
|
}
|
|
2969
3021
|
function signalHasStatements(signal) {
|
|
2970
|
-
if (signal.extraArgs || signal.forcePersist || signal.render.length || signal.effect.length || signal.values.length || signal.intersection) return true;
|
|
3022
|
+
if (signal.extraArgs || signal.forcePersist || signal.render.length || signal.effect.length || signal.hasHTMLEffect || signal.values.length || signal.intersection) return true;
|
|
2971
3023
|
const binding = signal.referencedBindings;
|
|
2972
3024
|
if (binding) {
|
|
2973
3025
|
if (!Array.isArray(binding) && (binding.closureSections || binding.type === 0 || binding.section === signal.section && (binding.hoists || binding.aliases.size || hasNonConstantPropertyAlias(binding)))) return true;
|
|
@@ -3241,8 +3293,15 @@ function writeRegisteredFns() {
|
|
|
3241
3293
|
if (registeredFns) {
|
|
3242
3294
|
for (const registeredFn of registeredFns) {
|
|
3243
3295
|
let fn;
|
|
3244
|
-
if (registeredFn.referencedBindings || registeredFn.referencesScope
|
|
3245
|
-
|
|
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;
|
|
3246
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);
|
|
3247
3306
|
statements.push(fn);
|
|
3248
3307
|
}
|
|
@@ -3250,12 +3309,17 @@ function writeRegisteredFns() {
|
|
|
3250
3309
|
(0, _marko_compiler_babel_utils.getProgram)().node.body.push(...statements);
|
|
3251
3310
|
}
|
|
3252
3311
|
}
|
|
3253
|
-
function toReturnedFunction(rawFn) {
|
|
3312
|
+
function toReturnedFunction(rawFn, prologue) {
|
|
3254
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
|
+
}
|
|
3255
3318
|
return fn.type === "FunctionDeclaration" ? [fn, _marko_compiler.types.returnStatement(fn.id)] : [_marko_compiler.types.returnStatement(fn)];
|
|
3256
3319
|
}
|
|
3257
3320
|
function addHTMLEffectCall(section, referencedBindings) {
|
|
3258
|
-
|
|
3321
|
+
const signal = getSignal(section, referencedBindings);
|
|
3322
|
+
signal.hasHTMLEffect = signal.hasSideEffect = true;
|
|
3259
3323
|
}
|
|
3260
3324
|
function writeHTMLResumeStatements(path) {
|
|
3261
3325
|
const section = getSectionForBody(path);
|
|
@@ -3287,7 +3351,7 @@ function writeHTMLResumeStatements(path) {
|
|
|
3287
3351
|
}
|
|
3288
3352
|
}
|
|
3289
3353
|
});
|
|
3290
|
-
for (let i = allSignals.length; i--;) if (allSignals[i].
|
|
3354
|
+
for (let i = allSignals.length; i--;) if (allSignals[i].hasHTMLEffect) {
|
|
3291
3355
|
const signalRefs = allSignals[i].referencedBindings;
|
|
3292
3356
|
body.push(_marko_compiler.types.expressionStatement(callRuntime("_script", scopeIdIdentifier, _marko_compiler.types.stringLiteral(getResumeRegisterId(section, signalRefs)))));
|
|
3293
3357
|
}
|
|
@@ -3497,6 +3561,7 @@ function getRegisteredFnExpression$1(node) {
|
|
|
3497
3561
|
const id = extra.name;
|
|
3498
3562
|
const referencesScope = extra.referencesScope;
|
|
3499
3563
|
const referencedBindings = extra.referencedBindingsInFunction;
|
|
3564
|
+
const referencedLocals = extra.referencedLocalBindingsInFunction;
|
|
3500
3565
|
let registeredFns = registeredFnsForProgram.get((0, _marko_compiler_babel_utils.getProgram)().node);
|
|
3501
3566
|
if (!registeredFns) registeredFnsForProgram.set((0, _marko_compiler_babel_utils.getProgram)().node, registeredFns = []);
|
|
3502
3567
|
registeredFns.push({
|
|
@@ -3505,9 +3570,17 @@ function getRegisteredFnExpression$1(node) {
|
|
|
3505
3570
|
registerId: extra.registerId,
|
|
3506
3571
|
section: extra.section,
|
|
3507
3572
|
referencesScope,
|
|
3508
|
-
referencedBindings
|
|
3573
|
+
referencedBindings,
|
|
3574
|
+
referencedLocals
|
|
3509
3575
|
});
|
|
3510
|
-
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]);
|
|
3511
3584
|
else return _marko_compiler.types.identifier(id);
|
|
3512
3585
|
}
|
|
3513
3586
|
}
|
|
@@ -3702,7 +3775,17 @@ function addRegisteredDeclarations(body) {
|
|
|
3702
3775
|
}
|
|
3703
3776
|
function getRegisteredFnExpression(node) {
|
|
3704
3777
|
const { extra } = node;
|
|
3705
|
-
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
|
+
}
|
|
3706
3789
|
}
|
|
3707
3790
|
//#endregion
|
|
3708
3791
|
//#region src/translator/util/body-to-text-literal.ts
|
|
@@ -5625,6 +5708,7 @@ function buildUndefined() {
|
|
|
5625
5708
|
//#endregion
|
|
5626
5709
|
//#region src/translator/visitors/program/index.ts
|
|
5627
5710
|
let scopeIdentifier;
|
|
5711
|
+
let localsIdentifier;
|
|
5628
5712
|
var program_default = {
|
|
5629
5713
|
migrate: {
|
|
5630
5714
|
enter(program) {
|
|
@@ -5667,6 +5751,7 @@ var program_default = {
|
|
|
5667
5751
|
translate: {
|
|
5668
5752
|
enter(program) {
|
|
5669
5753
|
scopeIdentifier = isOutputDOM() ? generateUidIdentifier("scope") : null;
|
|
5754
|
+
localsIdentifier = isOutputDOM() ? generateUidIdentifier("locals") : null;
|
|
5670
5755
|
{
|
|
5671
5756
|
const markoOpts = getMarkoOpts();
|
|
5672
5757
|
const { output, entry, runtimeId } = markoOpts;
|
|
@@ -5861,7 +5946,9 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
5861
5946
|
const childScopeBinding = tagExtra[kChildScopeBinding];
|
|
5862
5947
|
if (getSerializeReason(section, childScopeBinding)) {
|
|
5863
5948
|
const peekScopeId = generateUidIdentifier(childScopeBinding?.name);
|
|
5864
|
-
|
|
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);
|
|
5865
5952
|
setBindingSerializedValue(section, childScopeBinding, callRuntime("_existing_scope", peekScopeId));
|
|
5866
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")))));
|
|
5867
5954
|
}
|
|
@@ -6552,6 +6639,17 @@ function trackReferencesForBinding(babelBinding, binding) {
|
|
|
6552
6639
|
invoked
|
|
6553
6640
|
});
|
|
6554
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
|
+
}
|
|
6555
6653
|
}
|
|
6556
6654
|
for (const ref of constantViolations) {
|
|
6557
6655
|
if (ref.type === "MarkoTag") throw ref.get("var").buildCodeFrameError(`Duplicate declaration ${JSON.stringify(binding.name)}`);
|
|
@@ -7176,6 +7274,9 @@ function getScopeAccessor(binding, encoded, includeId) {
|
|
|
7176
7274
|
else if (includeId || canonicalBinding.type === 0) return `${canonicalBinding.name}/${canonicalBinding.id}`;
|
|
7177
7275
|
return canonicalBinding.scopeAccessor ?? canonicalBinding.name;
|
|
7178
7276
|
}
|
|
7277
|
+
function getLocalsScopeAccessor(binding) {
|
|
7278
|
+
return getScopeAccessor(binding, false, true);
|
|
7279
|
+
}
|
|
7179
7280
|
function getPrefixedScopeAccessor(binding, prefix) {
|
|
7180
7281
|
const canonicalBinding = getCanonicalBinding(binding);
|
|
7181
7282
|
if (isOptimize()) switch (prefix) {
|
|
@@ -7250,6 +7351,11 @@ function getReadReplacement(node, signal) {
|
|
|
7250
7351
|
if (read.props === void 0) {
|
|
7251
7352
|
if (read.getter?.invoked) return;
|
|
7252
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
|
+
}
|
|
7253
7359
|
const inlined = getSignals(extra.section).get(readBinding)?.inline?.value;
|
|
7254
7360
|
if (inlined) replacement = _marko_compiler.types.cloneNode(inlined, true);
|
|
7255
7361
|
else if (signal?.referencedBindings === readBinding && !signal.hasSideEffect) replacement = getSignalValueIdentifier(signal);
|
|
@@ -9834,6 +9940,10 @@ function getFileNameWithLoc(fileName, { node: { loc } }) {
|
|
|
9834
9940
|
return fileName;
|
|
9835
9941
|
}
|
|
9836
9942
|
//#endregion
|
|
9943
|
+
//#region src/translator/interop/constants/feature-type.ts
|
|
9944
|
+
const Class = "class";
|
|
9945
|
+
const Tags = "tags";
|
|
9946
|
+
//#endregion
|
|
9837
9947
|
//#region src/translator/interop/feature-detection.ts
|
|
9838
9948
|
function isTagsAPI(file = (0, _marko_compiler_babel_utils.getFile)()) {
|
|
9839
9949
|
const program = file.path;
|
|
@@ -9843,11 +9953,11 @@ function isTagsAPI(file = (0, _marko_compiler_babel_utils.getFile)()) {
|
|
|
9843
9953
|
const lookup = (0, _marko_compiler_babel_utils.getTaglibLookup)(file);
|
|
9844
9954
|
const tagsDir = getTagsDir(file.opts.filename);
|
|
9845
9955
|
const state = {};
|
|
9846
|
-
if (tagsDir && !lookup.manualTagsDirs?.has(tagsDir)) addFeature(state,
|
|
9956
|
+
if (tagsDir && !lookup.manualTagsDirs?.has(tagsDir)) addFeature(state, Tags, "Template file within a tags directory", program);
|
|
9847
9957
|
scanBody(state, program.get("body"));
|
|
9848
9958
|
featureType = file.metadata.marko.api = programExtra.featureType = state.feature?.type || (lookup.exclusiveTagDiscoveryDirs === "tags" ? "tags" : "class");
|
|
9849
9959
|
}
|
|
9850
|
-
return featureType ===
|
|
9960
|
+
return featureType === Tags;
|
|
9851
9961
|
}
|
|
9852
9962
|
function getTagsDir(filename) {
|
|
9853
9963
|
const pathSeparator = /\/|\\/.exec(filename)?.[0];
|
|
@@ -9874,23 +9984,23 @@ function scanBody(state, body) {
|
|
|
9874
9984
|
scanTag(state, child);
|
|
9875
9985
|
break;
|
|
9876
9986
|
case "MarkoComment":
|
|
9877
|
-
if (/^\s*use tags\s*$/.test(child.node.value)) addFeature(state,
|
|
9878
|
-
else if (/^\s*use class\s*$/.test(child.node.value)) addFeature(state,
|
|
9987
|
+
if (/^\s*use tags\s*$/.test(child.node.value)) addFeature(state, Tags, "<!-- use tags -->", child);
|
|
9988
|
+
else if (/^\s*use class\s*$/.test(child.node.value)) addFeature(state, Class, "<!-- use class -->", child);
|
|
9879
9989
|
break;
|
|
9880
9990
|
case "MarkoScriptlet":
|
|
9881
|
-
if (!child.node.static) addFeature(state,
|
|
9991
|
+
if (!child.node.static) addFeature(state, Class, "Scriptlet", child);
|
|
9882
9992
|
break;
|
|
9883
9993
|
case "MarkoClass":
|
|
9884
|
-
addFeature(state,
|
|
9994
|
+
addFeature(state, Class, "Class block", child.get("body"));
|
|
9885
9995
|
break;
|
|
9886
9996
|
}
|
|
9887
9997
|
}
|
|
9888
9998
|
function scanTag(state, tag) {
|
|
9889
|
-
if (tag.node.var) addFeature(state,
|
|
9999
|
+
if (tag.node.var) addFeature(state, Tags, "Tag variable", tag.get("var"));
|
|
9890
10000
|
const tagDef = (0, _marko_compiler_babel_utils.getTagDef)(tag);
|
|
9891
10001
|
if (tagDef) {
|
|
9892
10002
|
if (tagDef.name === "style") {
|
|
9893
|
-
if (/^style(?:(?:\.[^.\s\\/:*?"<>|({]+)+)?\s*\{/.test(tag.node.rawValue || "")) addFeature(state,
|
|
10003
|
+
if (/^style(?:(?:\.[^.\s\\/:*?"<>|({]+)+)?\s*\{/.test(tag.node.rawValue || "")) addFeature(state, Class, `style block`, tag.get("name"));
|
|
9894
10004
|
} else if (tagDef.taglibId === runtime_info_default.taglibId) {
|
|
9895
10005
|
const feature = getFeatureTypeFromCoreTagName(tagDef.name);
|
|
9896
10006
|
if (feature) addFeature(state, feature, `<${tagDef.name}> tag`, tag.get("name"));
|
|
@@ -9899,10 +10009,10 @@ function scanTag(state, tag) {
|
|
|
9899
10009
|
if (!tagDef?.parseOptions?.rawOpenTag) {
|
|
9900
10010
|
for (const attr of tag.get("attributes")) if (attr.isMarkoAttribute()) {
|
|
9901
10011
|
if (attr.node.arguments?.length) {
|
|
9902
|
-
addFeature(state,
|
|
10012
|
+
addFeature(state, Class, "Attribute arguments", attr.get("arguments")[0]);
|
|
9903
10013
|
break;
|
|
9904
10014
|
} else if (attr.node.bound) {
|
|
9905
|
-
addFeature(state,
|
|
10015
|
+
addFeature(state, Tags, "Bound attribute", attr);
|
|
9906
10016
|
break;
|
|
9907
10017
|
}
|
|
9908
10018
|
}
|
|
@@ -9919,7 +10029,7 @@ function getFeatureTypeFromCoreTagName(tagName) {
|
|
|
9919
10029
|
case "init-components":
|
|
9920
10030
|
case "macro":
|
|
9921
10031
|
case "module-code":
|
|
9922
|
-
case "while": return
|
|
10032
|
+
case "while": return Class;
|
|
9923
10033
|
case "const":
|
|
9924
10034
|
case "debug":
|
|
9925
10035
|
case "define":
|
|
@@ -9929,7 +10039,7 @@ function getFeatureTypeFromCoreTagName(tagName) {
|
|
|
9929
10039
|
case "log":
|
|
9930
10040
|
case "return":
|
|
9931
10041
|
case "show":
|
|
9932
|
-
case "try": return
|
|
10042
|
+
case "try": return Tags;
|
|
9933
10043
|
default: return;
|
|
9934
10044
|
}
|
|
9935
10045
|
}
|
|
@@ -10115,6 +10225,7 @@ function getVisitorExit(visit) {
|
|
|
10115
10225
|
}
|
|
10116
10226
|
//#endregion
|
|
10117
10227
|
//#region src/translator/index.ts
|
|
10228
|
+
const version = package_json.default.version;
|
|
10118
10229
|
const cheatsheet = "../../cheatsheet.md";
|
|
10119
10230
|
const visitors = extractVisitors({
|
|
10120
10231
|
Program: program_default,
|
|
@@ -10151,9 +10262,4 @@ exports.tagDiscoveryDirs = tagDiscoveryDirs;
|
|
|
10151
10262
|
exports.taglibs = taglibs;
|
|
10152
10263
|
exports.transform = transform;
|
|
10153
10264
|
exports.translate = translate;
|
|
10154
|
-
|
|
10155
|
-
enumerable: true,
|
|
10156
|
-
get: function() {
|
|
10157
|
-
return package_json.version;
|
|
10158
|
-
}
|
|
10159
|
-
});
|
|
10265
|
+
exports.version = version;
|