@wp-blocks/make-pot 1.6.2 → 1.6.4

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 (58) hide show
  1. package/README.md +2 -1
  2. package/biome.json +6 -3
  3. package/lib/assets/block-i18n.js.map +7 -1
  4. package/lib/assets/package-i18n.js.map +7 -1
  5. package/lib/assets/theme-i18n.js.map +7 -1
  6. package/lib/assets/wp-plugin-i18n.js.map +7 -1
  7. package/lib/assets/wp-theme-i18n.js.map +7 -1
  8. package/lib/cli/getArgs.js +1 -1
  9. package/lib/cli/getArgs.js.map +7 -1
  10. package/lib/cli/getJsonArgs.js.map +7 -1
  11. package/lib/cli/parseCli.js +1 -1
  12. package/lib/cli/parseCli.js.map +7 -1
  13. package/lib/cli.js.map +7 -1
  14. package/lib/const.js.map +7 -1
  15. package/lib/extractors/auditStrings.js +4 -3
  16. package/lib/extractors/auditStrings.js.map +7 -1
  17. package/lib/extractors/css.js.map +7 -1
  18. package/lib/extractors/headers.js +7 -6
  19. package/lib/extractors/headers.js.map +7 -1
  20. package/lib/extractors/json.js +1 -1
  21. package/lib/extractors/json.js.map +7 -1
  22. package/lib/extractors/packageJson.js.map +7 -1
  23. package/lib/extractors/php.js.map +7 -1
  24. package/lib/extractors/schema.js +3 -4
  25. package/lib/extractors/schema.js.map +7 -1
  26. package/lib/extractors/text.js.map +7 -1
  27. package/lib/fs/fs.js +2 -2
  28. package/lib/fs/fs.js.map +7 -1
  29. package/lib/fs/glob.js +1 -1
  30. package/lib/fs/glob.js.map +7 -1
  31. package/lib/index.js.map +7 -1
  32. package/lib/jsonCommand.js.map +7 -1
  33. package/lib/makeJson.js.map +7 -1
  34. package/lib/makePot.js.map +7 -1
  35. package/lib/parser/exec.js +1 -1
  36. package/lib/parser/exec.js.map +7 -1
  37. package/lib/parser/makeJson.js +1 -1
  38. package/lib/parser/makeJson.js.map +7 -1
  39. package/lib/parser/makePot.js.map +7 -1
  40. package/lib/parser/patterns.js.map +7 -1
  41. package/lib/parser/process.js +1 -1
  42. package/lib/parser/process.js.map +7 -1
  43. package/lib/parser/progress.js.map +7 -1
  44. package/lib/parser/taskRunner.js +2 -2
  45. package/lib/parser/taskRunner.js.map +7 -1
  46. package/lib/parser/tree.js +2 -1
  47. package/lib/parser/tree.js.map +7 -1
  48. package/lib/potCommand.js.map +7 -1
  49. package/lib/types.js.map +7 -1
  50. package/lib/utils/common.js.map +7 -1
  51. package/lib/utils/extractors.js +1 -1
  52. package/lib/utils/extractors.js.map +7 -1
  53. package/lib/utils/output.js +1 -1
  54. package/lib/utils/output.js.map +7 -1
  55. package/package.json +15 -12
  56. package/tests/extract-headers.test.js +69 -1
  57. package/tests/generate-header.test.js +27 -0
  58. package/tests/tree.test.js +111 -1
