@kubohiroya/turbowarp-asset-cache 0.1.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 +373 -0
- package/README.md +118 -0
- package/dist/asset-cache.js +3388 -0
- package/dist/composition.js +8333 -0
- package/dist/extension-manifest.json +420 -0
- package/dist/types/animation.d.ts +41 -0
- package/dist/types/asset-cache-error.d.ts +28 -0
- package/dist/types/audio-voice.d.ts +9 -0
- package/dist/types/binary-bundle-store.d.ts +93 -0
- package/dist/types/binary-object-store.d.ts +56 -0
- package/dist/types/composition.d.ts +111 -0
- package/dist/types/dom-image-resource.d.ts +18 -0
- package/dist/types/extension.d.ts +257 -0
- package/dist/types/feature-flags.d.ts +10 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/named-body-provider.d.ts +12 -0
- package/dist/types/opfs-binary-bundle-store.d.ts +19 -0
- package/dist/types/server-manifest.d.ts +16 -0
- package/dist/types/session-binary-backing.d.ts +59 -0
- package/dist/types/text-style.d.ts +24 -0
- package/dist/types/verified-cache-catalog.d.ts +57 -0
- package/dist/types/verified-remote-cache.d.ts +106 -0
- package/package.json +85 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type VerifiedRemoteStoryCacheDeleteResult, type VerifiedRemoteStoryCacheInfo, type VerifiedRemoteStoryCachePruneResult } from './verified-cache-catalog.js';
|
|
2
|
+
export type { VerifiedRemoteStoryCacheDeleteResult, VerifiedRemoteStoryCacheInfo, VerifiedRemoteStoryCachePruneResult } from './verified-cache-catalog.js';
|
|
3
|
+
export interface VerifiedRemoteBinaryInput {
|
|
4
|
+
readonly url: unknown;
|
|
5
|
+
readonly integrity: unknown;
|
|
6
|
+
readonly size: unknown;
|
|
7
|
+
readonly contentType: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface NormalizedVerifiedRemoteBinaryInput {
|
|
10
|
+
readonly url: string;
|
|
11
|
+
readonly integrity: string;
|
|
12
|
+
readonly size: number;
|
|
13
|
+
readonly contentType: string;
|
|
14
|
+
}
|
|
15
|
+
export interface VerifiedRemoteBinaryLoadResult {
|
|
16
|
+
readonly bytes: ArrayBuffer | Uint8Array;
|
|
17
|
+
readonly contentType: unknown;
|
|
18
|
+
readonly transferOwnership?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface VerifiedRemoteBinaryResolveOptions {
|
|
21
|
+
readonly load: (input: NormalizedVerifiedRemoteBinaryInput, context: Readonly<{
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
}>) => Promise<VerifiedRemoteBinaryLoadResult>;
|
|
24
|
+
readonly signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
export interface VerifiedRemoteCacheWarning {
|
|
27
|
+
readonly operation: 'read' | 'write' | 'cleanup';
|
|
28
|
+
readonly code: string;
|
|
29
|
+
}
|
|
30
|
+
export interface VerifiedRemoteCacheIdentityInput {
|
|
31
|
+
readonly id: unknown;
|
|
32
|
+
readonly label: unknown;
|
|
33
|
+
readonly databaseName?: unknown;
|
|
34
|
+
}
|
|
35
|
+
export interface VerifiedRemoteCacheIdentity {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly label: string;
|
|
38
|
+
readonly databaseName: string;
|
|
39
|
+
}
|
|
40
|
+
export interface VerifiedRemoteBinaryResult {
|
|
41
|
+
readonly bytes: Uint8Array;
|
|
42
|
+
readonly contentType: string;
|
|
43
|
+
readonly integrity: string;
|
|
44
|
+
readonly source: 'indexeddb' | 'network';
|
|
45
|
+
readonly cacheRead: 'hit' | 'miss' | 'invalid' | 'failed';
|
|
46
|
+
readonly cacheWrite: 'not-needed' | 'stored' | 'skipped' | 'failed';
|
|
47
|
+
readonly cacheWarnings: ReadonlyArray<VerifiedRemoteCacheWarning>;
|
|
48
|
+
}
|
|
49
|
+
export interface VerifiedRemoteCacheStats {
|
|
50
|
+
readonly databaseName: string;
|
|
51
|
+
readonly cacheIdentity: VerifiedRemoteCacheIdentity | null;
|
|
52
|
+
readonly entries: number;
|
|
53
|
+
readonly bytes: number;
|
|
54
|
+
readonly oldestAccessedAt: number | null;
|
|
55
|
+
readonly newestAccessedAt: number | null;
|
|
56
|
+
readonly highWaterBytes: number;
|
|
57
|
+
readonly lowWaterBytes: number;
|
|
58
|
+
readonly lastCleanupAt: number | null;
|
|
59
|
+
readonly lastCleanupRemovedEntries: number;
|
|
60
|
+
readonly lastCleanupRemovedBytes: number;
|
|
61
|
+
readonly warnings: ReadonlyArray<VerifiedRemoteCacheWarning>;
|
|
62
|
+
}
|
|
63
|
+
export interface VerifiedRemoteCachePruneResult {
|
|
64
|
+
readonly databaseName: string;
|
|
65
|
+
readonly cacheIdentity: VerifiedRemoteCacheIdentity | null;
|
|
66
|
+
readonly removedEntries: number;
|
|
67
|
+
readonly removedBytes: number;
|
|
68
|
+
readonly remainingEntries: number;
|
|
69
|
+
readonly remainingBytes: number;
|
|
70
|
+
readonly highWaterBytes: number;
|
|
71
|
+
readonly lowWaterBytes: number;
|
|
72
|
+
readonly warnings: ReadonlyArray<VerifiedRemoteCacheWarning>;
|
|
73
|
+
}
|
|
74
|
+
export interface VerifiedRemoteBinaryCacheOptions {
|
|
75
|
+
readonly indexedDB?: IDBFactory;
|
|
76
|
+
readonly subtleCrypto?: SubtleCrypto;
|
|
77
|
+
readonly estimateStorage?: () => Promise<Readonly<{
|
|
78
|
+
quota?: number;
|
|
79
|
+
usage?: number;
|
|
80
|
+
}>>;
|
|
81
|
+
readonly now?: () => number;
|
|
82
|
+
readonly maxCacheBytes?: number;
|
|
83
|
+
readonly quotaFraction?: number;
|
|
84
|
+
readonly lowWaterRatio?: number;
|
|
85
|
+
readonly ttlMs?: number;
|
|
86
|
+
readonly touchIntervalMs?: number;
|
|
87
|
+
readonly cleanupBatchSize?: number;
|
|
88
|
+
readonly leaseTtlMs?: number;
|
|
89
|
+
readonly cacheIdentity?: VerifiedRemoteCacheIdentityInput;
|
|
90
|
+
}
|
|
91
|
+
export interface VerifiedRemoteBinaryCache {
|
|
92
|
+
resolve(input: VerifiedRemoteBinaryInput, options: VerifiedRemoteBinaryResolveOptions): Promise<VerifiedRemoteBinaryResult>;
|
|
93
|
+
getStats(): Promise<VerifiedRemoteCacheStats>;
|
|
94
|
+
prune(): Promise<VerifiedRemoteCachePruneResult>;
|
|
95
|
+
clear(): Promise<VerifiedRemoteCachePruneResult>;
|
|
96
|
+
listStoryCaches(): Promise<ReadonlyArray<VerifiedRemoteStoryCacheInfo>>;
|
|
97
|
+
pruneStoryCaches(): Promise<VerifiedRemoteStoryCachePruneResult>;
|
|
98
|
+
deleteStoryCache(databaseName: unknown): Promise<VerifiedRemoteStoryCacheDeleteResult>;
|
|
99
|
+
renewStoryCacheLease(): Promise<void>;
|
|
100
|
+
releaseStoryCacheLease(): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
export declare function createVerifiedRemoteCacheDatabaseName(input: {
|
|
103
|
+
readonly id: unknown;
|
|
104
|
+
readonly label: unknown;
|
|
105
|
+
}): string;
|
|
106
|
+
export declare function createVerifiedRemoteBinaryCache(options?: VerifiedRemoteBinaryCacheOptions): VerifiedRemoteBinaryCache;
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kubohiroya/turbowarp-asset-cache",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A browser-local image, audio, and runtime-text asset cache for TurboWarp projects.",
|
|
5
|
+
"author": "Hiroya Kubo <hiroya@cuc.ac.jp>",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MPL-2.0",
|
|
8
|
+
"homepage": "https://kubohiroya.github.io/turbowarp-asset-cache/",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/kubohiroya/turbowarp-asset-cache.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/kubohiroya/turbowarp-asset-cache/issues"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
"./composition": {
|
|
18
|
+
"types": "./dist/types/composition.d.ts",
|
|
19
|
+
"import": "./dist/composition.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"unpkg": "./dist/asset-cache.js",
|
|
29
|
+
"jsdelivr": "./dist/asset-cache.js",
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"packageManager": "pnpm@11.11.0",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22.18.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"dev": "vite build --watch",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"lint": "eslint src tests scripts vite.config.ts vite.composition.config.ts vite-indent-plugin.ts",
|
|
42
|
+
"format": "eslint src tests scripts vite.config.ts vite.composition.config.ts vite-indent-plugin.ts --fix",
|
|
43
|
+
"build": "pnpm build:extension && pnpm build:composition && pnpm build:types",
|
|
44
|
+
"build:extension": "vite build",
|
|
45
|
+
"build:composition": "vite build --config vite.composition.config.ts",
|
|
46
|
+
"build:types": "tsc --project tsconfig.build.json",
|
|
47
|
+
"types:composition:check": "tsc --project tsconfig.composition-consumer.json",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"test:browser:opfs": "node scripts/check-opfs-browser.ts",
|
|
50
|
+
"docs": "node scripts/generate-readme.ts",
|
|
51
|
+
"docs:check": "pnpm run docs && git diff --exit-code -- docs/block-reference.md",
|
|
52
|
+
"docs:site:check": "node scripts/check-site.ts",
|
|
53
|
+
"repo:check": "node scripts/check-repo.ts",
|
|
54
|
+
"check:dist": "pnpm run build && git diff --exit-code -- dist",
|
|
55
|
+
"archive:check": "node scripts/check-github-archive.ts",
|
|
56
|
+
"pack:check": "npm pack --dry-run --ignore-scripts",
|
|
57
|
+
"release:check": "npm publish --dry-run --access public",
|
|
58
|
+
"check": "pnpm run typecheck && pnpm run lint && pnpm run test && pnpm run build && pnpm run test:browser:opfs && pnpm run types:composition:check && pnpm run docs:check && pnpm run docs:site:check && pnpm run check:dist && pnpm run archive:check && pnpm run repo:check && pnpm run pack:check",
|
|
59
|
+
"prepack": "pnpm run build"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@eslint/js": "^9.39.5",
|
|
63
|
+
"@kubohiroya/turbowarp-named-data": "0.1.0",
|
|
64
|
+
"@kubohiroya/turbowarp-extension-manifest": "0.2.0",
|
|
65
|
+
"@kubohiroya/vite-plugin-turbowarp-extension": "0.4.0",
|
|
66
|
+
"@types/node": "^22.20.1",
|
|
67
|
+
"@xmldom/xmldom": "0.9.11",
|
|
68
|
+
"eslint": "^9.39.5",
|
|
69
|
+
"fake-indexeddb": "6.2.5",
|
|
70
|
+
"typescript": "^5.9.3",
|
|
71
|
+
"typescript-eslint": "^8.70.0",
|
|
72
|
+
"vite": "^8.2.2",
|
|
73
|
+
"vitest": "^4.1.10"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"@kubohiroya/turbowarp-named-data": "^0.1.0"
|
|
77
|
+
},
|
|
78
|
+
"keywords": [
|
|
79
|
+
"turbowarp",
|
|
80
|
+
"scratch",
|
|
81
|
+
"extension",
|
|
82
|
+
"assets",
|
|
83
|
+
"indexeddb"
|
|
84
|
+
]
|
|
85
|
+
}
|