@saykit/config 0.9.0 → 0.10.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
CHANGED
|
@@ -51,7 +51,7 @@ have a file yet are bootstrapped with an empty, header-only catalogue so a TMS c
|
|
|
51
51
|
existing translation files are left untouched. Translated content is owned by your TMS.
|
|
52
52
|
|
|
53
53
|
At load time (via the unplugin or Babel plugin), each locale module is filled from its fallback
|
|
54
|
-
chain, so an untranslated key resolves to a fallback locale and ultimately the source string
|
|
54
|
+
chain, so an untranslated key resolves to a fallback locale and ultimately the source string, the
|
|
55
55
|
runtime still loads a single locale.
|
|
56
56
|
|
|
57
57
|
`saykit clean` only ever subtracts from non-source locales: it drops entries that no longer exist in
|
|
@@ -2,7 +2,7 @@ import { n as Config } from "../../shapes-CRlXtss0.cjs";
|
|
|
2
2
|
//#region src/features/loader/resolve.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The config file {@link resolveConfig} would load, for callers that need the
|
|
5
|
-
* path itself rather than its contents
|
|
5
|
+
* path itself rather than its contents, salting a bundler's cache key with it,
|
|
6
6
|
* for one, since what a catalogue assembles into depends on the config.
|
|
7
7
|
*/
|
|
8
8
|
declare function resolveConfigFile(name?: string): string;
|
|
@@ -2,7 +2,7 @@ import { n as Config } from "../../shapes-CRlXtss0.mjs";
|
|
|
2
2
|
//#region src/features/loader/resolve.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The config file {@link resolveConfig} would load, for callers that need the
|
|
5
|
-
* path itself rather than its contents
|
|
5
|
+
* path itself rather than its contents, salting a bundler's cache key with it,
|
|
6
6
|
* for one, since what a catalogue assembles into depends on the config.
|
|
7
7
|
*/
|
|
8
8
|
declare function resolveConfigFile(name?: string): string;
|
|
@@ -3,17 +3,15 @@
|
|
|
3
3
|
* The ICU argument types a macro can author, and the named styles each accepts.
|
|
4
4
|
*
|
|
5
5
|
* A style may also be a skeleton, which is where the formats these names have
|
|
6
|
-
* no word for live
|
|
6
|
+
* no word for live; see {@link validateArgumentStyle}.
|
|
7
7
|
*
|
|
8
|
-
* `currency` is deliberately absent from `number
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* than an amount. Currency belongs to a skeleton, `::currency/EUR`, which names
|
|
12
|
-
* the code and which the formatter does honour.
|
|
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.
|
|
13
11
|
*
|
|
14
|
-
* `spellout`, RBNF `ordinal
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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`.
|
|
17
15
|
*/
|
|
18
16
|
declare const ARGUMENT_STYLES: {
|
|
19
17
|
readonly number: readonly ["integer", "percent"];
|
|
@@ -27,13 +25,12 @@ declare function isArgumentType(kind: string): kind is ArgumentType;
|
|
|
27
25
|
* Reject an argument style the formatter cannot honour, while the style is
|
|
28
26
|
* still attached to a file and a line.
|
|
29
27
|
*
|
|
30
|
-
* A style is a bare string in the source and
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* perfectly normal and only misformats once it reaches a user.
|
|
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.
|
|
34
31
|
*
|
|
35
|
-
* Three forms are accepted: a named style, a `::`-prefixed skeleton, and
|
|
36
|
-
* a number
|
|
32
|
+
* Three forms are accepted: a named style, a `::`-prefixed skeleton, and, for
|
|
33
|
+
* a number, a literal pattern such as `#,##0.00`.
|
|
37
34
|
*/
|
|
38
35
|
declare function validateArgumentStyle(type: ArgumentType, style: string): void;
|
|
39
36
|
//#endregion
|
|
@@ -44,25 +41,21 @@ declare const AUTO_INCREMENT_IDENTIFIER: unique symbol;
|
|
|
44
41
|
*
|
|
45
42
|
* Under `plural` and `ordinal` a number names an exact value, spelled `=0`, and
|
|
46
43
|
* so is distinct from the CLDR category that would otherwise match it. `select`
|
|
47
|
-
* has no such syntax
|
|
48
|
-
* a parse error — so a numeric key stays bare, where it matches both `0` and
|
|
44
|
+
* has no such syntax, so a numeric key stays bare and matches both `0` and
|
|
49
45
|
* `'0'`.
|
|
50
46
|
*
|
|
51
|
-
* Digits are read literally rather than coerced
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* author's own key out of the catalogue. Anything else stays a key, where the
|
|
55
|
-
* whitespace or punctuation that made it numeric-looking is caught.
|
|
47
|
+
* Digits are read literally rather than coerced: `''`, `' '` and `'+0'` all
|
|
48
|
+
* coerce to `=0`, which would pass for a key selecting zero and leave the
|
|
49
|
+
* author's own key out of the catalogue.
|
|
56
50
|
*/
|
|
57
51
|
declare function getBranchCase(kind: string, identifier: string | typeof AUTO_INCREMENT_IDENTIFIER): string;
|
|
58
52
|
/**
|
|
59
53
|
* Reject a branch key ICU cannot express, while the key is still attached to a
|
|
60
54
|
* file and a line.
|
|
61
55
|
*
|
|
62
|
-
* A hyphenated string union is ordinary application code
|
|
63
|
-
* builds, and extracts to a catalogue entry
|
|
64
|
-
*
|
|
65
|
-
* source is long gone.
|
|
56
|
+
* A hyphenated string union is ordinary application code: it typechecks,
|
|
57
|
+
* builds, and extracts to a normal-looking catalogue entry, and the only sign
|
|
58
|
+
* of trouble is a parse error at format time.
|
|
66
59
|
*/
|
|
67
60
|
declare function validateBranchIdentifier(kind: string, identifier: string | typeof AUTO_INCREMENT_IDENTIFIER): void;
|
|
68
61
|
/**
|
|
@@ -86,7 +79,7 @@ declare class LiteralMessage extends Base {
|
|
|
86
79
|
}
|
|
87
80
|
/**
|
|
88
81
|
* An ICU argument type and style, e.g. `{n, number, percent}`. A style is
|
|
89
|
-
* optional
|
|
82
|
+
* optional: `{n, number}` is the type's default formatting.
|
|
90
83
|
*
|
|
91
84
|
* Both are kept as the ICU strings they are written as, rather than as `Intl`
|
|
92
85
|
* options, because the catalogue is the source of truth and only the ICU
|
|
@@ -158,19 +151,16 @@ declare function convertMessageToIcu(message: Message): string;
|
|
|
158
151
|
* Quoting for text that has to survive a message format unchanged.
|
|
159
152
|
*
|
|
160
153
|
* This lives beside the converter rather than in a transform because it belongs
|
|
161
|
-
* to the format being written, not
|
|
162
|
-
*
|
|
163
|
-
* moment there is a second target format its reserved characters — and the way
|
|
164
|
-
* it spells an escape — are its own.
|
|
154
|
+
* to the format being written, not the syntax being read: a literal is the same
|
|
155
|
+
* literal whether it came from a template literal or from JSX.
|
|
165
156
|
*/
|
|
166
157
|
/**
|
|
167
158
|
* Escape literal text so ICU MessageFormat 1 reads it as the text it is.
|
|
168
159
|
*
|
|
169
160
|
* MF1 escapes with an apostrophe: a run wrapped in one is taken literally, and a
|
|
170
|
-
* doubled apostrophe is a single apostrophe.
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* inside a plural and the three characters `'#'` anywhere else, which is why
|
|
161
|
+
* doubled apostrophe is a single apostrophe. An apostrophe only opens a quoted
|
|
162
|
+
* run when a character that needs quoting follows it, so `'#'` is a real escape
|
|
163
|
+
* inside a plural and three literal characters anywhere else, which is why
|
|
174
164
|
* `hash` has to be told rather than assumed.
|
|
175
165
|
*
|
|
176
166
|
* @param text Literal text as the author wrote it
|
|
@@ -183,7 +173,7 @@ declare function escapeIcuLiteral(text: string, hash?: boolean): string;
|
|
|
183
173
|
/**
|
|
184
174
|
* Hashed in userland rather than with `node:crypto`, because this runs wherever
|
|
185
175
|
* a bundler runs it. `createHash` is one of the entry points `unenv` leaves
|
|
186
|
-
* unimplemented
|
|
176
|
+
* unimplemented, "[unenv] crypto.createHash is not implemented yet!", so a
|
|
187
177
|
* plugin reaching for it throws in a Nitro or workerd build. The Web Crypto
|
|
188
178
|
* equivalent, `subtle.digest`, is async, and an id is resolved from a
|
|
189
179
|
* synchronous extraction pass.
|
|
@@ -3,17 +3,15 @@
|
|
|
3
3
|
* The ICU argument types a macro can author, and the named styles each accepts.
|
|
4
4
|
*
|
|
5
5
|
* A style may also be a skeleton, which is where the formats these names have
|
|
6
|
-
* no word for live
|
|
6
|
+
* no word for live; see {@link validateArgumentStyle}.
|
|
7
7
|
*
|
|
8
|
-
* `currency` is deliberately absent from `number
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* than an amount. Currency belongs to a skeleton, `::currency/EUR`, which names
|
|
12
|
-
* the code and which the formatter does honour.
|
|
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.
|
|
13
11
|
*
|
|
14
|
-
* `spellout`, RBNF `ordinal
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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`.
|
|
17
15
|
*/
|
|
18
16
|
declare const ARGUMENT_STYLES: {
|
|
19
17
|
readonly number: readonly ["integer", "percent"];
|
|
@@ -27,13 +25,12 @@ declare function isArgumentType(kind: string): kind is ArgumentType;
|
|
|
27
25
|
* Reject an argument style the formatter cannot honour, while the style is
|
|
28
26
|
* still attached to a file and a line.
|
|
29
27
|
*
|
|
30
|
-
* A style is a bare string in the source and
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* perfectly normal and only misformats once it reaches a user.
|
|
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.
|
|
34
31
|
*
|
|
35
|
-
* Three forms are accepted: a named style, a `::`-prefixed skeleton, and
|
|
36
|
-
* a number
|
|
32
|
+
* Three forms are accepted: a named style, a `::`-prefixed skeleton, and, for
|
|
33
|
+
* a number, a literal pattern such as `#,##0.00`.
|
|
37
34
|
*/
|
|
38
35
|
declare function validateArgumentStyle(type: ArgumentType, style: string): void;
|
|
39
36
|
//#endregion
|
|
@@ -44,25 +41,21 @@ declare const AUTO_INCREMENT_IDENTIFIER: unique symbol;
|
|
|
44
41
|
*
|
|
45
42
|
* Under `plural` and `ordinal` a number names an exact value, spelled `=0`, and
|
|
46
43
|
* so is distinct from the CLDR category that would otherwise match it. `select`
|
|
47
|
-
* has no such syntax
|
|
48
|
-
* a parse error — so a numeric key stays bare, where it matches both `0` and
|
|
44
|
+
* has no such syntax, so a numeric key stays bare and matches both `0` and
|
|
49
45
|
* `'0'`.
|
|
50
46
|
*
|
|
51
|
-
* Digits are read literally rather than coerced
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* author's own key out of the catalogue. Anything else stays a key, where the
|
|
55
|
-
* whitespace or punctuation that made it numeric-looking is caught.
|
|
47
|
+
* Digits are read literally rather than coerced: `''`, `' '` and `'+0'` all
|
|
48
|
+
* coerce to `=0`, which would pass for a key selecting zero and leave the
|
|
49
|
+
* author's own key out of the catalogue.
|
|
56
50
|
*/
|
|
57
51
|
declare function getBranchCase(kind: string, identifier: string | typeof AUTO_INCREMENT_IDENTIFIER): string;
|
|
58
52
|
/**
|
|
59
53
|
* Reject a branch key ICU cannot express, while the key is still attached to a
|
|
60
54
|
* file and a line.
|
|
61
55
|
*
|
|
62
|
-
* A hyphenated string union is ordinary application code
|
|
63
|
-
* builds, and extracts to a catalogue entry
|
|
64
|
-
*
|
|
65
|
-
* source is long gone.
|
|
56
|
+
* A hyphenated string union is ordinary application code: it typechecks,
|
|
57
|
+
* builds, and extracts to a normal-looking catalogue entry, and the only sign
|
|
58
|
+
* of trouble is a parse error at format time.
|
|
66
59
|
*/
|
|
67
60
|
declare function validateBranchIdentifier(kind: string, identifier: string | typeof AUTO_INCREMENT_IDENTIFIER): void;
|
|
68
61
|
/**
|
|
@@ -86,7 +79,7 @@ declare class LiteralMessage extends Base {
|
|
|
86
79
|
}
|
|
87
80
|
/**
|
|
88
81
|
* An ICU argument type and style, e.g. `{n, number, percent}`. A style is
|
|
89
|
-
* optional
|
|
82
|
+
* optional: `{n, number}` is the type's default formatting.
|
|
90
83
|
*
|
|
91
84
|
* Both are kept as the ICU strings they are written as, rather than as `Intl`
|
|
92
85
|
* options, because the catalogue is the source of truth and only the ICU
|
|
@@ -158,19 +151,16 @@ declare function convertMessageToIcu(message: Message): string;
|
|
|
158
151
|
* Quoting for text that has to survive a message format unchanged.
|
|
159
152
|
*
|
|
160
153
|
* This lives beside the converter rather than in a transform because it belongs
|
|
161
|
-
* to the format being written, not
|
|
162
|
-
*
|
|
163
|
-
* moment there is a second target format its reserved characters — and the way
|
|
164
|
-
* it spells an escape — are its own.
|
|
154
|
+
* to the format being written, not the syntax being read: a literal is the same
|
|
155
|
+
* literal whether it came from a template literal or from JSX.
|
|
165
156
|
*/
|
|
166
157
|
/**
|
|
167
158
|
* Escape literal text so ICU MessageFormat 1 reads it as the text it is.
|
|
168
159
|
*
|
|
169
160
|
* MF1 escapes with an apostrophe: a run wrapped in one is taken literally, and a
|
|
170
|
-
* doubled apostrophe is a single apostrophe.
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* inside a plural and the three characters `'#'` anywhere else, which is why
|
|
161
|
+
* doubled apostrophe is a single apostrophe. An apostrophe only opens a quoted
|
|
162
|
+
* run when a character that needs quoting follows it, so `'#'` is a real escape
|
|
163
|
+
* inside a plural and three literal characters anywhere else, which is why
|
|
174
164
|
* `hash` has to be told rather than assumed.
|
|
175
165
|
*
|
|
176
166
|
* @param text Literal text as the author wrote it
|
|
@@ -183,7 +173,7 @@ declare function escapeIcuLiteral(text: string, hash?: boolean): string;
|
|
|
183
173
|
/**
|
|
184
174
|
* Hashed in userland rather than with `node:crypto`, because this runs wherever
|
|
185
175
|
* a bundler runs it. `createHash` is one of the entry points `unenv` leaves
|
|
186
|
-
* unimplemented
|
|
176
|
+
* unimplemented, "[unenv] crypto.createHash is not implemented yet!", so a
|
|
187
177
|
* plugin reaching for it throws in a Nitro or workerd build. The Web Crypto
|
|
188
178
|
* equivalent, `subtle.digest`, is async, and an id is resolved from a
|
|
189
179
|
* synchronous extraction pass.
|