@saykit/config 0.11.0 → 0.12.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,233 @@
1
+ import { sha256 } from "js-sha256";
2
+ import { parse } from "@messageformat/parser";
3
+ import { getDateTimeFormatOptions, parseDateTokens } from "@messageformat/date-skeleton";
4
+ import { getNumberFormatOptions, parseNumberPattern, parseNumberSkeleton } from "@messageformat/number-skeleton";
5
+ // src/features/messages/hash.ts
6
+ function generateHash(input, context) {
7
+ const hasher = sha256.create();
8
+ hasher.update(`${input}\u{001F}${context || ""}`);
9
+ const elements = hasher.toString().match(/.{1,2}/g)?.map((b) => parseInt(b, 16)) || [];
10
+ const bytes = Uint8Array.from(elements);
11
+ return btoa(String.fromCharCode(...bytes)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "").slice(0, 6);
12
+ }
13
+ // src/features/messages/styles.ts
14
+ const ARGUMENT_STYLES = {
15
+ number: ["integer", "percent"],
16
+ date: [
17
+ "short",
18
+ "medium",
19
+ "long",
20
+ "full"
21
+ ],
22
+ time: [
23
+ "short",
24
+ "medium",
25
+ "long",
26
+ "full"
27
+ ]
28
+ };
29
+ const ARGUMENT_TYPES = Object.keys(ARGUMENT_STYLES);
30
+ function isArgumentType(kind) {
31
+ return Object.hasOwn(ARGUMENT_STYLES, kind);
32
+ }
33
+ var StyleError = class extends Error {};
34
+ const SKELETON = "::";
35
+ const LITERAL_STYLE_PATTERN = /^[^{}\r\n]*[#0][^{}\r\n]*$/;
36
+ const DATE_STYLES = {
37
+ short: {
38
+ year: "numeric",
39
+ month: "numeric",
40
+ day: "numeric"
41
+ },
42
+ medium: {
43
+ year: "numeric",
44
+ month: "short",
45
+ day: "numeric"
46
+ },
47
+ long: {
48
+ year: "numeric",
49
+ month: "long",
50
+ day: "numeric"
51
+ },
52
+ full: {
53
+ year: "numeric",
54
+ month: "long",
55
+ day: "numeric",
56
+ weekday: "long"
57
+ }
58
+ };
59
+ const TIME_STYLES = {
60
+ short: {
61
+ hour: "numeric",
62
+ minute: "numeric"
63
+ },
64
+ medium: {
65
+ hour: "numeric",
66
+ minute: "numeric",
67
+ second: "numeric"
68
+ },
69
+ long: {
70
+ hour: "numeric",
71
+ minute: "numeric",
72
+ second: "numeric",
73
+ timeZoneName: "short"
74
+ },
75
+ full: {
76
+ hour: "numeric",
77
+ minute: "numeric",
78
+ second: "numeric",
79
+ timeZoneName: "long"
80
+ }
81
+ };
82
+ function dateTimeStyle(kind, style) {
83
+ const named = kind === "date" ? DATE_STYLES : TIME_STYLES;
84
+ if (style.startsWith(SKELETON)) {
85
+ const errors = [];
86
+ const tokens = parseDateTokens(style.slice(2));
87
+ const opt = getDateTimeFormatOptions(tokens, (_type, message) => errors.push(message));
88
+ if (errors.length > 0) throw new StyleError(errors[0]);
89
+ if (Object.keys(opt).length === 0) throw new StyleError("it names no fields");
90
+ return opt;
91
+ }
92
+ if (style === "") return named.medium;
93
+ if (Object.hasOwn(named, style)) return named[style];
94
+ throw new StyleError(`Unsupported ${kind} style ${style}`);
95
+ }
96
+ function numberStyle(style) {
97
+ if (style === "") return {};
98
+ if (style === "integer") return { maximumFractionDigits: 0 };
99
+ if (style === "percent") return { style: "percent" };
100
+ if (style === SKELETON) throw new StyleError("it names no fields");
101
+ const errors = [];
102
+ const onError = (error) => errors.push(String(error));
103
+ const skeleton = style.startsWith(SKELETON) ? parseNumberSkeleton(style.slice(2), onError) : parseNumberPattern(style, "XXX", onError);
104
+ let scale;
105
+ const opt = getNumberFormatOptions(skeleton, (stem, option) => {
106
+ if (stem === "scale") scale = Number(option);
107
+ else errors.push(`unsupported stem '${stem}'`);
108
+ });
109
+ if (errors.length > 0) throw new StyleError(errors[0]);
110
+ return scale === void 0 ? opt : {
111
+ ...opt,
112
+ scale
113
+ };
114
+ }
115
+ function validateArgumentStyle(type, style) {
116
+ const named = ARGUMENT_STYLES[type];
117
+ if (named.includes(style)) return;
118
+ const skeleton = style.startsWith(SKELETON);
119
+ if (skeleton || type === "number" && LITERAL_STYLE_PATTERN.test(style)) try {
120
+ if (type === "number") numberStyle(style);
121
+ else dateTimeStyle(type, style);
122
+ return;
123
+ } catch (error) {
124
+ if (!(error instanceof StyleError)) throw error;
125
+ throw new Error(`Invalid ${type} ${skeleton ? "skeleton" : "pattern"} '${style}': ${error.message}`);
126
+ }
127
+ const expected = named.map((s) => `'${s}'`).join(", ");
128
+ throw new Error(`Invalid ${type} style '${style}', expected ${expected}, or a skeleton such as ` + (type === "number" ? "::currency/EUR" : "::yyyyMMdd") + (type === "number" ? ", or a literal number pattern such as #,##0.00" : ""));
129
+ }
130
+ // src/features/messages/compile.ts
131
+ const Kind = {
132
+ Value: 0,
133
+ Number: 1,
134
+ DateTime: 2,
135
+ Plural: 3,
136
+ Ordinal: 4,
137
+ Select: 5,
138
+ Hash: 6
139
+ };
140
+ const EXACT = /^=\d+$/;
141
+ function key(argument) {
142
+ return `_${argument}`;
143
+ }
144
+ function concat(nodes) {
145
+ if (nodes.length === 0) return "";
146
+ if (nodes.length === 1) return nodes[0];
147
+ return nodes;
148
+ }
149
+ function compileMessage(icu) {
150
+ function argument(token) {
151
+ const value = key(token.arg);
152
+ let style = "";
153
+ for (const part of token.param ?? []) {
154
+ if (part.type !== "content") throw new Error(`Unsupported style part: ${part.type}`);
155
+ style += part.value;
156
+ }
157
+ style = style.trim();
158
+ const resolve = (read, fallback) => {
159
+ try {
160
+ return read(style);
161
+ } catch (error) {
162
+ if (!(error instanceof StyleError)) throw error;
163
+ return fallback();
164
+ }
165
+ };
166
+ switch (token.key) {
167
+ case "date":
168
+ case "time": {
169
+ const kind = token.key;
170
+ const options = resolve((s) => dateTimeStyle(kind, s), () => dateTimeStyle(kind, ""));
171
+ return [
172
+ Kind.DateTime,
173
+ value,
174
+ options
175
+ ];
176
+ }
177
+ case "number": {
178
+ const { scale, ...options } = resolve(numberStyle, () => ({}));
179
+ if (scale !== void 0) return [
180
+ Kind.Number,
181
+ value,
182
+ options,
183
+ scale
184
+ ];
185
+ return Object.keys(options).length === 0 ? [Kind.Number, value] : [
186
+ Kind.Number,
187
+ value,
188
+ options
189
+ ];
190
+ }
191
+ default: return [Kind.Value, value];
192
+ }
193
+ }
194
+ function choice(token) {
195
+ const value = key(token.arg);
196
+ const cases = Object.create(null);
197
+ for (const branch of token.cases) {
198
+ const key = EXACT.test(branch.key) ? `=${Number(branch.key.slice(1))}` : branch.key;
199
+ if (!Object.hasOwn(cases, key)) cases[key] = pattern(branch.tokens);
200
+ }
201
+ if (token.type === "select") return [
202
+ Kind.Select,
203
+ value,
204
+ cases
205
+ ];
206
+ const kind = token.type === "selectordinal" ? Kind.Ordinal : Kind.Plural;
207
+ const offset = token.pluralOffset ?? 0;
208
+ return offset === 0 ? [
209
+ kind,
210
+ value,
211
+ cases
212
+ ] : [
213
+ kind,
214
+ value,
215
+ cases,
216
+ offset
217
+ ];
218
+ }
219
+ function fragment(token) {
220
+ switch (token.type) {
221
+ case "content": return token.value;
222
+ case "argument": return [Kind.Value, key(token.arg)];
223
+ case "function": return argument(token);
224
+ case "octothorpe": return [Kind.Hash];
225
+ default: return choice(token);
226
+ }
227
+ }
228
+ function pattern(tokens) {
229
+ return concat(tokens.map(fragment));
230
+ }
231
+ return pattern(parse(icu));
232
+ }
233
+ export { dateTimeStyle as a, validateArgumentStyle as c, StyleError as i, generateHash as l, ARGUMENT_STYLES as n, isArgumentType as o, ARGUMENT_TYPES as r, numberStyle as s, compileMessage as t };
@@ -0,0 +1,182 @@
1
+ const require_compile = require("./compile-BrwRUqtQ.cjs");
2
+ let node_fs_promises = require("node:fs/promises");
3
+ let node_path = require("node:path");
4
+ // src/features/catalogue/merge.ts
5
+ function mergeUnique(...items) {
6
+ return Array.from(new Set(items.flat()));
7
+ }
8
+ function getMessageKey(message) {
9
+ return message.id ?? require_compile.generateHash(message.message, message.context);
10
+ }
11
+ function mergeExtractedMessages(messages) {
12
+ const mergedMessages = messages.reduce((map, message) => {
13
+ const key = getMessageKey(message);
14
+ const existing = map.get(key) ?? message;
15
+ map.set(key, {
16
+ ...existing,
17
+ comments: mergeUnique(...existing.comments, ...message.comments),
18
+ references: mergeUnique(...existing.references, ...message.references)
19
+ });
20
+ return map;
21
+ }, /* @__PURE__ */ new Map());
22
+ return Array.from(mergedMessages.values());
23
+ }
24
+ function pruneLocaleMessages(existingMessages, sourceMessages) {
25
+ const sourceKeys = new Set(sourceMessages.map(getMessageKey));
26
+ return existingMessages.filter((message) => sourceKeys.has(getMessageKey(message)) && Boolean(message.translation));
27
+ }
28
+ // src/features/catalogue/path.ts
29
+ function expandBucketOutputPath(bucket, locale, extension = bucket.formatter.extension) {
30
+ const outputMessageTemplate = bucket.output.replaceAll("{locale}", locale).replaceAll("{extension}", extension.slice(1));
31
+ return (0, node_path.resolve)(outputMessageTemplate);
32
+ }
33
+ // src/features/catalogue/storage.ts
34
+ async function readCatalogueMessages(bucket, locale, path = expandBucketOutputPath(bucket, locale)) {
35
+ const content = await (0, node_fs_promises.readFile)(path, "utf8").catch(() => "");
36
+ if (!content) return [];
37
+ return bucket.formatter.parse(content);
38
+ }
39
+ async function writeCatalogueMessages(bucket, locale, messages, path = expandBucketOutputPath(bucket, locale)) {
40
+ const existingContent = await (0, node_fs_promises.readFile)(path, "utf8").catch(() => void 0);
41
+ const catalogueContent = bucket.formatter.stringify(messages, {
42
+ locale,
43
+ existingContent
44
+ });
45
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(path), { recursive: true });
46
+ await (0, node_fs_promises.writeFile)(path, catalogueContent);
47
+ }
48
+ // src/features/catalogue/record.ts
49
+ function resolveFallbackChain(config, locale) {
50
+ const source = config.locales[0];
51
+ const configured = config.fallbackLocales?.[locale];
52
+ const fallbacks = configured ? Array.isArray(configured) ? configured : [configured] : [];
53
+ return Array.from(/* @__PURE__ */ new Set([
54
+ locale,
55
+ ...fallbacks,
56
+ source
57
+ ]));
58
+ }
59
+ function resolveCatalogueSources(config, bucket, path) {
60
+ const resolved = (0, node_path.resolve)(path);
61
+ const locale = config.locales.find((l) => expandBucketOutputPath(bucket, l) === resolved);
62
+ return {
63
+ locale,
64
+ sources: locale ? resolveFallbackChain(config, locale).map((l) => expandBucketOutputPath(bucket, l)) : [resolved]
65
+ };
66
+ }
67
+ function assembleCatalogueRecord(bucket, contents) {
68
+ const record = {};
69
+ for (const content of [...contents].reverse()) {
70
+ if (!content) continue;
71
+ for (const message of bucket.formatter.parse(content)) {
72
+ const key = message.id || require_compile.generateHash(message.message, message.context);
73
+ if (message.translation) {
74
+ record[key] = message.translation;
75
+ continue;
76
+ }
77
+ if (!record[key] && message.message) record[key] = message.message;
78
+ }
79
+ }
80
+ return record;
81
+ }
82
+ // src/features/catalogue/emit.ts
83
+ const DECLARATION_CONTENT = `
84
+ import type { Message } from 'saykit';
85
+
86
+ declare const messages: Record<string, Message>;
87
+ export default messages;
88
+ `.trimStart();
89
+ function modulePathFor(bucket, locale) {
90
+ const catalogue = (0, node_path.resolve)(expandBucketOutputPath(bucket, locale));
91
+ const { dir, name } = (0, node_path.parse)(catalogue);
92
+ const path = (0, node_path.resolve)(dir, `${name}.js`);
93
+ if (path === catalogue) throw new Error(`Catalogue ${catalogue} is where its compiled module would be written. Use a formatter whose extension is not '.js'`);
94
+ return path;
95
+ }
96
+ function toSource(value) {
97
+ return JSON.stringify(value).replace(/([{,])"__proto__":/g, "$1[\"__proto__\"]:");
98
+ }
99
+ function generateCatalogueModule(record) {
100
+ return `// Generated by saykit. Do not edit.
101
+ export default {\n${Object.entries(record).map(([id, icu]) => {
102
+ const message = require_compile.compileMessage(icu);
103
+ return `${icu.split(/\r\n|[\n\r\u2028\u2029]/).map((line) => ` // ${line}`).join("\n")}\n ${id === "__proto__" ? "[\"__proto__\"]" : JSON.stringify(id)}: ${toSource(message)},`;
104
+ }).join("\n\n")}\n};\n`;
105
+ }
106
+ async function emitCatalogueModule(config, bucket, locale) {
107
+ const sources = resolveFallbackChain(config, locale).map((l) => expandBucketOutputPath(bucket, l));
108
+ const record = assembleCatalogueRecord(bucket, await Promise.all(sources.map((source) => (0, node_fs_promises.readFile)(source, "utf8").catch(() => ""))));
109
+ const path = modulePathFor(bucket, locale);
110
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(path), { recursive: true });
111
+ await Promise.all([(0, node_fs_promises.writeFile)(path, generateCatalogueModule(record)), (0, node_fs_promises.writeFile)(path.replace(/\.js$/, ".d.ts"), DECLARATION_CONTENT)]);
112
+ return {
113
+ path,
114
+ count: Object.keys(record).length
115
+ };
116
+ }
117
+ Object.defineProperty(exports, "assembleCatalogueRecord", {
118
+ enumerable: true,
119
+ get: function() {
120
+ return assembleCatalogueRecord;
121
+ }
122
+ });
123
+ Object.defineProperty(exports, "emitCatalogueModule", {
124
+ enumerable: true,
125
+ get: function() {
126
+ return emitCatalogueModule;
127
+ }
128
+ });
129
+ Object.defineProperty(exports, "expandBucketOutputPath", {
130
+ enumerable: true,
131
+ get: function() {
132
+ return expandBucketOutputPath;
133
+ }
134
+ });
135
+ Object.defineProperty(exports, "generateCatalogueModule", {
136
+ enumerable: true,
137
+ get: function() {
138
+ return generateCatalogueModule;
139
+ }
140
+ });
141
+ Object.defineProperty(exports, "mergeExtractedMessages", {
142
+ enumerable: true,
143
+ get: function() {
144
+ return mergeExtractedMessages;
145
+ }
146
+ });
147
+ Object.defineProperty(exports, "modulePathFor", {
148
+ enumerable: true,
149
+ get: function() {
150
+ return modulePathFor;
151
+ }
152
+ });
153
+ Object.defineProperty(exports, "pruneLocaleMessages", {
154
+ enumerable: true,
155
+ get: function() {
156
+ return pruneLocaleMessages;
157
+ }
158
+ });
159
+ Object.defineProperty(exports, "readCatalogueMessages", {
160
+ enumerable: true,
161
+ get: function() {
162
+ return readCatalogueMessages;
163
+ }
164
+ });
165
+ Object.defineProperty(exports, "resolveCatalogueSources", {
166
+ enumerable: true,
167
+ get: function() {
168
+ return resolveCatalogueSources;
169
+ }
170
+ });
171
+ Object.defineProperty(exports, "resolveFallbackChain", {
172
+ enumerable: true,
173
+ get: function() {
174
+ return resolveFallbackChain;
175
+ }
176
+ });
177
+ Object.defineProperty(exports, "writeCatalogueMessages", {
178
+ enumerable: true,
179
+ get: function() {
180
+ return writeCatalogueMessages;
181
+ }
182
+ });
@@ -0,0 +1,117 @@
1
+ import { l as generateHash, t as compileMessage } from "./compile-VUAk0xEx.mjs";
2
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import { dirname, parse, resolve } from "node:path";
4
+ // src/features/catalogue/merge.ts
5
+ function mergeUnique(...items) {
6
+ return Array.from(new Set(items.flat()));
7
+ }
8
+ function getMessageKey(message) {
9
+ return message.id ?? generateHash(message.message, message.context);
10
+ }
11
+ function mergeExtractedMessages(messages) {
12
+ const mergedMessages = messages.reduce((map, message) => {
13
+ const key = getMessageKey(message);
14
+ const existing = map.get(key) ?? message;
15
+ map.set(key, {
16
+ ...existing,
17
+ comments: mergeUnique(...existing.comments, ...message.comments),
18
+ references: mergeUnique(...existing.references, ...message.references)
19
+ });
20
+ return map;
21
+ }, /* @__PURE__ */ new Map());
22
+ return Array.from(mergedMessages.values());
23
+ }
24
+ function pruneLocaleMessages(existingMessages, sourceMessages) {
25
+ const sourceKeys = new Set(sourceMessages.map(getMessageKey));
26
+ return existingMessages.filter((message) => sourceKeys.has(getMessageKey(message)) && Boolean(message.translation));
27
+ }
28
+ // src/features/catalogue/path.ts
29
+ function expandBucketOutputPath(bucket, locale, extension = bucket.formatter.extension) {
30
+ const outputMessageTemplate = bucket.output.replaceAll("{locale}", locale).replaceAll("{extension}", extension.slice(1));
31
+ return resolve(outputMessageTemplate);
32
+ }
33
+ // src/features/catalogue/storage.ts
34
+ async function readCatalogueMessages(bucket, locale, path = expandBucketOutputPath(bucket, locale)) {
35
+ const content = await readFile(path, "utf8").catch(() => "");
36
+ if (!content) return [];
37
+ return bucket.formatter.parse(content);
38
+ }
39
+ async function writeCatalogueMessages(bucket, locale, messages, path = expandBucketOutputPath(bucket, locale)) {
40
+ const existingContent = await readFile(path, "utf8").catch(() => void 0);
41
+ const catalogueContent = bucket.formatter.stringify(messages, {
42
+ locale,
43
+ existingContent
44
+ });
45
+ await mkdir(dirname(path), { recursive: true });
46
+ await writeFile(path, catalogueContent);
47
+ }
48
+ // src/features/catalogue/record.ts
49
+ function resolveFallbackChain(config, locale) {
50
+ const source = config.locales[0];
51
+ const configured = config.fallbackLocales?.[locale];
52
+ const fallbacks = configured ? Array.isArray(configured) ? configured : [configured] : [];
53
+ return Array.from(/* @__PURE__ */ new Set([
54
+ locale,
55
+ ...fallbacks,
56
+ source
57
+ ]));
58
+ }
59
+ function resolveCatalogueSources(config, bucket, path) {
60
+ const resolved = resolve(path);
61
+ const locale = config.locales.find((l) => expandBucketOutputPath(bucket, l) === resolved);
62
+ return {
63
+ locale,
64
+ sources: locale ? resolveFallbackChain(config, locale).map((l) => expandBucketOutputPath(bucket, l)) : [resolved]
65
+ };
66
+ }
67
+ function assembleCatalogueRecord(bucket, contents) {
68
+ const record = {};
69
+ for (const content of [...contents].reverse()) {
70
+ if (!content) continue;
71
+ for (const message of bucket.formatter.parse(content)) {
72
+ const key = message.id || generateHash(message.message, message.context);
73
+ if (message.translation) {
74
+ record[key] = message.translation;
75
+ continue;
76
+ }
77
+ if (!record[key] && message.message) record[key] = message.message;
78
+ }
79
+ }
80
+ return record;
81
+ }
82
+ // src/features/catalogue/emit.ts
83
+ const DECLARATION_CONTENT = `
84
+ import type { Message } from 'saykit';
85
+
86
+ declare const messages: Record<string, Message>;
87
+ export default messages;
88
+ `.trimStart();
89
+ function modulePathFor(bucket, locale) {
90
+ const catalogue = resolve(expandBucketOutputPath(bucket, locale));
91
+ const { dir, name } = parse(catalogue);
92
+ const path = resolve(dir, `${name}.js`);
93
+ if (path === catalogue) throw new Error(`Catalogue ${catalogue} is where its compiled module would be written. Use a formatter whose extension is not '.js'`);
94
+ return path;
95
+ }
96
+ function toSource(value) {
97
+ return JSON.stringify(value).replace(/([{,])"__proto__":/g, "$1[\"__proto__\"]:");
98
+ }
99
+ function generateCatalogueModule(record) {
100
+ return `// Generated by saykit. Do not edit.
101
+ export default {\n${Object.entries(record).map(([id, icu]) => {
102
+ const message = compileMessage(icu);
103
+ return `${icu.split(/\r\n|[\n\r\u2028\u2029]/).map((line) => ` // ${line}`).join("\n")}\n ${id === "__proto__" ? "[\"__proto__\"]" : JSON.stringify(id)}: ${toSource(message)},`;
104
+ }).join("\n\n")}\n};\n`;
105
+ }
106
+ async function emitCatalogueModule(config, bucket, locale) {
107
+ const sources = resolveFallbackChain(config, locale).map((l) => expandBucketOutputPath(bucket, l));
108
+ const record = assembleCatalogueRecord(bucket, await Promise.all(sources.map((source) => readFile(source, "utf8").catch(() => ""))));
109
+ const path = modulePathFor(bucket, locale);
110
+ await mkdir(dirname(path), { recursive: true });
111
+ await Promise.all([writeFile(path, generateCatalogueModule(record)), writeFile(path.replace(/\.js$/, ".d.ts"), DECLARATION_CONTENT)]);
112
+ return {
113
+ path,
114
+ count: Object.keys(record).length
115
+ };
116
+ }
117
+ export { resolveCatalogueSources as a, writeCatalogueMessages as c, pruneLocaleMessages as d, assembleCatalogueRecord as i, expandBucketOutputPath as l, generateCatalogueModule as n, resolveFallbackChain as o, modulePathFor as r, readCatalogueMessages as s, emitCatalogueModule as t, mergeExtractedMessages as u };
@@ -1,48 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_hash = require("../../hash-51ce8YiG.cjs");
3
- const require_storage = require("../../storage-DSdC-TYq.cjs");
4
- let node_path = require("node:path");
5
- //#region src/features/catalogue/record.ts
6
- function resolveFallbackChain(config, locale) {
7
- const source = config.locales[0];
8
- const configured = config.fallbackLocales?.[locale];
9
- const fallbacks = configured ? Array.isArray(configured) ? configured : [configured] : [];
10
- return Array.from(/* @__PURE__ */ new Set([
11
- locale,
12
- ...fallbacks,
13
- source
14
- ]));
15
- }
16
- function resolveCatalogueSources(config, bucket, path) {
17
- const resolved = (0, node_path.resolve)(path);
18
- const locale = config.locales.find((l) => require_storage.expandBucketOutputPath(bucket, l) === resolved);
19
- return {
20
- locale,
21
- sources: locale ? resolveFallbackChain(config, locale).map((l) => require_storage.expandBucketOutputPath(bucket, l)) : [resolved]
22
- };
23
- }
24
- function assembleCatalogueRecord(bucket, contents) {
25
- const record = {};
26
- for (const content of [...contents].reverse()) {
27
- if (!content) continue;
28
- for (const message of bucket.formatter.parse(content)) {
29
- const key = message.id || require_hash.generateHash(message.message, message.context);
30
- if (message.translation) {
31
- record[key] = message.translation;
32
- continue;
33
- }
34
- if (!record[key] && message.message) record[key] = message.message;
35
- }
36
- }
37
- return record;
38
- }
39
- //#endregion
40
- exports.assembleCatalogueRecord = assembleCatalogueRecord;
41
- exports.declarationPathFor = require_storage.declarationPathFor;
42
- exports.expandBucketOutputPath = require_storage.expandBucketOutputPath;
43
- exports.mergeExtractedMessages = require_storage.mergeExtractedMessages;
44
- exports.pruneLocaleMessages = require_storage.pruneLocaleMessages;
45
- exports.readCatalogueMessages = require_storage.readCatalogueMessages;
46
- exports.resolveCatalogueSources = resolveCatalogueSources;
47
- exports.resolveFallbackChain = resolveFallbackChain;
48
- exports.writeCatalogueMessages = require_storage.writeCatalogueMessages;
2
+ const require_emit = require("../../emit-NFgnvdzK.cjs");
3
+ exports.assembleCatalogueRecord = require_emit.assembleCatalogueRecord;
4
+ exports.emitCatalogueModule = require_emit.emitCatalogueModule;
5
+ exports.expandBucketOutputPath = require_emit.expandBucketOutputPath;
6
+ exports.generateCatalogueModule = require_emit.generateCatalogueModule;
7
+ exports.mergeExtractedMessages = require_emit.mergeExtractedMessages;
8
+ exports.modulePathFor = require_emit.modulePathFor;
9
+ exports.pruneLocaleMessages = require_emit.pruneLocaleMessages;
10
+ exports.readCatalogueMessages = require_emit.readCatalogueMessages;
11
+ exports.resolveCatalogueSources = require_emit.resolveCatalogueSources;
12
+ exports.resolveFallbackChain = require_emit.resolveFallbackChain;
13
+ exports.writeCatalogueMessages = require_emit.writeCatalogueMessages;