@wp-blocks/make-pot 1.6.5 → 1.6.6

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 (50) hide show
  1. package/README.md +2 -2
  2. package/lib/assets/block-i18n.js +41 -1
  3. package/lib/assets/package-i18n.js +38 -1
  4. package/lib/assets/theme-i18n.js +110 -1
  5. package/lib/assets/wp-plugin-i18n.js +39 -1
  6. package/lib/assets/wp-theme-i18n.js +37 -1
  7. package/lib/cli/getArgs.js +156 -1
  8. package/lib/cli/getArgs.js.map +2 -2
  9. package/lib/cli/getJsonArgs.js +82 -1
  10. package/lib/cli/parseCli.js +179 -1
  11. package/lib/cli.js +43 -1
  12. package/lib/const.js +111 -1
  13. package/lib/extractors/auditStrings.js +177 -6
  14. package/lib/extractors/auditStrings.js.map +2 -2
  15. package/lib/extractors/css.js +69 -1
  16. package/lib/extractors/headers.js +253 -15
  17. package/lib/extractors/headers.js.map +2 -2
  18. package/lib/extractors/json.js +70 -1
  19. package/lib/extractors/packageJson.js +55 -1
  20. package/lib/extractors/php.js +79 -2
  21. package/lib/extractors/php.js.map +2 -2
  22. package/lib/extractors/schema.js +217 -3
  23. package/lib/extractors/text.js +41 -1
  24. package/lib/fs/fs.js +114 -2
  25. package/lib/fs/glob.js +103 -1
  26. package/lib/index.js +64 -1
  27. package/lib/jsonCommand.js +51 -1
  28. package/lib/makeJson.js +28 -1
  29. package/lib/makePot.js +27 -1
  30. package/lib/parser/exec.js +94 -3
  31. package/lib/parser/exec.js.map +2 -2
  32. package/lib/parser/makeJson.js +393 -1
  33. package/lib/parser/makePot.js +48 -1
  34. package/lib/parser/patterns.js +54 -1
  35. package/lib/parser/process.js +85 -1
  36. package/lib/parser/progress.js +57 -1
  37. package/lib/parser/taskRunner.js +65 -2
  38. package/lib/parser/taskRunner.js.map +2 -2
  39. package/lib/parser/tree.js +228 -2
  40. package/lib/potCommand.js +36 -1
  41. package/lib/potCommand.js.map +2 -2
  42. package/lib/types.js +17 -1
  43. package/lib/types.js.map +1 -1
  44. package/lib/utils/common.js +161 -8
  45. package/lib/utils/common.js.map +2 -2
  46. package/lib/utils/extractors.js +69 -1
  47. package/lib/utils/output.js +59 -1
  48. package/lib/utils/output.js.map +3 -3
  49. package/package.json +1 -2
  50. package/tests/parse-php.test.js +47 -0
