prosebook 0.0.1 → 0.2.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/LICENSE +21 -0
- package/README.md +604 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +508 -0
- package/dist/cli.js.map +1 -0
- package/dist/config-D--RITk2.js +1208 -0
- package/dist/config-D--RITk2.js.map +1 -0
- package/dist/config-_4HfnJQu.d.ts +517 -0
- package/dist/config-_4HfnJQu.d.ts.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +1 -0
- package/dist/copy-DXnzXsJa.d.ts +162 -0
- package/dist/copy-DXnzXsJa.d.ts.map +1 -0
- package/dist/helpers-BPuPGjQP.js +61 -0
- package/dist/helpers-BPuPGjQP.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +188 -0
- package/dist/index.js.map +1 -0
- package/dist/inspector.d.ts +37 -0
- package/dist/inspector.d.ts.map +1 -0
- package/dist/inspector.js +572 -0
- package/dist/inspector.js.map +1 -0
- package/dist/react/index.d.ts +37 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +86 -0
- package/dist/react/index.js.map +1 -0
- package/dist/sarif-CI8HOokm.js +1033 -0
- package/dist/sarif-CI8HOokm.js.map +1 -0
- package/dist/scan-Ch2BfIUD.js +2561 -0
- package/dist/scan-Ch2BfIUD.js.map +1 -0
- package/dist/tools.d.ts +377 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +4 -0
- package/dist/vite.d.ts +24 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +264 -0
- package/dist/vite.js.map +1 -0
- package/package.json +148 -15
- package/src/cli.ts +528 -0
- package/src/index.ts +31 -0
- package/src/inspector-dialog.ts +450 -0
- package/src/inspector.ts +228 -0
- package/src/react/index.tsx +112 -0
- package/src/runtime/copy.ts +221 -0
- package/src/runtime/helpers.ts +66 -0
- package/src/runtime/locale.ts +49 -0
- package/src/runtime/types.ts +106 -0
- package/src/tools/catalog.ts +449 -0
- package/src/tools/compile.ts +121 -0
- package/src/tools/config.ts +211 -0
- package/src/tools/diff.ts +84 -0
- package/src/tools/entry.ts +325 -0
- package/src/tools/extract.ts +694 -0
- package/src/tools/generate.ts +257 -0
- package/src/tools/icu.ts +211 -0
- package/src/tools/index.ts +91 -0
- package/src/tools/lint.ts +865 -0
- package/src/tools/lock.ts +95 -0
- package/src/tools/mf1.ts +246 -0
- package/src/tools/mf2.ts +752 -0
- package/src/tools/migrate.ts +138 -0
- package/src/tools/presets.ts +159 -0
- package/src/tools/pseudo.ts +40 -0
- package/src/tools/sarif.ts +80 -0
- package/src/tools/scan.ts +303 -0
- package/src/tools/syntax.ts +24 -0
- package/src/tools/types.ts +137 -0
- package/src/vite.ts +296 -0
- package/index.js +0 -1
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { A as sentences, B as EntryLocation, C as RuleContext, D as definePlugin, E as compileRule, F as KindRule, G as entryLocation, H as Message, I as STRICT_LISTS, J as whereOf, K as loadCatalog, L as Severity, M as words, N as DEFAULT_KINDS, O as lint, P as DEFAULT_SURFACES, R as Catalog, S as Rule, T as applyEdits, U as Problem, V as KEY_PATTERN, W as Translation, Y as MessageFormatElement, _ as HOLE, b as Readings, c as resolveConfig, d as CheckRule, f as ConditionalRule, g as Finding, h as ExistenceRule, i as ResolvedConfig, j as singularOf, k as phrase, l as CORE_RULES, m as Edit, o as defineConfig, p as CoreRule, q as previewOf, r as ProsebookConfig, s as loadConfig, u as CapitalizationRule, v as OccurrenceRule, w as SubstitutionRule, x as Report, y as Plugin, z as CatalogError } from "./config-_4HfnJQu.js";
|
|
2
|
+
import "@formatjs/icu-messageformat-parser";
|
|
3
|
+
type Entry = readonly [key: string, ast: MessageFormatElement[]];
|
|
4
|
+
interface CompiledLocale {
|
|
5
|
+
/** `const oN = {…};` lines the messages refer to. */
|
|
6
|
+
declarations: string[];
|
|
7
|
+
/** `"key": message,` lines. */
|
|
8
|
+
rows: string[];
|
|
9
|
+
}
|
|
10
|
+
/** One locale's messages as code, keeping only `keep` when given. */
|
|
11
|
+
export declare function compileLocale(entries: Iterable<Entry>, keep?: (key: string) => boolean): CompiledLocale;
|
|
12
|
+
/** The locale as an ES module whose default export is its messages. */
|
|
13
|
+
export declare function localeModule(compiled: CompiledLocale, banner: string, ts: boolean): string;
|
|
14
|
+
/** The locale as one expression, for a bundler to inline in place of the module. */
|
|
15
|
+
export declare function localeExpression(compiled: CompiledLocale): string;
|
|
16
|
+
interface Extraction {
|
|
17
|
+
file: string;
|
|
18
|
+
line: number;
|
|
19
|
+
column: number;
|
|
20
|
+
key: string;
|
|
21
|
+
/** The ICU message. */
|
|
22
|
+
message: string;
|
|
23
|
+
/** Whether an entry with this key and message already exists, so none is added. */
|
|
24
|
+
reused: boolean;
|
|
25
|
+
where: string;
|
|
26
|
+
/** The code that replaces the hardcoded text. */
|
|
27
|
+
replacement: string;
|
|
28
|
+
}
|
|
29
|
+
interface NewEntry {
|
|
30
|
+
key: string;
|
|
31
|
+
area: string;
|
|
32
|
+
message: string;
|
|
33
|
+
kind?: string;
|
|
34
|
+
surface?: string;
|
|
35
|
+
context: string;
|
|
36
|
+
args: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
interface Edit$1 {
|
|
39
|
+
start: number;
|
|
40
|
+
end: number;
|
|
41
|
+
text: string;
|
|
42
|
+
}
|
|
43
|
+
interface FilePlan {
|
|
44
|
+
path: string;
|
|
45
|
+
file: string;
|
|
46
|
+
code: string;
|
|
47
|
+
edits: Edit$1[];
|
|
48
|
+
extractions: Extraction[];
|
|
49
|
+
warnings: string[];
|
|
50
|
+
}
|
|
51
|
+
interface ExtractPlan {
|
|
52
|
+
files: FilePlan[];
|
|
53
|
+
entries: NewEntry[];
|
|
54
|
+
/** What said which placeholders are numbers and dates: `TypeScript`, or `syntax` alone. */
|
|
55
|
+
types: string;
|
|
56
|
+
}
|
|
57
|
+
/** The area a file's strings go in: its name in kebab case, or its folder's for an `index`. */
|
|
58
|
+
export declare function areaOf(file: string): string;
|
|
59
|
+
/** A key segment from the words of a message: its first four, plain ASCII, lowercase. */
|
|
60
|
+
export declare function slugOf(message: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* A count followed by a plural noun, `{n, number} files`, as the plural it needs: `{n, plural, one {#
|
|
63
|
+
* file} other {# files}}`. English only, and a draft: the TODO above the entry asks for a look.
|
|
64
|
+
*/
|
|
65
|
+
export declare function draftPlurals(message: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Plans an extraction over the files in `paths` against the current catalog. With `types` (the
|
|
68
|
+
* default), the project's TypeScript says which placeholders are numbers and dates.
|
|
69
|
+
*/
|
|
70
|
+
export declare function planExtract(config: ResolvedConfig, paths: string[], options?: {
|
|
71
|
+
area?: string;
|
|
72
|
+
types?: boolean;
|
|
73
|
+
}): Promise<ExtractPlan>;
|
|
74
|
+
/** Applies a plan: rewrites the files and appends the new entries to their area's catalog file. */
|
|
75
|
+
export declare function applyExtract(config: ResolvedConfig, plan: ExtractPlan): string[];
|
|
76
|
+
interface EntryFields {
|
|
77
|
+
/** The source message. */
|
|
78
|
+
message: string;
|
|
79
|
+
/** By locale. Empty or missing is no translation, so the locale falls back. */
|
|
80
|
+
translations: Record<string, string>;
|
|
81
|
+
context: string;
|
|
82
|
+
kind: string;
|
|
83
|
+
surface: string;
|
|
84
|
+
fragment: boolean;
|
|
85
|
+
/** What each placeholder holds, by name. */
|
|
86
|
+
args: Record<string, string>;
|
|
87
|
+
/** A change asked of whoever edits next; empty is none. */
|
|
88
|
+
comment: string;
|
|
89
|
+
/** Asks for the entry to go, with the code that reads it. */
|
|
90
|
+
remove: boolean;
|
|
91
|
+
}
|
|
92
|
+
interface EntryYaml {
|
|
93
|
+
/** The entry in the catalog, from its key to the end of its value. */
|
|
94
|
+
catalog: string;
|
|
95
|
+
/** By locale, the entry in that locale's file. Empty is no translation. */
|
|
96
|
+
translations?: Record<string, string>;
|
|
97
|
+
}
|
|
98
|
+
interface EntryView {
|
|
99
|
+
key: string;
|
|
100
|
+
/** The source locale. */
|
|
101
|
+
source: string;
|
|
102
|
+
/** Every translated locale, the source aside. */
|
|
103
|
+
locales: string[];
|
|
104
|
+
/** Relative to the project root. A locale without the entry names the file it would go in. */
|
|
105
|
+
files: {
|
|
106
|
+
catalog: string;
|
|
107
|
+
translations: Record<string, string>;
|
|
108
|
+
};
|
|
109
|
+
/** With every locale in `translations`, empty where it has none. */
|
|
110
|
+
fields: EntryFields;
|
|
111
|
+
yaml: Required<EntryYaml>;
|
|
112
|
+
/** The source message's placeholders. */
|
|
113
|
+
argNames: string[];
|
|
114
|
+
kinds: string[];
|
|
115
|
+
surfaces: string[];
|
|
116
|
+
/** What lint says of the entry as it stands, in every locale. */
|
|
117
|
+
findings: EntryFinding[];
|
|
118
|
+
}
|
|
119
|
+
interface EntryFinding extends Finding {
|
|
120
|
+
/** The locale's text with this finding fixed, so the page can make the fix without lint's code. */
|
|
121
|
+
fixed?: string;
|
|
122
|
+
}
|
|
123
|
+
type EntryEdit = {
|
|
124
|
+
fields: EntryFields;
|
|
125
|
+
} | {
|
|
126
|
+
yaml: EntryYaml;
|
|
127
|
+
};
|
|
128
|
+
/** The entry for `key`, with its translation in every locale. */
|
|
129
|
+
export declare function readEntry(config: ResolvedConfig, key: string): EntryView;
|
|
130
|
+
/**
|
|
131
|
+
* Applies an edit and checks the catalog with it. With `write`, a clean edit is written; without, it
|
|
132
|
+
* only comes back as the view, which is how the dialog turns fields into YAML and back.
|
|
133
|
+
*/
|
|
134
|
+
export declare function editEntry(config: ResolvedConfig, key: string, edit: EntryEdit, write: boolean): {
|
|
135
|
+
view?: EntryView;
|
|
136
|
+
problems: Problem[];
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Makes the edits that lint's findings carry, each message in its own file, and writes them only if
|
|
140
|
+
* the catalog they make loads clean: the problems come back instead, and nothing is written.
|
|
141
|
+
*/
|
|
142
|
+
export declare function applyFixes(config: ResolvedConfig, catalog: Catalog, findings: Finding[]): {
|
|
143
|
+
fixed: number;
|
|
144
|
+
problems: Problem[];
|
|
145
|
+
};
|
|
146
|
+
interface Lock {
|
|
147
|
+
version: 2;
|
|
148
|
+
/** Source text by hash: every text some translation is anchored to. */
|
|
149
|
+
sources: Record<string, string>;
|
|
150
|
+
/** Per locale, per key: `<source hash>:<translation hash>`. */
|
|
151
|
+
translations: Record<string, Record<string, string>>;
|
|
152
|
+
}
|
|
153
|
+
export declare function hash(text: string): string;
|
|
154
|
+
export declare function emptyLock(): Lock;
|
|
155
|
+
/** The lock at `path`. A version 1 lock, which held only the translations, reads with no source texts. */
|
|
156
|
+
export declare function readLock(path: string): Lock;
|
|
157
|
+
export declare function serializeLock(lock: Lock): string;
|
|
158
|
+
interface StaleTranslation {
|
|
159
|
+
/** The source the translation was made from, where the lock recorded it. */
|
|
160
|
+
was: string | undefined;
|
|
161
|
+
/** The source now. */
|
|
162
|
+
now: string;
|
|
163
|
+
/** The translation, made from `was`. */
|
|
164
|
+
translation: string;
|
|
165
|
+
}
|
|
166
|
+
interface Reconciled {
|
|
167
|
+
lock: Lock;
|
|
168
|
+
/** Per locale, per key: the translations made from a source that has changed since. */
|
|
169
|
+
stale: Map<string, Map<string, StaleTranslation>>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The lock brought up to date with the catalog, and what is stale. `accept` re-anchors the given
|
|
173
|
+
* translations (per locale, keys, or `true` for all of them) to the current source.
|
|
174
|
+
*/
|
|
175
|
+
export declare function reconcile(catalog: Catalog, previous: Lock, accept?: Map<string, Set<string> | true>): Reconciled;
|
|
176
|
+
/** Every locale the app can switch to, in order: the source, the translations, the pseudo-locale. */
|
|
177
|
+
export declare function localesOf(catalog: Catalog, config: ResolvedConfig): string[];
|
|
178
|
+
/** Per locale, the messages its module holds. A translated locale holds only what it translates. */
|
|
179
|
+
export declare function localeEntries(catalog: Catalog, config: ResolvedConfig, stale: Map<string, Map<string, StaleTranslation>>): Map<string, Entry[]>;
|
|
180
|
+
/** The JSON Schema an editor reads to complete and explain catalog entries. */
|
|
181
|
+
export declare function catalogSchema(config: ResolvedConfig): object;
|
|
182
|
+
interface Generated {
|
|
183
|
+
catalog: Catalog;
|
|
184
|
+
/** Absolute path to content. */
|
|
185
|
+
files: Map<string, string>;
|
|
186
|
+
lock: Lock;
|
|
187
|
+
stale: Map<string, Map<string, StaleTranslation>>;
|
|
188
|
+
entries: Map<string, Entry[]>;
|
|
189
|
+
}
|
|
190
|
+
/** Everything `generate` writes, in memory. */
|
|
191
|
+
export declare function render(config: ResolvedConfig, accept?: Map<string, Set<string> | true>): Generated;
|
|
192
|
+
/** Writes what changed. With `check`, writes nothing and returns what would have changed. */
|
|
193
|
+
export declare function writeFiles(files: Map<string, string>, check?: boolean): string[];
|
|
194
|
+
export declare function generate(config: ResolvedConfig, options?: {
|
|
195
|
+
check?: boolean;
|
|
196
|
+
accept?: Map<string, Set<string> | true>;
|
|
197
|
+
}): Generated & {
|
|
198
|
+
changed: string[];
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* A word diff, for showing a translator what changed in the source since they translated it. Words,
|
|
202
|
+
* runs of whitespace and single punctuation marks are the units, so an ICU brace or a period changes
|
|
203
|
+
* on its own rather than taking its word with it.
|
|
204
|
+
*/
|
|
205
|
+
interface DiffPart {
|
|
206
|
+
op: 'same' | 'add' | 'del';
|
|
207
|
+
text: string;
|
|
208
|
+
}
|
|
209
|
+
export declare function wordDiff(before: string, after: string): DiffPart[];
|
|
210
|
+
/** The diff as one line: `Save [-the-]{+a+} draft`, the notation of `git diff --word-diff`. */
|
|
211
|
+
export declare function formatDiff(parts: DiffPart[]): string;
|
|
212
|
+
export declare function pseudoText(text: string): string;
|
|
213
|
+
export declare function pseudoAst(ast: MessageFormatElement[]): MessageFormatElement[];
|
|
214
|
+
type Element$1 = MessageFormatElement;
|
|
215
|
+
/** A function as written: `:number minimumFractionDigits=2`. Kept on the styles it produces, to write back. */
|
|
216
|
+
interface Mf2Function {
|
|
217
|
+
name: string;
|
|
218
|
+
options: Record<string, string>;
|
|
219
|
+
}
|
|
220
|
+
/** An MF2 message as the element tree. Throws, with the fix, where it can't be read or compiled. */
|
|
221
|
+
export declare function parseMf2(text: string, locale: string): Element$1[];
|
|
222
|
+
/** The `Intl.NumberFormat` options a numeric function formats with. */
|
|
223
|
+
export declare function intlNumber(fn: Mf2Function): Intl.NumberFormatOptions;
|
|
224
|
+
/**
|
|
225
|
+
* The `Intl.DateTimeFormat` options a date or time function formats with. MF2's date and time
|
|
226
|
+
* functions are still a draft; this follows the spec's semantic options as the `messageformat`
|
|
227
|
+
* package does, so a message reads the same in both.
|
|
228
|
+
*/
|
|
229
|
+
export declare function intlDate(fn: Mf2Function): Intl.DateTimeFormatOptions;
|
|
230
|
+
/** A message tree as MF2 text. Throws, saying what has no MF2 equivalent, where it can't be written. */
|
|
231
|
+
export declare function toMf2(ast: Element$1[], locale: string): string;
|
|
232
|
+
type Element = MessageFormatElement;
|
|
233
|
+
export declare function toMf1(ast: Element[]): string;
|
|
234
|
+
type MessageFormatVersion = 1 | 2;
|
|
235
|
+
export declare const SYNTAX_NAME: Record<MessageFormatVersion, string>;
|
|
236
|
+
/**
|
|
237
|
+
* A message as the element tree. MF2 is read per locale: which variants a value can reach depends
|
|
238
|
+
* on the locale's plural rules (see `matchTree` in mf2.ts).
|
|
239
|
+
*/
|
|
240
|
+
export declare function readMessage(version: MessageFormatVersion, text: string, locale: string): MessageFormatElement[];
|
|
241
|
+
/** A tree as text in the given syntax. Throws, saying what the syntax can't express, where it can't. */
|
|
242
|
+
export declare function writeMessage(version: MessageFormatVersion, ast: MessageFormatElement[], locale: string): string;
|
|
243
|
+
interface Located {
|
|
244
|
+
key: string;
|
|
245
|
+
locale: string;
|
|
246
|
+
/** The file, relative to the project root. */
|
|
247
|
+
file: string;
|
|
248
|
+
}
|
|
249
|
+
interface MigratePlan {
|
|
250
|
+
to: MessageFormatVersion;
|
|
251
|
+
rewrites: (Located & {
|
|
252
|
+
before: string;
|
|
253
|
+
after: string;
|
|
254
|
+
})[];
|
|
255
|
+
/** Messages the target syntax can't say, and why. Nothing is written while there are any. */
|
|
256
|
+
blocked: (Located & {
|
|
257
|
+
reason: string;
|
|
258
|
+
})[];
|
|
259
|
+
/** Messages that would render differently, with the first values that show it. */
|
|
260
|
+
changed: (Located & {
|
|
261
|
+
values: string;
|
|
262
|
+
before: string;
|
|
263
|
+
after: string;
|
|
264
|
+
})[];
|
|
265
|
+
}
|
|
266
|
+
export declare function planMigrate(config: ResolvedConfig, to: MessageFormatVersion): MigratePlan;
|
|
267
|
+
/** Writes the plan's rewrites into the YAML files, keeping their comments and layout. Returns the files written. */
|
|
268
|
+
export declare function applyMigrate(config: ResolvedConfig, plan: MigratePlan): string[];
|
|
269
|
+
type Node = {
|
|
270
|
+
type: string;
|
|
271
|
+
start: number;
|
|
272
|
+
end: number;
|
|
273
|
+
[field: string]: any;
|
|
274
|
+
};
|
|
275
|
+
/** `node` is markup or an object, which a message can't hold as text. */
|
|
276
|
+
type ValueKind = 'string' | 'number' | 'date' | 'node' | 'unknown';
|
|
277
|
+
interface Span {
|
|
278
|
+
start: number;
|
|
279
|
+
end: number;
|
|
280
|
+
}
|
|
281
|
+
interface TypeOracle {
|
|
282
|
+
/** Where the answers come from, for the report. */
|
|
283
|
+
readonly source: string;
|
|
284
|
+
/** The kind of each span's expression in `file`, or nothing where the oracle can't say. */
|
|
285
|
+
kinds(file: string, spans: readonly Span[]): Promise<(ValueKind | undefined)[]>;
|
|
286
|
+
close(): Promise<void>;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* An oracle over the projects the files belong to, or nothing where TypeScript 7 isn't installed or
|
|
290
|
+
* none of the files has a tsconfig. One compiler process serves every project and is closed by `close`.
|
|
291
|
+
*/
|
|
292
|
+
export declare function typescriptOracle(root: string, files: readonly string[]): Promise<TypeOracle | undefined>;
|
|
293
|
+
/** The kind an expression's syntax gives away, where it does: `items.length`, `a * b`, `new Date()`. */
|
|
294
|
+
export declare function syntaxKind(expr: Node): ValueKind | undefined;
|
|
295
|
+
interface SarifResult {
|
|
296
|
+
/** A rule the report describes, or one of a lint plugin's. */
|
|
297
|
+
rule: string;
|
|
298
|
+
level: 'error' | 'warning';
|
|
299
|
+
message: string;
|
|
300
|
+
/** Relative to the project root, with forward slashes; none for a problem that isn't in a file. */
|
|
301
|
+
file?: string;
|
|
302
|
+
/** From 1; none for the file as a whole. */
|
|
303
|
+
line?: number;
|
|
304
|
+
column?: number;
|
|
305
|
+
}
|
|
306
|
+
interface SarifTool {
|
|
307
|
+
name: string;
|
|
308
|
+
version: string;
|
|
309
|
+
informationUri: string;
|
|
310
|
+
}
|
|
311
|
+
/** Collects what a command found, then writes it as one SARIF run. */
|
|
312
|
+
export declare class SarifReport {
|
|
313
|
+
readonly results: SarifResult[];
|
|
314
|
+
private readonly rules;
|
|
315
|
+
/** Describes a rule in one sentence; the first description given for an id stands. */
|
|
316
|
+
rule(id: string, description?: string): void;
|
|
317
|
+
add(result: SarifResult): void;
|
|
318
|
+
toJSON(root: string, tool: SarifTool): object;
|
|
319
|
+
}
|
|
320
|
+
export declare function sourceFiles(dirs: string[], extensions: string[], skip?: string[]): string[];
|
|
321
|
+
interface KeyRefs {
|
|
322
|
+
exact: Set<string>;
|
|
323
|
+
/** `nav.` from `nav.${id}` or `'nav.' + id`: every key under it may be read. */
|
|
324
|
+
prefixes: Set<string>;
|
|
325
|
+
}
|
|
326
|
+
export declare function keyRefs(code: string, into?: KeyRefs): KeyRefs;
|
|
327
|
+
export declare function isReferenced(key: string, refs: KeyRefs): boolean;
|
|
328
|
+
interface Hardcoded {
|
|
329
|
+
file: string;
|
|
330
|
+
line: number;
|
|
331
|
+
column: number;
|
|
332
|
+
text: string;
|
|
333
|
+
/** Where it sits: `text`, or the attribute it is the value of. */
|
|
334
|
+
where: string;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Text that reads as code rather than prose: one token holding a path, a call, an identifier with an
|
|
338
|
+
* underscore or a dotted name, as in `form.json()` or `src/index.ts`. Trailing punctuation doesn't
|
|
339
|
+
* count, so `Done.` is still prose.
|
|
340
|
+
*/
|
|
341
|
+
export declare function looksLikeCode(text: string): boolean;
|
|
342
|
+
/** Literal text in JSX that a person reads, where it should be a catalog entry. */
|
|
343
|
+
export declare function hardcodedText(file: string, code: string, attributes: string[]): Hardcoded[];
|
|
344
|
+
interface ScanResult {
|
|
345
|
+
hardcoded: Hardcoded[];
|
|
346
|
+
refs: KeyRefs;
|
|
347
|
+
files: number;
|
|
348
|
+
}
|
|
349
|
+
export declare function scan(dirs: string[], extensions: string[], attributes: string[], root: string, skip?: string[]): ScanResult;
|
|
350
|
+
/** A copy's methods that take a key first. */
|
|
351
|
+
export declare const READERS: Set<string>;
|
|
352
|
+
interface UnseenRead {
|
|
353
|
+
file: string;
|
|
354
|
+
line: number;
|
|
355
|
+
column: number;
|
|
356
|
+
/** The read as written, on one line. */
|
|
357
|
+
code: string;
|
|
358
|
+
/** What it calls: a reader, the name it was imported by, or `Text`. */
|
|
359
|
+
name: string;
|
|
360
|
+
}
|
|
361
|
+
interface Reads {
|
|
362
|
+
/** Reads whose key a build can't see, in calls that may be to a copy's `t` or `rich`. */
|
|
363
|
+
unseen: UnseenRead[];
|
|
364
|
+
/** Names a copy's readers are bound to here, as in `const { rich: tRich } = copy`. */
|
|
365
|
+
aliases: Set<string>;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* The reads in a module whose key a pruned build can't see, as in `t(item.key)` or `<Text id={id} />`:
|
|
369
|
+
* the build would leave the message out, and the key would show in its place. A build has no types,
|
|
370
|
+
* so readers are known by name: `t` and `rich` called alone or as methods, and any name imported here,
|
|
371
|
+
* which may be bound to one elsewhere (`aliases`); the caller keeps those whose name turns out to be a
|
|
372
|
+
* reader. `<Text>` counts where it is imported from `prosebook/react`. Lines marked `prosebook-ignore`
|
|
373
|
+
* are skipped.
|
|
374
|
+
*/
|
|
375
|
+
export declare function unseenReads(file: string, code: string): Reads;
|
|
376
|
+
export { CORE_RULES, type CapitalizationRule, type Catalog, CatalogError, type CheckRule, type CompiledLocale, type ConditionalRule, type CoreRule, DEFAULT_KINDS, DEFAULT_SURFACES, type DiffPart, type Edit, type Entry, type EntryEdit, type EntryFields, type EntryFinding, type EntryLocation, type EntryView, type EntryYaml, type ExistenceRule, type ExtractPlan, type Extraction, type FilePlan, type Finding, type Generated, HOLE, type Hardcoded, KEY_PATTERN, type KeyRefs, type KindRule, type Lock, type Message, type MessageFormatVersion, type Mf2Function, type MigratePlan, type NewEntry, type OccurrenceRule, type Plugin, type Problem, type ProsebookConfig, type Readings, type Reads, type Report, type ResolvedConfig, type Rule, type RuleContext, STRICT_LISTS, type SarifResult, type SarifTool, type Severity, type Span, type StaleTranslation, type SubstitutionRule, type Translation, type TypeOracle, type UnseenRead, type ValueKind, applyEdits, compileRule, defineConfig, definePlugin, entryLocation, lint, loadCatalog, loadConfig, phrase, previewOf, resolveConfig, sentences, singularOf, whereOf, words };
|
|
377
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","names":["Edit","Element"],"sources":["../src/tools/compile.ts","../src/tools/extract.ts","../src/tools/entry.ts","../src/tools/lock.ts","../src/tools/generate.ts","../src/tools/diff.ts","../src/tools/pseudo.ts","../src/tools/mf2.ts","../src/tools/mf1.ts","../src/tools/syntax.ts","../src/tools/migrate.ts","../src/tools/types.ts","../src/tools/sarif.ts","../src/tools/scan.ts"],"mappings":";;KAaY,kBAAkB,aAAa,KAAK;UA4E/B;;EAEf;;EAEA;;;wBAIc,cAAc,SAAS,SAAS,QAAQ,QAAQ,0BAA0B;;wBAW1E,aAAa,UAAU,gBAAgB,gBAAgB;;wBAUvD,iBAAiB,UAAU;UC5F1B;EACf;EACA;EACA;EACA;;EAEA;;EAEA;EACA;;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AAU;;wBAMI,QAAQ,cAAc,OAAM,UAAsD;wBAMlF,aAAa,aAAa,MAAM;UAM/B;EACf;EACA;EACA;EACA;;EAEA;;;;;;;wBAUc,cAAc;;wBAiCd,cAAc,cAAc,cAAc,uBAAuB;UAsDhE;EACf,WAAW;EACX,MAAM;EACN;;wBAGc,KAAK,gBAAgB,sBAAsB,sBAAsB,cAAc,kBAAsB;;qBAaxG,SAAO;UAEH;EACf;EACA;EACA;;EAEA;;EAEA;;UAGe;;EAEf,QAAQ;;EAER,SAAS;;;;;;;;;;wBA6CK,YAAY,cAAc,eAAe"}
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { A as entryLocation, B as parseMf2, C as editEntry, D as localeModule, E as localeExpression, F as SYNTAX_NAME, H as toMf1, I as readMessage, L as writeMessage, M as loadCatalog, N as previewOf, O as CatalogError, P as whereOf, R as intlDate, S as applyFixes, T as compileLocale, V as toMf2, _ as emptyLock, a as looksLikeCode, b as reconcile, c as unseenReads, d as localeEntries, f as localesOf, g as pseudoText, h as pseudoAst, i as keyRefs, k as KEY_PATTERN, l as catalogSchema, m as writeFiles, n as hardcodedText, o as scan, p as render, r as isReferenced, s as sourceFiles, t as READERS, u as generate, v as hash, w as readEntry, x as serializeLock, y as readLock, z as intlNumber } from "./scan-Ch2BfIUD.js";
|
|
2
|
+
import { a as wordDiff, c as draftPlurals, d as syntaxKind, f as typescriptOracle, i as formatDiff, l as planExtract, n as applyMigrate, o as applyExtract, r as planMigrate, s as areaOf, t as SarifReport, u as slugOf } from "./sarif-CI8HOokm.js";
|
|
3
|
+
import { _ as words, a as DEFAULT_KINDS, c as CORE_RULES, d as compileRule, f as definePlugin, g as singularOf, h as sentences, i as resolveConfig, l as HOLE, m as phrase, n as defineConfig, o as DEFAULT_SURFACES, p as lint, r as loadConfig, s as STRICT_LISTS, u as applyEdits } from "./config-D--RITk2.js";
|
|
4
|
+
export { CORE_RULES, CatalogError, DEFAULT_KINDS, DEFAULT_SURFACES, HOLE, KEY_PATTERN, READERS, STRICT_LISTS, SYNTAX_NAME, SarifReport, applyEdits, applyExtract, applyFixes, applyMigrate, areaOf, catalogSchema, compileLocale, compileRule, defineConfig, definePlugin, draftPlurals, editEntry, emptyLock, entryLocation, formatDiff, generate, hardcodedText, hash, intlDate, intlNumber, isReferenced, keyRefs, lint, loadCatalog, loadConfig, localeEntries, localeExpression, localeModule, localesOf, looksLikeCode, parseMf2, phrase, planExtract, planMigrate, previewOf, pseudoAst, pseudoText, readEntry, readLock, readMessage, reconcile, render, resolveConfig, scan, sentences, serializeLock, singularOf, slugOf, sourceFiles, syntaxKind, toMf1, toMf2, typescriptOracle, unseenReads, whereOf, wordDiff, words, writeFiles, writeMessage };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { r as ProsebookConfig } from "./config-_4HfnJQu.js";
|
|
2
|
+
import { Plugin } from "vite";
|
|
3
|
+
export interface ProsebookPluginOptions {
|
|
4
|
+
/** The config, inline. Without it, `prosebook.config.*` at `root` is read. */
|
|
5
|
+
config?: ProsebookConfig;
|
|
6
|
+
/**
|
|
7
|
+
* The folder the config's paths resolve from, and where its file is found: the Vite root when
|
|
8
|
+
* unset. Apps that share one catalog name its folder, so each build generates the same files.
|
|
9
|
+
*/
|
|
10
|
+
root?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Ship only the messages the code names. `strict`, the default, also fails the build on a read
|
|
13
|
+
* whose key it can't see, such as `t(item.key)`, which would show the key where its message was
|
|
14
|
+
* pruned. `loose` prunes without that check; `false` ships every message.
|
|
15
|
+
*/
|
|
16
|
+
prune?: 'strict' | 'loose' | false;
|
|
17
|
+
/** Keys a build always keeps, exactly or as `prefix.*`: for keys built at runtime from data. */
|
|
18
|
+
keep?: string[];
|
|
19
|
+
/** In dev, Alt-click a string on the page to open its entry in the editor. On by default. */
|
|
20
|
+
inspect?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function prosebook(options?: ProsebookPluginOptions): Plugin;
|
|
23
|
+
export { prosebook as default };
|
|
24
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":";;iBA2BiB;;EAEf,SAAS;;;;;EAKT;;;;;;EAMA;;EAEA;;EAEA;;wBAgCc,UAAU,UAAS,yBAA8B"}
|