@rohal12/twee-ts 1.7.0 → 1.8.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-N2OR5KHL.js} +2 -2
- package/dist/{chunk-HXL3JC4L.js.map → chunk-N2OR5KHL.js.map} +1 -1
- package/dist/index.cjs +75 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +73 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/rollup.js +1 -1
- package/dist/plugins/vite.js +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -411,5 +411,21 @@ declare function fetchDirectFormat(url: string): Promise<StoryFormatInfo>;
|
|
|
411
411
|
declare function resolveRemoteFormat(name: string, version: string, indices?: string[], urls?: string[]): Promise<StoryFormatInfo | undefined>;
|
|
412
412
|
/** Discover all cached remote formats. Returns a Map like discoverFormats(). */
|
|
413
413
|
declare function discoverCachedFormats(): Map<string, StoryFormatInfo>;
|
|
414
|
+
/** Info about a cached format entry with size and modification date. */
|
|
415
|
+
interface CachedFormatEntry {
|
|
416
|
+
readonly name: string;
|
|
417
|
+
readonly version: string;
|
|
418
|
+
readonly sizeBytes: number;
|
|
419
|
+
readonly modifiedAt: Date;
|
|
420
|
+
}
|
|
421
|
+
/** List all cached formats with size and modification date. */
|
|
422
|
+
declare function listCachedFormats(): readonly CachedFormatEntry[];
|
|
423
|
+
/** Clear all cached formats, or only those matching a given name. Returns the number of entries removed. */
|
|
424
|
+
declare function clearCachedFormats(name?: string): number;
|
|
425
|
+
/** Get total cache size in bytes and format count. */
|
|
426
|
+
declare function getCacheSize(): {
|
|
427
|
+
totalBytes: number;
|
|
428
|
+
count: number;
|
|
429
|
+
};
|
|
414
430
|
|
|
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 };
|
|
431
|
+
export { type BrokenLink, CONFIG_FILENAME, type CachedFormatEntry, 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, clearCachedFormats, compile, 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
|
@@ -411,5 +411,21 @@ declare function fetchDirectFormat(url: string): Promise<StoryFormatInfo>;
|
|
|
411
411
|
declare function resolveRemoteFormat(name: string, version: string, indices?: string[], urls?: string[]): Promise<StoryFormatInfo | undefined>;
|
|
412
412
|
/** Discover all cached remote formats. Returns a Map like discoverFormats(). */
|
|
413
413
|
declare function discoverCachedFormats(): Map<string, StoryFormatInfo>;
|
|
414
|
+
/** Info about a cached format entry with size and modification date. */
|
|
415
|
+
interface CachedFormatEntry {
|
|
416
|
+
readonly name: string;
|
|
417
|
+
readonly version: string;
|
|
418
|
+
readonly sizeBytes: number;
|
|
419
|
+
readonly modifiedAt: Date;
|
|
420
|
+
}
|
|
421
|
+
/** List all cached formats with size and modification date. */
|
|
422
|
+
declare function listCachedFormats(): readonly CachedFormatEntry[];
|
|
423
|
+
/** Clear all cached formats, or only those matching a given name. Returns the number of entries removed. */
|
|
424
|
+
declare function clearCachedFormats(name?: string): number;
|
|
425
|
+
/** Get total cache size in bytes and format count. */
|
|
426
|
+
declare function getCacheSize(): {
|
|
427
|
+
totalBytes: number;
|
|
428
|
+
count: number;
|
|
429
|
+
};
|
|
414
430
|
|
|
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 };
|
|
431
|
+
export { type BrokenLink, CONFIG_FILENAME, type CachedFormatEntry, 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, clearCachedFormats, compile, 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";
|
|
@@ -2554,6 +2623,7 @@ export {
|
|
|
2554
2623
|
TweeLexer,
|
|
2555
2624
|
TweeTsError,
|
|
2556
2625
|
applyTagAliases,
|
|
2626
|
+
clearCachedFormats,
|
|
2557
2627
|
compile,
|
|
2558
2628
|
compileToFile,
|
|
2559
2629
|
discoverCachedFormats,
|
|
@@ -2563,8 +2633,10 @@ export {
|
|
|
2563
2633
|
formatLintReport,
|
|
2564
2634
|
generateIFID,
|
|
2565
2635
|
getCacheDir,
|
|
2636
|
+
getCacheSize,
|
|
2566
2637
|
getFormatSearchDirs,
|
|
2567
2638
|
lint,
|
|
2639
|
+
listCachedFormats,
|
|
2568
2640
|
loadConfig,
|
|
2569
2641
|
loadConfigFile,
|
|
2570
2642
|
parseFormatJSON,
|