@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.
@@ -1,41 +1,49 @@
1
- //#region src/features/messages/format.d.ts
2
1
  /**
3
- * The ICU argument types a macro can author, and the named styles each accepts.
4
- *
5
- * A style may also be a skeleton, which is where the formats these names have
6
- * no word for live; see {@link validateArgumentStyle}.
2
+ * What each node in a compiled message is, by the number it starts with.
7
3
  *
8
- * `currency` is deliberately absent from `number`: MF1 has nowhere to write the
9
- * code, so `{price, number, currency}` formats as a bare number. Currency
10
- * belongs to a skeleton, `::currency/EUR`, which the formatter does honour.
11
- *
12
- * `spellout`, RBNF `ordinal` and `choice` are absent by decision: the first two
13
- * are ICU4J/ICU4C rule-based formats with no `Intl` equivalent, and the third
14
- * is deprecated in ICU itself in favour of `plural`.
4
+ * The numbers are the format, so a kind is only ever appended, never renumbered or reused.
15
5
  */
16
- declare const ARGUMENT_STYLES: {
17
- readonly number: readonly ["integer", "percent"];
18
- readonly date: readonly ["short", "medium", "long", "full"];
19
- readonly time: readonly ["short", "medium", "long", "full"];
6
+ declare const Kind: {
7
+ readonly Value: 0;
8
+ readonly Number: 1;
9
+ readonly DateTime: 2;
10
+ readonly Plural: 3;
11
+ readonly Ordinal: 4;
12
+ readonly Select: 5;
13
+ readonly Hash: 6;
20
14
  };
21
- type ArgumentType = keyof typeof ARGUMENT_STYLES;
22
- declare const ARGUMENT_TYPES: ArgumentType[];
23
- declare function isArgumentType(kind: string): kind is ArgumentType;
15
+ type Kind = (typeof Kind)[keyof typeof Kind];
24
16
  /**
25
- * Reject an argument style the formatter cannot honour, while the style is
26
- * still attached to a file and a line.
17
+ * A compiled message.
18
+ *
19
+ * The CLI compiles a catalogue to this: strings and arrays, with styles already resolved to
20
+ * `Intl` options. It is plain JSON, so it can cross a server/client boundary.
27
21
  *
28
- * A style is a bare string in the source and in the catalogue, so nothing
29
- * between here and the runtime has an opinion about it. Left unchecked, a typo
30
- * like `{d, date, meduim}` only misformats once it reaches a user.
22
+ * A node is an array starting with its {@link Kind}; an array starting with anything else is a
23
+ * concatenation. Operands are descriptor keys, never nodes. A message with no placeholders is its
24
+ * own string.
25
+ */
26
+ type Message$1 = string | Message$1[] | [typeof Kind.Value, string] | [typeof Kind.Number, string, Intl.NumberFormatOptions?, number?] | [typeof Kind.DateTime, string, Intl.DateTimeFormatOptions?] | [typeof Kind.Plural, string, Message$1.Cases, number?] | [typeof Kind.Ordinal, string, Message$1.Cases, number?] | [typeof Kind.Select, string, Message$1.Cases] | [typeof Kind.Hash];
27
+ declare namespace Message$1 {
28
+ /**
29
+ * A plural's or a select's branches, by key. A plural's keys are CLDR
30
+ * categories or an exact `=n`, and `other` is the fallback for both.
31
+ */
32
+ type Cases = {
33
+ [key: string]: Message$1;
34
+ };
35
+ /** What a compiled message is called with: the descriptor the transform built. */
36
+ type Values = Record<string, unknown>;
37
+ }
38
+ /**
39
+ * Compile one ICU MessageFormat 1 message.
31
40
  *
32
- * Three forms are accepted: a named style, a `::`-prefixed skeleton, and, for
33
- * a number, a literal pattern such as `#,##0.00`.
41
+ * @param icu The message, in ICU MessageFormat 1 syntax
42
+ * @returns The compiled message
43
+ * @throws If the message is not valid ICU MessageFormat 1
34
44
  */
35
- declare function validateArgumentStyle(type: ArgumentType, style: string): void;
36
- //#endregion
37
- //#region src/features/messages/identifier.d.ts
38
- declare const AUTO_INCREMENT_IDENTIFIER: unique symbol;
45
+ export declare function compileMessage(icu: string): Message$1;
46
+ export declare const AUTO_INCREMENT_IDENTIFIER: unique symbol;
39
47
  /**
40
48
  * The ICU case a branch is written as.
41
49
  *
@@ -48,7 +56,7 @@ declare const AUTO_INCREMENT_IDENTIFIER: unique symbol;
48
56
  * coerce to `=0`, which would pass for a key selecting zero and leave the
49
57
  * author's own key out of the catalogue.
50
58
  */
51
- declare function getBranchCase(kind: string, identifier: string | typeof AUTO_INCREMENT_IDENTIFIER): string;
59
+ export declare function getBranchCase(kind: string, identifier: string | typeof AUTO_INCREMENT_IDENTIFIER): string;
52
60
  /**
53
61
  * Reject a branch key ICU cannot express, while the key is still attached to a
54
62
  * file and a line.
@@ -57,23 +65,77 @@ declare function getBranchCase(kind: string, identifier: string | typeof AUTO_IN
57
65
  * builds, and extracts to a normal-looking catalogue entry, and the only sign
58
66
  * of trouble is a parse error at format time.
59
67
  */
60
- declare function validateBranchIdentifier(kind: string, identifier: string | typeof AUTO_INCREMENT_IDENTIFIER): void;
68
+ export declare function validateBranchIdentifier(kind: string, identifier: string | typeof AUTO_INCREMENT_IDENTIFIER): void;
61
69
  /**
62
70
  * Decides whether two placeholders sharing a name are the same placeholder, and
63
71
  * so may share it. Only the syntax that produced them can answer that, so the
64
72
  * caller supplies the comparison; by default nothing is interchangeable.
65
73
  */
66
- type PlaceholderEquivalence = (a: any, b: any) => boolean;
67
- declare function assignSequenceIdentifiers(message: Message, sequence?: {
74
+ export type PlaceholderEquivalence = (a: any, b: any) => boolean;
75
+ export declare function assignSequenceIdentifiers(message: Message, sequence?: {
68
76
  current: number;
69
77
  }, equivalent?: PlaceholderEquivalence): void;
70
- //#endregion
71
- //#region src/features/messages/types.d.ts
78
+ /**
79
+ * Argument styles: which ones a macro may author, and the `Intl` options each resolves to.
80
+ *
81
+ * Validation and compilation share these functions, so a style the transform accepts is one the
82
+ * compiler honours.
83
+ */
84
+ /**
85
+ * The ICU argument types a macro can author, and the named styles each accepts.
86
+ *
87
+ * `currency` is absent from `number` because MF1 has nowhere to write the code; use
88
+ * `::currency/EUR`.
89
+ * `duration`, `spellout`, RBNF `ordinal` and `choice` are absent too, and compile to the bare
90
+ * value.
91
+ */
92
+ export declare const ARGUMENT_STYLES: {
93
+ readonly number: readonly ['integer', 'percent'];
94
+ readonly date: readonly ['short', 'medium', 'long', 'full'];
95
+ readonly time: readonly ['short', 'medium', 'long', 'full'];
96
+ };
97
+ export type ArgumentType = keyof typeof ARGUMENT_STYLES;
98
+ export declare const ARGUMENT_TYPES: ArgumentType[];
99
+ export declare function isArgumentType(kind: string): kind is ArgumentType;
100
+ /** The extra key a number's bag may carry, which `Intl` has no option for. */
101
+ export type NumberOptions = Intl.NumberFormatOptions & {
102
+ scale?: number;
103
+ };
104
+ /** A style that could not be resolved, with the reason it could not. */
105
+ export declare class StyleError extends Error {}
106
+ /**
107
+ * Turn a `date` or `time` argument style into `Intl.DateTimeFormat` options.
108
+ *
109
+ * A `::`-prefixed style is a skeleton such as `::yyyyMMdd`; an empty style takes MF1's default.
110
+ *
111
+ * @throws {StyleError} If the style names no fields
112
+ */
113
+ export declare function dateTimeStyle(kind: 'date' | 'time', style: string): Intl.DateTimeFormatOptions;
114
+ /**
115
+ * Turn a `number` argument style into `Intl.NumberFormat` options.
116
+ *
117
+ * Accepts MF1's named styles, a `::`-prefixed skeleton, or a literal pattern such as `#,##0.00`.
118
+ * Named styles are expanded here because the pattern parser would read `percent` as literal text.
119
+ *
120
+ * `scale` comes back beside the bag, since `Intl` has no option for it.
121
+ *
122
+ * @throws {StyleError} If the style is not valid, or asks for something `Intl` cannot express
123
+ */
124
+ export declare function numberStyle(style: string): NumberOptions;
125
+ /**
126
+ * Reject an argument style the compiler cannot honour, while it is still attached to a file and
127
+ * line.
128
+ *
129
+ * The compiler falls back to the default format, so an unchecked typo like `{d, date, meduim}` only
130
+ * misformats in production.
131
+ * Skeletons and patterns are checked by resolving them as the compiler will.
132
+ */
133
+ export declare function validateArgumentStyle(type: ArgumentType, style: string): void;
72
134
  declare abstract class Base {
73
135
  toICUString(this: Message): string;
74
136
  toHashString(this: Message): string;
75
137
  }
76
- declare class LiteralMessage extends Base {
138
+ export declare class LiteralMessage extends Base {
77
139
  readonly text: string;
78
140
  constructor(text: string);
79
141
  }
@@ -85,23 +147,23 @@ declare class LiteralMessage extends Base {
85
147
  * options, because the catalogue is the source of truth and only the ICU
86
148
  * spelling round-trips back out of it.
87
149
  */
88
- interface ArgumentFormat {
150
+ export interface ArgumentFormat {
89
151
  type: ArgumentType;
90
152
  style?: string;
91
153
  }
92
- declare class ArgumentMessage extends Base {
154
+ export declare class ArgumentMessage extends Base {
93
155
  identifier: string | typeof AUTO_INCREMENT_IDENTIFIER;
94
156
  readonly expression: any;
95
157
  readonly format?: ArgumentFormat | undefined;
96
158
  constructor(identifier: string | typeof AUTO_INCREMENT_IDENTIFIER, expression: any, format?: ArgumentFormat | undefined);
97
159
  }
98
- declare class ElementMessage extends Base {
160
+ export declare class ElementMessage extends Base {
99
161
  identifier: string | typeof AUTO_INCREMENT_IDENTIFIER;
100
162
  readonly children: Message[];
101
163
  readonly expression: any;
102
164
  constructor(identifier: string | typeof AUTO_INCREMENT_IDENTIFIER, children: Message[], expression: any);
103
165
  }
104
- declare class ChoiceMessage extends Base {
166
+ export declare class ChoiceMessage extends Base {
105
167
  readonly kind: string;
106
168
  identifier: string | typeof AUTO_INCREMENT_IDENTIFIER;
107
169
  readonly branches: {
@@ -126,7 +188,7 @@ declare class ChoiceMessage extends Base {
126
188
  */
127
189
  offset?: number | undefined);
128
190
  }
129
- declare class CompositeMessage extends Base {
191
+ export declare class CompositeMessage extends Base {
130
192
  readonly descriptor: {
131
193
  id?: string;
132
194
  context?: string;
@@ -141,12 +203,8 @@ declare class CompositeMessage extends Base {
141
203
  context?: string;
142
204
  }, comments: string[], references: string[], children: Message[], accessor: any, whitespace?: boolean | undefined);
143
205
  }
144
- type Message = LiteralMessage | ArgumentMessage | ElementMessage | ChoiceMessage | CompositeMessage;
145
- //#endregion
146
- //#region src/features/messages/convert.d.ts
147
- declare function convertMessageToIcu(message: Message): string;
148
- //#endregion
149
- //#region src/features/messages/escape.d.ts
206
+ export type Message = LiteralMessage | ArgumentMessage | ElementMessage | ChoiceMessage | CompositeMessage;
207
+ export declare function convertMessageToIcu(message: Message): string;
150
208
  /**
151
209
  * Quoting for text that has to survive a message format unchanged.
152
210
  *
@@ -167,9 +225,7 @@ declare function convertMessageToIcu(message: Message): string;
167
225
  * @param hash Whether `#` stands for a number here, i.e. whether some `plural`
168
226
  * or `ordinal` encloses this text
169
227
  */
170
- declare function escapeIcuLiteral(text: string, hash?: boolean): string;
171
- //#endregion
172
- //#region src/features/messages/hash.d.ts
228
+ export declare function escapeIcuLiteral(text: string, hash?: boolean): string;
173
229
  /**
174
230
  * Hashed in userland rather than with `node:crypto`, because this runs wherever
175
231
  * a bundler runs it. `createHash` is one of the entry points `unenv` leaves
@@ -178,6 +234,5 @@ declare function escapeIcuLiteral(text: string, hash?: boolean): string;
178
234
  * equivalent, `subtle.digest`, is async, and an id is resolved from a
179
235
  * synchronous extraction pass.
180
236
  */
181
- declare function generateHash(input: string, context?: string): string;
182
- //#endregion
183
- export { ARGUMENT_STYLES, ARGUMENT_TYPES, AUTO_INCREMENT_IDENTIFIER, ArgumentFormat, ArgumentMessage, ArgumentType, ChoiceMessage, CompositeMessage, ElementMessage, LiteralMessage, Message, PlaceholderEquivalence, assignSequenceIdentifiers, convertMessageToIcu, escapeIcuLiteral, generateHash, getBranchCase, isArgumentType, validateArgumentStyle, validateBranchIdentifier };
237
+ export declare function generateHash(input: string, context?: string): string;
238
+ export {};
@@ -1,12 +1,9 @@
1
- import { t as generateHash } from "../../hash-DvzpieJD.mjs";
2
- import { getDateTimeFormatOptions, parseDateTokens } from "@messageformat/date-skeleton";
3
- import { getNumberFormatOptions, parseNumberSkeleton } from "@messageformat/number-skeleton";
4
- //#region src/features/messages/escape.ts
1
+ import { a as dateTimeStyle, c as validateArgumentStyle, i as StyleError, l as generateHash, n as ARGUMENT_STYLES, o as isArgumentType, r as ARGUMENT_TYPES, s as numberStyle, t as compileMessage } from "../../compile-VUAk0xEx.mjs";
2
+ // src/features/messages/escape.ts
5
3
  function escapeIcuLiteral(text, hash = false) {
6
4
  return text.replace(/'/gu, "''").replace(hash ? /[{}#]+/gu : /[{}]+/gu, (run) => `'${run}'`);
7
5
  }
8
- //#endregion
9
- //#region src/features/messages/types.ts
6
+ // src/features/messages/types.ts
10
7
  var Base = class {
11
8
  toICUString() {
12
9
  return convertMessageToIcu(this);
@@ -77,8 +74,7 @@ var CompositeMessage = class extends Base {
77
74
  this.whitespace = whitespace;
78
75
  }
79
76
  };
80
- //#endregion
81
- //#region src/features/messages/identifier.ts
77
+ // src/features/messages/identifier.ts
82
78
  const AUTO_INCREMENT_IDENTIFIER = Symbol("auto-increment");
83
79
  const BRANCH_PATTERN = /^(?:=\d+|[^\p{Pattern_Syntax}\p{Pattern_White_Space}]+)$/u;
84
80
  function getBranchCase(kind, identifier) {
@@ -147,8 +143,7 @@ function collectAssignedIdentifiers(message, equivalent) {
147
143
  for (const tag of tags.keys()) if (values.has(tag)) throw new Error(`Element tag '${tag}' collides with an argument of the same name`);
148
144
  return /* @__PURE__ */ new Set([...tags.keys(), ...values.keys()]);
149
145
  }
150
- //#endregion
151
- //#region src/features/messages/convert.ts
146
+ // src/features/messages/convert.ts
152
147
  function convertMessageToIcu(message) {
153
148
  function internalConvertMessageToIcu(message, hash) {
154
149
  switch (true) {
@@ -181,53 +176,4 @@ function convertMessageToIcu(message) {
181
176
  }
182
177
  return internalConvertMessageToIcu(message, void 0).trim();
183
178
  }
184
- //#endregion
185
- //#region src/features/messages/format.ts
186
- const ARGUMENT_STYLES = {
187
- number: ["integer", "percent"],
188
- date: [
189
- "short",
190
- "medium",
191
- "long",
192
- "full"
193
- ],
194
- time: [
195
- "short",
196
- "medium",
197
- "long",
198
- "full"
199
- ]
200
- };
201
- const ARGUMENT_TYPES = Object.keys(ARGUMENT_STYLES);
202
- function isArgumentType(kind) {
203
- return Object.hasOwn(ARGUMENT_STYLES, kind);
204
- }
205
- const LITERAL_STYLE_PATTERN = /^[^{}\r\n]*[#0][^{}\r\n]*$/;
206
- const SKELETON = "::";
207
- function invalidSkeleton(type, skeleton) {
208
- if (skeleton === "") return "it names no fields";
209
- const errors = [];
210
- if (type === "number") {
211
- getNumberFormatOptions(parseNumberSkeleton(skeleton, (error) => errors.push(String(error))), (stem) => {
212
- if (stem !== "scale") errors.push(`unsupported stem '${stem}'`);
213
- });
214
- return errors[0];
215
- }
216
- const options = getDateTimeFormatOptions(parseDateTokens(skeleton), (_type, message) => errors.push(message));
217
- if (errors.length > 0) return errors[0];
218
- if (Object.keys(options).length === 0) return "it names no fields";
219
- }
220
- function validateArgumentStyle(type, style) {
221
- const named = ARGUMENT_STYLES[type];
222
- if (named.includes(style)) return;
223
- if (style.startsWith(SKELETON)) {
224
- const reason = invalidSkeleton(type, style.slice(2));
225
- if (!reason) return;
226
- throw new Error(`Invalid ${type} skeleton '${style}': ${reason}`);
227
- }
228
- if (type === "number" && LITERAL_STYLE_PATTERN.test(style)) return;
229
- const expected = named.map((s) => `'${s}'`).join(", ");
230
- 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" : ""));
231
- }
232
- //#endregion
233
- export { ARGUMENT_STYLES, ARGUMENT_TYPES, AUTO_INCREMENT_IDENTIFIER, ArgumentMessage, ChoiceMessage, CompositeMessage, ElementMessage, LiteralMessage, assignSequenceIdentifiers, convertMessageToIcu, escapeIcuLiteral, generateHash, getBranchCase, isArgumentType, validateArgumentStyle, validateBranchIdentifier };
179
+ export { ARGUMENT_STYLES, ARGUMENT_TYPES, AUTO_INCREMENT_IDENTIFIER, ArgumentMessage, ChoiceMessage, CompositeMessage, ElementMessage, LiteralMessage, StyleError, assignSequenceIdentifiers, compileMessage, convertMessageToIcu, dateTimeStyle, escapeIcuLiteral, generateHash, getBranchCase, isArgumentType, numberStyle, validateArgumentStyle, validateBranchIdentifier };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
2
+ // \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -16,11 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
- //#endregion
24
23
  let picomatch = require("picomatch");
25
24
  picomatch = __toESM(picomatch, 1);
26
25
  let zod = require("zod");
@@ -85,10 +84,8 @@ const Config = zod.object({
85
84
  fallbackLocales: zod.record(zod.string(), zod.string().or(zod.string().array())).optional(),
86
85
  buckets: Bucket.array()
87
86
  });
88
- //#endregion
89
- //#region src/index.ts
87
+ // src/index.ts
90
88
  function defineConfig(config) {
91
89
  return Config.parse(config);
92
90
  }
93
- //#endregion
94
91
  exports.defineConfig = defineConfig;
package/dist/index.d.cts CHANGED
@@ -1,22 +1,11 @@
1
- import { a as Message, i as Formatter, n as Config, o as Transformer, r as DeclaredMessage, t as Bucket } from "./shapes-CRlXtss0.cjs";
1
+ import { a as Message, i as Formatter, n as Config, o as Transformer, r as DeclaredMessage, t as Bucket } from "./shapes-Dq0aJdsn.cjs";
2
2
  import { input } from "zod";
3
- //#region src/index.d.ts
4
- declare function defineConfig<C extends input<typeof Config>>(config: C): {
3
+ export declare function defineConfig<C extends input<typeof Config>>(config: C): {
5
4
  locales: [string, ...string[]];
5
+ fallbackLocales?: Record<string, string | string[]> | undefined;
6
6
  buckets: {
7
- messages: {
8
- message: string;
9
- comments: string[];
10
- references: string[];
11
- translation?: string | undefined;
12
- id?: string | undefined;
13
- context?: string | undefined;
14
- }[];
15
- match: (id: string) => boolean;
16
- output: `${string}{locale}${string}.{extension}` & {
17
- match: import("picomatch/lib/picomatch.js").Matcher;
18
- };
19
7
  include: string[];
8
+ exclude?: string[] | undefined;
20
9
  formatter: {
21
10
  extension: `.${string}`;
22
11
  parse: (content: string) => Message[];
@@ -29,17 +18,26 @@ declare function defineConfig<C extends input<typeof Config>>(config: C): {
29
18
  match: (id: string) => boolean;
30
19
  extract: (code: string, id: string) => {
31
20
  message: string;
32
- comments: string[];
33
- references: string[];
34
21
  translation?: string | undefined;
35
22
  id?: string | undefined;
36
23
  context?: string | undefined;
24
+ comments: string[];
25
+ references: string[];
37
26
  }[];
38
27
  transform: (code: string, id: string) => string;
39
28
  };
40
- exclude?: string[] | undefined;
29
+ messages: {
30
+ message: string;
31
+ translation?: string | undefined;
32
+ id?: string | undefined;
33
+ context?: string | undefined;
34
+ comments: string[];
35
+ references: string[];
36
+ }[];
37
+ match: (id: string) => boolean;
38
+ output: `${string}{locale}${string}.{extension}` & {
39
+ match: import("picomatch/lib/picomatch.js").Matcher;
40
+ };
41
41
  }[];
42
- fallbackLocales?: Record<string, string | string[]> | undefined;
43
42
  };
44
- //#endregion
45
- export { type Bucket, type Config, type DeclaredMessage, type Formatter, type Message, type Transformer, defineConfig };
43
+ export type { Bucket, Config, DeclaredMessage, Formatter, Message, Transformer };
package/dist/index.d.mts CHANGED
@@ -1,22 +1,11 @@
1
- import { a as Message, i as Formatter, n as Config, o as Transformer, r as DeclaredMessage, t as Bucket } from "./shapes-CRlXtss0.mjs";
1
+ import { a as Message, i as Formatter, n as Config, o as Transformer, r as DeclaredMessage, t as Bucket } from "./shapes-Dq0aJdsn.mjs";
2
2
  import { input } from "zod";
3
- //#region src/index.d.ts
4
- declare function defineConfig<C extends input<typeof Config>>(config: C): {
3
+ export declare function defineConfig<C extends input<typeof Config>>(config: C): {
5
4
  locales: [string, ...string[]];
5
+ fallbackLocales?: Record<string, string | string[]> | undefined;
6
6
  buckets: {
7
- messages: {
8
- message: string;
9
- comments: string[];
10
- references: string[];
11
- translation?: string | undefined;
12
- id?: string | undefined;
13
- context?: string | undefined;
14
- }[];
15
- match: (id: string) => boolean;
16
- output: `${string}{locale}${string}.{extension}` & {
17
- match: import("picomatch/lib/picomatch.js").Matcher;
18
- };
19
7
  include: string[];
8
+ exclude?: string[] | undefined;
20
9
  formatter: {
21
10
  extension: `.${string}`;
22
11
  parse: (content: string) => Message[];
@@ -29,17 +18,26 @@ declare function defineConfig<C extends input<typeof Config>>(config: C): {
29
18
  match: (id: string) => boolean;
30
19
  extract: (code: string, id: string) => {
31
20
  message: string;
32
- comments: string[];
33
- references: string[];
34
21
  translation?: string | undefined;
35
22
  id?: string | undefined;
36
23
  context?: string | undefined;
24
+ comments: string[];
25
+ references: string[];
37
26
  }[];
38
27
  transform: (code: string, id: string) => string;
39
28
  };
40
- exclude?: string[] | undefined;
29
+ messages: {
30
+ message: string;
31
+ translation?: string | undefined;
32
+ id?: string | undefined;
33
+ context?: string | undefined;
34
+ comments: string[];
35
+ references: string[];
36
+ }[];
37
+ match: (id: string) => boolean;
38
+ output: `${string}{locale}${string}.{extension}` & {
39
+ match: import("picomatch/lib/picomatch.js").Matcher;
40
+ };
41
41
  }[];
42
- fallbackLocales?: Record<string, string | string[]> | undefined;
43
42
  };
44
- //#endregion
45
- export { type Bucket, type Config, type DeclaredMessage, type Formatter, type Message, type Transformer, defineConfig };
43
+ export type { Bucket, Config, DeclaredMessage, Formatter, Message, Transformer };
package/dist/index.mjs CHANGED
@@ -60,10 +60,8 @@ const Config = z.object({
60
60
  fallbackLocales: z.record(z.string(), z.string().or(z.string().array())).optional(),
61
61
  buckets: Bucket.array()
62
62
  });
63
- //#endregion
64
- //#region src/index.ts
63
+ // src/index.ts
65
64
  function defineConfig(config) {
66
65
  return Config.parse(config);
67
66
  }
68
- //#endregion
69
67
  export { defineConfig };
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { extname, join } from "node:path";
3
3
  import { existsSync } from "node:fs";
4
- //#region src/features/loader/files.ts
4
+ // src/features/loader/files.ts
5
5
  const SUPPORTED_CONFIG_FILES = [
6
6
  "saykit.config.js",
7
7
  "saykit.config.cjs",
@@ -20,8 +20,7 @@ function findConfigFile(moduleName, projectDir) {
20
20
  }
21
21
  return null;
22
22
  }
23
- //#endregion
24
- //#region src/features/loader/module.ts
23
+ // src/features/loader/module.ts
25
24
  function requireFresh(require, path) {
26
25
  const resolved = require.resolve(path);
27
26
  delete require.cache[resolved];
@@ -59,8 +58,7 @@ const configLoaders = Object.freeze({
59
58
  ".mts": ts,
60
59
  ".cts": ts
61
60
  });
62
- //#endregion
63
- //#region src/features/loader/resolve.ts
61
+ // src/features/loader/resolve.ts
64
62
  function resolveConfigFile(name = "saykit") {
65
63
  const file = findConfigFile(name, process.cwd());
66
64
  if (!file) throw new Error(`Could not find config file for "${name}"`);
@@ -75,5 +73,4 @@ function resolveConfig(name = "saykit") {
75
73
  if (!config || typeof config !== "object") throw new Error(`Invalid config file for "${name}"`);
76
74
  return config;
77
75
  }
78
- //#endregion
79
76
  export { resolveConfigFile as n, resolveConfig as t };
@@ -1,7 +1,7 @@
1
1
  let node_path = require("node:path");
2
2
  let node_fs = require("node:fs");
3
3
  let node_module = require("node:module");
4
- //#region src/features/loader/files.ts
4
+ // src/features/loader/files.ts
5
5
  const SUPPORTED_CONFIG_FILES = [
6
6
  "saykit.config.js",
7
7
  "saykit.config.cjs",
@@ -20,13 +20,12 @@ function findConfigFile(moduleName, projectDir) {
20
20
  }
21
21
  return null;
22
22
  }
23
- //#endregion
24
- //#region src/features/loader/module.ts
25
- function requireFresh(require, path) {
26
- const resolved = require.resolve(path);
27
- delete require.cache[resolved];
28
- const module = require(path);
29
- delete require.cache[resolved];
23
+ // src/features/loader/module.ts
24
+ function requireFresh(require$1, path) {
25
+ const resolved = require$1.resolve(path);
26
+ delete require$1.cache[resolved];
27
+ const module = require$1(path);
28
+ delete require$1.cache[resolved];
30
29
  return module?.default ?? module;
31
30
  }
32
31
  const TYPESCRIPT = /* @__PURE__ */ new Set([
@@ -59,8 +58,7 @@ const configLoaders = Object.freeze({
59
58
  ".mts": ts,
60
59
  ".cts": ts
61
60
  });
62
- //#endregion
63
- //#region src/features/loader/resolve.ts
61
+ // src/features/loader/resolve.ts
64
62
  function resolveConfigFile(name = "saykit") {
65
63
  const file = findConfigFile(name, process.cwd());
66
64
  if (!file) throw new Error(`Could not find config file for "${name}"`);
@@ -75,7 +73,6 @@ function resolveConfig(name = "saykit") {
75
73
  if (!config || typeof config !== "object") throw new Error(`Invalid config file for "${name}"`);
76
74
  return config;
77
75
  }
78
- //#endregion
79
76
  Object.defineProperty(exports, "resolveConfig", {
80
77
  enumerable: true,
81
78
  get: function() {