@wp-blocks/make-pot 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/biome.json +12 -0
  2. package/lib/assets/block-i18n.js +1 -0
  3. package/lib/assets/package-i18n.js +1 -0
  4. package/lib/assets/theme-i18n.js +1 -0
  5. package/lib/assets/wp-plugin-i18n.js +1 -0
  6. package/lib/assets/wp-theme-i18n.js +1 -0
  7. package/lib/cli/getArgs.js +1 -0
  8. package/lib/cli/parseCli.js +1 -110
  9. package/lib/const.js +1 -82
  10. package/lib/extractors/css.js +1 -42
  11. package/lib/extractors/headers.js +1 -73
  12. package/lib/extractors/json.js +1 -69
  13. package/lib/extractors/php.js +2 -49
  14. package/lib/extractors/schema.js +1 -100
  15. package/lib/extractors/text.js +1 -18
  16. package/lib/extractors/utils.js +1 -55
  17. package/lib/fs/fs.js +1 -0
  18. package/lib/fs/glob.js +3 -83
  19. package/lib/index.js +1 -26
  20. package/lib/parser/exec.js +3 -49
  21. package/lib/parser/makePot.js +1 -0
  22. package/lib/parser/patterns.js +1 -33
  23. package/lib/parser/process.js +1 -38
  24. package/lib/parser/progress.js +1 -21
  25. package/lib/parser/taskRunner.js +1 -33
  26. package/lib/parser/tree.js +1 -104
  27. package/lib/run.js +1 -0
  28. package/lib/types.js +1 -3
  29. package/lib/utils/common.js +2 -0
  30. package/package.json +68 -75
  31. package/tsconfig.json +4 -20
  32. package/ .prettierignore +0 -3
  33. package/.editorconfig +0 -15
  34. package/.eslintrc.json +0 -12
  35. package/jest.config.json +0 -18
  36. package/lib/assets/block-i18n.json +0 -17
  37. package/lib/assets/package-i18n.json +0 -13
  38. package/lib/assets/theme-i18n.json +0 -86
  39. package/lib/assets/wp-plugin-i18n.json +0 -14
  40. package/lib/assets/wp-theme-i18n.json +0 -13
  41. package/lib/cli/index.d.ts +0 -1
  42. package/lib/cli/index.js +0 -114
  43. package/lib/cli/index.js.map +0 -1
  44. package/lib/cli/parseCli.d.ts +0 -3
  45. package/lib/cli/parseCli.js.map +0 -1
  46. package/lib/const.d.ts +0 -140
  47. package/lib/const.js.map +0 -1
  48. package/lib/extractors/css.d.ts +0 -2
  49. package/lib/extractors/css.js.map +0 -1
  50. package/lib/extractors/headers.d.ts +0 -5
  51. package/lib/extractors/headers.js.map +0 -1
  52. package/lib/extractors/index.d.ts +0 -2
  53. package/lib/extractors/index.js +0 -50
  54. package/lib/extractors/index.js.map +0 -1
  55. package/lib/extractors/json.d.ts +0 -10
  56. package/lib/extractors/json.js.map +0 -1
  57. package/lib/extractors/php.d.ts +0 -3
  58. package/lib/extractors/php.js.map +0 -1
  59. package/lib/extractors/schema.d.ts +0 -84
  60. package/lib/extractors/schema.js.map +0 -1
  61. package/lib/extractors/text.d.ts +0 -1
  62. package/lib/extractors/text.js.map +0 -1
  63. package/lib/extractors/utils.d.ts +0 -5
  64. package/lib/extractors/utils.js.map +0 -1
  65. package/lib/fs/glob.d.ts +0 -13
  66. package/lib/fs/glob.js.map +0 -1
  67. package/lib/fs/index.d.ts +0 -2
  68. package/lib/fs/index.js +0 -58
  69. package/lib/fs/index.js.map +0 -1
  70. package/lib/index.d.ts +0 -2
  71. package/lib/index.js.map +0 -1
  72. package/lib/parser/exec.d.ts +0 -2
  73. package/lib/parser/exec.js.map +0 -1
  74. package/lib/parser/index.d.ts +0 -2
  75. package/lib/parser/index.js +0 -30
  76. package/lib/parser/index.js.map +0 -1
  77. package/lib/parser/patterns.d.ts +0 -2
  78. package/lib/parser/patterns.js.map +0 -1
  79. package/lib/parser/process.d.ts +0 -4
  80. package/lib/parser/process.js.map +0 -1
  81. package/lib/parser/progress.d.ts +0 -3
  82. package/lib/parser/progress.js.map +0 -1
  83. package/lib/parser/taskRunner.d.ts +0 -4
  84. package/lib/parser/taskRunner.js.map +0 -1
  85. package/lib/parser/tree.d.ts +0 -2
  86. package/lib/parser/tree.js.map +0 -1
  87. package/lib/types.d.ts +0 -50
  88. package/lib/types.js.map +0 -1
  89. package/lib/utils/index.d.ts +0 -9
  90. package/lib/utils/index.js +0 -83
  91. package/lib/utils/index.js.map +0 -1
  92. package/tests/extract.test.ts +0 -382
  93. package/tests/getFiles.test.ts +0 -114
  94. package/tests/ignoreFunction.test.ts +0 -102
  95. package/tests/jsonParse.ts +0 -51
  96. package/tests/tree.test.ts +0 -151
