docs-i18n 0.12.1 → 0.13.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.
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM } from "./chunk-CNvmzFzq.js";
2
2
  import { l as require_react, r as require_jsx_runtime, t as useRouter } from "./useRouter-BXJvr8to.js";
3
- import { A as decodePath, B as replaceEqualDeep, C as processRouteMasks, D as DEFAULT_PROTOCOL_ALLOWLIST, E as invariant, F as isDangerousProtocol, L as isPromise, M as encodePathLikeUrl, N as escapeHtml, O as arraysEqual, P as functionalUpdate, R as last, S as findSingleMatch, T as createLRUCache, _ as trimPath, a as matchContext, b as findFlatMatch, c as rootRouteId, d as compileDecodeCharMap, g as resolvePath, j as deepEqual, k as createControlledPromise, l as isNotFound, m as joinPaths, o as ClientOnly, p as interpolatePath, r as useStore, u as cleanPath, w as processRouteTree, x as findRouteMatch, y as trimPathRight, z as nullReplaceEqualDeep } from "./__tanstack-start-server-fn-resolver-BDlz7b4M.js";
3
+ import { A as decodePath, B as replaceEqualDeep, C as processRouteMasks, D as DEFAULT_PROTOCOL_ALLOWLIST, E as invariant, F as isDangerousProtocol, L as isPromise, M as encodePathLikeUrl, N as escapeHtml, O as arraysEqual, P as functionalUpdate, R as last, S as findSingleMatch, T as createLRUCache, _ as trimPath, a as matchContext, b as findFlatMatch, c as rootRouteId, d as compileDecodeCharMap, g as resolvePath, j as deepEqual, k as createControlledPromise, l as isNotFound, m as joinPaths, o as ClientOnly, p as interpolatePath, r as useStore, u as cleanPath, w as processRouteTree, x as findRouteMatch, y as trimPathRight, z as nullReplaceEqualDeep } from "./__tanstack-start-server-fn-resolver-SG4WUVWE.js";
4
4
  import { g as redirect, m as isRedirect } from "./createServerFn-CAF9Kl7K.js";
5
5
  //#region ../../node_modules/.bun/@tanstack+router-core@1.168.3/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.js