@@ -1 +1,48 @@
1
- "use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})},u=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of f(e))!h.call(t,a)&&a!==o&&i(t,a,{get:()=>e[a],enumerable:!(r=s(e,a))||r.enumerable});return t};var x=t=>u(i({},"__esModule",{value:!0}),t);var y={};d(y,{makePot:()=>k});module.exports=x(y);var m=require("../extractors/headers.js"),c=require("../extractors/packageJson.js"),n=require("../fs/fs.js"),p=require("./exec.js");async function k(t){const e=(0,c.extractPackageJson)(t),o=(0,m.extractMainFileData)(t);return t.headers={...t?.options?.headers,...e,...o},await(0,p.exec)(t).then(r=>((0,n.writeFile)(r,t),r)).catch(r=>(console.error(r),""))}0&&(module.exports={makePot});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var makePot_exports = {};
20
+ __export(makePot_exports, {
21
+ makePot: () => makePot
22
+ });
23
+ module.exports = __toCommonJS(makePot_exports);
24
+ var import_headers = require("../extractors/headers.js");
25
+ var import_packageJson = require("../extractors/packageJson.js");
26
+ var import_fs = require("../fs/fs.js");
27
+ var import_exec = require("./exec.js");
28
+ async function makePot(args) {
29
+ const pkgData = (0, import_packageJson.extractPackageJson)(args);
30
+ const metadata = (0, import_headers.extractMainFileData)(args);
31
+ args.headers = {
32
+ ...args?.options?.headers,
33
+ ...pkgData,
34
+ ...metadata
35
+ };
36
+ return await (0, import_exec.exec)(args).then((jsonTranslations) => {
37
+ (0, import_fs.writeFile)(jsonTranslations, args);
38
+ return jsonTranslations;
39
+ }).catch((error) => {
40
+ console.error(error);
41
+ return "";
42
+ });
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ makePot
47
+ });
48
+ //# sourceMappingURL=makePot.js.map
@@ -1 +1,54 @@
1
- "use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var p in e)n(t,p,{get:e[p],enumerable:!0})},l=(t,e,p,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of u(e))!c.call(t,s)&&s!==p&&n(t,s,{get:()=>e[s],enumerable:!(o=i(e,s))||o.enumerable});return t};var d=t=>l(n({},"__esModule",{value:!0}),t);var a={};h(a,{getPatterns:()=>r});module.exports=d(a);function r(t){const e={include:t.patterns.include||[],exclude:t.patterns.exclude||[],mergePaths:t.patterns.mergePaths,subtractPaths:t.patterns.subtractPaths,subtractAndMerge:t.patterns.subtractAndMerge};return t.options&&(t.options.skip.blade?e.exclude.push("**/*.blade.php"):t.options.skip.php&&e.exclude.push("**/*.php","**/*.blade.php"),t.options.skip.js&&e.exclude.push("**/*.{js,jsx,ts,tsx,mjs,cjs}"),t.options.skip.blockJson&&e.exclude.push("block.json"),t.options.skip.themeJson&&e.exclude.push("theme.json")),e}0&&(module.exports={getPatterns});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var patterns_exports = {};
20
+ __export(patterns_exports, {
21
+ getPatterns: () => getPatterns
22
+ });
23
+ module.exports = __toCommonJS(patterns_exports);
24
+ function getPatterns(args) {
25
+ const pattern = {
26
+ include: args.patterns.include || [],
27
+ exclude: args.patterns.exclude || [],
28
+ mergePaths: args.patterns.mergePaths,
29
+ subtractPaths: args.patterns.subtractPaths,
30
+ subtractAndMerge: args.patterns.subtractAndMerge
31
+ };
32
+ if (args.options) {
33
+ if (args.options.skip.blade) {
34
+ pattern.exclude.push("**/*.blade.php");
35
+ } else if (args.options.skip.php) {
36
+ pattern.exclude.push("**/*.php", "**/*.blade.php");
37
+ }
38
+ if (args.options.skip.js) {
39
+ pattern.exclude.push("**/*.{js,jsx,ts,tsx,mjs,cjs}");
40
+ }
41
+ if (args.options.skip.blockJson) {
42
+ pattern.exclude.push("block.json");
43
+ }
44
+ if (args.options.skip.themeJson) {
45
+ pattern.exclude.push("theme.json");
46
+ }
47
+ }
48
+ return pattern;
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ getPatterns
53
+ });
54
+ //# sourceMappingURL=patterns.js.map
@@ -1 +1,85 @@
1
- "use strict";var x=Object.create;var f=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var $=(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 F(e))!O.call(t,s)&&s!==o&&f(t,s,{get:()=>e[s],enumerable:!(i=C(e,s))||i.enumerable});return t};var g=(t,e,o)=>(o=t!=null?x(w(t)):{},d(e||!t||!t.__esModule?f(o,"default",{value:t,enumerable:!0}):o,t)),j=t=>d(f({},"__esModule",{value:!0}),t);var R={};$(R,{processFiles:()=>A});module.exports=j(R);var r=g(require("node:path")),h=require("../extractors/json.js"),a=require("../fs/fs.js"),k=require("../fs/glob.js"),P=require("./tree.js"),b=require("../const");async function A(t,e,o){const i=[];let s=0,l=0;const p=await(0,k.getFiles)(e,t);o&&(o.setTotal(p.length),o.update(0,{filename:`Found ${p.length} files`}));for(const n of p){const c=r.default.basename(n),S=r.default.extname(n).replace(/^./,""),u=r.default.resolve(e.paths.cwd,n);if(c==="theme.json"||c==="block.json")s++,i.push((0,a.readFileAsync)(u).then(m=>(0,h.parseJsonCallback)(m,e.paths.cwd,c)));else if(b.allowedFormats.includes(S)){s++;const m=(0,a.readFileAsync)(u).then(y=>(0,P.doTree)(y,n,e.debug,e));m&&i.push(m)}else l++;o&&o.update(s+l,{filename:`${r.default.basename(n)} (Processed: ${s} | Skipped: ${l})`})}return{tasks:i,processedCount:s,skippedCount:l}}0&&(module.exports={processFiles});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var process_exports = {};
30
+ __export(process_exports, {
31
+ processFiles: () => processFiles
32
+ });
33
+ module.exports = __toCommonJS(process_exports);
34
+ var import_node_path = __toESM(require("node:path"));
35
+ var import_json = require("../extractors/json.js");
36
+ var import_fs = require("../fs/fs.js");
37
+ var import_glob = require("../fs/glob.js");
38
+ var import_tree = require("./tree.js");
39
+ var import_const = require("../const");
40
+ async function processFiles(patterns, args, progressBar) {
41
+ const tasks = [];
42
+ let processedCount = 0;
43
+ let skippedCount = 0;
44
+ const files = await (0, import_glob.getFiles)(args, patterns);
45
+ if (progressBar) {
46
+ progressBar.setTotal(files.length);
47
+ progressBar.update(0, {
48
+ filename: `Found ${files.length} files`
49
+ });
50
+ }
51
+ for (const file of files) {
52
+ const filename = import_node_path.default.basename(file);
53
+ const ext = import_node_path.default.extname(file).replace(/^./, "");
54
+ const fileRealPath = import_node_path.default.resolve(args.paths.cwd, file);
55
+ if (filename === "theme.json" || filename === "block.json") {
56
+ processedCount++;
57
+ tasks.push(
58
+ (0, import_fs.readFileAsync)(fileRealPath).then(
59
+ (sourceCode) => (0, import_json.parseJsonCallback)(sourceCode, args.paths.cwd, filename)
60
+ )
61
+ );
62
+ } else if (import_const.allowedFormats.includes(ext)) {
63
+ processedCount++;
64
+ const fileTree = (0, import_fs.readFileAsync)(fileRealPath).then(
65
+ (content) => (0, import_tree.doTree)(content, file, args.debug, args)
66
+ );
67
+ if (fileTree) {
68
+ tasks.push(fileTree);
69
+ }
70
+ } else {
71
+ skippedCount++;
72
+ }
73
+ if (progressBar) {
74
+ progressBar.update(processedCount + skippedCount, {
75
+ filename: `${import_node_path.default.basename(file)} (Processed: ${processedCount} | Skipped: ${skippedCount})`
76
+ });
77
+ }
78
+ }
79
+ return { tasks, processedCount, skippedCount };
80
+ }
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ processFiles
84
+ });
85
+ //# sourceMappingURL=process.js.map
@@ -1 +1,57 @@
1
- "use strict";var f=Object.create;var i=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var $=(e,r)=>{for(var s in r)i(e,s,{get:r[s],enumerable:!0})},a=(e,r,s,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of E(r))!I.call(e,t)&&t!==s&&i(e,t,{get:()=>r[t],enumerable:!(n=m(r,t))||n.enumerable});return e};var d=(e,r,s)=>(s=e!=null?f(p(e)):{},a(r||!e||!e.__esModule?i(s,"default",{value:e,enumerable:!0}):s,e)),A=e=>a(i({},"__esModule",{value:!0}),e);var h={};$(h,{initProgress:()=>_});module.exports=A(h);var o=d(require("cli-progress"));function _(e,r){return new o.default.SingleBar({clearOnComplete:!0,etaBuffer:1e3,hideCursor:!0,format:(n,t,l)=>{const g=n.barCompleteString?.substring(0,Math.round(t.progress*(n.barsize??40)))??"",u=n.barIncompleteString?.substring(0,(n.barsize??40)-g.length)??"",c=Math.round(t.progress*100),b=(l.filename||"").substring(0,40).padEnd(40);return` ${g}${u} ${c}% | ETA: ${t.eta}s | ${b} | ${t.value}/${t.total}`}},o.default.Presets.shades_classic)}0&&(module.exports={initProgress});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var progress_exports = {};
30
+ __export(progress_exports, {
31
+ initProgress: () => initProgress
32
+ });
33
+ module.exports = __toCommonJS(progress_exports);
34
+ var import_cli_progress = __toESM(require("cli-progress"));
35
+ function initProgress(_args, _filesCount) {
36
+ const FILENAME_WIDTH = 40;
37
+ return new import_cli_progress.default.SingleBar(
38
+ {
39
+ clearOnComplete: true,
40
+ etaBuffer: 1e3,
41
+ hideCursor: true,
42
+ format: (options, params, payload) => {
43
+ const bar = options.barCompleteString?.substring(0, Math.round(params.progress * (options.barsize ?? 40))) ?? "";
44
+ const emptyBar = options.barIncompleteString?.substring(0, (options.barsize ?? 40) - bar.length) ?? "";
45
+ const pct = Math.round(params.progress * 100);
46
+ const filename = (payload.filename || "").substring(0, FILENAME_WIDTH).padEnd(FILENAME_WIDTH);
47
+ return ` ${bar}${emptyBar} ${pct}% | ETA: ${params.eta}s | ${filename} | ${params.value}/${params.total}`;
48
+ }
49
+ },
50
+ import_cli_progress.default.Presets.shades_classic
51
+ );
52
+ }
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ initProgress
56
+ });
57
+ //# sourceMappingURL=progress.js.map
@@ -1,2 +1,65 @@
1
- "use strict";var g=Object.create;var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var s in e)i(t,s,{get:e[s],enumerable:!0})},m=(t,e,s,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of k(e))!d.call(t,n)&&n!==s&&i(t,n,{get:()=>e[n],enumerable:!(l=u(e,n))||l.enumerable});return t};var p=(t,e,s)=>(s=t!=null?g(S(t)):{},m(e||!t||!t.__esModule?i(s,"default",{value:t,enumerable:!0}):s,t)),O=t=>m(i({},"__esModule",{value:!0}),t);var B={};y(B,{taskRunner:()=>b});module.exports=O(B);var $=p(require("node:os")),a=p(require("node:path"));async function b(t,e,s,l){const n=[],f=t.map(r=>r.then(o=>(l.increment({filename:o.path?a.default.basename(o.path):""}),o)).catch(o=>{throw l.increment({filename:"error"}),o}));return await Promise.allSettled(f).then(r=>r.map(o=>o.status==="fulfilled"&&o.value).filter(Boolean)).then(r=>{for(const o of r)if(o.blocks.length>0){e.addArray(o.blocks);const c=o.blocks.map(h=>h.msgid);s.options?.silent!==!0&&n.push(`\u2705 ${o.path} - ${c.length} strings found [${c.join(", ")}]`)}else s.options?.silent!==!0&&n.push(`\u274C ${o.path} - has no strings`)}).catch(r=>new Error(r)),l.stop(),console.log(`
2
- \u{1F389} Done!`),console.log(`\u{1F4DD} Found ${Object.values(e.blocks).length} translation strings in ${a.default.resolve(s.paths.cwd)}.`),console.log(n.join($.EOL)),e}0&&(module.exports={taskRunner});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var taskRunner_exports = {};
30
+ __export(taskRunner_exports, {
31
+ taskRunner: () => taskRunner
32
+ });
33
+ module.exports = __toCommonJS(taskRunner_exports);
34
+ var import_node_path = __toESM(require("node:path"));
35
+ async function taskRunner(tasks, destination, args, progressBar) {
36
+ const tasksWithProgress = tasks.map(
37
+ (task) => task.then((result) => {
38
+ progressBar.increment({
39
+ filename: result.path ? import_node_path.default.basename(result.path) : ""
40
+ });
41
+ return result;
42
+ }).catch((err) => {
43
+ progressBar.increment({ filename: "error" });
44
+ throw err;
45
+ })
46
+ );
47
+ await Promise.allSettled(tasksWithProgress).then((strings) => {
48
+ return strings.map((block) => block.status === "fulfilled" && block.value).filter(Boolean);
49
+ }).then((consolidated) => {
50
+ for (const result of consolidated) {
51
+ if (result.blocks.length > 0) {
52
+ destination.addArray(result.blocks);
53
+ }
54
+ }
55
+ }).catch((err) => {
56
+ return new Error(err);
57
+ });
58
+ progressBar.stop();
59
+ return destination;
60
+ }
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ taskRunner
64
+ });
65
+ //# sourceMappingURL=taskRunner.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/parser/taskRunner.ts"],
4
- "sourcesContent": ["import * as os from \"node:os\";\r\nimport path from \"node:path\";\r\nimport type { SingleBar } from \"cli-progress\";\r\nimport type { SetOfBlocks } from \"gettext-merger\";\r\nimport type { Args } from \"../types.js\";\r\n\r\n/**\r\n * Task runner for the extraction process.\r\n *\r\n * @param tasks - The tasks to run\r\n * @param destination - The destination\r\n * @param args - The command line arguments\r\n * @param progressBar\r\n */\r\nexport async function taskRunner(\r\n\ttasks: Promise<SetOfBlocks>[],\r\n\tdestination: SetOfBlocks,\r\n\targs: Args,\r\n\tprogressBar: SingleBar,\r\n) {\r\n\tconst messages: string[] = [];\r\n\t// Create a new array of promises that update the bar when they finish.\r\n\tconst tasksWithProgress = tasks.map((task) =>\r\n\t\ttask.then((result) => {\r\n\t\t\tprogressBar.increment({\r\n\t\t\t\tfilename: result.path ? path.basename(result.path) : \"\",\r\n\t\t\t});\r\n\t\t\treturn result;\r\n\t\t}).catch((err) => {\r\n\t\t\tprogressBar.increment({ filename: \"error\" });\r\n\t\t\tthrow err;\r\n\t\t})\r\n\t);\r\n\tawait Promise.allSettled(tasksWithProgress)\r\n\t\t.then((strings) => {\r\n\t\t\t/**\r\n\t\t\t * Return the strings that are not rejected (they are fulfilled)\r\n\t\t\t */\r\n\t\t\treturn strings\r\n\t\t\t\t.map((block) => block.status === \"fulfilled\" && block.value)\r\n\t\t\t\t.filter(Boolean) as SetOfBlocks[]; // remove nullish\r\n\t\t})\r\n\t\t.then((consolidated) => {\r\n\t\t\t/** Log the results */\r\n\t\t\tfor (const result of consolidated) {\r\n\t\t\t\tif (result.blocks.length > 0) {\r\n\t\t\t\t\t/**\r\n\t\t\t\t\t * Add the strings to the destination set\r\n\t\t\t\t\t */\r\n\t\t\t\t\tdestination.addArray(result.blocks);\r\n\t\t\t\t\tconst strings = result.blocks.map((b) => b.msgid);\r\n\r\n\t\t\t\t\t/* Log the results */\r\n\t\t\t\t\tif (args.options?.silent !== true) {\r\n\t\t\t\t\t\tmessages.push(\r\n\t\t\t\t\t\t\t`\u2705 ${result.path} - ${strings.length} strings found [${strings.join(\", \")}]`,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t} else if (args.options?.silent !== true) {\r\n\t\t\t\t\tmessages.push(`\u274C ${result.path} - has no strings`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n\t\t.catch((err) => {\r\n\t\t\treturn new Error(err);\r\n\t\t});\r\n\r\n\tprogressBar.stop();\r\n\r\n\tconsole.log(\"\\n\uD83C\uDF89 Done!\");\r\n\tconsole.log(\r\n\t\t`\uD83D\uDCDD Found ${Object.values(destination.blocks).length} translation strings in ${path.resolve(args.paths.cwd)}.`,\r\n\t);\r\n\r\n\tconsole.log(messages.join(os.EOL));\r\n\r\n\treturn destination;\r\n}\r\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,KAAK,CAAC,WAAW;AACrB,kBAAY,UAAU;AAAA,QACrB,UAAU,OAAO,OAAO,iBAAAA,QAAK,SAAS,OAAO,IAAI,IAAI;AAAA,MACtD,CAAC;AACD,aAAO;AAAA,IACR,CAAC,EAAE,MAAM,CAAC,QAAQ;AACjB,kBAAY,UAAU,EAAE,UAAU,QAAQ,CAAC;AAC3C,YAAM;AAAA,IACP,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;",
4
+ "sourcesContent": ["import * as os from \"node:os\";\r\nimport path from \"node:path\";\r\nimport type { SingleBar } from \"cli-progress\";\r\nimport type { SetOfBlocks } from \"gettext-merger\";\r\nimport type { Args } from \"../types.js\";\r\n\r\n/**\r\n * Task runner for the extraction process.\r\n *\r\n * @param tasks - The tasks to run\r\n * @param destination - The destination\r\n * @param args - The command line arguments\r\n * @param progressBar\r\n */\r\nexport async function taskRunner(\r\n\ttasks: Promise<SetOfBlocks>[],\r\n\tdestination: SetOfBlocks,\r\n\targs: Args,\r\n\tprogressBar: SingleBar,\r\n) {\r\n\t// Create a new array of promises that update the bar when they finish.\r\n\tconst tasksWithProgress = tasks.map((task) =>\r\n\t\ttask.then((result) => {\r\n\t\t\tprogressBar.increment({\r\n\t\t\t\tfilename: result.path ? path.basename(result.path) : \"\",\r\n\t\t\t});\r\n\t\t\treturn result;\r\n\t\t}).catch((err) => {\r\n\t\t\tprogressBar.increment({ filename: \"error\" });\r\n\t\t\tthrow err;\r\n\t\t})\r\n\t);\r\n\tawait Promise.allSettled(tasksWithProgress)\r\n\t\t.then((strings) => {\r\n\t\t\t/**\r\n\t\t\t * Return the strings that are not rejected (they are fulfilled)\r\n\t\t\t */\r\n\t\t\treturn strings\r\n\t\t\t\t.map((block) => block.status === \"fulfilled\" && block.value)\r\n\t\t\t\t.filter(Boolean) as SetOfBlocks[]; // remove nullish\r\n\t\t})\r\n\t\t.then((consolidated) => {\r\n\t\t\t/** Log the results */\r\n\t\t\tfor (const result of consolidated) {\r\n\t\t\t\tif (result.blocks.length > 0) {\r\n\t\t\t\t\t/**\r\n\t\t\t\t\t * Add the strings to the destination set\r\n\t\t\t\t\t */\r\n\t\t\t\t\tdestination.addArray(result.blocks);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n\t\t.catch((err) => {\r\n\t\t\treturn new Error(err);\r\n\t\t});\r\n\r\n\tprogressBar.stop();\r\n\r\n\treturn destination;\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAiB;AAajB,eAAsB,WACrB,OACA,aACA,MACA,aACC;AAED,QAAM,oBAAoB,MAAM;AAAA,IAAI,CAAC,SACpC,KAAK,KAAK,CAAC,WAAW;AACrB,kBAAY,UAAU;AAAA,QACrB,UAAU,OAAO,OAAO,iBAAAA,QAAK,SAAS,OAAO,IAAI,IAAI;AAAA,MACtD,CAAC;AACD,aAAO;AAAA,IACR,CAAC,EAAE,MAAM,CAAC,QAAQ;AACjB,kBAAY,UAAU,EAAE,UAAU,QAAQ,CAAC;AAC3C,YAAM;AAAA,IACP,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;AAAA,MACnC;AAAA,IACD;AAAA,EACD,CAAC,EACA,MAAM,CAAC,QAAQ;AACf,WAAO,IAAI,MAAM,GAAG;AAAA,EACrB,CAAC;AAEF,cAAY,KAAK;AAEjB,SAAO;AACR;",
6
6
  "names": ["path"]
7
7
  }
@@ -1,2 +1,228 @@
1
- "use strict";var L=Object.create;var g=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},N=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of O(t))!z.call(e,o)&&o!==n&&g(e,o,{get:()=>t[o],enumerable:!(s=M(t,o))||s.enumerable});return e};var K=(e,t,n)=>(n=e!=null?L(j(e)):{},N(t||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),V=e=>N(g({},"__esModule",{value:!0}),e);var R={};D(R,{doTree:()=>I});module.exports=V(R);var F=K(require("tree-sitter")),h=require("../const.js"),f=require("gettext-merger"),B=require("../fs/glob.js"),x=require("../utils/common.js");function q(e){let t=e,n=0;for(;t&&n<6;){if(t.previousSibling?.type==="comment"&&t.previousSibling.text.toLowerCase().includes("translators"))return(0,x.stripTranslationMarkup)(t.previousSibling.text);n++,t=t.parent}}const y={n:`
2
- `,r:"\r",t:" ",f:"\f",v:"\v",0:"\0","\\":"\\",'"':'"',"'":"'",$:"$",e:"\x1B"};function E(e){if(e.type==="encapsed_string")return e.children.map(t=>{if(t.type==="escape_sequence"){const n=t.text.slice(1);return n in y?y[n]:t.text}return t.type==="string_content"||t.type==="variable_name"?t.text:""}).join("");if(e.type==="string"){const t=e.text;if(t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')){const n=t.startsWith('"');let s=t.slice(1,-1);return n?s=s.replace(/\\(.)/g,(o,u)=>u in y?y[u]:o):s=s.replace(/\\'/g,"'").replace(/\\\\/g,"\\"),s}}return e.text}function I(e,t,n,s){const o=new F.default,u=(0,B.getParser)(t);if(!u)return new f.SetOfBlocks([],t);o.setLanguage(u);const S=new f.SetOfBlocks([],t),P=t.split(".").pop()?.toLowerCase()!=="php"?"call_expression":"function_call_expression",T=["name","string","string_value","variable_name","binary_expression","member_expression","subscript_expression","shell_command_expression","function_call_expression","encapsed_string"];function v(i){if(i?.children.length)for(const a of i.children)v(a);if(i?.type===P){const a=i.firstChild?.text??null;if(a===null||!Object.keys(h.i18nFunctions).includes(a))return;const l=i.childForFieldName("arguments");if(l===null||l.childCount===0||l.type!=="arguments"||!l)return;const c={text_domain:"default"},_=h.i18nFunctions[a],W=l.children;let m=0;for(const p of W){let r=p;if(r.type==="("||r.type===")"||r.type===","||r.type==="["||r.type==="]"||r.type==="comment")continue;if(p.type==="argument"){if(p.children.length===0)continue;const C=p.childForFieldName("name");let w=!1;for(const d of p.children)if(d.id!==C?.id&&!(d.type==="comment"||d.type===":")){r=d,w=!0;break}if(!w)continue}if(m>=_.length)break;const k=_[m];let b=E(r);if(k==="number")b=r.text;else if(!r?.type||!T.includes(r.type)){n&&console.error(`Unexpected node type ${r?.type} identified as ${_[m]} with value ${b} in ${t} at ${r.startPosition.row+1} pos ${r.startPosition.column+1}`);return}c[k]=b,m+=1}if(Array.isArray(s?.options?.translationDomains)&&c.text_domain&&!s.options.translationDomains.includes(c.text_domain))return;const $=q(i),A=new f.Block({msgctxt:c.msgctxt,msgid:c.msgid??"",msgid_plural:c.msgid_plural,msgstr:c.msgid_plural?["",""]:[""],comments:{translator:$?[$]:void 0,reference:[`${(0,x.reverseSlashes)(t)}:${i.startPosition.row+1}`]}});S.add(A)}}try{if(e){const i=Buffer.byteLength(e,"utf8");let a=1024*32;i>=a&&(a=i+32),i>=1024*1024*2&&console.warn(`File size warning: ${t} exceeds 2 MB.`);const l=o.parse(e,void 0,{bufferSize:a});l&&v(l.rootNode)}}catch(i){console.error(`Failed to parse ${t}: ${i}`)}return S}0&&(module.exports={doTree});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var tree_exports = {};
30
+ __export(tree_exports, {
31
+ doTree: () => doTree
32
+ });
33
+ module.exports = __toCommonJS(tree_exports);
34
+ var import_tree_sitter = __toESM(require("tree-sitter"));
35
+ var import_const = require("../const.js");
36
+ var import_gettext_merger = require("gettext-merger");
37
+ var import_glob = require("../fs/glob.js");
38
+ var import_common = require("../utils/common.js");
39
+ function collectComments(node) {
40
+ let currentNode = node;
41
+ let depth = 0;
42
+ while (currentNode && depth < 6) {
43
+ if (currentNode.previousSibling?.type === "comment" && currentNode.previousSibling.text.toLowerCase().includes("translators")) {
44
+ return (0, import_common.stripTranslationMarkup)(currentNode.previousSibling.text);
45
+ }
46
+ depth++;
47
+ currentNode = currentNode.parent;
48
+ }
49
+ return void 0;
50
+ }
51
+ const escapeMap = {
52
+ "n": "\n",
53
+ "r": "\r",
54
+ "t": " ",
55
+ "f": "\f",
56
+ "v": "\v",
57
+ "0": "\0",
58
+ "\\": "\\",
59
+ '"': '"',
60
+ "'": "'",
61
+ "$": "$",
62
+ "e": "\x1B"
63
+ };
64
+ function resolveStringValue(node) {
65
+ if (node.type === "encapsed_string") {
66
+ return node.children.map((child) => {
67
+ if (child.type === "escape_sequence") {
68
+ const ch = child.text.slice(1);
69
+ return ch in escapeMap ? escapeMap[ch] : child.text;
70
+ }
71
+ if (child.type === "string_content") {
72
+ return child.text;
73
+ }
74
+ if (child.type === "variable_name") {
75
+ return child.text;
76
+ }
77
+ return "";
78
+ }).join("");
79
+ }
80
+ if (node.type === "string") {
81
+ const text = node.text;
82
+ if (text.startsWith("'") && text.endsWith("'") || text.startsWith('"') && text.endsWith('"')) {
83
+ const isDouble = text.startsWith('"');
84
+ let inner = text.slice(1, -1);
85
+ if (isDouble) {
86
+ inner = inner.replace(
87
+ /\\(.)/g,
88
+ (_match, ch) => ch in escapeMap ? escapeMap[ch] : _match
89
+ );
90
+ } else {
91
+ inner = inner.replace(/\\'/g, "'").replace(/\\\\/g, "\\");
92
+ }
93
+ return inner;
94
+ }
95
+ }
96
+ return node.text;
97
+ }
98
+ function doTree(sourceCode, filepath, debugEnabled, args) {
99
+ const parser = new import_tree_sitter.default();
100
+ const parserExt = (0, import_glob.getParser)(filepath);
101
+ if (!parserExt) return new import_gettext_merger.SetOfBlocks([], filepath);
102
+ parser.setLanguage(parserExt);
103
+ const gettextTranslations = new import_gettext_merger.SetOfBlocks([], filepath);
104
+ const typeToMatch = filepath.split(".").pop()?.toLowerCase() !== "php" ? "call_expression" : "function_call_expression";
105
+ const stringType = [
106
+ "name",
107
+ "string",
108
+ "string_value",
109
+ "variable_name",
110
+ "binary_expression",
111
+ "member_expression",
112
+ "subscript_expression",
113
+ "shell_command_expression",
114
+ "function_call_expression",
115
+ "encapsed_string"
116
+ ];
117
+ function traverse(node) {
118
+ if (node?.children.length) {
119
+ for (const child of node.children) {
120
+ traverse(child);
121
+ }
122
+ }
123
+ if (node?.type === typeToMatch) {
124
+ const functionName = node.firstChild?.text ?? null;
125
+ if (functionName === null || !Object.keys(import_const.i18nFunctions).includes(functionName)) {
126
+ return;
127
+ }
128
+ const argsNode = node.childForFieldName("arguments");
129
+ if (argsNode === null || argsNode.childCount === 0 || argsNode.type !== "arguments") {
130
+ return;
131
+ }
132
+ if (!argsNode) return;
133
+ const translation = {
134
+ // WordPress default text domain is 'default'
135
+ text_domain: "default"
136
+ };
137
+ const translationKeys = import_const.i18nFunctions[functionName];
138
+ const children = argsNode.children;
139
+ let translationKeyIndex = 0;
140
+ for (const child of children) {
141
+ let node2 = child;
142
+ if (node2.type === "(" || node2.type === ")" || node2.type === "," || node2.type === "[" || node2.type === "]") {
143
+ continue;
144
+ }
145
+ if (node2.type === "comment") {
146
+ continue;
147
+ }
148
+ if (child.type === "argument") {
149
+ if (child.children.length === 0) continue;
150
+ const nameNode = child.childForFieldName("name");
151
+ let foundValue = false;
152
+ for (const argChild of child.children) {
153
+ if (argChild.id === nameNode?.id) {
154
+ continue;
155
+ }
156
+ if (argChild.type === "comment" || argChild.type === ":") {
157
+ continue;
158
+ }
159
+ node2 = argChild;
160
+ foundValue = true;
161
+ break;
162
+ }
163
+ if (!foundValue) {
164
+ continue;
165
+ }
166
+ }
167
+ if (translationKeyIndex >= translationKeys.length) {
168
+ break;
169
+ }
170
+ const currentKey = translationKeys[translationKeyIndex];
171
+ let nodeValue = resolveStringValue(node2);
172
+ if (currentKey === "number") {
173
+ nodeValue = node2.text;
174
+ } else if (!node2?.type || !stringType.includes(node2.type)) {
175
+ if (debugEnabled) {
176
+ console.error(
177
+ `Unexpected node type ${node2?.type} identified as ${translationKeys[translationKeyIndex]} with value ${nodeValue} in ${filepath} at ${node2.startPosition.row + 1} pos ${node2.startPosition.column + 1}`
178
+ );
179
+ }
180
+ return;
181
+ }
182
+ translation[currentKey] = nodeValue;
183
+ translationKeyIndex += 1;
184
+ }
185
+ if (Array.isArray(args?.options?.translationDomains) && translation.text_domain && !args.options.translationDomains.includes(translation.text_domain)) {
186
+ return;
187
+ }
188
+ const comments = collectComments(node);
189
+ const block = new import_gettext_merger.Block({
190
+ msgctxt: translation.msgctxt,
191
+ msgid: translation.msgid ?? "",
192
+ msgid_plural: translation.msgid_plural,
193
+ msgstr: translation.msgid_plural ? ["", ""] : [""],
194
+ comments: {
195
+ translator: comments ? [comments] : void 0,
196
+ reference: [
197
+ `${(0, import_common.reverseSlashes)(filepath)}:${node.startPosition.row + 1}`
198
+ ]
199
+ }
200
+ });
201
+ gettextTranslations.add(block);
202
+ }
203
+ }
204
+ try {
205
+ if (sourceCode) {
206
+ const fileSize = Buffer.byteLength(sourceCode, "utf8");
207
+ let bufferSize = 1024 * 32;
208
+ if (fileSize >= bufferSize) {
209
+ bufferSize = fileSize + 32;
210
+ }
211
+ if (fileSize >= 1024 * 1024 * 2) {
212
+ console.warn(`File size warning: ${filepath} exceeds 2 MB.`);
213
+ }
214
+ const tree = parser.parse(sourceCode, void 0, { bufferSize });
215
+ if (tree) {
216
+ traverse(tree.rootNode);
217
+ }
218
+ }
219
+ } catch (e) {
220
+ console.error(`Failed to parse ${filepath}: ${e}`);
221
+ }
222
+ return gettextTranslations;
223
+ }
224
+ // Annotate the CommonJS export names for ESM import in node:
225
+ 0 && (module.exports = {
226
+ doTree
227
+ });
228
+ //# sourceMappingURL=tree.js.map
package/lib/potCommand.js CHANGED
@@ -1 +1,36 @@
1
- "use strict";var n=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of s(t))!c.call(e,r)&&r!==o&&n(e,r,{get:()=>t[r],enumerable:!(p=f(t,r))||p.enumerable});return e};var k=e=>d(n({},"__esModule",{value:!0}),e);var h={};l(h,{default:()=>a});module.exports=k(h);var i=require("./parser/makePot.js"),m=require("./utils/common.js");function a(e){if(Object.keys(e).length>0){(0,m.printModuleInfo)();const t=new Date;(0,i.makePot)(e).then(()=>{(0,m.printTimeElapsed)("Make-Pot",t)}).catch(o=>{console.error(`\u{1FAE4} Make-pot - ${o}`)})}}
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var potCommand_exports = {};
20
+ __export(potCommand_exports, {
21
+ default: () => potCommand
22
+ });
23
+ module.exports = __toCommonJS(potCommand_exports);
24
+ var import_makePot = require("./parser/makePot.js");
25
+ var import_common = require("./utils/common.js");
26
+ function potCommand(args) {
27
+ if (Object.keys(args).length > 0) {
28
+ (0, import_common.printModuleInfo)();
29
+ (0, import_makePot.makePot)(args).then(() => {
30
+ (0, import_common.printTimeElapsed)("Make-Pot", args.timeStart);
31
+ }).catch((error) => {
32
+ console.error(`\u{1FAE4} Make-pot - ${error}`);
33
+ });
34
+ }
35
+ }
36
+ //# sourceMappingURL=potCommand.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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;",
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/** 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\", args.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,gCAAQ,IAAI,EACV,KAAK,MAAM;AAEX,0CAAiB,YAAY,KAAK,SAAS;AAAA,IAC5C,CAAC,EACA,MAAM,CAAC,UAAU;AACjB,cAAQ,MAAM,wBAAiB,KAAK,EAAE;AAAA,IACvC,CAAC;AAAA,EACH;AACD;",
6
6
  "names": []
7
7
  }
package/lib/types.js CHANGED
@@ -1 +1,17 @@
1
- "use strict";var s=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var p=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!g.call(t,n)&&n!==a&&s(t,n,{get:()=>e[n],enumerable:!(r=o(e,n))||r.enumerable});return t};var l=t=>p(s({},"__esModule",{value:!0}),t);var d={};module.exports=l(d);
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
17
+ //# sourceMappingURL=types.js.map