package/biome.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
3
+ "organizeImports": {
4
+ "enabled": true
5
+ },
6
+ "linter": {
7
+ "enabled": true,
8
+ "rules": {
9
+ "recommended": true
10
+ }
11
+ }
12
+ }
@@ -0,0 +1 @@
1
+ "use strict";var l=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var s=(o,i)=>{for(var e in i)l(o,e,{get:i[e],enumerable:!0})},b=(o,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of c(i))!k.call(o,t)&&t!==e&&l(o,t,{get:()=>i[t],enumerable:!(r=a(i,t))||r.enumerable});return o};var d=o=>b(l({},"__esModule",{value:!0}),o);var y={};s(y,{default:()=>n});module.exports=d(y);var n={title:"block title",description:"block description",keywords:["block keyword"],styles:[{label:"block style label"}],variations:[{title:"block variation title",description:"block variation description",keywords:["block variation keyword"]}]};
@@ -0,0 +1 @@
1
+ "use strict";var u=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var t=Object.prototype.hasOwnProperty;var n=(e,r)=>{for(var s in r)u(e,s,{get:r[s],enumerable:!0})},b=(e,r,s,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of l(r))!t.call(e,i)&&i!==s&&u(e,i,{get:()=>r[i],enumerable:!(o=a(r,i))||o.enumerable});return e};var g=e=>b(u({},"__esModule",{value:!0}),e);var p={};n(p,{default:()=>m});module.exports=g(p);var m={name:"name",url:"url",description:"description",author:"author",authorEmail:"authorEmail",version:"version",bugs:"bugs","bugs.url":"bugsUrl","bugs.email":"bugsEmail",license:"license",repository:"repository"};
@@ -0,0 +1 @@
1
+ "use strict";var m=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(a,e)=>{for(var t in e)m(a,t,{get:e[t],enumerable:!0})},r=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!l.call(a,n)&&n!==t&&m(a,n,{get:()=>e[n],enumerable:!(i=o(e,n))||i.enumerable});return a};var c=a=>r(m({},"__esModule",{value:!0}),a);var z={};p(z,{default:()=>g});module.exports=c(z);var g={title:"Style variation name",settings:{typography:{fontSizes:[{name:"Font size name"}],fontFamilies:[{name:"Font family name"}]},color:{palette:[{name:"Color name"}],gradients:[{name:"Gradient name"}],duotone:[{name:"Duotone name"}]},spacing:{spacingSizes:[{name:"Space size name"}]},blocks:{"*":{typography:{fontSizes:[{name:"Font size name"}],fontFamilies:[{name:"Font family name"}]},color:{palette:[{name:"Color name"}],gradients:[{name:"Gradient name"}]},spacing:{spacingSizes:[{name:"Space size name"}]}}}},customTemplates:[{title:"Custom template name"}],templateParts:[{title:"Template part name"}]};
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var l=(i,e)=>{for(var t in e)a(i,t,{get:e[t],enumerable:!0})},U=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of u(e))!s.call(i,n)&&n!==t&&a(i,n,{get:()=>e[n],enumerable:!(o=r(e,n))||o.enumerable});return i};var g=i=>U(a({},"__esModule",{value:!0}),i);var h={};l(h,{default:()=>c});module.exports=g(h);var c={name:"Plugin Name",slug:"Plugin Slug",url:"Plugin URI",description:"Description",version:"Version",author:"Author",authorUri:"Author URI",tags:"Tags",license:"License",licenseUri:"License URI",updateUri:"Update URI",domainPath:"Domain Path",textDomain:"Text Domain"};
@@ -0,0 +1 @@
1
+ "use strict";var n=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var m=(i,e)=>{for(var a in e)n(i,a,{get:e[a],enumerable:!0})},c=(i,e,a,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of s(e))!h.call(i,t)&&t!==a&&n(i,t,{get:()=>e[t],enumerable:!(o=r(e,t))||o.enumerable});return i};var u=i=>c(n({},"__esModule",{value:!0}),i);var l={};m(l,{default:()=>U});module.exports=u(l);var U={name:"Theme Name",author:"Author",authorUri:"Author URI",description:"Description",url:"Theme URI",tags:"Tags",version:"Version",license:"License",licenseUri:"License URI",domainPath:"Domain Path",textDomain:"Text Domain"};
@@ -0,0 +1 @@
1
+ "use strict";var l=Object.create;var o=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var m=(e,i)=>{for(var t in i)o(e,t,{get:i[t],enumerable:!0})},n=(e,i,t,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of g(i))!y.call(e,s)&&s!==t&&o(e,s,{get:()=>i[s],enumerable:!(r=b(i,s))||r.enumerable});return e};var a=(e,i,t)=>(t=e!=null?l(u(e)):{},n(i||!e||!e.__esModule?o(t,"default",{value:e,enumerable:!0}):t,e)),f=e=>n(o({},"__esModule",{value:!0}),e);var S={};m(S,{getArgs:()=>h});module.exports=f(S);var p=a(require("node:process")),k=a(require("yargs")),c=require("yargs/helpers"),d=require("./parseCli.js");function h(e={}){const i=k.default((0,c.hideBin)(p.default.argv)).help("h").alias("help","help").usage("Usage: $0 <source> [destination] [options]").positional("sourceDirectory",{describe:"Source directory",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).options({slug:{describe:"Plugin or theme slug",type:"string"},domain:{describe:"Text domain to look for in the source code",type:"string"},"skip-js":{describe:"Skip JavaScript files",type:"boolean"},"skip-php":{describe:"Skip PHP files",type:"boolean"},"skip-blade":{describe:"Skip Blade files",type:"boolean"},"skip-block-json":{describe:"Skip block.json files",type:"boolean"},"skip-theme-json":{describe:"Skip theme.json files",type:"boolean"},"skip-audit":{describe:"Skip auditing of strings",type:"boolean"},headers:{describe:"Headers",type:"string"},"file-comment":{describe:"File comment",type:"string"},"package-name":{describe:"Package name",type:"string"},location:{describe:"Include location information",type:"boolean"},"ignore-domain":{describe:"Ignore text domain",type:"boolean"},mergePaths:{describe:"Merge with existing POT file(s)",type:"string"},subtractPaths:{describe:"Subtract strings from existing POT file(s)",type:"string"},subtractAndMerge:{describe:"Subtract and merge strings from existing POT file(s)",type:"boolean"},include:{describe:"Include specific files",type:"string"},exclude:{describe:"Exclude specific files",type:"string"},silent:{describe:"No output to stdout",type:"boolean"},json:{describe:"Output the json gettext data",type:"boolean"},output:{describe:"Output the gettext data",type:"boolean"}}).parseSync();return(0,d.parseCliArgs)({...e,...i})}0&&(module.exports={getArgs});
@@ -1,110 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.parseCliArgs = void 0;
27
- const utils_1 = require("../utils");
28
- const path = __importStar(require("path"));
29
- const process = __importStar(require("process"));
30
- const const_1 = require("../const");
31
- const node_fs_1 = __importStar(require("node:fs"));
32
- function isThemeOrPlugin(currentPath = '/', slug) {
33
- const currentWorkingDirectory = currentPath;
34
- try {
35
- (0, node_fs_1.accessSync)(path.join(currentWorkingDirectory, slug + '.php'), node_fs_1.default.constants.R_OK);
36
- return 'plugin';
37
- }
38
- catch (err) {
39
- console.log('the current working directory ' +
40
- currentWorkingDirectory +
41
- ' does not contain a ' +
42
- slug +
43
- '.php file');
44
- }
45
- try {
46
- (0, node_fs_1.accessSync)(path.join(currentWorkingDirectory, 'style.css'), node_fs_1.default.constants.R_OK);
47
- return 'theme';
48
- }
49
- catch (err) {
50
- console.log('the current working directory ' +
51
- currentWorkingDirectory +
52
- ' does not contain a style.css file');
53
- }
54
- if (currentWorkingDirectory.includes('wp-content' + path.sep + 'themes')) {
55
- return 'theme';
56
- }
57
- else if (currentWorkingDirectory.includes('wp-content' + path.sep + 'plugins')) {
58
- return 'plugin';
59
- }
60
- return 'generic';
61
- }
62
- function parseCliArgs(args) {
63
- const inputPath = typeof args._[0] === 'string' ? args._[0] : '.';
64
- const outputPath = typeof args._[1] === 'string' ? args._[1] : '.';
65
- const currentWorkingDirectory = process.cwd();
66
- const slug = args.slug && typeof args.slug === 'string'
67
- ? args.slug
68
- : path.basename(path.resolve(currentWorkingDirectory, inputPath));
69
- const cwd = path.relative(currentWorkingDirectory, inputPath);
70
- const out = path.relative(currentWorkingDirectory, outputPath);
71
- const domain = args?.domain ?? isThemeOrPlugin(path.resolve(cwd), slug);
72
- const parsedArgs = {
73
- slug: slug,
74
- domain: domain,
75
- paths: { cwd: cwd, out: out },
76
- options: {
77
- ignoreDomain: !!args?.ignoreDomain,
78
- packageName: String(args.packageName),
79
- silent: !!args.silent,
80
- json: !!args.json,
81
- location: !!args?.location,
82
- output: !!args?.output,
83
- fileComment: args.fileComment
84
- ? String(args.fileComment)
85
- : undefined,
86
- skip: {
87
- js: !!args.skipJs,
88
- php: !!args.skipPhp,
89
- blade: !!args.skipBlade,
90
- blockJson: !!args.skipBlockJson,
91
- themeJson: !!args.skipThemeJson,
92
- audit: !!args.skipAudit,
93
- },
94
- },
95
- headers: {
96
- fileComment: args.fileComment ?? '',
97
- },
98
- patterns: {
99
- mergePaths: (0, utils_1.stringstring)(args.mergePaths) ?? [],
100
- subtractPaths: (0, utils_1.stringstring)(args.subtractPaths) ?? [],
101
- subtractAndMerge: !!args.subtractAndMerge,
102
- include: (0, utils_1.stringstring)(args.include) ?? ['**'],
103
- exclude: (0, utils_1.stringstring)(args.exclude) ?? const_1.DEFAULT_EXCLUDED_PATH,
104
- },
105
- };
106
- parsedArgs.paths.root = args.root ? String(args.root) : undefined;
107
- return parsedArgs;
108
- }
109
- exports.parseCliArgs = parseCliArgs;
110
- //# sourceMappingURL=parseCli.js.map
1
+ "use strict";var y=Object.create;var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var P=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},a=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of k(e))!D.call(t,s)&&s!==n&&p(t,s,{get:()=>e[s],enumerable:!(i=g(e,s))||i.enumerable});return t};var u=(t,e,n)=>(n=t!=null?y(A(t)):{},a(e||!t||!t.__esModule?p(n,"default",{value:t,enumerable:!0}):n,t)),_=t=>a(p({},"__esModule",{value:!0}),t);var j={};P(j,{parseCliArgs:()=>T});module.exports=_(j);var r=u(require("node:fs")),o=u(require("node:path")),b=u(require("node:process")),d=require("../const.js"),c=require("../utils/common.js");function w(t="/",e="default"){const n=t;try{return(0,r.accessSync)(o.join(n,`${e}.php`),r.default.constants.R_OK),"plugin"}catch{console.log(`the current working directory ${n} does not contain a ${e}.php file`)}try{return(0,r.accessSync)(o.join(n,"style.css"),r.default.constants.R_OK),"theme"}catch{console.log(`the current working directory ${n} does not contain a style.css file`)}return n.includes(`wp-content${o.sep}themes`)?"theme":n.includes(`wp-content${o.sep}plugins`)?"plugin":"generic"}function T(t){const e=typeof t._[0]=="string"?t._[0]:".",n=typeof t._[1]=="string"?t._[1]:".",i=b.cwd(),s=t.slug&&typeof t.slug=="string"?t.slug:o.basename(o.resolve(i,e)),l=o.relative(i,e),f=o.relative(i,n),h=t?.domain??w(o.resolve(l),s),m={slug:s,domain:h,paths:{cwd:l,out:f},options:{ignoreDomain:!!t?.ignoreDomain,packageName:String(t.packageName),silent:!!t.silent,json:!!t.json,location:!!t?.location,output:!!t?.output,fileComment:t.fileComment?String(t.fileComment):void 0,skip:{js:!!t.skipJs,php:!!t.skipPhp,blade:!!t.skipBlade,blockJson:!!t.skipBlockJson,themeJson:!!t.skipThemeJson,audit:!!t.skipAudit}},patterns:{mergePaths:(0,c.stringstring)(t.mergePaths)??[],subtractPaths:(0,c.stringstring)(t.subtractPaths)??[],subtractAndMerge:!!t.subtractAndMerge,include:(0,c.stringstring)(t.include)??["**"],exclude:(0,c.stringstring)(t.exclude)??d.DEFAULT_EXCLUDED_PATH}};return m.paths.root=t.root?String(t.root):void 0,m}0&&(module.exports={parseCliArgs});
package/lib/const.js CHANGED
@@ -1,82 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.i18nFunctions = exports.allowedFiles = exports.DEFAULT_EXCLUDED_PATH = exports.themeHeaders = exports.pluginHeaders = exports.pkgJsonHeaders = exports.blockJson = exports.themeJson = exports.pkgJson = void 0;
27
- const blocki18n = __importStar(require("./assets/block-i18n.json"));
28
- const themei18n = __importStar(require("./assets/theme-i18n.json"));
29
- const packagei18n = __importStar(require("./assets/package-i18n.json"));
30
- const wpThemei18n = __importStar(require("./assets/wp-theme-i18n.json"));
31
- const wpPlugini18n = __importStar(require("./assets/wp-plugin-i18n.json"));
32
- const package_json_1 = require("../package.json");
33
- exports.pkgJson = {
34
- name: package_json_1.name,
35
- version: package_json_1.version,
36
- description: package_json_1.description,
37
- };
38
- exports.themeJson = themei18n;
39
- exports.blockJson = blocki18n;
40
- exports.pkgJsonHeaders = packagei18n;
41
- exports.pluginHeaders = wpPlugini18n;
42
- exports.themeHeaders = wpThemei18n;
43
- exports.DEFAULT_EXCLUDED_PATH = [
44
- '.git',
45
- 'node_modules',
46
- 'vendor',
47
- 'build',
48
- 'dist',
49
- 'uploads',
50
- 'Gruntfile.js',
51
- 'webpack.config.js',
52
- '**/*.min.js',
53
- 'tsconfig.js',
54
- '**.test.**',
55
- 'tests',
56
- ];
57
- exports.allowedFiles = ['php', 'js', 'jsx', 'ts', 'tsx', 'mjs', 'cjs'];
58
- exports.i18nFunctions = {
59
- __: ['msgid', 'text_domain'],
60
- esc_attr__: ['msgid', 'text_domain'],
61
- esc_html__: ['msgid', 'text_domain'],
62
- esc_xml__: ['msgid', 'text_domain'],
63
- _e: ['msgid', 'text_domain'],
64
- esc_attr_e: ['msgid', 'text_domain'],
65
- esc_html_e: ['msgid', 'text_domain'],
66
- esc_xml_e: ['msgid', 'text_domain'],
67
- _x: ['msgid', 'msgctxt', 'text_domain'],
68
- _ex: ['msgid', 'msgctxt', 'text_domain'],
69
- esc_attr_x: ['msgid', 'msgctxt', 'text_domain'],
70
- esc_html_x: ['msgid', 'msgctxt', 'text_domain'],
71
- esc_xml_x: ['msgid', 'msgctxt', 'text_domain'],
72
- _n: ['msgid', 'msgid_plural', 'number', 'text_domain'],
73
- _nx: ['msgid', 'msgid_plural', 'number', 'msgctxt', 'text_domain'],
74
- _n_noop: ['msgid', 'msgid_plural', 'text_domain'],
75
- _nx_noop: ['msgid', 'msgid_plural', 'msgctxt', 'text_domain'],
76
- _: ['msgid', 'text_domain'],
77
- _c: ['msgid', 'text_domain'],
78
- _nc: ['msgid', 'msgid_plural', 'number', 'text_domain'],
79
- __ngettext: ['msgid', 'msgid_plural', 'number', 'text_domain'],
80
- __ngettext_noop: ['msgid', 'msgid_plural', 'text_domain'],
81
- };
82
- //# sourceMappingURL=const.js.map
1
+ "use strict";var c=Object.create;var _=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var f=(t,m)=>{for(var s in m)_(t,s,{get:m[s],enumerable:!0})},n=(t,m,s,o)=>{if(m&&typeof m=="object"||typeof m=="function")for(let e of l(m))!b.call(t,e)&&e!==s&&_(t,e,{get:()=>m[e],enumerable:!(o=p(m,e))||o.enumerable});return t};var i=(t,m,s)=>(s=t!=null?c(u(t)):{},n(m||!t||!t.__esModule?_(s,"default",{value:t,enumerable:!0}):s,t)),h=t=>n(_({},"__esModule",{value:!0}),t);var T={};f(T,{DEFAULT_EXCLUDED_PATH:()=>E,allowedFiles:()=>F,blockJson:()=>k,i18nFunctions:()=>J,pkgJsonHeaders:()=>w,pluginHeaders:()=>H,themeHeaders:()=>D,themeJson:()=>j});module.exports=h(T);var d=i(require("./assets/block-i18n.js")),x=i(require("./assets/package-i18n.js")),g=i(require("./assets/theme-i18n.js")),a=i(require("./assets/wp-plugin-i18n.js")),r=i(require("./assets/wp-theme-i18n.js"));const j=g.default,k=d.default,w=x.default,H=a.default,D=r.default,E=[".git","node_modules","vendor","build","dist","uploads","Gruntfile.js","webpack.config.js","**/*.min.js","tsconfig.js","**.test.**","tests"],F=["php","js","jsx","ts","tsx","mjs","cjs"],J={__:["msgid","text_domain"],esc_attr__:["msgid","text_domain"],esc_html__:["msgid","text_domain"],esc_xml__:["msgid","text_domain"],_e:["msgid","text_domain"],esc_attr_e:["msgid","text_domain"],esc_html_e:["msgid","text_domain"],esc_xml_e:["msgid","text_domain"],_x:["msgid","msgctxt","text_domain"],_ex:["msgid","msgctxt","text_domain"],esc_attr_x:["msgid","msgctxt","text_domain"],esc_html_x:["msgid","msgctxt","text_domain"],esc_xml_x:["msgid","msgctxt","text_domain"],_n:["msgid","msgid_plural","number","text_domain"],_nx:["msgid","msgid_plural","number","msgctxt","text_domain"],_n_noop:["msgid","msgid_plural","text_domain"],_nx_noop:["msgid","msgid_plural","msgctxt","text_domain"],_:["msgid","text_domain"],_c:["msgid","text_domain"],_nc:["msgid","msgid_plural","number","text_domain"],__ngettext:["msgid","msgid_plural","number","text_domain"],__ngettext_noop:["msgid","msgid_plural","text_domain"]};0&&(module.exports={DEFAULT_EXCLUDED_PATH,allowedFiles,blockJson,i18nFunctions,pkgJsonHeaders,pluginHeaders,themeHeaders,themeJson});
@@ -1,42 +1 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.extractCssThemeData = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const utils_1 = require("../utils");
10
- const text_1 = require("./text");
11
- const const_1 = require("../const");
12
- const utils_2 = require("./utils");
13
- function extractCssThemeData(args) {
14
- let fileData = {};
15
- const styleCssFile = path_1.default.join(args.paths.cwd, 'style.css');
16
- if (fs_1.default.existsSync(styleCssFile)) {
17
- const fileContent = fs_1.default.readFileSync(styleCssFile, 'utf8');
18
- const commentBlock = (0, utils_1.getCommentBlock)(fileContent);
19
- fileData = (0, text_1.extractFileData)(commentBlock);
20
- if ('Theme Name' in fileData) {
21
- console.log('Theme stylesheet detected.');
22
- console.log(`Theme stylesheet: ${styleCssFile}`);
23
- args.domain = 'theme';
24
- const themeInfo = {};
25
- for (const keyValueMatch of Object.entries(fileData)) {
26
- if (keyValueMatch && keyValueMatch[0] && keyValueMatch[1]) {
27
- const header = (0, utils_2.getKeyByValue)(const_1.themeHeaders, keyValueMatch[0].trim());
28
- if (header === undefined)
29
- continue;
30
- themeInfo[header] = keyValueMatch[1].trim();
31
- }
32
- }
33
- return themeInfo;
34
- }
35
- }
36
- else {
37
- console.log(`Theme stylesheet not found in ${styleCssFile}`);
38
- }
39
- return {};
40
- }
41
- exports.extractCssThemeData = extractCssThemeData;
42
- //# sourceMappingURL=css.js.map
1
+ "use strict";var u=Object.create;var i=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},f=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of x(t))!j.call(e,s)&&s!==o&&i(e,s,{get:()=>t[s],enumerable:!(r=T(t,s))||r.enumerable});return e};var a=(e,t,o)=>(o=e!=null?u(C(e)):{},f(t||!e||!e.__esModule?i(o,"default",{value:e,enumerable:!0}):o,e)),B=e=>f(i({},"__esModule",{value:!0}),e);var F={};k(F,{extractCssThemeData:()=>D});module.exports=B(F);var m=a(require("node:fs")),h=a(require("node:path")),d=require("../const.js"),p=require("../utils/common.js"),y=require("./text.js"),g=require("./utils.js");function D(e){let t={};const o=h.default.join(e.paths.cwd,"style.css");if(m.default.existsSync(o)){const r=m.default.readFileSync(o,"utf8"),s=(0,p.getCommentBlock)(r);if(t=(0,y.extractFileData)(s),"Theme Name"in t){console.log("Theme stylesheet detected."),console.log(`Theme stylesheet: ${o}`),e.domain="theme";const c={};for(const n of Object.entries(t))if(n&&n[0]&&n[1]){const l=(0,g.getKeyByValue)(d.themeHeaders,n[0].trim());if(l===void 0)continue;c[l]=n[1].trim()}return c}}else console.log(`Theme stylesheet not found in ${o}`);return{}}0&&(module.exports={extractCssThemeData});
@@ -1,73 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.translationsHeaders = exports.extractMainFileData = exports.generateHeader = void 0;
4
- const php_1 = require("./php");
5
- const css_1 = require("./css");
6
- const utils_1 = require("./utils");
7
- const const_1 = require("../const");
8
- const gettext_merger_1 = require("gettext-merger");
9
- function generateHeader(args) {
10
- const headerData = {
11
- ...args.headers,
12
- author: args.headers?.author || 'AUTHOR',
13
- slug: args.slug || 'PLUGIN NAME',
14
- email: args.headers?.email || 'EMAIL',
15
- license: args.headers?.license || 'gpl-2.0 or later',
16
- version: args.headers?.version || '1.0.0',
17
- language: args.headers?.language || 'en',
18
- domain: args.headers?.textDomain || args.headers?.slug || undefined,
19
- bugs: {
20
- url: args.headers?.bugsUrl ||
21
- 'https://wordpress.org/support/plugin/' + args.slug,
22
- email: args.headers?.bugsEmail ||
23
- args.headers?.authoremail ||
24
- 'AUTHOR EMAIL',
25
- },
26
- };
27
- const authorString = `${headerData.author} <${headerData.email}>`;
28
- const domain = headerData.domain ? `X-Domain: ${headerData.domain}` : '';
29
- return {
30
- 'Project-Id-Version': `${headerData.slug} ${headerData.version}`,
31
- 'Report-Msgid-Bugs-To': authorString,
32
- 'MIME-Version': `1.0`,
33
- 'Content-Transfer-Encoding': `8bit`,
34
- 'content-type': 'text/plain; charset=iso-8859-1',
35
- 'plural-forms': 'nplurals=2; plural=(n!=1);',
36
- 'POT-Creation-Date': `${new Date().toISOString()}`,
37
- 'PO-Revision-Date': `${new Date().getFullYear()}-MO-DA HO:MI+ZONE`,
38
- 'Last-Translator': authorString,
39
- 'Language-Team': authorString,
40
- 'X-Generator': `${const_1.pkgJson.name} ${const_1.pkgJson.version}`,
41
- Language: `${headerData.language}`,
42
- domain,
43
- };
44
- }
45
- exports.generateHeader = generateHeader;
46
- function extractMainFileData(args) {
47
- let extractedData = {};
48
- if (['plugin', 'block', 'generic'].includes(args.domain)) {
49
- extractedData = (0, php_1.extractPhpPluginData)(args);
50
- }
51
- else if (['theme', 'theme-block'].includes(args.domain)) {
52
- extractedData = (0, css_1.extractCssThemeData)(args);
53
- }
54
- else {
55
- console.log('No main file detected.');
56
- }
57
- return extractedData;
58
- }
59
- exports.extractMainFileData = extractMainFileData;
60
- function translationsHeaders(args) {
61
- const { domain, headers } = args;
62
- const { name, description, author, authorUri, url } = headers;
63
- const fakePath = domain === 'plugin' ? args.slug + '.php' : 'style.css';
64
- return new gettext_merger_1.SetOfBlocks([
65
- (0, utils_1.gentranslation)(`Name of the ${domain}`, name, fakePath),
66
- (0, utils_1.gentranslation)(`Url of the ${domain}`, url, fakePath),
67
- (0, utils_1.gentranslation)(`Description of the ${domain}`, description, fakePath),
68
- (0, utils_1.gentranslation)(`Author of the ${domain}`, author, fakePath),
69
- (0, utils_1.gentranslation)(`Author URI of the ${domain}`, authorUri, fakePath),
70
- ]);
71
- }
72
- exports.translationsHeaders = translationsHeaders;
73
- //# sourceMappingURL=headers.js.map
1
+ "use strict";var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var A=(e,t)=>{for(var o in t)c(e,o,{get:t[o],enumerable:!0})},P=(e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of D(t))!$.call(e,n)&&n!==o&&c(e,n,{get:()=>t[n],enumerable:!(a=f(t,n))||a.enumerable});return e};var O=e=>P(c({},"__esModule",{value:!0}),e);var k={};A(k,{extractMainFileData:()=>I,generateHeader:()=>x,translationsHeaders:()=>M});module.exports=O(k);var d=require("gettext-merger"),g=require("../utils/common"),h=require("./css.js"),p=require("./php.js"),s=require("./utils.js");function x(e){const{author:t,textDomain:o}=e.headers,{name:a,version:n}=(0,g.getPkgJsonData)("name","version"),i="EMAIL",u="en",l=`${t} <${i}>`,r=o?`X-Domain: ${o}`:"",H={url:"https://wordpress.org/support/plugin/"+e.slug,email:i||"AUTHOR EMAIL"},m={...e.headers,author:e.headers?.author||"AUTHOR",slug:e.slug||"PLUGIN NAME",email:i,license:e.headers?.license||"gpl-2.0 or later",version:e.headers?.version||"1.0.0",language:u,domain:e.headers?.textDomain||e.headers?.slug||"PLUGIN DOMAIN"};return{"Project-Id-Version":`${m.slug} ${m.version}`,"Report-Msgid-Bugs-To":l,"MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=iso-8859-1","plural-forms":"nplurals=2; plural=(n!=1);","POT-Creation-Date":`${new Date().toISOString()}`,"PO-Revision-Date":`${new Date().getFullYear()}-MO-DA HO:MI+ZONE`,"Last-Translator":l,"Language-Team":l,"X-Generator":`${a} ${n}`,Language:`${u}`,domain:r}}function I(e){let t={};return["plugin","block","generic"].includes(e.domain)?t=(0,p.extractPhpPluginData)(e):["theme","theme-block"].includes(e.domain)?t=(0,h.extractCssThemeData)(e):console.log("No main file detected."),t}function M(e){const{domain:t,headers:o}=e,{name:a,description:n,author:i,authorUri:u,url:l}=o,r=t==="plugin"?`${e.slug}.php`:"style.css";return new d.SetOfBlocks([(0,s.gentranslation)(`Name of the ${t}`,a,r),(0,s.gentranslation)(`Url of the ${t}`,l,r),(0,s.gentranslation)(`Description of the ${t}`,n,r),(0,s.gentranslation)(`Author of the ${t}`,i,r),(0,s.gentranslation)(`Author URI of the ${t}`,u,r)])}0&&(module.exports={extractMainFileData,generateHeader,translationsHeaders});
@@ -1,69 +1 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseJsonCallback = exports.extractPackageJson = exports.getJsonComment = exports.parseJsonFile = void 0;
7
- const const_1 = require("../const");
8
- const schema_1 = require("./schema");
9
- const path_1 = __importDefault(require("path"));
10
- const fs_1 = __importDefault(require("fs"));
11
- const utils_1 = require("./utils");
12
- async function parseJsonFile(opts) {
13
- const jsonTranslations = await schema_1.JsonSchemaExtractor.fromString(opts.fileContent, {
14
- file: opts.filename,
15
- schema: opts.filename === 'theme.json'
16
- ? schema_1.JsonSchemaExtractor.themeJsonSource
17
- : schema_1.JsonSchemaExtractor.blockJsonSource,
18
- schemaFallback: opts.filename === 'theme.json'
19
- ? schema_1.JsonSchemaExtractor.themeJsonFallback
20
- : schema_1.JsonSchemaExtractor.blockJsonFallback,
21
- addReferences: true,
22
- });
23
- return jsonTranslations ?? {};
24
- }
25
- exports.parseJsonFile = parseJsonFile;
26
- function getSchema(type) {
27
- switch (type) {
28
- case 'block.json':
29
- return const_1.blockJson;
30
- case 'theme.json':
31
- return const_1.themeJson;
32
- default:
33
- return {};
34
- }
35
- }
36
- function getJsonComment(key, type) {
37
- const comments = getSchema(type);
38
- return key in Object.values(comments)
39
- ? comments[key]
40
- : key;
41
- }
42
- exports.getJsonComment = getJsonComment;
43
- function extractPackageJson(args) {
44
- const fields = const_1.pkgJsonHeaders;
45
- const pkgJsonMeta = {};
46
- const packageJsonPath = args.paths.cwd
47
- ? path_1.default.join(args.paths.cwd, 'package.json')
48
- : 'package.json';
49
- if (fs_1.default.existsSync(packageJsonPath)) {
50
- const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
51
- for (const field of Object.keys(fields)) {
52
- if (field in packageJson) {
53
- pkgJsonMeta[field] = packageJson[field];
54
- }
55
- }
56
- }
57
- return pkgJsonMeta;
58
- }
59
- exports.extractPackageJson = extractPackageJson;
60
- async function parseJsonCallback(fileContent, filePath, filename) {
61
- const data = await parseJsonFile({
62
- fileContent: fileContent,
63
- filename: filename,
64
- filepath: filePath,
65
- });
66
- return (0, utils_1.yieldParsedData)(data, filename, path_1.default.join(filePath, filename));
67
- }
68
- exports.parseJsonCallback = parseJsonCallback;
69
- //# sourceMappingURL=json.js.map
1
+ "use strict";var k=Object.create;var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var b=(e,n)=>{for(var t in n)c(e,t,{get:n[t],enumerable:!0})},l=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of j(n))!d.call(e,o)&&o!==t&&c(e,o,{get:()=>n[o],enumerable:!(s=u(n,o))||s.enumerable});return e};var g=(e,n,t)=>(t=e!=null?k(J(e)):{},l(n||!e||!e.__esModule?c(t,"default",{value:e,enumerable:!0}):t,e)),S=e=>l(c({},"__esModule",{value:!0}),e);var F={};b(F,{extractPackageJson:()=>w,getJsonComment:()=>x,parseJsonCallback:()=>C,parseJsonFile:()=>h});module.exports=S(F);var m=g(require("node:fs")),f=g(require("node:path")),a=require("../const.js"),r=require("./schema.js"),p=require("./utils.js");async function h(e){return await r.JsonSchemaExtractor.fromString(e.fileContent,{file:e.filename,schema:e.filename==="theme.json"?r.JsonSchemaExtractor.themeJsonSource:r.JsonSchemaExtractor.blockJsonSource,schemaFallback:e.filename==="theme.json"?r.JsonSchemaExtractor.themeJsonFallback:r.JsonSchemaExtractor.blockJsonFallback,addReferences:!0})??{}}function y(e){switch(e){case"block.json":return a.blockJson;case"theme.json":return a.themeJson;default:return{}}}function x(e,n){const t=y(n);return e in Object.values(t)?t[e]:e}function w(e){const n=a.pkgJsonHeaders,t={},s=e.paths.cwd?f.default.join(e.paths.cwd,"package.json"):"package.json";if(m.default.existsSync(s)){const o=JSON.parse(m.default.readFileSync(s,"utf8"));for(const i of Object.keys(n))i in o&&(t[i]=o[i])}return t}async function C(e,n,t){const s=await h({fileContent:e,filename:t,filepath:n});return(0,p.yieldParsedData)(s,t,f.default.join(n,t))}0&&(module.exports={extractPackageJson,getJsonComment,parseJsonCallback,parseJsonFile});
@@ -1,49 +1,2 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parsePHPFile = exports.extractPhpPluginData = void 0;
7
- const const_1 = require("../const");
8
- const utils_1 = require("./utils");
9
- const path_1 = __importDefault(require("path"));
10
- const fs_1 = __importDefault(require("fs"));
11
- function extractPhpPluginData(args) {
12
- let fileData = {};
13
- const folderPhpFile = path_1.default.join(args.paths.cwd, `${args.slug}.php`);
14
- if (fs_1.default.existsSync(folderPhpFile)) {
15
- const fileContent = fs_1.default.readFileSync(folderPhpFile, 'utf8');
16
- fileData = parsePHPFile(fileContent);
17
- console.log('Plugin file detected.');
18
- console.log(`Plugin file: ${folderPhpFile}`);
19
- args.domain = 'plugin';
20
- return fileData;
21
- }
22
- else {
23
- console.log('Plugin file not found.');
24
- console.log(`Missing Plugin filename: ${folderPhpFile}`);
25
- }
26
- return {};
27
- }
28
- exports.extractPhpPluginData = extractPhpPluginData;
29
- function parsePHPFile(phpContent) {
30
- const match = phpContent.match(/\/\*\*([\s\S]*?)\*\//);
31
- if (match && match[1]) {
32
- const commentBlock = match[1];
33
- const lines = commentBlock.split('\n');
34
- const pluginInfo = {};
35
- for (const line of lines) {
36
- const keyValueMatch = line.match(/^\s*\*\s*([^:]+):\s*(.*)/);
37
- if (keyValueMatch && keyValueMatch[1] && keyValueMatch[2]) {
38
- const header = (0, utils_1.getKeyByValue)(const_1.pluginHeaders, keyValueMatch[1].trim());
39
- if (header === undefined)
40
- continue;
41
- pluginInfo[header] = keyValueMatch[2].trim();
42
- }
43
- }
44
- return pluginInfo;
45
- }
46
- return {};
47
- }
48
- exports.parsePHPFile = parsePHPFile;
49
- //# sourceMappingURL=php.js.map
1
+ "use strict";var h=Object.create;var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var k=(n,t)=>{for(var e in t)s(n,e,{get:t[e],enumerable:!0})},f=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of y(t))!R.call(n,o)&&o!==e&&s(n,o,{get:()=>t[o],enumerable:!(i=P(t,o))||i.enumerable});return n};var g=(n,t,e)=>(e=n!=null?h(x(n)):{},f(t||!n||!n.__esModule?s(e,"default",{value:n,enumerable:!0}):e,n)),B=n=>f(s({},"__esModule",{value:!0}),n);var S={};k(S,{extractPhpPluginData:()=>F,parsePHPFile:()=>a});module.exports=B(S);var l=g(require("node:fs")),m=g(require("node:path")),u=require("../const.js"),p=require("./utils.js");function F(n){let t={};const e=m.default.join(n.paths.cwd,`${n.slug}.php`);if(l.default.existsSync(e)){const i=l.default.readFileSync(e,"utf8");return t=a(i),console.log("Plugin file detected."),console.log(`Plugin file: ${e}`),n.domain="plugin",t}else console.log("Plugin file not found."),console.log(`Missing Plugin filename: ${e}`);return{}}function a(n){const t=n.match(/\/\*\*([\s\S]*?)\*\//);if(t&&t[1]){const i=t[1].split(`
2
+ `),o={};for(const d of i){const r=d.match(/^\s*\*\s*([^:]+):\s*(.*)/);if(r&&r[1]&&r[2]){const c=(0,p.getKeyByValue)(u.pluginHeaders,r[1].trim());if(c===void 0)continue;o[c]=r[2].trim()}}return o}return{}}0&&(module.exports={extractPhpPluginData,parsePHPFile});
@@ -1,100 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.JsonSchemaExtractor = void 0;
30
- const axios_1 = __importDefault(require("axios"));
31
- const themei18n = __importStar(require("../assets/theme-i18n.json"));
32
- const blocki18n = __importStar(require("../assets/block-i18n.json"));
33
- class JsonSchemaExtractor {
34
- static async loadSchema(url, fallback) {
35
- if (this.schemaCache.url) {
36
- return this.schemaCache.url;
37
- }
38
- try {
39
- const response = await axios_1.default.get(url);
40
- this.schemaCache.url = response.data;
41
- return response.data;
42
- }
43
- catch (error) {
44
- console.error(`Failed to load schema from ${url}. Using fallback.`);
45
- const fallbackData = fallback;
46
- this.schemaCache.url = fallbackData;
47
- return fallbackData;
48
- }
49
- }
50
- static async fromString(text, options) {
51
- const schema = await this.loadSchema(options.schema, options.schemaFallback);
52
- if (!schema) {
53
- console.error('Failed to load schema.');
54
- return;
55
- }
56
- const json = JSON.parse(text);
57
- if (json === null) {
58
- console.error(`Could not parse JSON.`);
59
- return;
60
- }
61
- return this.extractStringsUsingI18nSchema(schema, json);
62
- }
63
- static extractStringsUsingI18nSchema(i18nSchema, settings) {
64
- if (!i18nSchema || !settings) {
65
- return {};
66
- }
67
- if (Array.isArray(i18nSchema) && typeof settings === 'object') {
68
- const result = {};
69
- for (const value in settings) {
70
- const extracted = this.extractStringsUsingI18nSchema(i18nSchema[value], value);
71
- Object.assign(result, extracted);
72
- }
73
- return result;
74
- }
75
- if (typeof i18nSchema === 'object' && typeof settings === 'object') {
76
- const groupKey = '*';
77
- const result = {};
78
- for (const [key, value] of Object.entries(settings)) {
79
- if (i18nSchema[key]) {
80
- result[key] = i18nSchema[key];
81
- }
82
- else if (Object.prototype.hasOwnProperty.call(i18nSchema, groupKey)) {
83
- const extracted = this.extractStringsUsingI18nSchema(i18nSchema[groupKey], value);
84
- if (extracted) {
85
- Object.assign(result, extracted);
86
- }
87
- }
88
- }
89
- return result;
90
- }
91
- return {};
92
- }
93
- }
94
- exports.JsonSchemaExtractor = JsonSchemaExtractor;
95
- JsonSchemaExtractor.schemaCache = {};
96
- JsonSchemaExtractor.themeJsonSource = 'http://develop.svn.wordpress.org/trunk/src/wp-includes/theme-i18n.json';
97
- JsonSchemaExtractor.themeJsonFallback = themei18n;
98
- JsonSchemaExtractor.blockJsonSource = 'http://develop.svn.wordpress.org/trunk/src/wp-includes/block-i18n.json';
99
- JsonSchemaExtractor.blockJsonFallback = blocki18n;
100
- //# sourceMappingURL=schema.js.map
1
+ "use strict";var u=Object.create;var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var b=(a,t)=>{for(var e in t)n(a,e,{get:t[e],enumerable:!0})},h=(a,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!d.call(a,r)&&r!==e&&n(a,r,{get:()=>t[r],enumerable:!(s=p(t,r))||s.enumerable});return a};var o=(a,t,e)=>(e=a!=null?u(S(a)):{},h(t||!a||!a.__esModule?n(e,"default",{value:a,enumerable:!0}):e,a)),g=a=>h(n({},"__esModule",{value:!0}),a);var j={};b(j,{JsonSchemaExtractor:()=>y});module.exports=g(j);var l=o(require("axios")),I=o(require("../assets/block-i18n.js")),k=o(require("../assets/theme-i18n.js"));class y{static schemaCache={};static themeJsonSource="http://develop.svn.wordpress.org/trunk/src/wp-includes/theme-i18n.json";static themeJsonFallback=k;static blockJsonSource="http://develop.svn.wordpress.org/trunk/src/wp-includes/block-i18n.json";static blockJsonFallback=I;static async loadSchema(t,e){if(this.schemaCache.url)return this.schemaCache.url;try{const s=await l.default.get(t);return this.schemaCache.url=s.data,s.data}catch{console.error(`Failed to load schema from ${t}. Using fallback.`);const r=e;return this.schemaCache.url=r,r}}static async fromString(t,e){const s=await this.loadSchema(e.schema,e.schemaFallback);if(!s){console.error("Failed to load schema.");return}const r=JSON.parse(t);if(r===null){console.error("Could not parse JSON.");return}return this.extractStringsUsingI18nSchema(s,r)}static extractStringsUsingI18nSchema(t,e){if(!t||!e)return{};if(Array.isArray(t)&&typeof e=="object"){const s={};for(const r in e){const c=this.extractStringsUsingI18nSchema(t[r],r);Object.assign(s,c)}return s}if(typeof t=="object"&&typeof e=="object"){const s="*",r={};for(const[c,m]of Object.entries(e))if(t[c])r[c]=t[c];else if(Object.prototype.hasOwnProperty.call(t,s)){const i=this.extractStringsUsingI18nSchema(t[s],m);i&&Object.assign(r,i)}return r}return{}}}0&&(module.exports={JsonSchemaExtractor});
@@ -1,18 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractFileData = void 0;
4
- const utils_1 = require("../utils");
5
- function extractFileData(fileContent, separator = ':') {
6
- const data = {};
7
- (0, utils_1.removeCommentMarkup)(fileContent)
8
- ?.forEach((line) => {
9
- const parts = line.split(separator);
10
- if (parts.length !== 2 && Object.values(data).length > 0) {
11
- return;
12
- }
13
- data[parts[0]?.trim()] = parts[1]?.trim();
14
- });
15
- return data;
16
- }
17
- exports.extractFileData = extractFileData;
18
- //# sourceMappingURL=text.js.map
1
+ "use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var m=(r,t)=>{for(var n in t)o(r,n,{get:t[n],enumerable:!0})},l=(r,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of c(t))!g.call(r,e)&&e!==n&&o(r,e,{get:()=>t[e],enumerable:!(i=a(t,e))||i.enumerable});return r};var p=r=>l(o({},"__esModule",{value:!0}),r);var f={};m(f,{extractFileData:()=>u});module.exports=p(f);var s=require("../utils/common.js");function u(r,t=":"){const n={};return(0,s.removeCommentMarkup)(r)?.forEach(i=>{const e=i.split(t);e.length!==2&&Object.values(n).length>0||(n[e[0]?.trim()]=e[1]?.trim())}),n}0&&(module.exports={extractFileData});