docs-i18n 0.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.
@@ -0,0 +1,6 @@
1
+ // node_modules/vite/misc/false.js
2
+ var false_default = false;
3
+
4
+ export {
5
+ false_default
6
+ };
@@ -0,0 +1,44 @@
1
+ // node_modules/vite/dist/node/chunks/chunk.js
2
+ import { createRequire } from "module";
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 __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
10
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
11
+ var __exportAll = (all, no_symbols) => {
12
+ let target = {};
13
+ for (var name in all) __defProp(target, name, {
14
+ get: all[name],
15
+ enumerable: true
16
+ });
17
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
18
+ return target;
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
22
+ key = keys[i];
23
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
24
+ get: ((k) => from[k]).bind(null, key),
25
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
26
+ });
27
+ }
28
+ return to;
29
+ };
30
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
31
+ value: mod,
32
+ enumerable: true
33
+ }) : target, mod));
34
+ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
36
+
37
+ export {
38
+ __esmMin,
39
+ __commonJSMin,
40
+ __exportAll,
41
+ __toESM,
42
+ __toCommonJS,
43
+ __require
44
+ };
@@ -0,0 +1,60 @@
1
+ import {
2
+ init_normalize,
3
+ init_parser,
4
+ normalize,
5
+ parseMdx
6
+ } from "./chunk-SUIDX6IZ.js";
7
+
8
+ // src/core/assembler.ts
9
+ init_normalize();
10
+ init_parser();
11
+ var NEEDS_TRANSLATION_START = "<!-- NEEDS_TRANSLATION -->";
12
+ var NEEDS_TRANSLATION_END = "<!-- /NEEDS_TRANSLATION -->";
13
+ function assemble(rawContent, lang, cache, sourceFilePath, fallbackToSource = false) {
14
+ const normalizedContent = normalize(rawContent);
15
+ const nodes = parseMdx(rawContent);
16
+ let result = "";
17
+ let lastEnd = 0;
18
+ let cachedCount = 0;
19
+ let uncachedCount = 0;
20
+ let totalTranslatable = 0;
21
+ for (const node of nodes) {
22
+ result += normalizedContent.substring(lastEnd, node.startOffset);
23
+ if (node.needsTranslation) {
24
+ totalTranslatable++;
25
+ const cached = node.md5 ? cache.get(lang, node.md5) : void 0;
26
+ if (node.md5 && sourceFilePath) {
27
+ const line = normalizedContent.substring(0, node.startOffset).split("\n").length;
28
+ cache.updateSource(lang, node.md5, sourceFilePath, line);
29
+ }
30
+ if (cached) {
31
+ result += cached;
32
+ cachedCount++;
33
+ } else if (fallbackToSource) {
34
+ result += node.rawText;
35
+ uncachedCount++;
36
+ } else {
37
+ result += `${NEEDS_TRANSLATION_START}
38
+ ${node.rawText}
39
+ ${NEEDS_TRANSLATION_END}`;
40
+ uncachedCount++;
41
+ }
42
+ } else {
43
+ result += node.rawText;
44
+ }
45
+ lastEnd = node.endOffset;
46
+ }
47
+ result += normalizedContent.substring(lastEnd);
48
+ return {
49
+ content: result,
50
+ allCached: uncachedCount === 0,
51
+ cachedCount,
52
+ uncachedCount,
53
+ totalTranslatable,
54
+ parsedNodes: nodes
55
+ };
56
+ }
57
+
58
+ export {
59
+ assemble
60
+ };
@@ -0,0 +1,122 @@
1
+ import {
2
+ __esm
3
+ } from "./chunk-AKLW2MUS.js";
4
+
5
+ // src/core/normalize.ts
6
+ function normalize(content) {
7
+ let result = content;
8
+ result = result.replace(
9
+ /^(<(?:AppOnly|PagesOnly|details[^>]*|div[^>]*)>)\n(?!\n)/gm,
10
+ "$1\n\n"
11
+ );
12
+ result = result.replace(
13
+ /(?<!\n)\n(<\/(?:AppOnly|PagesOnly|details|div)>)/gm,
14
+ "\n\n$1"
15
+ );
16
+ result = result.replace(
17
+ /^(<\/(?:AppOnly|PagesOnly|details|div)>)\n(?!\n)/gm,
18
+ "$1\n\n"
19
+ );
20
+ return result;
21
+ }
22
+ var init_normalize = __esm({
23
+ "src/core/normalize.ts"() {
24
+ "use strict";
25
+ }
26
+ });
27
+
28
+ // src/core/parser.ts
29
+ import crypto from "crypto";
30
+ import { remark } from "remark";
31
+ function isHtmlPureTag(text) {
32
+ const lines = text.trim().split("\n");
33
+ return lines.every((line) => {
34
+ const trimmed = line.trim();
35
+ if (trimmed === "") return true;
36
+ if (/^<\w[^>]*\/>$/.test(trimmed)) return true;
37
+ if (/^<\/?\w[\w-]*[^>]*>$/.test(trimmed)) return true;
38
+ return false;
39
+ });
40
+ }
41
+ function computeHash(text) {
42
+ return crypto.createHash("md5").update(text).digest("hex");
43
+ }
44
+ function parseMdx(rawContent) {
45
+ const content = normalize(rawContent);
46
+ const tree = remark().parse(content);
47
+ const nodes = [];
48
+ let frontmatterHandled = false;
49
+ if (content.startsWith("---") && tree.children.length >= 2 && tree.children[0].type === "thematicBreak") {
50
+ const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
51
+ if (fmMatch) {
52
+ const fmEnd = fmMatch[0].length;
53
+ const fmText = fmMatch[0];
54
+ nodes.push({
55
+ type: "frontmatter",
56
+ rawText: fmText,
57
+ needsTranslation: true,
58
+ md5: computeHash(fmText),
59
+ startOffset: 0,
60
+ endOffset: fmEnd
61
+ });
62
+ frontmatterHandled = true;
63
+ }
64
+ }
65
+ for (const child of tree.children) {
66
+ const startOffset = child.position?.start.offset ?? 0;
67
+ const endOffset = child.position?.end.offset ?? 0;
68
+ if (frontmatterHandled && startOffset < nodes[0].endOffset) {
69
+ continue;
70
+ }
71
+ const rawText = content.substring(startOffset, endOffset);
72
+ const type = child.type;
73
+ let needsTranslation;
74
+ if (TRANSLATABLE_TYPES.has(type)) {
75
+ needsTranslation = true;
76
+ } else if (type === "html") {
77
+ needsTranslation = !isHtmlPureTag(rawText);
78
+ } else {
79
+ needsTranslation = false;
80
+ }
81
+ const node = {
82
+ type,
83
+ rawText,
84
+ needsTranslation,
85
+ startOffset,
86
+ endOffset
87
+ };
88
+ if (needsTranslation) {
89
+ node.md5 = computeHash(rawText);
90
+ }
91
+ nodes.push(node);
92
+ }
93
+ return nodes;
94
+ }
95
+ var TRANSLATABLE_TYPES, FRONTMATTER_TRANSLATABLE_FIELDS;
96
+ var init_parser = __esm({
97
+ "src/core/parser.ts"() {
98
+ "use strict";
99
+ init_normalize();
100
+ TRANSLATABLE_TYPES = /* @__PURE__ */ new Set([
101
+ "paragraph",
102
+ "heading",
103
+ "list",
104
+ "blockquote"
105
+ ]);
106
+ FRONTMATTER_TRANSLATABLE_FIELDS = [
107
+ "title",
108
+ "description",
109
+ "nav_title",
110
+ "related.title",
111
+ "related.description"
112
+ ];
113
+ }
114
+ });
115
+
116
+ export {
117
+ normalize,
118
+ init_normalize,
119
+ FRONTMATTER_TRANSLATABLE_FIELDS,
120
+ parseMdx,
121
+ init_parser
122
+ };