@intlayer/vue-compiler 8.6.9 → 8.7.0-canary.0

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.
@@ -0,0 +1,89 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ let _vue_compiler_sfc = require("@vue/compiler-sfc");
4
+ _vue_compiler_sfc = require_runtime.__toESM(_vue_compiler_sfc);
5
+
6
+ //#region src/extractVueFieldUsage.ts
7
+ /**
8
+ * Extracts intlayer dictionary field usage from a Vue SFC for a set of
9
+ * plain variable bindings (i.e. `const content = useIntlayer('key')`).
10
+ *
11
+ * Two access patterns are recognised:
12
+ *
13
+ * 1. `varName.value.fieldName` in script blocks
14
+ * Vue's `useIntlayer` returns a reactive `Ref<Content>`, so fields are
15
+ * accessed one level deeper via `.value`.
16
+ *
17
+ * 2. `varName.fieldName` in the template block
18
+ * Inside `<template>`, Vue automatically unwraps top-level refs, so
19
+ * fields are accessed directly without `.value`.
20
+ *
21
+ * The template block is extracted via `@vue/compiler-sfc` so that nested
22
+ * `<template v-for>` / `<template v-if>` tags do not confuse the parser.
23
+ * Falls back to a greedy regex when the package is unavailable.
24
+ */
25
+ /** Escapes special regex characters in a string used as a regex literal. */
26
+ const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
27
+ /**
28
+ * Splits a Vue SFC source string into its script and template regions.
29
+ *
30
+ * Uses `@vue/compiler-sfc` to get exact character offsets so that nested
31
+ * `<template>` tags (used by Vue directives like `v-for` / `v-if`) never
32
+ * cause the template region to be mis-identified.
33
+ */
34
+ const splitVueSfc = (code) => {
35
+ try {
36
+ const { descriptor } = _vue_compiler_sfc.default.parse(code);
37
+ const templateSource = descriptor.template?.content ?? "";
38
+ const scriptParts = [];
39
+ if (descriptor.script?.content) scriptParts.push(descriptor.script.content);
40
+ if (descriptor.scriptSetup?.content) scriptParts.push(descriptor.scriptSetup.content);
41
+ return {
42
+ scriptSource: scriptParts.join("\n"),
43
+ templateSource
44
+ };
45
+ } catch {
46
+ const templateMatch = /<template(?:[^>]*)>([\s\S]*)<\/template>/i.exec(code);
47
+ const templateSource = templateMatch ? templateMatch[1] : "";
48
+ return {
49
+ scriptSource: code.replace(/<template[\s\S]*<\/template>/gi, ""),
50
+ templateSource
51
+ };
52
+ }
53
+ };
54
+ /**
55
+ * Analyzes a Vue SFC source string and returns the top-level content field
56
+ * names that are statically accessed for each plain intlayer variable binding.
57
+ *
58
+ * @param code - Full `.vue` file source.
59
+ * @param plainVariables - List of plain variable bindings to analyse.
60
+ * @returns Map from dictionary key to the set of accessed top-level field names.
61
+ * If no fields can be determined for a given key it is omitted from the
62
+ * map so the caller can fall back to `'all'`.
63
+ */
64
+ const extractVueIntlayerFieldUsage = (code, plainVariables) => {
65
+ const result = /* @__PURE__ */ new Map();
66
+ if (plainVariables.length === 0) return result;
67
+ const { scriptSource, templateSource } = splitVueSfc(code);
68
+ for (const { variableName, dictionaryKey } of plainVariables) {
69
+ const fields = /* @__PURE__ */ new Set();
70
+ const esc = escapeRegExp(variableName);
71
+ const scriptRe = new RegExp(`\\b${esc}\\.value\\.(\\w+)`, "g");
72
+ scriptRe.lastIndex = 0;
73
+ for (let m = scriptRe.exec(scriptSource); m !== null; m = scriptRe.exec(scriptSource)) {
74
+ const field = m[1];
75
+ if (field !== "value") fields.add(field);
76
+ }
77
+ if (templateSource) {
78
+ const templateRe = new RegExp(`\\b${esc}\\.(\\w+)`, "g");
79
+ templateRe.lastIndex = 0;
80
+ for (let m = templateRe.exec(templateSource); m !== null; m = templateRe.exec(templateSource)) fields.add(m[1]);
81
+ }
82
+ if (fields.size > 0) result.set(dictionaryKey, fields);
83
+ }
84
+ return result;
85
+ };
86
+
87
+ //#endregion
88
+ exports.extractVueIntlayerFieldUsage = extractVueIntlayerFieldUsage;
89
+ //# sourceMappingURL=extractVueFieldUsage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractVueFieldUsage.cjs","names":["vueSfc"],"sources":["../../src/extractVueFieldUsage.ts"],"sourcesContent":["/**\n * Extracts intlayer dictionary field usage from a Vue SFC for a set of\n * plain variable bindings (i.e. `const content = useIntlayer('key')`).\n *\n * Two access patterns are recognised:\n *\n * 1. `varName.value.fieldName` in script blocks\n * Vue's `useIntlayer` returns a reactive `Ref<Content>`, so fields are\n * accessed one level deeper via `.value`.\n *\n * 2. `varName.fieldName` in the template block\n * Inside `<template>`, Vue automatically unwraps top-level refs, so\n * fields are accessed directly without `.value`.\n *\n * The template block is extracted via `@vue/compiler-sfc` so that nested\n * `<template v-for>` / `<template v-if>` tags do not confuse the parser.\n * Falls back to a greedy regex when the package is unavailable.\n */\n\nimport vueSfc from '@vue/compiler-sfc';\n\n/** Escapes special regex characters in a string used as a regex literal. */\nconst escapeRegExp = (str: string): string =>\n str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/** Input descriptor for a single plain variable binding. */\nexport type PlainVariableInfo = {\n /** The local variable name in the script (`content` in `const content = useIntlayer(…)`). */\n variableName: string;\n /** The intlayer dictionary key passed to `useIntlayer`. */\n dictionaryKey: string;\n};\n\n/**\n * Splits a Vue SFC source string into its script and template regions.\n *\n * Uses `@vue/compiler-sfc` to get exact character offsets so that nested\n * `<template>` tags (used by Vue directives like `v-for` / `v-if`) never\n * cause the template region to be mis-identified.\n */\nconst splitVueSfc = (\n code: string\n): { scriptSource: string; templateSource: string } => {\n try {\n const { descriptor } = (\n vueSfc.parse as (src: string) => { descriptor: any }\n )(code);\n\n const templateSource: string = descriptor.template?.content ?? '';\n\n const scriptParts: string[] = [];\n if (descriptor.script?.content) scriptParts.push(descriptor.script.content);\n if (descriptor.scriptSetup?.content)\n scriptParts.push(descriptor.scriptSetup.content);\n const scriptSource = scriptParts.join('\\n');\n\n return { scriptSource, templateSource };\n } catch {\n // @vue/compiler-sfc not available or parse failed.\n // Fall back: use a greedy regex to capture everything between the\n // outermost <template> tags (robust against nested tags unlike the\n // non-greedy variant).\n const templateMatch = /<template(?:[^>]*)>([\\s\\S]*)<\\/template>/i.exec(\n code\n );\n const templateSource = templateMatch ? templateMatch[1] : '';\n const scriptSource = code.replace(/<template[\\s\\S]*<\\/template>/gi, '');\n return { scriptSource, templateSource };\n }\n};\n\n/**\n * Analyzes a Vue SFC source string and returns the top-level content field\n * names that are statically accessed for each plain intlayer variable binding.\n *\n * @param code - Full `.vue` file source.\n * @param plainVariables - List of plain variable bindings to analyse.\n * @returns Map from dictionary key to the set of accessed top-level field names.\n * If no fields can be determined for a given key it is omitted from the\n * map so the caller can fall back to `'all'`.\n */\nexport const extractVueIntlayerFieldUsage = (\n code: string,\n plainVariables: PlainVariableInfo[]\n): Map<string, Set<string>> => {\n const result = new Map<string, Set<string>>();\n\n if (plainVariables.length === 0) return result;\n\n const { scriptSource, templateSource } = splitVueSfc(code);\n\n for (const { variableName, dictionaryKey } of plainVariables) {\n const fields = new Set<string>();\n const esc = escapeRegExp(variableName);\n\n // ── 1. Script pattern: varName.value.fieldName ─────────────────────────\n // Vue's reactive ref accessor; the actual content fields live one level\n // deeper than the variable itself.\n const scriptRe = new RegExp(`\\\\b${esc}\\\\.value\\\\.(\\\\w+)`, 'g');\n scriptRe.lastIndex = 0;\n for (\n let m = scriptRe.exec(scriptSource);\n m !== null;\n m = scriptRe.exec(scriptSource)\n ) {\n const field = m[1];\n // Skip chained `.value.value` artefacts\n if (field !== 'value') fields.add(field);\n }\n\n // ── 2. Template pattern: varName.fieldName ─────────────────────────────\n // Inside `<template>` Vue auto-unwraps refs, so content is accessed\n // directly without `.value`.\n if (templateSource) {\n const templateRe = new RegExp(`\\\\b${esc}\\\\.(\\\\w+)`, 'g');\n\n templateRe.lastIndex = 0;\n for (\n let m = templateRe.exec(templateSource);\n m !== null;\n m = templateRe.exec(templateSource)\n ) {\n fields.add(m[1]);\n }\n }\n\n if (fields.size > 0) {\n result.set(dictionaryKey, fields);\n }\n }\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,gBAAgB,QACpB,IAAI,QAAQ,uBAAuB,OAAO;;;;;;;;AAiB5C,MAAM,eACJ,SACqD;AACrD,KAAI;EACF,MAAM,EAAE,eACNA,0BAAO,MACP,KAAK;EAEP,MAAM,iBAAyB,WAAW,UAAU,WAAW;EAE/D,MAAM,cAAwB,EAAE;AAChC,MAAI,WAAW,QAAQ,QAAS,aAAY,KAAK,WAAW,OAAO,QAAQ;AAC3E,MAAI,WAAW,aAAa,QAC1B,aAAY,KAAK,WAAW,YAAY,QAAQ;AAGlD,SAAO;GAAE,cAFY,YAAY,KAAK,KAAK;GAEpB;GAAgB;SACjC;EAKN,MAAM,gBAAgB,4CAA4C,KAChE,KACD;EACD,MAAM,iBAAiB,gBAAgB,cAAc,KAAK;AAE1D,SAAO;GAAE,cADY,KAAK,QAAQ,kCAAkC,GAAG;GAChD;GAAgB;;;;;;;;;;;;;AAc3C,MAAa,gCACX,MACA,mBAC6B;CAC7B,MAAM,yBAAS,IAAI,KAA0B;AAE7C,KAAI,eAAe,WAAW,EAAG,QAAO;CAExC,MAAM,EAAE,cAAc,mBAAmB,YAAY,KAAK;AAE1D,MAAK,MAAM,EAAE,cAAc,mBAAmB,gBAAgB;EAC5D,MAAM,yBAAS,IAAI,KAAa;EAChC,MAAM,MAAM,aAAa,aAAa;EAKtC,MAAM,WAAW,IAAI,OAAO,MAAM,IAAI,oBAAoB,IAAI;AAC9D,WAAS,YAAY;AACrB,OACE,IAAI,IAAI,SAAS,KAAK,aAAa,EACnC,MAAM,MACN,IAAI,SAAS,KAAK,aAAa,EAC/B;GACA,MAAM,QAAQ,EAAE;AAEhB,OAAI,UAAU,QAAS,QAAO,IAAI,MAAM;;AAM1C,MAAI,gBAAgB;GAClB,MAAM,aAAa,IAAI,OAAO,MAAM,IAAI,YAAY,IAAI;AAExD,cAAW,YAAY;AACvB,QACE,IAAI,IAAI,WAAW,KAAK,eAAe,EACvC,MAAM,MACN,IAAI,WAAW,KAAK,eAAe,CAEnC,QAAO,IAAI,EAAE,GAAG;;AAIpB,MAAI,OAAO,OAAO,EAChB,QAAO,IAAI,eAAe,OAAO;;AAIrC,QAAO"}
@@ -1,6 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_vue_intlayer_extract = require('./vue-intlayer-extract.cjs');
3
+ const require_extractVueFieldUsage = require('./extractVueFieldUsage.cjs');
3
4
 
