@rohal12/twee-ts 1.18.2 → 2.0.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 +23 -3
- package/THIRD_PARTY_NOTICES +111 -0
- package/UNLICENSE +24 -0
- package/dist/bin/twee-ts.js +689 -9446
- package/dist/bin/twee-ts.js.map +1 -1
- package/dist/diagnostic-text-BRddVulf.cjs +26463 -0
- package/dist/diagnostic-text-BRddVulf.cjs.map +1 -0
- package/dist/diagnostic-text-CebYCTPQ.js +26040 -0
- package/dist/diagnostic-text-CebYCTPQ.js.map +1 -0
- package/dist/index.cjs +86 -9137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +192 -416
- package/dist/index.d.ts +192 -416
- package/dist/index.js +4 -9317
- package/dist/lint-VayZI_jp.js +288 -0
- package/dist/lint-VayZI_jp.js.map +1 -0
- package/dist/options-DuBkFyqi.d.cts +28 -0
- package/dist/options-nc5NpnSc.d.ts +28 -0
- package/dist/plugins/rollup.cjs +172 -0
- package/dist/plugins/rollup.cjs.map +1 -0
- package/dist/plugins/rollup.d.cts +46 -0
- package/dist/plugins/rollup.d.ts +7 -12
- package/dist/plugins/rollup.js +130 -65
- package/dist/plugins/rollup.js.map +1 -1
- package/dist/plugins/vite.cjs +1926 -0
- package/dist/plugins/vite.cjs.map +1 -0
- package/dist/plugins/vite.d.cts +15 -0
- package/dist/plugins/vite.d.ts +5 -12
- package/dist/plugins/vite.js +1763 -458
- package/dist/plugins/vite.js.map +1 -1
- package/dist/types-BvI6pg2y.d.cts +389 -0
- package/dist/types-BvI6pg2y.d.ts +389 -0
- package/dist/watch-targets-BI7jYrwa.js +486 -0
- package/dist/watch-targets-BI7jYrwa.js.map +1 -0
- package/dist/watch-targets-C0Anuw17.cjs +575 -0
- package/dist/watch-targets-C0Anuw17.cjs.map +1 -0
- package/package.json +80 -27
- package/schemas/twee-ts.config.schema.json +55 -17
- package/dist/index.js.map +0 -1
- package/dist/paths-BuTAg2av.js +0 -7044
- package/dist/paths-BuTAg2av.js.map +0 -1
- package/dist/types-D8Xfe0l8.d.ts +0 -71
package/dist/index.d.cts
CHANGED
|
@@ -1,333 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { A as StoryFormatInfo, C as RemoteResolveOptions, D as SourceInput, E as SemVer, F as Twine2Metadata, I as WatchOptions, L as WordCountMethod, M as TweeTsErrorCode, N as Twine1Metadata, O as SourceLocation, P as Twine2FormatJSON, S as RemoteFetchOptions, T as SFAIndexEntry, _ as PassageMetadata, a as DecompileOptions, b as ReadonlyPassage, c as FileCacheEntry, d as InspectOptions, f as ItemType, g as Passage, h as OutputMode, i as CompileToFileOptions, j as TweeTsConfig, k as Story, l as IFID, m as OmittingTag, n as CompileResult, o as Diagnostic, p as LexerItem, r as CompileStats, s as ExcludeGlob, t as CompileOptions, u as InlineSource, v as PassageOmission, w as SFAIndex, x as ReadonlyStory, y as PassageOutputTarget } from "./types-BvI6pg2y.cjs";
|
|
3
|
+
//#region src/filesystem.d.ts
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
5
|
+
* A watched path that can't be watched: fs.watch failed on it, or on the folder it is
|
|
6
|
+
* watched through. watchFilesystem passes it to its `onError` and keeps watching the rest.
|
|
4
7
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
filename: string;
|
|
9
|
-
content: string | Buffer;
|
|
10
|
-
};
|
|
11
|
-
type SourceInput = string | InlineSource;
|
|
12
|
-
interface CompileOptions {
|
|
13
|
-
/**
|
|
14
|
-
* Files, directories, or inline sources to compile. Directories are walked
|
|
15
|
-
* recursively; inside one, a symbolic link to a file is read, but a link to a
|
|
16
|
-
* directory is not followed (as in Tweego).
|
|
17
|
-
*/
|
|
18
|
-
sources: readonly SourceInput[];
|
|
19
|
-
/**
|
|
20
|
-
* Glob patterns for files to leave out of `sources`, matched against each file's
|
|
21
|
-
* path relative to the working directory (as `stats.files` lists it). Modules are not affected.
|
|
22
|
-
*/
|
|
23
|
-
exclude?: readonly string[];
|
|
24
|
-
/** Output mode. Default: 'html'. */
|
|
25
|
-
outputMode?: OutputMode;
|
|
26
|
-
/** Story format directory ID (e.g. 'sugarcube-2'). */
|
|
27
|
-
formatId?: string;
|
|
28
|
-
/** Name of the starting passage. Default: 'Start'. */
|
|
29
|
-
startPassage?: string;
|
|
30
|
-
/** Extra directories to search for story formats. */
|
|
31
|
-
formatPaths?: readonly string[];
|
|
32
|
-
/** Also search TWEEGO_PATH env for formats. Default: true. */
|
|
33
|
-
useTweegoPath?: boolean;
|
|
34
|
-
/** Module files to inject into <head>. */
|
|
35
|
-
modules?: readonly string[];
|
|
36
|
-
/** Raw HTML file to append to <head>. */
|
|
37
|
-
headFile?: string;
|
|
38
|
-
/** Trim passage whitespace. Default: true. */
|
|
39
|
-
trim?: boolean;
|
|
40
|
-
/** Twee2 compatibility mode. Default: false. */
|
|
41
|
-
twee2Compat?: boolean;
|
|
42
|
-
/** Enable debug/test mode option. Default: false. */
|
|
43
|
-
testMode?: boolean;
|
|
44
|
-
/** URLs to SFA-compatible index.json files for remote format lookup. */
|
|
45
|
-
formatIndices?: readonly string[];
|
|
46
|
-
/**
|
|
47
|
-
* Direct URLs to format.js files. Each URL's download is cached under that URL, and is
|
|
48
|
-
* looked up before the downloads shared by name and version.
|
|
49
|
-
*/
|
|
50
|
-
formatUrls?: readonly string[];
|
|
51
|
-
/** Disable remote format fetching. Default: false. */
|
|
52
|
-
noRemote?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Cancels the compile. Story format requests still in progress are aborted, and the compile
|
|
55
|
-
* rejects with the signal's reason. `watch()` aborts its builds, and stops watching, when it aborts.
|
|
56
|
-
*/
|
|
57
|
-
signal?: AbortSignal;
|
|
58
|
-
/**
|
|
59
|
-
* Milliseconds each story format request (an index or a format.js) may take before it fails
|
|
60
|
-
* with a warning and the next source is tried. 0 turns the limit off. Default: 30000.
|
|
61
|
-
*/
|
|
62
|
-
formatFetchTimeout?: number;
|
|
63
|
-
/** Map alias tags to canonical special tags (e.g. { library: 'script' }). */
|
|
64
|
-
tagAliases?: Record<string, string>;
|
|
65
|
-
/** Emit source file and line as data- attributes on passage elements. Default: false. */
|
|
66
|
-
sourceInfo?: boolean;
|
|
67
|
-
/** Word counting method. Default: 'tweego'. */
|
|
68
|
-
wordCountMethod?: WordCountMethod;
|
|
69
|
-
}
|
|
70
|
-
interface CompileToFileOptions extends CompileOptions {
|
|
71
|
-
/**
|
|
72
|
-
* Output file path. It is never read as a source, even inside a source folder or
|
|
73
|
-
* reached through a symbolic link. Naming it as a source, a module or the head
|
|
74
|
-
* file is a TweeTsError, and nothing is written.
|
|
75
|
-
*/
|
|
76
|
-
outFile: string;
|
|
77
|
-
}
|
|
78
|
-
interface WatchOptions extends CompileToFileOptions {
|
|
79
|
-
/**
|
|
80
|
-
* Called after each build is written, including one whose diagnostics report errors. Builds
|
|
81
|
-
* run one at a time and are reported in order, each as it finishes, also while changes keep
|
|
82
|
-
* arriving: the changes made during a build go into one follow-up build after it.
|
|
83
|
-
*/
|
|
84
|
-
onBuild?: (result: CompileResult) => void;
|
|
85
|
-
/**
|
|
86
|
-
* Called when a build fails with a fatal error (nothing is written), when `onBuild` throws,
|
|
87
|
-
* and when a watched path can't be watched (the other paths are still watched). An exception
|
|
88
|
-
* thrown here is reported to the console, and watching goes on.
|
|
89
|
-
*/
|
|
90
|
-
onError?: (error: Error) => void;
|
|
91
|
-
}
|
|
92
|
-
type Diagnostic = {
|
|
93
|
-
level: 'warning';
|
|
94
|
-
message: string;
|
|
95
|
-
file?: string;
|
|
96
|
-
line?: number;
|
|
97
|
-
} | {
|
|
98
|
-
level: 'error';
|
|
99
|
-
message: string;
|
|
100
|
-
file?: string;
|
|
101
|
-
line?: number;
|
|
102
|
-
fatal?: boolean;
|
|
103
|
-
};
|
|
104
|
-
interface CompileResult {
|
|
105
|
-
/** The compiled output string (HTML, Twee, JSON, etc.). */
|
|
106
|
-
output: string;
|
|
107
|
-
/** The parsed story model (read-only after compilation). */
|
|
108
|
-
story: ReadonlyStory;
|
|
109
|
-
/** The format used for compilation (undefined for non-HTML modes). */
|
|
110
|
-
format?: StoryFormatInfo;
|
|
111
|
-
/** Collected diagnostics. */
|
|
112
|
-
diagnostics: Diagnostic[];
|
|
113
|
-
/** Compilation statistics. */
|
|
114
|
-
stats: CompileStats;
|
|
115
|
-
}
|
|
116
|
-
interface CompileStats {
|
|
117
|
-
passages: number;
|
|
118
|
-
storyPassages: number;
|
|
119
|
-
words: number;
|
|
120
|
-
files: string[];
|
|
121
|
-
}
|
|
122
|
-
interface SourceLocation {
|
|
123
|
-
readonly file: string;
|
|
124
|
-
readonly line: number;
|
|
125
|
-
}
|
|
126
|
-
interface PassageMetadata {
|
|
127
|
-
position?: string;
|
|
128
|
-
size?: string;
|
|
129
|
-
[key: string]: string | undefined;
|
|
8
|
+
export declare class WatchPathError extends Error {
|
|
9
|
+
readonly path: string;
|
|
10
|
+
constructor(path: string, cause: unknown);
|
|
130
11
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
type IFID = string & {
|
|
139
|
-
readonly __brand: 'IFID';
|
|
140
|
-
};
|
|
141
|
-
interface Twine1Metadata {
|
|
142
|
-
settings: Map<string, string>;
|
|
143
|
-
}
|
|
144
|
-
interface Twine2Metadata {
|
|
145
|
-
format: string;
|
|
146
|
-
formatVersion: string;
|
|
147
|
-
options: Map<string, boolean>;
|
|
148
|
-
start: string;
|
|
149
|
-
tags: string;
|
|
150
|
-
tagColors: Map<string, string>;
|
|
151
|
-
zoom: number;
|
|
152
|
-
}
|
|
153
|
-
interface Story {
|
|
154
|
-
name: string;
|
|
155
|
-
ifid: IFID;
|
|
156
|
-
passages: Passage[];
|
|
157
|
-
legacyIFID: IFID;
|
|
158
|
-
twine1: Twine1Metadata;
|
|
159
|
-
twine2: Twine2Metadata;
|
|
160
|
-
}
|
|
161
|
-
type ReadonlyPassage = Readonly<Omit<Passage, 'tags' | 'metadata'>> & {
|
|
162
|
-
readonly tags: readonly string[];
|
|
163
|
-
readonly metadata?: Readonly<PassageMetadata>;
|
|
164
|
-
};
|
|
165
|
-
type ReadonlyStory = Readonly<Omit<Story, 'passages' | 'twine1' | 'twine2'>> & {
|
|
166
|
-
readonly passages: readonly ReadonlyPassage[];
|
|
167
|
-
readonly twine1: Readonly<Omit<Twine1Metadata, 'settings'>> & {
|
|
168
|
-
readonly settings: ReadonlyMap<string, string>;
|
|
169
|
-
};
|
|
170
|
-
readonly twine2: Readonly<Omit<Twine2Metadata, 'options' | 'tagColors'>> & {
|
|
171
|
-
readonly options: ReadonlyMap<string, boolean>;
|
|
172
|
-
readonly tagColors: ReadonlyMap<string, string>;
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
type OmittingTag = 'Twine.private' | 'script' | 'stylesheet';
|
|
176
|
-
type PassageOmission = {
|
|
177
|
-
readonly kind: 'special-name';
|
|
178
|
-
readonly name: 'StoryData' | 'StoryTitle';
|
|
179
|
-
} | {
|
|
180
|
-
readonly kind: 'tag';
|
|
181
|
-
readonly tag: OmittingTag;
|
|
182
|
-
} | {
|
|
183
|
-
readonly kind: 'empty-story-settings';
|
|
184
|
-
};
|
|
185
|
-
/** The output whose rules decide which passages a story emits as passages. */
|
|
186
|
-
type PassageOutputTarget = 'twine1' | 'twine2';
|
|
187
|
-
interface DecompileOptions {
|
|
188
|
-
/**
|
|
189
|
-
* Trim whitespace at both ends of passage text (and of the Twine 2 story stylesheet and script),
|
|
190
|
-
* as the Twee lexer does. When false, the stored text is kept exactly. Default: true.
|
|
191
|
-
*/
|
|
192
|
-
readonly trim?: boolean;
|
|
193
|
-
}
|
|
194
|
-
interface InspectOptions {
|
|
195
|
-
/**
|
|
196
|
-
* Check link destinations against this output's passage rules. A link to a passage that the
|
|
197
|
-
* output leaves out (in Twine 2: `script`, `stylesheet` and `Twine.private` passages,
|
|
198
|
-
* StoryData, StoryTitle and an empty StorySettings; in Twine 1: `Twine.private` passages) is
|
|
199
|
-
* then a broken link, and says why. The passages it leaves out also give no links, as their
|
|
200
|
-
* text never reaches the player, except script passages, which Twine 2 output runs. Without a
|
|
201
|
-
* target, every source passage gives links, and a link is broken only when no passage has its
|
|
202
|
-
* name.
|
|
203
|
-
*/
|
|
204
|
-
readonly target?: PassageOutputTarget;
|
|
205
|
-
}
|
|
206
|
-
interface StoryFormatInfo {
|
|
207
|
-
id: string;
|
|
208
|
-
filename: string;
|
|
209
|
-
isTwine2: boolean;
|
|
210
|
-
name: string;
|
|
211
|
-
version: string;
|
|
212
|
-
proofing: boolean;
|
|
213
|
-
author?: string;
|
|
214
|
-
description?: string;
|
|
215
|
-
image?: string;
|
|
216
|
-
url?: string;
|
|
217
|
-
license?: string;
|
|
218
|
-
}
|
|
219
|
-
interface Twine2FormatJSON {
|
|
220
|
-
name: string;
|
|
221
|
-
version: string;
|
|
222
|
-
proofing?: boolean;
|
|
223
|
-
source: string;
|
|
224
|
-
author?: string;
|
|
225
|
-
description?: string;
|
|
226
|
-
image?: string;
|
|
227
|
-
url?: string;
|
|
228
|
-
license?: string;
|
|
229
|
-
}
|
|
230
|
-
export declare const ItemType: {
|
|
231
|
-
readonly Error: 0;
|
|
232
|
-
readonly EOF: 1;
|
|
233
|
-
readonly Header: 2;
|
|
234
|
-
readonly Name: 3;
|
|
235
|
-
readonly Tags: 4;
|
|
236
|
-
readonly Metadata: 5;
|
|
237
|
-
readonly Content: 6;
|
|
238
|
-
};
|
|
239
|
-
export type ItemType = (typeof ItemType)[keyof typeof ItemType];
|
|
240
|
-
interface LexerItem {
|
|
241
|
-
type: ItemType;
|
|
242
|
-
line: number;
|
|
243
|
-
pos: number;
|
|
244
|
-
val: string;
|
|
245
|
-
}
|
|
246
|
-
interface SFAIndexEntry {
|
|
247
|
-
name: string;
|
|
248
|
-
version: string;
|
|
249
|
-
proofing: boolean;
|
|
250
|
-
files: string[];
|
|
251
|
-
checksums: Record<string, string>;
|
|
252
|
-
}
|
|
253
|
-
interface SFAIndex {
|
|
254
|
-
twine1: SFAIndexEntry[];
|
|
255
|
-
twine2: SFAIndexEntry[];
|
|
256
|
-
}
|
|
257
|
-
/** Options for the network requests that fetch story formats and their indices. */
|
|
258
|
-
interface RemoteFetchOptions {
|
|
259
|
-
/** Aborts the requests; the call then rejects with the signal's reason. */
|
|
260
|
-
readonly signal?: AbortSignal;
|
|
261
|
-
/** Milliseconds each request may take before it fails. 0 turns the limit off. Default: 30000. */
|
|
262
|
-
readonly timeout?: number;
|
|
263
|
-
}
|
|
264
|
-
interface FileCacheEntry {
|
|
265
|
-
readonly mtimeMs: number;
|
|
266
|
-
/**
|
|
267
|
-
* Identity of the parse options (`trim`, `twee2Compat`) the entry was parsed with. An entry is
|
|
268
|
-
* reused only when this matches the current options; an entry without it is treated as stale
|
|
269
|
-
* and reparsed. The value is opaque: leave it to twee-ts to set.
|
|
270
|
-
*/
|
|
271
|
-
readonly parseOptionsKey?: string;
|
|
272
|
-
readonly passages: readonly Passage[];
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/errors.d.ts
|
|
14
|
+
/**
|
|
15
|
+
* A build that could not run: nothing was built or written. `code` says why (see TweeTsErrorCode),
|
|
16
|
+
* `diagnostics` holds what the build reported before it stopped, and `cause` the error behind it, if any.
|
|
17
|
+
*/
|
|
18
|
+
export declare class TweeTsError extends Error {
|
|
273
19
|
readonly diagnostics: readonly Diagnostic[];
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
outputMode?: OutputMode;
|
|
280
|
-
formatId?: string;
|
|
281
|
-
startPassage?: string;
|
|
282
|
-
formatPaths?: string[];
|
|
283
|
-
formatIndices?: string[];
|
|
284
|
-
formatUrls?: string[];
|
|
285
|
-
useTweegoPath?: boolean;
|
|
286
|
-
modules?: string[];
|
|
287
|
-
headFile?: string;
|
|
288
|
-
trim?: boolean;
|
|
289
|
-
twee2Compat?: boolean;
|
|
290
|
-
testMode?: boolean;
|
|
291
|
-
noRemote?: boolean;
|
|
292
|
-
/** Milliseconds each story format request may take. 0 turns the limit off. Default: 30000. */
|
|
293
|
-
formatFetchTimeout?: number;
|
|
294
|
-
tagAliases?: Record<string, string>;
|
|
295
|
-
sourceInfo?: boolean;
|
|
296
|
-
wordCountMethod?: WordCountMethod;
|
|
20
|
+
readonly code: TweeTsErrorCode;
|
|
21
|
+
constructor(message: string, diagnostics?: readonly Diagnostic[], options?: {
|
|
22
|
+
readonly code?: TweeTsErrorCode;
|
|
23
|
+
readonly cause?: unknown;
|
|
24
|
+
});
|
|
297
25
|
}
|
|
298
26
|
//#endregion
|
|
299
27
|
//#region src/compiler.d.ts
|
|
300
|
-
export declare class TweeTsError extends Error {
|
|
301
|
-
diagnostics: Diagnostic[];
|
|
302
|
-
constructor(message: string, diagnostics?: Diagnostic[]);
|
|
303
|
-
}
|
|
304
28
|
/**
|
|
305
29
|
* Compile Twee sources to HTML, Twee, or JSON.
|
|
306
30
|
*/
|
|
307
31
|
export declare function compile(options: CompileOptions): Promise<CompileResult>;
|
|
308
32
|
/**
|
|
309
|
-
* Compile and write to a file.
|
|
310
|
-
* build or the new one, never part of it,
|
|
33
|
+
* Compile and write to a file. How the file is written depends on what is there (see atomic-write.ts): a
|
|
34
|
+
* regular file is replaced atomically, so a reader sees the previous build or the new one, never part of it,
|
|
35
|
+
* and a failed write leaves the previous build; a FIFO or a device is written through; a read-only file is
|
|
36
|
+
* refused. An output that can't be written (a read-only file, a missing folder) fails before the build.
|
|
311
37
|
*/
|
|
312
38
|
export declare function compileToFile(options: CompileToFileOptions): Promise<CompileResult>;
|
|
313
39
|
/**
|
|
314
40
|
* Compile with incremental caching support.
|
|
315
41
|
* Plugins and advanced users can manage their own cache and changed-file tracking.
|
|
316
42
|
*
|
|
317
|
-
* Without `changedFiles`, a cached file is reused while its modification time
|
|
318
|
-
* With it, a file it names is always reparsed,
|
|
43
|
+
* Without `changedFiles`, a cached file is reused while its modification time, size, inode and
|
|
44
|
+
* status-change time are unchanged. With it, a file it names is always reparsed, and every
|
|
319
45
|
* other cached file is reused as it is. A file may be named by an absolute path or by a path
|
|
320
|
-
* relative to the working directory, with or without a leading
|
|
321
|
-
* the source files by
|
|
322
|
-
* the next build tries it again.
|
|
46
|
+
* relative to the working directory, with or without a leading `./`, or through a link: entries are
|
|
47
|
+
* matched to the source files by identity (see path-identity.ts). A file that fails to load is
|
|
48
|
+
* dropped from the cache, so the next build tries it again.
|
|
323
49
|
*/
|
|
324
50
|
export declare function compileIncremental(options: CompileOptions, cache: Map<string, FileCacheEntry>, changedFiles?: ReadonlySet<string>): Promise<CompileResult>;
|
|
325
51
|
/**
|
|
326
|
-
* Watch for file changes and recompile. Every build is written to `outFile` (
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
52
|
+
* Watch for file changes and recompile. Every build is written to `outFile` (as compileToFile()
|
|
53
|
+
* writes it), including one whose diagnostics report errors. Builds run one at a time, and each
|
|
54
|
+
* one is written and reported as it finishes, in order: changes made during a build go into one
|
|
55
|
+
* follow-up build after it. A watched path that can't be watched is passed to `onError`.
|
|
56
|
+
*
|
|
57
|
+
* Options that can't work (an output that is also a named input or an authored file in a source or module
|
|
58
|
+
* folder, an out-of-range option) reject the returned promise before anything is watched. A build that fails for such a reason later (a link
|
|
59
|
+
* changed to make the output an input) is passed to `onError`, and watching stops.
|
|
331
60
|
*
|
|
332
61
|
* Aborting the returned controller, or the `signal` in the options, stops watching and
|
|
333
62
|
* aborts the story format requests of the build in progress.
|
|
@@ -337,48 +66,56 @@ export declare function watch(options: WatchOptions): Promise<AbortController>;
|
|
|
337
66
|
//#region src/inspect.d.ts
|
|
338
67
|
interface StoryMap {
|
|
339
68
|
/** All passage names, in source order. */
|
|
340
|
-
passages: string[];
|
|
69
|
+
readonly passages: readonly string[];
|
|
341
70
|
/** Only story passages (excludes StoryData, StoryTitle, scripts, stylesheets, etc.). */
|
|
342
|
-
storyPassages: string[];
|
|
71
|
+
readonly storyPassages: readonly string[];
|
|
343
72
|
/** Only info/special passages. */
|
|
344
|
-
infoPassages: string[];
|
|
73
|
+
readonly infoPassages: readonly string[];
|
|
345
74
|
/** All unique tags used across the story, sorted alphabetically. */
|
|
346
|
-
tags: string[];
|
|
75
|
+
readonly tags: readonly string[];
|
|
347
76
|
/** Map of tag → passage names that carry that tag, each listed once even if the tag is repeated. */
|
|
348
|
-
passagesByTag:
|
|
77
|
+
readonly passagesByTag: ReadonlyMap<string, readonly string[]>;
|
|
349
78
|
/** Map of passage name → tags on that passage, as written (a repeated tag appears twice). */
|
|
350
|
-
tagsByPassage:
|
|
79
|
+
readonly tagsByPassage: ReadonlyMap<string, readonly string[]>;
|
|
351
80
|
/**
|
|
352
81
|
* Map of passage name → passage names it links to.
|
|
353
82
|
* Parses `[[target]]`, `[[display->target]]`, `[[target<-display]]`, `[[display|target]]`,
|
|
354
|
-
* each with or without a setter (`[[display|target][$x to 1]]`),
|
|
355
|
-
* `<<goto "target">>` / `<<link "display" "target"
|
|
356
|
-
*
|
|
83
|
+
* each with or without a setter (`[[display|target][$x to 1]]`), SugarCube's
|
|
84
|
+
* `<<goto "target">>` / `<<link "display" "target">>` / `<<button "display" "target">>`, and
|
|
85
|
+
* elements with a `data-passage="target"` attribute, read as SugarCube 2 reads them
|
|
86
|
+
* (see "How links are read" in docs/api.md). Links and calls in comments are not read. A script passage is
|
|
357
87
|
* read for links only in its strings; a stylesheet passage (including a loaded `.css` file) is
|
|
358
88
|
* CSS and links to nothing. With a `target` (see `InspectOptions`), a passage that output leaves
|
|
359
89
|
* out links to nothing, except a script passage, which Twine 2 output runs.
|
|
360
90
|
*/
|
|
361
|
-
links:
|
|
91
|
+
readonly links: ReadonlyMap<string, readonly string[]>;
|
|
362
92
|
/**
|
|
363
93
|
* Broken links: `{ from, to }` pairs where `to` doesn't exist as a passage, or, with a `target`
|
|
364
94
|
* (see `InspectOptions`), where that output leaves the `to` passage out (`omission` says why).
|
|
365
95
|
*/
|
|
366
|
-
brokenLinks: BrokenLink[];
|
|
96
|
+
readonly brokenLinks: readonly BrokenLink[];
|
|
367
97
|
/** Story passages with no outgoing links (potential dead ends). */
|
|
368
|
-
deadEnds: string[];
|
|
369
|
-
/**
|
|
370
|
-
|
|
98
|
+
readonly deadEnds: readonly string[];
|
|
99
|
+
/**
|
|
100
|
+
* Story passages that the player cannot reach: no chain of links leads to them from the start passage or
|
|
101
|
+
* from an info passage the story format runs or shows without a link (such as StoryInit, PassageHeader, or a
|
|
102
|
+
* `script` or `widget` passage). An `annotation` note, a `Twine.` passage (private or media), StoryData,
|
|
103
|
+
* StorySettings and StoryIncludes are not shown, so links from them count only when a link leads to them. A
|
|
104
|
+
* passage that links only to itself, or a group that links only among itself, is an orphan. Only the links
|
|
105
|
+
* `links` lists count, so a passage that is shown only through a macro such as `<<include>>` is listed too.
|
|
106
|
+
*/
|
|
107
|
+
readonly orphans: readonly string[];
|
|
371
108
|
/** The configured start passage name, if any. */
|
|
372
|
-
start: string;
|
|
109
|
+
readonly start: string;
|
|
373
110
|
}
|
|
374
111
|
interface BrokenLink {
|
|
375
|
-
from: string;
|
|
376
|
-
to: string;
|
|
112
|
+
readonly from: string;
|
|
113
|
+
readonly to: string;
|
|
377
114
|
/**
|
|
378
115
|
* Set when a passage named `to` exists, but the inspected output leaves it out of the story
|
|
379
116
|
* (only with a `target`): why it is left out. Absent when no passage has the name.
|
|
380
117
|
*/
|
|
381
|
-
omission?: PassageOmission;
|
|
118
|
+
readonly omission?: PassageOmission;
|
|
382
119
|
}
|
|
383
120
|
/**
|
|
384
121
|
* Inspect a story and return its full structural map.
|
|
@@ -407,21 +144,34 @@ export declare function storyInspect(story: ReadonlyStory, options?: InspectOpti
|
|
|
407
144
|
//#endregion
|
|
408
145
|
//#region src/story.d.ts
|
|
409
146
|
/**
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
147
|
+
* Builds a story from passages, as the compiler does: duplicates replace earlier passages (with a warning),
|
|
148
|
+
* and the special passages StoryTitle, StoryData and StorySettings decide the story metadata.
|
|
149
|
+
*
|
|
150
|
+
* The story is changed only through the builder's methods, so its passage list, its name lookups and its
|
|
151
|
+
* metadata always agree. Passages are copied in and out: changing a passage object after `add()`, or one that
|
|
152
|
+
* `get()`, `passages` or `build()` returned, does not change the builder.
|
|
415
153
|
*/
|
|
416
154
|
export declare class StoryBuilder {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
constructor();
|
|
420
|
-
/** Add a passage, handling special passages (StoryData, StoryTitle, etc.). */
|
|
155
|
+
#private;
|
|
156
|
+
/** Add a passage, handling special passages (StoryData, StoryTitle, etc.) and duplicates. */
|
|
421
157
|
add(passage: Passage, diagnostics: Diagnostic[]): void;
|
|
422
|
-
/**
|
|
158
|
+
/** Whether a passage has this name. */
|
|
423
159
|
has(name: string): boolean;
|
|
424
|
-
/**
|
|
160
|
+
/** The passage with this name (a frozen copy), or undefined. */
|
|
161
|
+
get(name: string): ReadonlyPassage | undefined;
|
|
162
|
+
/**
|
|
163
|
+
* Remove the passage with this name, and with it the metadata it decided (removing StoryData clears the
|
|
164
|
+
* IFID, format and start). Returns false when no passage has the name.
|
|
165
|
+
*/
|
|
166
|
+
remove(name: string): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Rename a passage, keeping its place in the story. A passage that already has the new name is replaced,
|
|
169
|
+
* with a warning, as a duplicate would be. Returns false when no passage has the old name.
|
|
170
|
+
*/
|
|
171
|
+
rename(from: string, to: string, diagnostics: Diagnostic[]): boolean;
|
|
172
|
+
/** The passages, in order (frozen copies). */
|
|
173
|
+
get passages(): readonly ReadonlyPassage[];
|
|
174
|
+
/** The story as it is now, as a frozen copy that later changes to the builder do not reach. */
|
|
425
175
|
build(): ReadonlyStory;
|
|
426
176
|
}
|
|
427
177
|
//#endregion
|
|
@@ -441,36 +191,40 @@ export declare function decompileHTML(html: string, options?: DecompileOptions):
|
|
|
441
191
|
//#region src/lint.d.ts
|
|
442
192
|
interface LintResult {
|
|
443
193
|
/** Compilation diagnostics (errors and warnings). */
|
|
444
|
-
diagnostics: Diagnostic[];
|
|
194
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
445
195
|
/** Compilation statistics. */
|
|
446
|
-
stats: CompileStats;
|
|
196
|
+
readonly stats: CompileStats;
|
|
447
197
|
/** Story format name from StoryData (e.g. "SugarCube"). */
|
|
448
|
-
formatName: string;
|
|
198
|
+
readonly formatName: string;
|
|
449
199
|
/** Story format version from StoryData (e.g. "2.37.3"). */
|
|
450
|
-
formatVersion: string;
|
|
200
|
+
readonly formatVersion: string;
|
|
451
201
|
/** The configured start passage name. */
|
|
452
|
-
start: string;
|
|
202
|
+
readonly start: string;
|
|
453
203
|
/** Total passage count. */
|
|
454
|
-
passages: number;
|
|
204
|
+
readonly passages: number;
|
|
455
205
|
/** Story passage count (excludes StoryData, StoryTitle, scripts, etc.). */
|
|
456
|
-
storyPassages: number;
|
|
206
|
+
readonly storyPassages: number;
|
|
457
207
|
/** Info/special passage count. */
|
|
458
|
-
infoPassages: number;
|
|
208
|
+
readonly infoPassages: number;
|
|
459
209
|
/**
|
|
460
210
|
* Broken links: link targets that don't exist as passages, or that Twine 2 output leaves out
|
|
461
211
|
* (script, stylesheet and `Twine.private` passages, StoryData, StoryTitle, an empty
|
|
462
212
|
* StorySettings); for those, `omission` says why.
|
|
463
213
|
*/
|
|
464
|
-
brokenLinks: BrokenLink[];
|
|
214
|
+
readonly brokenLinks: readonly BrokenLink[];
|
|
465
215
|
/** Story passages with no outgoing links. */
|
|
466
|
-
deadEnds: string[];
|
|
467
|
-
/**
|
|
468
|
-
|
|
216
|
+
readonly deadEnds: readonly string[];
|
|
217
|
+
/**
|
|
218
|
+
* Story passages the player cannot reach: no chain of links leads to them from the start passage or from
|
|
219
|
+
* an info passage the story format runs or shows without a link (see `StoryMap.orphans`).
|
|
220
|
+
*/
|
|
221
|
+
readonly orphans: readonly string[];
|
|
469
222
|
}
|
|
470
223
|
/**
|
|
471
224
|
* Lint a story: compile without output rendering, then inspect structure.
|
|
472
225
|
* Uses JSON output mode internally to avoid format resolution, so it checks
|
|
473
|
-
* the starting passage itself, against the Twine 2 passage rules
|
|
226
|
+
* the starting passage itself, against the Twine 2 passage rules, and adds
|
|
227
|
+
* what Twine 2 HTML output reports about the story's own data. Link
|
|
474
228
|
* destinations are checked against the same rules: a link to a passage that
|
|
475
229
|
* Twine 2 output leaves out is broken, and a passage it leaves out (other than
|
|
476
230
|
* a script passage) gives no links.
|
|
@@ -483,11 +237,15 @@ export declare function formatLintReport(result: LintResult): string;
|
|
|
483
237
|
//#endregion
|
|
484
238
|
//#region src/passage.d.ts
|
|
485
239
|
/**
|
|
486
|
-
* Apply tag aliases: for each passage carrying an alias tag, add the canonical
|
|
487
|
-
* tag
|
|
488
|
-
*
|
|
240
|
+
* Apply tag aliases: for each passage carrying an alias tag, add the canonical tag if not already present. A
|
|
241
|
+
* canonical tag that is itself an alias is followed (`{ a: 'b', b: 'c' }` adds `b` and `c` to a passage tagged
|
|
242
|
+
* `a`), until no mapping adds anything, so cycles and self-mappings end too. Authored tags are kept as written (a
|
|
243
|
+
* tag written twice stays twice, as in Tweego), whether or not an alias applies; added tags follow in the order they
|
|
244
|
+
* were reached, and none repeats a tag already there. Returns new passage objects where tags changed; unchanged
|
|
245
|
+
* passages are returned as-is. Idempotent: the result carries every tag the mappings reach, so applying the same
|
|
246
|
+
* aliases again adds nothing.
|
|
489
247
|
*/
|
|
490
|
-
export declare function applyTagAliases(passages: readonly Passage[], aliases: Record<string, string
|
|
248
|
+
export declare function applyTagAliases(passages: readonly Passage[], aliases: Readonly<Record<string, string>>): Passage[];
|
|
491
249
|
//#endregion
|
|
492
250
|
//#region src/lexer.d.ts
|
|
493
251
|
/**
|
|
@@ -511,11 +269,14 @@ export declare class TweeLexer {
|
|
|
511
269
|
//#region src/parser.d.ts
|
|
512
270
|
interface ParseOptions {
|
|
513
271
|
/** Filename for diagnostics. */
|
|
514
|
-
filename?: string;
|
|
515
|
-
/**
|
|
516
|
-
|
|
272
|
+
filename?: string | undefined;
|
|
273
|
+
/**
|
|
274
|
+
* Trim white space at both ends of passage content. Default: true. When false, the content is kept as
|
|
275
|
+
* written except for its trailing blank lines, which the Twee 3 specification requires a reader to drop.
|
|
276
|
+
*/
|
|
277
|
+
trim?: boolean | undefined;
|
|
517
278
|
/** Enable Twee2 compatibility. Default: false. */
|
|
518
|
-
twee2Compat?: boolean;
|
|
279
|
+
twee2Compat?: boolean | undefined;
|
|
519
280
|
}
|
|
520
281
|
interface ParseResult {
|
|
521
282
|
passages: Passage[];
|
|
@@ -524,25 +285,20 @@ interface ParseResult {
|
|
|
524
285
|
/**
|
|
525
286
|
* Parse Twee source text into passages.
|
|
526
287
|
*
|
|
527
|
-
* The source is normalized first
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
288
|
+
* The source is normalized first (see `normalizeTweeSource`): a leading UTF-8 BOM is removed, CRLF and bare CR
|
|
289
|
+
* line endings become LF, and a BOM at the start of a later line, directly before `::` (left there by
|
|
290
|
+
* concatenating files), is removed too, so that line stays a passage header.
|
|
291
|
+
*
|
|
292
|
+
* Names and tags are read as Tweego reads them: unescaped, then the name trimmed and the tags split at white
|
|
293
|
+
* space, where white space is Go's `unicode.IsSpace` (see `isTweeSpace`).
|
|
531
294
|
*/
|
|
532
295
|
export declare function parseTwee(source: string, options?: ParseOptions): ParseResult;
|
|
533
296
|
//#endregion
|
|
534
297
|
//#region src/formats.d.ts
|
|
535
|
-
/**
|
|
536
|
-
* Parse the Twine 2 format.js JSON chunk; null when it cannot be used ({@link decodeFormatJSON}
|
|
537
|
-
* gives the reason).
|
|
538
|
-
*
|
|
539
|
-
* @param _formatId No longer used; kept so existing callers keep compiling.
|
|
540
|
-
*/
|
|
541
|
-
export declare function parseFormatJSON(source: string, _formatId?: string): Twine2FormatJSON | null;
|
|
542
298
|
/**
|
|
543
299
|
* Discover all story formats in the given search directories, pruned by SemVer: within each
|
|
544
|
-
* (name, major) group only the highest version survives.
|
|
545
|
-
*
|
|
300
|
+
* (name, major) group only the highest version survives. A later search directory outranks an earlier one,
|
|
301
|
+
* and a format in it replaces one of the same name and version from an earlier directory.
|
|
546
302
|
*/
|
|
547
303
|
export declare function discoverFormats(searchDirs: readonly string[]): Map<string, StoryFormatInfo>;
|
|
548
304
|
/**
|
|
@@ -553,20 +309,27 @@ export declare function discoverFormats(searchDirs: readonly string[]): Map<stri
|
|
|
553
309
|
* Tweego.
|
|
554
310
|
*/
|
|
555
311
|
export declare function getFormatSearchDirs(extraPaths?: readonly string[], useTweegoPath?: boolean): string[];
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/semver.d.ts
|
|
314
|
+
/** Parse a version string, or return null when it is not a version (see the module comment). */
|
|
315
|
+
export declare function parseVersion(text: string): SemVer | null;
|
|
316
|
+
/** Compare two versions by SemVer precedence: negative when `a` ranks lower, 0 when equal, positive when higher. */
|
|
317
|
+
export declare function compareVersions(a: SemVer, b: SemVer): number;
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/format-decode.d.ts
|
|
556
320
|
/**
|
|
557
|
-
*
|
|
558
|
-
*
|
|
321
|
+
* Read the format object of a Twine 2 `format.js` (the object literal passed to its `storyFormat()` call);
|
|
322
|
+
* null when the file holds no usable format. Compiling reports why a format cannot be used.
|
|
559
323
|
*/
|
|
560
|
-
export declare function
|
|
561
|
-
/** Compare [major, minor, patch] tuples. Use {@link compareVersions} to take prereleases into account. */
|
|
562
|
-
export declare function semverCompare(a: [number, number, number], b: [number, number, number]): number;
|
|
324
|
+
export declare function parseFormatJSON(source: string): Twine2FormatJSON | null;
|
|
563
325
|
//#endregion
|
|
564
326
|
//#region src/ifid.d.ts
|
|
565
327
|
/** Generate a new IFID (UUID v4, uppercase). */
|
|
566
328
|
export declare function generateIFID(): IFID;
|
|
567
329
|
/**
|
|
568
330
|
* Validate and brand an IFID string. Throws on invalid input.
|
|
569
|
-
* Returns the IFID in
|
|
331
|
+
* Returns the IFID in the form the story model stores: the uppercase bare UUID (a `UUID://…//` wrapper is
|
|
332
|
+
* removed).
|
|
570
333
|
*/
|
|
571
334
|
export declare function createIFID(value: string): IFID;
|
|
572
335
|
/**
|
|
@@ -579,19 +342,24 @@ export declare function validateIFID(ifid: string): string | null;
|
|
|
579
342
|
//#region src/config.d.ts
|
|
580
343
|
export declare const CONFIG_FILENAME = "twee-ts.config.json";
|
|
581
344
|
/**
|
|
582
|
-
* Load a config file from the given directory (default: cwd). Returns null
|
|
345
|
+
* Load a config file from the given directory (default: cwd). Returns null when nothing is at its path.
|
|
583
346
|
*
|
|
584
347
|
* @param diagnostics Receives warnings that do not stop the config from loading: keys the config does not
|
|
585
348
|
* define, and a file that is not valid UTF-8 (it is read as Windows-1252).
|
|
586
|
-
* @throws
|
|
349
|
+
* @throws A TweeTsError when something is at the path but cannot be read (a dangling symbolic link, a link loop,
|
|
350
|
+
* a folder that can't be searched, a file it may not read), is not valid JSON or fails {@link validateConfig}.
|
|
587
351
|
*/
|
|
588
352
|
export declare function loadConfig(dir?: string, diagnostics?: Diagnostic[]): TweeTsConfig | null;
|
|
589
353
|
/**
|
|
590
354
|
* Load a config from a specific file path.
|
|
591
355
|
*
|
|
356
|
+
* The paths in it (`sources`, `output`, `modules`, `headFile`, `formatPaths`) are relative to the folder
|
|
357
|
+
* that holds the config file, and so are the `exclude` globs: the config is returned with them rebased onto
|
|
358
|
+
* the working directory (or absolute, when that folder is outside it).
|
|
359
|
+
*
|
|
592
360
|
* @param diagnostics Receives warnings that do not stop the config from loading: keys the config does not
|
|
593
361
|
* define, and a file that is not valid UTF-8 (it is read as Windows-1252).
|
|
594
|
-
* @throws
|
|
362
|
+
* @throws A TweeTsError when the file cannot be read, is not valid JSON or fails {@link validateConfig}.
|
|
595
363
|
*/
|
|
596
364
|
export declare function loadConfigFile(filePath: string, diagnostics?: Diagnostic[]): TweeTsConfig;
|
|
597
365
|
/**
|
|
@@ -607,59 +375,67 @@ export declare function validateConfig(data: unknown): string[];
|
|
|
607
375
|
* an object, which {@link validateConfig} reports.
|
|
608
376
|
*/
|
|
609
377
|
export declare function unknownConfigKeyWarnings(data: unknown): string[];
|
|
610
|
-
/** Return a default config JSON string for --init scaffolding. */
|
|
611
|
-
export declare function scaffoldConfig(): string;
|
|
378
|
+
/** Return a default config JSON string for --init scaffolding, naming the schema of `version` (this twee-ts). */
|
|
379
|
+
export declare function scaffoldConfig(version?: string): string;
|
|
612
380
|
//#endregion
|
|
613
|
-
//#region src/
|
|
614
|
-
/** Get the cache directory for downloaded story formats. */
|
|
615
|
-
export declare function getCacheDir(): string;
|
|
616
|
-
/**
|
|
617
|
-
* Download a format, verify its checksum, check that it is the format the entry names, write it to
|
|
618
|
-
* the cache shared by name and version, and return its StoryFormatInfo. Concurrent calls for one
|
|
619
|
-
* download URL share one request for the bytes; each call then verifies them against its own
|
|
620
|
-
* entry, within its own timeout.
|
|
621
|
-
*/
|
|
622
|
-
export declare function fetchAndCacheFormat(entry: SFAIndexEntry, downloadUrl: string, options?: RemoteFetchOptions): Promise<StoryFormatInfo>;
|
|
623
|
-
/**
|
|
624
|
-
* Download a direct format.js URL, parse its JSON, cache it under that URL (apart from the
|
|
625
|
-
* downloads shared by name and version), and return its StoryFormatInfo. Concurrent calls for
|
|
626
|
-
* one URL share one request.
|
|
627
|
-
*/
|
|
628
|
-
export declare function fetchDirectFormat(url: string, options?: RemoteFetchOptions): Promise<StoryFormatInfo>;
|
|
381
|
+
//#region src/format-resolution.d.ts
|
|
629
382
|
/**
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
* 3. Try custom index URLs, then the default SFA indices
|
|
634
|
-
* 4. Fall back to a compatible download from the shared cache (e.g. when offline)
|
|
383
|
+
* Resolve a story format by name and version from format URLs and format indices only (no local
|
|
384
|
+
* folders), by the same policy as a compile: `options.urls` first, then `options.indices`, then the
|
|
385
|
+
* Story Formats Archive. Returns undefined when no source has the format.
|
|
635
386
|
*
|
|
636
387
|
* `options.signal` aborts the lookup, which then rejects with the signal's reason;
|
|
637
|
-
* `options.timeout` limits each request (default
|
|
388
|
+
* `options.timeout` limits each request (default 30000 ms), and `options.resolutionTimeout` the
|
|
389
|
+
* whole lookup (default 120000 ms); `options.useDefaultIndices: false` leaves the Story Formats
|
|
390
|
+
* Archive out.
|
|
391
|
+
*
|
|
392
|
+
* @throws A TweeTsError: `INVALID_OPTIONS` for a URL or time limit that cannot be used, before any
|
|
393
|
+
* request; `FORMAT_UNAVAILABLE`, listing every failure (also in its `diagnostics`), when no source
|
|
394
|
+
* has the format and some source failed.
|
|
638
395
|
*/
|
|
639
|
-
export declare function resolveRemoteFormat(name: string, version: string,
|
|
640
|
-
|
|
641
|
-
|
|
396
|
+
export declare function resolveRemoteFormat(name: string, version: string, options?: RemoteResolveOptions): Promise<StoryFormatInfo | undefined>;
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/format-cache.d.ts
|
|
399
|
+
/** Get the cache directory for downloaded story formats. */
|
|
400
|
+
export declare function getCacheDir(): string;
|
|
642
401
|
/** Info about a cached format entry with size and modification date. */
|
|
643
402
|
interface CachedFormatEntry {
|
|
403
|
+
/** The format's name and version. */
|
|
644
404
|
readonly name: string;
|
|
645
405
|
readonly version: string;
|
|
406
|
+
/** Where it was downloaded from: a format index or a format URL. */
|
|
407
|
+
readonly source: 'index' | 'url';
|
|
408
|
+
/** The format index URL or the format URL. */
|
|
409
|
+
readonly origin: string;
|
|
646
410
|
readonly sizeBytes: number;
|
|
411
|
+
/** When it was downloaded. */
|
|
647
412
|
readonly modifiedAt: Date;
|
|
648
413
|
}
|
|
649
|
-
/** List all cached formats
|
|
414
|
+
/** List all cached formats (downloads from format indices and from format URLs), in a stable order. */
|
|
650
415
|
export declare function listCachedFormats(): readonly CachedFormatEntry[];
|
|
651
416
|
/**
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
417
|
+
* Every cached format whose files are intact, keyed by cache entry (so two downloads of the same
|
|
418
|
+
* name and version from different origins are both listed).
|
|
419
|
+
*/
|
|
420
|
+
export declare function discoverCachedFormats(): Map<string, StoryFormatInfo>;
|
|
421
|
+
/**
|
|
422
|
+
* Clear all cached formats (no name given), or only those with a given name (matched as format names are, without
|
|
423
|
+
* regard to letter case; an empty name matches none). Returns the number of cached formats removed. Clearing all also removes
|
|
424
|
+
* the directories older twee-ts versions wrote.
|
|
657
425
|
*/
|
|
658
426
|
export declare function clearCachedFormats(name?: string): number;
|
|
659
427
|
/** Get total cache size in bytes and format count. */
|
|
660
428
|
export declare function getCacheSize(): {
|
|
661
|
-
totalBytes: number;
|
|
662
|
-
count: number;
|
|
429
|
+
readonly totalBytes: number;
|
|
430
|
+
readonly count: number;
|
|
663
431
|
};
|
|
664
432
|
//#endregion
|
|
665
|
-
|
|
433
|
+
//#region src/remote-formats.d.ts
|
|
434
|
+
/**
|
|
435
|
+
* Download a direct format.js URL (or confirm that its cached copy is current), cache it under
|
|
436
|
+
* that URL, and return its StoryFormatInfo. Concurrent calls for one URL share one request.
|
|
437
|
+
* Throws when the URL is not usable, the download fails, or the cache cannot be written.
|
|
438
|
+
*/
|
|
439
|
+
export declare function fetchDirectFormat(url: string, options?: RemoteFetchOptions): Promise<StoryFormatInfo>;
|
|
440
|
+
//#endregion
|
|
441
|
+
export { type BrokenLink, type CachedFormatEntry, type CompileOptions, type CompileResult, type CompileStats, type CompileToFileOptions, type DecompileOptions, type DecompileResult, type Diagnostic, type ExcludeGlob, type FileCacheEntry, type IFID, type InlineSource, type InspectOptions, ItemType, type LexerItem, type LintResult, type OmittingTag, type OutputMode, type ParseOptions, type ParseResult, type Passage, type PassageMetadata, type PassageOmission, type PassageOutputTarget, type ReadonlyPassage, type ReadonlyStory, type RemoteFetchOptions, type RemoteResolveOptions, type SFAIndex, type SFAIndexEntry, type SemVer, type SourceInput, type SourceLocation, type Story, type StoryFormatInfo, type StoryMap, type TweeTsConfig, type TweeTsErrorCode, type Twine1Metadata, type Twine2FormatJSON, type Twine2Metadata, type WatchOptions, type WordCountMethod };
|