@bascik/language-server 0.1.0-rc.5 → 1.0.0-rc.1

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.
Files changed (127) hide show
  1. package/README.md +74 -30
  2. package/dist/analyzer.d.ts +75 -1
  3. package/dist/analyzer.d.ts.map +1 -1
  4. package/dist/analyzer.js +727 -76
  5. package/dist/analyzer.js.map +1 -1
  6. package/dist/api-rules.d.ts +7 -0
  7. package/dist/api-rules.d.ts.map +1 -1
  8. package/dist/api-rules.js +282 -17
  9. package/dist/api-rules.js.map +1 -1
  10. package/dist/bin-args.d.ts +11 -0
  11. package/dist/bin-args.d.ts.map +1 -0
  12. package/dist/bin-args.js +21 -0
  13. package/dist/bin-args.js.map +1 -0
  14. package/dist/bin.js +17 -5
  15. package/dist/bin.js.map +1 -1
  16. package/dist/check.d.ts +14 -1
  17. package/dist/check.d.ts.map +1 -1
  18. package/dist/check.js +116 -10
  19. package/dist/check.js.map +1 -1
  20. package/dist/cli.d.ts.map +1 -1
  21. package/dist/cli.js +27 -8
  22. package/dist/cli.js.map +1 -1
  23. package/dist/compatibility-rules.json +21 -3
  24. package/dist/component-metadata.d.ts.map +1 -1
  25. package/dist/component-metadata.js +3 -1
  26. package/dist/component-metadata.js.map +1 -1
  27. package/dist/component-usages.d.ts +47 -0
  28. package/dist/component-usages.d.ts.map +1 -0
  29. package/dist/component-usages.js +495 -0
  30. package/dist/component-usages.js.map +1 -0
  31. package/dist/config-reader.d.ts +41 -0
  32. package/dist/config-reader.d.ts.map +1 -0
  33. package/dist/config-reader.js +461 -0
  34. package/dist/config-reader.js.map +1 -0
  35. package/dist/config.d.ts +10 -0
  36. package/dist/config.d.ts.map +1 -1
  37. package/dist/config.js +25 -30
  38. package/dist/config.js.map +1 -1
  39. package/dist/css-brace-balance.d.ts +33 -0
  40. package/dist/css-brace-balance.d.ts.map +1 -0
  41. package/dist/css-brace-balance.js +99 -0
  42. package/dist/css-brace-balance.js.map +1 -0
  43. package/dist/hand-written-escaper.d.ts +35 -0
  44. package/dist/hand-written-escaper.d.ts.map +1 -0
  45. package/dist/hand-written-escaper.js +739 -0
  46. package/dist/hand-written-escaper.js.map +1 -0
  47. package/dist/module-specifiers.d.ts +25 -0
  48. package/dist/module-specifiers.d.ts.map +1 -1
  49. package/dist/module-specifiers.js +234 -165
  50. package/dist/module-specifiers.js.map +1 -1
  51. package/dist/name-groups.d.ts +36 -0
  52. package/dist/name-groups.d.ts.map +1 -0
  53. package/dist/name-groups.js +198 -0
  54. package/dist/name-groups.js.map +1 -0
  55. package/dist/plain-holes.d.ts +116 -0
  56. package/dist/plain-holes.d.ts.map +1 -0
  57. package/dist/plain-holes.js +1970 -0
  58. package/dist/plain-holes.js.map +1 -0
  59. package/dist/preserved-targets.d.ts +50 -0
  60. package/dist/preserved-targets.d.ts.map +1 -0
  61. package/dist/preserved-targets.js +358 -0
  62. package/dist/preserved-targets.js.map +1 -0
  63. package/dist/project.d.ts +68 -1
  64. package/dist/project.d.ts.map +1 -1
  65. package/dist/project.js +157 -8
  66. package/dist/project.js.map +1 -1
  67. package/dist/references.d.ts +47 -0
  68. package/dist/references.d.ts.map +1 -0
  69. package/dist/references.js +241 -0
  70. package/dist/references.js.map +1 -0
  71. package/dist/script-modules.d.ts +60 -0
  72. package/dist/script-modules.d.ts.map +1 -0
  73. package/dist/script-modules.js +382 -0
  74. package/dist/script-modules.js.map +1 -0
  75. package/dist/server-script-rules.d.ts +94 -1
  76. package/dist/server-script-rules.d.ts.map +1 -1
  77. package/dist/server-script-rules.js +2572 -230
  78. package/dist/server-script-rules.js.map +1 -1
  79. package/dist/server-script-templates.d.ts +250 -0
  80. package/dist/server-script-templates.d.ts.map +1 -0
  81. package/dist/server-script-templates.js +1685 -0
  82. package/dist/server-script-templates.js.map +1 -0
  83. package/dist/server.d.ts +191 -3
  84. package/dist/server.d.ts.map +1 -1
  85. package/dist/server.js +822 -50
  86. package/dist/server.js.map +1 -1
  87. package/dist/start.d.ts +10 -1
  88. package/dist/start.d.ts.map +1 -1
  89. package/dist/start.js +14 -2
  90. package/dist/start.js.map +1 -1
  91. package/dist/string-typed-flow.d.ts +26 -0
  92. package/dist/string-typed-flow.d.ts.map +1 -0
  93. package/dist/string-typed-flow.js +496 -0
  94. package/dist/string-typed-flow.js.map +1 -0
  95. package/dist/typescript-blocks.d.ts +205 -0
  96. package/dist/typescript-blocks.d.ts.map +1 -0
  97. package/dist/typescript-blocks.js +464 -0
  98. package/dist/typescript-blocks.js.map +1 -0
  99. package/dist/typescript-editor-mode.d.ts +28 -0
  100. package/dist/typescript-editor-mode.d.ts.map +1 -0
  101. package/dist/typescript-editor-mode.js +161 -0
  102. package/dist/typescript-editor-mode.js.map +1 -0
  103. package/dist/typescript-engine.d.ts +115 -0
  104. package/dist/typescript-engine.d.ts.map +1 -0
  105. package/dist/typescript-engine.js +286 -0
  106. package/dist/typescript-engine.js.map +1 -0
  107. package/dist/typescript-features.d.ts +136 -0
  108. package/dist/typescript-features.d.ts.map +1 -0
  109. package/dist/typescript-features.js +374 -0
  110. package/dist/typescript-features.js.map +1 -0
  111. package/dist/typescript-loader.d.ts +55 -0
  112. package/dist/typescript-loader.d.ts.map +1 -0
  113. package/dist/typescript-loader.js +202 -0
  114. package/dist/typescript-loader.js.map +1 -0
  115. package/dist/typescript-lsp.d.ts +8 -0
  116. package/dist/typescript-lsp.d.ts.map +1 -0
  117. package/dist/typescript-lsp.js +115 -0
  118. package/dist/typescript-lsp.js.map +1 -0
  119. package/dist/typescript-service.d.ts +350 -0
  120. package/dist/typescript-service.d.ts.map +1 -0
  121. package/dist/typescript-service.js +1465 -0
  122. package/dist/typescript-service.js.map +1 -0
  123. package/dist/typescript-worker.d.ts +11 -0
  124. package/dist/typescript-worker.d.ts.map +1 -0
  125. package/dist/typescript-worker.js +107 -0
  126. package/dist/typescript-worker.js.map +1 -0
  127. package/package.json +34 -12
