@terai/dev 0.0.8 → 0.0.10

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 (61) hide show
  1. package/dist/cli.default.js +20906 -24
  2. package/dist/cli.default.js.map +1 -1
  3. package/dist/cli.default.mjs +20923 -20
  4. package/dist/cli.default.mjs.map +1 -1
  5. package/dist/cli.js +20900 -13
  6. package/dist/cli.js.map +1 -1
  7. package/dist/cli.mjs +20913 -9
  8. package/dist/cli.mjs.map +1 -1
  9. package/dist/commands/extract.js +687 -12
  10. package/dist/commands/extract.js.map +1 -1
  11. package/dist/commands/extract.mjs +661 -5
  12. package/dist/commands/extract.mjs.map +1 -1
  13. package/dist/commands/index.js +997 -31
  14. package/dist/commands/index.js.map +1 -1
  15. package/dist/commands/index.mjs +965 -8
  16. package/dist/commands/index.mjs.map +1 -1
  17. package/dist/commands/init.js +778 -12
  18. package/dist/commands/init.js.map +1 -1
  19. package/dist/commands/init.mjs +747 -4
  20. package/dist/commands/init.mjs.map +1 -1
  21. package/dist/commands/translate.js +724 -12
  22. package/dist/commands/translate.js.map +1 -1
  23. package/dist/commands/translate.mjs +692 -5
  24. package/dist/commands/translate.mjs.map +1 -1
  25. package/dist/index.js +34 -22
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +10 -8
  28. package/dist/index.mjs.map +1 -1
  29. package/package.json +8 -8
  30. package/dist/chunk-27YGPZZO.mjs +0 -30
  31. package/dist/chunk-27YGPZZO.mjs.map +0 -1
  32. package/dist/chunk-3ELQZT5F.js +0 -17773
  33. package/dist/chunk-3ELQZT5F.js.map +0 -1
  34. package/dist/chunk-42NIF5EX.js +0 -8
  35. package/dist/chunk-42NIF5EX.js.map +0 -1
  36. package/dist/chunk-6YEMZ7V4.mjs +0 -120
  37. package/dist/chunk-6YEMZ7V4.mjs.map +0 -1
  38. package/dist/chunk-73E3KEZD.js +0 -199
  39. package/dist/chunk-73E3KEZD.js.map +0 -1
  40. package/dist/chunk-7KUNFJIY.mjs +0 -563
  41. package/dist/chunk-7KUNFJIY.mjs.map +0 -1
  42. package/dist/chunk-K2FH2SX6.mjs +0 -17755
  43. package/dist/chunk-K2FH2SX6.mjs.map +0 -1
  44. package/dist/chunk-KYDPPJQL.js +0 -86
  45. package/dist/chunk-KYDPPJQL.js.map +0 -1
  46. package/dist/chunk-LIRTPATK.js +0 -52
  47. package/dist/chunk-LIRTPATK.js.map +0 -1
  48. package/dist/chunk-M6WICIYM.js +0 -571
  49. package/dist/chunk-M6WICIYM.js.map +0 -1
  50. package/dist/chunk-OF7BELAL.js +0 -32
  51. package/dist/chunk-OF7BELAL.js.map +0 -1
  52. package/dist/chunk-QC3QM3MM.mjs +0 -192
  53. package/dist/chunk-QC3QM3MM.mjs.map +0 -1
  54. package/dist/chunk-RKCAHME2.mjs +0 -6
  55. package/dist/chunk-RKCAHME2.mjs.map +0 -1
  56. package/dist/chunk-RWH4GVGM.mjs +0 -83
  57. package/dist/chunk-RWH4GVGM.mjs.map +0 -1
  58. package/dist/chunk-SSJE2GTB.js +0 -123
  59. package/dist/chunk-SSJE2GTB.js.map +0 -1
  60. package/dist/chunk-UOKEQCV3.mjs +0 -50
  61. package/dist/chunk-UOKEQCV3.mjs.map +0 -1
