@saykit/config 0.11.1 → 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.
- package/README.md +6 -4
- package/dist/commands/index.cjs +59 -42
- package/dist/commands/index.mjs +51 -34
- package/dist/compile-BrwRUqtQ.cjs +286 -0
- package/dist/compile-VUAk0xEx.mjs +233 -0
- package/dist/emit-NFgnvdzK.cjs +182 -0
- package/dist/emit-q78c-G_t.mjs +117 -0
- package/dist/features/catalogue/index.cjs +12 -47
- package/dist/features/catalogue/index.d.cts +38 -33
- package/dist/features/catalogue/index.d.mts +38 -33
- package/dist/features/catalogue/index.mjs +1 -39
- package/dist/features/loader/index.cjs +1 -1
- package/dist/features/loader/index.d.cts +3 -6
- package/dist/features/loader/index.d.mts +3 -6
- package/dist/features/loader/index.mjs +1 -2
- package/dist/features/messages/index.cjs +15 -65
- package/dist/features/messages/index.d.cts +109 -54
- package/dist/features/messages/index.d.mts +109 -54
- package/dist/features/messages/index.mjs +6 -60
- package/dist/index.cjs +3 -6
- package/dist/index.d.cts +19 -21
- package/dist/index.d.mts +19 -21
- package/dist/index.mjs +1 -3
- package/dist/{loader-C6XxYhMl.mjs → loader-1PBbw7yb.mjs} +3 -6
- package/dist/{loader-XE7SprlF.cjs → loader-V92j1gfD.cjs} +8 -11
- package/dist/{shapes-CRlXtss0.d.cts → shapes-Dq0aJdsn.d.cts} +50 -52
- package/dist/{shapes-CRlXtss0.d.mts → shapes-Dq0aJdsn.d.mts} +50 -52
- package/package.json +10 -5
- package/dist/hash-51ce8YiG.cjs +0 -16
- package/dist/hash-DvzpieJD.mjs +0 -11
- package/dist/storage-8485YdBh.mjs +0 -59
- package/dist/storage-DSdC-TYq.cjs +0 -94
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import picomatch from "picomatch";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
//#region src/shapes.d.ts
|
|
4
3
|
declare const Message: z.ZodObject<{
|
|
5
4
|
message: z.ZodString;
|
|
6
5
|
translation: z.ZodOptional<z.ZodString>;
|
|
@@ -79,11 +78,11 @@ declare const Bucket: z.ZodPipe<z.ZodObject<{
|
|
|
79
78
|
match: (id: string) => boolean;
|
|
80
79
|
extract: (code: string, id: string) => {
|
|
81
80
|
message: string;
|
|
82
|
-
comments: string[];
|
|
83
|
-
references: string[];
|
|
84
81
|
translation?: string | undefined;
|
|
85
82
|
id?: string | undefined;
|
|
86
83
|
context?: string | undefined;
|
|
84
|
+
comments: string[];
|
|
85
|
+
references: string[];
|
|
87
86
|
}[];
|
|
88
87
|
transform: (code: string, id: string) => string;
|
|
89
88
|
}, {
|
|
@@ -92,19 +91,8 @@ declare const Bucket: z.ZodPipe<z.ZodObject<{
|
|
|
92
91
|
transform: (code: string, id: string) => string;
|
|
93
92
|
}[]>>;
|
|
94
93
|
}, z.core.$strip>, z.ZodTransform<{
|
|
95
|
-
messages: {
|
|
96
|
-
message: string;
|
|
97
|
-
comments: string[];
|
|
98
|
-
references: string[];
|
|
99
|
-
translation?: string | undefined;
|
|
100
|
-
id?: string | undefined;
|
|
101
|
-
context?: string | undefined;
|
|
102
|
-
}[];
|
|
103
|
-
match: (id: string) => boolean;
|
|
104
|
-
output: `${string}{locale}${string}.{extension}` & {
|
|
105
|
-
match: picomatch.Matcher;
|
|
106
|
-
};
|
|
107
94
|
include: string[];
|
|
95
|
+
exclude?: string[] | undefined;
|
|
108
96
|
formatter: {
|
|
109
97
|
extension: `.${string}`;
|
|
110
98
|
parse: (content: string) => Message[];
|
|
@@ -117,18 +105,35 @@ declare const Bucket: z.ZodPipe<z.ZodObject<{
|
|
|
117
105
|
match: (id: string) => boolean;
|
|
118
106
|
extract: (code: string, id: string) => {
|
|
119
107
|
message: string;
|
|
120
|
-
comments: string[];
|
|
121
|
-
references: string[];
|
|
122
108
|
translation?: string | undefined;
|
|
123
109
|
id?: string | undefined;
|
|
124
110
|
context?: string | undefined;
|
|
111
|
+
comments: string[];
|
|
112
|
+
references: string[];
|
|
125
113
|
}[];
|
|
126
114
|
transform: (code: string, id: string) => string;
|
|
127
115
|
};
|
|
128
|
-
|
|
116
|
+
messages: {
|
|
117
|
+
message: string;
|
|
118
|
+
translation?: string | undefined;
|
|
119
|
+
id?: string | undefined;
|
|
120
|
+
context?: string | undefined;
|
|
121
|
+
comments: string[];
|
|
122
|
+
references: string[];
|
|
123
|
+
}[];
|
|
124
|
+
match: (id: string) => boolean;
|
|
125
|
+
output: `${string}{locale}${string}.{extension}` & {
|
|
126
|
+
match: picomatch.Matcher;
|
|
127
|
+
};
|
|
129
128
|
}, {
|
|
130
129
|
include: string[];
|
|
130
|
+
exclude?: string[] | undefined;
|
|
131
131
|
output: `${string}{locale}${string}.{extension}`;
|
|
132
|
+
messages?: Record<string, string | {
|
|
133
|
+
message: string;
|
|
134
|
+
context?: string | undefined;
|
|
135
|
+
comments?: string[] | undefined;
|
|
136
|
+
}> | undefined;
|
|
132
137
|
formatter: {
|
|
133
138
|
extension: `.${string}`;
|
|
134
139
|
parse: (content: string) => Message[];
|
|
@@ -141,20 +146,14 @@ declare const Bucket: z.ZodPipe<z.ZodObject<{
|
|
|
141
146
|
match: (id: string) => boolean;
|
|
142
147
|
extract: (code: string, id: string) => {
|
|
143
148
|
message: string;
|
|
144
|
-
comments: string[];
|
|
145
|
-
references: string[];
|
|
146
149
|
translation?: string | undefined;
|
|
147
150
|
id?: string | undefined;
|
|
148
151
|
context?: string | undefined;
|
|
152
|
+
comments: string[];
|
|
153
|
+
references: string[];
|
|
149
154
|
}[];
|
|
150
155
|
transform: (code: string, id: string) => string;
|
|
151
156
|
};
|
|
152
|
-
exclude?: string[] | undefined;
|
|
153
|
-
messages?: Record<string, string | {
|
|
154
|
-
message: string;
|
|
155
|
-
context?: string | undefined;
|
|
156
|
-
comments?: string[] | undefined;
|
|
157
|
-
}> | undefined;
|
|
158
157
|
}>>;
|
|
159
158
|
type Bucket = z.infer<typeof Bucket>;
|
|
160
159
|
declare const Config: z.ZodObject<{
|
|
@@ -200,11 +199,11 @@ declare const Config: z.ZodObject<{
|
|
|
200
199
|
match: (id: string) => boolean;
|
|
201
200
|
extract: (code: string, id: string) => {
|
|
202
201
|
message: string;
|
|
203
|
-
comments: string[];
|
|
204
|
-
references: string[];
|
|
205
202
|
translation?: string | undefined;
|
|
206
203
|
id?: string | undefined;
|
|
207
204
|
context?: string | undefined;
|
|
205
|
+
comments: string[];
|
|
206
|
+
references: string[];
|
|
208
207
|
}[];
|
|
209
208
|
transform: (code: string, id: string) => string;
|
|
210
209
|
}, {
|
|
@@ -213,19 +212,8 @@ declare const Config: z.ZodObject<{
|
|
|
213
212
|
transform: (code: string, id: string) => string;
|
|
214
213
|
}[]>>;
|
|
215
214
|
}, z.core.$strip>, z.ZodTransform<{
|
|
216
|
-
messages: {
|
|
217
|
-
message: string;
|
|
218
|
-
comments: string[];
|
|
219
|
-
references: string[];
|
|
220
|
-
translation?: string | undefined;
|
|
221
|
-
id?: string | undefined;
|
|
222
|
-
context?: string | undefined;
|
|
223
|
-
}[];
|
|
224
|
-
match: (id: string) => boolean;
|
|
225
|
-
output: `${string}{locale}${string}.{extension}` & {
|
|
226
|
-
match: picomatch.Matcher;
|
|
227
|
-
};
|
|
228
215
|
include: string[];
|
|
216
|
+
exclude?: string[] | undefined;
|
|
229
217
|
formatter: {
|
|
230
218
|
extension: `.${string}`;
|
|
231
219
|
parse: (content: string) => Message[];
|
|
@@ -238,18 +226,35 @@ declare const Config: z.ZodObject<{
|
|
|
238
226
|
match: (id: string) => boolean;
|
|
239
227
|
extract: (code: string, id: string) => {
|
|
240
228
|
message: string;
|
|
241
|
-
comments: string[];
|
|
242
|
-
references: string[];
|
|
243
229
|
translation?: string | undefined;
|
|
244
230
|
id?: string | undefined;
|
|
245
231
|
context?: string | undefined;
|
|
232
|
+
comments: string[];
|
|
233
|
+
references: string[];
|
|
246
234
|
}[];
|
|
247
235
|
transform: (code: string, id: string) => string;
|
|
248
236
|
};
|
|
249
|
-
|
|
237
|
+
messages: {
|
|
238
|
+
message: string;
|
|
239
|
+
translation?: string | undefined;
|
|
240
|
+
id?: string | undefined;
|
|
241
|
+
context?: string | undefined;
|
|
242
|
+
comments: string[];
|
|
243
|
+
references: string[];
|
|
244
|
+
}[];
|
|
245
|
+
match: (id: string) => boolean;
|
|
246
|
+
output: `${string}{locale}${string}.{extension}` & {
|
|
247
|
+
match: picomatch.Matcher;
|
|
248
|
+
};
|
|
250
249
|
}, {
|
|
251
250
|
include: string[];
|
|
251
|
+
exclude?: string[] | undefined;
|
|
252
252
|
output: `${string}{locale}${string}.{extension}`;
|
|
253
|
+
messages?: Record<string, string | {
|
|
254
|
+
message: string;
|
|
255
|
+
context?: string | undefined;
|
|
256
|
+
comments?: string[] | undefined;
|
|
257
|
+
}> | undefined;
|
|
253
258
|
formatter: {
|
|
254
259
|
extension: `.${string}`;
|
|
255
260
|
parse: (content: string) => Message[];
|
|
@@ -262,22 +267,15 @@ declare const Config: z.ZodObject<{
|
|
|
262
267
|
match: (id: string) => boolean;
|
|
263
268
|
extract: (code: string, id: string) => {
|
|
264
269
|
message: string;
|
|
265
|
-
comments: string[];
|
|
266
|
-
references: string[];
|
|
267
270
|
translation?: string | undefined;
|
|
268
271
|
id?: string | undefined;
|
|
269
272
|
context?: string | undefined;
|
|
273
|
+
comments: string[];
|
|
274
|
+
references: string[];
|
|
270
275
|
}[];
|
|
271
276
|
transform: (code: string, id: string) => string;
|
|
272
277
|
};
|
|
273
|
-
exclude?: string[] | undefined;
|
|
274
|
-
messages?: Record<string, string | {
|
|
275
|
-
message: string;
|
|
276
|
-
context?: string | undefined;
|
|
277
|
-
comments?: string[] | undefined;
|
|
278
|
-
}> | undefined;
|
|
279
278
|
}>>>;
|
|
280
279
|
}, z.core.$strip>;
|
|
281
280
|
type Config = z.infer<typeof Config>;
|
|
282
|
-
//#endregion
|
|
283
281
|
export { Message as a, Formatter as i, Config as n, Transformer as o, DeclaredMessage as r, Bucket as t };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import picomatch from "picomatch";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
//#region src/shapes.d.ts
|
|
4
3
|
declare const Message: z.ZodObject<{
|
|
5
4
|
message: z.ZodString;
|
|
6
5
|
translation: z.ZodOptional<z.ZodString>;
|
|
@@ -79,11 +78,11 @@ declare const Bucket: z.ZodPipe<z.ZodObject<{
|
|
|
79
78
|
match: (id: string) => boolean;
|
|
80
79
|
extract: (code: string, id: string) => {
|
|
81
80
|
message: string;
|
|
82
|
-
comments: string[];
|
|
83
|
-
references: string[];
|
|
84
81
|
translation?: string | undefined;
|
|
85
82
|
id?: string | undefined;
|
|
86
83
|
context?: string | undefined;
|
|
84
|
+
comments: string[];
|
|
85
|
+
references: string[];
|
|
87
86
|
}[];
|
|
88
87
|
transform: (code: string, id: string) => string;
|
|
89
88
|
}, {
|
|
@@ -92,19 +91,8 @@ declare const Bucket: z.ZodPipe<z.ZodObject<{
|
|
|
92
91
|
transform: (code: string, id: string) => string;
|
|
93
92
|
}[]>>;
|
|
94
93
|
}, z.core.$strip>, z.ZodTransform<{
|
|
95
|
-
messages: {
|
|
96
|
-
message: string;
|
|
97
|
-
comments: string[];
|
|
98
|
-
references: string[];
|
|
99
|
-
translation?: string | undefined;
|
|
100
|
-
id?: string | undefined;
|
|
101
|
-
context?: string | undefined;
|
|
102
|
-
}[];
|
|
103
|
-
match: (id: string) => boolean;
|
|
104
|
-
output: `${string}{locale}${string}.{extension}` & {
|
|
105
|
-
match: picomatch.Matcher;
|
|
106
|
-
};
|
|
107
94
|
include: string[];
|
|
95
|
+
exclude?: string[] | undefined;
|
|
108
96
|
formatter: {
|
|
109
97
|
extension: `.${string}`;
|
|
110
98
|
parse: (content: string) => Message[];
|
|
@@ -117,18 +105,35 @@ declare const Bucket: z.ZodPipe<z.ZodObject<{
|
|
|
117
105
|
match: (id: string) => boolean;
|
|
118
106
|
extract: (code: string, id: string) => {
|
|
119
107
|
message: string;
|
|
120
|
-
comments: string[];
|
|
121
|
-
references: string[];
|
|
122
108
|
translation?: string | undefined;
|
|
123
109
|
id?: string | undefined;
|
|
124
110
|
context?: string | undefined;
|
|
111
|
+
comments: string[];
|
|
112
|
+
references: string[];
|
|
125
113
|
}[];
|
|
126
114
|
transform: (code: string, id: string) => string;
|
|
127
115
|
};
|
|
128
|
-
|
|
116
|
+
messages: {
|
|
117
|
+
message: string;
|
|
118
|
+
translation?: string | undefined;
|
|
119
|
+
id?: string | undefined;
|
|
120
|
+
context?: string | undefined;
|
|
121
|
+
comments: string[];
|
|
122
|
+
references: string[];
|
|
123
|
+
}[];
|
|
124
|
+
match: (id: string) => boolean;
|
|
125
|
+
output: `${string}{locale}${string}.{extension}` & {
|
|
126
|
+
match: picomatch.Matcher;
|
|
127
|
+
};
|
|
129
128
|
}, {
|
|
130
129
|
include: string[];
|
|
130
|
+
exclude?: string[] | undefined;
|
|
131
131
|
output: `${string}{locale}${string}.{extension}`;
|
|
132
|
+
messages?: Record<string, string | {
|
|
133
|
+
message: string;
|
|
134
|
+
context?: string | undefined;
|
|
135
|
+
comments?: string[] | undefined;
|
|
136
|
+
}> | undefined;
|
|
132
137
|
formatter: {
|
|
133
138
|
extension: `.${string}`;
|
|
134
139
|
parse: (content: string) => Message[];
|
|
@@ -141,20 +146,14 @@ declare const Bucket: z.ZodPipe<z.ZodObject<{
|
|
|
141
146
|
match: (id: string) => boolean;
|
|
142
147
|
extract: (code: string, id: string) => {
|
|
143
148
|
message: string;
|
|
144
|
-
comments: string[];
|
|
145
|
-
references: string[];
|
|
146
149
|
translation?: string | undefined;
|
|
147
150
|
id?: string | undefined;
|
|
148
151
|
context?: string | undefined;
|
|
152
|
+
comments: string[];
|
|
153
|
+
references: string[];
|
|
149
154
|
}[];
|
|
150
155
|
transform: (code: string, id: string) => string;
|
|
151
156
|
};
|
|
152
|
-
exclude?: string[] | undefined;
|
|
153
|
-
messages?: Record<string, string | {
|
|
154
|
-
message: string;
|
|
155
|
-
context?: string | undefined;
|
|
156
|
-
comments?: string[] | undefined;
|
|
157
|
-
}> | undefined;
|
|
158
157
|
}>>;
|
|
159
158
|
type Bucket = z.infer<typeof Bucket>;
|
|
160
159
|
declare const Config: z.ZodObject<{
|
|
@@ -200,11 +199,11 @@ declare const Config: z.ZodObject<{
|
|
|
200
199
|
match: (id: string) => boolean;
|
|
201
200
|
extract: (code: string, id: string) => {
|
|
202
201
|
message: string;
|
|
203
|
-
comments: string[];
|
|
204
|
-
references: string[];
|
|
205
202
|
translation?: string | undefined;
|
|
206
203
|
id?: string | undefined;
|
|
207
204
|
context?: string | undefined;
|
|
205
|
+
comments: string[];
|
|
206
|
+
references: string[];
|
|
208
207
|
}[];
|
|
209
208
|
transform: (code: string, id: string) => string;
|
|
210
209
|
}, {
|
|
@@ -213,19 +212,8 @@ declare const Config: z.ZodObject<{
|
|
|
213
212
|
transform: (code: string, id: string) => string;
|
|
214
213
|
}[]>>;
|
|
215
214
|
}, z.core.$strip>, z.ZodTransform<{
|
|
216
|
-
messages: {
|
|
217
|
-
message: string;
|
|
218
|
-
comments: string[];
|
|
219
|
-
references: string[];
|
|
220
|
-
translation?: string | undefined;
|
|
221
|
-
id?: string | undefined;
|
|
222
|
-
context?: string | undefined;
|
|
223
|
-
}[];
|
|
224
|
-
match: (id: string) => boolean;
|
|
225
|
-
output: `${string}{locale}${string}.{extension}` & {
|
|
226
|
-
match: picomatch.Matcher;
|
|
227
|
-
};
|
|
228
215
|
include: string[];
|
|
216
|
+
exclude?: string[] | undefined;
|
|
229
217
|
formatter: {
|
|
230
218
|
extension: `.${string}`;
|
|
231
219
|
parse: (content: string) => Message[];
|
|
@@ -238,18 +226,35 @@ declare const Config: z.ZodObject<{
|
|
|
238
226
|
match: (id: string) => boolean;
|
|
239
227
|
extract: (code: string, id: string) => {
|
|
240
228
|
message: string;
|
|
241
|
-
comments: string[];
|
|
242
|
-
references: string[];
|
|
243
229
|
translation?: string | undefined;
|
|
244
230
|
id?: string | undefined;
|
|
245
231
|
context?: string | undefined;
|
|
232
|
+
comments: string[];
|
|
233
|
+
references: string[];
|
|
246
234
|
}[];
|
|
247
235
|
transform: (code: string, id: string) => string;
|
|
248
236
|
};
|
|
249
|
-
|
|
237
|
+
messages: {
|
|
238
|
+
message: string;
|
|
239
|
+
translation?: string | undefined;
|
|
240
|
+
id?: string | undefined;
|
|
241
|
+
context?: string | undefined;
|
|
242
|
+
comments: string[];
|
|
243
|
+
references: string[];
|
|
244
|
+
}[];
|
|
245
|
+
match: (id: string) => boolean;
|
|
246
|
+
output: `${string}{locale}${string}.{extension}` & {
|
|
247
|
+
match: picomatch.Matcher;
|
|
248
|
+
};
|
|
250
249
|
}, {
|
|
251
250
|
include: string[];
|
|
251
|
+
exclude?: string[] | undefined;
|
|
252
252
|
output: `${string}{locale}${string}.{extension}`;
|
|
253
|
+
messages?: Record<string, string | {
|
|
254
|
+
message: string;
|
|
255
|
+
context?: string | undefined;
|
|
256
|
+
comments?: string[] | undefined;
|
|
257
|
+
}> | undefined;
|
|
253
258
|
formatter: {
|
|
254
259
|
extension: `.${string}`;
|
|
255
260
|
parse: (content: string) => Message[];
|
|
@@ -262,22 +267,15 @@ declare const Config: z.ZodObject<{
|
|
|
262
267
|
match: (id: string) => boolean;
|
|
263
268
|
extract: (code: string, id: string) => {
|
|
264
269
|
message: string;
|
|
265
|
-
comments: string[];
|
|
266
|
-
references: string[];
|
|
267
270
|
translation?: string | undefined;
|
|
268
271
|
id?: string | undefined;
|
|
269
272
|
context?: string | undefined;
|
|
273
|
+
comments: string[];
|
|
274
|
+
references: string[];
|
|
270
275
|
}[];
|
|
271
276
|
transform: (code: string, id: string) => string;
|
|
272
277
|
};
|
|
273
|
-
exclude?: string[] | undefined;
|
|
274
|
-
messages?: Record<string, string | {
|
|
275
|
-
message: string;
|
|
276
|
-
context?: string | undefined;
|
|
277
|
-
comments?: string[] | undefined;
|
|
278
|
-
}> | undefined;
|
|
279
278
|
}>>>;
|
|
280
279
|
}, z.core.$strip>;
|
|
281
280
|
type Config = z.infer<typeof Config>;
|
|
282
|
-
//#endregion
|
|
283
281
|
export { Message as a, Formatter as i, Config as n, Transformer as o, DeclaredMessage as r, Bucket as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saykit/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "CLI and configuration tooling for saykit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
"!dist/**/*.map"
|
|
27
27
|
],
|
|
28
28
|
"type": "module",
|
|
29
|
+
"imports": {
|
|
30
|
+
"#/*": "./src/*"
|
|
31
|
+
},
|
|
29
32
|
"exports": {
|
|
30
33
|
".": {
|
|
31
34
|
"require": {
|
|
@@ -76,13 +79,15 @@
|
|
|
76
79
|
"@commander-js/extra-typings": "^15.0.0",
|
|
77
80
|
"@messageformat/date-skeleton": "2.0.0-0",
|
|
78
81
|
"@messageformat/number-skeleton": "2.0.0-0",
|
|
82
|
+
"@messageformat/parser": "^5.1.1",
|
|
79
83
|
"commander": "^15.0.0",
|
|
80
|
-
"js-sha256": "^0.
|
|
81
|
-
"picomatch": "^4.0.
|
|
82
|
-
"zod": "^4.
|
|
84
|
+
"js-sha256": "^1.0.0",
|
|
85
|
+
"picomatch": "^4.0.7",
|
|
86
|
+
"zod": "^4.6.7"
|
|
83
87
|
},
|
|
84
88
|
"devDependencies": {
|
|
85
|
-
"@types/picomatch": "^4.0.3"
|
|
89
|
+
"@types/picomatch": "^4.0.3",
|
|
90
|
+
"saykit": "0.12.0"
|
|
86
91
|
},
|
|
87
92
|
"engines": {
|
|
88
93
|
"node": ">=22.18"
|
package/dist/hash-51ce8YiG.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
let js_sha256 = require("js-sha256");
|
|
2
|
-
//#region src/features/messages/hash.ts
|
|
3
|
-
function generateHash(input, context) {
|
|
4
|
-
const hasher = js_sha256.sha256.create();
|
|
5
|
-
hasher.update(`${input}\u{001F}${context || ""}`);
|
|
6
|
-
const elements = hasher.toString().match(/.{1,2}/g)?.map((b) => parseInt(b, 16)) || [];
|
|
7
|
-
const bytes = Uint8Array.from(elements);
|
|
8
|
-
return btoa(String.fromCharCode(...bytes)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "").slice(0, 6);
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
Object.defineProperty(exports, "generateHash", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function() {
|
|
14
|
-
return generateHash;
|
|
15
|
-
}
|
|
16
|
-
});
|
package/dist/hash-DvzpieJD.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { sha256 } from "js-sha256";
|
|
2
|
-
//#region src/features/messages/hash.ts
|
|
3
|
-
function generateHash(input, context) {
|
|
4
|
-
const hasher = sha256.create();
|
|
5
|
-
hasher.update(`${input}\u{001F}${context || ""}`);
|
|
6
|
-
const elements = hasher.toString().match(/.{1,2}/g)?.map((b) => parseInt(b, 16)) || [];
|
|
7
|
-
const bytes = Uint8Array.from(elements);
|
|
8
|
-
return btoa(String.fromCharCode(...bytes)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "").slice(0, 6);
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
export { generateHash as t };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { t as generateHash } from "./hash-DvzpieJD.mjs";
|
|
2
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
-
import { dirname, parse, resolve } from "node:path";
|
|
4
|
-
//#region 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
|
-
//#endregion
|
|
29
|
-
//#region src/features/catalogue/path.ts
|
|
30
|
-
function expandBucketOutputPath(bucket, locale, extension = bucket.formatter.extension) {
|
|
31
|
-
return resolve(bucket.output.replaceAll("{locale}", locale).replaceAll("{extension}", extension.slice(1)));
|
|
32
|
-
}
|
|
33
|
-
function declarationPathFor(cataloguePath) {
|
|
34
|
-
const { dir, name, ext } = parse(cataloguePath);
|
|
35
|
-
return resolve(dir, `${name}.d${ext}.ts`);
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/features/catalogue/storage.ts
|
|
39
|
-
const DECLARATION_CONTENT = `
|
|
40
|
-
declare const messages: Record<string, string>;
|
|
41
|
-
export default messages;
|
|
42
|
-
`.trimStart();
|
|
43
|
-
async function readCatalogueMessages(bucket, locale, path = expandBucketOutputPath(bucket, locale)) {
|
|
44
|
-
const content = await readFile(path, "utf8").catch(() => "");
|
|
45
|
-
if (!content) return [];
|
|
46
|
-
return bucket.formatter.parse(content);
|
|
47
|
-
}
|
|
48
|
-
async function writeCatalogueMessages(bucket, locale, messages, path = expandBucketOutputPath(bucket, locale)) {
|
|
49
|
-
const existingContent = await readFile(path, "utf8").catch(() => void 0);
|
|
50
|
-
const catalogueContent = bucket.formatter.stringify(messages, {
|
|
51
|
-
locale,
|
|
52
|
-
existingContent
|
|
53
|
-
});
|
|
54
|
-
const declarationPath = declarationPathFor(path);
|
|
55
|
-
await mkdir(dirname(path), { recursive: true });
|
|
56
|
-
await Promise.all([writeFile(path, catalogueContent), writeFile(declarationPath, DECLARATION_CONTENT)]);
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
export { mergeExtractedMessages as a, expandBucketOutputPath as i, writeCatalogueMessages as n, pruneLocaleMessages as o, declarationPathFor as r, readCatalogueMessages as t };
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
const require_hash = require("./hash-51ce8YiG.cjs");
|
|
2
|
-
let node_fs_promises = require("node:fs/promises");
|
|
3
|
-
let node_path = require("node:path");
|
|
4
|
-
//#region 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_hash.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
|
-
//#endregion
|
|
29
|
-
//#region src/features/catalogue/path.ts
|
|
30
|
-
function expandBucketOutputPath(bucket, locale, extension = bucket.formatter.extension) {
|
|
31
|
-
return (0, node_path.resolve)(bucket.output.replaceAll("{locale}", locale).replaceAll("{extension}", extension.slice(1)));
|
|
32
|
-
}
|
|
33
|
-
function declarationPathFor(cataloguePath) {
|
|
34
|
-
const { dir, name, ext } = (0, node_path.parse)(cataloguePath);
|
|
35
|
-
return (0, node_path.resolve)(dir, `${name}.d${ext}.ts`);
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/features/catalogue/storage.ts
|
|
39
|
-
const DECLARATION_CONTENT = `
|
|
40
|
-
declare const messages: Record<string, string>;
|
|
41
|
-
export default messages;
|
|
42
|
-
`.trimStart();
|
|
43
|
-
async function readCatalogueMessages(bucket, locale, path = expandBucketOutputPath(bucket, locale)) {
|
|
44
|
-
const content = await (0, node_fs_promises.readFile)(path, "utf8").catch(() => "");
|
|
45
|
-
if (!content) return [];
|
|
46
|
-
return bucket.formatter.parse(content);
|
|
47
|
-
}
|
|
48
|
-
async function writeCatalogueMessages(bucket, locale, messages, path = expandBucketOutputPath(bucket, locale)) {
|
|
49
|
-
const existingContent = await (0, node_fs_promises.readFile)(path, "utf8").catch(() => void 0);
|
|
50
|
-
const catalogueContent = bucket.formatter.stringify(messages, {
|
|
51
|
-
locale,
|
|
52
|
-
existingContent
|
|
53
|
-
});
|
|
54
|
-
const declarationPath = declarationPathFor(path);
|
|
55
|
-
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(path), { recursive: true });
|
|
56
|
-
await Promise.all([(0, node_fs_promises.writeFile)(path, catalogueContent), (0, node_fs_promises.writeFile)(declarationPath, DECLARATION_CONTENT)]);
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
Object.defineProperty(exports, "declarationPathFor", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
get: function() {
|
|
62
|
-
return declarationPathFor;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(exports, "expandBucketOutputPath", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function() {
|
|
68
|
-
return expandBucketOutputPath;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(exports, "mergeExtractedMessages", {
|
|
72
|
-
enumerable: true,
|
|
73
|
-
get: function() {
|
|
74
|
-
return mergeExtractedMessages;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
Object.defineProperty(exports, "pruneLocaleMessages", {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
get: function() {
|
|
80
|
-
return pruneLocaleMessages;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(exports, "readCatalogueMessages", {
|
|
84
|
-
enumerable: true,
|
|
85
|
-
get: function() {
|
|
86
|
-
return readCatalogueMessages;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
Object.defineProperty(exports, "writeCatalogueMessages", {
|
|
90
|
-
enumerable: true,
|
|
91
|
-
get: function() {
|
|
92
|
-
return writeCatalogueMessages;
|
|
93
|
-
}
|
|
94
|
-
});
|