package/dist/project.d.ts CHANGED
@@ -7,9 +7,76 @@ export interface ProjectSnapshot {
7
7
  componentMap: Map<string, string>;
8
8
  componentMetadata: Map<string, ComponentMetadata>;
9
9
  importRoot: string;
10
+ /** The pages folder (`directory.pages`, default `src/pages`), resolved. Its HTML is in `htmlUsageByFile`. */
11
+ pagesRoot?: string;
12
+ /** The HTML that can use a component outside the component roots: everything under `src` and `pagesRoot`. */
10
13
  htmlUsageByFile: Map<string, string>;
14
+ /**
15
+ * The text of every component file, keyed by absolute path, including component roots outside `src`.
16
+ * Find All References reads usages from it and `htmlUsageByFile`.
17
+ */
18
+ componentSourceByFile?: Map<string, string>;
19
+ /**
20
+ * `scoping.attributes.name`: whether the project opts in to scoping `name` per component instance. Off by
21
+ * default, when every `name` ships as written.
22
+ */
23
+ scopesName?: boolean;
24
+ /**
25
+ * `scoping.scriptBlocks`: whether each client script block of a component is wrapped in its own function, so
26
+ * its top-level names stay in that block. On by default. Page scripts are never wrapped.
27
+ */
28
+ scopesScriptBlocks?: boolean;
29
+ /**
30
+ * `scoping.preserve`: the tag names (or `*` patterns) whose `class` and `id` stay unscoped. `["code"]` when
31
+ * the config does not set it.
32
+ */
33
+ preserve?: string[];
11
34
  }
35
+ /**
36
+ * Config filenames in the CLI's discovery order (pkg/src/lib/config-file-names.ts): the first that exists is
37
+ * the project's config, so the editor reads the same file `bascik` loads when more than one is present.
38
+ */
12
39
  export declare const CONFIG_FILE_CANDIDATES: string[];