5
+ exports.extractVueIntlayerFieldUsage = require_extractVueFieldUsage.extractVueIntlayerFieldUsage;
4
6
  exports.intlayerVueExtract = require_vue_intlayer_extract.intlayerVueExtract;
5
7
  exports.processVueFile = require_vue_intlayer_extract.processVueFile;
6
8
  exports.shouldProcessFile = require_vue_intlayer_extract.shouldProcessFile;
@@ -0,0 +1,86 @@
1
+ import vueSfc from "@vue/compiler-sfc";
2
+
3
+ //#region src/extractVueFieldUsage.ts
4
+ /**
5
+ * Extracts intlayer dictionary field usage from a Vue SFC for a set of
6
+ * plain variable bindings (i.e. `const content = useIntlayer('key')`).
7
+ *
8
+ * Two access patterns are recognised:
9
+ *
10
+ * 1. `varName.value.fieldName` in script blocks
11
+ * Vue's `useIntlayer` returns a reactive `Ref<Content>`, so fields are
12
+ * accessed one level deeper via `.value`.
13
+ *
14
+ * 2. `varName.fieldName` in the template block
15
+ * Inside `<template>`, Vue automatically unwraps top-level refs, so
16
+ * fields are accessed directly without `.value`.
17
+ *
18
+ * The template block is extracted via `@vue/compiler-sfc` so that nested
19
+ * `<template v-for>` / `<template v-if>` tags do not confuse the parser.
20
+ * Falls back to a greedy regex when the package is unavailable.
21
+ */
22
+ /** Escapes special regex characters in a string used as a regex literal. */
23
+ const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
24
+ /**
25
+ * Splits a Vue SFC source string into its script and template regions.
26
+ *
27
+ * Uses `@vue/compiler-sfc` to get exact character offsets so that nested
28
+ * `<template>` tags (used by Vue directives like `v-for` / `v-if`) never
29
+ * cause the template region to be mis-identified.
30
+ */
31
+ const splitVueSfc = (code) => {
32
+ try {
33
+ const { descriptor } = vueSfc.parse(code);
34
+ const templateSource = descriptor.template?.content ?? "";
35
+ const scriptParts = [];
36
+ if (descriptor.script?.content) scriptParts.push(descriptor.script.content);
37
+ if (descriptor.scriptSetup?.content) scriptParts.push(descriptor.scriptSetup.content);
38
+ return {
39
+ scriptSource: scriptParts.join("\n"),
40
+ templateSource
41
+ };
42
+ } catch {
43
+ const templateMatch = /<template(?:[^>]*)>([\s\S]*)<\/template>/i.exec(code);
44
+ const templateSource = templateMatch ? templateMatch[1] : "";
45
+ return {
46
+ scriptSource: code.replace(/<template[\s\S]*<\/template>/gi, ""),
47
+ templateSource
48
+ };
49
+ }
50
+ };
51
+ /**
52
+ * Analyzes a Vue SFC source string and returns the top-level content field
53
+ * names that are statically accessed for each plain intlayer variable binding.
54
+ *
55
+ * @param code - Full `.vue` file source.
56
+ * @param plainVariables - List of plain variable bindings to analyse.
57
+ * @returns Map from dictionary key to the set of accessed top-level field names.
58
+ * If no fields can be determined for a given key it is omitted from the
59
+ * map so the caller can fall back to `'all'`.
60
+ */
61
+ const extractVueIntlayerFieldUsage = (code, plainVariables) => {
62
+ const result = /* @__PURE__ */ new Map();
63
+ if (plainVariables.length === 0) return result;
64
+ const { scriptSource, templateSource } = splitVueSfc(code);
65
+ for (const { variableName, dictionaryKey } of plainVariables) {
66
+ const fields = /* @__PURE__ */ new Set();
67
+ const esc = escapeRegExp(variableName);
68
+ const scriptRe = new RegExp(`\\b${esc}\\.value\\.(\\w+)`, "g");
69
+ scriptRe.lastIndex = 0;
70
+ for (let m = scriptRe.exec(scriptSource); m !== null; m = scriptRe.exec(scriptSource)) {
71
+ const field = m[1];
72
+ if (field !== "value") fields.add(field);
73
+ }
74
+ if (templateSource) {
75
+ const templateRe = new RegExp(`\\b${esc}\\.(\\w+)`, "g");
76
+ templateRe.lastIndex = 0;
77
+ for (let m = templateRe.exec(templateSource); m !== null; m = templateRe.exec(templateSource)) fields.add(m[1]);
78
+ }
79
+ if (fields.size > 0) result.set(dictionaryKey, fields);
80
+ }
81
+ return result;
82
+ };
83
+
84
+ //#endregion
85
+ export { extractVueIntlayerFieldUsage };
86
+ //# sourceMappingURL=extractVueFieldUsage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractVueFieldUsage.mjs","names":[],"sources":["../../src/extractVueFieldUsage.ts"],"sourcesContent":["/**\n * Extracts intlayer dictionary field usage from a Vue SFC for a set of\n * plain variable bindings (i.e. `const content = useIntlayer('key')`).\n *\n * Two access patterns are recognised:\n *\n * 1. `varName.value.fieldName` in script blocks\n * Vue's `useIntlayer` returns a reactive `Ref<Content>`, so fields are\n * accessed one level deeper via `.value`.\n *\n * 2. `varName.fieldName` in the template block\n * Inside `<template>`, Vue automatically unwraps top-level refs, so\n * fields are accessed directly without `.value`.\n *\n * The template block is extracted via `@vue/compiler-sfc` so that nested\n * `<template v-for>` / `<template v-if>` tags do not confuse the parser.\n * Falls back to a greedy regex when the package is unavailable.\n */\n\nimport vueSfc from '@vue/compiler-sfc';\n\n/** Escapes special regex characters in a string used as a regex literal. */\nconst escapeRegExp = (str: string): string =>\n str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/** Input descriptor for a single plain variable binding. */\nexport type PlainVariableInfo = {\n /** The local variable name in the script (`content` in `const content = useIntlayer(…)`). */\n variableName: string;\n /** The intlayer dictionary key passed to `useIntlayer`. */\n dictionaryKey: string;\n};\n\n/**\n * Splits a Vue SFC source string into its script and template regions.\n *\n * Uses `@vue/compiler-sfc` to get exact character offsets so that nested\n * `<template>` tags (used by Vue directives like `v-for` / `v-if`) never\n * cause the template region to be mis-identified.\n */\nconst splitVueSfc = (\n code: string\n): { scriptSource: string; templateSource: string } => {\n try {\n const { descriptor } = (\n vueSfc.parse as (src: string) => { descriptor: any }\n )(code);\n\n const templateSource: string = descriptor.template?.content ?? '';\n\n const scriptParts: string[] = [];\n if (descriptor.script?.content) scriptParts.push(descriptor.script.content);\n if (descriptor.scriptSetup?.content)\n scriptParts.push(descriptor.scriptSetup.content);\n const scriptSource = scriptParts.join('\\n');\n\n return { scriptSource, templateSource };\n } catch {\n // @vue/compiler-sfc not available or parse failed.\n // Fall back: use a greedy regex to capture everything between the\n // outermost <template> tags (robust against nested tags unlike the\n // non-greedy variant).\n const templateMatch = /<template(?:[^>]*)>([\\s\\S]*)<\\/template>/i.exec(\n code\n );\n const templateSource = templateMatch ? templateMatch[1] : '';\n const scriptSource = code.replace(/<template[\\s\\S]*<\\/template>/gi, '');\n return { scriptSource, templateSource };\n }\n};\n\n/**\n * Analyzes a Vue SFC source string and returns the top-level content field\n * names that are statically accessed for each plain intlayer variable binding.\n *\n * @param code - Full `.vue` file source.\n * @param plainVariables - List of plain variable bindings to analyse.\n * @returns Map from dictionary key to the set of accessed top-level field names.\n * If no fields can be determined for a given key it is omitted from the\n * map so the caller can fall back to `'all'`.\n */\nexport const extractVueIntlayerFieldUsage = (\n code: string,\n plainVariables: PlainVariableInfo[]\n): Map<string, Set<string>> => {\n const result = new Map<string, Set<string>>();\n\n if (plainVariables.length === 0) return result;\n\n const { scriptSource, templateSource } = splitVueSfc(code);\n\n for (const { variableName, dictionaryKey } of plainVariables) {\n const fields = new Set<string>();\n const esc = escapeRegExp(variableName);\n\n // ── 1. Script pattern: varName.value.fieldName ─────────────────────────\n // Vue's reactive ref accessor; the actual content fields live one level\n // deeper than the variable itself.\n const scriptRe = new RegExp(`\\\\b${esc}\\\\.value\\\\.(\\\\w+)`, 'g');\n scriptRe.lastIndex = 0;\n for (\n let m = scriptRe.exec(scriptSource);\n m !== null;\n m = scriptRe.exec(scriptSource)\n ) {\n const field = m[1];\n // Skip chained `.value.value` artefacts\n if (field !== 'value') fields.add(field);\n }\n\n // ── 2. Template pattern: varName.fieldName ─────────────────────────────\n // Inside `<template>` Vue auto-unwraps refs, so content is accessed\n // directly without `.value`.\n if (templateSource) {\n const templateRe = new RegExp(`\\\\b${esc}\\\\.(\\\\w+)`, 'g');\n\n templateRe.lastIndex = 0;\n for (\n let m = templateRe.exec(templateSource);\n m !== null;\n m = templateRe.exec(templateSource)\n ) {\n fields.add(m[1]);\n }\n }\n\n if (fields.size > 0) {\n result.set(dictionaryKey, fields);\n }\n }\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,gBAAgB,QACpB,IAAI,QAAQ,uBAAuB,OAAO;;;;;;;;AAiB5C,MAAM,eACJ,SACqD;AACrD,KAAI;EACF,MAAM,EAAE,eACN,OAAO,MACP,KAAK;EAEP,MAAM,iBAAyB,WAAW,UAAU,WAAW;EAE/D,MAAM,cAAwB,EAAE;AAChC,MAAI,WAAW,QAAQ,QAAS,aAAY,KAAK,WAAW,OAAO,QAAQ;AAC3E,MAAI,WAAW,aAAa,QAC1B,aAAY,KAAK,WAAW,YAAY,QAAQ;AAGlD,SAAO;GAAE,cAFY,YAAY,KAAK,KAAK;GAEpB;GAAgB;SACjC;EAKN,MAAM,gBAAgB,4CAA4C,KAChE,KACD;EACD,MAAM,iBAAiB,gBAAgB,cAAc,KAAK;AAE1D,SAAO;GAAE,cADY,KAAK,QAAQ,kCAAkC,GAAG;GAChD;GAAgB;;;;;;;;;;;;;AAc3C,MAAa,gCACX,MACA,mBAC6B;CAC7B,MAAM,yBAAS,IAAI,KAA0B;AAE7C,KAAI,eAAe,WAAW,EAAG,QAAO;CAExC,MAAM,EAAE,cAAc,mBAAmB,YAAY,KAAK;AAE1D,MAAK,MAAM,EAAE,cAAc,mBAAmB,gBAAgB;EAC5D,MAAM,yBAAS,IAAI,KAAa;EAChC,MAAM,MAAM,aAAa,aAAa;EAKtC,MAAM,WAAW,IAAI,OAAO,MAAM,IAAI,oBAAoB,IAAI;AAC9D,WAAS,YAAY;AACrB,OACE,IAAI,IAAI,SAAS,KAAK,aAAa,EACnC,MAAM,MACN,IAAI,SAAS,KAAK,aAAa,EAC/B;GACA,MAAM,QAAQ,EAAE;AAEhB,OAAI,UAAU,QAAS,QAAO,IAAI,MAAM;;AAM1C,MAAI,gBAAgB;GAClB,MAAM,aAAa,IAAI,OAAO,MAAM,IAAI,YAAY,IAAI;AAExD,cAAW,YAAY;AACvB,QACE,IAAI,IAAI,WAAW,KAAK,eAAe,EACvC,MAAM,MACN,IAAI,WAAW,KAAK,eAAe,CAEnC,QAAO,IAAI,EAAE,GAAG;;AAIpB,MAAI,OAAO,OAAO,EAChB,QAAO,IAAI,eAAe,OAAO;;AAIrC,QAAO"}
@@ -1,3 +1,4 @@
1
1
  import { intlayerVueExtract, processVueFile, shouldProcessFile } from "./vue-intlayer-extract.mjs";
