@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,111 @@
|
|
|
1
|
+
import { type AssetManagerFeatureFlags } from './feature-flags.js';
|
|
2
|
+
import { type BinaryBundleBackendStatus, type BinaryBundlePruneResult, type BinaryBundleStoreStats, type BinaryBundleKeyInput, type BinaryBundleOperationOptions, type BinaryBundlePutInput, type BinaryBundleRegistration, type BinaryBundleResult, type BinaryBundleStoreOptions } from './binary-bundle-store.js';
|
|
3
|
+
import { type VerifiedRemoteBinaryCacheOptions, type VerifiedRemoteBinaryInput, type VerifiedRemoteBinaryResolveOptions, type VerifiedRemoteBinaryResult, type VerifiedRemoteCachePruneResult, type VerifiedRemoteCacheStats, type VerifiedRemoteStoryCacheDeleteResult, type VerifiedRemoteStoryCacheInfo, type VerifiedRemoteStoryCachePruneResult } from './verified-remote-cache.js';
|
|
4
|
+
import { type SessionBinaryBacking, type SessionBinaryBackingInput, type SessionBinaryBackingOptions } from './session-binary-backing.js';
|
|
5
|
+
import { type DOMImageResource } from './dom-image-resource.js';
|
|
6
|
+
import { type NamedAssetBodyProvider } from './named-body-provider.js';
|
|
7
|
+
export { type AssetManagerAudioVoice, type AssetManagerAudioVoiceOptions } from './audio-voice.js';
|
|
8
|
+
import { type AssetManagerAudioVoice, type AssetManagerAudioVoiceOptions } from './audio-voice.js';
|
|
9
|
+
export { type DOMImageResource } from './dom-image-resource.js';
|
|
10
|
+
export { NAMED_ASSET_BODY_NAMESPACE, NamedAssetBodyError, type NamedAssetBodyErrorCode, type NamedAssetBodyMetadata, type NamedAssetBodyOpenOptions, type NamedAssetBodyProvider, type NamedAssetBodyReference, type NamedAssetBodySnapshot } from './named-body-provider.js';
|
|
11
|
+
export { createBinaryBundleStore, type BinaryBundleBackendStatus, type BinaryBundleBackendWarning, type BinaryBundleFileInput, type BinaryBundleFileRegistration, type BinaryBundleFileResult, type BinaryBundleKeyInput, type BinaryBundleOperationOptions, type BinaryBundlePruneResult, type BinaryBundlePutInput, type BinaryBundleRegistration, type BinaryBundleResult, type BinaryBundleStore, type BinaryBundleStoreStats, type BinaryBundleStoreOptions } from './binary-bundle-store.js';
|
|
12
|
+
export { createIndexedDBBinaryObjectStore, createOpfsBinaryObjectStore, type BinaryObjectDescriptor, type BinaryObjectOperationOptions, type BinaryObjectResult, type BinaryObjectStore, type BinaryObjectStoreStats, type BinaryObjectStatsOptions, type BinaryStorageBackendPolicy, type IndexedDBBinaryObjectStoreOptions, type OpfsBinaryObjectStoreOptions, type OpfsStorageManager } from './binary-object-store.js';
|
|
13
|
+
export { createVerifiedRemoteBinaryCache, createVerifiedRemoteCacheDatabaseName, type NormalizedVerifiedRemoteBinaryInput, type VerifiedRemoteBinaryCache, type VerifiedRemoteBinaryCacheOptions, type VerifiedRemoteBinaryInput, type VerifiedRemoteBinaryLoadResult, type VerifiedRemoteBinaryResolveOptions, type VerifiedRemoteBinaryResult, type VerifiedRemoteCacheWarning, type VerifiedRemoteCacheIdentity, type VerifiedRemoteCacheIdentityInput, type VerifiedRemoteCachePruneResult, type VerifiedRemoteCacheStats, type VerifiedRemoteStoryCacheDeleteResult, type VerifiedRemoteStoryCacheInfo, type VerifiedRemoteStoryCachePruneResult } from './verified-remote-cache.js';
|
|
14
|
+
export { createSessionBinaryBacking, type SessionBinaryBacking, type SessionBinaryBackingAssetInput, type SessionBinaryBackingInput, type SessionBinaryBackingMode, type SessionBinaryBackingOptions, type SessionBinaryBackingPolicy, type SessionBinaryBackingSource, type SessionBinaryBackingSourceAsset, type SessionBinaryBackingWarning } from './session-binary-backing.js';
|
|
15
|
+
export interface EmbeddedAssetBytesInput {
|
|
16
|
+
name: unknown;
|
|
17
|
+
nameMode?: AssetNameMode;
|
|
18
|
+
bytes: ArrayBuffer | Uint8Array;
|
|
19
|
+
mimeType: unknown;
|
|
20
|
+
sourceName?: unknown;
|
|
21
|
+
bitmapResolution?: 1 | 2;
|
|
22
|
+
}
|
|
23
|
+
export interface EmbeddedAssetRegistration {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly mimeType: string;
|
|
26
|
+
}
|
|
27
|
+
export type AssetNameMode = 'trimmed' | 'literal';
|
|
28
|
+
export type ProjectAssetLocator = Readonly<{
|
|
29
|
+
kind: 'backdrop';
|
|
30
|
+
name: string;
|
|
31
|
+
}> | Readonly<{
|
|
32
|
+
kind: 'costume';
|
|
33
|
+
target: string;
|
|
34
|
+
name: string;
|
|
35
|
+
}> | Readonly<{
|
|
36
|
+
kind: 'sound';
|
|
37
|
+
name: string;
|
|
38
|
+
target?: string;
|
|
39
|
+
}>;
|
|
40
|
+
export type ProjectAssetRegistrationInput = Readonly<{
|
|
41
|
+
name: unknown;
|
|
42
|
+
nameMode?: AssetNameMode;
|
|
43
|
+
resourceId: unknown;
|
|
44
|
+
locator?: never;
|
|
45
|
+
}> | Readonly<{
|
|
46
|
+
name: unknown;
|
|
47
|
+
nameMode?: AssetNameMode;
|
|
48
|
+
locator: ProjectAssetLocator;
|
|
49
|
+
resourceId?: never;
|
|
50
|
+
}>;
|
|
51
|
+
export interface AssetManagerCompositionTarget {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly isStage: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface DOMImageResourceTarget {
|
|
56
|
+
readonly namespaceURI?: string | null;
|
|
57
|
+
readonly localName?: string;
|
|
58
|
+
getAttribute(name: string): string | null;
|
|
59
|
+
setAttribute(name: string, value: string): void;
|
|
60
|
+
removeAttribute(name: string): void;
|
|
61
|
+
}
|
|
62
|
+
export interface DOMImageResourceBindingOptions {
|
|
63
|
+
readonly attribute?: 'href' | 'src';
|
|
64
|
+
readonly owner?: AssetManagerCompositionTarget;
|
|
65
|
+
}
|
|
66
|
+
export interface AssetManagerCompositionOptions {
|
|
67
|
+
readonly verifiedRemoteCache?: VerifiedRemoteBinaryCacheOptions;
|
|
68
|
+
readonly binaryBundleStore?: BinaryBundleStoreOptions;
|
|
69
|
+
readonly sessionBinaryBacking?: SessionBinaryBackingOptions;
|
|
70
|
+
}
|
|
71
|
+
export interface AssetManagerComposition {
|
|
72
|
+
registerProjectAsset(input: ProjectAssetRegistrationInput): Promise<EmbeddedAssetRegistration>;
|
|
73
|
+
registerEmbeddedAsset(input: EmbeddedAssetBytesInput): Promise<EmbeddedAssetRegistration>;
|
|
74
|
+
releaseAsset(name: unknown): void;
|
|
75
|
+
releaseAll(): void;
|
|
76
|
+
isRegistered(name: unknown): boolean;
|
|
77
|
+
getMimeType(name: unknown): string;
|
|
78
|
+
getNamedBodyProvider(): NamedAssetBodyProvider | null;
|
|
79
|
+
getNamedDataProvider(): NamedAssetBodyProvider | null;
|
|
80
|
+
resolveDOMImageResource(name: unknown): Promise<DOMImageResource>;
|
|
81
|
+
applyDOMImageResource(name: unknown, target: DOMImageResourceTarget, options?: DOMImageResourceBindingOptions): Promise<DOMImageResource>;
|
|
82
|
+
releaseDOMImageResource(target: DOMImageResourceTarget): void;
|
|
83
|
+
releaseAllDOMImageResources(): void;
|
|
84
|
+
applyToStage(name: unknown): Promise<void>;
|
|
85
|
+
applyToTarget(name: unknown, target: AssetManagerCompositionTarget): Promise<void>;
|
|
86
|
+
playSound(name: unknown, options?: Readonly<{
|
|
87
|
+
untilDone?: boolean;
|
|
88
|
+
}>): Promise<void>;
|
|
89
|
+
createAudioVoice(name: unknown, options?: AssetManagerAudioVoiceOptions): Promise<AssetManagerAudioVoice>;
|
|
90
|
+
stopSound(name: unknown): void;
|
|
91
|
+
stopAllSounds(): void;
|
|
92
|
+
resolveVerifiedRemoteBinary(input: VerifiedRemoteBinaryInput, options: VerifiedRemoteBinaryResolveOptions): Promise<VerifiedRemoteBinaryResult>;
|
|
93
|
+
getVerifiedRemoteCacheStats(): Promise<VerifiedRemoteCacheStats>;
|
|
94
|
+
pruneVerifiedRemoteCache(): Promise<VerifiedRemoteCachePruneResult>;
|
|
95
|
+
clearVerifiedRemoteCache(): Promise<VerifiedRemoteCachePruneResult>;
|
|
96
|
+
listVerifiedRemoteStoryCaches(): Promise<ReadonlyArray<VerifiedRemoteStoryCacheInfo>>;
|
|
97
|
+
pruneVerifiedRemoteStoryCaches(): Promise<VerifiedRemoteStoryCachePruneResult>;
|
|
98
|
+
deleteVerifiedRemoteStoryCache(databaseName: unknown): Promise<VerifiedRemoteStoryCacheDeleteResult>;
|
|
99
|
+
renewVerifiedRemoteStoryCacheLease(): Promise<void>;
|
|
100
|
+
releaseVerifiedRemoteStoryCacheLease(): Promise<void>;
|
|
101
|
+
putBinaryBundle(input: BinaryBundlePutInput, options?: BinaryBundleOperationOptions): Promise<BinaryBundleRegistration>;
|
|
102
|
+
getBinaryBundle(input: BinaryBundleKeyInput, options?: BinaryBundleOperationOptions): Promise<BinaryBundleResult>;
|
|
103
|
+
deleteBinaryBundle(input: BinaryBundleKeyInput, options?: BinaryBundleOperationOptions): Promise<void>;
|
|
104
|
+
getBinaryBundleBackendStatus(): BinaryBundleBackendStatus;
|
|
105
|
+
getBinaryBundleStoreStats(): Promise<BinaryBundleStoreStats>;
|
|
106
|
+
pruneBinaryBundleStore(): Promise<BinaryBundlePruneResult>;
|
|
107
|
+
clearBinaryBundleStore(): Promise<BinaryBundlePruneResult>;
|
|
108
|
+
releaseBinaryStore(): Promise<void>;
|
|
109
|
+
createSessionBinaryBacking(input: SessionBinaryBackingInput, options?: BinaryBundleOperationOptions): Promise<SessionBinaryBacking>;
|
|
110
|
+
}
|
|
111
|
+
export declare function createAssetManagerComposition(featureFlags?: AssetManagerFeatureFlags, options?: AssetManagerCompositionOptions): AssetManagerComposition;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface DOMImageResource {
|
|
2
|
+
readonly url: string;
|
|
3
|
+
readonly mimeType: string;
|
|
4
|
+
readonly width: number;
|
|
5
|
+
readonly height: number;
|
|
6
|
+
readonly released: boolean;
|
|
7
|
+
release(): void;
|
|
8
|
+
}
|
|
9
|
+
export interface DOMImageResourceInput {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly bytes: Uint8Array;
|
|
12
|
+
readonly mimeType: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DOMImageResourceBacking {
|
|
15
|
+
acquire(onRelease?: (resource: DOMImageResource) => void): DOMImageResource;
|
|
16
|
+
}
|
|
17
|
+
export declare function createDOMImageResource(input: DOMImageResourceInput, onRelease?: (resource: DOMImageResource) => void): Promise<DOMImageResource>;
|
|
18
|
+
export declare function createDOMImageResourceBacking(input: DOMImageResourceInput, onIdle?: (backing: DOMImageResourceBacking) => void): Promise<DOMImageResourceBacking>;
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { AssetManagerError } from './asset-cache-error.js';
|
|
2
|
+
import { type AssetManagerFeatureFlags } from './feature-flags.js';
|
|
3
|
+
import { type DOMImageResource } from './dom-image-resource.js';
|
|
4
|
+
import { type AssetManagerAudioVoice, type AssetManagerAudioVoiceOptions } from './audio-voice.js';
|
|
5
|
+
import { type NamedAssetBodyProvider } from './named-body-provider.js';
|
|
6
|
+
export declare const EXTENSION_ID = "kubohiroyaassetcache";
|
|
7
|
+
export declare const EXTENSION_VERSION = "0.14.0";
|
|
8
|
+
export declare const EXTENSION_DOCS_URI = "https://kubohiroya.github.io/turbowarp-asset-cache/";
|
|
9
|
+
export declare const BLOCK_ICON_URI: string;
|
|
10
|
+
type BlockArgs = Record<string, unknown>;
|
|
11
|
+
export type AssetKind = 'external' | 'costume' | 'backdrop' | 'sound' | 'text';
|
|
12
|
+
export interface EmbeddedAssetBytesInput {
|
|
13
|
+
name: unknown;
|
|
14
|
+
bytes: ArrayBuffer | Uint8Array;
|
|
15
|
+
mimeType: unknown;
|
|
16
|
+
sourceName?: unknown;
|
|
17
|
+
bitmapResolution?: 1 | 2;
|
|
18
|
+
}
|
|
19
|
+
export interface EmbeddedAssetRegistration {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly mimeType: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ResolvedImageAssetBytes {
|
|
24
|
+
readonly bytes: Uint8Array;
|
|
25
|
+
readonly mimeType: string;
|
|
26
|
+
}
|
|
27
|
+
export interface AssetManagerDOMImageCapability {
|
|
28
|
+
isRegistered(name: unknown): boolean;
|
|
29
|
+
getMimeType(name: unknown): string;
|
|
30
|
+
resolveDOMImageResource(name: unknown): Promise<DOMImageResource>;
|
|
31
|
+
}
|
|
32
|
+
export type { NamedAssetBodyMetadata, NamedAssetBodyOpenOptions, NamedAssetBodyProvider, NamedAssetBodyReference, NamedAssetBodySnapshot } from './named-body-provider.js';
|
|
33
|
+
interface ResolvedSkin {
|
|
34
|
+
skinId: number;
|
|
35
|
+
sourceSize: number | null;
|
|
36
|
+
}
|
|
37
|
+
export type ParsedResourceIdentifier = {
|
|
38
|
+
kind: 'cache';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'external';
|
|
41
|
+
url: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'costume';
|
|
44
|
+
spriteName: string;
|
|
45
|
+
costumeName: string | null;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'backdrop';
|
|
48
|
+
backdropName: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'sound';
|
|
51
|
+
spriteName: string;
|
|
52
|
+
soundName: string;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'text';
|
|
55
|
+
runtimeVariableName: string;
|
|
56
|
+
};
|
|
57
|
+
export type ProjectAssetLocator = Readonly<{
|
|
58
|
+
kind: 'backdrop';
|
|
59
|
+
name: string;
|
|
60
|
+
}> | Readonly<{
|
|
61
|
+
kind: 'costume';
|
|
62
|
+
target: string;
|
|
63
|
+
name: string;
|
|
64
|
+
}> | Readonly<{
|
|
65
|
+
kind: 'sound';
|
|
66
|
+
name: string;
|
|
67
|
+
target?: string;
|
|
68
|
+
}>;
|
|
69
|
+
export type ProjectAssetAddressValidation = {
|
|
70
|
+
ok: true;
|
|
71
|
+
kind: ParsedResourceIdentifier['kind'];
|
|
72
|
+
projectLocal: boolean;
|
|
73
|
+
} | {
|
|
74
|
+
ok: false;
|
|
75
|
+
type: string;
|
|
76
|
+
label: string;
|
|
77
|
+
message: string;
|
|
78
|
+
};
|
|
79
|
+
export declare function normalizeName(value: unknown): string;
|
|
80
|
+
export declare function parseProjectAssetLocator(value: unknown): ProjectAssetLocator;
|
|
81
|
+
export declare function guessMimeType(value: unknown): string;
|
|
82
|
+
export declare function normalizeMimeType(mimeType: unknown, urlOrName: unknown): string;
|
|
83
|
+
export declare function parseResourceIdentifier(value: unknown, fallbackAssetName?: unknown): ParsedResourceIdentifier;
|
|
84
|
+
export declare function validateProjectAssetAddress(runtime: TurboWarpRuntime, assetName: unknown, resourceIdentifier: unknown): ProjectAssetAddressValidation;
|
|
85
|
+
export declare class AssetManagerExtension {
|
|
86
|
+
protected readonly runtime: TurboWarpRuntime;
|
|
87
|
+
private readonly renderer;
|
|
88
|
+
private readonly externalAssets;
|
|
89
|
+
private readonly costumeAssets;
|
|
90
|
+
private readonly soundAssets;
|
|
91
|
+
private readonly textAssets;
|
|
92
|
+
private readonly assetRegistry;
|
|
93
|
+
private readonly displayedAssets;
|
|
94
|
+
private readonly playingAudio;
|
|
95
|
+
private readonly audioVoiceStops;
|
|
96
|
+
private readonly registrationVersions;
|
|
97
|
+
private readonly successfulRegistrationVersions;
|
|
98
|
+
private readonly registrationCancellationVersions;
|
|
99
|
+
private readonly registrationCommits;
|
|
100
|
+
private readonly committedCacheRecords;
|
|
101
|
+
protected readonly featureFlags: AssetManagerFeatureFlags;
|
|
102
|
+
private loadingBackdropName;
|
|
103
|
+
private loadingCostumes?;
|
|
104
|
+
private loadingAssetCountValue?;
|
|
105
|
+
private lastAssetErrorType;
|
|
106
|
+
private lastAssetErrorLabel;
|
|
107
|
+
private assetErrorVersion;
|
|
108
|
+
private readonly domImageResourceVersions;
|
|
109
|
+
private readonly domImageResourceBackings;
|
|
110
|
+
private readonly activeDOMImageResources;
|
|
111
|
+
private readonly activeDOMImageResourcesByName;
|
|
112
|
+
private domImageCapabilityValue?;
|
|
113
|
+
private namedBodyProviderValue?;
|
|
114
|
+
private namedBodyProviderRegistration;
|
|
115
|
+
private unbindNamedDataRegistryLifecycle;
|
|
116
|
+
private readonly openNamedBodySnapshots;
|
|
117
|
+
private namedBodyLifecycleVersion;
|
|
118
|
+
private listeningForNamedBodyLifecycle;
|
|
119
|
+
private listeningForDOMImageLifecycle;
|
|
120
|
+
private readonly releaseAllDOMImageResourcesForLifecycle;
|
|
121
|
+
private readonly releaseDOMImageResourcesForRuntimeDispose;
|
|
122
|
+
private readonly releaseNamedBodySnapshotsForLifecycle;
|
|
123
|
+
private readonly unregisterNamedBodyProviderForRuntimeDispose;
|
|
124
|
+
constructor(featureFlags?: AssetManagerFeatureFlags);
|
|
125
|
+
setLoadingBackdrop(args: BlockArgs): void;
|
|
126
|
+
setLoadingCostumes(args: BlockArgs): void;
|
|
127
|
+
prepareLoadingAssets(args: BlockArgs, util: ScratchBlockUtility): void;
|
|
128
|
+
loadingAssetCount(): number;
|
|
129
|
+
loadingBackdrop(): string;
|
|
130
|
+
loadingCostumeAt(args: BlockArgs): string;
|
|
131
|
+
getInfo(): {
|
|
132
|
+
id: string;
|
|
133
|
+
name: string;
|
|
134
|
+
docsURI: string;
|
|
135
|
+
blockIconURI: string;
|
|
136
|
+
color1: string;
|
|
137
|
+
color2: string;
|
|
138
|
+
color3: string;
|
|
139
|
+
blocks: Record<string, unknown>[];
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Exposes the stock extension registry through a host-neutral DOM image
|
|
143
|
+
* resource contract for other unsandboxed extensions.
|
|
144
|
+
*/
|
|
145
|
+
getDOMImageCapability(): AssetManagerDOMImageCapability;
|
|
146
|
+
/**
|
|
147
|
+
* Returns the optional read-only `asset` body provider. The startup-fixed
|
|
148
|
+
* feature flag keeps the adapter completely absent from the default path.
|
|
149
|
+
*/
|
|
150
|
+
getNamedBodyProvider(): NamedAssetBodyProvider | null;
|
|
151
|
+
/** Canonical typed entry point for the existing asset registry provider. */
|
|
152
|
+
getNamedDataProvider(): NamedAssetBodyProvider | null;
|
|
153
|
+
validateProjectAssetAddress(args: BlockArgs): string;
|
|
154
|
+
registerProjectAssetLiteral(assetName: unknown, locatorInput: unknown): Promise<void>;
|
|
155
|
+
registerAsset(args: BlockArgs): Promise<void>;
|
|
156
|
+
registerEmbeddedAsset(input: EmbeddedAssetBytesInput): Promise<EmbeddedAssetRegistration>;
|
|
157
|
+
assetErrorType(): string;
|
|
158
|
+
assetErrorLabel(): string;
|
|
159
|
+
/** Legacy opcode retained for existing projects. */
|
|
160
|
+
loadAsset(args: BlockArgs): Promise<void>;
|
|
161
|
+
deleteMemoryAsset(args: BlockArgs): void;
|
|
162
|
+
deleteAllMemoryAssets(): void;
|
|
163
|
+
deleteCachedAsset(args: BlockArgs): Promise<void>;
|
|
164
|
+
deleteAllCachedAssets(): Promise<void>;
|
|
165
|
+
isLoaded(args: BlockArgs): boolean;
|
|
166
|
+
setThisSpriteSkin(args: BlockArgs, util: ScratchBlockUtility): Promise<void>;
|
|
167
|
+
setSpriteSkin(args: BlockArgs, util?: ScratchBlockUtility): Promise<void>;
|
|
168
|
+
setStageSkin(args: BlockArgs): Promise<void>;
|
|
169
|
+
playSound(args: BlockArgs): Promise<void>;
|
|
170
|
+
playSoundUntilDone(args: BlockArgs): Promise<void>;
|
|
171
|
+
createAudioVoice(value: unknown, options?: AssetManagerAudioVoiceOptions): Promise<AssetManagerAudioVoice>;
|
|
172
|
+
stopSound(args: BlockArgs): void;
|
|
173
|
+
stopAllSounds(): void;
|
|
174
|
+
getAssetMimeType(args: BlockArgs): string;
|
|
175
|
+
resolveImageAssetBytes(args: BlockArgs): Promise<ResolvedImageAssetBytes>;
|
|
176
|
+
getVersion(): string;
|
|
177
|
+
setTextValue(args: BlockArgs): Promise<void>;
|
|
178
|
+
setTextStyle(args: BlockArgs): void;
|
|
179
|
+
protected assetNotRegistered(operation: string, name: string): AssetManagerError;
|
|
180
|
+
protected assetTypeMismatch(operation: string, name: string, expectedKind: string, actualKind: string): AssetManagerError;
|
|
181
|
+
private toScratchBlock;
|
|
182
|
+
private requireAssetName;
|
|
183
|
+
private requireTextAssetName;
|
|
184
|
+
private clearAssetError;
|
|
185
|
+
private beginRegistration;
|
|
186
|
+
private cancelRegistrations;
|
|
187
|
+
private isRegistrationCancellationCurrent;
|
|
188
|
+
private registerExternalAsset;
|
|
189
|
+
private registerCostumeReference;
|
|
190
|
+
private registerBackdropReference;
|
|
191
|
+
private registerSoundReference;
|
|
192
|
+
private registerLiteralSoundReference;
|
|
193
|
+
private registerTextReference;
|
|
194
|
+
private unregisterAsset;
|
|
195
|
+
private commitPreparedAsset;
|
|
196
|
+
private commitPreparedAssetNow;
|
|
197
|
+
private assertReplacementKind;
|
|
198
|
+
private replaceRegisteredAsset;
|
|
199
|
+
private getRegisteredAsset;
|
|
200
|
+
private installRegisteredAsset;
|
|
201
|
+
private removeRegisteredAsset;
|
|
202
|
+
private disposeRegisteredAsset;
|
|
203
|
+
private externalMediaKind;
|
|
204
|
+
private openDatabase;
|
|
205
|
+
private transaction;
|
|
206
|
+
private cacheGet;
|
|
207
|
+
private cachePut;
|
|
208
|
+
private cacheDelete;
|
|
209
|
+
private cacheClear;
|
|
210
|
+
private restoreCacheIfGeneration;
|
|
211
|
+
private fetchExternalAsset;
|
|
212
|
+
private getStageTarget;
|
|
213
|
+
protected findTargetByName(name: string): TurboWarpTarget | null;
|
|
214
|
+
private resolveReferencedTarget;
|
|
215
|
+
private findCostume;
|
|
216
|
+
private findSound;
|
|
217
|
+
protected resolveSkin(value: unknown): Promise<ResolvedSkin>;
|
|
218
|
+
protected applyAssetToTarget(target: TurboWarpTarget, value: unknown, util?: ScratchBlockUtility): Promise<void>;
|
|
219
|
+
protected setDisplayBinding(target: TurboWarpTarget, name: string, kind: AssetKind, skinId?: number): void;
|
|
220
|
+
private isDisplayBindingCurrent;
|
|
221
|
+
protected applyResolvedSkinToTarget(target: TurboWarpTarget, name: string, skin: ResolvedSkin): void;
|
|
222
|
+
private applyTextToTarget;
|
|
223
|
+
private applyTextReferenceToTarget;
|
|
224
|
+
private requireTemporaryVariables;
|
|
225
|
+
private setRuntimeVariable;
|
|
226
|
+
private requireAnimatedTextOpcode;
|
|
227
|
+
private ensureExternalSkin;
|
|
228
|
+
private resolveProjectImageStorageAsset;
|
|
229
|
+
private cancelledDOMImageResolution;
|
|
230
|
+
private resolveExtensionDOMImageResource;
|
|
231
|
+
private releaseActiveDOMImageResource;
|
|
232
|
+
private invalidateDOMImageResources;
|
|
233
|
+
private releaseAllDOMImageResources;
|
|
234
|
+
private startListeningForDOMImageLifecycle;
|
|
235
|
+
private stopListeningForDOMImageLifecycle;
|
|
236
|
+
private createNamedBodyProvider;
|
|
237
|
+
private resolveNamedBodySource;
|
|
238
|
+
private releaseOpenNamedBodySnapshots;
|
|
239
|
+
private startListeningForNamedBodyLifecycle;
|
|
240
|
+
private stopListeningForNamedBodyLifecycle;
|
|
241
|
+
private ensureExternalAssetSkin;
|
|
242
|
+
private resolveSkinFromAsset;
|
|
243
|
+
private resolveCostumeReference;
|
|
244
|
+
private resolveCostumeAssetReference;
|
|
245
|
+
private resolveSoundAssetReference;
|
|
246
|
+
private resolveSoundReference;
|
|
247
|
+
private deleteOwnedSkinIfExists;
|
|
248
|
+
protected applySkinToTarget(target: TurboWarpTarget, skin: ResolvedSkin): void;
|
|
249
|
+
protected playResolvedSound(value: unknown, waitUntilDone: boolean): Promise<void>;
|
|
250
|
+
private resolveAudioBytes;
|
|
251
|
+
private startBrowserAudioVoice;
|
|
252
|
+
private playExternalSound;
|
|
253
|
+
private stopExternalAudio;
|
|
254
|
+
private playProjectSound;
|
|
255
|
+
private playbackError;
|
|
256
|
+
private projectAssetMimeType;
|
|
257
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface AssetManagerFeatureFlags {
|
|
2
|
+
readonly ENABLE_LIVE_ASSET_REPLACEMENT: boolean;
|
|
3
|
+
readonly ENABLE_STRICT_ASSET_KIND_REPLACEMENT: boolean;
|
|
4
|
+
readonly NAMED_ASSET_BODY_PROVIDER: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Startup-fixed rollout flags. Optional features remain disabled unless a host
|
|
8
|
+
* explicitly configures them before loading the extension bundle.
|
|
9
|
+
*/
|
|
10
|
+
export declare const FEATURE_FLAGS: AssetManagerFeatureFlags;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NamedDataError, type NamedDataBody, type NamedDataErrorCode, type NamedDataMetadata, type NamedDataProvider, type NamedDataReference, type NamedDataResolveContext } from '@kubohiroya/turbowarp-named-data/composition';
|
|
2
|
+
export declare const NAMED_ASSET_BODY_NAMESPACE: "asset";
|
|
3
|
+
export declare const NamedAssetBodyError: typeof NamedDataError;
|
|
4
|
+
export type NamedAssetBodyErrorCode = NamedDataErrorCode;
|
|
5
|
+
export type NamedAssetBodyMetadata = NamedDataMetadata;
|
|
6
|
+
export type NamedAssetBodyReference = NamedDataReference;
|
|
7
|
+
export type NamedAssetBodySnapshot = NamedDataBody;
|
|
8
|
+
export type NamedAssetBodyOpenOptions = NamedDataResolveContext;
|
|
9
|
+
export type NamedAssetBodyProvider = NamedDataProvider;
|
|
10
|
+
export declare function requireNamedAssetBodyReference(value: unknown): NamedDataReference;
|
|
11
|
+
export declare function namedBodyAbortError(): NamedDataError;
|
|
12
|
+
export declare function throwIfNamedBodyAborted(signal?: AbortSignal): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BinaryBundleStore } from './binary-bundle-store.js';
|
|
2
|
+
import type { BinaryObjectStore } from './binary-object-store.js';
|
|
3
|
+
export interface OpfsBinaryBundleStoreOptions {
|
|
4
|
+
readonly objectStore: BinaryObjectStore;
|
|
5
|
+
readonly indexedDB?: IDBFactory;
|
|
6
|
+
readonly databaseName: string;
|
|
7
|
+
readonly subtleCrypto?: SubtleCrypto;
|
|
8
|
+
readonly now?: () => number;
|
|
9
|
+
readonly maxFilesPerBundle?: number;
|
|
10
|
+
readonly maxBundleBytes?: number;
|
|
11
|
+
readonly maxStoredBundles?: number;
|
|
12
|
+
readonly maxStoreBytes?: number;
|
|
13
|
+
readonly ttlMs?: number;
|
|
14
|
+
readonly recoveryBatchSize?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface EstablishedOpfsBinaryBundleStore extends BinaryBundleStore {
|
|
17
|
+
establish(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare function createOpfsBinaryBundleStore(options: OpfsBinaryBundleStoreOptions): EstablishedOpfsBinaryBundleStore;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ExtensionManifest, type ExtensionManifestBlock } from '@kubohiroya/turbowarp-extension-manifest';
|
|
2
|
+
export interface AssetCacheManifestBlock extends ExtensionManifestBlock {
|
|
3
|
+
resultType: 'boolean' | 'string' | 'void';
|
|
4
|
+
effect: 'control' | 'pure' | 'storage-write';
|
|
5
|
+
immutable: boolean;
|
|
6
|
+
errors: string[];
|
|
7
|
+
server: {
|
|
8
|
+
supported: false;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface AssetCacheManifest extends Omit<ExtensionManifest, 'formatVersion' | 'blocks'> {
|
|
12
|
+
formatVersion: 2;
|
|
13
|
+
blocks: AssetCacheManifestBlock[];
|
|
14
|
+
}
|
|
15
|
+
export declare function createAssetCacheManifest(id: string, definitions: unknown): AssetCacheManifest;
|
|
16
|
+
export declare function serializeAssetCacheManifest(id: string, definitions: unknown): string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type BinaryBundleBackendWarning, type BinaryBundleFileInput, type BinaryBundleFileRegistration, type BinaryBundleKeyInput, type BinaryBundleOperationOptions, type BinaryBundleResult } from './binary-bundle-store.js';
|
|
2
|
+
import type { BinaryStorageBackendPolicy, OpfsBinaryObjectStoreOptions } from './binary-object-store.js';
|
|
3
|
+
export type SessionBinaryBackingPolicy = 'prefer' | 'required' | 'disabled';
|
|
4
|
+
export type SessionBinaryBackingMode = 'session' | 'direct';
|
|
5
|
+
export interface SessionBinaryBackingAssetInput extends BinaryBundleKeyInput {
|
|
6
|
+
readonly files: ReadonlyArray<BinaryBundleFileRegistration>;
|
|
7
|
+
}
|
|
8
|
+
export interface SessionBinaryBackingSourceAsset extends BinaryBundleKeyInput {
|
|
9
|
+
readonly files: ReadonlyArray<BinaryBundleFileInput>;
|
|
10
|
+
}
|
|
11
|
+
export interface SessionBinaryBackingSource {
|
|
12
|
+
read(asset: SessionBinaryBackingAssetInput, options?: BinaryBundleOperationOptions): Promise<SessionBinaryBackingSourceAsset>;
|
|
13
|
+
release(): Promise<void> | void;
|
|
14
|
+
}
|
|
15
|
+
export interface SessionBinaryBackingWarning {
|
|
16
|
+
readonly code: 'ASSET_SESSION_BINARY_DIRECT_FALLBACK';
|
|
17
|
+
readonly causeCode: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SessionBinaryBackingInput {
|
|
20
|
+
readonly policy: unknown;
|
|
21
|
+
readonly sessionId: unknown;
|
|
22
|
+
readonly assets: ReadonlyArray<SessionBinaryBackingAssetInput>;
|
|
23
|
+
readonly source: SessionBinaryBackingSource;
|
|
24
|
+
readonly onFatalError?: (error: Error) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface SessionBinaryBackingOptions {
|
|
27
|
+
readonly indexedDB?: IDBFactory;
|
|
28
|
+
readonly subtleCrypto?: SubtleCrypto;
|
|
29
|
+
readonly databaseName?: string;
|
|
30
|
+
readonly now?: () => number;
|
|
31
|
+
readonly maxFilesPerAsset?: number;
|
|
32
|
+
readonly maxAssetBytes?: number;
|
|
33
|
+
readonly maxSessionAssets?: number;
|
|
34
|
+
readonly maxSessionBytes?: number;
|
|
35
|
+
readonly leaseTtlMs?: number;
|
|
36
|
+
readonly heartbeatIntervalMs?: number;
|
|
37
|
+
readonly orphanCleanupBatchSize?: number;
|
|
38
|
+
readonly backendPolicy?: BinaryStorageBackendPolicy;
|
|
39
|
+
readonly opfs?: OpfsBinaryObjectStoreOptions;
|
|
40
|
+
readonly opfsMetadataDatabaseName?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface SessionBinaryBacking {
|
|
43
|
+
readonly sessionId: string;
|
|
44
|
+
readonly mode: SessionBinaryBackingMode;
|
|
45
|
+
readonly backend: 'direct' | 'indexeddb' | 'opfs';
|
|
46
|
+
readonly warning?: SessionBinaryBackingWarning;
|
|
47
|
+
readonly storageWarning?: BinaryBundleBackendWarning;
|
|
48
|
+
get(input: BinaryBundleKeyInput, options?: BinaryBundleOperationOptions): Promise<BinaryBundleResult>;
|
|
49
|
+
renewLease(): Promise<void>;
|
|
50
|
+
dispose(): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Establish a fixed direct or IndexedDB-backed binary session without changing persistent caches.
|
|
54
|
+
*
|
|
55
|
+
* The source must remain readable until `release` is called. A `prefer` fallback keeps that same
|
|
56
|
+
* source for direct reads; an established session releases it only after every bundle passes
|
|
57
|
+
* commit and integrity read-back.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createSessionBinaryBacking(inputValue: SessionBinaryBackingInput, optionValue?: SessionBinaryBackingOptions, operationOptions?: BinaryBundleOperationOptions): Promise<SessionBinaryBacking>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const TEXT_RUNTIME_NAMESPACE = "text";
|
|
2
|
+
export declare const TEXT_STYLE_RUNTIME_NAMESPACE = "textStyle";
|
|
3
|
+
export declare const TEXT_STYLE_PROPERTIES: readonly ["animation", "font", "color", "width", "align"];
|
|
4
|
+
export type TextStyleProperty = typeof TEXT_STYLE_PROPERTIES[number];
|
|
5
|
+
export type TextAnimation = 'none' | 'type' | 'rainbow' | 'zoom' | 'shake';
|
|
6
|
+
export type TextAlignment = 'left' | 'center' | 'right';
|
|
7
|
+
export interface TextStyle {
|
|
8
|
+
animation: TextAnimation;
|
|
9
|
+
font: string;
|
|
10
|
+
color: string;
|
|
11
|
+
width: number;
|
|
12
|
+
align: TextAlignment;
|
|
13
|
+
}
|
|
14
|
+
export declare const DEFAULT_OUTLINE_WIDTH = 2;
|
|
15
|
+
export declare const DEFAULT_OUTLINE_COLOR = "#000000";
|
|
16
|
+
export declare function textRuntimeVariableName(name: string): string;
|
|
17
|
+
export declare function textStyleRuntimeVariableName(name: string, property: TextStyleProperty): string;
|
|
18
|
+
export declare function normalizeTextStyleProperty(value: unknown): TextStyleProperty;
|
|
19
|
+
/**
|
|
20
|
+
* Normalize a DSL-facing style value for runtime-variable storage.
|
|
21
|
+
* An empty value intentionally resets the property to its default.
|
|
22
|
+
*/
|
|
23
|
+
export declare function normalizeTextStyleValue(property: TextStyleProperty, value: unknown): string;
|
|
24
|
+
export declare function resolveTextStyle(name: string, stageWidth: unknown, getRuntimeVariable: (variableName: string) => unknown): TextStyle;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface VerifiedRemoteStoryCacheInfo {
|
|
2
|
+
readonly databaseName: string;
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly entries: number;
|
|
6
|
+
readonly bytes: number;
|
|
7
|
+
readonly lastOpenedAt: number;
|
|
8
|
+
readonly lastAccessedAt: number;
|
|
9
|
+
readonly lastCleanupAt: number | null;
|
|
10
|
+
readonly active: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface VerifiedRemoteStoryCachePruneResult {
|
|
13
|
+
readonly removedDatabases: number;
|
|
14
|
+
readonly removedEntries: number;
|
|
15
|
+
readonly removedBytes: number;
|
|
16
|
+
readonly remainingDatabases: number;
|
|
17
|
+
readonly remainingBytes: number;
|
|
18
|
+
readonly highWaterBytes: number;
|
|
19
|
+
readonly lowWaterBytes: number;
|
|
20
|
+
readonly warnings: ReadonlyArray<string>;
|
|
21
|
+
}
|
|
22
|
+
export interface VerifiedRemoteStoryCacheDeleteResult {
|
|
23
|
+
readonly databaseName: string;
|
|
24
|
+
readonly deleted: boolean;
|
|
25
|
+
readonly removedEntries: number;
|
|
26
|
+
readonly removedBytes: number;
|
|
27
|
+
}
|
|
28
|
+
export interface StoryCacheCatalogIdentity {
|
|
29
|
+
readonly databaseName: string;
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly label: string;
|
|
32
|
+
}
|
|
33
|
+
export interface StoryCacheCatalogStats {
|
|
34
|
+
readonly entries: number;
|
|
35
|
+
readonly bytes: number;
|
|
36
|
+
readonly lastCleanupAt: number | null;
|
|
37
|
+
readonly revision: number;
|
|
38
|
+
}
|
|
39
|
+
export declare class StoryCacheCatalog {
|
|
40
|
+
#private;
|
|
41
|
+
constructor(indexedDB: IDBFactory | undefined, now: () => number);
|
|
42
|
+
acquireLease(identity: StoryCacheCatalogIdentity, accessedAt: number, token: string, expiresAt: number): Promise<void>;
|
|
43
|
+
upsertAndRenewLease(identity: StoryCacheCatalogIdentity, stats: StoryCacheCatalogStats, accessedAt: number, token: string, expiresAt: number): Promise<void>;
|
|
44
|
+
touchAndRenewLease(identity: StoryCacheCatalogIdentity, accessedAt: number, token: string, expiresAt: number): Promise<void>;
|
|
45
|
+
list(): Promise<ReadonlyArray<VerifiedRemoteStoryCacheInfo>>;
|
|
46
|
+
delete(databaseName: string, deletionToken: string): Promise<VerifiedRemoteStoryCacheDeleteResult>;
|
|
47
|
+
releaseLease(databaseName: string, token: string): Promise<void>;
|
|
48
|
+
prune(options: {
|
|
49
|
+
readonly highWaterBytes: number;
|
|
50
|
+
readonly lowWaterBytes: number;
|
|
51
|
+
readonly ttlMs: number;
|
|
52
|
+
readonly incomingBytes?: number;
|
|
53
|
+
readonly pinnedDatabaseName?: string | null;
|
|
54
|
+
readonly force?: boolean;
|
|
55
|
+
readonly createDeletionToken: () => string;
|
|
56
|
+
}): Promise<VerifiedRemoteStoryCachePruneResult>;
|
|
57
|
+
}
|