@intlayer/lsp 9.0.0-canary.12 → 9.0.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 (35) hide show
  1. package/dist/esm/callers/patterns.mjs.map +1 -1
  2. package/dist/esm/dictionaryUtils.mjs +1 -1
  3. package/dist/esm/dictionaryUtils.mjs.map +1 -1
  4. package/dist/esm/findFieldInFile.mjs.map +1 -1
  5. package/dist/esm/findKeyAtOffset.mjs.map +1 -1
  6. package/dist/esm/findKeyInContentFile.mjs +3 -3
  7. package/dist/esm/findKeyInContentFile.mjs.map +1 -1
  8. package/dist/esm/findTCallAtOffset.mjs.map +1 -1
  9. package/dist/esm/findUsageFieldAtOffset.mjs.map +1 -1
  10. package/dist/esm/index.mjs +32 -5
  11. package/dist/esm/index.mjs.map +1 -1
  12. package/dist/esm/oxcUtils.mjs.map +1 -1
  13. package/dist/esm/usageAnalyzer.mjs +86 -23
  14. package/dist/esm/usageAnalyzer.mjs.map +1 -1
  15. package/dist/types/callers/index.d.ts +0 -3
  16. package/dist/types/callers/patterns.d.ts +20 -20
  17. package/dist/types/callers/patterns.d.ts.map +1 -1
  18. package/dist/types/dictionaryUtils.d.ts +0 -1
  19. package/dist/types/dictionaryUtils.d.ts.map +1 -1
  20. package/dist/types/findFieldInFile.d.ts +18 -19
  21. package/dist/types/findFieldInFile.d.ts.map +1 -1
  22. package/dist/types/findKeyAtOffset.d.ts +15 -15
  23. package/dist/types/findKeyAtOffset.d.ts.map +1 -1
  24. package/dist/types/findKeyInContentFile.d.ts +20 -20
  25. package/dist/types/findKeyInContentFile.d.ts.map +1 -1
  26. package/dist/types/findTCallAtOffset.d.ts +15 -15
  27. package/dist/types/findTCallAtOffset.d.ts.map +1 -1
  28. package/dist/types/findUsageFieldAtOffset.d.ts +14 -14
  29. package/dist/types/findUsageFieldAtOffset.d.ts.map +1 -1
  30. package/dist/types/index.d.ts +1 -1
  31. package/dist/types/oxcUtils.d.ts +22 -22
  32. package/dist/types/oxcUtils.d.ts.map +1 -1
  33. package/dist/types/usageAnalyzer.d.ts +95 -83
  34. package/dist/types/usageAnalyzer.d.ts.map +1 -1
  35. package/package.json +11 -11
@@ -1,21 +1,21 @@
1
1
  //#region src/oxcUtils.d.ts
2
2
  type OxcNode = Record<string, unknown>;
3
3
  /**
4
- * Parse `text` into an Oxc program AST.
5
- * Returns null when the parse completely fails (e.g. unsupported syntax).
6
- * Oxc is generally resilient to partial/in-progress edits and still returns a
7
- * usable AST alongside error diagnostics, so this is rare.
8
- */
4
+ * Parse `text` into an Oxc program AST.
5
+ * Returns null when the parse completely fails (e.g. unsupported syntax).
6
+ * Oxc is generally resilient to partial/in-progress edits and still returns a
7
+ * usable AST alongside error diagnostics, so this is rare.
8
+ */
9
9
  declare const parseText: (text: string) => OxcNode | null;
10
10
  /**
11
- * Depth-first walk of an Oxc AST. Visitor is called for every node that has
12
- * a `type` property; returning `true` prunes that subtree.
13
- */
11
+ * Depth-first walk of an Oxc AST. Visitor is called for every node that has
12
+ * a `type` property; returning `true` prunes that subtree.
13
+ */
14
14
  declare const walkAst: (node: unknown, visitor: (node: OxcNode) => boolean | void) => void;
15
15
  /**
16
- * Build a child → parent reference map for upward traversal.
17
- * Only AST-node-valued properties are followed; primitives are ignored.
18
- */
16
+ * Build a child → parent reference map for upward traversal.
17
+ * Only AST-node-valued properties are followed; primitives are ignored.
18
+ */
19
19
  declare const buildParentMap: (root: OxcNode) => Map<OxcNode, OxcNode>;
20
20
  /** Byte offset of the node's start. */
21
21
  declare const nodeStart: (node: OxcNode) => number;
