@formatjs/cli 6.16.3 → 6.16.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.
@@ -2,7 +2,7 @@ import { fileURLToPath as _furl } from "node:url";
2
2
  import { dirname as _dname } from "node:path";
3
3
  _dname(_furl(import.meta.url));
4
4
  import { t as parseScript } from "./formatjs";
5
- import { parseFile as parseFile$1 } from "./hbs_extractor-BGwD6qGk.js";
5
+ import { parseFile as parseFile$1 } from "./hbs_extractor-DC74dtk6.js";
6
6
  import { Preprocessor } from "content-tag";
7
7
  //#region packages/cli-lib/gts_extractor.ts
8
8
  let p = new Preprocessor();
@@ -14,4 +14,4 @@ function parseFile(source, fileName, options) {
14
14
  //#endregion
15
15
  export { parseFile };
16
16
 
17
- //# sourceMappingURL=gts_extractor-vkhePCTf.js.map
17
+ //# sourceMappingURL=gts_extractor-Dk_HfFGZ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gts_extractor-vkhePCTf.js","names":[],"sources":["../gts_extractor.ts"],"sourcesContent":["import {Preprocessor} from 'content-tag'\nimport {parseFile as parseHbsFile} from '#packages/cli-lib/hbs_extractor.js'\nimport {parseScript} from '#packages/cli-lib/parse_script.js'\nlet p = new Preprocessor()\n\nexport function parseFile(\n source: string,\n fileName: string,\n options: any\n): void {\n const scriptParseFn = parseScript(options, fileName)\n const transformedSource = p.process(source, {filename: fileName})\n\n scriptParseFn(transformedSource.code)\n\n // extract template from transformed source to then run through hbs processor\n const parseResult = p.parse(source, {filename: fileName})\n\n for (let parsed of parseResult) {\n parseHbsFile(parsed.contents, fileName, options)\n }\n}\n"],"mappings":";;;;;;;AAGA,IAAI,IAAI,IAAI,aAAa;AAEzB,SAAgB,UACd,QACA,UACA,SACM;CAIN,YAHkC,SAAS,QAG/B,EAFc,EAAE,QAAQ,QAAQ,EAAC,UAAU,SAAQ,CAEjC,EAAE,IAAI;CAGpC,MAAM,cAAc,EAAE,MAAM,QAAQ,EAAC,UAAU,SAAQ,CAAC;CAExD,KAAK,IAAI,UAAU,aACjB,YAAa,OAAO,UAAU,UAAU,OAAO;AAEnD"}
1
+ {"version":3,"file":"gts_extractor-Dk_HfFGZ.js","names":[],"sources":["../gts_extractor.ts"],"sourcesContent":["import {Preprocessor} from 'content-tag'\nimport {parseFile as parseHbsFile} from '#packages/cli-lib/hbs_extractor.js'\nimport {parseScript} from '#packages/cli-lib/parse_script.js'\nlet p = new Preprocessor()\n\nexport function parseFile(\n source: string,\n fileName: string,\n options: any\n): void {\n const scriptParseFn = parseScript(options, fileName)\n const transformedSource = p.process(source, {filename: fileName})\n\n scriptParseFn(transformedSource.code)\n\n // extract template from transformed source to then run through hbs processor\n const parseResult = p.parse(source, {filename: fileName})\n\n for (let parsed of parseResult) {\n parseHbsFile(parsed.contents, fileName, options)\n }\n}\n"],"mappings":";;;;;;;AAGA,IAAI,IAAI,IAAI,aAAa;AAEzB,SAAgB,UACd,QACA,UACA,SACM;CAIN,YAHkC,SAAS,QAG/B,EAFc,EAAE,QAAQ,QAAQ,EAAC,UAAU,SAAQ,CAEjC,EAAE,IAAI;CAGpC,MAAM,cAAc,EAAE,MAAM,QAAQ,EAAC,UAAU,SAAQ,CAAC;CAExD,KAAK,IAAI,UAAU,aACjB,YAAa,OAAO,UAAU,UAAU,OAAO;AAEnD"}
@@ -35,4 +35,4 @@ function parseFile(source, fileName, options) {
35
35
  //#endregion
36
36
  export { parseFile };
37
37
 
38
- //# sourceMappingURL=hbs_extractor-BGwD6qGk.js.map
38
+ //# sourceMappingURL=hbs_extractor-DC74dtk6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hbs_extractor-BGwD6qGk.js","names":[],"sources":["../hbs_extractor.ts"],"sourcesContent":["import {type Opts} from '@formatjs/ts-transformer'\nimport {preprocess, traverse, type AST, type ASTv1} from '@glimmer/syntax'\n\nfunction extractText(\n node: AST.MustacheStatement | AST.SubExpression,\n fileName: string,\n options: Opts\n) {\n if (!options.onMsgExtracted) return\n if (!options.overrideIdFn) return\n\n if (node.path.type !== 'PathExpression') return\n\n if (['format-message', 'formatMessage'].includes(node.path.original)) {\n let [first, second] = node.params\n\n if (first.type !== 'StringLiteral') return\n\n let message = first?.value\n\n let desc: string | undefined\n if (second?.type === 'StringLiteral') {\n desc = second.value?.trim().replace(/\\s+/gm, ' ')\n }\n\n let defaultMessage = message?.trim().replace(/\\s+/gm, ' ')\n\n let id =\n typeof options.overrideIdFn === 'string'\n ? options.overrideIdFn\n : options.overrideIdFn(undefined, defaultMessage, desc, fileName)\n\n options.onMsgExtracted(fileName, [\n {\n id: id,\n defaultMessage: defaultMessage,\n description: desc,\n },\n ])\n }\n}\n\nexport function parseFile(\n source: string,\n fileName: string,\n options: any\n): void {\n const ast = preprocess(source)\n traverse(ast, {\n MustacheStatement(node: ASTv1.MustacheStatement) {\n extractText(node, fileName, options)\n },\n SubExpression(node: ASTv1.SubExpression) {\n extractText(node, fileName, options)\n },\n })\n}\n"],"mappings":";;;;;AAGA,SAAS,YACP,MACA,UACA,SACA;CACA,IAAI,CAAC,QAAQ,gBAAgB;CAC7B,IAAI,CAAC,QAAQ,cAAc;CAE3B,IAAI,KAAK,KAAK,SAAS,kBAAkB;CAEzC,IAAI,CAAC,kBAAkB,eAAe,EAAE,SAAS,KAAK,KAAK,QAAQ,GAAG;EACpE,IAAI,CAAC,OAAO,UAAU,KAAK;EAE3B,IAAI,MAAM,SAAS,iBAAiB;EAEpC,IAAI,UAAU,OAAO;EAErB,IAAI;EACJ,IAAI,QAAQ,SAAS,iBACnB,OAAO,OAAO,OAAO,KAAK,EAAE,QAAQ,SAAS,GAAG;EAGlD,IAAI,iBAAiB,SAAS,KAAK,EAAE,QAAQ,SAAS,GAAG;EAEzD,IAAI,KACF,OAAO,QAAQ,iBAAiB,WAC5B,QAAQ,eACR,QAAQ,aAAa,KAAA,GAAW,gBAAgB,MAAM,QAAQ;EAEpE,QAAQ,eAAe,UAAU,CAC/B;GACM;GACY;GAChB,aAAa;EACf,CACF,CAAC;CACH;AACF;AAEA,SAAgB,UACd,QACA,UACA,SACM;CAEN,SADY,WAAW,MACZ,GAAG;EACZ,kBAAkB,MAA+B;GAC/C,YAAY,MAAM,UAAU,OAAO;EACrC;EACA,cAAc,MAA2B;GACvC,YAAY,MAAM,UAAU,OAAO;EACrC;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"hbs_extractor-DC74dtk6.js","names":[],"sources":["../hbs_extractor.ts"],"sourcesContent":["import {type Opts} from '@formatjs/ts-transformer'\nimport {preprocess, traverse, type AST, type ASTv1} from '@glimmer/syntax'\n\nfunction extractText(\n node: AST.MustacheStatement | AST.SubExpression,\n fileName: string,\n options: Opts\n) {\n if (!options.onMsgExtracted) return\n if (!options.overrideIdFn) return\n\n if (node.path.type !== 'PathExpression') return\n\n if (['format-message', 'formatMessage'].includes(node.path.original)) {\n let [first, second] = node.params\n\n if (first.type !== 'StringLiteral') return\n\n let message = first?.value\n\n let desc: string | undefined\n if (second?.type === 'StringLiteral') {\n desc = second.value?.trim().replace(/\\s+/gm, ' ')\n }\n\n let defaultMessage = message?.trim().replace(/\\s+/gm, ' ')\n\n let id =\n typeof options.overrideIdFn === 'string'\n ? options.overrideIdFn\n : options.overrideIdFn(undefined, defaultMessage, desc, fileName)\n\n options.onMsgExtracted(fileName, [\n {\n id: id,\n defaultMessage: defaultMessage,\n description: desc,\n },\n ])\n }\n}\n\nexport function parseFile(\n source: string,\n fileName: string,\n options: any\n): void {\n const ast = preprocess(source)\n traverse(ast, {\n MustacheStatement(node: ASTv1.MustacheStatement) {\n extractText(node, fileName, options)\n },\n SubExpression(node: ASTv1.SubExpression) {\n extractText(node, fileName, options)\n },\n })\n}\n"],"mappings":";;;;;AAGA,SAAS,YACP,MACA,UACA,SACA;CACA,IAAI,CAAC,QAAQ,gBAAgB;CAC7B,IAAI,CAAC,QAAQ,cAAc;CAE3B,IAAI,KAAK,KAAK,SAAS,kBAAkB;CAEzC,IAAI,CAAC,kBAAkB,eAAe,EAAE,SAAS,KAAK,KAAK,QAAQ,GAAG;EACpE,IAAI,CAAC,OAAO,UAAU,KAAK;EAE3B,IAAI,MAAM,SAAS,iBAAiB;EAEpC,IAAI,UAAU,OAAO;EAErB,IAAI;EACJ,IAAI,QAAQ,SAAS,iBACnB,OAAO,OAAO,OAAO,KAAK,EAAE,QAAQ,SAAS,GAAG;EAGlD,IAAI,iBAAiB,SAAS,KAAK,EAAE,QAAQ,SAAS,GAAG;EAEzD,IAAI,KACF,OAAO,QAAQ,iBAAiB,WAC5B,QAAQ,eACR,QAAQ,aAAa,KAAA,GAAW,gBAAgB,MAAM,QAAQ;EAEpE,QAAQ,eAAe,UAAU,CAC/B;GACM;GACY;GAChB,aAAa;EACf,CACF,CAAC;CACH;AACF;AAEA,SAAgB,UACd,QACA,UACA,SACM;CAEN,SADY,WAAW,MACZ,GAAG;EACZ,kBAAkB,MAA+B;GAC/C,YAAY,MAAM,UAAU,OAAO;EACrC;EACA,cAAc,MAA2B;GACvC,YAAY,MAAM,UAAU,OAAO;EACrC;CACF,CAAC;AACH"}
@@ -96,4 +96,4 @@ function parseFile(source, filename, parseScriptFn) {
96
96
  //#endregion
97
97
  export { parseFile };
98
98
 
99
- //# sourceMappingURL=svelte_extractor-CLhHGLMq.js.map
99
+ //# sourceMappingURL=svelte_extractor-R4PlmulG.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"svelte_extractor-CLhHGLMq.js","names":[],"sources":["../svelte_extractor.ts"],"sourcesContent":["import {parse} from 'svelte/compiler'\n\nexport type ScriptParseFn = (source: string) => void\n\ninterface SvelteNode {\n type: string\n start: number\n end: number\n [key: string]: any\n}\n\nfunction walkFragment(\n fragment: SvelteNode | null | undefined,\n source: string,\n parseScriptFn: ScriptParseFn\n): void {\n if (!fragment || !fragment.nodes) {\n return\n }\n for (const node of fragment.nodes) {\n walkNode(node, source, parseScriptFn)\n }\n}\n\nfunction extractExpression(\n expression: SvelteNode | null | undefined,\n source: string,\n parseScriptFn: ScriptParseFn\n): void {\n if (!expression || expression.start == null || expression.end == null) {\n return\n }\n const content = source.slice(expression.start, expression.end)\n try {\n parseScriptFn(`(${content})`)\n } catch (e) {\n console.warn(\n `Failed to parse \"${content}\". Ignore this if content has no extractable message`,\n e\n )\n }\n}\n\nfunction walkNode(\n node: SvelteNode,\n source: string,\n parseScriptFn: ScriptParseFn\n): void {\n switch (node.type) {\n case 'ExpressionTag':\n extractExpression(node.expression, source, parseScriptFn)\n break\n\n case 'ConstTag':\n // {@const x = expr} — the declaration contains the expression\n if (node.declaration) {\n const content = source.slice(\n node.declaration.start,\n node.declaration.end\n )\n try {\n parseScriptFn(content)\n } catch (e) {\n console.warn(\n `Failed to parse const declaration. Ignore this if content has no extractable message`,\n e\n )\n }\n }\n break\n\n case 'IfBlock':\n extractExpression(node.test, source, parseScriptFn)\n walkFragment(node.consequent, source, parseScriptFn)\n walkFragment(node.alternate, source, parseScriptFn)\n break\n\n case 'EachBlock':\n extractExpression(node.expression, source, parseScriptFn)\n if (node.key) {\n extractExpression(node.key, source, parseScriptFn)\n }\n walkFragment(node.body, source, parseScriptFn)\n walkFragment(node.fallback, source, parseScriptFn)\n break\n\n case 'AwaitBlock':\n extractExpression(node.expression, source, parseScriptFn)\n walkFragment(node.pending, source, parseScriptFn)\n walkFragment(node.then, source, parseScriptFn)\n walkFragment(node.catch, source, parseScriptFn)\n break\n\n case 'KeyBlock':\n extractExpression(node.expression, source, parseScriptFn)\n walkFragment(node.fragment, source, parseScriptFn)\n break\n\n case 'SnippetBlock':\n walkFragment(node.body, source, parseScriptFn)\n break\n\n case 'RegularElement':\n case 'Component':\n case 'SvelteComponent':\n case 'SvelteElement':\n case 'SvelteHead':\n case 'SvelteBody':\n case 'SvelteWindow':\n case 'SvelteDocument':\n case 'SlotElement':\n case 'SvelteSelf':\n case 'SvelteFragment':\n // Process attributes\n if (node.attributes) {\n for (const attr of node.attributes) {\n if (attr.type === 'Attribute') {\n if (Array.isArray(attr.value)) {\n for (const v of attr.value) {\n if (v.type === 'ExpressionTag') {\n extractExpression(v.expression, source, parseScriptFn)\n }\n }\n } else if (\n typeof attr.value === 'object' &&\n attr.value !== null &&\n attr.value.type === 'ExpressionTag'\n ) {\n extractExpression(attr.value.expression, source, parseScriptFn)\n }\n } else if (attr.type === 'SpreadAttribute') {\n extractExpression(attr.expression, source, parseScriptFn)\n } else if (attr.expression) {\n // Directive nodes (OnDirective, BindDirective, etc.)\n extractExpression(attr.expression, source, parseScriptFn)\n }\n }\n }\n // Process children\n walkFragment(node.fragment, source, parseScriptFn)\n break\n }\n}\n\nexport function parseFile(\n source: string,\n filename: string,\n parseScriptFn: ScriptParseFn\n): void {\n const ast = parse(source, {modern: true, filename})\n\n // Walk the template fragment\n walkFragment(ast.fragment as unknown as SvelteNode, source, parseScriptFn)\n\n // Process <script> block\n if (ast.instance) {\n const program = ast.instance.content as unknown as SvelteNode\n parseScriptFn(source.slice(program.start, program.end))\n }\n\n // Process <script context=\"module\"> / <script module> block\n if (ast.module) {\n const program = ast.module.content as unknown as SvelteNode\n parseScriptFn(source.slice(program.start, program.end))\n }\n}\n"],"mappings":";;;;;AAWA,SAAS,aACP,UACA,QACA,eACM;CACN,IAAI,CAAC,YAAY,CAAC,SAAS,OACzB;CAEF,KAAK,MAAM,QAAQ,SAAS,OAC1B,SAAS,MAAM,QAAQ,aAAa;AAExC;AAEA,SAAS,kBACP,YACA,QACA,eACM;CACN,IAAI,CAAC,cAAc,WAAW,SAAS,QAAQ,WAAW,OAAO,MAC/D;CAEF,MAAM,UAAU,OAAO,MAAM,WAAW,OAAO,WAAW,GAAG;CAC7D,IAAI;EACF,cAAc,IAAI,QAAQ,EAAE;CAC9B,SAAS,GAAG;EACV,QAAQ,KACN,oBAAoB,QAAQ,uDAC5B,CACF;CACF;AACF;AAEA,SAAS,SACP,MACA,QACA,eACM;CACN,QAAQ,KAAK,MAAb;EACE,KAAK;GACH,kBAAkB,KAAK,YAAY,QAAQ,aAAa;GACxD;EAEF,KAAK;GAEH,IAAI,KAA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a;IAAA,OAE3D,IAAI,KAAK,SAAS,mBACvB,kBAAkB,KAAK,YAAY,QAAQ,aAAa;SACnD,IAAI,KAAK,YAEd,kBAAkB,KAAK,YAAY,QAAQ,aAAa;GAAA;GAK9D,aAAa,KAAK,UAAU,QAAQ,aAAa;GACjD;CACJ;AACF;AAEA,SAAgB,UACd,QACA,UACA,eACM;CACN,MAAM,MAAM,MAAM,QAAQ;EAAC,QAAQ;EAAM;CAAQ,CAAC;CAGlD,aAAa,IAAI,UAAmC,QAAQ,aAAa;CAGzE,IAAI,IAAI,UAAU;EAChB,MAAM,UAAU,IAAI,SAAS;EAC7B,cAAc,OAAO,MAAM,QAAQ,OAAO,QAAQ,GAAG,CAAC;CACxD;CAGA,IAAI,IAAI,QAAQ;EACd,MAAM,UAAU,IAAI,OAAO;EAC3B,cAAc,OAAO,MAAM,QAAQ,OAAO,QAAQ,GAAG,CAAC;CACxD;AACF"}
1
+ {"version":3,"file":"svelte_extractor-R4PlmulG.js","names":[],"sources":["../svelte_extractor.ts"],"sourcesContent":["import {parse} from 'svelte/compiler'\n\nexport type ScriptParseFn = (source: string) => void\n\ninterface SvelteNode {\n type: string\n start: number\n end: number\n [key: string]: any\n}\n\nfunction walkFragment(\n fragment: SvelteNode | null | undefined,\n source: string,\n parseScriptFn: ScriptParseFn\n): void {\n if (!fragment || !fragment.nodes) {\n return\n }\n for (const node of fragment.nodes) {\n walkNode(node, source, parseScriptFn)\n }\n}\n\nfunction extractExpression(\n expression: SvelteNode | null | undefined,\n source: string,\n parseScriptFn: ScriptParseFn\n): void {\n if (!expression || expression.start == null || expression.end == null) {\n return\n }\n const content = source.slice(expression.start, expression.end)\n try {\n parseScriptFn(`(${content})`)\n } catch (e) {\n console.warn(\n `Failed to parse \"${content}\". Ignore this if content has no extractable message`,\n e\n )\n }\n}\n\nfunction walkNode(\n node: SvelteNode,\n source: string,\n parseScriptFn: ScriptParseFn\n): void {\n switch (node.type) {\n case 'ExpressionTag':\n extractExpression(node.expression, source, parseScriptFn)\n break\n\n case 'ConstTag':\n // {@const x = expr} — the declaration contains the expression\n if (node.declaration) {\n const content = source.slice(\n node.declaration.start,\n node.declaration.end\n )\n try {\n parseScriptFn(content)\n } catch (e) {\n console.warn(\n `Failed to parse const declaration. Ignore this if content has no extractable message`,\n e\n )\n }\n }\n break\n\n case 'IfBlock':\n extractExpression(node.test, source, parseScriptFn)\n walkFragment(node.consequent, source, parseScriptFn)\n walkFragment(node.alternate, source, parseScriptFn)\n break\n\n case 'EachBlock':\n extractExpression(node.expression, source, parseScriptFn)\n if (node.key) {\n extractExpression(node.key, source, parseScriptFn)\n }\n walkFragment(node.body, source, parseScriptFn)\n walkFragment(node.fallback, source, parseScriptFn)\n break\n\n case 'AwaitBlock':\n extractExpression(node.expression, source, parseScriptFn)\n walkFragment(node.pending, source, parseScriptFn)\n walkFragment(node.then, source, parseScriptFn)\n walkFragment(node.catch, source, parseScriptFn)\n break\n\n case 'KeyBlock':\n extractExpression(node.expression, source, parseScriptFn)\n walkFragment(node.fragment, source, parseScriptFn)\n break\n\n case 'SnippetBlock':\n walkFragment(node.body, source, parseScriptFn)\n break\n\n case 'RegularElement':\n case 'Component':\n case 'SvelteComponent':\n case 'SvelteElement':\n case 'SvelteHead':\n case 'SvelteBody':\n case 'SvelteWindow':\n case 'SvelteDocument':\n case 'SlotElement':\n case 'SvelteSelf':\n case 'SvelteFragment':\n // Process attributes\n if (node.attributes) {\n for (const attr of node.attributes) {\n if (attr.type === 'Attribute') {\n if (Array.isArray(attr.value)) {\n for (const v of attr.value) {\n if (v.type === 'ExpressionTag') {\n extractExpression(v.expression, source, parseScriptFn)\n }\n }\n } else if (\n typeof attr.value === 'object' &&\n attr.value !== null &&\n attr.value.type === 'ExpressionTag'\n ) {\n extractExpression(attr.value.expression, source, parseScriptFn)\n }\n } else if (attr.type === 'SpreadAttribute') {\n extractExpression(attr.expression, source, parseScriptFn)\n } else if (attr.expression) {\n // Directive nodes (OnDirective, BindDirective, etc.)\n extractExpression(attr.expression, source, parseScriptFn)\n }\n }\n }\n // Process children\n walkFragment(node.fragment, source, parseScriptFn)\n break\n }\n}\n\nexport function parseFile(\n source: string,\n filename: string,\n parseScriptFn: ScriptParseFn\n): void {\n const ast = parse(source, {modern: true, filename})\n\n // Walk the template fragment\n walkFragment(ast.fragment as unknown as SvelteNode, source, parseScriptFn)\n\n // Process <script> block\n if (ast.instance) {\n const program = ast.instance.content as unknown as SvelteNode\n parseScriptFn(source.slice(program.start, program.end))\n }\n\n // Process <script context=\"module\"> / <script module> block\n if (ast.module) {\n const program = ast.module.content as unknown as SvelteNode\n parseScriptFn(source.slice(program.start, program.end))\n }\n}\n"],"mappings":";;;;;AAWA,SAAS,aACP,UACA,QACA,eACM;CACN,IAAI,CAAC,YAAY,CAAC,SAAS,OACzB;CAEF,KAAK,MAAM,QAAQ,SAAS,OAC1B,SAAS,MAAM,QAAQ,aAAa;AAExC;AAEA,SAAS,kBACP,YACA,QACA,eACM;CACN,IAAI,CAAC,cAAc,WAAW,SAAS,QAAQ,WAAW,OAAO,MAC/D;CAEF,MAAM,UAAU,OAAO,MAAM,WAAW,OAAO,WAAW,GAAG;CAC7D,IAAI;EACF,cAAc,IAAI,QAAQ,EAAE;CAC9B,SAAS,GAAG;EACV,QAAQ,KACN,oBAAoB,QAAQ,uDAC5B,CACF;CACF;AACF;AAEA,SAAS,SACP,MACA,QACA,eACM;CACN,QAAQ,KAAK,MAAb;EACE,KAAK;GACH,kBAAkB,KAAK,YAAY,QAAQ,aAAa;GACxD;EAEF,KAAK;GAEH,IAAI,KAAK,aAAa;IACpB,MAAM,UAAU,OAAO,MACrB,KAAK,YAAY,OACjB,KAAK,YAAY,GACnB;IACA,IAAI;KACF,cAAc,OAAO;IACvB,SAAS,GAAG;KACV,QAAQ,KACN,wFACA,CACF;IACF;GACF;GACA;EAEF,KAAK;GACH,kBAAkB,KAAK,MAAM,QAAQ,aAAa;GAClD,aAAa,KAAK,YAAY,QAAQ,aAAa;GACnD,aAAa,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QAAQ;EAAM;CAAQ,CAAC;CAGlD,aAAa,IAAI,UAAmC,QAAQ,aAAa;CAGzE,IAAI,IAAI,UAAU;EAChB,MAAM,UAAU,IAAI,SAAS;EAC7B,cAAc,OAAO,MAAM,QAAQ,OAAO,QAAQ,GAAG,CAAC;CACxD;CAGA,IAAI,IAAI,QAAQ;EACd,MAAM,UAAU,IAAI,OAAO;EAC3B,cAAc,OAAO,MAAM,QAAQ,OAAO,QAAQ,GAAG,CAAC;CACxD;AACF"}
@@ -41,4 +41,4 @@ function parseFile(source, filename, parseScriptFn) {
41
41
  //#endregion
42
42
  export { parseFile };
43
43
 
44
- //# sourceMappingURL=vue_extractor-BFqKdH3o.js.map
44
+ //# sourceMappingURL=vue_extractor-CGXoDm-M.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vue_extractor-BFqKdH3o.js","names":[],"sources":["../vue_extractor.ts"],"sourcesContent":["import {\n NodeTypes,\n type TextNode,\n type CompoundExpressionNode,\n type DirectiveNode,\n type ElementNode,\n type InterpolationNode,\n type RootNode,\n type SimpleExpressionNode,\n type TemplateChildNode,\n} from '@vue/compiler-core'\nimport {parse} from 'vue/compiler-sfc'\n\nexport type ScriptParseFn = (source: string) => void\n\nfunction walk(\n node:\n | RootNode\n | TemplateChildNode\n | SimpleExpressionNode\n | CompoundExpressionNode\n | InterpolationNode\n | TextNode\n | string\n | symbol\n | undefined,\n visitor: (\n node:\n | ElementNode\n | InterpolationNode\n | CompoundExpressionNode\n | SimpleExpressionNode\n ) => void\n) {\n if (typeof node !== 'object' || node == null) {\n return\n }\n if (node.type === NodeTypes.ROOT) {\n node.children.forEach(n => walk(n, visitor))\n return\n }\n if (\n node.type !== NodeTypes.ELEMENT &&\n node.type !== NodeTypes.COMPOUND_EXPRESSION &&\n node.type !== NodeTypes.INTERPOLATION\n ) {\n return\n }\n visitor(node)\n if (node.type === NodeTypes.INTERPOLATION) {\n visitor(node.content)\n } else if (node.type === NodeTypes.ELEMENT) {\n node.children.forEach(n => walk(n, visitor))\n node.props\n .filter(\n (prop): prop is DirectiveNode => prop.type === NodeTypes.DIRECTIVE\n )\n .filter(prop => !!prop.exp)\n .forEach(prop => visitor(prop.exp!))\n } else {\n node.children.forEach(n => walk(n, visitor))\n }\n}\n\nfunction templateSimpleExpressionNodeVisitor(parseScriptFn: ScriptParseFn) {\n return (\n n:\n | ElementNode\n | CompoundExpressionNode\n | CompoundExpressionNode['children'][0]\n ) => {\n if (typeof n !== 'object') {\n return\n }\n if (n.type !== NodeTypes.SIMPLE_EXPRESSION) {\n return\n }\n\n const {content} = n as SimpleExpressionNode\n // Wrap this in () since a vue comp node attribute can just be\n // an object literal which, by itself is invalid TS\n // but with () it becomes an ExpressionStatement\n try {\n parseScriptFn(`(${content})`)\n } catch (e) {\n console.warn(\n `Failed to parse \"${content}\". Ignore this if content has no extractable message`,\n e\n )\n }\n }\n}\n\nexport function parseFile(\n source: string,\n filename: string,\n parseScriptFn: ScriptParseFn\n): void {\n const {descriptor, errors} = parse(source, {\n filename,\n })\n if (errors.length) {\n throw errors[0]\n }\n const {script, scriptSetup, template} = descriptor\n\n if (template) {\n walk(template.ast, templateSimpleExpressionNodeVisitor(parseScriptFn))\n }\n\n if (script) {\n parseScriptFn(script.content)\n }\n\n if (scriptSetup) {\n parseScriptFn(scriptSetup.content)\n }\n}\n"],"mappings":";;;;;;AAeA,SAAS,KACP,MAUA,SAOA;CACA,IAAI,OAAO,SAAS,YAAY,QAAQ,MACtC;CAEF,IAAI,KAAK,SAAS,UAAU,MAAM;EAChC,KAAK,SAAS,SAAQ,MAAK,KAAK,GAAG,OAAO,CAAC;EAC3C;CACF;CACA,IACE,KAAK,SAAS,UAAU,WACxB,KAAK,SAAS,UAAU,uBACxB,KAAK,SAAS,UAAU,eAExB;CAEF,QAAQ,IAAI;CACZ,IAAI,KAAK,SAAS,UAAU,eAC1B,QAAQ,KAAK,OAAO;MACf,IAAI,KAAK,SAAS,UAAU,SAAS;EAC1C,KAAK,SAAS,SAAQ,MAAK,KAAK,GAAG,OAAO,CAAC;EAC3C,KAAK,MACF,QACE,SAAgC,KAAK,SAAS,UAAU,SAC3D,EACC,QAAO,SAAQ,CAAC,CAAC,KAAK,GAAG,EACzB,SAAQ,SAAQ,QAAQ,KAAK,GAAI,CAAC;CACvC,OACE,KAAK,SAAS,SAAQ,MAAK,KAAK,GAAG,OAAO,CAAC;AAE/C;AAEA,SAAS,oCAAoC,eAA8B;CACzE,QACE,MAIG;EACH,IAAI,OAAO,MAAM,UACf;EAEF,IAAI,EAAE,SAAS,UAAU,mBACvB;EAGF,MAAM,EAAC,YAAW;EAIlB,IAAI;GACF,cAAc,IAAI,QAAQ,EAAE;EAC9B,SAAS,GAAG;GACV,QAAQ,KACN,oBAAoB,QAAQ,uDAC5B,CACF;EACF;CACF;AACF;AAEA,SAAgB,UACd,QACA,UACA,eACM;CACN,MAAM,EAAC,YAAY,WAAU,MAAM,QAAQ,EACzC,SACF,CAAC;CACD,IAAI,OAAO,QACT,MAAM,OAAO;CAEf,MAAM,EAAC,QAAQ,aAAa,aAAY;CAExC,IAAI,UACF,KAAK,SAAS,KAAK,oCAAoC,aAAa,CAAC;CAGvE,IAAI,QACF,cAAc,OAAO,OAAO;CAG9B,IAAI,aACF,cAAc,YAAY,OAAO;AAErC"}
1
+ {"version":3,"file":"vue_extractor-CGXoDm-M.js","names":[],"sources":["../vue_extractor.ts"],"sourcesContent":["import {\n NodeTypes,\n type TextNode,\n type CompoundExpressionNode,\n type DirectiveNode,\n type ElementNode,\n type InterpolationNode,\n type RootNode,\n type SimpleExpressionNode,\n type TemplateChildNode,\n} from '@vue/compiler-core'\nimport {parse} from 'vue/compiler-sfc'\n\nexport type ScriptParseFn = (source: string) => void\n\nfunction walk(\n node:\n | RootNode\n | TemplateChildNode\n | SimpleExpressionNode\n | CompoundExpressionNode\n | InterpolationNode\n | TextNode\n | string\n | symbol\n | undefined,\n visitor: (\n node:\n | ElementNode\n | InterpolationNode\n | CompoundExpressionNode\n | SimpleExpressionNode\n ) => void\n) {\n if (typeof node !== 'object' || node == null) {\n return\n }\n if (node.type === NodeTypes.ROOT) {\n node.children.forEach(n => walk(n, visitor))\n return\n }\n if (\n node.type !== NodeTypes.ELEMENT &&\n node.type !== NodeTypes.COMPOUND_EXPRESSION &&\n node.type !== NodeTypes.INTERPOLATION\n ) {\n return\n }\n visitor(node)\n if (node.type === NodeTypes.INTERPOLATION) {\n visitor(node.content)\n } else if (node.type === NodeTypes.ELEMENT) {\n node.children.forEach(n => walk(n, visitor))\n node.props\n .filter(\n (prop): prop is DirectiveNode => prop.type === NodeTypes.DIRECTIVE\n )\n .filter(prop => !!prop.exp)\n .forEach(prop => visitor(prop.exp!))\n } else {\n node.children.forEach(n => walk(n, visitor))\n }\n}\n\nfunction templateSimpleExpressionNodeVisitor(parseScriptFn: ScriptParseFn) {\n return (\n n:\n | ElementNode\n | CompoundExpressionNode\n | CompoundExpressionNode['children'][0]\n ) => {\n if (typeof n !== 'object') {\n return\n }\n if (n.type !== NodeTypes.SIMPLE_EXPRESSION) {\n return\n }\n\n const {content} = n as SimpleExpressionNode\n // Wrap this in () since a vue comp node attribute can just be\n // an object literal which, by itself is invalid TS\n // but with () it becomes an ExpressionStatement\n try {\n parseScriptFn(`(${content})`)\n } catch (e) {\n console.warn(\n `Failed to parse \"${content}\". Ignore this if content has no extractable message`,\n e\n )\n }\n }\n}\n\nexport function parseFile(\n source: string,\n filename: string,\n parseScriptFn: ScriptParseFn\n): void {\n const {descriptor, errors} = parse(source, {\n filename,\n })\n if (errors.length) {\n throw errors[0]\n }\n const {script, scriptSetup, template} = descriptor\n\n if (template) {\n walk(template.ast, templateSimpleExpressionNodeVisitor(parseScriptFn))\n }\n\n if (script) {\n parseScriptFn(script.content)\n }\n\n if (scriptSetup) {\n parseScriptFn(scriptSetup.content)\n }\n}\n"],"mappings":";;;;;;AAeA,SAAS,KACP,MAUA,SAOA;CACA,IAAI,OAAO,SAAS,YAAY,QAAQ,MACtC;CAEF,IAAI,KAAK,SAAS,UAAU,MAAM;EAChC,KAAK,SAAS,SAAQ,MAAK,KAAK,GAAG,OAAO,CAAC;EAC3C;CACF;CACA,IACE,KAAK,SAAS,UAAU,WACxB,KAAK,SAAS,UAAU,uBACxB,KAAK,SAAS,UAAU,eAExB;CAEF,QAAQ,IAAI;CACZ,IAAI,KAAK,SAAS,UAAU,eAC1B,QAAQ,KAAK,OAAO;MACf,IAAI,KAAK,SAAS,UAAU,SAAS;EAC1C,KAAK,SAAS,SAAQ,MAAK,KAAK,GAAG,OAAO,CAAC;EAC3C,KAAK,MACF,QACE,SAAgC,KAAK,SAAS,UAAU,SAC3D,EACC,QAAO,SAAQ,CAAC,CAAC,KAAK,GAAG,EACzB,SAAQ,SAAQ,QAAQ,KAAK,GAAI,CAAC;CACvC,OACE,KAAK,SAAS,SAAQ,MAAK,KAAK,GAAG,OAAO,CAAC;AAE/C;AAEA,SAAS,oCAAoC,eAA8B;CACzE,QACE,MAIG;EACH,IAAI,OAAO,MAAM,UACf;EAEF,IAAI,EAAE,SAAS,UAAU,mBACvB;EAGF,MAAM,EAAC,YAAW;EAIlB,IAAI;GACF,cAAc,IAAI,QAAQ,EAAE;EAC9B,SAAS,GAAG;GACV,QAAQ,KACN,oBAAoB,QAAQ,uDAC5B,CACF;EACF;CACF;AACF;AAEA,SAAgB,UACd,QACA,UACA,eACM;CACN,MAAM,EAAC,YAAY,WAAU,MAAM,QAAQ,EACzC,SACF,CAAC;CACD,IAAI,OAAO,QACT,MAAM,OAAO;CAEf,MAAM,EAAC,QAAQ,aAAa,aAAY;CAExC,IAAI,UACF,KAAK,SAAS,KAAK,oCAAoC,aAAa,CAAC;CAGvE,IAAI,QACF,cAAc,OAAO,OAAO;CAG9B,IAAI,aACF,cAAc,YAAY,OAAO;AAErC"}
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@formatjs/cli",
3
3
  "description": "A CLI for formatjs.",
4
- "version": "6.16.3",
4
+ "version": "6.16.5",
5
5
  "license": "MIT",
6
6
  "author": "Linjie Ding <linjie@airtable.com>",
7
7
  "engines": {
8
8
  "node": ">= 20.12.0"
9
9
  },
10
10
  "devDependencies": {
11
- "@formatjs/cli-lib": "8.7.2"
11
+ "@formatjs/cli-lib": "8.7.4"
12
12
  },
13
13
  "peerDependencies": {
14
14
  "@glimmer/syntax": "^0.84.3 || ^0.95.0",
@@ -39,10 +39,10 @@
39
39
  "translation"
40
40
  ],
41
41
  "optionalDependencies": {
42
- "@formatjs/cli-native-linux-arm64": "1.2.0",
43
- "@formatjs/cli-native-linux-x64": "1.1.0",
44
42
  "@formatjs/cli-native-darwin-arm64": "1.1.0",
45
- "@formatjs/cli-native-win32-x64": "1.1.1"
43
+ "@formatjs/cli-native-linux-x64": "1.1.0",
44
+ "@formatjs/cli-native-win32-x64": "1.1.1",
45
+ "@formatjs/cli-native-linux-arm64": "1.2.0"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
48
  "vue": {