@@ -1 +1,7 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/extractors/schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,mEAAqD;AAErD,mEAAqD;AAGrD;;GAEG;AAEH,gEAAgE;AAChE,MAAa,mBAAmB;IACvB,MAAM,CAAC,WAAW,GAAkC,EAAE,CAAC;IAE/D,YAAY;IACZ,MAAM,CAAC,eAAe,GACrB,wEAAwE,CAAC;IAC1E,MAAM,CAAC,iBAAiB,GAAG,SAAsB,CAAC;IAClD,YAAY;IACZ,MAAM,CAAC,eAAe,GACrB,wEAAwE,CAAC;IAC1E,MAAM,CAAC,iBAAiB,GAAG,SAAsB,CAAC;IAElD;;;;;;OAMG;IACK,MAAM,CAAC,KAAK,CAAC,UAAU,CAC9B,GAAW,EACX,QAAoB;QAEpB,IAAI,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1C,OAAO,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,6BAA6B,GAAG,EAAE,CAAC,CAAC;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AC,QAAQ,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;wBACzC,CAAC;6BAAM,CAAC;4BACP,iEAAiE;4BACjE,oDAAoD;4BACpD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gCACzC,IAAI,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;oCACvC,cAAc,CACb,QAAQ,CAAC,GAAG,CAAC,EACb,cAAc,EACd,QAAQ,EACR,aAAa,CACb,CAAC;gCACH,CAAC;4BACF,CAAC;wBACF,CAAC;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAED;;;;;;WAMG;QACH,SAAS,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa;YAC9D,IAAI,CAAC,OAAO;gBAAE,OAAO,CAAC,2BAA2B;YAEjD,MAAM,WAAW,GAAG;gBACnB,KAAK;gBACL,OAAO;aACE,CAAC;YAEX,IAAI,aAAa,EAAE,CAAC;gBACnB,WAAW,CAAC,QAAQ,GAAG;oBACtB,SAAS,EAAE,CAAC,QAAQ,CAAC;iBACrB,CAAC;YACH,CAAC;YAED,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAChC,CAAC;QAED,iCAAiC;QACjC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEtB,OAAO,YAAY,CAAC;IACrB,CAAC;;AAhQF,kDAiQC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extractors/schema.ts"],
4
+ "sourcesContent": ["import type { Block } from \"gettext-merger\";\r\nimport * as blocki18n from \"../assets/block-i18n.js\";\r\nimport * as themei18n from \"../assets/theme-i18n.js\";\r\nimport type { I18nSchema } from \"../types.js\";\r\n\r\n/**\r\n * Extracts strings from JSON files using the I18n schema.\r\n */\r\n// biome-ignore lint/complexity/noStaticOnlyClass: <ATM it's fine in that way>\r\nexport class JsonSchemaExtractor {\r\n\tprivate static schemaCache: { [url: string]: I18nSchema } = {};\r\n\r\n\t/** Theme */\r\n\tstatic themeJsonSource =\r\n\t\t\"http://develop.svn.wordpress.org/trunk/src/wp-includes/theme-i18n.json\";\r\n\tstatic themeJsonFallback = themei18n;\r\n\t/** Block */\r\n\tstatic blockJsonSource =\r\n\t\t\"http://develop.svn.wordpress.org/trunk/src/wp-includes/block-i18n.json\";\r\n\tstatic blockJsonFallback = blocki18n;\r\n\r\n\t/**\r\n\t * Load the schema from the specified URL, with a fallback URL if needed.\r\n\t *\r\n\t * @param {string} url - The URL to load the schema from.\r\n\t * @param {I18nSchema} fallback - The fallback schema to use if the main URL fails.\r\n\t * @return {Promise<I18nSchema>} The loaded schema.\r\n\t */\r\n\tprivate static async loadSchema(\r\n\t\turl: string,\r\n\t\tfallback: I18nSchema,\r\n\t): Promise<I18nSchema> {\r\n\t\tif (JsonSchemaExtractor.schemaCache[url]) {\r\n\t\t\treturn JsonSchemaExtractor.schemaCache[url];\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst response = await fetch(url, {\r\n\t\t\t\theaders: {\r\n\t\t\t\t\t\"Access-Control-Allow-Origin\": \"*\",\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t\t\t.then((response) => response.json())\r\n\t\t\t\t.catch((error: Error) => {\r\n\t\t\t\t\tthrow new Error(\r\n\t\t\t\t\t\t`\\nFailed to load schema from ${url}. Error: ${error.message}`,\r\n\t\t\t\t\t);\r\n\t\t\t\t});\r\n\r\n\t\t\t// Verify if the response is valid\r\n\t\t\tif (!response) {\r\n\t\t\t\treturn fallback;\r\n\t\t\t}\r\n\r\n\t\t\tJsonSchemaExtractor.schemaCache[url] = response;\r\n\t\t\treturn response;\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\r\n\t\t\t\t`\\nFailed to load schema from ${url}. Using fallback. Error: ${(error as Error).message}`,\r\n\t\t\t);\r\n\t\t\tJsonSchemaExtractor.schemaCache[url] = fallback;\r\n\t\t\treturn fallback;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Parses a string and extracts translations using the specified schema.\r\n\t *\r\n\t * @param {string} text - the input string to be parsed\r\n\t * @param {object} schema - the schema to use for parsing the input string\r\n\t * @param {string} schema.url - the URL of the schema to use for parsing the input string\r\n\t * @param {object} schema.schemaFallback - the fallback schema to use if the main schema fails\r\n\t * @param {object} options - the options for parsing the input string\r\n\t * @param {string} options.file - the name of the file being parsed\r\n\t * @param {boolean} options.addReferences - whether to add references to the extracted strings\r\n\t *\r\n\t * @return {Promise<I18nSchema | undefined>} a promise that resolves with the extracted schema\r\n\t */\r\n\tpublic static async parse(\r\n\t\ttext: string,\r\n\t\tschema: {\r\n\t\t\turl: string;\r\n\t\t\tfallback: I18nSchema;\r\n\t\t},\r\n\t\toptions: {\r\n\t\t\tfile: \"block.json\" | \"theme.json\";\r\n\t\t\taddReferences: boolean;\r\n\t\t},\r\n\t): Promise<Block[] | undefined> {\r\n\t\tconst parsedSchema = await JsonSchemaExtractor.loadSchema(\r\n\t\t\tschema.url,\r\n\t\t\tschema.fallback,\r\n\t\t);\r\n\r\n\t\ttry {\r\n\t\t\tconst json = JSON.parse(text) as Record<string, unknown>;\r\n\t\t\tif (!json) {\r\n\t\t\t\tconsole.error(\"Could not parse JSON.\");\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\treturn JsonSchemaExtractor.extractFromJsonSchema(\r\n\t\t\t\tjson,\r\n\t\t\t\tparsedSchema,\r\n\t\t\t\toptions,\r\n\t\t\t);\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(`Error parsing JSON: ${(error as Error).message}`);\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Extracts translatable strings from a JSON file by comparing it with a schema\r\n\t *\r\n\t * @param {Object} json - The JSON object to extract strings from\r\n\t * @param {Object} schema - The schema that defines which fields contain translatable strings\r\n\t * @param {Object} options - Options for extraction\r\n\t * @param {string} options.filename - The name of the file being extracted (for references)\r\n\t * @param {boolean} options.addReferences - Whether to add file references in comments\r\n\t * @return {Array} - An array of objects with translatable strings in gettext format\r\n\t */\r\n\tprivate static extractFromJsonSchema(\r\n\t\tjson: Record<string, unknown>,\r\n\t\tschema: I18nSchema,\r\n\t\toptions: { filename?: string; addReferences?: boolean } = {\r\n\t\t\tfilename: undefined,\r\n\t\t\taddReferences: false,\r\n\t\t},\r\n\t): Block[] | undefined {\r\n\t\tconst { filename = \"block.json\", addReferences = false } = options;\r\n\t\tconst translations: Block[] = [];\r\n\r\n\t\t/**\r\n\t\t * Recursive function to extract translatable strings\r\n\t\t * @param {*} currentJson - The current node in the JSON\r\n\t\t * @param {*} currentSchema - The current node in the schema\r\n\t\t * @param {Array} path - The current path in the JSON\r\n\t\t */\r\n\t\tfunction extract(\r\n\t\t\tcurrentJson: Record<string, unknown>,\r\n\t\t\tcurrentSchema: I18nSchema,\r\n\t\t\tpath: string[] = [],\r\n\t\t) {\r\n\t\t\t// If either is null or undefined, there's nothing to do\r\n\t\t\tif (!currentJson || !currentSchema) return;\r\n\r\n\t\t\t// Handles the case where both are objects\r\n\t\t\tif (\r\n\t\t\t\ttypeof currentJson === \"object\" &&\r\n\t\t\t\t!Array.isArray(currentJson) &&\r\n\t\t\t\ttypeof currentSchema === \"object\" &&\r\n\t\t\t\t!Array.isArray(currentSchema)\r\n\t\t\t) {\r\n\t\t\t\t// Iterate over the schema keys\r\n\t\t\t\tfor (const key of Object.keys(currentSchema)) {\r\n\t\t\t\t\tif (key in currentJson) {\r\n\t\t\t\t\t\t// If the key exists in the JSON, check the type\r\n\t\t\t\t\t\tif (typeof currentJson[key] === \"string\") {\r\n\t\t\t\t\t\t\t// It's a string - add it to translations\r\n\t\t\t\t\t\t\taddTranslation(\r\n\t\t\t\t\t\t\t\tcurrentJson[key],\r\n\t\t\t\t\t\t\t\tcurrentSchema[key] as string,\r\n\t\t\t\t\t\t\t\tfilename,\r\n\t\t\t\t\t\t\t\taddReferences,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t} else if (\r\n\t\t\t\t\t\t\tArray.isArray(currentJson[key]) &&\r\n\t\t\t\t\t\t\tArray.isArray(currentSchema[key])\r\n\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\t// It's an array - handle each element\r\n\t\t\t\t\t\t\thandleArrays(\r\n\t\t\t\t\t\t\t\tcurrentJson[key],\r\n\t\t\t\t\t\t\t\tcurrentSchema[key],\r\n\t\t\t\t\t\t\t\t[...path, key],\r\n\t\t\t\t\t\t\t\tfilename,\r\n\t\t\t\t\t\t\t\taddReferences,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t} else if (\r\n\t\t\t\t\t\t\ttypeof currentJson[key] === \"object\" &&\r\n\t\t\t\t\t\t\tcurrentJson[key] !== null &&\r\n\t\t\t\t\t\t\ttypeof currentSchema[key] === \"object\"\r\n\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\t// It's an object - recurse\r\n\t\t\t\t\t\t\textract(\r\n\t\t\t\t\t\t\t\tcurrentJson[key] as Record<string, unknown>,\r\n\t\t\t\t\t\t\t\tcurrentSchema[key] as I18nSchema,\r\n\t\t\t\t\t\t\t\t[...path, key],\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * Handles arrays in JSON and schema\r\n\t\t * @param {unknown[]} jsonArray - The JSON array\r\n\t\t * @param {string[] | I18nSchema[]} schemaArray - The schema array\r\n\t\t * @param {string[]} path - The current path\r\n\t\t * @param {string} filename - The name of the file\r\n\t\t * @param {boolean} addReferences - whenever to add references\r\n\t\t */\r\n\t\tfunction handleArrays(\r\n\t\t\tjsonArray: unknown[],\r\n\t\t\tschemaArray: string[] | I18nSchema[],\r\n\t\t\tpath: string[],\r\n\t\t\tfilename: string,\r\n\t\t\taddReferences: boolean,\r\n\t\t) {\r\n\t\t\t// If the schema has at least one element, use it as a template\r\n\t\t\tif (schemaArray.length > 0) {\r\n\t\t\t\tconst schemaTemplate = schemaArray[0];\r\n\r\n\t\t\t\t// For each element in the JSON array\r\n\t\t\t\tfor (const jsonItem of jsonArray) {\r\n\t\t\t\t\tif (typeof jsonItem === \"string\") {\r\n\t\t\t\t\t\t// If the JSON element is a string, add it directly\r\n\t\t\t\t\t\taddTranslation(\r\n\t\t\t\t\t\t\tjsonItem,\r\n\t\t\t\t\t\t\tschemaTemplate as string,\r\n\t\t\t\t\t\t\tfilename,\r\n\t\t\t\t\t\t\taddReferences,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t} else if (typeof jsonItem === \"object\" && jsonItem !== null) {\r\n\t\t\t\t\t\t// If it's an object, recurse\r\n\t\t\t\t\t\tif (typeof schemaTemplate === \"object\") {\r\n\t\t\t\t\t\t\textract(\r\n\t\t\t\t\t\t\t\tjsonItem as Record<string, unknown>,\r\n\t\t\t\t\t\t\t\tschemaTemplate as I18nSchema,\r\n\t\t\t\t\t\t\t\tpath,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t// Edge case: handles cases like keywords: [\"string1\", \"string2\"]\r\n\t\t\t\t\t\t\t// when the schema has keywords: [\"keyword context\"]\r\n\t\t\t\t\t\t\tfor (const key of Object.keys(jsonItem)) {\r\n\t\t\t\t\t\t\t\t// Type guard to ensure we are accessing a string\r\n\t\t\t\t\t\t\t\tconst value = (jsonItem as Record<string, unknown>)[key];\r\n\t\t\t\t\t\t\t\tif (typeof value === \"string\") {\r\n\t\t\t\t\t\t\t\t\taddTranslation(\r\n\t\t\t\t\t\t\t\t\t\tvalue,\r\n\t\t\t\t\t\t\t\t\t\tschemaTemplate as string,\r\n\t\t\t\t\t\t\t\t\t\tfilename,\r\n\t\t\t\t\t\t\t\t\t\taddReferences,\r\n\t\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * Adds a translation to the translations array\r\n\t\t * @param {string} msgctxt - The context of the text to be translated\r\n\t\t * @param {string} msgid - The text to be translated\r\n\t\t * @param {string} filename - The name of the file for references\r\n\t\t * @param {boolean} addReferences - Whether to add references\r\n\t\t */\r\n\t\tfunction addTranslation(msgctxt: string, msgid: string, filename: string, addReferences: boolean) {\r\n\t\t\tif (!msgctxt) return; // Do not add empty strings\r\n\r\n\t\t\tconst translation = {\r\n\t\t\t\tmsgid,\r\n\t\t\t\tmsgctxt,\r\n\t\t\t} as Block;\r\n\r\n\t\t\tif (addReferences) {\r\n\t\t\t\ttranslation.comments = {\r\n\t\t\t\t\treference: [filename],\r\n\t\t\t\t};\r\n\t\t\t}\r\n\r\n\t\t\ttranslations.push(translation);\r\n\t\t}\r\n\r\n\t\t// Start extraction from the root\r\n\t\textract(json, schema);\r\n\r\n\t\treturn translations;\r\n\t}\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAA2B;AAC3B,gBAA2B;AAOpB,MAAM,oBAAoB;AAAA,EAChC,OAAe,cAA6C,CAAC;AAAA;AAAA,EAG7D,OAAO,kBACN;AAAA,EACD,OAAO,oBAAoB;AAAA;AAAA,EAE3B,OAAO,kBACN;AAAA,EACD,OAAO,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS3B,aAAqB,WACpB,KACA,UACsB;AACtB,QAAI,oBAAoB,YAAY,GAAG,GAAG;AACzC,aAAO,oBAAoB,YAAY,GAAG;AAAA,IAC3C;AAEA,QAAI;AACH,YAAM,WAAW,MAAM,MAAM,KAAK;AAAA,QACjC,SAAS;AAAA,UACR,+BAA+B;AAAA,QAChC;AAAA,MACD,CAAC,EACC,KAAK,CAACA,cAAaA,U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AAU,UAAU;AAC9B;AAAA,oBACC;AAAA,oBACA;AAAA,oBACAD;AAAA,oBACAC;AAAA,kBACD;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AASA,aAAS,eAAe,SAAiB,OAAeD,WAAkBC,gBAAwB;AACjG,UAAI,CAAC,QAAS;AAEd,YAAM,cAAc;AAAA,QACnB;AAAA,QACA;AAAA,MACD;AAEA,UAAIA,gBAAe;AAClB,oBAAY,WAAW;AAAA,UACtB,WAAW,CAACD,SAAQ;AAAA,QACrB;AAAA,MACD;AAEA,mBAAa,KAAK,WAAW;AAAA,IAC9B;AAGA,YAAQ,MAAM,MAAM;AAEpB,WAAO;AAAA,EACR;AACD;",
6
+ "names": ["response", "filename", "addReferences"]
7
+ }
@@ -1 +1,7 @@
1
- {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/extractors/text.ts"],"names":[],"mappings":";;AASA,0CAqBC;AA9BD,kDAAyD;AAEzD;;;;;;GAMG;AACH,SAAgB,eAAe,CAC9B,WAAmB,EACnB,SAAS,GAAG,GAAG;IAEf,MAAM,IAAI,GAA2B,EAAE,CAAC;IAExC,qCAAqC;IACrC,MAAM,IAAI,GAAG,IAAA,+BAAmB,EAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IACpD,mEAAmE;IACnE,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACpC;;qCAE0B;QAC1B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACtE,SAAS;QACV,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extractors/text.ts"],
4
+ "sourcesContent": ["import { removeCommentMarkup } from \"../utils/common.js\";\n\n/**\n * Extracts file data from the given file content.\n *\n * @param {string} fileContent - The content of the file.\n * @param {string} separator - The separator used in the file.\n * @return {Record<string, string>} An object containing the extracted file data.\n */\nexport function extractFileData(\n\tfileContent: string,\n\tseparator = \":\",\n): Record<string, string> {\n\tconst data: Record<string, string> = {};\n\n\t// split by lines and trim every line\n\tconst text = removeCommentMarkup(fileContent) ?? [];\n\t// split each line by break line and trim each part and add to data\n\tfor (const line of text) {\n\t\tconst parts = line.split(separator);\n\t\t/* Check if the parser has already collected the data from the previous line\n\t\t\t and the current line is empty.\n\t\t\t If so, skip this line */\n\t\tif (parts.length !== 2 && Object.values(data).length > 0 && parts[1]) {\n\t\t\tcontinue;\n\t\t}\n\t\tdata[parts[0]?.trim()] = parts[1].trim();\n\t}\n\n\treturn data;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAoC;AAS7B,SAAS,gBACf,aACA,YAAY,KACa;AACzB,QAAM,OAA+B,CAAC;AAGtC,QAAM,WAAO,mCAAoB,WAAW,KAAK,CAAC;AAElD,aAAW,QAAQ,MAAM;AACxB,UAAM,QAAQ,KAAK,MAAM,SAAS;AAIlC,QAAI,MAAM,WAAW,KAAK,OAAO,OAAO,IAAI,EAAE,SAAS,KAAK,MAAM,CAAC,GAAG;AACrE;AAAA,IACD;AACA,SAAK,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK;AAAA,EACxC;AAEA,SAAO;AACR;",
6
+ "names": []
7
+ }
package/lib/fs/fs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.create;var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of m(t))!x.call(e,r)&&r!==n&&i(e,r,{get:()=>t[r],enumerable:!(o=p(t,r))||o.enumerable});return e};var f=(e,t,n)=>(n=e!=null?l(F(e)):{},u(t||!e||!e.__esModule?i(n,"default",{value:e,enumerable:!0}):n,e)),w=e=>u(i({},"__esModule",{value:!0}),e);var j={};y(j,{getCharset:()=>d,getEncodingCharset:()=>$,readFileAsync:()=>S,writeFile:()=>C});module.exports=w(j);var s=f(require("node:fs")),a=require("node:fs/promises"),c=f(require("node:path"));function E(e){if(e===void 0)return".";try{s.default.accessSync(c.default.resolve(e),s.default.constants.R_OK|s.default.constants.W_OK)}catch(t){if(t.code==="ENOENT")return s.default.mkdirSync(e,{recursive:!0}),console.log(`Folder created: ${e}`),e}return e}function d(e){if(!e)return"latin1";switch(e.toLowerCase()){case"utf-8":case"utf8":return"utf-8";default:return"latin1"}}function $(e){if(!e)return"iso-8859-1";switch(e.toLowerCase()){case"utf-8":case"utf8":return"utf-8";default:return"iso-8859-1"}}function h(e){const{out:t,headers:n,options:o}=e.paths;let r=t??n?.domainPath??"languages";r=r.replace(/^\/+|\/+$/g,"");const g=o?.json?"json":"pot";return c.default.join(process.cwd(),r,`${e.slug}.${g}`)}function C(e,t){const n=h(t);if(E(c.default.dirname(n))){const o=d(t.options?.charset);console.log(`
2
- Pot File created at ${n}`);const r=Buffer.from(e);(0,s.writeFileSync)(n,r.toString(o),{encoding:o})}else console.log(`Folder ${n} does not exist and cannot be created`)}async function S(e){return(0,a.readFile)(e,"utf-8")}0&&(module.exports={getCharset,getEncodingCharset,readFileAsync,writeFile});
1
+ "use strict";var p=Object.create;var i=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var n in e)i(t,n,{get:e[n],enumerable:!0})},f=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of F(e))!y.call(t,r)&&r!==n&&i(t,r,{get:()=>e[r],enumerable:!(o=m(e,r))||o.enumerable});return t};var a=(t,e,n)=>(n=t!=null?p(x(t)):{},f(e||!t||!t.__esModule?i(n,"default",{value:t,enumerable:!0}):n,t)),E=t=>f(i({},"__esModule",{value:!0}),t);var A={};w(A,{getCharset:()=>g,getEncodingCharset:()=>h,readFileAsync:()=>j,writeFile:()=>S});module.exports=E(A);var s=a(require("node:fs")),d=require("node:fs/promises"),c=a(require("node:path"));function $(t){if(t===void 0)return".";try{s.default.accessSync(c.default.resolve(t),s.default.constants.R_OK|s.default.constants.W_OK)}catch(e){if(e.code==="ENOENT")return s.default.mkdirSync(t,{recursive:!0}),console.log(`Folder created: ${t}`),t}return t}function g(t){if(!t)return"latin1";switch(t.toLowerCase()){case"utf-8":case"utf8":return"utf-8";default:return"latin1"}}function h(t){if(!t)return"iso-8859-1";switch(t.toLowerCase()){case"utf-8":case"utf8":return"utf-8";default:return"iso-8859-1"}}function C(t){const{paths:e,headers:n,options:o}=t;let u=e.out??n?.domainPath??"languages";u=u.replace(/^\/+|\/+$/g,"");const l=o?.json?"json":"pot";return c.default.join(process.cwd(),u,`${t.slug}.${l}`)}function S(t,e){const n=C(e);if($(c.default.dirname(n))){const o=g(e.options?.charset);console.log(`
2
+ Pot File created at ${n}`);const r=Buffer.from(t);(0,s.writeFileSync)(n,r.toString(o),{encoding:o})}else console.log(`Folder ${n} does not exist and cannot be created`)}async function j(t){return(0,d.readFile)(t,"utf-8")}0&&(module.exports={getCharset,getEncodingCharset,readFileAsync,writeFile});
package/lib/fs/fs.js.map CHANGED
@@ -1 +1,7 @@
1
- {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/fs/fs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;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CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,uCAAuC,CAAC,CAAC;IACpE,CAAC;AACF,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,aAAa,CAAC,IAAY;IAC/C,OAAO,IAAA,mBAAQ,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/fs/fs.ts"],
4
+ "sourcesContent": ["import fs, { writeFileSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { Args } from \"../types.js\";\n\n/**\n * Ensures that a folder exists at the specified path.\n *\n * @param {string | undefined} folderPath - The path of the folder to ensure existence for.\n * @return {string} - The path of the folder, or '.' if folderPath is undefined.\n */\nfunction ensureFolderExists(folderPath: string | undefined): string {\n\tif (folderPath === undefined) {\n\t\treturn \".\";\n\t}\n\ttry {\n\t\t// Check if the folder exists\n\t\tfs.accessSync(\n\t\t\tpath.resolve(folderPath),\n\t\t\tfs.constants.R_OK | fs.constants.W_OK,\n\t\t);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n\t\t\t// The Folder does not exist, so create it\n\t\t\tfs.mkdirSync(folderPath, { recursive: true });\n\t\t\tconsole.log(`Folder created: ${folderPath}`);\n\t\t\treturn folderPath;\n\t\t}\n\t}\n\treturn folderPath;\n}\n\n/**\n * Gets the charset of the .pot file\n *\n * @param charset the charset of the .pot file\n * @return the charset of the .pot file\n */\nexport function getCharset(charset: string | undefined): BufferEncoding {\n\tif (!charset) {\n\t\treturn \"latin1\";\n\t}\n\t// we need to check if the charset is valid otherwise we return latin1 that is a common alias for ISO-8859-1 and the default charset for pot files\n\tswitch (charset.toLowerCase()) {\n\t\tcase \"utf-8\":\n\t\tcase \"utf8\":\n\t\t\treturn \"utf-8\";\n\t\tdefault:\n\t\t\treturn \"latin1\";\n\t}\n}\n\nexport function getEncodingCharset(charset: string | undefined): string {\n\tif (!charset) {\n\t\treturn \"iso-8859-1\";\n\t}\n\t// we need to check if the charset is valid otherwise we return utf-8 that is a common alias for ISO-8859-1 and the default charset for pot files\n\tswitch (charset.toLowerCase()) {\n\t\tcase \"utf-8\":\n\t\tcase \"utf8\":\n\t\t\treturn \"utf-8\";\n\t\tdefault:\n\t\t\treturn \"iso-8859-1\";\n\t}\n}\n\n/**\n * The output path for the pot file.\n * @param args - the command line arguments\n */\nfunction getOutputFilePath(args: Args): string {\n\tconst { paths, headers, options } = args;\n\tconst out = paths.out\n\tlet i18nFolder = out ?? headers?.domainPath ?? \"languages\";\n\n\t// Remove leading and trailing slashes\n\ti18nFolder = i18nFolder.replace(/^\\/+|\\/+$/g, \"\");\n\n\tconst extension = options?.json ? \"json\" : \"pot\";\n\n\treturn path.join(process.cwd(), i18nFolder, `${args.slug}.${extension}`);\n}\n\n/**\n * Writes the .pot file to disk\n *\n * @param fileContent the content of the .pot file\n * @param args the command line arguments passed to the program\n */\nexport function writeFile(fileContent: string, args: Args): void {\n\tconst dest = getOutputFilePath(args);\n\n\tif (ensureFolderExists(path.dirname(dest))) {\n\t\t// get the encoding charset\n\t\tconst encodingCharset = getCharset(args.options?.charset);\n\t\tconsole.log(`\\nPot File created at ${dest}`);\n\n\t\t// write the file\n\t\tconst potBuffer = Buffer.from(fileContent);\n\t\twriteFileSync(dest, potBuffer.toString(encodingCharset), {\n\t\t\tencoding: encodingCharset,\n\t\t});\n\t} else {\n\t\tconsole.log(`Folder ${dest} does not exist and cannot be created`);\n\t}\n}\n\n/**\n * The async version of fs.readFile method\n * @param path the path of the file to read\n * @return the content of the file as a string\n */\nexport async function readFileAsync(path: string): Promise<string> {\n\treturn readFile(path, \"utf-8\");\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAkC;AAClC,sBAAyB;AACzB,uBA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AAG;AAE3C,UAAM,kBAAkB,WAAW,KAAK,SAAS,OAAO;AACxD,YAAQ,IAAI;AAAA,sBAAyB,IAAI,EAAE;AAG3C,UAAM,YAAY,OAAO,KAAK,WAAW;AACzC,sCAAc,MAAM,UAAU,SAAS,eAAe,GAAG;AAAA,MACxD,UAAU;AAAA,IACX,CAAC;AAAA,EACF,OAAO;AACN,YAAQ,IAAI,UAAU,IAAI,uCAAuC;AAAA,EAClE;AACD;AAOA,eAAsB,cAAcA,OAA+B;AAClE,aAAO,0BAASA,OAAM,OAAO;AAC9B;",
6
+ "names": ["fs", "path"]
7
+ }
package/lib/fs/glob.js CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.create;var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})},p=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!j.call(t,n)&&n!==r&&s(t,n,{get:()=>e[n],enumerable:!(i=g(e,n))||i.enumerable});return t};var o=(t,e,r)=>(r=t!=null?f(x(t)):{},p(e||!t||!t.__esModule?s(r,"default",{value:t,enumerable:!0}):r,t)),P=t=>p(s({},"__esModule",{value:!0}),t);var A={};w(A,{getFiles:()=>F,getParser:()=>v,ignoreFunc:()=>d});module.exports=P(A);var u=o(require("node:path")),l=require("glob"),h=require("minimatch"),b=o(require("tree-sitter-javascript")),c=o(require("tree-sitter-php")),m=o(require("tree-sitter-typescript")),a=require("../utils/common.js");function v(t){switch((0,a.getFileExtension)(t)){case"ts":return m.typescript;case"tsx":return m.tsx;case"js":case"jsx":case"mjs":case"cjs":return b;case"php":return c.php;case"blade.php":return c.php_only;default:return null}}const d=(t,e)=>e.some(r=>{switch((0,a.detectPatternType)(r)){case"file":return t.isNamed(r);case"directory":return t.relative().includes(r);default:return(0,h.minimatch)(t.relative(),r)}});function F(t,e){return new l.Glob(e.include,{ignore:{ignored:r=>d(r,e.exclude)},nodir:!0,cwd:t.paths.cwd,root:t.paths.root?u.default.resolve(t.paths.root):void 0})}0&&(module.exports={getFiles,getParser,ignoreFunc});
1
+ "use strict";var d=Object.create;var o=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var j=(t,r)=>{for(var e in r)o(t,e,{get:r[e],enumerable:!0})},p=(t,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of y(r))!x.call(t,n)&&n!==e&&o(t,n,{get:()=>r[n],enumerable:!(s=f(r,n))||s.enumerable});return t};var a=(t,r,e)=>(e=t!=null?d(w(t)):{},p(r||!t||!t.__esModule?o(e,"default",{value:t,enumerable:!0}):e,t)),P=t=>p(o({},"__esModule",{value:!0}),t);var k={};j(k,{getFiles:()=>F,getParser:()=>v,ignoreFunc:()=>h});module.exports=P(k);var u=a(require("node:path")),l=require("glob"),g=require("minimatch"),b=a(require("tree-sitter-javascript")),c=a(require("tree-sitter-php")),m=a(require("tree-sitter-typescript")),i=require("../utils/common.js");function v(t){switch((0,i.getFileExtension)(t)){case"ts":return m.typescript;case"tsx":return m.tsx;case"js":case"jsx":case"mjs":case"cjs":return b;case"php":return c.php;case"blade.php":return c.php_only;default:return null}}const h=(t,r)=>r.some(e=>{switch((0,i.detectPatternType)(e)){case"file":return t.isNamed(e);case"directory":return t.relative().includes(e);default:return(0,g.minimatch)(t.relative(),e)}});async function F(t,r){return new l.Glob(r.include,{ignore:{ignored:s=>h(s,r.exclude)},nodir:!0,cwd:t.paths.cwd,root:t.paths.root?u.default.resolve(t.paths.root):void 0}).walk()}0&&(module.exports={getFiles,getParser,ignoreFunc});
@@ -1 +1,7 @@
1
- {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/fs/glob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkB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,CAAC,CAAC;AAjBW,QAAA,UAAU,cAiBrB;AAEF;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAU,EAAE,OAAiB;IACrD,kDAAkD;IAClD,OAAO,IAAI,WAAI,CAAC,OAAO,CAAC,OAAO,EAAE;QAChC,MAAM,EAAE;YACP,OAAO,EAAE,CAAC,CAAO,EAAE,EAAE,CAAC,IAAA,kBAAU,EAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC;SACpD;QACD,KAAK,EAAE,IAAI;QACX,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG;QACnB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KACjE,CAAC,CAAC;AACJ,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/fs/glob.ts"],
4
+ "sourcesContent": ["import path from 'node:path'\r\nimport { Glob, type Path } from 'glob'\r\nimport { minimatch } from 'minimatch'\r\nimport * as javascript from 'tree-sitter-javascript'\r\n// @ts-expect-error\r\nimport * as php from 'tree-sitter-php'\r\n// @ts-expect-error\r\nimport * as ts from 'tree-sitter-typescript'\r\nimport type { Args, Patterns } from '../types.js'\r\nimport { detectPatternType, getFileExtension } from '../utils/common.js'\r\n\r\n/**\r\n * Return the parser based on the file extension\r\n *\r\n * @param file - Path to the file\r\n * @return {Parser|null} - the parser to be used with the file or null if no parser is found\r\n */\r\nexport function getParser(\r\n\tfile: string,\r\n): string | { name: string; language: unknown } | null {\r\n\tconst ext = getFileExtension(file);\r\n\tswitch (ext) {\r\n\t\tcase \"ts\":\r\n\t\t\treturn ts.typescript;\r\n\t\tcase \"tsx\":\r\n\t\t\treturn ts.tsx;\r\n\t\tcase \"js\":\r\n\t\tcase \"jsx\":\r\n\t\tcase \"mjs\":\r\n\t\tcase \"cjs\":\r\n\t\t\treturn javascript;\r\n\t\tcase \"php\":\r\n\t\t\treturn php.php;\r\n\t\tcase \"blade.php\":\r\n\t\t\treturn php.php_only;\r\n\t\tdefault:\r\n\t\t\treturn null;\r\n\t}\r\n}\r\n\r\n// Build the ignore function for Glob\r\nexport const ignoreFunc = (\r\n\tfilePath: Path,\r\n\texcludedPatterns: string[],\r\n): boolean => {\r\n\treturn excludedPatterns.some((exclude) => {\r\n\t\tconst type = detectPatternType(exclude);\r\n\t\t// return true to ignore\r\n\t\tswitch (type) {\r\n\t\t\tcase \"file\":\r\n\t\t\t\treturn filePath.isNamed(exclude);\r\n\t\t\tcase \"directory\":\r\n\t\t\t\treturn filePath.relative().includes(exclude);\r\n\t\t\tdefault:\r\n\t\t\t\t// Handle glob patterns using minimatch\r\n\t\t\t\treturn minimatch(filePath.relative(), exclude);\r\n\t\t}\r\n\t}) as boolean;\r\n};\r\n\r\n/**\r\n * Retrieves a list of files based on the provided arguments and patterns.\r\n *\r\n * @param {Args} args - The argument object containing the source directory and other options.\r\n * @param {Patterns} pattern - The pattern object containing the included and excluded file patterns.\r\n * @return A promise that resolves to an array of file paths.\r\n */\r\nexport async function getFiles(args: Args, pattern: Patterns): Promise<string[]> {\r\n\t// 1. Create the Glob instance\r\n\tconst g = new Glob(pattern.include, {\r\n\t\tignore: {\r\n\t\t\tignored: (p: Path) => ignoreFunc(p, pattern.exclude),\r\n\t\t},\r\n\t\tnodir: true,\r\n\t\tcwd: args.paths.cwd,\r\n\t\troot: args.paths.root ? path.resolve(args.paths.root) : undefined,\r\n\t});\r\n\r\n\t// 2. Return the walk() promise, which resolves to an array of all file paths\r\n\treturn g.walk();\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;AACjB,kBAAgC;AAChC,uBAA0B;AAC1B,iBAA4B;AAE5B,UAAqB;AAErB,SAAoB;AAEpB,oBAAoD;AAQ7C,SAAS,UACf,MACsD;AACtD,QAAM,UAAM,gCAAiB,IAAI;AACjC,UAAQ,KAAK;AAAA,IACZ,KAAK;AACJ,aAAO,GAAG;AAAA,IACX,KAAK;AACJ,aAAO,GAAG;AAAA,IACX,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO,IAAI;AAAA,IACZ,KAAK;AACJ,aAAO,IAAI;AAAA,IACZ;AACC,aAAO;AAAA,EACT;AACD;AAGO,MAAM,aAAa,CACzB,UACA,qBACa;AACb,SAAO,iBAAiB,KAAK,CAAC,YAAY;AACzC,UAAM,WAAO,iCAAkB,OAAO;AAEtC,YAAQ,MAAM;AAAA,MACb,KAAK;AACJ,eAAO,SAAS,QAAQ,OAAO;AAAA,MAChC,KAAK;AACJ,eAAO,SAAS,SAAS,EAAE,SAAS,OAAO;AAAA,MAC5C;AAEC,mBAAO,4BAAU,SAAS,SAAS,GAAG,OAAO;AAAA,IAC/C;AAAA,EACD,CAAC;AACF;AASA,eAAsB,SAAS,MAAY,SAAsC;AAEhF,QAAM,IAAI,IAAI,iBAAK,QAAQ,SAAS;AAAA,IACnC,QAAQ;AAAA,MACP,SAAS,CAAC,MAAY,WAAW,GAAG,QAAQ,OAAO;AAAA,IACpD;AAAA,IACA,OAAO;AAAA,IACP,KAAK,KAAK,MAAM;AAAA,IAChB,MAAM,KAAK,MAAM,OAAO,iBAAAA,QAAK,QAAQ,KAAK,MAAM,IAAI,IAAI;AAAA,EACzD,CAAC;AAGD,SAAO,EAAE,KAAK;AACf;",
6
+ "names": ["path"]
7
+ }
package/lib/index.js.map CHANGED
@@ -1 +1,7 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,mFAAyD;AAc7B,wBAdrB,yBAAa,CAcqB;AAbzC,sEAAwC;AAa/B,mBAbF,wBAAQ,CAaE;AAZjB,oEAAsC;AAYnB,kBAZZ,uBAAO,CAYY;AAV1B,8CAAoD;AAA3C,2GAAA,eAAe,OAAA;AACxB,kDAAgE;AAAvD,4GAAA,OAAO,OAAkB;AAClC,4CAA0C;AAAjC,iGAAA,MAAM,OAAA;AACf,gDAAqD;AAA5C,wGAAA,aAAa,OAAA;AACtB,sDAIiC;AAHhC,iHAAA,mBAAmB,OAAA;AACnB,4GAAA,cAAc,OAAA;AACd,kHAAA,oBAAoB,OAAA"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["import StringAuditor from \"./extractors/auditStrings.js\";\nimport makeJson from \"./jsonCommand.js\";\nimport makePot from \"./potCommand.js\";\n\nexport { MakeJsonCommand } from \"./parser/makeJson\";\nexport { makePot as makePotCommand } from \"./parser/makePot.js\";\nexport { doTree } from \"./parser/tree.js\";\nexport { parseJsonFile } from \"./extractors/json.js\";\nexport {\n\textractMainFileData,\n\tgenerateHeader,\n\tgetAuthorFromPackage,\n} from \"./extractors/headers.js\";\n\nexport { makeJson, makePot, StringAuditor };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,2CAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,qCAAAC;AAAA,EAAA,iCAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,0BAA0B;AAC1B,yBAAqB;AACrB,wBAAoB;AAEpB,sBAAgC;AAChC,qBAA0C;AAC1C,kBAAuB;AACvB,kBAA8B;AAC9B,qBAIO;",
6
+ "names": ["StringAuditor", "makeJson", "makePot"]
7
+ }
@@ -1 +1,7 @@
1
- {"version":3,"file":"jsonCommand.js","sourceRoot":"","sources":["../src/jsonCommand.ts"],"names":[],"mappings":";;;;;AAIA,kCAoBC;AAxBD,uEAAmD;AAEnD,iDAAsE;AAEtE,SAAwB,eAAe,CAAC,IAAkB;IACzD,MAAM,QAAQ,GAAG,IAAI,qBAAe,CAAC,IAAI,CAAC,CAAC;IAE3C,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,IAAA,2BAAe,GAAE,CAAC;QAClB,4BAA4B;QAC5B,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,QAAQ;aACN,IAAI,EAAE;aACN,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAChB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;YACD,yBAAyB;YACzB,IAAA,4BAAgB,EAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChB,OAAO,CAAC,KAAK,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC;AACF,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/jsonCommand.ts"],
4
+ "sourcesContent": ["import MakeJsonCommand from \"./parser/makeJson.js\";\nimport type { MakeJsonArgs } from \"./types.js\";\nimport { printModuleInfo, printTimeElapsed } from \"./utils/common.js\";\n\nexport default function makeJsonCommand(args: MakeJsonArgs) {\n\tconst makeJson = new MakeJsonCommand(args);\n\n\tif (Object.keys(args).length > 0) {\n\t\tprintModuleInfo();\n\t\t/* capture the start time */\n\t\tconst timeStart = new Date();\n\t\tmakeJson\n\t\t\t.exec()\n\t\t\t.then((result) => {\n\t\t\t\tif (args.debug) {\n\t\t\t\t\tconsole.log(result);\n\t\t\t\t}\n\t\t\t\t/* output the end time */\n\t\t\t\tprintTimeElapsed(\"Make-Json\", timeStart);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconsole.error(`\uD83E\uDEE4 make-json - Error: ${error}`);\n\t\t\t});\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA4B;AAE5B,oBAAkD;AAEnC,SAAR,gBAAiC,MAAoB;AAC3D,QAAM,WAAW,IAAI,gBAAAA,QAAgB,IAAI;AAEzC,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AACjC,uCAAgB;AAEhB,UAAM,YAAY,oBAAI,KAAK;AAC3B,aACE,KAAK,EACL,KAAK,CAAC,WAAW;AACjB,UAAI,KAAK,OAAO;AACf,gBAAQ,IAAI,MAAM;AAAA,MACnB;AAEA,0CAAiB,aAAa,SAAS;AAAA,IACxC,CAAC,EACA,MAAM,CAAC,UAAU;AACjB,cAAQ,MAAM,gCAAyB,KAAK,EAAE;AAAA,IAC/C,CAAC;AAAA,EACH;AACD;",
6
+ "names": ["MakeJsonCommand"]
7
+ }
@@ -1 +1,7 @@
1
- {"version":3,"file":"makeJson.js","sourceRoot":"","sources":["../src/makeJson.ts"],"names":[],"mappings":";;;;;;AAEA,yDAAmD;AACnD,sEAAwC;AAExC,MAAM,IAAI,GAAG,IAAA,4BAAW,GAAE,CAAC;AAE3B,IAAA,wBAAQ,EAAC,IAAI,CAAC,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/makeJson.ts"],
4
+ "sourcesContent": ["#!/usr/bin/env node\n\nimport { getJsonArgs } from \"./cli/getJsonArgs.js\";\nimport makeJson from \"./jsonCommand.js\";\n\nconst args = getJsonArgs();\n\nmakeJson(args);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAEA,yBAA4B;AAC5B,yBAAqB;AAErB,MAAM,WAAO,gCAAY;AAAA,IAEzB,mBAAAA,SAAS,IAAI;",
6
+ "names": ["makeJson"]
7
+ }
@@ -1 +1,7 @@
1
- {"version":3,"file":"makePot.js","sourceRoot":"","sources":["../src/makePot.ts"],"names":[],"mappings":";;;;;;AAEA,iDAA2C;AAC3C,oEAA6C;AAG7C,qBAAqB;AACrB,IAAA,uBAAc,EAAC,IAAA,oBAAO,GAAU,CAAC,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/makePot.ts"],
4
+ "sourcesContent": ["#!/usr/bin/env node\n\nimport { getArgs } from \"./cli/getArgs.js\";\nimport makepotCommand from \"./potCommand.js\";\nimport type { Args } from \"./types.js\";\n\n/** Main execution */\nmakepotCommand(getArgs() as Args);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAEA,qBAAwB;AACxB,wBAA2B;AAAA,IAI3B,kBAAAA,aAAe,wBAAQ,CAAS;",
6
+ "names": ["makepotCommand"]
7
+ }
@@ -1,3 +1,3 @@
1
- "use strict";var w=Object.create;var s=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var k=(t,o)=>{for(var e in o)s(t,e,{get:o[e],enumerable:!0})},c=(t,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of S(o))!$.call(t,n)&&n!==e&&s(t,n,{get:()=>o[n],enumerable:!(i=x(o,n))||i.enumerable});return t};var A=(t,o,e)=>(e=t!=null?w(v(t)):{},c(o||!t||!t.__esModule?s(e,"default",{value:t,enumerable:!0}):e,t)),B=t=>c(s({},"__esModule",{value:!0}),t);var H={};k(H,{exec:()=>G});module.exports=B(H);var m=A(require("node:path")),f=require("gettext-parser"),h=require("../extractors/auditStrings.js"),p=require("../extractors/headers.js"),a=require("../fs/fs.js"),r=require("../utils/common.js"),u=require("../utils/output"),d=require("./patterns.js"),g=require("./process.js"),y=require("./progress.js"),T=require("./taskRunner.js");async function G(t){t.options?.silent||(console.log("\u{1F4DD} Starting makePot for",t?.slug),(0,r.printStats)());const o=await(0,p.generateHeader)(t);let e=(0,p.translationsHeaders)(t);t.options?.silent||(0,r.outputPathRecap)(m.default.resolve(t.paths.cwd),t.patterns);const i=(0,y.initProgress)(t,0);i.start(3,1,{filename:`Resolving files in ${m.default.resolve(t.paths.cwd)}`});const n=(0,d.getPatterns)(t),l=await(0,g.processFiles)(n,t);if(i.update(2,{filename:`Found ${l.length} files... `}),e=await(0,T.taskRunner)(l,e,t,i),t.options?.skip.audit||(console.log(`
1
+ "use strict";var w=Object.create;var s=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var k=(t,o)=>{for(var e in o)s(t,e,{get:o[e],enumerable:!0})},c=(t,o,e,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of S(o))!$.call(t,i)&&i!==e&&s(t,i,{get:()=>o[i],enumerable:!(n=x(o,i))||n.enumerable});return t};var A=(t,o,e)=>(e=t!=null?w(v(t)):{},c(o||!t||!t.__esModule?s(e,"default",{value:t,enumerable:!0}):e,t)),B=t=>c(s({},"__esModule",{value:!0}),t);var H={};k(H,{exec:()=>G});module.exports=B(H);var l=A(require("node:path")),f=require("gettext-parser"),h=require("../extractors/auditStrings.js"),p=require("../extractors/headers.js"),a=require("../fs/fs.js"),r=require("../utils/common.js"),u=require("../utils/output"),d=require("./patterns.js"),g=require("./process.js"),y=require("./progress.js"),T=require("./taskRunner.js");async function G(t){t.options?.silent||(console.log("\u{1F4DD} Starting makePot for",t?.slug),(0,r.printStats)());const o=await(0,p.generateHeader)(t);let e=(0,p.translationsHeaders)(t);t.options?.silent||(0,r.outputPathRecap)(l.default.resolve(t.paths.cwd),t.patterns);const n=(0,y.initProgress)(t,0);n.start(3,1,{filename:`Resolving files in ${l.default.resolve(t.paths.cwd)}`});const i=(0,d.getPatterns)(t),m=await(0,g.processFiles)(i,t,n);if(n.start(m.length,0,{filename:`Found ${m.length} files... `}),e=await(0,T.taskRunner)(m,e,t,n),t.options?.skip.audit||(console.log(`
2
2
  Audit strings...`),(0,h.audit)(t,e)),t.options?.json)return(0,u.outputJson)(t,o,e);const C={charset:(0,a.getEncodingCharset)(t.options?.charset),headers:o,translations:e.toJson()},P=f.po.compile(C).toString((0,a.getCharset)(t.options?.charset));return`${t.options?.fileComment||(0,r.getCopyright)(t.headers?.name||t.slug,t.headers?.license??"GPL v2 or later")}
3
3
  ${P}`}0&&(module.exports={exec});
@@ -1 +1,7 @@
1
- {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/parser/exec.ts"],"names":[],"mappings":";;;;;AAoBA,oBA0EC;AA9FD,0DAA6B;AAE7B,mDAA8D;AAC9D,mEAAsD;AACtD,yDAA+E;AAC/E,uCAA6D;AAE7D,kDAA+E;AAC/E,4CAA6C;AAC7C,+CAA4C;AAC5C,6CAA4C;AAC5C,+CAA6C;AAC7C,mDAA6C;AAE7C;;;;;GAKG;AACI,KAAK,UAAU,IAAI,CAAC,IAAU;IACpC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACnD,IAAA,sBAAU,GAAE,CAAC;IACd,CAAC;IAED,sEAAsE;IACtE,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAc,EAAC,IAAI,CAAC,CAAC;IAE7C,8GAA8G;IAC9G,IAAI,iBAAiB,GAAG,IAAA,gCAAmB,EAAC,IAAI,CAAC,CAAC;IAElD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM;QACxB,IAAA,2BAAe,EAAC,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE9D;;OAEG;IACH,MAAM,WAAW,GAAc,IAAA,0BAAY,EAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACrD,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE;QACvB,QAAQ,EAAE,sBAAsB,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;KAC9D,CAAC,CAAC;IAEH;;OAEG;IACH,MAAM,QAAQ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CAAC,OAAO,EAAE,OAAkB,IAAI,iBAAiB,CACtD,CAAC;IACH,OAAO,GAAG,gBAAgB,KAAK,kBAAkB,EAAE,CAAC;AACrD,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/parser/exec.ts"],
4
+ "sourcesContent": ["import path from \"node:path\";\nimport type { SingleBar } from \"cli-progress\";\nimport { type GetTextTranslations, po } from \"gettext-parser\";\nimport { audit } from \"../extractors/auditStrings.js\";\nimport { generateHeader, translationsHeaders } from \"../extractors/headers.js\";\nimport { getCharset, getEncodingCharset } from \"../fs/fs.js\";\nimport type { Args } from \"../types.js\";\nimport { getCopyright, outputPathRecap, printStats } from \"../utils/common.js\";\nimport { outputJson } from \"../utils/output\";\nimport { getPatterns } from \"./patterns.js\";\nimport { processFiles } from \"./process.js\";\nimport { initProgress } from \"./progress.js\";\nimport { taskRunner } from \"./taskRunner.js\";\n\n/**\n * Runs the parser and generates the pot file or the json file based on the command line arguments\n *\n * @param {Args} args - The command line arguments\n * @return {Promise<string>} - A promise that resolves with the generated pot file\n */\nexport async function exec(args: Args): Promise<string> {\n\tif (!args.options?.silent) {\n\t\tconsole.log(\"\uD83D\uDCDD Starting makePot for\", args?.slug);\n\t\tprintStats();\n\t}\n\n\t/** The pot file header contains the data about the plugin or theme */\n\tconst potHeader = await generateHeader(args);\n\n\t/** We need to find the main file data so that the definitions are extracted from the plugin or theme files */\n\tlet translationsUnion = translationsHeaders(args);\n\n\tif (!args.options?.silent)\n\t\toutputPathRecap(path.resolve(args.paths.cwd), args.patterns);\n\n\t/**\n\t * The progress bar that is used to show the progress of the extraction process.\n\t */\n\tconst progressBar: SingleBar = initProgress(args, 0);\n\tprogressBar.start(3, 1, {\n\t\tfilename: `Resolving files in ${path.resolve(args.paths.cwd)}`,\n\t});\n\n\t/**\n\t * Extract the strings from the files\n\t */\n\tconst patterns = getPatterns(args);\n\tconst files = await processFiles(patterns, args, progressBar);\n\n\tprogressBar.start(files.length, 0, {\n\t\tfilename: `Found ${files.length} files... `,\n\t});\n\n\ttranslationsUnion = await taskRunner(\n\t\tfiles,\n\t\ttranslationsUnion,\n\t\targs,\n\t\tprogressBar,\n\t);\n\n\t/**\n\t * Audit Strings: Strings are validated and reported to the user if they are not compliant.\n\t * --skip-audit flag turns this off\n\t **/\n\tif (!args.options?.skip.audit) {\n\t\tconsole.log(\"\\nAudit strings...\");\n\t\taudit(args, translationsUnion);\n\t}\n\n\t/** generate the JSON file based on the --json flag passed */\n\tif (args.options?.json) {\n\t\treturn outputJson(args, potHeader, translationsUnion);\n\t}\n\n\t/** Generate the pot file JSON */\n\tconst getTextTranslations: GetTextTranslations = {\n\t\tcharset: getEncodingCharset(args.options?.charset),\n\t\theaders: potHeader as { [headerName: string]: string },\n\t\ttranslations: translationsUnion.toJson(),\n\t};\n\n\t/** And then compile the pot file to a string */\n\tconst pluginTranslations = po\n\t\t.compile(getTextTranslations)\n\t\t.toString(getCharset(args.options?.charset));\n\n\t/** Return the pot file as a string, prefixed with the header */\n\tconst copyrightComment =\n\t\targs.options?.fileComment ||\n\t\tgetCopyright(\n\t\t\targs.headers?.name || args.slug,\n\t\t\t(args.headers?.license as string) ?? \"GPL v2 or later\",\n\t\t);\n\treturn `${copyrightComment}\\n${pluginTranslations}`;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;AAEjB,4BAA6C;AAC7C,0BAAsB;AACtB,qBAAoD;AACpD,gBAA+C;AAE/C,oBAA0D;AAC1D,oBAA2B;AAC3B,sBAA4B;AAC5B,qBAA6B;AAC7B,sBAA6B;AAC7B,wBAA2B;AAQ3B,eAAsB,KAAK,MAA6B;AACvD,MAAI,CAAC,KAAK,SAAS,QAAQ;AAC1B,YAAQ,IAAI,kCAA2B,MAAM,IAAI;AACjD,kCAAW;AAAA,EACZ;AAGA,QAAM,YAAY,UAAM,+BAAe,IAAI;AAG3C,MAAI,wBAAoB,oCAAoB,IAAI;AAEhD,MAAI,CAAC,KAAK,SAAS;AAClB,uCAAgB,iBAAAA,QAAK,QAAQ,KAAK,MAAM,GAAG,GAAG,KAAK,QAAQ;AAK5D,QAAM,kBAAyB,8BAAa,MAAM,CAAC;AACnD,cAAY,MAAM,GAAG,GAAG;AAAA,IACvB,UAAU,sBAAsB,iBAAAA,QAAK,QAAQ,KAAK,MAAM,GAAG,CAAC;AAAA,EAC7D,CAAC;AAKD,QAAM,eAAW,6BAAY,IAAI;AACjC,QAAM,QAAQ,UAAM,6BAAa,UAAU,MAAM,WAAW;AAE5D,cAAY,MAAM,MAAM,QAAQ,GAAG;AAAA,IAClC,UAAU,SAAS,MAAM,MAAM;AAAA,EAChC,CAAC;AAED,sBAAoB,UAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAMA,MAAI,CAAC,KAAK,SAAS,KAAK,OAAO;AAC9B,YAAQ,IAAI,oBAAoB;AAChC,mCAAM,MAAM,iBAAiB;AAAA,EAC9B;AAGA,MAAI,KAAK,SAAS,MAAM;AACvB,eAAO,0BAAW,MAAM,WAAW,iBAAiB;AAAA,EACrD;AAGA,QAAM,sBAA2C;AAAA,IAChD,aAAS,8BAAmB,KAAK,SAAS,OAAO;AAAA,IACjD,SAAS;AAAA,IACT,cAAc,kBAAkB,OAAO;AAAA,EACxC;AAGA,QAAM,qBAAqB,yBACzB,QAAQ,mBAAmB,EAC3B,aAAS,sBAAW,KAAK,SAAS,OAAO,CAAC;AAG5C,QAAM,mBACL,KAAK,SAAS,mBACd;AAAA,IACC,KAAK,SAAS,QAAQ,KAAK;AAAA,IAC1B,KAAK,SAAS,WAAsB;AAAA,EACtC;AACD,SAAO,GAAG,gBAAgB;AAAA,EAAK,kBAAkB;AAClD;",
6
+ "names": ["path"]
7
+ }
@@ -1 +1 @@
1
- "use strict";var P=Object.create;var g=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var D=(o,t)=>{for(var e in t)g(o,e,{get:t[e],enumerable:!0})},v=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of N(t))!$.call(o,i)&&i!==e&&g(o,i,{get:()=>t[i],enumerable:!(s=w(t,i))||s.enumerable});return o};var m=(o,t,e)=>(e=o!=null?P(M(o)):{},v(t||!o||!o.__esModule?g(e,"default",{value:o,enumerable:!0}):e,o)),C=o=>v(g({},"__esModule",{value:!0}),o);var G={};D(G,{MakeJsonCommand:()=>F,default:()=>I});module.exports=C(G);var S=m(require("node:crypto")),c=m(require("node:fs")),a=m(require("node:path")),x=require("@babel/core"),k=require("gettext-parser"),h=require("glob"),d=require("../const.js"),J=require("../utils/common.js"),T=require("./tree");class F{source;destination;allowedFormats;purge;prettyPrint;debug;scriptName;paths;sourceDir;stripUnused;constructor(t){if(this.sourceDir=a.default.relative(t.paths.cwd,t.source??""),!c.existsSync(this.sourceDir))throw console.error("Source directory not found",t),new Error(`Source directory ${this.sourceDir} not found`);this.stripUnused=t.stripUnused,this.scriptName=t.scriptName,this.source=t.source,this.destination=t.destination,this.allowedFormats=t.allowedFormats??[".ts",".tsx",".js",".jsx",".mjs",".cjs"],this.purge=t.purge,this.prettyPrint=t.prettyPrint,this.debug=t.debug,this.paths=t.paths}async exec(){const t=await(0,h.glob)("**/*.po",{cwd:this.destination,nodir:!0});console.log("Found po files",t,"in",this.destination,"folder");const e={};for(const s of t){this.scriptName||(this.scriptName=await(0,h.glob)("**/*.js",{cwd:this.source,nodir:!0}),console.log(`Found script: ${this.scriptName} in ${this.source} folder`)),typeof this.scriptName=="string"&&(this.scriptName=[this.scriptName]);for(const i of this.scriptName){const n=this.addPot(s,i);n.data?e[n.filename]=n.data:console.log(`\u274C Translation strings not found in Script ${i} in ${s} po file`)}}for(const[s,i]of Object.entries(e)){let n;if(this.purge)c.existsSync(a.default.join(this.destination,s))&&(console.log(`Removing ${a.default.join(this.destination,s)} as the purge option is enabled`),c.unlinkSync(a.default.join(this.destination,s))),n=JSON.stringify(i,null,this?.prettyPrint?2:0);else{const l=c.readFileSync(a.default.join(this.source,s),"utf8");n=JSON.stringify({...i,...JSON.parse(l)},null,this?.prettyPrint?2:0)}const r=a.default.join(this.destination,s);c.writeFileSync(r,n),console.log(`\u2705 JSON file written to ${r} with ${s}`)}return e}processFile(t,e,s="utf8"){const i=a.default.join(this.destination,t),n=c.readFileSync(i,s),r=this.parsePoFile(n);if(this.stripUnused){const l=this.parseScript(e);if(!l)return null;const p=this.compareStrings(l.blocks,r);if(!p)return null;r.translations=p.translations}return this.convertToJed(r.headers,r.translations,e,this.extractIsoCode(i))}parsePoFile(t){return k.po.parse(t)}convertToJed(t,e,s,i){const n=(0,J.getPkgJsonData)(d.modulePath,"name","version"),r="messages",l=`${n.name}/${n.version}`,p={[r]:{"":{domain:r,lang:i||t.Language||"en",plural_forms:t["Plural-Forms"]||"nplurals=2; plural=(n != 1);"}}};for(const u of Object.keys(e)){const y=e[u];for(const f of Object.keys(y)){const b=y[f];if(f==="")continue;const j=u&&u!==""?`${u}${f}`:f;p[r][j]=b.msgstr}}return{"translation-revision-date":new Date().toISOString(),generator:l,source:a.default.join(this.sourceDir,s).replace(/\\/g,"/"),domain:r,locale_data:p}}extractIsoCode(t){const e=t.match(d.IsoCodeRegex);return e?e[1]:void 0}md5(t){return S.default.createHash("md5").update(t).digest("hex")}generateFilename(t,e){const s=this.md5(t);return e.replace(".po",`-${s}.json`)}addPot(t,e){return{filename:this.generateFilename(a.default.join(this.source,e).replace(/\\/g,"/"),t),data:this.processFile(t,e)}}compareStrings(t,e){const s={charset:e.charset,headers:{...e.headers},translations:{"":{}}};e.translations[""][""]&&(s.translations[""][""]={...e.translations[""][""]});const i=new Set(t.map(n=>n.msgid));for(const n in e.translations)if(n==="")for(const r in e.translations[n])r!==""&&i.has(r)&&(s.translations[n]||(s.translations[n]={}),s.translations[n][r]={...e.translations[n][r]});return Object.keys(s.translations[""]).length<=1?null:s}parseScript(t){const e=c.readFileSync(a.default.join(this.source,t),"utf8"),s=(0,x.transformSync)(e,{configFile:!1,presets:["@babel/preset-env"],compact:!1,comments:!0,sourceMaps:!1,plugins:[({types:i})=>({visitor:{CallExpression(n){const r=n.node.callee;if(i.isSequenceExpression(r)&&i.isMemberExpression(r.expressions[1])){const l=r.expressions[1].property;i.isIdentifier(l)&&d.allowedFunctions.has(l.name)&&(n.node.callee=i.identifier(l.name))}}}})]}).code;return(0,T.doTree)(s,t,this.debug)}}var I=F;0&&(module.exports={MakeJsonCommand});
1
+ "use strict";var j=Object.create;var g=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var D=(o,t)=>{for(var e in t)g(o,e,{get:t[e],enumerable:!0})},x=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of M(t))!$.call(o,i)&&i!==e&&g(o,i,{get:()=>t[i],enumerable:!(s=w(t,i))||s.enumerable});return o};var h=(o,t,e)=>(e=o!=null?j(E(o)):{},x(t||!o||!o.__esModule?g(e,"default",{value:o,enumerable:!0}):e,o)),C=o=>x(g({},"__esModule",{value:!0}),o);var I={};D(I,{MakeJsonCommand:()=>T,default:()=>B});module.exports=C(I);var v=h(require("node:crypto")),d=h(require("node:fs")),a=h(require("node:path")),S=require("@babel/core"),b=require("gettext-parser"),y=require("glob"),u=require("../const.js"),k=require("../utils/common.js"),J=require("./tree");class T{source;destination;allowedFormats;purge;prettyPrint;debug;scriptName;paths;sourceDir;stripUnused;constructor(t){if(this.sourceDir=a.default.relative(t.paths.cwd,t.source??""),!d.existsSync(this.sourceDir))throw console.error("Source directory not found",t),new Error(`Source directory ${this.sourceDir} not found`);this.stripUnused=t.stripUnused,this.scriptName=t.scriptName,this.source=t.source,this.destination=t.destination,this.allowedFormats=t.allowedFormats??[".ts",".tsx",".js",".jsx",".mjs",".cjs"],this.purge=t.purge,this.prettyPrint=t.prettyPrint,this.debug=t.debug,this.paths=t.paths}async exec(){const t=await(0,y.glob)("**/*.po",{cwd:this.destination,nodir:!0});console.log("Found po files",t,"in",this.destination,"folder");const e={};for(const s of t){this.scriptName||(this.scriptName=await(0,y.glob)("**/*.js",{cwd:this.source,nodir:!0}),console.log(`Found script: ${this.scriptName} in ${this.source} folder`)),typeof this.scriptName=="string"&&(this.scriptName=[this.scriptName]);for(const i of this.scriptName){const n=this.addPot(s,i);n.data?e[n.filename]=n.data:console.log(`\u274C Translation strings not found in Script ${i} in ${s} po file`)}}for(const[s,i]of Object.entries(e)){let n;if(this.purge)d.existsSync(a.default.join(this.destination,s))&&(console.log(`Removing ${a.default.join(this.destination,s)} as the purge option is enabled`),d.unlinkSync(a.default.join(this.destination,s))),n=JSON.stringify(i,null,this?.prettyPrint?2:0);else{const c=d.readFileSync(a.default.join(this.source,s),"utf8");n=JSON.stringify({...i,...JSON.parse(c)},null,this?.prettyPrint?2:0)}const r=a.default.join(this.destination,s);d.writeFileSync(r,n),console.log(`\u2705 JSON file written to ${r} with ${s}`)}return e}processFile(t,e,s="utf8"){const i=a.default.join(this.destination,t),n=d.readFileSync(i,s),r=this.parsePoFile(n);if(this.stripUnused){const c=this.parseScript(e);if(!c)return null;const l=this.compareStrings(c.blocks,r);if(!l)return null;r.translations=l.translations}return this.convertToJed(r.headers,r.translations,e,this.extractIsoCode(i))}parsePoFile(t){return b.po.parse(t)}convertToJed(t,e,s,i){const n=(0,k.getPkgJsonData)(u.modulePath,"name","version"),r="messages",c=`${n.name}/${n.version}`,l={[r]:{"":{domain:r,lang:i||t.Language||"en",plural_forms:t["Plural-Forms"]||"nplurals=2; plural=(n != 1);"}}};for(const p of Object.keys(e)){const f=e[p];for(const m of Object.keys(f)){const F=f[m];if(m==="")continue;const N=p&&p!==""?`${p}${m}`:m;l[r][N]=F.msgstr}}return{"translation-revision-date":new Date().toISOString(),generator:c,source:a.default.join(this.sourceDir,s).replace(/\\/g,"/"),domain:r,locale_data:l}}extractIsoCode(t){const e=t.match(u.IsoCodeRegex);return e?e[1]:void 0}md5(t){return v.default.createHash("md5").update(t).digest("hex")}generateFilename(t,e){const s=this.md5(t);return e.replace(".po",`-${s}.json`)}addPot(t,e){return{filename:this.generateFilename(a.default.join(this.source,e).replace(/\\/g,"/"),t),data:this.processFile(t,e)}}compareStrings(t,e){const s={charset:e.charset,headers:{...e.headers},translations:{"":{}}};e.translations[""][""]&&(s.translations[""][""]={...e.translations[""][""]});const i=new Set(t.map(n=>n.msgid));for(const n in e.translations)if(n==="")for(const r in e.translations[n])r!==""&&i.has(r)&&(s.translations[n]||(s.translations[n]={}),s.translations[n][r]={...e.translations[n][r]});return Object.keys(s.translations[""]).length<=1?null:s}parseScript(t){const e=d.readFileSync(a.default.join(this.source,t),"utf8"),s=(0,S.transformSync)(e,{configFile:!1,presets:["@babel/preset-env"],compact:!1,comments:!0,sourceMaps:!1,plugins:[({types:i})=>({visitor:{CallExpression(n){const r=n.node.callee;if(i.isSequenceExpression(r)){const l=r.expressions[1];if(i.isMemberExpression(l)){const p=l.property;if(i.isIdentifier(p)){const f=p;u.allowedFunctions.has(f.name)&&(n.node.callee=i.identifier(f.name))}}}}}})]})?.code??"";return(0,J.doTree)(s,t,this.debug)}}var B=T;0&&(module.exports={MakeJsonCommand});
@@ -1 +1,7 @@
1
- {"version":3,"file":"makeJson.js","sourceRoot":"","sources":["../../src/parser/makeJson.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAiC;AACjC,4CAA8B;AAC9B,0DAA6B;AAC7B,sCAA4C;AAE5C,mDAIwB;AACxB,+BAA4B;AAC5B,0CAAyE;AAEzE,kDAAoD;AACpD,iCAAgC;AAEhC,MAAa,eAAe;IAC3B;;;;OAIG;IACc,MAAM,CAAS;IAChC;;;;OAIG;IACc,WAAW,CAAS;IACrC;;;OAGG;IACc,cAAc,CAAW;IAC1C;;;OAGG;IACc,KAAK,CAAU;IAChC;;;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wBACF,CAAC;qBACD;iBACD,CAAC;aACF;SACD,CAAC,CAAC,IAAc,CAAC;QAElB,OAAO,IAAA,aAAM,EAAC,iBAAiB,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;CACD;AA5bD,0CA4bC;AAED,kBAAe,eAAe,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/parser/makeJson.ts"],
4
+ "sourcesContent": ["import crypto from \"node:crypto\";\r\nimport * as fs from \"node:fs\";\r\nimport path from \"node:path\";\r\nimport { type NodePath, transformSync, type types as BabelTypes } from \"@babel/core\";\r\nimport type { SetOfBlocks } from \"gettext-merger\";\r\nimport {\r\n\ttype GetTextTranslation,\r\n\ttype GetTextTranslations,\r\n\tpo,\r\n} from \"gettext-parser\";\r\nimport { glob } from \"glob\";\r\nimport { IsoCodeRegex, allowedFunctions, modulePath } from \"../const.js\";\r\nimport type { JedData, MakeJson, MakeJsonArgs } from \"../types.js\";\r\nimport { getPkgJsonData } from \"../utils/common.js\";\r\nimport { doTree } from \"./tree\";\r\n\r\nexport class MakeJsonCommand {\r\n\t/**\r\n\t * The source file path.\r\n\t * Should be the \"build\" directory containing .js files\r\n\t * @private\r\n\t */\r\n\tprivate readonly source: string;\r\n\t/**\r\n\t * The destination file path.\r\n\t * Should be the \"languages\" directory containing .po files\r\n\t * @private\r\n\t */\r\n\tprivate readonly destination: string;\r\n\t/**\r\n\t * The allowed file extensions.\r\n\t * @private\r\n\t */\r\n\tprivate readonly allowedFormats: string[];\r\n\t/**\r\n\t * Remove old POT files.\r\n\t * @private\r\n\t */\r\n\tprivate readonly purge: boolean;\r\n\t/**\r\n\t * Pretty print JSON.\r\n\t * @private\r\n\t */\r\n\tprivate readonly prettyPrint: boolean;\r\n\t/**\r\n\t * Enable debug mode.\r\n\t * @private\r\n\t */\r\n\tprivate debug: boolean;\r\n\t/**\r\n\t * The script to be translated.\r\n\t * @private\r\n\t */\r\n\tprivate scriptName: string | string[] | undefined;\r\n\t/**\r\n\t * The paths to be translated.\r\n\t * @private\r\n\t */\r\n\tprivate paths: object | undefined;\r\n\t/**\r\n\t * The source directory.\r\n\t * @private\r\n\t */\r\n\tprivate readonly sourceDir: string;\r\n\t/**\r\n\t * Whenever to strip unused translations from js files\r\n\t * @private\r\n\t */\r\n\tprivate stripUnused: boolean;\r\n\r\n\t/**\r\n\t * The constructor.\r\n\t * @param args - The arguments to the command.\r\n\t */\r\n\tpublic constructor(args: MakeJsonArgs) {\r\n\t\tthis.sourceDir = path.relative(args.paths.cwd, args.source ?? \"\");\r\n\t\tif (!fs.existsSync(this.sourceDir)) {\r\n\t\t\tconsole.error(\"Source directory not found\", args);\r\n\t\t\tthrow new Error(`Source directory ${this.sourceDir} not found`);\r\n\t\t}\r\n\r\n\t\tthis.stripUnused = args.stripUnused;\r\n\t\tthis.scriptName = args.scriptName;\r\n\t\tthis.source = args.source;\r\n\t\tthis.destination = args.destination;\r\n\t\tthis.allowedFormats = args.allowedFormats ?? [\r\n\t\t\t\".ts\",\r\n\t\t\t\".tsx\",\r\n\t\t\t\".js\",\r\n\t\t\t\".jsx\",\r\n\t\t\t\".mjs\",\r\n\t\t\t\".cjs\",\r\n\t\t];\r\n\t\tthis.purge = args.purge;\r\n\t\tthis.prettyPrint = args.prettyPrint;\r\n\t\tthis.debug = args.debug;\r\n\t\tthis.paths = args.paths;\r\n\t}\r\n\r\n\t/**\r\n\t * The main function. Parses the PO files and generates the JSON files.\r\n\t */\r\n\tpublic async exec(): Promise<Record<string, MakeJson>> {\r\n\t\t// get all the files in the source directory\r\n\t\tconst files = await glob(\"**/*.po\", { cwd: this.destination, nodir: true });\r\n\r\n\t\tconsole.log(\"Found po files\", files, \"in\", this.destination, \"folder\");\r\n\r\n\t\t// get all the po files\r\n\t\tconst output: Record<string, MakeJson> = {};\r\n\t\tfor (const file of files) {\r\n\t\t\tif (!this.scriptName) {\r\n\t\t\t\tthis.scriptName = await glob(\"**/*.js\", {\r\n\t\t\t\t\tcwd: this.source,\r\n\t\t\t\t\tnodir: true,\r\n\t\t\t\t});\r\n\t\t\t\tconsole.log(\r\n\t\t\t\t\t`Found script: ${this.scriptName} in ${this.source} folder`,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tif (typeof this.scriptName === \"string\") {\r\n\t\t\t\tthis.scriptName = [this.scriptName];\r\n\t\t\t}\r\n\r\n\t\t\tfor (const script of this.scriptName) {\r\n\t\t\t\tconst pot = this.addPot(file, script);\r\n\t\t\t\tif (pot.data) {\r\n\t\t\t\t\toutput[pot.filename] = pot.data;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tconsole.log(\r\n\t\t\t\t\t\t`\u274C Translation strings not found in Script ${script} in ${file} po file`,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// write the json files\r\n\t\tfor (const [filename, content] of Object.entries(output)) {\r\n\t\t\tlet contentString: string;\r\n\t\t\tif (this.purge) {\r\n\t\t\t\tif (fs.existsSync(path.join(this.destination, filename))) {\r\n\t\t\t\t\tconsole.log(\r\n\t\t\t\t\t\t`Removing ${path.join(this.destination, filename)} as the purge option is enabled`,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tfs.unlinkSync(path.join(this.destination, filename));\r\n\t\t\t\t}\r\n\t\t\t\tcontentString = JSON.stringify(\r\n\t\t\t\t\tcontent,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tthis?.prettyPrint ? 2 : 0,\r\n\t\t\t\t);\r\n\t\t\t} else {\r\n\t\t\t\tconst oldJedContent = fs.readFileSync(\r\n\t\t\t\t\tpath.join(this.source, filename),\r\n\t\t\t\t\t\"utf8\",\r\n\t\t\t\t);\r\n\r\n\t\t\t\tcontentString = JSON.stringify(\r\n\t\t\t\t\t{ ...content, ...JSON.parse(oldJedContent) },\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tthis?.prettyPrint ? 2 : 0,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tconst destinationPath = path.join(this.destination, filename);\r\n\t\t\tfs.writeFileSync(destinationPath, contentString);\r\n\t\t\tconsole.log(\r\n\t\t\t\t`\u2705 JSON file written to ${destinationPath} with ${filename}`,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\t// return the output\r\n\t\treturn output;\r\n\t}\r\n\r\n\t/**\r\n\t * Process a PO file and return the JSON data.\r\n\t * @param file - The path to the PO file.\r\n\t * @param script - The script to be translated.\r\n\t * @param encoding - The encoding of the PO file.\r\n\t */\r\n\tpublic processFile(\r\n\t\tfile: string,\r\n\t\tscript: string,\r\n\t\tencoding: BufferEncoding = \"utf8\",\r\n\t): MakeJson | null {\r\n\t\t// Get the file path\r\n\t\tconst filePath = path.join(this.destination, file);\r\n\r\n\t\t// Read the source file\r\n\t\tconst content = fs.readFileSync(filePath, encoding) as string;\r\n\r\n\t\t// Parse the source file\r\n\t\tconst poContent = this.parsePoFile(content);\r\n\r\n\t\tif (this.stripUnused) {\r\n\t\t\t// get the strings used in the script\r\n\t\t\tconst scriptContent = this.parseScript(script);\r\n\r\n\t\t\tif (!scriptContent) {\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\r\n\t\t\t// compare the strings used in the script with the strings in the po file\r\n\t\t\tconst stringsNotInPoFile = this.compareStrings(\r\n\t\t\t\tscriptContent.blocks,\r\n\t\t\t\tpoContent,\r\n\t\t\t);\r\n\r\n\t\t\tif (!stringsNotInPoFile) {\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\r\n\t\t\t// replace the po file strings with the strings used in the script\r\n\t\t\tpoContent.translations = stringsNotInPoFile.translations;\r\n\t\t}\r\n\r\n\t\t// Convert to Jed json dataset\r\n\t\treturn this.convertToJed(\r\n\t\t\tpoContent.headers,\r\n\t\t\tpoContent.translations,\r\n\t\t\tscript,\r\n\t\t\tthis.extractIsoCode(filePath), // extract the ISO code from the po filename\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * Takes a PO file and returns the header and translations.\r\n\t * @param content - The content of the PO file.\r\n\t * @private\r\n\t *\r\n\t * @returns An object containing the header and translations.\r\n\t */\r\n\tprivate parsePoFile(content: string): GetTextTranslations {\r\n\t\treturn po.parse(content);\r\n\t}\r\n\r\n\t/**\r\n\t * Converts PO data to Jed data.\r\n\t * @param header - The header of the PO file.\r\n\t * @param translations - The translations of the PO file.\r\n\t * @param source - The source of the PO file.\r\n\t * @param languageIsoCode - The ISO code of the language.\r\n\t * @private\r\n\t *\r\n\t * @return An object containing the Jed data.\r\n\t */\r\n\tprivate convertToJed(\r\n\t\theader: Record<string, string>,\r\n\t\ttranslations: {\r\n\t\t\t[msgctxt: string]: { [msgId: string]: GetTextTranslation };\r\n\t\t},\r\n\t\tsource: string,\r\n\t\tlanguageIsoCode?: string,\r\n\t): MakeJson {\r\n\t\tconst packageJson = getPkgJsonData(modulePath, \"name\", \"version\") as {\r\n\t\t\tname: string;\r\n\t\t\tversion: string;\r\n\t\t};\r\n\r\n\t\t// Domain name to use for the Jed format\r\n\t\tconst domain: string = \"messages\";\r\n\r\n\t\tconst generator = `${packageJson.name}/${packageJson.version}`;\r\n\r\n\t\t// Initialize the Jed-compatible structure\r\n\t\tconst jedData: JedData = {\r\n\t\t\t[domain]: {\r\n\t\t\t\t\"\": {\r\n\t\t\t\t\tdomain,\r\n\t\t\t\t\tlang: languageIsoCode || header.Language || \"en\",\r\n\t\t\t\t\tplural_forms:\r\n\t\t\t\t\t\theader[\"Plural-Forms\"] || \"nplurals=2; plural=(n != 1);\",\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t};\r\n\r\n\t\t// Process all translations\r\n\t\tfor (const msgctxt of Object.keys(translations)) {\r\n\t\t\tconst contextTranslations = translations[msgctxt];\r\n\r\n\t\t\tfor (const msgid of Object.keys(contextTranslations)) {\r\n\t\t\t\tconst translation = contextTranslations[msgid];\r\n\r\n\t\t\t\t// Skip empty msgid (header) as we've already handled it\r\n\t\t\t\tif (msgid === \"\") continue;\r\n\r\n\t\t\t\t// Construct the key using context if available\r\n\t\t\t\tconst key =\r\n\t\t\t\t\tmsgctxt && msgctxt !== \"\" ? `${msgctxt}\\u0004${msgid}` : msgid;\r\n\r\n\t\t\t\t// Add the translation to the Jed data structure\r\n\t\t\t\tjedData[domain][key] = translation.msgstr;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst makeJson: {\r\n\t\t\tdomain: string;\r\n\t\t\tgenerator: string;\r\n\t\t\t\"translation-revision-date\": string;\r\n\t\t\tsource: string;\r\n\t\t\tlocale_data: JedData;\r\n\t\t} = {\r\n\t\t\t\"translation-revision-date\": new Date().toISOString(),\r\n\t\t\tgenerator: generator,\r\n\t\t\tsource: path.join(this.sourceDir, source).replace(/\\\\/g, \"/\"),\r\n\t\t\tdomain,\r\n\t\t\tlocale_data: jedData,\r\n\t\t};\r\n\r\n\t\treturn makeJson as MakeJson;\r\n\t}\r\n\r\n\t/**\r\n\t * Gets the ISO code from the filename.\r\n\t * @param filename The filename to extract the ISO code from.\r\n\t * @private\r\n\t *\r\n\t * @returns The ISO code if found, otherwise null.\r\n\t */\r\n\tprivate extractIsoCode(filename: string): string | undefined {\r\n\t\tconst match = filename.match(IsoCodeRegex);\r\n\t\treturn match ? match[1] : undefined;\r\n\t}\r\n\r\n\t/**\r\n\t * Takes a string and returns its md5 hash.\r\n\t * @param text\r\n\t * @private\r\n\t */\r\n\tprivate md5(text: string): string {\r\n\t\treturn crypto.createHash(\"md5\").update(text).digest(\"hex\");\r\n\t}\r\n\r\n\t/**\r\n\t * Generates the filename for the json file.\r\n\t * @param script\r\n\t * @param file\r\n\t * @private\r\n\t */\r\n\tprivate generateFilename(script: string, file: string): string {\r\n\t\tconst scriptName = this.md5(script);\r\n\t\t//build the filename for the json file using the po files\r\n\t\treturn file.replace(\".po\", `-${scriptName}.json`);\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a script to the output object.\r\n\t * @private\r\n\t *\r\n\t * @param potFile - The pot file to parse.\r\n\t * @param script - The script to add.\r\n\t * @return {Record<string, JedData>} - The output object.\r\n\t * */\r\n\tprivate addPot(\r\n\t\tpotFile: string,\r\n\t\tscript: string,\r\n\t): { filename: string; data: MakeJson | null } {\r\n\t\tconst filename = this.generateFilename(\r\n\t\t\tpath.join(this.source, script).replace(/\\\\/g, \"/\"),\r\n\t\t\tpotFile,\r\n\t\t);\r\n\t\t// the processed file is added to the output object\r\n\t\treturn {\r\n\t\t\tfilename,\r\n\t\t\tdata: this.processFile(potFile, script),\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Compares the strings used in the script with the strings in the po file.\r\n\t * @param jsArray - The strings used in the script.\r\n\t * @param poObject - The content of the po file.\r\n\t * @private\r\n\t */\r\n\tprivate compareStrings(\r\n\t\tjsArray: SetOfBlocks[\"blocks\"],\r\n\t\tpoObject: GetTextTranslations,\r\n\t): GetTextTranslations | null {\r\n\t\t// The copy of the po file with only the strings used in the script\r\n\t\tconst filteredPo = {\r\n\t\t\tcharset: poObject.charset,\r\n\t\t\theaders: { ...poObject.headers },\r\n\t\t\ttranslations: { \"\": {} },\r\n\t\t} as GetTextTranslations;\r\n\r\n\t\t// copy the original header\r\n\t\tif (poObject.translations[\"\"][\"\"]) {\r\n\t\t\tfilteredPo.translations[\"\"][\"\"] = { ...poObject.translations[\"\"][\"\"] };\r\n\t\t}\r\n\r\n\t\t// Create a set of message ids from the JS file\r\n\t\tconst jsMessageIds = new Set(jsArray.map((item) => item.msgid));\r\n\r\n\t\t// Iterate over the po file and keep only the strings used in the script\r\n\t\tfor (const domain in poObject.translations) {\r\n\t\t\tif (domain !== \"\") continue; // handle only the main domain\r\n\r\n\t\t\tfor (const msgid in poObject.translations[domain]) {\r\n\t\t\t\tif (msgid === \"\") continue; // Skip the header\r\n\r\n\t\t\t\tif (jsMessageIds.has(msgid)) {\r\n\t\t\t\t\t// ok the msgid is used\r\n\t\t\t\t\tif (!filteredPo.translations[domain]) {\r\n\t\t\t\t\t\tfilteredPo.translations[domain] = {};\r\n\t\t\t\t\t}\r\n\t\t\t\t\tfilteredPo.translations[domain][msgid] = {\r\n\t\t\t\t\t\t...poObject.translations[domain][msgid],\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// check if the po file is empty, 1 means that the header is the only string available\r\n\t\t// TODO: if the json file is empty, we should delete it?\r\n\t\tif (Object.keys(filteredPo.translations[\"\"]).length <= 1) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\treturn filteredPo;\r\n\t}\r\n\r\n\tprivate parseScript(script: string): SetOfBlocks | undefined {\r\n\t\tconst fileContent = fs.readFileSync(path.join(this.source, script), \"utf8\");\r\n\t\tconst transformedScript = transformSync(fileContent, {\r\n\t\t\tconfigFile: false,\r\n\t\t\tpresets: [\"@babel/preset-env\"],\r\n\t\t\tcompact: false,\r\n\t\t\tcomments: true,\r\n\t\t\tsourceMaps: false,\r\n\t\t\tplugins: [\r\n\t\t\t\t({ types: t }) => ({\r\n\t\t\t\t\tvisitor: {\r\n\t\t\t\t\t\tCallExpression(path: NodePath<BabelTypes.CallExpression>) {\r\n\t\t\t\t\t\t\tconst callee = path.node.callee;\r\n\r\n\t\t\t\t\t\t\t// Check for pattern like: (fn)(\"...\")\r\n\t\t\t\t\t\t\tif (t.isSequenceExpression(callee)) {\r\n\t\t\t\t\t\t\t\tconst seqExpr = callee as BabelTypes.SequenceExpression;\r\n\t\t\t\t\t\t\t\tconst secondExpression = seqExpr.expressions[1];\r\n\r\n\t\t\t\t\t\t\t\tif (t.isMemberExpression(secondExpression)) {\r\n\t\t\t\t\t\t\t\t\tconst memberExpr = secondExpression as BabelTypes.MemberExpression;\r\n\t\t\t\t\t\t\t\t\tconst property = memberExpr.property;\r\n\r\n\t\t\t\t\t\t\t\t\tif (t.isIdentifier(property)) {\r\n\t\t\t\t\t\t\t\t\t\t// Cast to Identifier\r\n\t\t\t\t\t\t\t\t\t\tconst identifier = property as BabelTypes.Identifier;\r\n\r\n\t\t\t\t\t\t\t\t\t\tif (allowedFunctions.has(identifier.name)) {\r\n\t\t\t\t\t\t\t\t\t\t\t// Replace with direct function call: __(\"...\"), _n(...), etc.\r\n\t\t\t\t\t\t\t\t\t\t\tpath.node.callee = t.identifier(identifier.name);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t},\r\n\t\t\t\t}),\r\n\t\t\t],\r\n\t\t})?.code ?? '';\r\n\r\n\t\treturn doTree(transformedScript, script, this.debug);\r\n\t}\r\n}\r\n\r\nexport default MakeJsonCommand;\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAmB;AACnB,SAAoB;AACpB,uBAAiB;AACjB,kBAAuE;AAEvE,4BAIO;AACP,kBAAqB;AACrB,mBAA2D;AAE3D,oBAA+B;AAC/B,kBAAuB;AAEhB,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKT;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMD,YAAY,MAAoB;AACtC,SAAK,YAAY,iBAAAA,QAAK,SAAS,KAAK,MAAM,KAAK,KAAK,UAAU,EAAE;AAChE,QAAI,CAAC,GAAG,WAAW,KAAK,SAAS,GAAG;AACnC,cAAQ,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,oBAChD;AAAA,kBACD;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD,CAAC,GAAG,QAAQ;AAEZ,eAAO,oBAAO,mBAAmB,QAAQ,KAAK,KAAK;AAAA,EACpD;AACD;AAEA,IAAO,mBAAQ;",
6
+ "names": ["path", "crypto"]
7
+ }
@@ -1 +1,7 @@
1
- {"version":3,"file":"makePot.js","sourceRoot":"","sources":["../../src/parser/makePot.ts"],"names":[],"mappings":";;AAYA,0BA0BC;AAtCD,yDAA+D;AAC/D,iEAAkE;AAClE,uCAAwC;AAExC,uCAAiC;AAEjC;;;;;GAKG;AACI,KAAK,UAAU,OAAO,CAAC,IAAU;IACvC,iDAAiD;IACjD,MAAM,OAAO,GAAG,IAAA,mCAAkB,EAAC,IAAI,CAAC,CAAC;IAEzC,yDAAyD;IACzD,MAAM,QAAQ,GAAG,IAAA,gCAAmB,EAAC,IAAI,CAAC,CAAC;IAE3C,qEAAqE;IACrE,IAAI,CAAC,OAAO,GAAG;QACd,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO;QACzB,GAAG,OAAO;QACV,GAAG,QAAQ;KACQ,CAAC;IAErB,4BAA4B;IAC5B,OAAO,MAAM,IAAA,cAAI,EAAC,IAAI,CAAC;SACrB,IAAI,CAAC,CAAC,gBAAgB,EAAE,EAAE;QAC1B,IAAA,iBAAS,EAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAElC,OAAO,gBAAgB,CAAC;IACzB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAErB,OAAO,EAAE,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/parser/makePot.ts"],
4
+ "sourcesContent": ["import { extractMainFileData } from \"../extractors/headers.js\";\nimport { extractPackageJson } from \"../extractors/packageJson.js\";\nimport { writeFile } from \"../fs/fs.js\";\nimport type { Args } from \"../types.js\";\nimport { exec } from \"./exec.js\";\n\n/**\n * Generates a pot file for localization.\n *\n * @param args - the command line arguments\n * @return {string} - a promise that resolves when the pot file is generated\n */\nexport async function makePot(args: Args): Promise<string> {\n\t/** Collect metadata from the get-go package JSON */\n\tconst pkgData = extractPackageJson(args);\n\n\t/** Get metadata from the main file (theme and plugin) */\n\tconst metadata = extractMainFileData(args);\n\n\t/** Merge the metadata to get a single object with all the headers */\n\targs.headers = {\n\t\t...args?.options?.headers,\n\t\t...pkgData,\n\t\t...metadata,\n\t} as Args[\"headers\"];\n\n\t/** Generate the pot file */\n\treturn await exec(args)\n\t\t.then((jsonTranslations) => {\n\t\t\twriteFile(jsonTranslations, args);\n\n\t\t\treturn jsonTranslations;\n\t\t})\n\t\t.catch((error) => {\n\t\t\tconsole.error(error);\n\n\t\t\treturn \"\";\n\t\t});\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoC;AACpC,yBAAmC;AACnC,gBAA0B;AAE1B,kBAAqB;AAQrB,eAAsB,QAAQ,MAA6B;AAE1D,QAAM,cAAU,uCAAmB,IAAI;AAGvC,QAAM,eAAW,oCAAoB,IAAI;AAGzC,OAAK,UAAU;AAAA,IACd,GAAG,MAAM,SAAS;AAAA,IAClB,GAAG;AAAA,IACH,GAAG;AAAA,EACJ;AAGA,SAAO,UAAM,kBAAK,IAAI,EACpB,KAAK,CAAC,qBAAqB;AAC3B,6BAAU,kBAAkB,IAAI;AAEhC,WAAO;AAAA,EACR,CAAC,EACA,MAAM,CAAC,UAAU;AACjB,YAAQ,MAAM,KAAK;AAEnB,WAAO;AAAA,EACR,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -1 +1,7 @@
1
- {"version":3,"file":"patterns.js","sourceRoot":"","sources":["../../src/parser/patterns.ts"],"names":[],"mappings":";;AAOA,kCAiCC;AAtCD;;;;GAI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patterns.ts"],
4
+ "sourcesContent": ["import type { Args, Patterns } from \"../types.js\";\r\n\r\n/**\r\n * Returns the patterns based on the given arguments.\r\n *\r\n * @param args - The arguments for the extract process.\r\n */\r\nexport function getPatterns(args: Args) {\r\n\tconst pattern = {\r\n\t\tinclude: args.patterns.include || [],\r\n\t\texclude: args.patterns.exclude || [],\r\n\t\tmergePaths: args.patterns.mergePaths,\r\n\t\tsubtractPaths: args.patterns.subtractPaths,\r\n\t\tsubtractAndMerge: args.patterns.subtractAndMerge,\r\n\t} as Patterns;\r\n\r\n\t// Additional logic to handle different file types and formats\r\n\tif (args.options) {\r\n\t\t// js typescript mjs cjs etc\r\n\t\tif (args.options.skip.blade) {\r\n\t\t\tpattern.exclude.push(\"**/*.blade.php\");\r\n\t\t} else if (args.options.skip.php) {\r\n\t\t\tpattern.exclude.push(\"**/*.php\", \"**/*.blade.php\");\r\n\t\t}\r\n\r\n\t\t// js typescript mjs cjs etc\r\n\t\tif (args.options.skip.js) {\r\n\t\t\tpattern.exclude.push(\"**/*.{js,jsx,ts,tsx,mjs,cjs}\");\r\n\t\t}\r\n\r\n\t\tif (args.options.skip.blockJson) {\r\n\t\t\tpattern.exclude.push(\"block.json\");\r\n\t\t}\r\n\r\n\t\tif (args.options.skip.themeJson) {\r\n\t\t\tpattern.exclude.push(\"theme.json\");\r\n\t\t}\r\n\t}\r\n\r\n\treturn pattern;\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,YAAY,MAAY;AACvC,QAAM,UAAU;AAAA,IACf,SAAS,KAAK,SAAS,WAAW,CAAC;AAAA,IACnC,SAAS,KAAK,SAAS,WAAW,CAAC;AAAA,IACnC,YAAY,KAAK,SAAS;AAAA,IAC1B,eAAe,KAAK,SAAS;AAAA,IAC7B,kBAAkB,KAAK,SAAS;AAAA,EACjC;AAGA,MAAI,KAAK,SAAS;AAEjB,QAAI,KAAK,QAAQ,KAAK,OAAO;AAC5B,cAAQ,QAAQ,KAAK,gBAAgB;AAAA,IACtC,WAAW,KAAK,QAAQ,KAAK,KAAK;AACjC,cAAQ,QAAQ,KAAK,YAAY,gBAAgB;AAAA,IAClD;AAGA,QAAI,KAAK,QAAQ,KAAK,IAAI;AACzB,cAAQ,QAAQ,KAAK,8BAA8B;AAAA,IACpD;AAEA,QAAI,KAAK,QAAQ,KAAK,WAAW;AAChC,cAAQ,QAAQ,KAAK,YAAY;AAAA,IAClC;AAEA,QAAI,KAAK,QAAQ,KAAK,WAAW;AAChC,cAAQ,QAAQ,KAAK,YAAY;AAAA,IAClC;AAAA,EACD;AAEA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1 +1 @@
1
- "use strict";var F=Object.create;var f=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var x=(e,t)=>{for(var o in t)f(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of S(t))!w.call(e,s)&&s!==o&&f(e,s,{get:()=>t[s],enumerable:!(i=O(t,s))||i.enumerable});return e};var g=(e,t,o)=>(o=e!=null?F(j(e)):{},d(t||!e||!e.__esModule?f(o,"default",{value:e,enumerable:!0}):o,e)),v=e=>d(f({},"__esModule",{value:!0}),e);var T={};x(T,{processFiles:()=>A});module.exports=v(T);var r=g(require("node:path")),u=require("../const.js"),h=require("../extractors/json.js"),a=require("../fs/fs.js"),k=require("../fs/glob.js"),P=require("./tree.js");async function A(e,t,o){const i=[];let s=0;const c=(0,k.getFiles)(t,e);o&&(o.setTotal(Object.values(c).length),o.update(0,{filename:`Found ${Object.values(c).length} files`}));for await(const l of c){s++;const n=r.default.basename(l),b=r.default.extname(l).replace(/^./,""),p=r.default.resolve(t.paths.cwd,l);if(n==="theme.json"||n==="block.json")i.push((0,a.readFileAsync)(p).then(m=>(0,h.parseJsonCallback)(m,t.paths.cwd,n)));else if(u.allowedFormats.includes(b)){const m=(0,a.readFileAsync)(p).then(y=>(0,P.doTree)(y,l,t.debug));m&&i.push(m)}o&&(o.update(s,{filename:n}),o.render())}return i}0&&(module.exports={processFiles});
1
+ "use strict";var S=Object.create;var f=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var O=(t,e)=>{for(var o in e)f(t,o,{get:e[o],enumerable:!0})},d=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of g(e))!x.call(t,s)&&s!==o&&f(t,s,{get:()=>e[s],enumerable:!(i=b(e,s))||i.enumerable});return t};var j=(t,e,o)=>(o=t!=null?S(w(t)):{},d(e||!t||!t.__esModule?f(o,"default",{value:t,enumerable:!0}):o,t)),A=t=>d(f({},"__esModule",{value:!0}),t);var $={};O($,{processFiles:()=>T});module.exports=A($);var n=j(require("node:path")),h=require("../const.js"),u=require("../extractors/json.js"),c=require("../fs/fs.js"),k=require("../fs/glob.js"),P=require("./tree.js");async function T(t,e,o){const i=[];let s=0;const r=await(0,k.getFiles)(e,t);o&&(o.setTotal(r.length),o.update(0,{filename:`Found ${r.length} files`}));for(const l of r){s++;const a=n.default.basename(l),y=n.default.extname(l).replace(/^./,""),p=n.default.resolve(e.paths.cwd,l);if(a==="theme.json"||a==="block.json")i.push((0,c.readFileAsync)(p).then(m=>(0,u.parseJsonCallback)(m,e.paths.cwd,a)));else if(h.allowedFormats.includes(y)){const m=(0,c.readFileAsync)(p).then(F=>(0,P.doTree)(F,l,e.debug,e));m&&i.push(m)}o&&o.update(s,{filename:`${n.default.basename(l)} (Valid: ${i.length})`})}return i}0&&(module.exports={processFiles});
@@ -1 +1,7 @@
1
- {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/parser/process.ts"],"names":[],"mappings":";;;;;AAkBA,oCA8CC;AAhED,0DAA6B;AAG7B,0CAA6C;AAC7C,mDAA0D;AAC1D,u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yBAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACzC,MAAM,QAAQ,GAAG,IAAA,qBAAa,EAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAC7D,IAAA,gBAAM,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CACjC,CAAC;YACF,IAAI,QAAQ,EAAE,CAAC;gBACd,KAAK,CAAC,IAAI,CAAC,QAAgC,CAAC,CAAC;YAC9C,CAAC;QACF,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YACjB,WAAW,CAAC,MAAM,CAAC,mBAAmB,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YAChE,WAAW,CAAC,MAAM,EAAE,CAAC;QACtB,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/parser/process.ts"],
4
+ "sourcesContent": ["import path from \"node:path\";\r\nimport type { SingleBar } from \"cli-progress\";\r\nimport type { SetOfBlocks } from \"gettext-merger\";\r\nimport { allowedFormats } from \"../const.js\";\r\nimport { parseJsonCallback } from \"../extractors/json.js\";\r\nimport { readFileAsync } from \"../fs/fs.js\";\r\nimport { getFiles } from \"../fs/glob.js\";\r\nimport type { Args, Patterns } from \"../types.js\";\r\nimport { doTree } from \"./tree.js\";\r\n\r\n/**\r\n * Processes the given files and returns an array of promises that resolve to TranslationStrings.\r\n *\r\n * @param patterns\r\n * @param {Args} args - The arguments for processing the files.\r\n * @param progressBar - The progress bar element.\r\n * @return {Promise<SetOfBlocks[]>} - An array of promises that resolve to TranslationStrings.\r\n */\r\nexport async function processFiles(\r\n\tpatterns: Patterns,\r\n\targs: Args,\r\n\tprogressBar?: SingleBar,\r\n): Promise<Promise<SetOfBlocks>[]> {\r\n\tconst tasks: Promise<SetOfBlocks>[] = [];\r\n\tlet processedFilesCount = 0;\r\n\r\n\tconst files = await getFiles(args, patterns);\r\n\r\n\tif (progressBar) {\r\n\t\tprogressBar.setTotal(files.length);\r\n\t\tprogressBar.update(0, {\r\n\t\t\tfilename: `Found ${files.length} files`,\r\n\t\t});\r\n\t}\r\n\r\n\t// Loop through the array\r\n\tfor (const file of files) {\r\n\t\tprocessedFilesCount++;\r\n\t\tconst filename = path.basename(file);\r\n\t\tconst ext = path.extname(file).replace(/^./, \"\");\r\n\t\tconst fileRealPath = path.resolve(args.paths.cwd, file);\r\n\r\n\t\tif (filename === \"theme.json\" || filename === \"block.json\") {\r\n\t\t\ttasks.push(\r\n\t\t\t\treadFileAsync(fileRealPath).then((sourceCode) =>\r\n\t\t\t\t\tparseJsonCallback(sourceCode, args.paths.cwd, filename),\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t} else if (allowedFormats.includes(ext)) {\r\n\t\t\tconst fileTree = readFileAsync(fileRealPath).then((content) =>\r\n\t\t\t\tdoTree(content, file, args.debug, args),\r\n\t\t\t);\r\n\t\t\tif (fileTree) {\r\n\t\t\t\ttasks.push(fileTree as Promise<SetOfBlocks>);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (progressBar) {\r\n\t\t\tprogressBar.update(processedFilesCount, {\r\n\t\t\t\tfilename: `${path.basename(file)} (Valid: ${tasks.length})`\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\treturn tasks;\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;AAGjB,mBAA+B;AAC/B,kBAAkC;AAClC,gBAA8B;AAC9B,kBAAyB;AAEzB,kBAAuB;AAUvB,eAAsB,aACrB,UACA,MACA,aACkC;AAClC,QAAM,QAAgC,CAAC;AACvC,MAAI,sBAAsB;AAE1B,QAAM,QAAQ,UAAM,sBAAS,MAAM,QAAQ;AAE3C,MAAI,aAAa;AAChB,gBAAY,SAAS,MAAM,MAAM;AACjC,gBAAY,OAAO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AC,OAAO,CAAC,cAAc,CAClC,CAAC;AACH,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/parser/progress.ts"],
4
+ "sourcesContent": ["import cliProgress, { type SingleBar } from \"cli-progress\";\nimport type { Args } from \"../types.js\";\n\n/**\n * Initializes a progress bar and returns the progress bar element.\n *\n * @param {Args} _args - The argument object containing the source directory and other options.\n * @param {number} _filesCount - An array of file names.\n * @return {cliProgress.SingleBar} The progress bar element.\n */\nexport function initProgress(_args: Args, _filesCount: number): SingleBar {\n\t// Set up the progress bar\n\treturn new cliProgress.SingleBar(\n\t\t{\n\t\t\tclearOnComplete: true,\n\t\t\tetaBuffer: 1000,\n\t\t\thideCursor: true,\n\t\t\tformat:\n\t\t\t\t\" {bar} {percentage}% | ETA: {eta}s | {filename} | {value}/{total}\",\n\t\t},\n\t\tcliProgress.Presets.shades_classic,\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4C;AAUrC,SAAS,aAAa,OAAa,aAAgC;AAEzE,SAAO,IAAI,oBAAAA,QAAY;AAAA,IACtB;AAAA,MACC,iBAAiB;AAAA,MACjB,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,QACC;AAAA,IACF;AAAA,IACA,oBAAAA,QAAY,QAAQ;AAAA,EACrB;AACD;",
6
+ "names": ["cliProgress"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.create;var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var B=(o,e)=>{for(var s in e)a(o,s,{get:e[s],enumerable:!0})},i=(o,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of u(e))!k.call(o,t)&&t!==s&&a(o,t,{get:()=>e[t],enumerable:!(n=g(e,t))||n.enumerable});return o};var p=(o,e,s)=>(s=o!=null?m(h(o)):{},i(e||!o||!o.__esModule?a(s,"default",{value:o,enumerable:!0}):s,o)),S=o=>i(a({},"__esModule",{value:!0}),o);var d={};B(d,{taskRunner:()=>O});module.exports=S(d);var y=p(require("node:os")),c=p(require("node:path"));async function O(o,e,s,n){const t=[];return await Promise.allSettled(o).then(l=>l.map(r=>r.status==="fulfilled"&&r.value).filter(Boolean)).then(l=>{if(s.options?.silent!==!0)for(const r of l)r.blocks.length>0?(e.addArray(r.blocks),t.push(`\u2705 ${r.path} [${r.blocks.map(f=>f.msgid).join(", ")}]`)):t.push(`\u274C ${r.path} has no strings`)}).catch(l=>new Error(l)),n.stop(),console.log(`
2
- \u{1F389} Done!`),console.log(`\u{1F4DD} Found ${Object.values(e.blocks).length} translation strings in ${c.default.resolve(s.paths.cwd)}.`),console.log(t.join(y.EOL)),e}0&&(module.exports={taskRunner});
1
+ "use strict";var u=Object.create;var i=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var d=(t,s)=>{for(var o in s)i(t,o,{get:s[o],enumerable:!0})},c=(t,s,o,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let e of k(s))!S.call(t,e)&&e!==o&&i(t,e,{get:()=>s[e],enumerable:!(l=h(s,e))||l.enumerable});return t};var p=(t,s,o)=>(o=t!=null?u(y(t)):{},c(s||!t||!t.__esModule?i(o,"default",{value:t,enumerable:!0}):o,t)),B=t=>c(i({},"__esModule",{value:!0}),t);var b={};d(b,{taskRunner:()=>$});module.exports=B(b);var O=p(require("node:os")),f=p(require("node:path"));async function $(t,s,o,l){const e=[],m=t.map(n=>n.finally(()=>{l.increment()}));return await Promise.allSettled(m).then(n=>n.map(r=>r.status==="fulfilled"&&r.value).filter(Boolean)).then(n=>{for(const r of n)if(r.blocks.length>0){s.addArray(r.blocks);const a=r.blocks.map(g=>g.msgid);o.options?.silent!==!0&&e.push(`\u2705 ${r.path} - ${a.length} strings found [${a.join(", ")}]`)}else o.options?.silent!==!0&&e.push(`\u274C ${r.path} - has no strings`)}).catch(n=>new Error(n)),l.stop(),console.log(`
2
+ \u{1F389} Done!`),console.log(`\u{1F4DD} Found ${Object.values(s.blocks).length} translation strings in ${f.default.resolve(o.paths.cwd)}.`),console.log(e.join(O.EOL)),s}0&&(module.exports={taskRunner});
@@ -1 +1,7 @@
1
- {"version":3,"file":"taskRunner.js","sourceRoot":"","sources":["../../src/parser/taskRunner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,gCA+CC;AA7DD,4CAA8B;AAC9B,0DAA6B;AAK7B;;;;;;;GAOG;AACI,KAAK,UAAU,UAAU,CAC/B,KAA6B,EAC7B,WAAwB,EACxB,IAAU,EACV,WAAsB;IAEtB,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;SAC7B,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QACjB;;WAEG;QACH,OAAO,OAAO;aACZ,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,IAAI,KAAK,CAAC,KAAK,CAAC;aAC3D,MAAM,CAAC,OAAO,CAAkB,CAAC,CAAC,iBAAiB;IACtD,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE;QACtB,sBAAsB;QACtB,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,EAAE,CAAC;YACnC,KAAK,MAAM,MAAM,IAAI,YAAY,EAAE,CAAC;gBACnC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC9B;;uBAEG;oBACH,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBACpC,qBAAqB;oBACrB,QAAQ,CAAC,IAAI,CACZ,KAAK,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACpE,CAAC;gBACH,CAAC;;oBAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,IAAI,iBAAiB,CAAC,CAAC;YACzD,CAAC;QACF,CAAC;IACF,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACd,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IAEJ,WAAW,CAAC,IAAI,EAAE,CAAC;IAEnB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1B,OAAO,CAAC,GAAG,CACV,YAAY,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,2BAA2B,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAC9G,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEnC,OAAO,WAAW,CAAC;AACpB,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/parser/taskRunner.ts"],
4
+ "sourcesContent": ["import * as os from \"node:os\";\nimport path from \"node:path\";\nimport type { SingleBar } from \"cli-progress\";\nimport type { SetOfBlocks } from \"gettext-merger\";\nimport type { Args } from \"../types.js\";\n\n/**\n * Task runner for the extraction process.\n *\n * @param tasks - The tasks to run\n * @param destination - The destination\n * @param args - The command line arguments\n * @param progressBar\n */\nexport async function taskRunner(\n\ttasks: Promise<SetOfBlocks>[],\n\tdestination: SetOfBlocks,\n\targs: Args,\n\tprogressBar: SingleBar,\n) {\n\tconst messages: string[] = [];\n\t// Create a new array of promises that update the bar when they finish.\n\tconst tasksWithProgress = tasks.map((task) =>\n\t\ttask.finally(() => {\n\t\t\tprogressBar.increment();\n\t\t})\n\t);\n\tawait Promise.allSettled(tasksWithProgress)\n\t\t.then((strings) => {\n\t\t\t/**\n\t\t\t * Return the strings that are not rejected (they are fulfilled)\n\t\t\t */\n\t\t\treturn strings\n\t\t\t\t.map((block) => block.status === \"fulfilled\" && block.value)\n\t\t\t\t.filter(Boolean) as SetOfBlocks[]; // remove nullish\n\t\t})\n\t\t.then((consolidated) => {\n\t\t\t/** Log the results */\n\t\t\tfor (const result of consolidated) {\n\t\t\t\tif (result.blocks.length > 0) {\n\t\t\t\t\t/**\n\t\t\t\t\t * Add the strings to the destination set\n\t\t\t\t\t */\n\t\t\t\t\tdestination.addArray(result.blocks);\n\t\t\t\t\tconst strings = result.blocks.map((b) => b.msgid);\n\n\t\t\t\t\t/* Log the results */\n\t\t\t\t\tif (args.options?.silent !== true) {\n\t\t\t\t\t\tmessages.push(\n\t\t\t\t\t\t\t`\u2705 ${result.path} - ${strings.length} strings found [${strings.join(\", \")}]`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (args.options?.silent !== true) {\n\t\t\t\t\tmessages.push(`\u274C ${result.path} - has no strings`);\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.catch((err) => {\n\t\t\treturn new Error(err);\n\t\t});\n\n\tprogressBar.stop();\n\n\tconsole.log(\"\\n\uD83C\uDF89 Done!\");\n\tconsole.log(\n\t\t`\uD83D\uDCDD Found ${Object.values(destination.blocks).length} translation strings in ${path.resolve(args.paths.cwd)}.`,\n\t);\n\n\tconsole.log(messages.join(os.EOL));\n\n\treturn destination;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,uBAAiB;AAajB,eAAsB,WACrB,OACA,aACA,MACA,aACC;AACD,QAAM,WAAqB,CAAC;AAE5B,QAAM,oBAAoB,MAAM;AAAA,IAAI,CAAC,SACpC,KAAK,QAAQ,MAAM;AAClB,kBAAY,UAAU;AAAA,IACvB,CAAC;AAAA,EACF;AACA,QAAM,QAAQ,WAAW,iBAAiB,EACxC,KAAK,CAAC,YAAY;AAIlB,WAAO,QACL,IAAI,CAAC,UAAU,MAAM,WAAW,eAAe,MAAM,KAAK,EAC1D,OAAO,OAAO;AAAA,EACjB,CAAC,EACA,KAAK,CAAC,iBAAiB;AAEvB,eAAW,UAAU,cAAc;AAClC,UAAI,OAAO,OAAO,SAAS,GAAG;AAI7B,oBAAY,SAAS,OAAO,MAAM;AAClC,cAAM,UAAU,OAAO,OAAO,IAAI,CAAC,MAAM,EAAE,KAAK;AAGhD,YAAI,KAAK,SAAS,WAAW,MAAM;AAClC,mBAAS;AAAA,YACR,UAAK,OAAO,IAAI,MAAM,QAAQ,MAAM,mBAAmB,QAAQ,KAAK,IAAI,CAAC;AAAA,UAC1E;AAAA,QACD;AAAA,MACD,WAAW,KAAK,SAAS,WAAW,MAAM;AACzC,iBAAS,KAAK,UAAK,OAAO,IAAI,mBAAmB;AAAA,MAClD;AAAA,IACD;AAAA,EACD,CAAC,EACA,MAAM,CAAC,QAAQ;AACf,WAAO,IAAI,MAAM,GAAG;AAAA,EACrB,CAAC;AAEF,cAAY,KAAK;AAEjB,UAAQ,IAAI,mBAAY;AACxB,UAAQ;AAAA,IACP,mBAAY,OAAO,OAAO,YAAY,MAAM,EAAE,MAAM,2BAA2B,iBAAAA,QAAK,QAAQ,KAAK,MAAM,GAAG,CAAC;AAAA,EAC5G;AAEA,UAAQ,IAAI,SAAS,KAAK,GAAG,GAAG,CAAC;AAEjC,SAAO;AACR;",
6
+ "names": ["path"]
7
+ }
@@ -1 +1,2 @@
1
- "use strict";var C=Object.create;var f=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var K=(t,e)=>{for(var n in e)f(t,n,{get:e[n],enumerable:!0})},S=(t,e,n,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of L(e))!z.call(t,i)&&i!==n&&f(t,i,{get:()=>e[i],enumerable:!(c=F(e,i))||c.enumerable});return t};var M=(t,e,n)=>(n=t!=null?C(O(t)):{},S(e||!t||!t.__esModule?f(n,"default",{value:t,enumerable:!0}):n,t)),j=t=>S(f({},"__esModule",{value:!0}),t);var U={};K(U,{doTree:()=>I});module.exports=j(U);var b=M(require("tree-sitter")),y=require("../const.js"),u=require("gettext-merger"),$=require("../fs/glob.js"),g=require("../utils/common.js");function E(t){let e=t,n=0;for(;e&&n<6;){if(e?.previousSibling?.type==="comment"&&e?.previousSibling?.text.toLowerCase().includes("translators"))return e?.previousSibling?.text?(0,g.stripTranslationMarkup)(e.previousSibling.text):void 0;n++,e=e.parent}}function I(t,e,n){const c=new b.default,i=(0,$.getParser)(e);if(!i)return new u.SetOfBlocks([],e);c.setLanguage(i);const x=new u.SetOfBlocks([],e),k=e.split(".").pop()?.toLowerCase()!=="php"?"call_expression":"function_call_expression",v=["name","string","string_value","variable_name","binary_expression","member_expression","subscript_expression","shell_command_expression","function_call_expression","encapsed_string"];function _(s){if(s?.children.length)for(const r of s.children)_(r);if(s?.type===k){const r=s.firstChild?.text??null;if(r===null||!Object.keys(y.i18nFunctions).includes(r))return;const l=s.lastChild;if(l===null||l.childCount===0||l.type!=="arguments")return;const[V,N]=s.children,a={},h=y.i18nFunctions[r],B=N.children.slice(1,-1);let m=0;for(const d of B){let o=d,p=o.text;if(d.type==="argument"){if(d.children.length===0)continue;o=d.children[0]}if(o?.type===",")continue;if(o?.type&&v.includes(o.type))p=p.slice(1,-1);else{n&&console.warn(`Unexpected node type ${o?.type} identified as ${h[m]} with value ${p} in ${e} at ${o.startPosition.row+1} pos ${o.startPosition.column+1}`);continue}const T=h[m];a[T]=p,m+=1}const w=E(l),P=new u.Block({msgctxt:a.msgctxt,msgid:a.msgid??"",msgid_plural:a.msgid_plural,msgstr:a.msgid_plural?["",""]:[""],comments:{translator:w?[w]:void 0,reference:[`${(0,g.reverseSlashes)(e)}:${s.startPosition.row+1}`]}});x.add(P)}}try{if(t){const s=Buffer.byteLength(t,"utf8");let r=1024*32;s>=r&&(r=s+32),s>=1024*1024*2&&console.warn(`File size warning: ${e} exceeds 2 MB.`);const l=c.parse(t,void 0,{bufferSize:r});l&&_(l.rootNode)}}catch(s){console.error(`Failed to parse ${e}: ${s}`)}return x}0&&(module.exports={doTree});
1
+ "use strict";var L=Object.create;var d=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var K=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},k=(t,e,r,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of W(e))!z.call(t,o)&&o!==r&&d(t,o,{get:()=>e[o],enumerable:!(l=O(e,o))||l.enumerable});return t};var M=(t,e,r)=>(r=t!=null?L(j(t)):{},k(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),V=t=>k(d({},"__esModule",{value:!0}),t);var I={};K(I,{doTree:()=>E});module.exports=V(I);var N=M(require("tree-sitter")),_=require("../const.js"),f=require("gettext-merger"),F=require("../fs/glob.js"),g=require("../utils/common.js");function D(t){let e=t,r=0;for(;e&&r<6;){if(e.previousSibling?.type==="comment"&&e.previousSibling.text.toLowerCase().includes("translators"))return(0,g.stripTranslationMarkup)(e.previousSibling.text);r++,e=e.parent}}function q(t){if(t.type==="encapsed_string")return t.children.map(e=>{if(e.type==="escape_sequence")switch(e.text){case"\\n":return`
2
+ `;case"\\r":return"\r";case"\\t":return" ";case"\\\\":return"\\";case'\\"':return'"';case"\\$":return"$";case"\\e":return"\x1B";case"\\f":return"\f";case"\\v":return"\v";default:return e.text}return e.type==="string_content"||e.type==="variable_name"?e.text:""}).join("");if(t.type==="string"){const e=t.text;if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/\\'/g,"'").replace(/\\\\/g,"\\")}return t.text}function E(t,e,r,l){const o=new N.default,b=(0,F.getParser)(e);if(!b)return new f.SetOfBlocks([],e);o.setLanguage(b);const h=new f.SetOfBlocks([],e),B=e.split(".").pop()?.toLowerCase()!=="php"?"call_expression":"function_call_expression",P=["name","string","string_value","variable_name","binary_expression","member_expression","subscript_expression","shell_command_expression","function_call_expression","encapsed_string"];function S(s){if(s?.children.length)for(const i of s.children)S(i);if(s?.type===B){const i=s.firstChild?.text??null;if(i===null||!Object.keys(_.i18nFunctions).includes(i))return;const a=s.childForFieldName("arguments");if(a===null||a.childCount===0||a.type!=="arguments"||!a)return;const c={text_domain:"default"},y=_.i18nFunctions[i],T=a.children;let p=0;for(const u of T){let n=u;if(n.type==="("||n.type===")"||n.type===","||n.type==="["||n.type==="]"||n.type==="comment")continue;if(u.type==="argument"){if(u.children.length===0)continue;const C=u.childForFieldName("name");let $=!1;for(const m of u.children)if(m.id!==C?.id&&!(m.type==="comment"||m.type===":")){n=m,$=!0;break}if(!$)continue}if(p>=y.length)break;const w=y[p];let x=q(n);if(w==="number")x=n.text;else if(!n?.type||!P.includes(n.type)){r&&console.error(`Unexpected node type ${n?.type} identified as ${y[p]} with value ${x} in ${e} at ${n.startPosition.row+1} pos ${n.startPosition.column+1}`);return}c[w]=x,p+=1}if(Array.isArray(l?.options?.translationDomains)&&c.text_domain&&!l.options.translationDomains.includes(c.text_domain))return;const v=D(s),A=new f.Block({msgctxt:c.msgctxt,msgid:c.msgid??"",msgid_plural:c.msgid_plural,msgstr:c.msgid_plural?["",""]:[""],comments:{translator:v?[v]:void 0,reference:[`${(0,g.reverseSlashes)(e)}:${s.startPosition.row+1}`]}});h.add(A)}}try{if(t){const s=Buffer.byteLength(t,"utf8");let i=1024*32;s>=i&&(i=s+32),s>=1024*1024*2&&console.warn(`File size warning: ${e} exceeds 2 MB.`);const a=o.parse(t,void 0,{bufferSize:i});a&&S(a.rootNode)}}catch(s){console.error(`Failed to parse ${e}: ${s}`)}return h}0&&(module.exports={doTree});
@@ -1 +1,7 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/parser/tree.ts"],"names":[],"mappings":";;;;;AAwCA,wBA8JC;AAtMD,8DAAsD;AACtD,0CAA4C;AAE5C,mDAAoD;AACpD,2CAA0C;AAC1C,kDAA4E;AAE5E;;;;;GAKG;AACH,SAAS,eAAe,CAAC,IAAgB;IACxC,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,mDAAmD;IACnD,OAAO,WAAW,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACjC,IACC,WAAW,EAAE,eAAe,EAAE,IAAI,KAAK,SAAS;YAChD,WAAW,EAAE,eAAe,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,EACvE,CAAC;YACF,OAAO,WAAW,EAAE,eAAe,EAAE,IAAI;gBACxC,CAAC,CAAC,IAAA,kCAAsB,EAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC;gBAC1D,CAAC,CAAC,SAAS,CAAC;QACd,CAAC;QACD,KAAK,EAAE,CAAC;QACR,WAAW,GAAG,WAAW,CAAC,MAAoB,CAAC;IAChD,CAAC;AACF,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,MAAM,CACrB,UAAkB,EAClB,QAAgB,EAChB,YAAsB;IAEtB,oBAAoB;IACpB,MAAM,MAAM,GAAG,IAAI,qBAAM,EAAE,CAAC;IAC5B,MAAM,SAAS,GAAG,IAAA,mBAAS,EAAC,QAAQ,CAAC,CAAC;IACtC,qCAAqC;IACrC,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,4BAAW,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACrD,0BAA0B;IAC1B,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAE9B,gCAAgC;IAChC,MAAM,mBAAmB,GAAgB,IAAI,4BAAW,CAAC,EAAE,EAAE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;IAClC,OAAO,mBAAmB,CAAC;AAC5B,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/parser/tree.ts"],
4
+ "sourcesContent": ["import Parser, { type SyntaxNode } from \"tree-sitter\";\r\nimport { i18nFunctions } from \"../const.js\";\r\nimport { Block, SetOfBlocks } from \"gettext-merger\";\r\nimport { getParser } from \"../fs/glob.js\";\r\nimport { reverseSlashes, stripTranslationMarkup } from \"../utils/common.js\";\r\nimport type { Args } from \"../types.js\";\r\n\r\n/**\r\n * Collect comments from the AST node and its preceding siblings.\r\n *\r\n * @param {SyntaxNode} node - The AST node.\r\n * @return {string | undefined} The collected comment or undefined.\r\n */\r\nfunction collectComments(node: SyntaxNode): string | undefined {\r\n\tlet currentNode: SyntaxNode | null = node;\r\n\tlet depth = 0;\r\n\r\n\t// Check the node's preceding siblings for comments\r\n\twhile (currentNode && depth < 6) {\r\n\t\tif (\r\n\t\t\tcurrentNode.previousSibling?.type === \"comment\" &&\r\n\t\t\tcurrentNode.previousSibling.text.toLowerCase().includes(\"translators\")\r\n\t\t) {\r\n\t\t\treturn stripTranslationMarkup(currentNode.previousSibling.text);\r\n\t\t}\r\n\t\tdepth++;\r\n\t\tcurrentNode = currentNode.parent;\r\n\t}\r\n\treturn undefined;\r\n}\r\n\r\n/**\r\n * Resolves the actual string value from a tree-sitter node,\r\n * handling escape sequences in double-quoted strings.\r\n *\r\n * @param {SyntaxNode} node - The AST node.\r\n * @return {string} The collected comment or undefined.\r\n */\r\nfunction resolveStringValue(node: SyntaxNode): string {\r\n\t// Handle double-quoted strings (PHP encapsed_string)\r\n\tif (node.type === 'encapsed_string') {\r\n\t\treturn node.children\r\n\t\t\t.map((child) => {\r\n\t\t\t\tif (child.type === 'escape_sequence') {\r\n\t\t\t\t\t// Unescape common sequences\r\n\t\t\t\t\tswitch (child.text) {\r\n\t\t\t\t\t\tcase '\\\\n': return '\\n';\r\n\t\t\t\t\t\tcase '\\\\r': return '\\r';\r\n\t\t\t\t\t\tcase '\\\\t': return '\\t';\r\n\t\t\t\t\t\tcase '\\\\\\\\': return '\\\\';\r\n\t\t\t\t\t\tcase '\\\\\"': return '\"';\r\n\t\t\t\t\t\tcase '\\\\$': return '$';\r\n\t\t\t\t\t\tcase '\\\\e': return '\\x1b';\r\n\t\t\t\t\t\tcase '\\\\f': return '\\f';\r\n\t\t\t\t\t\tcase '\\\\v': return '\\v';\r\n\t\t\t\t\t\tdefault: return child.text;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t// Return literal content\r\n\t\t\t\tif (child.type === 'string_content') {\r\n\t\t\t\t\treturn child.text;\r\n\t\t\t\t}\r\n\t\t\t\t// Handle variables if they appear (preserve them as text)\r\n\t\t\t\tif (child.type === 'variable_name') {\r\n\t\t\t\t\treturn child.text;\r\n\t\t\t\t}\r\n\t\t\t\treturn '';\r\n\t\t\t})\r\n\t\t\t.join('');\r\n\t}\r\n\r\n\t// Handle single-quoted strings (PHP string) or JS strings\r\n\tif (node.type === 'string') {\r\n\t\tconst text = node.text;\r\n\t\t// Strip surrounding quotes if present\r\n\t\tif ((text.startsWith(\"'\") && text.endsWith(\"'\")) ||\r\n\t\t\t(text.startsWith('\"') && text.endsWith('\"'))) {\r\n\t\t\t// Remove quotes and unescape escaped quotes\r\n\t\t\treturn text.slice(1, -1).replace(/\\\\'/g, \"'\").replace(/\\\\\\\\/g, \"\\\\\");\r\n\t\t}\r\n\t}\r\n\r\n\t// Fallback for other node types (identifiers, etc.)\r\n\treturn node.text;\r\n}\r\n\r\n/**\r\n * Parses the source code using the specified language parser and extracts the strings from the file.\r\n *\r\n * @param {string} sourceCode - The source code to be parsed.\r\n * @param {string} filepath - The path to the file being parsed.\r\n * @param {boolean} debugEnabled - Whether debug mode is enabled.\r\n * @param {Args} args - The command line arguments, optional.\r\n * @return {SetOfBlocks} An array of translation strings.\r\n */\r\nexport function doTree(\r\n\tsourceCode: string,\r\n\tfilepath: string,\r\n\tdebugEnabled?: boolean,\r\n\targs?: Args,\r\n): SetOfBlocks {\r\n\t// set up the parser\r\n\tconst parser = new Parser();\r\n\tconst parserExt = getParser(filepath);\r\n\r\n\t// if no parser is found return empty\r\n\tif (!parserExt) return new SetOfBlocks([], filepath);\r\n\r\n\t// set the parser language\r\n\tparser.setLanguage(parserExt);\r\n\r\n\t// set up the translation object\r\n\tconst gettextTranslations: SetOfBlocks = new SetOfBlocks([], filepath);\r\n\r\n\tconst typeToMatch =\r\n\t\tfilepath.split(\".\").pop()?.toLowerCase() !== \"php\"\r\n\t\t\t? \"call_expression\"\r\n\t\t\t: \"function_call_expression\";\r\n\r\n\tconst stringType = [\r\n\t\t\"name\",\r\n\t\t\"string\",\r\n\t\t\"string_value\",\r\n\t\t\"variable_name\",\r\n\t\t\"binary_expression\",\r\n\t\t\"member_expression\",\r\n\t\t\"subscript_expression\",\r\n\t\t\"shell_command_expression\",\r\n\t\t\"function_call_expression\",\r\n\t\t\"encapsed_string\",\r\n\t];\r\n\r\n\t/**\r\n\t * Traverse the tree \uD83C\uDF33\r\n\t *\r\n\t * @param {SyntaxNode} node The node to traverse through\r\n\t */\r\n\tfunction traverse(node: SyntaxNode): void {\r\n\t\t// Walk the tree\r\n\t\tif (node?.children.length) {\r\n\t\t\tfor (const child of node.children) {\r\n\t\t\t\ttraverse(child);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Check if the node matches\r\n\t\tif (node?.type === typeToMatch) {\r\n\t\t\t// The function name is the first child\r\n\t\t\tconst functionName = node.firstChild?.text ?? null;\r\n\t\t\tif (\r\n\t\t\t\tfunctionName === null ||\r\n\t\t\t\t!Object.keys(i18nFunctions).includes(functionName)\r\n\t\t\t) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// The arguments are the last child\r\n\t\t\tconst argsNode = node.childForFieldName(\"arguments\");\r\n\t\t\tif (\r\n\t\t\t\targsNode === null ||\r\n\t\t\t\targsNode.childCount === 0 ||\r\n\t\t\t\targsNode.type !== \"arguments\"\r\n\t\t\t) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Safety check: verify we actually have an arguments node\r\n\t\t\tif (!argsNode) return;\r\n\r\n\t\t\tconst translation: Partial<{\r\n\t\t\t\tmsgctxt: string;\r\n\t\t\t\tmsgid: string;\r\n\t\t\t\tmsgid_plural: string;\r\n\t\t\t\tnumber: string;\r\n\t\t\t\tmsgstr: string;\r\n\t\t\t\ttext_domain: string;\r\n\t\t\t}> = {\r\n\t\t\t\t// WordPress default text domain is 'default'\r\n\t\t\t\ttext_domain: 'default',\r\n\t\t\t};\r\n\r\n\t\t\tconst translationKeys =\r\n\t\t\t\ti18nFunctions[functionName as keyof typeof i18nFunctions];\r\n\r\n\t\t\t// Slice the children to skip the opening and closing parentheses/brackets or process them directly\r\n\t\t\t// We iterate over all children and handle them based on type\r\n\t\t\tconst children = argsNode.children;\r\n\t\t\tlet translationKeyIndex = 0;\r\n\r\n\t\t\t// Get the translation from the arguments\r\n\t\t\tfor (const child of children) {\r\n\t\t\t\tlet node = child;\r\n\r\n\t\t\t\t// Skip parentheses and commas\r\n\t\t\t\tif (\r\n\t\t\t\t\tnode.type === \"(\" ||\r\n\t\t\t\t\tnode.type === \")\" ||\r\n\t\t\t\t\tnode.type === \",\" ||\r\n\t\t\t\t\tnode.type === \"[\" ||\r\n\t\t\t\t\tnode.type === \"]\"\r\n\t\t\t\t) {\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Skip comments\r\n\t\t\t\tif (node.type === \"comment\") {\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// unwrap the argument node, which is used in PHP.\r\n\t\t\t\tif (child.type === \"argument\") {\r\n\t\t\t\t\tif (child.children.length === 0) continue;\r\n\r\n\t\t\t\t\t// Check if this is a named argument\r\n\t\t\t\t\tconst nameNode = child.childForFieldName(\"name\");\r\n\r\n\t\t\t\t\t// Iterate over children to find the value\r\n\t\t\t\t\t// The value is the child that is NOT the name node, not a comment, and not punctuation.\r\n\t\t\t\t\tlet foundValue = false;\r\n\t\t\t\t\tfor (const argChild of child.children) {\r\n\t\t\t\t\t\tif (argChild.id === nameNode?.id) {\r\n\t\t\t\t\t\t\tcontinue; // Skip the name label\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (argChild.type === \"comment\" || argChild.type === \":\") {\r\n\t\t\t\t\t\t\tcontinue; // Skip comments and colon\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t// Found the value!\r\n\t\t\t\t\t\tnode = argChild;\r\n\t\t\t\t\t\tfoundValue = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// If we didn't find a value (e.g. only comments?), skip this argument\r\n\t\t\t\t\tif (!foundValue) {\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Stop if we have more arguments than keys defined\r\n\t\t\t\tif (translationKeyIndex >= translationKeys.length) {\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// the translation key (eg. msgid)\r\n\t\t\t\tconst currentKey = translationKeys[\r\n\t\t\t\t\ttranslationKeyIndex\r\n\t\t\t\t] as keyof typeof translation;\r\n\r\n\t\t\t\t// Resolve the value using our new function (handles quotes and escapes)\r\n\t\t\t\tlet nodeValue: string = resolveStringValue(node);\r\n\r\n\t\t\t\tif (currentKey === 'number') {\r\n\t\t\t\t\t// `number` accepts any value, this will not be provided in the POT file\r\n\t\t\t\t\tnodeValue = node.text;\r\n\t\t\t\t} else if (!node?.type || !stringType.includes(node.type)) {\r\n\t\t\t\t\t// Whenever we get an unexpected node type this string is not translatable and should be skipped\r\n\t\t\t\t\tif (debugEnabled) {\r\n\t\t\t\t\t\tconsole.error(\r\n\t\t\t\t\t\t\t`Unexpected node type ${node?.type} identified as ${translationKeys[translationKeyIndex]} with value ${nodeValue} in ${filepath} at ${node.startPosition.row + 1} pos ${node.startPosition.column + 1}`,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn; // Parse error, skip this translation.\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// the value of that key\r\n\t\t\t\ttranslation[currentKey] = nodeValue;\r\n\r\n\t\t\t\t// increment the index of the translation key\r\n\t\t\t\ttranslationKeyIndex += 1;\r\n\t\t\t}\r\n\r\n\t\t\t// Check if domain matches the requested domain filter\r\n\t\t\tif (\r\n\t\t\t\tArray.isArray(args?.options?.translationDomains) &&\r\n\t\t\t\ttranslation.text_domain &&\r\n\t\t\t\t!args.options.translationDomains.includes(translation.text_domain)\r\n\t\t\t) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst comments = collectComments(node); // Pass the CallExpression node, collectComments walks up\r\n\r\n\t\t\t// Get the translation data\r\n\t\t\tconst block = new Block({\r\n\t\t\t\tmsgctxt: translation.msgctxt,\r\n\t\t\t\tmsgid: translation.msgid ?? \"\",\r\n\t\t\t\tmsgid_plural: translation.msgid_plural,\r\n\t\t\t\tmsgstr: translation.msgid_plural ? [\"\", \"\"] : [\"\"],\r\n\t\t\t\tcomments: {\r\n\t\t\t\t\ttranslator: comments ? [comments] : undefined,\r\n\t\t\t\t\treference: [\r\n\t\t\t\t\t\t`${reverseSlashes(filepath)}:${node.startPosition.row + 1}`,\r\n\t\t\t\t\t],\r\n\t\t\t\t},\r\n\t\t\t} as Block);\r\n\r\n\t\t\tgettextTranslations.add(block);\r\n\t\t}\r\n\t}\r\n\r\n\ttry {\r\n\t\tif (sourceCode) {\r\n\t\t\tconst fileSize = Buffer.byteLength(sourceCode, \"utf8\");\r\n\t\t\tlet bufferSize = 1024 * 32; // 32 KB default buffer size\r\n\r\n\t\t\tif (fileSize >= bufferSize) {\r\n\t\t\t\tbufferSize = fileSize + 32; // dynamic buffer size with 32 bytes of padding\r\n\t\t\t}\r\n\r\n\t\t\tif (fileSize >= 1024 * 1024 * 2) {\r\n\t\t\t\tconsole.warn(`File size warning: ${filepath} exceeds 2 MB.`);\r\n\t\t\t}\r\n\r\n\t\t\t// parse the file\r\n\t\t\tconst tree = parser.parse(sourceCode, undefined, { bufferSize });\r\n\t\t\tif (tree) {\r\n\t\t\t\ttraverse(tree.rootNode);\r\n\t\t\t}\r\n\t\t}\r\n\t} catch (e) {\r\n\t\tconsole.error(`Failed to parse ${filepath}: ${e}`);\r\n\t}\r\n\r\n\t// Return both matches and entries\r\n\treturn gettextTranslations;\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwC;AACxC,mBAA8B;AAC9B,4BAAmC;AACnC,kBAA0B;AAC1B,oBAAuD;AASvD,SAAS,gBAAgB,MAAsC;AAC9D,MAAI,cAAiC;AACrC,MAAI,QAAQ;AAGZ,SAAO,eAAe,QAAQ,GAAG;AAChC,QACC,YAAY,iBAAiB,SAAS,aACtC,YAAY,gBAAgB,KAAK,YAAY,EAAE,SAAS,aAAa,GACpE;AACD,iBAAO,sCAAuB,YAAY,gBAAgB,IAAI;AAAA,IAC/D;AACA;AACA,kBAAc,YAAY;AAAA,EAC3B;AACA,SAAO;AACR;AASA,SAAS,mBAAmB,MAA0B;AAErD,MAAI,KAAK,SAAS,mBAAmB;AACpC,WAAO,KAAK,SACV,IAAI,CAAC,UAAU;AACf,UAAI,MAAM,SAAS,mBAAmB;AAErC,gBAAQ,MAAM,MAAM;AAAA,UACnB,KAAK;AAAO,mBAAO;AAAA,UACnB,KAAK;AAAO,mBAAO;AAAA,UACnB,KAAK;AAAO,mBAAO;AAAA,UACnB,KAAK;AAAQ,mBAAO;AAAA,UACpB,KAAK;AAAO,mBAAO;AAAA,UACnB,KAAK;AAAO,mBAAO;AAAA,UACnB,KAAK;AAAO,mBAAO;AAAA,UACnB,KAAK;AAAO,mBAAO;AAAA,UACnB,KAAK;AAAO,mBAAO;AAAA,UACnB;AAAS,m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SAAO;AACR;",
6
+ "names": ["Parser", "node"]
7
+ }
@@ -1 +1,7 @@
1
- {"version":3,"file":"potCommand.js","sourceRoot":"","sources":["../src/potCommand.ts"],"names":[],"mappings":";;AAKA,6BAeC;AApBD,oDAA8C;AAG9C,iDAAsE;AAEtE,SAAwB,UAAU,CAAC,IAAU;IAC5C,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,IAAA,2BAAe,GAAE,CAAC;QAClB,4BAA4B;QAC5B,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,wBAAwB;QACxB,IAAA,oBAAO,EAAC,IAAI,CAAC;aACX,IAAI,CAAC,GAAG,EAAE;YACV,yBAAyB;YACzB,IAAA,4BAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACzC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChB,OAAO,CAAC,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;AACF,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/potCommand.ts"],
4
+ "sourcesContent": ["import { makePot } from \"./parser/makePot.js\";\n\nimport type { Args } from \"./types.js\";\nimport { printModuleInfo, printTimeElapsed } from \"./utils/common.js\";\n\nexport default function potCommand(args: Args) {\n\tif (Object.keys(args).length > 0) {\n\t\tprintModuleInfo();\n\t\t/* capture the start time */\n\t\tconst timeStart = new Date();\n\t\t/** make the pot file */\n\t\tmakePot(args)\n\t\t\t.then(() => {\n\t\t\t\t/* output the end time */\n\t\t\t\tprintTimeElapsed(\"Make-Pot\", timeStart);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconsole.error(`\uD83E\uDEE4 Make-pot - ${error}`);\n\t\t\t});\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AAGxB,oBAAkD;AAEnC,SAAR,WAA4B,MAAY;AAC9C,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AACjC,uCAAgB;AAEhB,UAAM,YAAY,oBAAI,KAAK;AAE3B,gCAAQ,IAAI,EACV,KAAK,MAAM;AAEX,0CAAiB,YAAY,SAAS;AAAA,IACvC,CAAC,EACA,MAAM,CAAC,UAAU;AACjB,cAAQ,MAAM,wBAAiB,KAAK,EAAE;AAAA,IACvC,CAAC;AAAA,EACH;AACD;",
6
+ "names": []
7
+ }