@@ -24,27 +24,27 @@ declare const nodeEnd: (node: OxcNode) => number;
24
24
  /** Returns `true` when `offset` falls inside the node's span (inclusive). */
25
25
  declare const nodeContainsOffset: (node: OxcNode, offset: number) => boolean;
26
26
  /**
27
- * Returns `true` for nodes that carry a static string value:
28
- * Literal / StringLiteral, and no-substitution TemplateLiteral.
29
- */
27
+ * Returns `true` for nodes that carry a static string value:
28
+ * Literal / StringLiteral, and no-substitution TemplateLiteral.
29
+ */
30
30
  declare const isStringLiteralNode: (node: OxcNode) => boolean;
31
31
  /**
32
- * Extract the static string value from a literal node, or null when the node
33
- * is not a static string.
34
- */
32
+ * Extract the static string value from a literal node, or null when the node
33
+ * is not a static string.
34
+ */
35
35
  declare const getStaticStringValue: (node: OxcNode | undefined) => string | null;
36
36
  /** Extract the string value from the Nth argument of a call expression. */
37
37
  declare const getStringArgAt: (callNode: OxcNode, index: number) => string | null;
38
38
  /** Extract the string value from the first argument of a call expression. */
39
39
  declare const getFirstStringArg: (callExpressionNode: OxcNode) => string | null;
40
40
  /**
41
- * Find the property node named `propertyName` inside an ObjectExpression.
42
- */
41
+ * Find the property node named `propertyName` inside an ObjectExpression.
42
+ */
43
43
  declare const getObjectPropertyNode: (objectExpression: OxcNode | undefined, propertyName: string) => OxcNode | null;
44
44
  /**
45
- * Read a static string property from an ObjectExpression argument,
46
- * e.g. the `namespace` of `useI18n({ namespace: 'about' })`.
47
- */
45
+ * Read a static string property from an ObjectExpression argument,
46
+ * e.g. the `namespace` of `useI18n({ namespace: 'about' })`.
47
+ */
48
48
  declare const getObjectPropertyString: (objectExpression: OxcNode | undefined, propertyName: string) => string | null;
49
49
  /** Get the identifier or string name of an object-property key node. */
50
50
  declare const getPropertyKeyName: (keyNode: OxcNode | undefined) => string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"oxcUtils.d.ts","names":[],"sources":["../../src/oxcUtils.ts"],"mappings":";KAEY,OAAA,GAAU,MAAA;AAAtB;;;;;AAQA;AARA,cAQa,SAAA,GAAa,IAAA,aAAe,OAAA;;;;AAczC;cAAa,OAAA,GACX,IAAA,WAEA,OAAA,GAAU,IAAA,EAAM,OAAA;;;;;cAyBL,cAAA,GAAkB,IAAA,EAAM,OAAA,KAAU,GAAA,CAAI,OAAA,EAAS,OAAA;;cA4B/C,SAAA,GAAa,IAAA,EAAM,OAAA;;cAMnB,OAAA,GAAW,IAAA,EAAM,OAAA;;cAMjB,kBAAA,GAAsB,IAAA,EAAM,OAAA,EAAS,MAAA;;;;;cAOrC,mBAAA,GAAuB,IAAA,EAAM,OAAA;;;;;cAkB7B,oBAAA,GACX,IAAA,EAAM,OAAA;;cA8BK,cAAA,GACX,QAAA,EAAU,OAAA,EACV,KAAA;;cAUW,iBAAA,GAAqB,kBAAA,EAAoB,OAAA;;;;cAMzC,qBAAA,GACX,gBAAA,EAAkB,OAAA,cAClB,YAAA,aACC,OAAA;AAnFH;;;;AAAA,cA+Ga,uBAAA,GACX,gBAAA,EAAkB,OAAA,cAClB,YAAA;AA3GF;AAAA,cAqHa,kBAAA,GACX,OAAA,EAAS,OAAA"}
1
+ {"version":3,"file":"oxcUtils.d.ts","names":[],"sources":["../../src/oxcUtils.ts"],"mappings":";KAEY,UAAU;;;;;;;cAQT,YAAa,iBAAe;;;;;cAc5B,UACX,eAEA,UAAU,MAAM;;;;;cAyBL,iBAAkB,MAAM,YAAU,IAAI,SAAS;;cA4B/C,YAAa,MAAM;;cAMnB,UAAW,MAAM;;cAMjB,qBAAsB,MAAM,SAAS;;;;;cAOrC,sBAAuB,MAAM;;;;;cAkB7B,uBACX,MAAM;;cA8BK,iBACX,UAAU,SACV;;cAUW,oBAAqB,oBAAoB;;;;cAMzC,wBACX,kBAAkB,qBAClB,yBACC;;;;;cA4BU,0BACX,kBAAkB,qBAClB;;cAUW,qBACX,SAAS"}
@@ -1,128 +1,140 @@
1
1
  import { OxcNode } from "./oxcUtils.js";