40
+ /** Reads `directory.pages` from the config source. The key must be exactly `pages`. */
41
+ export declare function parsePagesRoot(source: string | undefined): string;
42
+ /**
43
+ * Reads `scoping.attributes.name` from the config source: true only when the `attributes` object sets
44
+ * `name: true`. Comments are ignored; a `name` key anywhere else is not the toggle.
45
+ */
46
+ export declare function parseScopesName(source: string | undefined): boolean;
47
+ /**
48
+ * Reads `scoping.preserve` from the config source: the string literals in its array, or `["code"]`, the
49
+ * compiler's default, when it is not set.
50
+ */
51
+ export declare function parsePreserve(source: string | undefined): string[];
52
+ /** Reads `scoping.scriptBlocks` from the config source: on unless it is set to `false`. */
53
+ export declare function parseScriptBlocks(source: string | undefined): boolean;
54
+ /**
55
+ * Whether each client script block of an HTML file runs in its own scope: true in a component when
56
+ * `scoping.scriptBlocks` is on, where Bascik wraps every block in a function. A page's blocks, and a component's
57
+ * when the setting is off, become plain `<script>` elements that share the page's global scope.
58
+ */
59
+ export declare function hasIsolatedClientBlocks(fsPath: string, snapshot: Pick<ProjectSnapshot, "componentRoots" | "scopesScriptBlocks">): boolean;
60
+ /** A component's file and its current text (an open editor buffer's, when newer than the file on disk). */
61
+ export interface ComponentSource {
62
+ fsPath: string;
63
+ text: string;
64
+ }
65
+ /**
66
+ * Every component a page uses, directly or through other components, with its file and text, whatever the script
67
+ * scoping. Each component appears once, in the order first used, and never the page itself. `readOpen` gives an
68
+ * open editor buffer's newer text.
69
+ */
70
+ export declare function usedComponentSources(fsPath: string, text: string, snapshot: Pick<ProjectSnapshot, "componentMap"> & Partial<Pick<ProjectSnapshot, "componentSourceByFile">>, readOpen?: (fsPath: string) => string | undefined): ComponentSource[];
71
+ /**
72
+ * The HTML of every component a page uses, directly or through other components, whose client scripts run in the
73
+ * page's own scope: all of them when `scoping.scriptBlocks` is off, none otherwise (each component block is then
74
+ * wrapped in its own function). Each component appears once, in the order first used. `readOpen` gives an open
75
+ * editor buffer's newer text.
76
+ */
77
+ export declare function pageScopeComponentHtml(fsPath: string, text: string, snapshot: Pick<ProjectSnapshot, "componentRoots" | "scopesScriptBlocks" | "componentMap"> & Partial<Pick<ProjectSnapshot, "componentSourceByFile">>, readOpen?: (fsPath: string) => string | undefined): string[];
78
+ /** Is `fsPath` HTML that `htmlUsageByFile` tracks: under `src` or the pages folder? */
79
+ export declare function isUsageSourcePath(fsPath: string, snapshot: Pick<ProjectSnapshot, "projectRoot" | "pagesRoot">): boolean;
13
80
  /** Reads `directory.api` from the config source. `apiTimeout` does not match: the key must be exactly `api`. */
14
81
  export declare function parseApiRoot(source: string | undefined): string;
15
82
  export declare function normalizeComponentName(name: string): string;
@@ -21,7 +88,7 @@ export declare function isInsideComponentRoots(fsPath: string, roots: string[]):
21
88
  export declare function findHtmlFiles(roots: string[]): Promise<string[]>;
22
89
  export declare function buildSnapshot(workspaceRoot: string): Promise<ProjectSnapshot>;
23
90
  export declare function isPathInside(fsPath: string, root: string): boolean;
24
- /** Is `fsPath` a Bascik config file (`bascik.config.ts`, `.js`, or `.mjs`)? */
91
+ /** Is `fsPath` a Bascik config file (`bascik.config.js`, `.mjs`, or `.ts`)? */
25
92
  export declare function isConfigFile(fsPath: string): boolean;
26
93
  /**
27
94
  * Paths that never hold a project: installed packages, build output, and git internals. Judged relative to the
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,eAAO,MAAM,sBAAsB,UAIlC,CAAC;AAKF,gHAAgH;AAChH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAI/D;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS3D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CASxE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKlE;AAED,w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AK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAuBtE;AAED,wBAAsB,aAAa,CACjC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,eAAe,CAAC,CAmF1B;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMlE;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACpB,OAAO,CAOT;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAiBT"}
package/dist/project.js CHANGED
@@ -1,18 +1,151 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as fsPromises from "node:fs/promises";
3
3
  import * as path from "node:path";
4
+ import { findComponentUsages } from "./component-usages.js";
4
5
  import { analyzeComponentSource, } from "./component-metadata.js";
6
+ /**
7
+ * Config filenames in the CLI's discovery order (pkg/src/lib/config-file-names.ts): the first that exists is
8
+ * the project's config, so the editor reads the same file `bascik` loads when more than one is present.
9
+ */
5
10
  export const CONFIG_FILE_CANDIDATES = [
6
- "bascik.config.ts",
7
11
  "bascik.config.js",
8
12
  "bascik.config.mjs",
13
+ "bascik.config.ts",
9
14
  ];
10
15
  const DEFAULT_COMPONENT_ROOTS = ["src/components"];
11
16
  const DEFAULT_IMPORT_ROOT = "src";
12
17
  const DEFAULT_API_ROOT = "src/api";