2
+ import { extractVueIntlayerFieldUsage } from "./extractVueFieldUsage.mjs";
2
3
 
3
- export { intlayerVueExtract, processVueFile, shouldProcessFile };
4
+ export { extractVueIntlayerFieldUsage, intlayerVueExtract, processVueFile, shouldProcessFile };
@@ -0,0 +1,38 @@
1
+ //#region src/extractVueFieldUsage.d.ts
2
+ /**
3
+ * Extracts intlayer dictionary field usage from a Vue SFC for a set of
4
+ * plain variable bindings (i.e. `const content = useIntlayer('key')`).
5
+ *
6
+ * Two access patterns are recognised:
7
+ *
8
+ * 1. `varName.value.fieldName` in script blocks
9
+ * Vue's `useIntlayer` returns a reactive `Ref<Content>`, so fields are
10
+ * accessed one level deeper via `.value`.
11
+ *
12
+ * 2. `varName.fieldName` in the template block
13
+ * Inside `<template>`, Vue automatically unwraps top-level refs, so
14
+ * fields are accessed directly without `.value`.
15
+ *
16
+ * The template block is extracted via `@vue/compiler-sfc` so that nested
17
+ * `<template v-for>` / `<template v-if>` tags do not confuse the parser.
18
+ * Falls back to a greedy regex when the package is unavailable.
19
+ */
20
+ /** Input descriptor for a single plain variable binding. */
21
+ type PlainVariableInfo = {
22
+ /** The local variable name in the script (`content` in `const content = useIntlayer(…)`). */variableName: string; /** The intlayer dictionary key passed to `useIntlayer`. */
23
+ dictionaryKey: string;
24
+ };
25
+ /**
26
+ * Analyzes a Vue SFC source string and returns the top-level content field
27
+ * names that are statically accessed for each plain intlayer variable binding.
28
+ *
29
+ * @param code - Full `.vue` file source.
30
+ * @param plainVariables - List of plain variable bindings to analyse.
31
+ * @returns Map from dictionary key to the set of accessed top-level field names.
32
+ * If no fields can be determined for a given key it is omitted from the
33
+ * map so the caller can fall back to `'all'`.
34
+ */
35
+ declare const extractVueIntlayerFieldUsage: (code: string, plainVariables: PlainVariableInfo[]) => Map<string, Set<string>>;
36
+ //#endregion
37
+ export { PlainVariableInfo, extractVueIntlayerFieldUsage };
38
+ //# sourceMappingURL=extractVueFieldUsage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractVueFieldUsage.d.ts","names":[],"sources":["../../src/extractVueFieldUsage.ts"],"mappings":";;AA0BA;;;;;AAuDA;;;;;;;;;;;;;KAvDY,iBAAA;EA0DM,6FAxDhB,YAAA;EAEA,aAAA;AAAA;;;;;;;;;;;cAmDW,4BAAA,GACX,IAAA,UACA,cAAA,EAAgB,iBAAA,OACf,GAAA,SAAY,GAAA"}
@@ -1,2 +1,3 @@
1
+ import { PlainVariableInfo, extractVueIntlayerFieldUsage } from "./extractVueFieldUsage.js";
1
2
  import { ExtractPluginOptions, ExtractResult, ExtractedContent, intlayerVueExtract, processVueFile, shouldProcessFile } from "./vue-intlayer-extract.js";