6
6
  function getSafeSessionStorage() {
@@ -1,8 +1,8 @@
1
1
  import { i as __toESM } from "./chunk-CNvmzFzq.js";
2
2
  import { l as require_react, r as require_jsx_runtime, t as useRouter } from "./useRouter-BXJvr8to.js";
3
- import { N as escapeHtml, j as deepEqual, r as useStore, s as useHydrated } from "./__tanstack-start-server-fn-resolver-BDlz7b4M.js";
4
- import { d as RouterCore, h as createNonReactiveReadonlyStore, l as getAssetCrossOrigin, m as createNonReactiveMutableStore, n as Outlet, u as resolveManifestAssetLink } from "./Match-jV7Q5nbh.js";
5
- import { A as skipToken, C as noop, D as resolveStaleTime, F as lazyRouteComponent, I as createFileRoute, L as createLazyFileRoute, N as focusManager, P as Subscribable, R as createRootRouteWithContext, S as matchQuery, _ as functionalUpdate, a as Mutation, g as ensureQueryFn, h as addToStart, l as onlineManager, m as addToEnd, p as addConsumeAwareSignal, r as QueryClientProvider, s as Query, t as Route$2, u as notifyManager, v as hashKey, w as partialMatchKey, x as matchMutation, y as hashQueryKeyByOptions } from "./routes-CUOd2KKc.js";
3
+ import { N as escapeHtml, j as deepEqual, r as useStore, s as useHydrated } from "./__tanstack-start-server-fn-resolver-SG4WUVWE.js";
4
+ import { d as RouterCore, h as createNonReactiveReadonlyStore, l as getAssetCrossOrigin, m as createNonReactiveMutableStore, n as Outlet, u as resolveManifestAssetLink } from "./Match-BeWrYoSG.js";
5
+ import { A as skipToken, C as noop, D as resolveStaleTime, F as lazyRouteComponent, I as createFileRoute, L as createLazyFileRoute, N as focusManager, P as Subscribable, R as createRootRouteWithContext, S as matchQuery, _ as functionalUpdate, a as Mutation, g as ensureQueryFn, h as addToStart, l as onlineManager, m as addToEnd, p as addConsumeAwareSignal, r as QueryClientProvider, s as Query, t as Route$2, u as notifyManager, v as hashKey, w as partialMatchKey, x as matchMutation, y as hashQueryKeyByOptions } from "./routes-D0bCl8P2.js";
6
6
  //#endregion
7
7
  //#region ../../node_modules/.bun/@tanstack+react-router@1.168.3+bf16f8eded5e12ee/node_modules/@tanstack/react-router/dist/esm/routerStores.js
8
8
  var getStoreFactory = (opts) => {
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM } from "./chunk-CNvmzFzq.js";
2
2
  import { a as useForwardedRef, i as reactUse, l as require_react, o as useIntersectionObserver, r as require_jsx_runtime, t as useRouter } from "./useRouter-BXJvr8to.js";
3
- import { B as replaceEqualDeep$1, E as invariant, F as isDangerousProtocol, I as isModuleNotFoundError, P as functionalUpdate$1, a as matchContext, c as rootRouteId, f as exactPathTest, h as removeTrailingSlash, i as dummyMatchContext, j as deepEqual, m as joinPaths, n as require_react_dom, r as useStore, s as useHydrated, t as getServerFnById, v as trimPathLeft, y as trimPathRight } from "./__tanstack-start-server-fn-resolver-BDlz7b4M.js";
3
+ import { B as replaceEqualDeep$1, E as invariant, F as isDangerousProtocol, I as isModuleNotFoundError, P as functionalUpdate$1, a as matchContext, c as rootRouteId, f as exactPathTest, h as removeTrailingSlash, i as dummyMatchContext, j as deepEqual, m as joinPaths, n as require_react_dom, r as useStore, s as useHydrated, t as getServerFnById, v as trimPathLeft, y as trimPathRight } from "./__tanstack-start-server-fn-resolver-SG4WUVWE.js";
4
4
  import { g as redirect, t as createServerFn, u as TSS_SERVER_FUNCTION } from "./createServerFn-CAF9Kl7K.js";
5
5
  import { t as useNavigate } from "./useNavigate-CDLfQmZd.js";
6
6
  //#region ../../node_modules/.bun/@tanstack+router-core@1.168.3/node_modules/@tanstack/router-core/dist/esm/link.js
@@ -2109,7 +2109,7 @@ var createSsrRpc = (functionId, importer) => {
2109
2109
  var getSession = createServerFn({ method: "GET" }).handler(createSsrRpc("539c27f871f75647d981e1ed4d82b5ee620e9e557722641a4a57c5a5818760c9"));
2110
2110
  //#endregion
2111
2111
  //#region app/routes/index.tsx
2112
- var $$splitComponentImporter = () => import("./routes-DMh4pkeO.js");
2112
+ var $$splitComponentImporter = () => import("./routes-ef6kOTX8.js");
2113
2113
  /**
2114
2114
  * Parse version keys into project/version structure.
2115
2115
  * Multi-project keys look like "query/v5", single-project keys look like "v5".
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM } from "./chunk-CNvmzFzq.js";
2
2
  import { l as require_react, r as require_jsx_runtime } from "./useRouter-BXJvr8to.js";
3
3
  import { t as createServerFn } from "./createServerFn-CAF9Kl7K.js";
4
- import { C as noop, D as resolveStaleTime, E as resolveEnabled, M as timeoutManager, N as focusManager, O as shallowEqualObjects, P as Subscribable, T as replaceData, b as isValidTimeout, c as fetchState, d as pendingThenable, f as environmentManager, i as useQueryClient, j as timeUntilStale, k as shouldThrowError, n as createSsrRpc, o as getDefaultState, t as Route, u as notifyManager, v as hashKey } from "./routes-CUOd2KKc.js";
4
+ import { C as noop, D as resolveStaleTime, E as resolveEnabled, M as timeoutManager, N as focusManager, O as shallowEqualObjects, P as Subscribable, T as replaceData, b as isValidTimeout, c as fetchState, d as pendingThenable, f as environmentManager, i as useQueryClient, j as timeUntilStale, k as shouldThrowError, n as createSsrRpc, o as getDefaultState, t as Route, u as notifyManager, v as hashKey } from "./routes-D0bCl8P2.js";
5
5
  import { t as useNavigate } from "./useNavigate-CDLfQmZd.js";
6
6
  import { t as authClient } from "./auth-client-DZADgYlJ.js";
7
7
  //#region ../../node_modules/.bun/@tanstack+query-core@5.95.2/node_modules/@tanstack/query-core/build/modern/queryObserver.js
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./assets/chunk-CNvmzFzq.js";
2
2
  import { l as require_react, n as routerContext, r as require_jsx_runtime, t as useRouter } from "./assets/useRouter-BXJvr8to.js";
3
- import { A as decodePath, E as invariant, T as createLRUCache, a as matchContext, c as rootRouteId, l as isNotFound, n as require_react_dom, t as getServerFnById } from "./assets/__tanstack-start-server-fn-resolver-BDlz7b4M.js";
4
- import { c as ErrorComponent, g as executeRewriteInput, p as createMemoryHistory, r as SafeFragment, s as CatchBoundary, t as Match, u as resolveManifestAssetLink } from "./assets/Match-jV7Q5nbh.js";
3
+ import { A as decodePath, E as invariant, T as createLRUCache, a as matchContext, c as rootRouteId, l as isNotFound, n as require_react_dom, t as getServerFnById } from "./assets/__tanstack-start-server-fn-resolver-SG4WUVWE.js";
4
+ import { c as ErrorComponent, g as executeRewriteInput, p as createMemoryHistory, r as SafeFragment, s as CatchBoundary, t as Match, u as resolveManifestAssetLink } from "./assets/Match-BeWrYoSG.js";
5
5
  import { a as createNullProtoObject, c as TSS_CONTENT_TYPE_FRAMED_VERSIONED, d as X_TSS_RAW_RESPONSE, f as X_TSS_SERIALIZED, h as isResolvedRedirect, i as runWithStartContext, l as TSS_FORMDATA_CONTEXT, m as isRedirect, n as flattenMiddlewares, o as safeObjectMerge, p as mergeHeaders, r as getStartOptions, s as FrameType, u as TSS_SERVER_FUNCTION } from "./assets/createServerFn-CAF9Kl7K.js";
6
6
  import { n as getResponse, r as requestHandler } from "./assets/request-response-Bj40K48O.js";
7
7
  import { n as getAuth, t as ensureMigrations } from "./assets/auth.server-C5kH0jex.js";
@@ -12246,7 +12246,7 @@ var baseManifestPromise;
12246
12246
  */
12247
12247
  var cachedFinalManifestPromise;
12248
12248
  async function loadEntries() {
12249
- const routerEntry = await import("./assets/router-DWZHm_v_.js");
12249
+ const routerEntry = await import("./assets/router-B4k1eDGl.js");
12250
12250
  return {
12251
12251
  startEntry: await import("./assets/start-BYRsG6Vf.js"),
12252
12252
  routerEntry
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  assemble
3
- } from "./chunk-CLYUAWZE.js";
4
- import "./chunk-JHBSHTXC.js";
3
+ } from "./chunk-KC3IKBKF.js";
4
+ import "./chunk-HUBYJOX7.js";
5
5
  import {
6
6
  TranslationCache
7
7
  } from "./chunk-QKIR7RKQ.js";
@@ -9,7 +9,7 @@ import "./chunk-L64GJ4OB.js";
9
9
  import {
10
10
  flattenSources
11
11
  } from "./chunk-TRURQFP4.js";
12
- import "./chunk-PNKVD2UK.js";
12
+ import "./chunk-KFQGP6VL.js";
13
13
 
14
14
  // src/commands/assemble.ts
15
15
  import {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __esm
3
- } from "./chunk-PNKVD2UK.js";
3
+ } from "./chunk-KFQGP6VL.js";
4
4
 
5
5
  // src/core/normalize.ts
6
6
  function normalize(content) {
@@ -3,7 +3,7 @@ import {
3
3
  init_parser,
4
4
  normalize,
5
5
  parseMdx
6
- } from "./chunk-JHBSHTXC.js";
6
+ } from "./chunk-HUBYJOX7.js";
7
7
 
8
8
  // src/core/assembler.ts
9
9
  init_normalize();
@@ -2,6 +2,12 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
6
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
7
+ }) : x)(function(x) {
8
+ if (typeof require !== "undefined") return require.apply(this, arguments);
9
+ throw Error('Dynamic require of "' + x + '" is not supported');
10
+ });
5
11
  var __esm = (fn, res) => function __init() {
6
12
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
13
  };