2
-
3
2
  //#region src/usageAnalyzer.d.ts
4
3
  /** How a message usage appears in source code. */
5
4
  type MessageUsageKind = "call" | "member" | "destructure" | "jsx" | "tagged-template" | "namespace";
6
5
  /**
7
- * One resolved translation usage inside a source file: which dictionary and
8
- * field it reads, and the text span it occupies.
9
- */
6
+ * One resolved translation usage inside a source file: which dictionary and
7
+ * field it reads, and the text span it occupies.
8
+ */
10
9
  type MessageUsage = {
11
- /** The intlayer dictionary key the usage reads from. */dictionaryKey: string;
10
+ /** The intlayer dictionary key the usage reads from. */
11
+ dictionaryKey: string;
12
12
  /**
13
- * Path of content fields from the dictionary root. Empty for
14
- * dictionary-level usages (`namespace` kind, or a bare content variable).
15
- */
13
+ * Path of content fields from the dictionary root. Empty for
14
+ * dictionary-level usages (`namespace` kind, or a bare content variable).
15
+ */
16
16
  fieldPath: string[];
17
17
  /**
18
- * Spans of each `fieldPath` segment, aligned by index, when the segments
19
- * are addressable in source (member chains). Used to trim the path to the
20
- * segment under the cursor.
21
- */
18
+ * Spans of each `fieldPath` segment, aligned by index, when the segments
19
+ * are addressable in source (member chains). Used to trim the path to the
20
+ * segment under the cursor.
21
+ */
22
22
  fieldSpans?: {
23
23
  start: number;
24
24
  end: number;
25
- }[]; /** Start offset of the usage expression. */
26
- start: number; /** End offset of the usage expression. */
25
+ }[];
26
+ /** Start offset of the usage expression. */
27
+ start: number;
28
+ /** End offset of the usage expression. */
27
29
  end: number;
28
- kind: MessageUsageKind; /** The caller that produced the usage, e.g. `'useTranslations'`. */
29
- callerName: string; /** The library the caller belongs to, e.g. `'next-intl'` or `'intlayer'`. */
30
- library: string; /** Module specifier the caller was imported from, when resolvable. */
30
+ kind: MessageUsageKind;
31
+ /** The caller that produced the usage, e.g. `'useTranslations'`. */
32
+ callerName: string;
33
+ /** The library the caller belongs to, e.g. `'next-intl'` or `'intlayer'`. */
34
+ library: string;
35
+ /** Module specifier the caller was imported from, when resolvable. */
31
36
  moduleSource?: string;
32
37
  /**
33
- * `true` for `member` usages that are a bare reference to a bound variable
34
- * (`{greet}` in JSX after `const { greet } = useIntlayer(…)`) — the field
35
- * name itself is not spelled at the usage site. Excluded from
36
- * find-references results but kept for decorations and hover.
37
- */
38
+ * `true` for `member` usages that are a bare reference to a bound variable
39
+ * (`{greet}` in JSX after `const { greet } = useIntlayer(…)`) — the field
40
+ * name itself is not spelled at the usage site. Excluded from
41
+ * find-references results but kept for decorations and hover.
42
+ */
38
43
  isBareReference?: boolean;
39
44
  };
40
45
  /**
41
- * Analyse a source file and return every resolvable translation usage:
42
- * base-intlayer content access and all compat-library forms (translation
43
- * functions, self calls, JSX message components, tagged templates).
44
- *
45
- * Pure and self-contained (oxc parse only) — shared by the LSP handlers and
46
- * the VS Code extension providers/decorations.
47
- *
48
- * @param text - Full source text (a script: TS/TSX or an extracted SFC block).
49
- * @returns Usages ordered by start offset.
50
- */
46
+ * Analyse a source file and return every resolvable translation usage:
47
+ * base-intlayer content access and all compat-library forms (translation
48
+ * functions, self calls, JSX message components, tagged templates).
49
+ *
50
+ * Pure and self-contained (oxc parse only) — shared by the LSP handlers and
51
+ * the VS Code extension providers/decorations.
52
+ *
53
+ * @param text - Full source text (a script: TS/TSX or an extracted SFC block).
54
+ * @returns Usages ordered by start offset.
55
+ */
51
56
  declare const collectMessageUsages: (text: string) => MessageUsage[];