2
- export { type ExtractPluginOptions, type ExtractResult, type ExtractedContent, intlayerVueExtract, processVueFile, shouldProcessFile };
3
+ export { type ExtractPluginOptions, type ExtractResult, type ExtractedContent, type PlainVariableInfo, extractVueIntlayerFieldUsage, intlayerVueExtract, processVueFile, shouldProcessFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/vue-compiler",
3
- "version": "8.6.9",
3
+ "version": "8.7.0-canary.0",
4
4
  "private": false,
5
5
  "description": "Vite-compatible compiler plugin for Vue with Intlayer, providing HMR support, file transformation, and optimized dictionary loading for Vue applications.",
6
6
  "keywords": [
@@ -81,8 +81,8 @@
81
81
  },
82
82
  "dependencies": {
83
83
  "@babel/core": "7.29.0",
84
- "@intlayer/config": "8.6.9",
85
- "@intlayer/types": "8.6.9",
84
+ "@intlayer/config": "8.7.0-canary.0",
85
+ "@intlayer/types": "8.7.0-canary.0",
86
86
  "@vue/compiler-sfc": ">=3.0.0",
87
87
  "fast-glob": "3.3.3",
88
88
  "magic-string": "0.30.21"
@@ -98,7 +98,7 @@
98
98
  "rimraf": "6.1.3",
99
99
  "tsdown": "0.21.7",
100
100
  "typescript": "6.0.2",
101
- "vitest": "4.1.2"
101
+ "vitest": "4.1.3"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "@babel/core": ">=6.0.0",