@@ -20,6 +26,7 @@ var __copyProps = (to, from, except, desc) => {
20
26
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
27
 
22
28
  export {
29
+ __require,
23
30
  __esm,
24
31
  __export,
25
32
  __toCommonJS
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  loadConfig
4
4
  } from "./chunk-TRURQFP4.js";
5
- import "./chunk-PNKVD2UK.js";
5
+ import "./chunk-KFQGP6VL.js";
6
6
 
7
7
  // src/cli.ts
8
8
  import { createRequire } from "module";
@@ -96,7 +96,7 @@ async function handleSiteCommand() {
96
96
  }
97
97
  if (subCommand === "upload") {
98
98
  console.log("Uploading content to D1...");
99
- const { collectContentFiles, generateContentSql, collectTranslations, generateTranslationSql } = await import("./upload-KYKJVERO.js");
99
+ const { collectContentFiles, generateContentSql, collectTranslations, generateTranslationSql, executeUpload } = await import("./upload-7XWK5UTZ.js");
100
100
  const projectRoot = process.cwd();
101
101
  const contentRows = collectContentFiles(projectRoot);
102
102
  const contentSql = generateContentSql(contentRows);
@@ -105,21 +105,16 @@ async function handleSiteCommand() {
105
105
  const translationSql = generateTranslationSql(translationData);
106
106
  console.log(`Collected ${translationData.sources.length} sources, ${translationData.translations.length} translations.`);
107
107
  const allSql = [...contentSql, ...translationSql];
108
- const sqlFile = resolve(os.tmpdir(), "docs-i18n-upload.sql");
109
- writeFileSync(sqlFile, allSql.join("\n"));
110
- await ensureTemplateDeps(templateRoot);
111
108
  const dbName = getOpt("db", "docs-i18n-db");
109
+ const useRemote = hasFlag("remote");
112
110
  const wranglerBin = resolve(templateRoot, "node_modules", ".bin", "wrangler");
113
- const child = spawn(wranglerBin, ["d1", "execute", dbName, "--file", sqlFile], {
114
- cwd: templateRoot,
115
- stdio: "inherit"
116
- });
117
- child.on("exit", (code) => {
118
- if (code === 0) {
119
- console.log("Upload complete.");
120
- }
121
- process.exit(code ?? 0);
111
+ executeUpload({
112
+ statements: allSql,
113
+ dbName,
114
+ remote: useRemote,
115
+ wranglerBin: exists(wranglerBin) ? wranglerBin : void 0
122
116
  });
117
+ return;
123
118
  } else if (subCommand === "deploy") {
124
119
  await ensureTemplateDeps(templateRoot);
125
120
  const wranglerBin2 = resolve(templateRoot, "node_modules", ".bin", "wrangler");
@@ -181,7 +176,7 @@ Options:
181
176
  console.error("Error: --lang is required");
182
177
  process.exit(1);
183
178
  }
184
- const { translate } = await import("./translate-AGUNMZMQ.js");
179
+ const { translate } = await import("./translate-AMKKSZ63.js");
185
180
  await translate(config, {
186
181
  lang,
187
182
  project: getOpt("project") || void 0,
@@ -198,7 +193,7 @@ Options:
198
193
  break;
199
194
  }
200
195
  case "assemble": {
201
- const { assembleAll } = await import("./assemble-S3MWVLBI.js");
196
+ const { assembleAll } = await import("./assemble-FKIKC5I4.js");
202
197
  await assembleAll(config, {
203
198
  project: getOpt("project") || void 0,
204
199
  version: getOpt("version") || void 0,
@@ -207,9 +202,9 @@ Options:
207
202
  break;
208
203
  }
209
204
  case "rescan": {
210
- const { rescan } = await import("./rescan-7XDHUNH5.js");
205
+ const { rescan } = await import("./rescan-RQQNQJPE.js");
211
206
  const plugins = config.plugins ?? [];
212
- const shouldScanBody = plugins.length > 0 ? (await import("./runner-KUGSO4CL.js")).createShouldScanBody(plugins) : void 0;
207
+ const shouldScanBody = plugins.length > 0 ? (await import("./runner-SO4OYQWW.js")).createShouldScanBody(plugins) : void 0;
213
208
  await rescan(config, {
214
209
  project: getOpt("project") || void 0,
215
210
  version: getOpt("version") || void 0,
@@ -223,7 +218,7 @@ Options:
223
218
  console.log("No plugins configured. Nothing to resolve.");
224
219
  break;
225
220
  }
226
- const { runBeforeScan } = await import("./runner-KUGSO4CL.js");
221
+ const { runBeforeScan } = await import("./runner-SO4OYQWW.js");
227
222
  const modified = runBeforeScan(resolvePlugins, config, {
228
223
  project: getOpt("project") || void 0,
229
224
  version: getOpt("version") || void 0,
@@ -234,7 +229,7 @@ ${modified} file(s) resolved`);
234
229
  break;
235
230
  }
236
231
  case "pipeline": {
237
- const { pipeline } = await import("./pipeline-3XGFR4QL.js");
232
+ const { pipeline } = await import("./pipeline-6F7CLVOH.js");
238
233
  await pipeline(config, {
239
234
  skipSync: hasFlag("skip-sync"),
240
235
  skipTranslate: hasFlag("skip-translate"),
@@ -249,7 +244,7 @@ ${modified} file(s) resolved`);
249
244
  break;
250
245
  }
251
246
  case "status": {
252
- const { status } = await import("./status-NX47XZIU.js");
247
+ const { status } = await import("./status-AVK3JWVT.js");
253
248
  await status(config, { lang: getOpt("lang") || void 0 });
254
249
  break;
255
250
  }
@@ -3,7 +3,7 @@ import {
3
3
  runBeforeScan
4
4
  } from "./chunk-BHYFOPS6.js";
5
5
  import "./chunk-TRURQFP4.js";
6
- import "./chunk-PNKVD2UK.js";
6
+ import "./chunk-KFQGP6VL.js";
7
7
 
8
8
  // src/commands/pipeline.ts
9
9
  import { execSync } from "child_process";
@@ -35,7 +35,7 @@ async function pipeline(config, opts) {
35
35
  console.log(" No plugins configured, skipping");
36
36
  }
37
37
  console.log("\n=== Step 3: Rescan ===");
38
- const { rescan } = await import("./rescan-7XDHUNH5.js");
38
+ const { rescan } = await import("./rescan-RQQNQJPE.js");
39
39
  const shouldScanBody = createShouldScanBody(plugins);
40
40
  await rescan(config, {
41
41
  project: opts.project,
@@ -44,7 +44,7 @@ async function pipeline(config, opts) {
44
44
  });
45
45
  if (!opts.skipTranslate) {
46
46
  console.log("\n=== Step 4: Translate ===");
47
- const { translate } = await import("./translate-AGUNMZMQ.js");
47
+ const { translate } = await import("./translate-AMKKSZ63.js");
48
48
  const langs = opts.lang ? [opts.lang] : config.languages;
49
49
  for (const lang of langs) {
50
50
  await translate(config, {
@@ -65,7 +65,7 @@ async function pipeline(config, opts) {
65
65
  console.log(" [DRY-RUN] Would upload to D1");
66
66
  } else {
67
67
  console.log(" Uploading to D1...");
68
- const { collectContentFiles, generateContentSql, collectTranslations, generateTranslationSql } = await import("./upload-KYKJVERO.js");
68
+ const { collectContentFiles, generateContentSql, collectTranslations, generateTranslationSql } = await import("./upload-7XWK5UTZ.js");
69
69
  const { writeFileSync } = await import("fs");
70
70
  const { resolve } = await import("path");
71
71
  const { tmpdir } = await import("os");
@@ -93,7 +93,7 @@ async function pipeline(config, opts) {
93
93
  console.log("\n=== Step 5: Upload (skipped) ===");
94
94
  }
95
95
  console.log("\n=== Step 6: Status ===");
96
- const { status } = await import("./status-NX47XZIU.js");
96
+ const { status } = await import("./status-AVK3JWVT.js");
97
97
  await status(config, { lang: opts.lang });
98
98
  const elapsed = ((Date.now() - t0) / 1e3).toFixed(1);
99
99
  console.log(`
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_parser,
3
3
  parseMdx
4
- } from "./chunk-JHBSHTXC.js";
4
+ } from "./chunk-HUBYJOX7.js";
5
5
  import {
6
6
  TranslationCache
7
7
  } from "./chunk-QKIR7RKQ.js";
@@ -9,7 +9,7 @@ import "./chunk-L64GJ4OB.js";
9
9
  import {
10
10
  flattenSources
11
11
  } from "./chunk-TRURQFP4.js";
12
- import "./chunk-PNKVD2UK.js";
12
+ import "./chunk-KFQGP6VL.js";
13
13
 
14
14
  // src/commands/rescan.ts
15
15
  import { existsSync, readdirSync, readFileSync } from "fs";
@@ -3,7 +3,7 @@ import {
3
3
  runBeforeScan
4
4
  } from "./chunk-BHYFOPS6.js";
5
5
  import "./chunk-TRURQFP4.js";
6
- import "./chunk-PNKVD2UK.js";
6
+ import "./chunk-KFQGP6VL.js";
7
7
  export {
8
8
  createShouldScanBody,
9
9
  runBeforeScan
@@ -5,7 +5,7 @@ import "./chunk-L64GJ4OB.js";
5
5
  import {
6
6
  flattenSources
7
7
  } from "./chunk-TRURQFP4.js";
8
- import "./chunk-PNKVD2UK.js";
8
+ import "./chunk-KFQGP6VL.js";
9
9
 
10
10
  // src/commands/status.ts
11
11
  import { resolve } from "path";
@@ -1,8 +1,8 @@
1
- import "./chunk-CLYUAWZE.js";
1
+ import "./chunk-KC3IKBKF.js";
2
2
  import {
3
3
  FRONTMATTER_TRANSLATABLE_FIELDS,
4
4
  init_parser
5
- } from "./chunk-JHBSHTXC.js";
5
+ } from "./chunk-HUBYJOX7.js";
6
6
  import {
7
7
  TranslationCache
8
8
  } from "./chunk-QKIR7RKQ.js";
@@ -14,7 +14,7 @@ import {
14
14
  __esm,
15
15
  __export,
16
16
  __toCommonJS
17
- } from "./chunk-PNKVD2UK.js";
17
+ } from "./chunk-KFQGP6VL.js";
18
18
 
19
19
  // src/core/frontmatter.ts
20
20
  var frontmatter_exports = {};
@@ -1,11 +1,14 @@
1
1
  import {
2
2
  openDatabase
3
3
  } from "./chunk-L64GJ4OB.js";
4
- import "./chunk-PNKVD2UK.js";
4
+ import {
5
+ __require
6
+ } from "./chunk-KFQGP6VL.js";
5
7
 
6
8
  // src/commands/upload.ts
7
- import { readFileSync, readdirSync, existsSync } from "fs";
9
+ import { readFileSync, readdirSync, existsSync, writeFileSync } from "fs";
8
10
  import { resolve, relative, join } from "path";
11
+ import { execSync } from "child_process";
9
12
  function collectContentFiles(projectRoot) {
10
13
  const contentDir = resolve(projectRoot, "content");
11
14
  if (!existsSync(contentDir)) {
@@ -67,6 +70,16 @@ function generateContentSql(rows) {
67
70
  updated_at INTEGER
68
71
  );`
69
72
  );
73
+ const projectVersions = /* @__PURE__ */ new Set();
74
+ for (const row of rows) {
75
+ projectVersions.add(`${row.project}/${row.version}`);
76
+ }
77
+ for (const pv of projectVersions) {
78
+ const [project, version] = pv.split("/");
79
+ statements.push(
80
+ `DELETE FROM content WHERE project = '${project}' AND version = '${version}';`
81
+ );
82
+ }
70
83
  for (const row of rows) {
71
84
  const escapedBody = row.body.replace(/'/g, "''");
72
85
  const escapedPath = row.path.replace(/'/g, "''");
@@ -77,10 +90,18 @@ function generateContentSql(rows) {
77
90
  return statements;
78
91
  }
79
92
  function collectTranslations(projectRoot) {
80
- const dbPath = resolve(projectRoot, ".docs-i18n", "translations.db");
93
+ const cacheDir = resolve(projectRoot, ".cache");
94
+ const dbPath = resolve(cacheDir, "translations.db");
81
95
  if (!existsSync(dbPath)) {
82
- return { sources: [], translations: [] };
96
+ const legacyPath = resolve(projectRoot, ".docs-i18n", "translations.db");
97
+ if (!existsSync(legacyPath)) {
98
+ return { sources: [], translations: [] };
99
+ }
100
+ return collectFromDb(legacyPath);
83
101
  }
102
+ return collectFromDb(dbPath);
103
+ }
104
+ function collectFromDb(dbPath) {
84
105
  const db = openDatabase(dbPath);
85
106
  try {
86
107
  const sources = db.prepare("SELECT key, text, type FROM sources").all();
@@ -109,6 +130,17 @@ function generateTranslationSql(data) {
109
130
  PRIMARY KEY (lang, key)
110
131
  );
111
132
  CREATE INDEX IF NOT EXISTS idx_translations_lang ON translations(lang);`
133
+ );
134
+ statements.push(
135
+ `CREATE TABLE IF NOT EXISTS source_files (
136
+ key TEXT NOT NULL,
137
+ file TEXT NOT NULL,
138
+ line INTEGER NOT NULL,
139
+ version TEXT NOT NULL DEFAULT 'latest',
140
+ PRIMARY KEY (version, key, file, line)
141
+ );
142
+ CREATE INDEX IF NOT EXISTS idx_source_files_version ON source_files(version);
143
+ CREATE INDEX IF NOT EXISTS idx_source_files_file ON source_files(version, file);`
112
144
  );
113
145
  for (const s of data.sources) {
114
146
  const escapedText = s.text.replace(/'/g, "''");
@@ -124,9 +156,59 @@ CREATE INDEX IF NOT EXISTS idx_translations_lang ON translations(lang);`
124
156
  }
125
157
  return statements;
126
158
  }
159
+ var MAX_BATCH_SIZE = 5 * 1024 * 1024;
160
+ function executeUpload(opts) {
161
+ const { statements, dbName, remote, accountId } = opts;
162
+ const wranglerBin = opts.wranglerBin || findWrangler();
163
+ if (!wranglerBin) {
164
+ throw new Error("wrangler not found. Install it or specify --wrangler-bin");
165
+ }
166
+ const batches = [[]];
167
+ let currentSize = 0;
168
+ for (const stmt of statements) {
169
+ const stmtSize = Buffer.byteLength(stmt, "utf-8");
170
+ if (currentSize + stmtSize > MAX_BATCH_SIZE && batches[batches.length - 1].length > 0) {
171
+ batches.push([]);
172
+ currentSize = 0;
173
+ }
174
+ batches[batches.length - 1].push(stmt);
175
+ currentSize += stmtSize;
176
+ }
177
+ console.log(`Uploading ${statements.length} SQL statements in ${batches.length} batch(es)...`);
178
+ for (let i = 0; i < batches.length; i++) {
179
+ const batch = batches[i];
180
+ const sqlFile = resolve(__require("os").tmpdir(), `docs-i18n-upload-${i}.sql`);
181
+ writeFileSync(sqlFile, batch.join("\n"));
182
+ const remoteFlag = remote ? "--remote" : "";
183
+ const env = accountId ? { ...process.env, CLOUDFLARE_ACCOUNT_ID: accountId } : process.env;
184
+ console.log(` Batch ${i + 1}/${batches.length}: ${batch.length} statements`);
185
+ execSync(
186
+ `"${wranglerBin}" d1 execute "${dbName}" ${remoteFlag} --file "${sqlFile}"`,
187
+ { stdio: "inherit", env }
188
+ );
189
+ }
190
+ console.log("Upload complete.");
191
+ }
192
+ function findWrangler() {
193
+ const candidates = [
194
+ resolve(process.cwd(), "node_modules", ".bin", "wrangler"),
195
+ // Check if docs-i18n template has wrangler
196
+ resolve(__dirname, "..", "..", "..", "template", "node_modules", ".bin", "wrangler")
197
+ ];
198
+ for (const candidate of candidates) {
199
+ if (existsSync(candidate)) return candidate;
200
+ }
201
+ try {
202
+ execSync("which wrangler", { stdio: "ignore" });
203
+ return "wrangler";
204
+ } catch {
205
+ return null;
206
+ }
207
+ }
127
208
  export {
128
209
  collectContentFiles,
129
210
  collectTranslations,
211
+ executeUpload,
130
212
  generateContentSql,
131
213
  generateTranslationSql
132
214
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docs-i18n",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "Universal documentation translation engine — parse, translate, cache, assemble, manage.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18463,12 +18463,12 @@ const manifest = { "2da8ac67817387d067b3bdceb46771231f5e146e3854d166a502e2e544b9
18463
18463
  }, "d70cb4120f5e21fc51a269146a3e4e34bf32fcdfc44d688d7a5f077efca69cf4": {
18464
18464
  functionName: "fetchDocsConfig_createServerFn_handler",
18465
18465
  importer: () => import("./assets/_lang._project.docs-BsnkRf-R.js")
18466
- }, "3a02e7ac36f08ce3d991de3075bacf6e5dda4be4582d9246009c781405783df6": {
18467
- functionName: "fetchDocsConfig_createServerFn_handler",
18468
- importer: () => import("./assets/_lang._project._version.docs-DOTNQiDb.js")
18469
18466
  }, "094bd97706d5673a22d38d99e5497787a36ac27d573b5d695feb60c7dacf19e0": {
18470
18467
  functionName: "fetchDoc_createServerFn_handler",
18471
18468
  importer: () => import("./assets/_lang._project.docs._-axRfm8vS.js")
18469
+ }, "3a02e7ac36f08ce3d991de3075bacf6e5dda4be4582d9246009c781405783df6": {
18470
+ functionName: "fetchDocsConfig_createServerFn_handler",
18471
+ importer: () => import("./assets/_lang._project._version.docs-DOTNQiDb.js")
18472
18472
  }, "845341eb547cb02d4c6586d04ff2cf53bfebae44b4824da03c4b2f625644d993": {
18473
18473
  functionName: "fetchFrameworkDoc_createServerFn_handler",
18474
18474
  importer: () => import("./assets/_lang.docs.framework._framework._-BFWLyU2h.js")
@@ -1658,10 +1658,6 @@ var manifest = {
1658
1658
  functionName: "getSession_createServerFn_handler",
1659
1659
  importer: () => import("./auth-Hlc_ErDZ.js")
1660
1660
  },
1661
- "5080dc3f2f2309ec6981b94c431969637130c657e8a1dfb10400b4614eecc1ea": {
1662
- functionName: "fetchModels_createServerFn_handler",
1663
- importer: () => import("./models-DTJbdHu7.js")
1664
- },
1665
1661
  "a3d81974aeece150d4b02be5b91590b8187442ebea56be4a89dcbf053626d22b": {
1666
1662
  functionName: "fetchVersion_createServerFn_handler",
1667
1663
  importer: () => import("./misc-leinq0id.js")
@@ -1678,6 +1674,26 @@ var manifest = {
1678
1674
  functionName: "openFile_createServerFn_handler",
1679
1675
  importer: () => import("./misc-leinq0id.js")
1680
1676
  },
1677
+ "421de02ce39dde6e27cf4689e837ec072cbd01e63f8cdd5c2a3f42f0bd5ca613": {
1678
+ functionName: "fetchJobs_createServerFn_handler",
1679
+ importer: () => import("./jobs-CcwecqaK.js")
1680
+ },
1681
+ "c08559ac758aa0d315deaca7a0d7d923a9a44d997c8cb811151417c1f221ddd6": {
1682
+ functionName: "createJob_createServerFn_handler",
1683
+ importer: () => import("./jobs-CcwecqaK.js")
1684
+ },
1685
+ "8a56694c9d7b29422a3e7d2f6b803be100d79d3853d92d465cb55ed572781e62": {
1686
+ functionName: "fetchJob_createServerFn_handler",
1687
+ importer: () => import("./jobs-CcwecqaK.js")
1688
+ },
1689
+ "88c2855c84e91504070bfecc50ddfa50339d22c305626800b6d9b05d79385d71": {
1690
+ functionName: "deleteJob_createServerFn_handler",
1691
+ importer: () => import("./jobs-CcwecqaK.js")
1692
+ },
1693
+ "5080dc3f2f2309ec6981b94c431969637130c657e8a1dfb10400b4614eecc1ea": {
1694
+ functionName: "fetchModels_createServerFn_handler",
1695
+ importer: () => import("./models-DTJbdHu7.js")
1696
+ },
1681
1697
  "4e218d79545765572808c7eab33b7663d4496209c15406d0b449366905b6b83f": {
1682
1698
  functionName: "fetchStatus_createServerFn_handler",
1683
1699
  importer: () => import("./status-VBCTGlIL.js")
@@ -1697,22 +1713,6 @@ var manifest = {
1697
1713
  "1d8e3916f992485c62e62c3693083850b773fdff4ec54277de5a01eb98dab664": {
1698
1714
  functionName: "rescanVersion_createServerFn_handler",
1699
1715
  importer: () => import("./status-VBCTGlIL.js")
1700
- },
1701
- "421de02ce39dde6e27cf4689e837ec072cbd01e63f8cdd5c2a3f42f0bd5ca613": {
1702
- functionName: "fetchJobs_createServerFn_handler",
1703
- importer: () => import("./jobs-CcwecqaK.js")
1704
- },
1705
- "c08559ac758aa0d315deaca7a0d7d923a9a44d997c8cb811151417c1f221ddd6": {
1706
- functionName: "createJob_createServerFn_handler",
1707
- importer: () => import("./jobs-CcwecqaK.js")
1708
- },
1709
- "8a56694c9d7b29422a3e7d2f6b803be100d79d3853d92d465cb55ed572781e62": {
1710
- functionName: "fetchJob_createServerFn_handler",
1711
- importer: () => import("./jobs-CcwecqaK.js")
1712
- },
1713
- "88c2855c84e91504070bfecc50ddfa50339d22c305626800b6d9b05d79385d71": {
1714
- functionName: "deleteJob_createServerFn_handler",
1715
- importer: () => import("./jobs-CcwecqaK.js")
1716
1716
  }
1717
1717
  };
1718
1718
  async function getServerFnById(id) {