52
57
  /**
53
- * Resolve the dictionary key declared by a single call-expression node when
54
- * it matches any registered non-self caller (`useIntlayer("key")`,
55
- * `useI18n({ namespace })`, …). Used for on-the-fly checks where the full
56
- * file analysis is not needed (e.g. completion context).
57
- *
58
- * @param callNode - A candidate CallExpression node.
59
- */
58
+ * Resolve the dictionary key declared by a single call-expression node when
59
+ * it matches any registered non-self caller (`useIntlayer("key")`,
60
+ * `useI18n({ namespace })`, …). Used for on-the-fly checks where the full
61
+ * file analysis is not needed (e.g. completion context).
62
+ *
63
+ * @param callNode - A candidate CallExpression node.
64
+ */
60
65
  declare const matchCallNamespace: (callNode: OxcNode) => string | null;
61
66
  /**
62
- * A call site declaring which dictionary a caller reads
63
- * (`useIntlayer("home")`, `useI18n({ namespace: 'home' })`), with the spans
64
- * needed to anchor diagnostics and cursor checks.
65
- */
67
+ * A call site declaring which dictionary a caller reads
68
+ * (`useIntlayer("home")`, `useI18n({ namespace: 'home' })`), with the spans
69
+ * needed to anchor diagnostics and cursor checks.
70
+ */
66
71
  type NamespaceReference = {
67
72
  dictionaryKey: string;
68
73
  callerName: string;
69
- library: string; /** Span of the whole call expression. */
74
+ library: string;
75
+ /** Span of the whole call expression. */
70
76
  callStart: number;
71
- callEnd: number; /** Span of the matched callee name (identifier or method property). */
77
+ callEnd: number;
78
+ /** Span of the matched callee name (identifier or method property). */
72
79
  calleeStart: number;
73
- calleeEnd: number; /** Span of the namespace argument (string literal or option value). */
80
+ calleeEnd: number;
81
+ /** Span of the namespace argument (string literal or option value). */
74
82
  namespaceStart: number;
75
83
  namespaceEnd: number;
76
84
  };
77
85
  /**
78
- * Collect every call site with an addressable namespace argument (positional
79
- * or options property) resolving to a static string. Powers the
80
- * unknown-dictionary diagnostics and `findKeyAtOffset`.
81
- *
82
- * Self callers (`formatMessage`, lingui `t`/`_`) don't declare a namespace at
83
- * the call site and are excluded.
84
- *
85
- * @param text - Full source text.
86
- */
86
+ * Collect every call site with an addressable namespace argument (positional
87
+ * or options property) resolving to a static string. Powers the
88
+ * unknown-dictionary diagnostics and `findKeyAtOffset`.
89
+ *
90
+ * Self callers (`formatMessage`, lingui `t`/`_`) don't declare a namespace at
91
+ * the call site and are excluded.
92
+ *
93
+ * @param text - Full source text.
94
+ */
87
95
  declare const collectNamespaceReferences: (text: string) => NamespaceReference[];
88
96
  /**
89
- * A source variable bound to a dictionary by a caller declaration:
90
- * dictionary content (or a field subtree of it) for `content` callers, or a
91
- * translation function for `return-value` / `destructured-t` callers.
92
- */
97
+ * A source variable bound to a dictionary by a caller declaration:
98
+ * dictionary content (or a field subtree of it) for `content` callers, or a
99
+ * translation function for `return-value` / `destructured-t` callers.
100
+ */
93
101
  type CallerVariableBinding = {
94
- /** Local variable name. */variableName: string; /** The dictionary the variable reads from. */
102
+ /** Local variable name. */
103
+ variableName: string;
104
+ /** The dictionary the variable reads from. */
95
105
  dictionaryKey: string;
96
106
  /**
97
- * Field path from the dictionary root the variable points at (content
98
- * bindings), or the key prefix applied to every call (translator bindings).
99
- */
100
- basePath: string[]; /** Whether the variable holds content or a translation function. */
101
- bindingKind: "content" | "translator"; /** The caller that created the binding. */
107
+ * Field path from the dictionary root the variable points at (content
108
+ * bindings), or the key prefix applied to every call (translator bindings).
109
+ */
110
+ basePath: string[];
111
+ /** Whether the variable holds content or a translation function. */
112
+ bindingKind: "content" | "translator";
113
+ /** The caller that created the binding. */
102
114
  callerName: string;
103
115
  library: string;
104
116
  };