@@ -1,86 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkOF7BELAL_js = require('./chunk-OF7BELAL.js');
4
- var chunkM6WICIYM_js = require('./chunk-M6WICIYM.js');
5
- var chunkLIRTPATK_js = require('./chunk-LIRTPATK.js');
6
- var perfectDebounce = require('perfect-debounce');
7
- var extractor = require('@terai/extractor');
8
- var runtime = require('@terai/runtime');
9
- var utils = require('@terai/utils');
10
-
11
- // src/commands/extract.ts
12
- chunkLIRTPATK_js.init_cjs_shims();
13
- function createExtractCommand(cli, cwd) {
14
- return cli.command("extract", "Statically extract messages from your project").option("-w, --watch", "Watch files and rebuild").option("--cwd <cwd>", "Current working directory", { default: cwd }).action(extractCmd);
15
- }
16
- async function extractCmd(options) {
17
- chunkM6WICIYM_js.logger.heading("extract", "Statically extract messages from your project");
18
- const done = chunkM6WICIYM_js.logger.time.success();
19
- const config = await runtime.loadConfig(options);
20
- const filesPaths = runtime.runtime.fs.glob({
21
- ...config,
22
- cwd: options.cwd
23
- });
24
- const outDirPath = runtime.runtime.path.resolve(options.cwd, config.outDir);
25
- const projectLocalePath = runtime.runtime.path.resolve(
26
- outDirPath,
27
- config.projectLocale
28
- );
29
- const manifestPath = runtime.runtime.path.resolve(
30
- outDirPath,
31
- ".terai",
32
- "locale-manifest.json"
33
- );
34
- chunkM6WICIYM_js.logger.info("Scan:", "Processing files...");
35
- async function extractor$1(files = filesPaths) {
36
- const extractedMessages = await extractor.extract({
37
- ...config,
38
- filesPaths: files,
39
- cwd: options.cwd
40
- });
41
- const dictionary = utils.convertExtractedMessagesToDictionary(extractedMessages);
42
- const manifest = {
43
- messages: extractedMessages
44
- };
45
- const dictionaries = utils.groupDictionaryByChunks(
46
- dictionary,
47
- manifest,
48
- config.projectLocale
49
- );
50
- runtime.runtime.fs.remove(runtime.runtime.path.resolve(projectLocalePath));
51
- await chunkOF7BELAL_js.generate({
52
- ...config,
53
- dictionaries,
54
- locale: config.projectLocale,
55
- cwd: options.cwd
56
- });
57
- runtime.runtime.fs.write(manifestPath, utils.stringify(manifest));
58
- return Object.keys(dictionary).length;
59
- }
60
- chunkM6WICIYM_js.logger.info("Extraction:", "Extracting messages...");
61
- const msgCount = await extractor$1();
62
- done(`Extracted ${msgCount} messages`);
63
- if (options.watch) {
64
- chunkM6WICIYM_js.logger.log("");
65
- chunkM6WICIYM_js.logger.info("Watch:", "Watching files for changes...\n");
66
- const configWatcher = runtime.runtime.fs.watch({
67
- ...config,
68
- ...options
69
- });
70
- configWatcher.on(
71
- "change",
72
- perfectDebounce.debounce(async () => {
73
- const done2 = chunkM6WICIYM_js.logger.time.success();
74
- chunkM6WICIYM_js.logger.info("Extraction:", "Files changed, processing messages...");
75
- const msgCount2 = await extractor$1();
76
- done2(`Extracted ${msgCount2} messages`);
77
- chunkM6WICIYM_js.logger.log("");
78
- })
79
- );
80
- }
81
- }
82
-
83
- exports.createExtractCommand = createExtractCommand;
84
- exports.extractCmd = extractCmd;
85
- //# sourceMappingURL=chunk-KYDPPJQL.js.map
86
- //# sourceMappingURL=chunk-KYDPPJQL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/extract.ts"],"names":["init_cjs_shims","logger","loadConfig","runtime","extractor","extract","convertExtractedMessagesToDictionary","groupDictionaryByChunks","generate","stringify","debounce","done","msgCount"],"mappings":";;;;;;;;;;;AAAAA,+BAAA,EAAA;AAsBO,SAAS,oBAAA,CAAqB,KAAU,GAAA,EAAa;AAC3D,EAAA,OAAO,IACL,OAAA,CAAQ,SAAA,EAAW,+CAA+C,CAAA,CAClE,MAAA,CAAO,eAAe,yBAAyB,CAAA,CAC/C,MAAA,CAAO,aAAA,EAAe,6BAA6B,EAAE,OAAA,EAAS,KAAK,CAAA,CACnE,OAAO,UAAU,CAAA;AACpB;AAEA,eAAsB,WAAW,OAAA,EAAyB;AACzD,EAAAC,uBAAA,CAAO,OAAA,CAAQ,WAAW,+CAA+C,CAAA;AAEzE,EAAA,MAAM,IAAA,GAAOA,uBAAA,CAAO,IAAA,CAAK,OAAA,EAAQ;AAEjC,EAAA,MAAM,MAAA,GAAS,MAAMC,kBAAA,CAAW,OAAO,CAAA;AACvC,EAAA,MAAM,UAAA,GAAaC,eAAA,CAAQ,EAAA,CAAG,IAAA,CAAK;AAAA,IAClC,GAAG,MAAA;AAAA,IACH,KAAK,OAAA,CAAQ;AAAA,GACb,CAAA;AAED,EAAA,MAAM,aAAaA,eAAA,CAAQ,IAAA,CAAK,QAAQ,OAAA,CAAQ,GAAA,EAAK,OAAO,MAAM,CAAA;AAClE,EAAA,MAAM,iBAAA,GAAoBA,gBAAQ,IAAA,CAAK,OAAA;AAAA,IACtC,UAAA;AAAA,IACA,MAAA,CAAO;AAAA,GACR;AACA,EAAA,MAA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AQ,KAAA,EAAO;AAClB,IAAAH,uBAAA,CAAO,IAAI,EAAE,CAAA;AACb,IAAAA,uBAAA,CAAO,IAAA,CAAK,UAAU,iCAAiC,CAAA;AACvD,IAAA,MAAM,aAAA,GAAgBE,eAAA,CAAQ,EAAA,CAAG,KAAA,CAAM;AAAA,MACtC,GAAG,MAAA;AAAA,MACH,GAAG;AAAA,KACH,CAAA;AAED,IAAA,aAAA,CAAc,EAAA;AAAA,MACb,QAAA;AAAA,MACAO,yBAAS,YAAY;AACpB,QAAA,MAAMC,KAAAA,GAAOV,uBAAA,CAAO,IAAA,CAAK,OAAA,EAAQ;AACjC,QAAAA,uBAAA,CAAO,IAAA,CAAK,eAAe,uCAAuC,CAAA;AAElE,QAAA,MAAMW,SAAAA,GAAW,MAAMR,WAAA,EAAU;AAEjC,QAAAO,KAAAA,CAAK,CAAA,UAAA,EAAaC,SAAQ,CAAA,SAAA,CAAW,CAAA;AACrC,QAAAX,uBAAA,CAAO,IAAI,EAAE,CAAA;AAAA,MACd,CAAC;AAAA,KACF;AAAA,EACD;AACD","file":"chunk-KYDPPJQL.js","sourcesContent":["// Dependencies\nimport { debounce } from 'perfect-debounce'\nimport { extract } from '@terai/extractor'\nimport { generate } from '@terai/generator'\nimport { loadConfig, runtime } from '@terai/runtime'\nimport { logger } from '@terai/logger'\nimport {\n\tconvertExtractedMessagesToDictionary,\n\tstringify,\n\tgroupDictionaryByChunks\n} from '@terai/utils'\n\n// Types\nimport type { CAC } from 'cac'\nimport type { BuildManifest } from '@terai/types'\n\nexport type ExtractOptions = {\n\tcwd: string\n\tforce?: boolean\n\twatch?: boolean\n}\n\nexport function createExtractCommand(cli: CAC, cwd: string) {\n\treturn cli\n\t\t.command('extract', 'Statically extract messages from your project')\n\t\t.option('-w, --watch', 'Watch files and rebuild')\n\t\t.option('--cwd <cwd>', 'Current working directory', { default: cwd })\n\t\t.action(extractCmd)\n}\n\nexport async function extractCmd(options: ExtractOptions) {\n\tlogger.heading('extract', 'Statically extract messages from your project')\n\n\tconst done = logger.time.success()\n\n\tconst config = await loadConfig(options)\n\tconst filesPaths = runtime.fs.glob({\n\t\t...config,\n\t\tcwd: options.cwd\n\t})\n\n\tconst outDirPath = runtime.path.resolve(options.cwd, config.outDir)\n\tconst projectLocalePath = runtime.path.resolve(\n\t\toutDirPath,\n\t\tconfig.projectLocale\n\t)\n\tconst manifestPath = runtime.path.resolve(\n\t\toutDirPath,\n\t\t'.terai',\n\t\t'locale-manifest.json'\n\t)\n\n\tlogger.info('Scan:', 'Processing files...')\n\n\tasync function extractor(files = filesPaths) {\n\t\tconst extractedMessages = await extract({\n\t\t\t...config,\n\t\t\tfilesPaths: files,\n\t\t\tcwd: options.cwd\n\t\t})\n\t\tconst dictionary = convertExtractedMessagesToDictionary(extractedMessages)\n\t\tconst manifest: BuildManifest = {\n\t\t\tmessages: extractedMessages\n\t\t}\n\n\t\tconst dictionaries = groupDictionaryByChunks(\n\t\t\tdictionary,\n\t\t\tmanifest,\n\t\t\tconfig.projectLocale\n\t\t)\n\n\t\truntime.fs.remove(runtime.path.resolve(projectLocalePath))\n\n\t\tawait generate({\n\t\t\t...config,\n\t\t\tdictionaries,\n\t\t\tlocale: config.projectLocale,\n\t\t\tcwd: options.cwd\n\t\t})\n\n\t\truntime.fs.write(manifestPath, stringify(manifest))\n\n\t\treturn Object.keys(dictionary).length\n\t}\n\n\tlogger.info('Extraction:', 'Extracting messages...')\n\n\tconst msgCount = await extractor()\n\n\tdone(`Extracted ${msgCount} messages`)\n\n\tif (options.watch) {\n\t\tlogger.log('')\n\t\tlogger.info('Watch:', 'Watching files for changes...\\n')\n\t\tconst configWatcher = runtime.fs.watch({\n\t\t\t...config,\n\t\t\t...options\n\t\t})\n\n\t\tconfigWatcher.on(\n\t\t\t'change',\n\t\t\tdebounce(async () => {\n\t\t\t\tconst done = logger.time.success()\n\t\t\t\tlogger.info('Extraction:', 'Files changed, processing messages...')\n\n\t\t\t\tconst msgCount = await extractor()\n\n\t\t\t\tdone(`Extracted ${msgCount} messages`)\n\t\t\t\tlogger.log('')\n\t\t\t})\n\t\t)\n\t}\n}\n"]}
@@ -1,52 +0,0 @@
1
- 'use strict';
2
-
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
- }) : x)(function(x) {
12
- if (typeof require !== "undefined") return require.apply(this, arguments);
13
- throw Error('Dynamic require of "' + x + '" is not supported');
14
- });
15
- var __esm = (fn, res) => function __init() {
16
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
17
- };
18
- var __commonJS = (cb, mod) => function __require2() {
19
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") {
23
- for (let key of __getOwnPropNames(from))
24
- if (!__hasOwnProp.call(to, key) && key !== except)
25
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
- }
27
- return to;
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
- // If the importer is in node compatibility mode or this is not an ESM
31
- // file that has been converted to a CommonJS file using a Babel-
32
- // compatible transform (i.e. "__esModule" has not been set), then set
33
- // "default" to the CommonJS "module.exports" for node compatibility.
34
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
- mod
36
- ));
37
-
38
- // ../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
39
- var getImportMetaUrl; exports.importMetaUrl = void 0;
40
- var init_cjs_shims = __esm({
41
- "../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js"() {
42
- getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
43
- exports.importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
44
- }
45
- });
46
-
47
- exports.__commonJS = __commonJS;
48
- exports.__require = __require;
49
- exports.__toESM = __toESM;
50
- exports.init_cjs_shims = init_cjs_shims;
51
- //# sourceMappingURL=chunk-LIRTPATK.js.map
52
- //# sourceMappingURL=chunk-LIRTPATK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js"],"names":["importMetaUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAKM,gBAAA,CAAA,CAOOA;AAZb,IAAA,cAAA,GAAA,KAAA,CAAA;AAAA,EAAA,qHAAA,GAAA;AAKA,IAAM,gBAAA,GAAmB,MACvB,OAAO,QAAA,KAAa,WAAA,GAChB,IAAI,GAAA,CAAI,CAAA,KAAA,EAAQ,UAAU,CAAA,CAAE,CAAA,CAAE,IAAA,GAC7B,QAAA,CAAS,aAAA,IAAiB,QAAA,CAAS,aAAA,CAAc,OAAA,CAAQ,WAAA,EAAY,KAAM,QAAA,GAC1E,QAAA,CAAS,aAAA,CAAc,GAAA,GACvB,IAAI,GAAA,CAAI,SAAA,EAAW,QAAA,CAAS,OAAO,CAAA,CAAE,IAAA;AAEtC,IAAMA,wCAAgC,gBAAA,EAAiB;AAAA,EAAA;AAAA,CAAA","file":"chunk-LIRTPATK.js","sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"]}