18
+ const DEFAULT_PAGES_ROOT = "src/pages";
19
+ /**
20
+ * The config source with `//` and `/* *\/` comments replaced by spaces (line breaks kept), so a commented-out
21
+ * setting never drives the editor while the compiler, which imports the real config, ignores it. Quotes and
22
+ * template literals are skipped, so `https://` in a string stays. One forward pass with `indexOf`, so an
23
+ * unclosed `/*` (a comment to the end of the file) or a run of them stays linear.
24
+ */
25
+ function stripConfigComments(source) {
26
+ const text = source ?? "";
27
+ let out = "";
28
+ let copiedTo = 0;
29
+ let i = 0;
30
+ const blank = (end) => {
31
+ out += text.slice(copiedTo, i) + text.slice(i, end).replace(/[^\n]/g, " ");
32
+ copiedTo = end;
33
+ i = end;
34
+ };
35
+ while (i < text.length) {
36
+ const c = text[i];
37
+ if (c === "/" && text[i + 1] === "/") {
38
+ const end = text.indexOf("\n", i + 2);
39
+ blank(end < 0 ? text.length : end);
40
+ }
41
+ else if (c === "/" && text[i + 1] === "*") {
42
+ const close = text.indexOf("*/", i + 2);
43
+ blank(close < 0 ? text.length : close + 2);
44
+ }
45
+ else if (c === '"' || c === "'" || c === "`") {
46
+ // A quoted string ends at its quote, or (unclosed) at the line break; a template at its backtick.
47
+ let j = i + 1;
48
+ while (j < text.length &&
49
+ text[j] !== c &&
50
+ (c === "`" || text[j] !== "\n"))
51
+ j += text[j] === "\\" ? 2 : 1;
52
+ i = j + 1;
53
+ }
54
+ else {
55
+ i++;
56
+ }
57
+ }
58
+ return copiedTo === 0 ? text : out + text.slice(copiedTo);
59
+ }
60
+ /** Reads `directory.pages` from the config source. The key must be exactly `pages`. */
61
+ export function parsePagesRoot(source) {
62
+ return (/(?<![\w$])pages\s*:\s*['"]([^'"]+)['"]/.exec(stripConfigComments(source))?.[1] ?? DEFAULT_PAGES_ROOT);
63
+ }
64
+ /**
65
+ * Reads `scoping.attributes.name` from the config source: true only when the `attributes` object sets
66
+ * `name: true`. Comments are ignored; a `name` key anywhere else is not the toggle.
67
+ */
68
+ export function parseScopesName(source) {
69
+ const code = stripConfigComments(source);
70
+ const attributes = /(?<![\w$])attributes\s*:\s*\{([^{}]*)\}/.exec(code);
71
+ if (!attributes)
72
+ return false;
73
+ return /(?<![\w$-])["']?name["']?\s*:\s*true\b/.test(attributes[1]);
74
+ }
75
+ /**
76
+ * Reads `scoping.preserve` from the config source: the string literals in its array, or `["code"]`, the
77
+ * compiler's default, when it is not set.
78
+ */
79
+ export function parsePreserve(source) {
80
+ const match = /(?<![\w$-])["']?preserve["']?\s*:\s*\[([^\]]*)\]/.exec(stripConfigComments(source));
81
+ if (!match)
82
+ return ["code"];
83
+ return Array.from(match[1].matchAll(/['"]([^'"]*)['"]/g), (item) => item[1]);
84
+ }
85
+ /** Reads `scoping.scriptBlocks` from the config source: on unless it is set to `false`. */
86
+ export function parseScriptBlocks(source) {
87
+ return !/(?<![\w$-])["']?scriptBlocks["']?\s*:\s*false\b/.test(stripConfigComments(source));
88
+ }
89
+ /**
90
+ * Whether each client script block of an HTML file runs in its own scope: true in a component when
91
+ * `scoping.scriptBlocks` is on, where Bascik wraps every block in a function. A page's blocks, and a component's
92
+ * when the setting is off, become plain `<script>` elements that share the page's global scope.
93
+ */
94
+ export function hasIsolatedClientBlocks(fsPath, snapshot) {
95
+ return (snapshot.scopesScriptBlocks !== false &&
96
+ isInsideComponentRoots(fsPath, snapshot.componentRoots));
97
+ }
98
+ /**
99
+ * Every component a page uses, directly or through other components, with its file and text, whatever the script
100
+ * scoping. Each component appears once, in the order first used, and never the page itself. `readOpen` gives an
101
+ * open editor buffer's newer text.
102
+ */
103
+ export function usedComponentSources(fsPath, text, snapshot, readOpen = () => undefined) {
104
+ const names = new Set(snapshot.componentMap.keys());
105
+ const seen = new Set([path.resolve(fsPath)]);
106
+ const found = [];
107
+ const queue = [text];
108
+ while (queue.length > 0) {
109
+ const html = queue.shift();
110
+ for (const usage of findComponentUsages(html, names)) {
111
+ const componentPath = snapshot.componentMap.get(usage.name);
112
+ if (componentPath === undefined)
113
+ continue;
114
+ const resolved = path.resolve(componentPath);
115
+ if (seen.has(resolved))
116
+ continue;
117
+ seen.add(resolved);
118
+ const source = readOpen(componentPath) ??
119
+ snapshot.componentSourceByFile?.get(componentPath);
120
+ if (source === undefined)
121
+ continue;
122
+ found.push({ fsPath: componentPath, text: source });
123
+ queue.push(source);
124
+ }
125
+ }
126
+ return found;
127
+ }
128
+ /**
129
+ * The HTML of every component a page uses, directly or through other components, whose client scripts run in the
130
+ * page's own scope: all of them when `scoping.scriptBlocks` is off, none otherwise (each component block is then
131
+ * wrapped in its own function). Each component appears once, in the order first used. `readOpen` gives an open
132
+ * editor buffer's newer text.
133
+ */
134
+ export function pageScopeComponentHtml(fsPath, text, snapshot, readOpen = () => undefined) {
135
+ if (snapshot.scopesScriptBlocks !== false)
136
+ return [];
137
+ return usedComponentSources(fsPath, text, snapshot, readOpen).map((component) => component.text);
138
+ }
139
+ /** Is `fsPath` HTML that `htmlUsageByFile` tracks: under `src` or the pages folder? */
140
+ export function isUsageSourcePath(fsPath, snapshot) {
141
+ return (isPathInside(fsPath, path.join(snapshot.projectRoot, "src")) ||
142
+ (snapshot.pagesRoot !== undefined &&
143
+ isPathInside(fsPath, snapshot.pagesRoot)));
144
+ }
13
145
  /** Reads `directory.api` from the config source. `apiTimeout` does not match: the key must be exactly `api`. */
14
146
  export function parseApiRoot(source) {
15
- return (/\bapi\s*:\s*['"]([^'"]+)['"]/.exec(source ?? "")?.[1] ?? DEFAULT_API_ROOT);
147
+ return (/\bapi\s*:\s*['"]([^'"]+)['"]/.exec(stripConfigComments(source))?.[1] ??
148
+ DEFAULT_API_ROOT);
16
149
  }
17
150
  export function normalizeComponentName(name) {
18
151
  return (name
@@ -25,15 +158,14 @@ export function normalizeComponentName(name) {
25
158
  export function parseComponentRoots(source) {
26
159
  if (!source)
27
160
  return DEFAULT_COMPONENT_ROOTS;
28
- const match = /\bcomponents\s*:\s*(\[[^\]]*\]|['"][^'"]+['"])/.exec(source);
161
+ const match = /\bcomponents\s*:\s*(\[[^\]]*\]|['"][^'"]+['"])/.exec(stripConfigComments(source));
29
162
  if (!match?.[1])
30
163
  return DEFAULT_COMPONENT_ROOTS;
31
164
  const literals = Array.from(match[1].matchAll(/['"]([^'"]+)['"]/g), (item) => item[1]);
32
165
  return literals.length > 0 ? literals : DEFAULT_COMPONENT_ROOTS;
33
166
  }
34
167
  export function parseImportRoot(source) {
35
- return (/importRoot\s*:\s*['"]([^'"]+)['"]/.exec(source ?? "")?.[1] ??
36
- DEFAULT_IMPORT_ROOT);
168
+ return (/importRoot\s*:\s*['"]([^'"]+)['"]/.exec(stripConfigComments(source))?.[1] ?? DEFAULT_IMPORT_ROOT);
37
169
  }
38
170
  export async function readConfigSource(workspaceRoot) {
39
171
  for (const candidate of CONFIG_FILE_CANDIDATES) {
@@ -100,9 +232,19 @@ export async function buildSnapshot(workspaceRoot) {
100
232
  componentMap.set(name, filePath);
101
233
  }
102
234
  const componentMetadata = new Map();
235
+ const componentSourceByFile = new Map();
236
+ await Promise.all(componentFiles.map(async (filePath) => {
237
+ try {
238
+ componentSourceByFile.set(filePath, await fsPromises.readFile(filePath, "utf8"));
239
+ }
240
+ catch {
241
+ // Ignored if file changed or unreadable
242
+ }
243
+ }));
103
244
  await Promise.all(Array.from(componentMap, async ([name, filePath]) => {
104
245
  try {
105
- const source = await fsPromises.readFile(filePath, "utf8");
246
+ const source = componentSourceByFile.get(filePath) ??
247
+ (await fsPromises.readFile(filePath, "utf8"));
106
248
  componentMetadata.set(name, analyzeComponentSource(source, {
107
249
  hasCompanionStyles: fs.existsSync(filePath.replace(/\.html$/i, ".css")),
108
250
  }));
@@ -112,7 +254,9 @@ export async function buildSnapshot(workspaceRoot) {
112
254
  }
113
255
  }));
114
256
  const htmlUsageByFile = new Map();
115
- const usageFiles = await findHtmlFiles([path.join(workspaceRoot, "src")]);
257
+ const srcRoot = path.join(workspaceRoot, "src");
258
+ const pagesRoot = path.resolve(workspaceRoot, parsePagesRoot(configSource));
259
+ const usageFiles = await findHtmlFiles(isPathInside(pagesRoot, srcRoot) ? [srcRoot] : [srcRoot, pagesRoot]);
116
260
  await Promise.all(usageFiles.map(async (filePath) => {
117
261
  try {
118
262
  htmlUsageByFile.set(filePath, await fsPromises.readFile(filePath, "utf8"));
@@ -130,7 +274,12 @@ export async function buildSnapshot(workspaceRoot) {
130
274
  componentMap,
131
275
  componentMetadata,
132
276
  importRoot: path.resolve(workspaceRoot, parseImportRoot(configSource)),
277
+ pagesRoot,
133
278
  htmlUsageByFile,
279
+ componentSourceByFile,
280
+ scopesName: parseScopesName(configSource),
281
+ scopesScriptBlocks: parseScriptBlocks(configSource),
282
+ preserve: parsePreserve(configSource),
134
283
  };
135
284
  }
136
285
  export function isPathInside(fsPath, root) {
@@ -138,7 +287,7 @@ export function isPathInside(fsPath, root) {
138
287
  return (relative === "" ||
139
288
  (!relative.startsWith("..") && !path.isAbsolute(relative)));
140
289
  }
141
- /** Is `fsPath` a Bascik config file (`bascik.config.ts`, `.js`, or `.mjs`)? */
290
+ /** Is `fsPath` a Bascik config file (`bascik.config.js`, `.mjs`, or `.ts`)? */
142
291
  export function isConfigFile(fsPath) {
143
292
  return CONFIG_FILE_CANDIDATES.includes(path.basename(fsPath));
144
293
  }
@@ -1 +1 @@
1
- {"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AAajC,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;CACpB,CAAC;AACF,MAAM,uBAAuB,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAClC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAEnC,gHAAgH;AAChH,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,OAAO,CACL,8BAA8B,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAC3E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAA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AAC,OAAO,CAChD,qBAAqB,EACrB,MAAM,CACP,CAAC;IACF,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACxE,MAAM,UAAU,GAAG,IAAI,MAAM,CAC3B,IAAI,oBAAoB,wCAAwC,EAChE,IAAI,CACL,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,MAAM,CAC1B,uBAAuB,eAAe,OAAO,EAC7C,GAAG,CACJ,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1D,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { Location, Position } from "vscode-languageserver";
2
+ import { TextDocument } from "vscode-languageserver-textdocument";
3
+ import { findCommentEnd } from "./component-usages.js";
4
+ import { type ProjectSnapshot } from "./project.js";
5
+ export { findCommentEnd };
6
+ /** One tag the compiler would read as a tag: outside comments, attribute values and raw-text bodies. */
7
+ export interface HtmlTag {
8
+ /** The tag name as written. */
9
+ name: string;
10
+ closing: boolean;
11
+ /** Offset of the `<`. */
12
+ start: number;
13
+ /** Offset of the first character of the name. */
14
+ nameStart: number;
15
+ /** Offset just past the closing `>`. */
16
+ end: number;
17
+ }
18
+ /**
19
+ * The tags of an HTML source in order, as a reader sees them: a comment, an attribute value, or the body of
20
+ * a `<script>`, `<style>` or `<textarea>` hides any tag text inside it, and a comment with no end hides
21
+ * nothing. Literal tags inside `<pre>`, `<code>` and `<template>` are tags. It places the cursor on a closing
22
+ * tag and finds a component's root element; which opening tags are usages is decided by
23
+ * `findComponentUsages`, which follows the compiler exactly. Linear time: the end of a tag body depends only
24
+ * on where its scan starts, so it is remembered per position.
25
+ */
26
+ export declare function scanHtmlTags(html: string): HtmlTag[];
27
+ export interface ReferencesRequest {
28
+ /** The requesting document, with its unsaved text. */
29
+ document: TextDocument;
30
+ fsPath: string;
31
+ position: Position;
32
+ includeDeclaration: boolean;
33
+ snapshot: ProjectSnapshot;
34
+ /** The text of every HTML file that can use a component, keyed by absolute path, unsaved buffers included. */
35
+ sources: Map<string, string>;
36
+ }
37
+ /** Is `fsPath` the file that defines a component, and which one? */
38
+ export declare function componentNameForFile(fsPath: string, snapshot: ProjectSnapshot): string | undefined;
39
+ /** The component a references request at `offset` asks about, or undefined. */
40
+ export declare function resolveReferencedComponent(text: string, offset: number, fsPath: string, snapshot: ProjectSnapshot): string | undefined;
41
+ /**
42
+ * Find All References for a component: one Location per opening tag that uses it, spanning the tag name,
43
+ * pages first, then component files, each by path and then position. With `includeDeclaration`, the
44
+ * component file's first line comes first. Anything that does not resolve to a component is an empty list.
45
+ */
46
+ export declare function createReferences(request: ReferencesRequest): Location[];
47
+ //# sourceMappingURL=references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACL,cAAc,EAGf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,wGAAwG;AACxG,MAAM,WAAW,OAAO;IACtB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;CACb;AAqBD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAuFpD;AAeD,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,QAAQ,EAAE,YAAY,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,QAAQ,EAAE,eAAe,CAAC;IAC1B,8GAA8G;IAC9G,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAKD,oEAAoE;AACpE,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,eAAe,GACxB,MAAM,GAAG,SAAS,CAMpB;AAED,+EAA+E;AAC/E,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,eAAe,GACxB,MAAM,GAAG,SAAS,CAkDpB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,QAAQ,EAAE,CAiEvE"}
@@ -0,0 +1,241 @@
1
+ import * as path from "node:path";
2
+ import { pathToFileURL } from "node:url";
3
+ import { TextDocument } from "vscode-languageserver-textdocument";
4
+ import { findCommentEnd, findComponentUsages, maskLikeCompiler, } from "./component-usages.js";
5
+ import { isInsideComponentRoots, normalizeComponentName, } from "./project.js";
6
+ export { findCommentEnd };
7
+ const RAW_TEXT_TAGS = new Set(["script", "style", "textarea"]);
8
+ const isTagNameStart = (code) => (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
9
+ const isTagNameChar = (code) => isTagNameStart(code) ||
10
+ (code >= 48 && code <= 57) ||
11
+ code === 95 ||
12
+ code === 45;
13
+ const isTagNameEnd = (code) => Number.isNaN(code) ||
14
+ code === 9 ||
15
+ code === 10 ||
16
+ code === 12 ||
17
+ code === 13 ||
18
+ code === 32 ||
19
+ code === 47 /* / */ ||
20
+ code === 62; /* > */
21
+ /**
22
+ * The tags of an HTML source in order, as a reader sees them: a comment, an attribute value, or the body of
23
+ * a `<script>`, `<style>` or `<textarea>` hides any tag text inside it, and a comment with no end hides
24
+ * nothing. Literal tags inside `<pre>`, `<code>` and `<template>` are tags. It places the cursor on a closing
25
+ * tag and finds a component's root element; which opening tags are usages is decided by
26
+ * `findComponentUsages`, which follows the compiler exactly. Linear time: the end of a tag body depends only
27
+ * on where its scan starts, so it is remembered per position.
28
+ */
29
+ export function scanHtmlTags(html) {
30
+ const tags = [];
31
+ const length = html.length;
32
+ // 0 = not scanned yet, -1 = no closing `>`, otherwise the index after `>`.
33
+ const tagEndFrom = new Int32Array(length + 1);
34
+ const visited = [];
35
+ const findTagEnd = (from) => {
36
+ let position = from;
37
+ let end = -1;
38
+ visited.length = 0;
39
+ while (position < length) {
40
+ const known = tagEndFrom[position];
41
+ if (known !== 0) {
42
+ end = known;
43
+ break;
44
+ }
45
+ visited.push(position);
46
+ const code = html.charCodeAt(position);
47
+ if (code === 62 /* > */) {
48
+ end = position + 1;
49
+ break;
50
+ }
51
+ if (code === 34 /* " */ || code === 39 /* ' */) {
52
+ const close = html.indexOf(html[position], position + 1);
53
+ if (close < 0)
54
+ break;
55
+ position = close + 1;
56
+ continue;
57
+ }
58
+ position++;
59
+ }
60
+ for (const index of visited)
61
+ tagEndFrom[index] = end;
62
+ return end;
63
+ };
64
+ // Where each raw-text closer was last found, so a run of unclosed openers does not rescan the rest.
65
+ const closerSearch = new Map();
66
+ const findCloser = (name, from) => {
67
+ const known = closerSearch.get(name);
68
+ if (known && known.from <= from && (known.at < 0 || known.at >= from))
69
+ return known.at;
70
+ const pattern = new RegExp(`</${name}\\s*>`, "gi");
71
+ pattern.lastIndex = from;
72
+ const match = pattern.exec(html);
73
+ const at = match ? match.index : -1;
74
+ closerSearch.set(name, { from, at });
75
+ return at;
76
+ };
77
+ // After a comment with no end, no later comment can end either, so none is looked for.
78
+ let comments = true;
79
+ let cursor = 0;
80
+ while (cursor < length) {
81
+ const open = html.indexOf("<", cursor);
82
+ if (open < 0)
83
+ break;
84
+ if (comments && html.startsWith("<!--", open)) {
85
+ const end = findCommentEnd(html, open);
86
+ if (end < 0)
87
+ comments = false;
88
+ cursor = end < 0 ? open + 4 : end;
89
+ continue;
90
+ }
91
+ const closing = html.charCodeAt(open + 1) === 47; /* / */
92
+ const nameStart = open + (closing ? 2 : 1);
93
+ if (!isTagNameStart(html.charCodeAt(nameStart))) {
94
+ cursor = open + 1;
95
+ continue;
96
+ }
97
+ let nameEnd = nameStart + 1;
98
+ while (nameEnd < length && isTagNameChar(html.charCodeAt(nameEnd)))
99
+ nameEnd++;
100
+ const end = findTagEnd(nameEnd);
101
+ if (end < 0 || !isTagNameEnd(html.charCodeAt(nameEnd))) {
102
+ cursor = open + 1;
103
+ continue;
104
+ }
105
+ const name = html.slice(nameStart, nameEnd);
106
+ tags.push({ name, closing, start: open, nameStart, end });
107
+ cursor = end;
108
+ const lower = name.toLowerCase();
109
+ if (!closing &&
110
+ RAW_TEXT_TAGS.has(lower) &&
111
+ !/\/\s*>$/.test(html.slice(open, end))) {
112
+ const closer = findCloser(lower, end);
113
+ if (closer >= 0)
114
+ cursor = closer;
115
+ }
116
+ }
117
+ return tags;
118
+ }
119
+ /** The leading `<!-- @bascik` doc comment's `[start, end)`, when the file starts with one. */
120
+ function findDocComment(html) {
121
+ const start = html.search(/\S/);
122
+ if (start < 0 || !html.startsWith("<!--", start))
123
+ return undefined;
124
+ if (!/^<!--\s*@bascik(?:\s|-->|$)/.test(html.slice(start, start + 64)))
125
+ return undefined;
126
+ const end = findCommentEnd(html, start);
127
+ return [start, end < 0 ? html.length : end];
128
+ }
129
+ /** Elements that may sit ahead of a component's root element without being it. */
130
+ const NON_ROOT_TAGS = new Set(["script", "style", "link", "meta"]);
131
+ const normalize = (fsPath) => path.resolve(fsPath).replace(/\\/g, "/");
132
+ /** Is `fsPath` the file that defines a component, and which one? */
133
+ export function componentNameForFile(fsPath, snapshot) {
134
+ if (!isInsideComponentRoots(normalize(fsPath), snapshot.componentRoots))
135
+ return undefined;
136
+ const name = normalizeComponentName(fsPath);
137
+ const defined = snapshot.componentMap.get(name);
138
+ return defined && normalize(defined) === normalize(fsPath) ? name : undefined;
139
+ }
140
+ /** The component a references request at `offset` asks about, or undefined. */
141
+ export function resolveReferencedComponent(text, offset, fsPath, snapshot) {
142
+ const tags = scanHtmlTags(text);
143
+ // (a) A component tag name, opening or closing, wins wherever it is. An opening tag counts where the
144
+ // compiler expands it; a closing tag counts outside what the compiler masks.
145
+ const masked = maskLikeCompiler(text);
146
+ const opening = findComponentUsages(text, new Set(snapshot.componentMap.keys()), masked).find((usage) => offset >= usage.nameStart && offset <= usage.nameEnd);
147
+ if (opening)
148
+ return opening.name;
149
+ const closing = tags.find((tag) => tag.closing &&
150
+ offset >= tag.nameStart &&
151
+ offset <= tag.nameStart + tag.name.length &&
152
+ masked.startsWith(tag.name, tag.nameStart));
153
+ if (closing) {
154
+ const name = closing.name.toLowerCase();
155
+ if (snapshot.componentMap.has(name))
156
+ return name;
157
+ }
158
+ // (b) A line of the component's own file that identifies it.
159
+ const ownName = componentNameForFile(fsPath, snapshot);
160
+ if (!ownName)
161
+ return undefined;
162
+ const lineOf = (at) => {
163
+ let line = 0;
164
+ for (let i = text.indexOf("\n"); i >= 0 && i < at; i = text.indexOf("\n", i + 1))
165
+ line++;
166
+ return line;
167
+ };
168
+ const cursorLine = lineOf(offset);
169
+ if (cursorLine === 0)
170
+ return ownName;
171
+ const docComment = findDocComment(text);
172
+ if (docComment && offset >= docComment[0] && offset <= docComment[1])
173
+ return ownName;
174
+ const root = tags.find((tag) => !tag.closing && !NON_ROOT_TAGS.has(tag.name.toLowerCase()));
175
+ if (root &&
176
+ cursorLine >= lineOf(root.start) &&
177
+ cursorLine <= lineOf(root.end - 1))
178
+ return ownName;
179
+ return undefined;
180
+ }
181
+ /**
182
+ * Find All References for a component: one Location per opening tag that uses it, spanning the tag name,
183
+ * pages first, then component files, each by path and then position. With `includeDeclaration`, the
184
+ * component file's first line comes first. Anything that does not resolve to a component is an empty list.
185
+ */
186
+ export function createReferences(request) {
187
+ const { document, fsPath, position, snapshot, sources } = request;
188
+ if (document.languageId !== "html" || !fsPath.toLowerCase().endsWith(".html"))
189
+ return [];
190
+ const name = resolveReferencedComponent(document.getText(), document.offsetAt(position), fsPath, snapshot);
191
+ if (!name)
192
+ return [];
193
+ const componentPath = snapshot.componentMap.get(name);
194
+ if (!componentPath)
195
+ return [];
196
+ const found = [];
197
+ const names = new Set(snapshot.componentMap.keys());
198
+ for (const [file, text] of sources) {
199
+ const usages = findComponentUsages(text, names).filter((usage) => usage.name === name);
200
+ if (usages.length === 0)
201
+ continue;
202
+ const lines = TextDocument.create("file:///", "html", 0, text);
203
+ const uri = pathToFileURL(file).toString();
204
+ found.push({
205
+ file: normalize(file),
206
+ isComponent: isInsideComponentRoots(normalize(file), snapshot.componentRoots),
207
+ locations: usages.map((usage) => ({
208
+ uri,
209
+ range: {
210
+ start: lines.positionAt(usage.nameStart),
211
+ end: lines.positionAt(usage.nameEnd),
212
+ },
213
+ })),
214
+ });
215
+ }
216
+ found.sort((left, right) => left.isComponent !== right.isComponent
217
+ ? left.isComponent
218
+ ? 1
219
+ : -1
220
+ : left.file < right.file
221
+ ? -1
222
+ : left.file > right.file
223
+ ? 1
224
+ : 0);
225
+ const locations = found.flatMap((entry) => entry.locations);
226
+ if (!request.includeDeclaration)
227
+ return locations;
228
+ const declarationText = sources.get(componentPath) ?? "";
229
+ const firstLineEnd = declarationText.search(/\r?\n|\r|$/);
230
+ return [
231
+ {
232
+ uri: pathToFileURL(componentPath).toString(),
233
+ range: {
234
+ start: { line: 0, character: 0 },
235
+ end: { line: 0, character: Math.max(0, firstLineEnd) },
236
+ },
237
+ },
238
+ ...locations,
239
+ ];
240
+ }
241
+ //# sourceMappingURL=references.js.map