@let-value/translate-extract-static 1.0.30 → 1.1.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.
package/dist/bin/cli.cjs CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env node
2
- const require_src = require('../src-Dvwnfabp.cjs');
2
+ const require_chunk = require('../chunk-CUT6urMc.cjs');
3
+ const require_binary = require('../binary-Do1nEoy8.cjs');
3
4
  let node_child_process = require("node:child_process");
4
- node_child_process = require_src.__toESM(node_child_process);
5
+ node_child_process = require_chunk.__toESM(node_child_process);
5
6
 
6
7
  //#region bin/cli.ts
7
- const child = (0, node_child_process.spawn)(require_src.binaryPath, process.argv.slice(2), {
8
+ const child = (0, node_child_process.spawn)(require_binary.binaryPath, process.argv.slice(2), {
8
9
  stdio: "inherit",
9
10
  windowsHide: true
10
11
  });
package/dist/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { binaryPath } from "../src-P8KovMIH.js";
2
+ import { binaryPath } from "../binary-DLbeeLiM.js";
3
3
  import { spawn } from "node:child_process";
4
4
 
5
5
  //#region bin/cli.ts
@@ -1,7 +1,7 @@
1
1
  import { resolve } from "node:path";
2
2
  import { familySync } from "detect-libc";
3
3
 
4
- //#region src/index.ts
4
+ //#region src/binary.ts
5
5
  const root = resolve(import.meta.dirname, "..");
6
6
  const platform = process.platform;
7
7
  const arch = process.arch;
@@ -12,7 +12,6 @@ function getBinaryName(platform$1, arch$1, libc$1) {
12
12
  }
13
13
  const binaryName = getBinaryName(platform, arch, libc);
14
14
  const binaryPath = resolve(root, "dist", binaryName);
15
- var src_default = binaryPath;
16
15
 
17
16
  //#endregion
18
- export { arch, binaryName, binaryPath, getBinaryName, libc, platform, root, src_default };
17
+ export { binaryName, binaryPath, platform };
@@ -0,0 +1,37 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ let node_path = require("node:path");
3
+ node_path = require_chunk.__toESM(node_path);
4
+ let detect_libc = require("detect-libc");
5
+ detect_libc = require_chunk.__toESM(detect_libc);
6
+
7
+ //#region src/binary.ts
8
+ const root = (0, node_path.resolve)(__dirname, "..");
9
+ const platform = process.platform;
10
+ const arch = process.arch;
11
+ const libc = (0, detect_libc.familySync)() || null;
12
+ function getBinaryName(platform$1, arch$1, libc$1) {
13
+ const extension = platform$1 === "win32" ? ".exe" : "";
14
+ return `extract-${platform$1}-${arch$1}${libc$1 ? `-${libc$1}` : ""}${extension}`;
15
+ }
16
+ const binaryName = getBinaryName(platform, arch, libc);
17
+ const binaryPath = (0, node_path.resolve)(root, "dist", binaryName);
18
+
19
+ //#endregion
20
+ Object.defineProperty(exports, 'binaryName', {
21
+ enumerable: true,
22
+ get: function () {
23
+ return binaryName;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, 'binaryPath', {
27
+ enumerable: true,
28
+ get: function () {
29
+ return binaryPath;
30
+ }
31
+ });
32
+ Object.defineProperty(exports, 'platform', {
33
+ enumerable: true,
34
+ get: function () {
35
+ return platform;
36
+ }
37
+ });
@@ -0,0 +1,30 @@
1
+ //#region rolldown:runtime
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 __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+
25
+ Object.defineProperty(exports, '__toESM', {
26
+ enumerable: true,
27
+ get: function () {
28
+ return __toESM;
29
+ }
30
+ });
@@ -1,8 +1,9 @@
1
- const require_src = require('../src-Dvwnfabp.cjs');
1
+ const require_chunk = require('../chunk-CUT6urMc.cjs');
2
+ const require_binary = require('../binary-Do1nEoy8.cjs');
2
3
  let node_path = require("node:path");
3
- node_path = require_src.__toESM(node_path);
4
+ node_path = require_chunk.__toESM(node_path);
4
5
  let node_fs = require("node:fs");
5
- node_fs = require_src.__toESM(node_fs);
6
+ node_fs = require_chunk.__toESM(node_fs);
6
7
 
7
8
  //#region scripts/postinstall.ts
8
9
  const root = (0, node_path.resolve)(__dirname, "../..");
@@ -10,7 +11,7 @@ const dist = (0, node_path.resolve)(root, "dist");
10
11
  const pkg = JSON.parse((0, node_fs.readFileSync)((0, node_path.resolve)(root, "package.json"), "utf8"));
11
12
  const repo = "https://github.com/let-value/translate";
12
13
  const tag = `v${pkg.version}`;
13
- const url = `${repo}/releases/download/${tag}/${require_src.binaryName}`;
14
+ const url = `${repo}/releases/download/${tag}/${require_binary.binaryName}`;
14
15
  async function downloadBinary() {
15
16
  try {
16
17
  const response = await fetch(url, {
@@ -18,19 +19,19 @@ async function downloadBinary() {
18
19
  signal: AbortSignal.timeout(3e4),
19
20
  headers: { "user-agent": "@let-value/translate-extract-static postinstall" }
20
21
  });
21
- (0, node_fs.writeFileSync)(require_src.binaryPath, Buffer.from(await response.arrayBuffer()));
22
- if (require_src.platform !== "win32") (0, node_fs.chmodSync)(require_src.binaryPath, 493);
22
+ (0, node_fs.writeFileSync)(require_binary.binaryPath, Buffer.from(await response.arrayBuffer()));
23
+ if (require_binary.platform !== "win32") (0, node_fs.chmodSync)(require_binary.binaryPath, 493);
23
24
  return true;
24
25
  } catch {}
25
26
  }
26
27
  async function main() {
27
28
  (0, node_fs.mkdirSync)(dist, { recursive: true });
28
- if ((0, node_fs.existsSync)(require_src.binaryPath)) return;
29
+ if ((0, node_fs.existsSync)(require_binary.binaryPath)) return;
29
30
  if (await downloadBinary()) {
30
- console.log(`Downloaded binary: ${require_src.binaryName}`);
31
+ console.log(`Downloaded binary: ${require_binary.binaryName}`);
31
32
  return;
32
33
  }
33
- console.warn(`Could not download a binary for ${require_src.binaryName}.`);
34
+ console.warn(`Could not download a binary for ${require_binary.binaryName}.`);
34
35
  }
35
36
  main().catch((error) => {
36
37
  console.warn(`Binary download failed: ${String(error)}`);
@@ -1,4 +1,4 @@
1
- import { binaryName, binaryPath, platform } from "../src-P8KovMIH.js";
1
+ import { binaryName, binaryPath, platform } from "../binary-DLbeeLiM.js";
2
2
  import { resolve } from "node:path";
3
3
  import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
4
 
@@ -1,11 +1,90 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_src = require('../src-Dvwnfabp.cjs');
1
+ const require_chunk = require('../chunk-CUT6urMc.cjs');
2
+ let node_path = require("node:path");
3
+ node_path = require_chunk.__toESM(node_path);
3
4
 
4
- exports.arch = require_src.arch;
5
- exports.binaryName = require_src.binaryName;
6
- exports.binaryPath = require_src.binaryPath;
7
- exports.default = require_src.src_default;
8
- exports.getBinaryName = require_src.getBinaryName;
9
- exports.libc = require_src.libc;
10
- exports.platform = require_src.platform;
11
- exports.root = require_src.root;
5
+ //#region ../extract/dist/static-DQHT7uqP.js
6
+ function core(...props) {
7
+ return { static: {
8
+ name: "core",
9
+ props
10
+ } };
11
+ }
12
+ function react(...props) {
13
+ return { static: {
14
+ name: "react",
15
+ props
16
+ } };
17
+ }
18
+ function po(...props) {
19
+ return { static: {
20
+ name: "po",
21
+ props
22
+ } };
23
+ }
24
+ function cleanup(...props) {
25
+ return { static: {
26
+ name: "cleanup",
27
+ props
28
+ } };
29
+ }
30
+
31
+ //#endregion
32
+ //#region ../extract/dist/core-DR3oxhSq.js
33
+ const defaultPlugins = {
34
+ core,
35
+ po,
36
+ cleanup
37
+ };
38
+ const defaultDestination = ({ entrypoint, locale }) => (0, node_path.join)((0, node_path.dirname)(entrypoint), "translations", `${(0, node_path.basename)(entrypoint, (0, node_path.extname)(entrypoint))}.${locale}.po`);
39
+ const defaultExclude = [
40
+ /(?:^|[\\/])node_modules(?:[\\/]|$)/,
41
+ /(?:^|[\\/])dist(?:[\\/]|$)/,
42
+ /(?:^|[\\/])build(?:[\\/]|$)/
43
+ ];
44
+ function normalizeExclude(exclude) {
45
+ if (!exclude) return [];
46
+ return Array.isArray(exclude) ? exclude : [exclude];
47
+ }
48
+ function resolveEntrypoint(ep) {
49
+ if (typeof ep === "string") return { entrypoint: ep };
50
+ const { entrypoint, destination, obsolete, walk, exclude } = ep;
51
+ return {
52
+ entrypoint,
53
+ destination,
54
+ obsolete,
55
+ walk,
56
+ exclude: exclude ? normalizeExclude(exclude) : void 0
57
+ };
58
+ }
59
+ function resolvePlugins(user) {
60
+ if (typeof user === "function") return user(defaultPlugins);
61
+ if (Array.isArray(user)) return [...Object.values(defaultPlugins).map((plugin) => plugin()), ...user];
62
+ return Object.values(defaultPlugins).map((plugin) => plugin());
63
+ }
64
+ /**
65
+ * Type helper to make it easier to use translate.config.ts
66
+ * @param config - {@link UserConfig}.
67
+ */
68
+ function defineConfig(config) {
69
+ const defaultLocale = config.defaultLocale ?? "en";
70
+ const plugins = resolvePlugins(config.plugins);
71
+ const entrypoints = (Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints]).map(resolveEntrypoint);
72
+ return {
73
+ plugins,
74
+ entrypoints,
75
+ defaultLocale,
76
+ locales: config.locales ?? [defaultLocale],
77
+ destination: config.destination ?? defaultDestination,
78
+ obsolete: config.obsolete ?? "mark",
79
+ walk: config.walk ?? true,
80
+ logLevel: config.logLevel ?? "info",
81
+ exclude: config.exclude ? normalizeExclude(config.exclude) : defaultExclude
82
+ };
83
+ }
84
+
85
+ //#endregion
86
+ exports.cleanup = cleanup;
87
+ exports.core = core;
88
+ exports.defineConfig = defineConfig;
89
+ exports.po = po;
90
+ exports.react = react;
@@ -1,10 +1,2 @@
1
- //#region src/index.d.ts
2
- declare const root: string;
3
- declare const platform: NodeJS.Platform;
4
- declare const arch: NodeJS.Architecture;
5
- declare const libc: string | null;
6
- declare function getBinaryName(platform: string, arch: string, libc?: string | null): string;
7
- declare const binaryName: string;
8
- declare const binaryPath: string;
9
- //#endregion
10
- export { arch, binaryName, binaryPath, binaryPath as default, getBinaryName, libc, platform, root };
1
+ export * from "@let-value/translate-extract/core";
2
+ export * from "@let-value/translate-extract/static";
@@ -1,10 +1,2 @@
1
- //#region src/index.d.ts
2
- declare const root: string;
3
- declare const platform: NodeJS.Platform;
4
- declare const arch: NodeJS.Architecture;
5
- declare const libc: string | null;
6
- declare function getBinaryName(platform: string, arch: string, libc?: string | null): string;
7
- declare const binaryName: string;
8
- declare const binaryPath: string;
9
- //#endregion
10
- export { arch, binaryName, binaryPath, binaryPath as default, getBinaryName, libc, platform, root };
1
+ export * from "@let-value/translate-extract/core";
2
+ export * from "@let-value/translate-extract/static";
package/dist/src/index.js CHANGED
@@ -1,3 +1,84 @@
1
- import { arch, binaryName, binaryPath, getBinaryName, libc, platform, root, src_default } from "../src-P8KovMIH.js";
1
+ import { basename, dirname, extname, join } from "node:path";
2
2
 
3
- export { arch, binaryName, binaryPath, src_default as default, getBinaryName, libc, platform, root };
3
+ //#region ../extract/dist/static-DQHT7uqP.js
4
+ function core(...props) {
5
+ return { static: {
6
+ name: "core",
7
+ props
8
+ } };
9
+ }
10
+ function react(...props) {
11
+ return { static: {
12
+ name: "react",
13
+ props
14
+ } };
15
+ }
16
+ function po(...props) {
17
+ return { static: {
18
+ name: "po",
19
+ props
20
+ } };
21
+ }
22
+ function cleanup(...props) {
23
+ return { static: {
24
+ name: "cleanup",
25
+ props
26
+ } };
27
+ }
28
+
29
+ //#endregion
30
+ //#region ../extract/dist/core-DR3oxhSq.js
31
+ const defaultPlugins = {
32
+ core,
33
+ po,
34
+ cleanup
35
+ };
36
+ const defaultDestination = ({ entrypoint, locale }) => join(dirname(entrypoint), "translations", `${basename(entrypoint, extname(entrypoint))}.${locale}.po`);
37
+ const defaultExclude = [
38
+ /(?:^|[\\/])node_modules(?:[\\/]|$)/,
39
+ /(?:^|[\\/])dist(?:[\\/]|$)/,
40
+ /(?:^|[\\/])build(?:[\\/]|$)/
41
+ ];
42
+ function normalizeExclude(exclude) {
43
+ if (!exclude) return [];
44
+ return Array.isArray(exclude) ? exclude : [exclude];
45
+ }
46
+ function resolveEntrypoint(ep) {
47
+ if (typeof ep === "string") return { entrypoint: ep };
48
+ const { entrypoint, destination, obsolete, walk, exclude } = ep;
49
+ return {
50
+ entrypoint,
51
+ destination,
52
+ obsolete,
53
+ walk,
54
+ exclude: exclude ? normalizeExclude(exclude) : void 0
55
+ };
56
+ }
57
+ function resolvePlugins(user) {
58
+ if (typeof user === "function") return user(defaultPlugins);
59
+ if (Array.isArray(user)) return [...Object.values(defaultPlugins).map((plugin) => plugin()), ...user];
60
+ return Object.values(defaultPlugins).map((plugin) => plugin());
61
+ }
62
+ /**
63
+ * Type helper to make it easier to use translate.config.ts
64
+ * @param config - {@link UserConfig}.
65
+ */
66
+ function defineConfig(config) {
67
+ const defaultLocale = config.defaultLocale ?? "en";
68
+ const plugins = resolvePlugins(config.plugins);
69
+ const entrypoints = (Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints]).map(resolveEntrypoint);
70
+ return {
71
+ plugins,
72
+ entrypoints,
73
+ defaultLocale,
74
+ locales: config.locales ?? [defaultLocale],
75
+ destination: config.destination ?? defaultDestination,
76
+ obsolete: config.obsolete ?? "mark",
77
+ walk: config.walk ?? true,
78
+ logLevel: config.logLevel ?? "info",
79
+ exclude: config.exclude ? normalizeExclude(config.exclude) : defaultExclude
80
+ };
81
+ }
82
+
83
+ //#endregion
84
+ export { cleanup, core, defineConfig, po, react };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@let-value/translate-extract-static",
3
- "version": "1.0.30",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.cjs",
6
6
  "module": "./dist/src/index.js",
@@ -29,6 +29,7 @@
29
29
  "test": "node --test"
30
30
  },
31
31
  "devDependencies": {
32
+ "@let-value/translate-extract": "1.1.0",
32
33
  "@types/bun": "1.3.8",
33
34
  "@types/node": "22.10.2",
34
35
  "tsdown": "0.15.2",
@@ -1,96 +0,0 @@
1
- //#region rolldown:runtime
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 __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- let node_path = require("node:path");
25
- node_path = __toESM(node_path);
26
- let detect_libc = require("detect-libc");
27
- detect_libc = __toESM(detect_libc);
28
-
29
- //#region src/index.ts
30
- const root = (0, node_path.resolve)(__dirname, "..");
31
- const platform = process.platform;
32
- const arch = process.arch;
33
- const libc = (0, detect_libc.familySync)() || null;
34
- function getBinaryName(platform$1, arch$1, libc$1) {
35
- const extension = platform$1 === "win32" ? ".exe" : "";
36
- return `extract-${platform$1}-${arch$1}${libc$1 ? `-${libc$1}` : ""}${extension}`;
37
- }
38
- const binaryName = getBinaryName(platform, arch, libc);
39
- const binaryPath = (0, node_path.resolve)(root, "dist", binaryName);
40
- var src_default = binaryPath;
41
-
42
- //#endregion
43
- Object.defineProperty(exports, '__toESM', {
44
- enumerable: true,
45
- get: function () {
46
- return __toESM;
47
- }
48
- });
49
- Object.defineProperty(exports, 'arch', {
50
- enumerable: true,
51
- get: function () {
52
- return arch;
53
- }
54
- });
55
- Object.defineProperty(exports, 'binaryName', {
56
- enumerable: true,
57
- get: function () {
58
- return binaryName;
59
- }
60
- });
61
- Object.defineProperty(exports, 'binaryPath', {
62
- enumerable: true,
63
- get: function () {
64
- return binaryPath;
65
- }
66
- });
67
- Object.defineProperty(exports, 'getBinaryName', {
68
- enumerable: true,
69
- get: function () {
70
- return getBinaryName;
71
- }
72
- });
73
- Object.defineProperty(exports, 'libc', {
74
- enumerable: true,
75
- get: function () {
76
- return libc;
77
- }
78
- });
79
- Object.defineProperty(exports, 'platform', {
80
- enumerable: true,
81
- get: function () {
82
- return platform;
83
- }
84
- });
85
- Object.defineProperty(exports, 'root', {
86
- enumerable: true,
87
- get: function () {
88
- return root;
89
- }
90
- });
91
- Object.defineProperty(exports, 'src_default', {
92
- enumerable: true,
93
- get: function () {
94
- return src_default;
95
- }
96
- });