@marko/language-tools 2.1.3 → 2.1.5

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 CHANGED
@@ -1066,10 +1066,7 @@ function crawlProgramScope(parsed, scriptParser) {
1066
1066
  case 16 /* AttrTag */: {
1067
1067
  if (child.var) {
1068
1068
  parentScope.bindings ??= {};
1069
- const parsedFn = scriptParser.expressionAt(
1070
- child.var.value.start - 6,
1071
- `${read(child.var.value)}=0`
1072
- );
1069
+ const parsedFn = scriptParser.expressionAt(child.var.value.start - 6, `${read(child.var.value)}=0`);
1073
1070
  if (parsedFn) {
1074
1071
  const lVal = parsedFn.left;
1075
1072
  checkForMutations(parentScope, lVal);
@@ -1440,7 +1437,9 @@ function trackMutations(node, scope, mutations, parentBlock, parentBlockShadows,
1440
1437
  }
1441
1438
  break;
1442
1439
  case "ClassDeclaration":
1443
- trackShadows(node.id, scope, parentBlockShadows);
1440
+ if (node.id) {
1441
+ trackShadows(node.id, scope, parentBlockShadows);
1442
+ }
1444
1443
  block = node.body;
1445
1444
  blockShadows = new Set(blockShadows);
1446
1445
  blockMutations = [];
@@ -3088,16 +3087,8 @@ function getMeta(dir) {
3088
3087
  function loadMeta(dir) {
3089
3088
  let cached = metaByDir.get(dir);
3090
3089
  if (!cached) {
3091
- let require2 = (0, import_module.createRequire)(dir);
3092
- let configPath;
3093
- try {
3094
- configPath = require2.resolve("@marko/compiler/config");
3095
- } catch {
3096
- require2 = (0, import_module.createRequire)(
3097
- import_path2.default.dirname(require2.resolve("marko/package.json"))
3098
- );
3099
- configPath = require2.resolve("@marko/compiler/config");
3100
- }
3090
+ const require2 = (0, import_module.createRequire)(import_path2.default.join(dir, "_.js"));
3091
+ const configPath = require2.resolve("@marko/compiler/config");
3101
3092
  cached = metaByCompiler.get(configPath);
3102
3093
  if (!cached) {
3103
3094
  const compiler = require2(import_path2.default.dirname(configPath));
@@ -3176,7 +3167,7 @@ var marko_default = {
3176
3167
  extension: ".marko",
3177
3168
  create({ ts, host, configFile }) {
3178
3169
  const currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ts.sys.getCurrentDirectory();
3179
- const defaultScriptLang = configFile && /tsconfig.json$/.test(configFile) ? "ts" /* ts */ : "js" /* js */;
3170
+ const defaultScriptLang = configFile && /tsconfig/g.test(configFile) ? "ts" /* ts */ : "js" /* js */;
3180
3171
  const runtimeTypes = getTypeLibs(currentDirectory, ts, host);
3181
3172
  const rootNames = [
3182
3173
  runtimeTypes.internalTypesFile,
@@ -3458,11 +3449,13 @@ var HTMLExtractor = class {
3458
3449
  hasDynamicAttrs = true;
3459
3450
  });
3460
3451
  this.#extractor.write(">");
3461
- (_b = node.body) == null ? void 0 : _b.forEach((child) => {
3462
- if (this.#visitNode(child))
3463
- hasDynamicBody = true;
3464
- });
3465
- this.#extractor.write(`</${node.nameText}>`);
3452
+ if (!isVoidTag(node.nameText)) {
3453
+ (_b = node.body) == null ? void 0 : _b.forEach((child) => {
3454
+ if (this.#visitNode(child))
3455
+ hasDynamicBody = true;
3456
+ });
3457
+ this.#extractor.write(`</${node.nameText}>`);
3458
+ }
3466
3459
  return { hasDynamicAttrs, hasDynamicBody };
3467
3460
  }
3468
3461
  #writeCustomTag(node) {
@@ -3507,6 +3500,27 @@ var HTMLExtractor = class {
3507
3500
  }
3508
3501
  }
3509
3502
  };
3503
+ function isVoidTag(tagName) {
3504
+ switch (tagName) {
3505
+ case "area":
3506
+ case "base":
3507
+ case "br":
3508
+ case "col":
3509
+ case "embed":
3510
+ case "hr":
3511
+ case "img":
3512
+ case "input":
3513
+ case "link":
3514
+ case "meta":
3515
+ case "param":
3516
+ case "source":
3517
+ case "track":
3518
+ case "wbr":
3519
+ return true;
3520
+ default:
3521
+ return false;
3522
+ }
3523
+ }
3510
3524
  // Annotate the CommonJS export names for ESM import in node:
3511
3525
  0 && (module.exports = {
3512
3526
  NodeType,
package/dist/index.mjs CHANGED
@@ -1034,10 +1034,7 @@ function crawlProgramScope(parsed, scriptParser) {
1034
1034
  case 16 /* AttrTag */: {
1035
1035
  if (child.var) {
1036
1036
  parentScope.bindings ??= {};
1037
- const parsedFn = scriptParser.expressionAt(
1038
- child.var.value.start - 6,
1039
- `${read(child.var.value)}=0`
1040
- );
1037
+ const parsedFn = scriptParser.expressionAt(child.var.value.start - 6, `${read(child.var.value)}=0`);
1041
1038
  if (parsedFn) {
1042
1039
  const lVal = parsedFn.left;
1043
1040
  checkForMutations(parentScope, lVal);
@@ -1408,7 +1405,9 @@ function trackMutations(node, scope, mutations, parentBlock, parentBlockShadows,
1408
1405
  }
1409
1406
  break;
1410
1407
  case "ClassDeclaration":
1411
- trackShadows(node.id, scope, parentBlockShadows);
1408
+ if (node.id) {
1409
+ trackShadows(node.id, scope, parentBlockShadows);
1410
+ }
1412
1411
  block = node.body;
1413
1412
  blockShadows = new Set(blockShadows);
1414
1413
  blockMutations = [];
@@ -3056,16 +3055,8 @@ function getMeta(dir) {
3056
3055
  function loadMeta(dir) {
3057
3056
  let cached = metaByDir.get(dir);
3058
3057
  if (!cached) {
3059
- let require2 = createRequire(dir);
3060
- let configPath;
3061
- try {
3062
- configPath = require2.resolve("@marko/compiler/config");
3063
- } catch {
3064
- require2 = createRequire(
3065
- path2.dirname(require2.resolve("marko/package.json"))
3066
- );
3067
- configPath = require2.resolve("@marko/compiler/config");
3068
- }
3058
+ const require2 = createRequire(path2.join(dir, "_.js"));
3059
+ const configPath = require2.resolve("@marko/compiler/config");
3069
3060
  cached = metaByCompiler.get(configPath);
3070
3061
  if (!cached) {
3071
3062
  const compiler = require2(path2.dirname(configPath));
@@ -3144,7 +3135,7 @@ var marko_default = {
3144
3135
  extension: ".marko",
3145
3136
  create({ ts, host, configFile }) {
3146
3137
  const currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ts.sys.getCurrentDirectory();
3147
- const defaultScriptLang = configFile && /tsconfig.json$/.test(configFile) ? "ts" /* ts */ : "js" /* js */;
3138
+ const defaultScriptLang = configFile && /tsconfig/g.test(configFile) ? "ts" /* ts */ : "js" /* js */;
3148
3139
  const runtimeTypes = getTypeLibs(currentDirectory, ts, host);
3149
3140
  const rootNames = [
3150
3141
  runtimeTypes.internalTypesFile,
@@ -3426,11 +3417,13 @@ var HTMLExtractor = class {
3426
3417
  hasDynamicAttrs = true;
3427
3418
  });
3428
3419
  this.#extractor.write(">");
3429
- (_b = node.body) == null ? void 0 : _b.forEach((child) => {
3430
- if (this.#visitNode(child))
3431
- hasDynamicBody = true;
3432
- });
3433
- this.#extractor.write(`</${node.nameText}>`);
3420
+ if (!isVoidTag(node.nameText)) {
3421
+ (_b = node.body) == null ? void 0 : _b.forEach((child) => {
3422
+ if (this.#visitNode(child))
3423
+ hasDynamicBody = true;
3424
+ });
3425
+ this.#extractor.write(`</${node.nameText}>`);
3426
+ }
3434
3427
  return { hasDynamicAttrs, hasDynamicBody };
3435
3428
  }
3436
3429
  #writeCustomTag(node) {
@@ -3475,6 +3468,27 @@ var HTMLExtractor = class {
3475
3468
  }
3476
3469
  }
3477
3470
  };
3471
+ function isVoidTag(tagName) {
3472
+ switch (tagName) {
3473
+ case "area":
3474
+ case "base":
3475
+ case "br":
3476
+ case "col":
3477
+ case "embed":
3478
+ case "hr":
3479
+ case "img":
3480
+ case "input":
3481
+ case "link":
3482
+ case "meta":
3483
+ case "param":
3484
+ case "source":
3485
+ case "track":
3486
+ case "wbr":
3487
+ return true;
3488
+ default:
3489
+ return false;
3490
+ }
3491
+ }
3478
3492
  export {
3479
3493
  NodeType,
3480
3494
  processors_exports as Processors,
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type TS from "typescript/lib/tsserverlibrary";
3
2
  import type { TaglibLookup } from "@marko/babel-utils";
4
3
  import type * as Compiler from "@marko/compiler";
@@ -23,43 +22,7 @@ interface TypeLibs {
23
22
  declare const defaultTypeLibs: Partial<TypeLibs>;
24
23
  export declare function getCompiler(dir?: string): typeof Compiler;
25
24
  export declare function getCache(dir?: string): Map<any, any>;
26
- export declare function getConfig(dir?: string): Omit<{
27
- output?: "source" | "html" | "dom" | "hydrate" | "migrate" | undefined;
28
- errorRecovery?: boolean | undefined;
29
- applyFixes?: Map<number, unknown> | undefined;
30
- stripTypes?: boolean | undefined;
31
- runtimeId?: string | null | undefined;
32
- ast?: boolean | undefined;
33
- code?: boolean | undefined;
34
- writeVersionComment?: boolean | undefined;
35
- ignoreUnrecognizedTags?: boolean | undefined;
36
- sourceMaps?: boolean | "inline" | "both" | undefined;
37
- translator?: any;
38
- fileSystem?: typeof import("fs") | undefined;
39
- modules?: "esm" | "cjs" | undefined;
40
- resolveVirtualDependency?: ((filename: string, dep: {
41
- virtualPath: string;
42
- code: string;
43
- map?: any;
44
- }) => string) | null | undefined;
45
- hydrateIncludeImports?: RegExp | ((request: string) => boolean) | undefined;
46
- optimize?: boolean | undefined;
47
- cache?: Map<unknown, unknown> | undefined;
48
- hot?: boolean | undefined;
49
- meta?: boolean | undefined;
50
- babelConfig?: {
51
- [x: string]: unknown;
52
- ast?: boolean | null | undefined;
53
- code?: boolean | null | undefined;
54
- comments?: boolean | null | undefined;
55
- compact?: boolean | "auto" | null | undefined;
56
- caller?: {
57
- [x: string]: unknown;
58
- name?: string | undefined;
59
- } | undefined;
60
- minified?: boolean | null | undefined;
61
- } | undefined;
62
- }, "cache" | "translator"> & {
25
+ export declare function getConfig(dir?: string): Omit<Compiler.Config, "cache" | "translator"> & {
63
26
  cache: Map<any, any>;
64
27
  translator: {
65
28
  [x: string]: unknown;
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
1
  {
2
2
  "name": "@marko/language-tools",
3
3
  "description": "Marko Language Tools",
4
- "version": "2.1.3",
4
+ "version": "2.1.5",
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"
8
8
  },
9
9
  "dependencies": {
10
- "@babel/helper-validator-identifier": "^7.22.5",
11
- "@babel/parser": "^7.22.7",
10
+ "@babel/helper-validator-identifier": "^7.22.20",
11
+ "@babel/parser": "^7.23.0",
12
12
  "htmljs-parser": "^5.5.0",
13
13
  "relative-import-path": "^1.0.0"
14
14
  },
15
15
  "devDependencies": {
16
- "@babel/code-frame": "^7.22.5",
17
- "@marko/compiler": "^5.31.1",
18
- "@marko/translator-default": "^5.29.2",
19
- "@types/babel__code-frame": "^7.0.3",
16
+ "@babel/code-frame": "^7.22.13",
17
+ "@marko/compiler": "^5.33.2",
18
+ "@marko/translator-default": "^5.31.3",
19
+ "@types/babel__code-frame": "^7.0.4",
20
20
  "@types/babel__helper-validator-identifier": "^7.15.0",
21
- "@typescript/vfs": "^1.4.0",
22
- "marko": "^5.29.2",
21
+ "@typescript/vfs": "^1.5.0",
22
+ "marko": "^5.31.10",
23
23
  "mitata": "^0.1.6",
24
- "tsx": "^3.12.7"
24
+ "tsx": "^3.13.0"
25
25
  },
26
26
  "exports": {
27
27
  ".": {