@rohal12/twee-ts 1.7.0 → 1.9.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/dist/bin/twee-ts.js +138 -2
- package/dist/bin/twee-ts.js.map +1 -1
- package/dist/{chunk-HXL3JC4L.js → chunk-FSZ5FD3P.js} +7 -3
- package/dist/chunk-FSZ5FD3P.js.map +1 -0
- package/dist/index.cjs +80 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +77 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/rollup.js +1 -1
- package/dist/plugins/vite.d.ts +10 -3
- package/dist/plugins/vite.js +43 -19
- package/dist/plugins/vite.js.map +1 -1
- package/package.json +3 -1
- package/dist/chunk-HXL3JC4L.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -161,6 +161,11 @@ interface SFAIndex {
|
|
|
161
161
|
twine1: SFAIndexEntry[];
|
|
162
162
|
twine2: SFAIndexEntry[];
|
|
163
163
|
}
|
|
164
|
+
interface FileCacheEntry {
|
|
165
|
+
readonly mtimeMs: number;
|
|
166
|
+
readonly passages: readonly Passage[];
|
|
167
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
168
|
+
}
|
|
164
169
|
interface TweeTsConfig {
|
|
165
170
|
sources?: string[];
|
|
166
171
|
output?: string;
|
|
@@ -193,6 +198,11 @@ declare function compile(options: CompileOptions): Promise<CompileResult>;
|
|
|
193
198
|
* Compile and write to a file.
|
|
194
199
|
*/
|
|
195
200
|
declare function compileToFile(options: CompileToFileOptions): Promise<CompileResult>;
|
|
201
|
+
/**
|
|
202
|
+
* Compile with incremental caching support.
|
|
203
|
+
* Plugins and advanced users can manage their own cache and changed-file tracking.
|
|
204
|
+
*/
|
|
205
|
+
declare function compileIncremental(options: CompileOptions, cache: Map<string, FileCacheEntry>, changedFiles?: ReadonlySet<string>): Promise<CompileResult>;
|
|
196
206
|
/**
|
|
197
207
|
* Watch for file changes and recompile.
|
|
198
208
|
*/
|
|
@@ -411,5 +421,21 @@ declare function fetchDirectFormat(url: string): Promise<StoryFormatInfo>;
|
|
|
411
421
|
declare function resolveRemoteFormat(name: string, version: string, indices?: string[], urls?: string[]): Promise<StoryFormatInfo | undefined>;
|
|
412
422
|
/** Discover all cached remote formats. Returns a Map like discoverFormats(). */
|
|
413
423
|
declare function discoverCachedFormats(): Map<string, StoryFormatInfo>;
|
|
424
|
+
/** Info about a cached format entry with size and modification date. */
|
|
425
|
+
interface CachedFormatEntry {
|
|
426
|
+
readonly name: string;
|
|
427
|
+
readonly version: string;
|
|
428
|
+
readonly sizeBytes: number;
|
|
429
|
+
readonly modifiedAt: Date;
|
|
430
|
+
}
|
|
431
|
+
/** List all cached formats with size and modification date. */
|
|
432
|
+
declare function listCachedFormats(): readonly CachedFormatEntry[];
|
|
433
|
+
/** Clear all cached formats, or only those matching a given name. Returns the number of entries removed. */
|
|
434
|
+
declare function clearCachedFormats(name?: string): number;
|
|
435
|
+
/** Get total cache size in bytes and format count. */
|
|
436
|
+
declare function getCacheSize(): {
|
|
437
|
+
totalBytes: number;
|
|
438
|
+
count: number;
|
|
439
|
+
};
|
|
414
440
|
|
|
415
|
-
export { type BrokenLink, CONFIG_FILENAME, type CompileOptions, type CompileResult, type CompileStats, type CompileToFileOptions, type Diagnostic, type InlineSource, ItemType, type LexerItem, type LintResult, type OutputMode, type Passage, type PassageMetadata, type SFAIndex, type SFAIndexEntry, type SourceInput, type SourceLocation, type Story, type StoryFormatInfo, type StoryMap, TweeLexer, type TweeTsConfig, TweeTsError, type WatchOptions, applyTagAliases, compile, compileToFile, discoverCachedFormats, discoverFormats, fetchAndCacheFormat, fetchDirectFormat, formatLintReport, generateIFID, getCacheDir, getFormatSearchDirs, lint, loadConfig, loadConfigFile, parseFormatJSON, parseSemver, parseTwee, resolveRemoteFormat, scaffoldConfig, semverCompare, storyInspect, tweeLexer, validateConfig, validateIFID, watch };
|
|
441
|
+
export { type BrokenLink, CONFIG_FILENAME, type CachedFormatEntry, type CompileOptions, type CompileResult, type CompileStats, type CompileToFileOptions, type Diagnostic, type FileCacheEntry, type InlineSource, ItemType, type LexerItem, type LintResult, type OutputMode, type Passage, type PassageMetadata, type SFAIndex, type SFAIndexEntry, type SourceInput, type SourceLocation, type Story, type StoryFormatInfo, type StoryMap, TweeLexer, type TweeTsConfig, TweeTsError, type WatchOptions, applyTagAliases, clearCachedFormats, compile, compileIncremental, compileToFile, discoverCachedFormats, discoverFormats, fetchAndCacheFormat, fetchDirectFormat, formatLintReport, generateIFID, getCacheDir, getCacheSize, getFormatSearchDirs, lint, listCachedFormats, loadConfig, loadConfigFile, parseFormatJSON, parseSemver, parseTwee, resolveRemoteFormat, scaffoldConfig, semverCompare, storyInspect, tweeLexer, validateConfig, validateIFID, watch };
|
package/dist/index.d.ts
CHANGED
|
@@ -161,6 +161,11 @@ interface SFAIndex {
|
|
|
161
161
|
twine1: SFAIndexEntry[];
|
|
162
162
|
twine2: SFAIndexEntry[];
|
|
163
163
|
}
|
|
164
|
+
interface FileCacheEntry {
|
|
165
|
+
readonly mtimeMs: number;
|
|
166
|
+
readonly passages: readonly Passage[];
|
|
167
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
168
|
+
}
|
|
164
169
|
interface TweeTsConfig {
|
|
165
170
|
sources?: string[];
|
|
166
171
|
output?: string;
|
|
@@ -193,6 +198,11 @@ declare function compile(options: CompileOptions): Promise<CompileResult>;
|
|
|
193
198
|
* Compile and write to a file.
|
|
194
199
|
*/
|
|
195
200
|
declare function compileToFile(options: CompileToFileOptions): Promise<CompileResult>;
|
|
201
|
+
/**
|
|
202
|
+
* Compile with incremental caching support.
|
|
203
|
+
* Plugins and advanced users can manage their own cache and changed-file tracking.
|
|
204
|
+
*/
|
|
205
|
+
declare function compileIncremental(options: CompileOptions, cache: Map<string, FileCacheEntry>, changedFiles?: ReadonlySet<string>): Promise<CompileResult>;
|
|
196
206
|
/**
|
|
197
207
|
* Watch for file changes and recompile.
|
|
198
208
|
*/
|
|
@@ -411,5 +421,21 @@ declare function fetchDirectFormat(url: string): Promise<StoryFormatInfo>;
|
|
|
411
421
|
declare function resolveRemoteFormat(name: string, version: string, indices?: string[], urls?: string[]): Promise<StoryFormatInfo | undefined>;
|
|
412
422
|
/** Discover all cached remote formats. Returns a Map like discoverFormats(). */
|
|
413
423
|
declare function discoverCachedFormats(): Map<string, StoryFormatInfo>;
|
|
424
|
+
/** Info about a cached format entry with size and modification date. */
|
|
425
|
+
interface CachedFormatEntry {
|
|
426
|
+
readonly name: string;
|
|
427
|
+
readonly version: string;
|
|
428
|
+
readonly sizeBytes: number;
|
|
429
|
+
readonly modifiedAt: Date;
|
|
430
|
+
}
|
|
431
|
+
/** List all cached formats with size and modification date. */
|
|
432
|
+
declare function listCachedFormats(): readonly CachedFormatEntry[];
|
|
433
|
+
/** Clear all cached formats, or only those matching a given name. Returns the number of entries removed. */
|
|
434
|
+
declare function clearCachedFormats(name?: string): number;
|
|
435
|
+
/** Get total cache size in bytes and format count. */
|
|
436
|
+
declare function getCacheSize(): {
|
|
437
|
+
totalBytes: number;
|
|
438
|
+
count: number;
|
|
439
|
+
};
|
|
414
440
|
|
|
415
|
-
export { type BrokenLink, CONFIG_FILENAME, type CompileOptions, type CompileResult, type CompileStats, type CompileToFileOptions, type Diagnostic, type InlineSource, ItemType, type LexerItem, type LintResult, type OutputMode, type Passage, type PassageMetadata, type SFAIndex, type SFAIndexEntry, type SourceInput, type SourceLocation, type Story, type StoryFormatInfo, type StoryMap, TweeLexer, type TweeTsConfig, TweeTsError, type WatchOptions, applyTagAliases, compile, compileToFile, discoverCachedFormats, discoverFormats, fetchAndCacheFormat, fetchDirectFormat, formatLintReport, generateIFID, getCacheDir, getFormatSearchDirs, lint, loadConfig, loadConfigFile, parseFormatJSON, parseSemver, parseTwee, resolveRemoteFormat, scaffoldConfig, semverCompare, storyInspect, tweeLexer, validateConfig, validateIFID, watch };
|
|
441
|
+
export { type BrokenLink, CONFIG_FILENAME, type CachedFormatEntry, type CompileOptions, type CompileResult, type CompileStats, type CompileToFileOptions, type Diagnostic, type FileCacheEntry, type InlineSource, ItemType, type LexerItem, type LintResult, type OutputMode, type Passage, type PassageMetadata, type SFAIndex, type SFAIndexEntry, type SourceInput, type SourceLocation, type Story, type StoryFormatInfo, type StoryMap, TweeLexer, type TweeTsConfig, TweeTsError, type WatchOptions, applyTagAliases, clearCachedFormats, compile, compileIncremental, compileToFile, discoverCachedFormats, discoverFormats, fetchAndCacheFormat, fetchDirectFormat, formatLintReport, generateIFID, getCacheDir, getCacheSize, getFormatSearchDirs, lint, listCachedFormats, loadConfig, loadConfigFile, parseFormatJSON, parseSemver, parseTwee, resolveRemoteFormat, scaffoldConfig, semverCompare, storyInspect, tweeLexer, validateConfig, validateIFID, watch };
|
package/dist/index.js
CHANGED
|
@@ -1853,7 +1853,7 @@ function modifyHead(html, modulePaths, headFile, diagnostics) {
|
|
|
1853
1853
|
}
|
|
1854
1854
|
|
|
1855
1855
|
// src/remote-formats.ts
|
|
1856
|
-
import { mkdirSync, readFileSync as readFileSync3, writeFileSync, existsSync, readdirSync as readdirSync3, statSync as statSync4 } from "fs";
|
|
1856
|
+
import { mkdirSync, readFileSync as readFileSync3, writeFileSync, existsSync, readdirSync as readdirSync3, statSync as statSync4, rmSync } from "fs";
|
|
1857
1857
|
import { join as join4 } from "path";
|
|
1858
1858
|
import { homedir as homedir2 } from "os";
|
|
1859
1859
|
var DEFAULT_SFA_INDICES = [
|
|
@@ -2084,6 +2084,75 @@ function discoverCachedFormats() {
|
|
|
2084
2084
|
}
|
|
2085
2085
|
return formats;
|
|
2086
2086
|
}
|
|
2087
|
+
function listCachedFormats() {
|
|
2088
|
+
const cacheDir = getCacheDir();
|
|
2089
|
+
const entries = [];
|
|
2090
|
+
try {
|
|
2091
|
+
if (!existsSync(cacheDir)) return entries;
|
|
2092
|
+
} catch {
|
|
2093
|
+
return entries;
|
|
2094
|
+
}
|
|
2095
|
+
let names;
|
|
2096
|
+
try {
|
|
2097
|
+
names = readdirSync3(cacheDir);
|
|
2098
|
+
} catch {
|
|
2099
|
+
return entries;
|
|
2100
|
+
}
|
|
2101
|
+
for (const name of names) {
|
|
2102
|
+
const nameDir = join4(cacheDir, name);
|
|
2103
|
+
try {
|
|
2104
|
+
if (!statSync4(nameDir).isDirectory()) continue;
|
|
2105
|
+
} catch {
|
|
2106
|
+
continue;
|
|
2107
|
+
}
|
|
2108
|
+
let versions;
|
|
2109
|
+
try {
|
|
2110
|
+
versions = readdirSync3(nameDir);
|
|
2111
|
+
} catch {
|
|
2112
|
+
continue;
|
|
2113
|
+
}
|
|
2114
|
+
for (const version of versions) {
|
|
2115
|
+
const formatPath = join4(nameDir, version, "format.js");
|
|
2116
|
+
try {
|
|
2117
|
+
const stat = statSync4(formatPath);
|
|
2118
|
+
entries.push({
|
|
2119
|
+
name,
|
|
2120
|
+
version,
|
|
2121
|
+
sizeBytes: stat.size,
|
|
2122
|
+
modifiedAt: stat.mtime
|
|
2123
|
+
});
|
|
2124
|
+
} catch {
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
return entries;
|
|
2129
|
+
}
|
|
2130
|
+
function clearCachedFormats(name) {
|
|
2131
|
+
const cacheDir = getCacheDir();
|
|
2132
|
+
if (!existsSync(cacheDir)) return 0;
|
|
2133
|
+
if (!name) {
|
|
2134
|
+
const entries = listCachedFormats();
|
|
2135
|
+
const count2 = entries.length;
|
|
2136
|
+
rmSync(cacheDir, { recursive: true, force: true });
|
|
2137
|
+
return count2;
|
|
2138
|
+
}
|
|
2139
|
+
const nameDir = join4(cacheDir, name);
|
|
2140
|
+
if (!existsSync(nameDir)) return 0;
|
|
2141
|
+
let versions;
|
|
2142
|
+
try {
|
|
2143
|
+
versions = readdirSync3(nameDir);
|
|
2144
|
+
} catch {
|
|
2145
|
+
return 0;
|
|
2146
|
+
}
|
|
2147
|
+
const count = versions.length;
|
|
2148
|
+
rmSync(nameDir, { recursive: true, force: true });
|
|
2149
|
+
return count;
|
|
2150
|
+
}
|
|
2151
|
+
function getCacheSize() {
|
|
2152
|
+
const entries = listCachedFormats();
|
|
2153
|
+
const totalBytes = entries.reduce((sum, e) => sum + e.sizeBytes, 0);
|
|
2154
|
+
return { totalBytes, count: entries.length };
|
|
2155
|
+
}
|
|
2087
2156
|
|
|
2088
2157
|
// src/compiler.ts
|
|
2089
2158
|
var CREATOR_NAME3 = "Twee-ts";
|
|
@@ -2104,6 +2173,9 @@ async function compileToFile(options) {
|
|
|
2104
2173
|
writeFileSync2(options.outFile, result.output, "utf-8");
|
|
2105
2174
|
return result;
|
|
2106
2175
|
}
|
|
2176
|
+
async function compileIncremental(options, cache, changedFiles) {
|
|
2177
|
+
return buildOutput(options, cache, changedFiles);
|
|
2178
|
+
}
|
|
2107
2179
|
async function watch(options) {
|
|
2108
2180
|
const controller = new AbortController();
|
|
2109
2181
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -2554,7 +2626,9 @@ export {
|
|
|
2554
2626
|
TweeLexer,
|
|
2555
2627
|
TweeTsError,
|
|
2556
2628
|
applyTagAliases,
|
|
2629
|
+
clearCachedFormats,
|
|
2557
2630
|
compile,
|
|
2631
|
+
compileIncremental,
|
|
2558
2632
|
compileToFile,
|
|
2559
2633
|
discoverCachedFormats,
|
|
2560
2634
|
discoverFormats,
|
|
@@ -2563,8 +2637,10 @@ export {
|
|
|
2563
2637
|
formatLintReport,
|
|
2564
2638
|
generateIFID,
|
|
2565
2639
|
getCacheDir,
|
|
2640
|
+
getCacheSize,
|
|
2566
2641
|
getFormatSearchDirs,
|
|
2567
2642
|
lint,
|
|
2643
|
+
listCachedFormats,
|
|
2568
2644
|
loadConfig,
|
|
2569
2645
|
loadConfigFile,
|
|
2570
2646
|
parseFormatJSON,
|