@marko/compiler 5.39.42 → 5.39.44
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/babel-utils.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ export interface PluginDefinition<T = any> {
|
|
|
23
23
|
path?: string;
|
|
24
24
|
hook: Plugin<T>;
|
|
25
25
|
}
|
|
26
|
+
export interface ParsePluginDefinition<T = any> {
|
|
27
|
+
path?: string;
|
|
28
|
+
hook: ParsePlugin<T>;
|
|
29
|
+
}
|
|
26
30
|
export interface TagDefinition {
|
|
27
31
|
dir: string;
|
|
28
32
|
filePath: string;
|
|
@@ -57,7 +61,7 @@ export interface TagDefinition {
|
|
|
57
61
|
openTagOnly: boolean;
|
|
58
62
|
analyzer?: PluginDefinition<t.MarkoTag>;
|
|
59
63
|
translator?: PluginDefinition<t.MarkoTag>;
|
|
60
|
-
parser?:
|
|
64
|
+
parser?: ParsePluginDefinition<t.MarkoTag>;
|
|
61
65
|
transformers?: PluginDefinition<t.MarkoTag>[];
|
|
62
66
|
migrators?: PluginDefinition<t.MarkoTag>[];
|
|
63
67
|
parseOptions?: {
|
|
@@ -127,9 +131,9 @@ export interface Tag {
|
|
|
127
131
|
openTagOnly?: boolean;
|
|
128
132
|
analyze?: Plugin<t.MarkoTag>;
|
|
129
133
|
translate?: Plugin<t.MarkoTag>;
|
|
130
|
-
parse?:
|
|
131
|
-
transform?: Plugin<t.MarkoTag>[];
|
|
132
|
-
migrate?: Plugin<t.MarkoTag>[];
|
|
134
|
+
parse?: ParsePlugin<t.MarkoTag>;
|
|
135
|
+
transform?: Plugin<t.MarkoTag> | Plugin<t.MarkoTag>[];
|
|
136
|
+
migrate?: Plugin<t.MarkoTag> | Plugin<t.MarkoTag>[];
|
|
133
137
|
parseOptions?: {
|
|
134
138
|
rootOnly?: boolean;
|
|
135
139
|
rawOpenTag?: boolean;
|
|
@@ -147,14 +151,20 @@ export type FunctionPlugin<T = any> = (
|
|
|
147
151
|
path: t.NodePath<T>,
|
|
148
152
|
types: typeof t,
|
|
149
153
|
) => void;
|
|
150
|
-
export
|
|
154
|
+
export interface EnterExitPlugin<T = any> {
|
|
151
155
|
enter?(path: t.NodePath<T>, types: typeof t): void;
|
|
152
156
|
exit?(path: t.NodePath<T>, types: typeof t): void;
|
|
153
|
-
}
|
|
157
|
+
}
|
|
154
158
|
|
|
155
|
-
export
|
|
159
|
+
export interface ModulePlugin<T = any> {
|
|
156
160
|
default: EnterExitPlugin<T> | FunctionPlugin<T>;
|
|
157
|
-
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface ModuleFunctionPlugin<T = any> {
|
|
164
|
+
default: FunctionPlugin<T>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export type ParsePlugin<T = any> = ModuleFunctionPlugin<T> | FunctionPlugin<T>;
|
|
158
168
|
|
|
159
169
|
export type Plugin<T = any> =
|
|
160
170
|
| ModulePlugin<T>
|
|
@@ -273,14 +273,10 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
if (markoOpts.stripTypes) {
|
|
277
|
-
stripTypes(file);
|
|
278
|
-
if (!isMigrate) {
|
|
279
|
-
file.path.scope.crawl();
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
276
|
if (isMigrate) {
|
|
277
|
+
if (markoOpts.stripTypes) {
|
|
278
|
+
stripTypes(file);
|
|
279
|
+
}
|
|
284
280
|
return file;
|
|
285
281
|
}
|
|
286
282
|
|
|
@@ -299,6 +295,12 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
299
295
|
}
|
|
300
296
|
traverseAll(file, rootTransformers);
|
|
301
297
|
|
|
298
|
+
if (markoOpts.stripTypes) {
|
|
299
|
+
stripTypes(file);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
file.path.scope.crawl();
|
|
303
|
+
|
|
302
304
|
for (const taglibId in taglibLookup.taglibsById) {
|
|
303
305
|
const { filePath } = taglibLookup.taglibsById[taglibId];
|
|
304
306
|
|
|
@@ -375,11 +377,39 @@ function mergeVisitors(all) {
|
|
|
375
377
|
if (all.length === 1) {
|
|
376
378
|
all = all[0];
|
|
377
379
|
} else {
|
|
378
|
-
return _traverse.default.visitors.merge(all);
|
|
380
|
+
return _traverse.default.visitors.merge(all.map(toExploded));
|
|
379
381
|
}
|
|
380
382
|
}
|
|
381
383
|
|
|
382
|
-
return
|
|
384
|
+
return toExploded(all);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const explodeCache = new WeakMap();
|
|
388
|
+
function toExploded(visitor) {
|
|
389
|
+
let cached = explodeCache.get(visitor);
|
|
390
|
+
if (!cached) {
|
|
391
|
+
cached = _traverse.default.visitors.explode(cloneVisitor(visitor));
|
|
392
|
+
explodeCache.set(visitor, cached);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return cached;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function cloneVisitor(visitor) {
|
|
399
|
+
const clone = {};
|
|
400
|
+
for (const key in visitor) {
|
|
401
|
+
clone[key] = cloneVisit(visitor[key]);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return clone;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function cloneVisit(visit) {
|
|
408
|
+
if (!visit || typeof visit !== "object") {
|
|
409
|
+
return visit;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return { ...visit };
|
|
383
413
|
}
|
|
384
414
|
|
|
385
415
|
function traverseAll(file, visitors) {
|
|
@@ -18,6 +18,7 @@ var _mergeErrors = _interopRequireDefault(require("../util/merge-errors"));funct
|
|
|
18
18
|
const noop = () => {};
|
|
19
19
|
const emptyRange = (part) => part.start === part.end;
|
|
20
20
|
const isAttrTag = (tag) => tag.name.value?.[0] === "@";
|
|
21
|
+
const isStatementTag = (tag) => tag.tagDef?.parseOptions?.statement;
|
|
21
22
|
const toBabelPosition = ({ line, character }) => ({
|
|
22
23
|
// Babel lines start at 1 and use "column" instead of "character".
|
|
23
24
|
line: line + 1,
|
|
@@ -28,6 +29,7 @@ function parseMarko(file) {
|
|
|
28
29
|
const { code } = file;
|
|
29
30
|
const { htmlParseOptions = {} } = file.markoOpts;
|
|
30
31
|
const { watchFiles } = file.metadata.marko;
|
|
32
|
+
const parseVisits = [];
|
|
31
33
|
let currentTag = file.path;
|
|
32
34
|
let currentBody = currentTag;
|
|
33
35
|
let currentAttr = undefined;
|
|
@@ -183,7 +185,7 @@ function parseMarko(file) {
|
|
|
183
185
|
}
|
|
184
186
|
break;
|
|
185
187
|
case "MarkoTag":
|
|
186
|
-
if (isAttrTag(prev)) {
|
|
188
|
+
if (isStatementTag(prev) || isAttrTag(prev)) {
|
|
187
189
|
value = value.replace(/^[\n\r]\s*/, "");
|
|
188
190
|
}
|
|
189
191
|
break;
|
|
@@ -207,7 +209,7 @@ function parseMarko(file) {
|
|
|
207
209
|
}
|
|
208
210
|
break;
|
|
209
211
|
case "MarkoTag":
|
|
210
|
-
if (isAttrTag(next)) {
|
|
212
|
+
if (isStatementTag(next) || isAttrTag(next)) {
|
|
211
213
|
value = value.replace(/[\n\r]\s*$/, "");
|
|
212
214
|
}
|
|
213
215
|
|
|
@@ -558,7 +560,7 @@ function parseMarko(file) {
|
|
|
558
560
|
if (parserPlugin) {
|
|
559
561
|
const { hook } = parserPlugin;
|
|
560
562
|
if (parserPlugin.path) watchFiles.push(parserPlugin.path);
|
|
561
|
-
(hook.default || hook
|
|
563
|
+
parseVisits.push(hook.default || hook, currentTag);
|
|
562
564
|
}
|
|
563
565
|
|
|
564
566
|
const parentTag = isAttrTag(node) ?
|
|
@@ -637,6 +639,10 @@ function parseMarko(file) {
|
|
|
637
639
|
parser.parse(code);
|
|
638
640
|
onNext();
|
|
639
641
|
|
|
642
|
+
for (let i = 0; i < parseVisits.length;) {
|
|
643
|
+
parseVisits[i++](parseVisits[i++]);
|
|
644
|
+
}
|
|
645
|
+
|
|
640
646
|
const { ast } = file;
|
|
641
647
|
const { program } = ast;
|
|
642
648
|
ast.start = program.start = 0;
|
|
@@ -19,6 +19,7 @@ const {
|
|
|
19
19
|
getBindingIdentifiers.keys.Program = ["params"];
|
|
20
20
|
getBindingIdentifiers.keys.MarkoTag = ["var"];
|
|
21
21
|
getBindingIdentifiers.keys.MarkoTagBody = ["params"];
|
|
22
|
+
getBindingIdentifiers.keys.MarkoScriptlet = ["body"];
|
|
22
23
|
|
|
23
24
|
_definitions.MARKO_TYPES.forEach((typeName) => {
|
|
24
25
|
definitionUtils.default(typeName, _definitions.default[typeName]);
|
package/dist/taglib/index.js
CHANGED
|
@@ -19,9 +19,9 @@ const registeredTaglibs = [];
|
|
|
19
19
|
const loadedTranslatorsTaglibs = new Map();
|
|
20
20
|
let lookupCache = Object.create(null);
|
|
21
21
|
|
|
22
|
-
register("
|
|
23
|
-
register("
|
|
24
|
-
register("
|
|
22
|
+
register(_markoHtml.default["taglib-id"], _markoHtml.default);
|
|
23
|
+
register(_markoSvg.default["taglib-id"], _markoSvg.default);
|
|
24
|
+
register(_markoMath.default["taglib-id"], _markoMath.default);
|
|
25
25
|
|
|
26
26
|
function buildLookup(dirname, requestedTranslator, onError) {
|
|
27
27
|
const translator = (0, _tryLoadTranslator.default)(requestedTranslator);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/compiler",
|
|
3
|
-
"version": "5.39.
|
|
3
|
+
"version": "5.39.44",
|
|
4
4
|
"description": "Marko template to JS compiler.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"babel",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"source-map-support": "^0.5.21"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"marko": "^5.
|
|
90
|
+
"marko": "^5.38.0"
|
|
91
91
|
},
|
|
92
92
|
"engines": {
|
|
93
93
|
"node": "18 || 20 || >=22"
|
package/register.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ import { Config } from ".";
|
|
|
3
3
|
type Extensions = Partial<typeof require.extensions>;
|
|
4
4
|
export default function register(
|
|
5
5
|
config: Config & { extensions?: Extensions },
|
|
6
|
-
):
|
|
6
|
+
): typeof require.extensions & {
|
|
7
|
+
".marko": (module: Module, filename: string) => any;
|
|
8
|
+
};
|