105
117
  /**
106
- * Collect every variable bound to a dictionary in the file. Used by consumers
107
- * that scan non-script regions (Vue/Angular templates) for references to
108
- * those variables, or that need to know which dictionaries a file consumes.
109
- *
110
- * @param text - Full source text (a script: TS/TSX or an extracted SFC block).
111
- */
118
+ * Collect every variable bound to a dictionary in the file. Used by consumers
119
+ * that scan non-script regions (Vue/Angular templates) for references to
120
+ * those variables, or that need to know which dictionaries a file consumes.
121
+ *
122
+ * @param text - Full source text (a script: TS/TSX or an extracted SFC block).
123
+ */
112
124
  declare const collectCallerBindings: (text: string) => CallerVariableBinding[];
113
125
  /**
114
- * Find the most specific translation usage at `offset`.
115
- *
116
- * For member chains the field path is trimmed to the segment under the
117
- * cursor: hovering `section` in `content.section.title` yields
118
- * `['section']`, not the full chain.
119
- *
120
- * Dictionary-level `namespace` usages are only returned when no field-level
121
- * usage matches the offset.
122
- *
123
- * @param text - Full source text.
124
- * @param offset - Cursor offset in `text`.
125
- */
126
+ * Find the most specific translation usage at `offset`.
127
+ *
128
+ * For member chains the field path is trimmed to the segment under the
129
+ * cursor: hovering `section` in `content.section.title` yields
130
+ * `['section']`, not the full chain.
131
+ *
132
+ * Dictionary-level `namespace` usages are only returned when no field-level
133
+ * usage matches the offset.
134
+ *
135
+ * @param text - Full source text.
136
+ * @param offset - Cursor offset in `text`.
137
+ */
126
138
  declare const findMessageUsageAtOffset: (text: string, offset: number) => MessageUsage | null;
127
139
  //#endregion
128
140
  export { CallerVariableBinding, MessageUsage, MessageUsageKind, NamespaceReference, collectCallerBindings, collectMessageUsages, collectNamespaceReferences, findMessageUsageAtOffset, matchCallNamespace };
@@ -1 +1 @@
1
- {"version":3,"file":"usageAnalyzer.d.ts","names":[],"sources":["../../src/usageAnalyzer.ts"],"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EA;EACA;;;;;;;;;cAUW,wBACX,iBACC;;;;;;;;;;;;;;cAkEU,2BACX,cACA,mBACC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/lsp",
3
- "version": "9.0.0-canary.12",
3
+ "version": "9.0.1",
4
4
  "private": false,
5
5
  "description": "Intlayer Language Server. Handle LSP to help IDE and AI agent to use Intlayer",
6
6
  "keywords": [
@@ -83,23 +83,23 @@
83
83
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
84
84
  },
85
85
  "dependencies": {
86
- "@intlayer/config": "9.0.0-canary.12",
87
- "@intlayer/engine": "9.0.0-canary.12",
88
- "@intlayer/types": "9.0.0-canary.12",
89
- "@intlayer/unmerged-dictionaries-entry": "9.0.0-canary.12",
90
- "oxc-parser": "0.134.0",
91
- "vscode-languageserver": "10.0.0",
86
+ "@intlayer/config": "9.0.1",
87
+ "@intlayer/engine": "9.0.1",
88
+ "@intlayer/types": "9.0.1",
89
+ "@intlayer/unmerged-dictionaries-entry": "9.0.1",
90
+ "oxc-parser": "0.141.0",
91
+ "vscode-languageserver": "10.1.0",
92
92
  "vscode-languageserver-textdocument": "1.0.12"
93
93
  },
94
94
  "devDependencies": {
95
- "@types/node": "25.9.4",
95
+ "@types/node": "26.1.1",
96
96
  "@utils/ts-config": "1.0.4",
97
97
  "@utils/ts-config-types": "1.0.4",
98
98
  "@utils/tsdown-config": "1.0.4",
99
99
  "rimraf": "6.1.3",
100
- "tsdown": "0.21.10",
101
- "typescript": "6.0.3",
102
- "vitest": "4.1.9"
100
+ "tsdown": "0.22.13",
101
+ "typescript": "7.0.2",
102
+ "vitest": "4.1.10"
103
103
  },
104
104
  "engines": {
105
105
  "node": ">=14.18"