@marko/language-tools 2.2.1 → 2.2.3
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/index.js +33 -29
- package/dist/index.mjs +33 -29
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1538,7 +1538,7 @@ function getComponentFilename(from) {
|
|
|
1538
1538
|
nameNoExt = nameNoExt.slice(0, -2);
|
|
1539
1539
|
}
|
|
1540
1540
|
const isEntry = nameNoExt === "index";
|
|
1541
|
-
const fileMatch = `(${nameNoExt.replace(
|
|
1541
|
+
const fileMatch = `(${nameNoExt.replace(/[.*+?^$[\]()|\\:!{}]/g, "\\$&")}\\.${isEntry ? "|" : ""})`;
|
|
1542
1542
|
const componentMatch = new RegExp(
|
|
1543
1543
|
`^${fileMatch}component(-browser)?\\.\\w+$`
|
|
1544
1544
|
);
|
|
@@ -2320,39 +2320,43 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2320
2320
|
break;
|
|
2321
2321
|
}
|
|
2322
2322
|
} else if (attr.args) {
|
|
2323
|
-
const stringLiteralFirstArgMatch = this.#execAtIndex(
|
|
2324
|
-
REG_ATTR_ARG_LITERAL,
|
|
2325
|
-
attr.args.value.start
|
|
2326
|
-
);
|
|
2327
2323
|
this.#extractor.write('"').copy(name).write('": ');
|
|
2328
|
-
if (
|
|
2329
|
-
const
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
const isValidProperty = REG_OBJECT_PROPERTY.test(
|
|
2333
|
-
stringLiteralFirstArgMatch[2]
|
|
2324
|
+
if (typeof name !== "string" && this.#read(name).startsWith("on")) {
|
|
2325
|
+
const stringLiteralFirstArgMatch = this.#execAtIndex(
|
|
2326
|
+
REG_ATTR_ARG_LITERAL,
|
|
2327
|
+
attr.args.value.start
|
|
2334
2328
|
);
|
|
2335
|
-
if (
|
|
2336
|
-
const
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2329
|
+
if (stringLiteralFirstArgMatch) {
|
|
2330
|
+
const hasPartialArgs = stringLiteralFirstArgMatch[3] === ",";
|
|
2331
|
+
const stringLiteralValue = stringLiteralFirstArgMatch[2];
|
|
2332
|
+
const stringLiteralStart = stringLiteralFirstArgMatch.index;
|
|
2333
|
+
const isValidProperty = REG_OBJECT_PROPERTY.test(
|
|
2334
|
+
stringLiteralFirstArgMatch[2]
|
|
2335
|
+
);
|
|
2336
|
+
if (isValidProperty) {
|
|
2337
|
+
const propertNameStart = stringLiteralStart + 1;
|
|
2338
|
+
this.#extractor.write("component.").copy({
|
|
2339
|
+
start: propertNameStart,
|
|
2340
|
+
end: propertNameStart + stringLiteralValue.length
|
|
2341
|
+
});
|
|
2342
|
+
} else {
|
|
2343
|
+
this.#extractor.write(`component[`).copy({
|
|
2344
|
+
start: stringLiteralStart,
|
|
2345
|
+
end: stringLiteralStart + stringLiteralValue.length + 2
|
|
2346
|
+
}).write("]");
|
|
2347
|
+
}
|
|
2348
|
+
if (hasPartialArgs) {
|
|
2349
|
+
this.#extractor.write(`.bind(component, `).copy({
|
|
2350
|
+
start: stringLiteralStart + stringLiteralFirstArgMatch[0].length,
|
|
2351
|
+
end: attr.args.value.end
|
|
2352
|
+
}).write(")");
|
|
2353
|
+
}
|
|
2341
2354
|
} else {
|
|
2342
|
-
this.#extractor.write(
|
|
2343
|
-
|
|
2344
|
-
end: stringLiteralStart + stringLiteralValue.length + 2
|
|
2345
|
-
}).write("]");
|
|
2346
|
-
}
|
|
2347
|
-
if (hasPartialArgs) {
|
|
2348
|
-
this.#extractor.write(`.bind(component, `).copy({
|
|
2349
|
-
start: stringLiteralStart + stringLiteralFirstArgMatch[0].length,
|
|
2350
|
-
end: attr.args.value.end
|
|
2351
|
-
}).write(")");
|
|
2355
|
+
this.#extractor.write(`${varShared("bind")}(component,
|
|
2356
|
+
`).copy(attr.args.value).write("\n)");
|
|
2352
2357
|
}
|
|
2353
2358
|
} else {
|
|
2354
|
-
this.#extractor.
|
|
2355
|
-
`).copy(attr.args.value).write("\n)");
|
|
2359
|
+
this.#extractor.copy(attr.args);
|
|
2356
2360
|
}
|
|
2357
2361
|
} else {
|
|
2358
2362
|
this.#extractor.write('"').copy(defaultMapPosition).copy(name).write(`": ${modifierIndex === false ? "true" : '""'}`);
|
package/dist/index.mjs
CHANGED
|
@@ -1506,7 +1506,7 @@ function getComponentFilename(from) {
|
|
|
1506
1506
|
nameNoExt = nameNoExt.slice(0, -2);
|
|
1507
1507
|
}
|
|
1508
1508
|
const isEntry = nameNoExt === "index";
|
|
1509
|
-
const fileMatch = `(${nameNoExt.replace(
|
|
1509
|
+
const fileMatch = `(${nameNoExt.replace(/[.*+?^$[\]()|\\:!{}]/g, "\\$&")}\\.${isEntry ? "|" : ""})`;
|
|
1510
1510
|
const componentMatch = new RegExp(
|
|
1511
1511
|
`^${fileMatch}component(-browser)?\\.\\w+$`
|
|
1512
1512
|
);
|
|
@@ -2288,39 +2288,43 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2288
2288
|
break;
|
|
2289
2289
|
}
|
|
2290
2290
|
} else if (attr.args) {
|
|
2291
|
-
const stringLiteralFirstArgMatch = this.#execAtIndex(
|
|
2292
|
-
REG_ATTR_ARG_LITERAL,
|
|
2293
|
-
attr.args.value.start
|
|
2294
|
-
);
|
|
2295
2291
|
this.#extractor.write('"').copy(name).write('": ');
|
|
2296
|
-
if (
|
|
2297
|
-
const
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
const isValidProperty = REG_OBJECT_PROPERTY.test(
|
|
2301
|
-
stringLiteralFirstArgMatch[2]
|
|
2292
|
+
if (typeof name !== "string" && this.#read(name).startsWith("on")) {
|
|
2293
|
+
const stringLiteralFirstArgMatch = this.#execAtIndex(
|
|
2294
|
+
REG_ATTR_ARG_LITERAL,
|
|
2295
|
+
attr.args.value.start
|
|
2302
2296
|
);
|
|
2303
|
-
if (
|
|
2304
|
-
const
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2297
|
+
if (stringLiteralFirstArgMatch) {
|
|
2298
|
+
const hasPartialArgs = stringLiteralFirstArgMatch[3] === ",";
|
|
2299
|
+
const stringLiteralValue = stringLiteralFirstArgMatch[2];
|
|
2300
|
+
const stringLiteralStart = stringLiteralFirstArgMatch.index;
|
|
2301
|
+
const isValidProperty = REG_OBJECT_PROPERTY.test(
|
|
2302
|
+
stringLiteralFirstArgMatch[2]
|
|
2303
|
+
);
|
|
2304
|
+
if (isValidProperty) {
|
|
2305
|
+
const propertNameStart = stringLiteralStart + 1;
|
|
2306
|
+
this.#extractor.write("component.").copy({
|
|
2307
|
+
start: propertNameStart,
|
|
2308
|
+
end: propertNameStart + stringLiteralValue.length
|
|
2309
|
+
});
|
|
2310
|
+
} else {
|
|
2311
|
+
this.#extractor.write(`component[`).copy({
|
|
2312
|
+
start: stringLiteralStart,
|
|
2313
|
+
end: stringLiteralStart + stringLiteralValue.length + 2
|
|
2314
|
+
}).write("]");
|
|
2315
|
+
}
|
|
2316
|
+
if (hasPartialArgs) {
|
|
2317
|
+
this.#extractor.write(`.bind(component, `).copy({
|
|
2318
|
+
start: stringLiteralStart + stringLiteralFirstArgMatch[0].length,
|
|
2319
|
+
end: attr.args.value.end
|
|
2320
|
+
}).write(")");
|
|
2321
|
+
}
|
|
2309
2322
|
} else {
|
|
2310
|
-
this.#extractor.write(
|
|
2311
|
-
|
|
2312
|
-
end: stringLiteralStart + stringLiteralValue.length + 2
|
|
2313
|
-
}).write("]");
|
|
2314
|
-
}
|
|
2315
|
-
if (hasPartialArgs) {
|
|
2316
|
-
this.#extractor.write(`.bind(component, `).copy({
|
|
2317
|
-
start: stringLiteralStart + stringLiteralFirstArgMatch[0].length,
|
|
2318
|
-
end: attr.args.value.end
|
|
2319
|
-
}).write(")");
|
|
2323
|
+
this.#extractor.write(`${varShared("bind")}(component,
|
|
2324
|
+
`).copy(attr.args.value).write("\n)");
|
|
2320
2325
|
}
|
|
2321
2326
|
} else {
|
|
2322
|
-
this.#extractor.
|
|
2323
|
-
`).copy(attr.args.value).write("\n)");
|
|
2327
|
+
this.#extractor.copy(attr.args);
|
|
2324
2328
|
}
|
|
2325
2329
|
} else {
|
|
2326
2330
|
this.#extractor.write('"').copy(defaultMapPosition).copy(name).write(`": ${modifierIndex === false ? "true" : '""'}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-tools",
|
|
3
3
|
"description": "Marko Language Tools",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.3",
|
|
5
5
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@marko/compiler": "^5.28.4"
|
|
@@ -9,20 +9,20 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@babel/helper-validator-identifier": "^7.22.20",
|
|
11
11
|
"@babel/parser": "^7.23.6",
|
|
12
|
-
"htmljs-parser": "^5.5.
|
|
12
|
+
"htmljs-parser": "^5.5.2",
|
|
13
13
|
"strip-json-comments": "^3.1.1",
|
|
14
14
|
"relative-import-path": "^1.0.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@babel/code-frame": "^7.23.5",
|
|
18
|
-
"@marko/compiler": "^5.34.
|
|
19
|
-
"@marko/translator-default": "^5.31.
|
|
18
|
+
"@marko/compiler": "^5.34.3",
|
|
19
|
+
"@marko/translator-default": "^5.31.10",
|
|
20
20
|
"@types/babel__code-frame": "^7.0.6",
|
|
21
21
|
"@types/babel__helper-validator-identifier": "^7.15.2",
|
|
22
22
|
"@typescript/vfs": "^1.5.0",
|
|
23
|
-
"marko": "^5.32.
|
|
23
|
+
"marko": "^5.32.4",
|
|
24
24
|
"mitata": "^0.1.6",
|
|
25
|
-
"tsx": "^4.
|
|
25
|
+
"tsx": "^4.7.0"
|
|
26
26
|
},
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|