@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,420 @@
|
|
|
1
|
+
{
|
|
2
|
+
"formatVersion": 2,
|
|
3
|
+
"id": "kubohiroyaassetcache",
|
|
4
|
+
"blocks": [
|
|
5
|
+
{
|
|
6
|
+
"opcode": "assetErrorLabel",
|
|
7
|
+
"blockType": "REPORTER",
|
|
8
|
+
"arguments": [],
|
|
9
|
+
"resultType": "string",
|
|
10
|
+
"effect": "pure",
|
|
11
|
+
"immutable": true,
|
|
12
|
+
"errors": [],
|
|
13
|
+
"server": {
|
|
14
|
+
"supported": false
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"opcode": "assetErrorType",
|
|
19
|
+
"blockType": "REPORTER",
|
|
20
|
+
"arguments": [],
|
|
21
|
+
"resultType": "string",
|
|
22
|
+
"effect": "pure",
|
|
23
|
+
"immutable": true,
|
|
24
|
+
"errors": [],
|
|
25
|
+
"server": {
|
|
26
|
+
"supported": false
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"opcode": "deleteAllCachedAssets",
|
|
31
|
+
"blockType": "COMMAND",
|
|
32
|
+
"arguments": [],
|
|
33
|
+
"resultType": "void",
|
|
34
|
+
"effect": "storage-write",
|
|
35
|
+
"immutable": false,
|
|
36
|
+
"errors": [],
|
|
37
|
+
"server": {
|
|
38
|
+
"supported": false
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"opcode": "deleteAllMemoryAssets",
|
|
43
|
+
"blockType": "COMMAND",
|
|
44
|
+
"arguments": [],
|
|
45
|
+
"resultType": "void",
|
|
46
|
+
"effect": "control",
|
|
47
|
+
"immutable": false,
|
|
48
|
+
"errors": [],
|
|
49
|
+
"server": {
|
|
50
|
+
"supported": false
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"opcode": "deleteCachedAsset",
|
|
55
|
+
"blockType": "COMMAND",
|
|
56
|
+
"arguments": [
|
|
57
|
+
{
|
|
58
|
+
"id": "NAME",
|
|
59
|
+
"type": "STRING"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"resultType": "void",
|
|
63
|
+
"effect": "storage-write",
|
|
64
|
+
"immutable": false,
|
|
65
|
+
"errors": [],
|
|
66
|
+
"server": {
|
|
67
|
+
"supported": false
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"opcode": "deleteMemoryAsset",
|
|
72
|
+
"blockType": "COMMAND",
|
|
73
|
+
"arguments": [
|
|
74
|
+
{
|
|
75
|
+
"id": "NAME",
|
|
76
|
+
"type": "STRING"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"resultType": "void",
|
|
80
|
+
"effect": "control",
|
|
81
|
+
"immutable": false,
|
|
82
|
+
"errors": [],
|
|
83
|
+
"server": {
|
|
84
|
+
"supported": false
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"opcode": "finishAllActorSequences",
|
|
89
|
+
"blockType": "COMMAND",
|
|
90
|
+
"arguments": [],
|
|
91
|
+
"resultType": "void",
|
|
92
|
+
"effect": "control",
|
|
93
|
+
"immutable": false,
|
|
94
|
+
"errors": [],
|
|
95
|
+
"server": {
|
|
96
|
+
"supported": false
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"opcode": "getAssetMimeType",
|
|
101
|
+
"blockType": "REPORTER",
|
|
102
|
+
"arguments": [
|
|
103
|
+
{
|
|
104
|
+
"id": "NAME",
|
|
105
|
+
"type": "STRING"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"resultType": "string",
|
|
109
|
+
"effect": "pure",
|
|
110
|
+
"immutable": true,
|
|
111
|
+
"errors": [],
|
|
112
|
+
"server": {
|
|
113
|
+
"supported": false
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"opcode": "getVersion",
|
|
118
|
+
"blockType": "REPORTER",
|
|
119
|
+
"arguments": [],
|
|
120
|
+
"resultType": "string",
|
|
121
|
+
"effect": "pure",
|
|
122
|
+
"immutable": true,
|
|
123
|
+
"errors": [],
|
|
124
|
+
"server": {
|
|
125
|
+
"supported": false
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"opcode": "isLoaded",
|
|
130
|
+
"blockType": "BOOLEAN",
|
|
131
|
+
"arguments": [
|
|
132
|
+
{
|
|
133
|
+
"id": "NAME",
|
|
134
|
+
"type": "STRING"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
"resultType": "boolean",
|
|
138
|
+
"effect": "pure",
|
|
139
|
+
"immutable": true,
|
|
140
|
+
"errors": [],
|
|
141
|
+
"server": {
|
|
142
|
+
"supported": false
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"opcode": "loadAsset",
|
|
147
|
+
"blockType": "COMMAND",
|
|
148
|
+
"arguments": [
|
|
149
|
+
{
|
|
150
|
+
"id": "NAME",
|
|
151
|
+
"type": "STRING"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"id": "URL",
|
|
155
|
+
"type": "STRING"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"resultType": "void",
|
|
159
|
+
"effect": "control",
|
|
160
|
+
"immutable": false,
|
|
161
|
+
"errors": [],
|
|
162
|
+
"server": {
|
|
163
|
+
"supported": false
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"opcode": "playSound",
|
|
168
|
+
"blockType": "COMMAND",
|
|
169
|
+
"arguments": [
|
|
170
|
+
{
|
|
171
|
+
"id": "NAME",
|
|
172
|
+
"type": "STRING"
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"resultType": "void",
|
|
176
|
+
"effect": "control",
|
|
177
|
+
"immutable": false,
|
|
178
|
+
"errors": [],
|
|
179
|
+
"server": {
|
|
180
|
+
"supported": false
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"opcode": "playSoundUntilDone",
|
|
185
|
+
"blockType": "COMMAND",
|
|
186
|
+
"arguments": [
|
|
187
|
+
{
|
|
188
|
+
"id": "NAME",
|
|
189
|
+
"type": "STRING"
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"resultType": "void",
|
|
193
|
+
"effect": "control",
|
|
194
|
+
"immutable": false,
|
|
195
|
+
"errors": [],
|
|
196
|
+
"server": {
|
|
197
|
+
"supported": false
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"opcode": "registerAsset",
|
|
202
|
+
"blockType": "COMMAND",
|
|
203
|
+
"arguments": [
|
|
204
|
+
{
|
|
205
|
+
"id": "NAME",
|
|
206
|
+
"type": "STRING"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"id": "RESOURCE_ID",
|
|
210
|
+
"type": "STRING"
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
"resultType": "void",
|
|
214
|
+
"effect": "control",
|
|
215
|
+
"immutable": false,
|
|
216
|
+
"errors": [],
|
|
217
|
+
"server": {
|
|
218
|
+
"supported": false
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"opcode": "setSpriteSkin",
|
|
223
|
+
"blockType": "COMMAND",
|
|
224
|
+
"arguments": [
|
|
225
|
+
{
|
|
226
|
+
"id": "NAME",
|
|
227
|
+
"type": "STRING"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"id": "SPRITE",
|
|
231
|
+
"type": "STRING"
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
"resultType": "void",
|
|
235
|
+
"effect": "control",
|
|
236
|
+
"immutable": false,
|
|
237
|
+
"errors": [],
|
|
238
|
+
"server": {
|
|
239
|
+
"supported": false
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"opcode": "setStageSkin",
|
|
244
|
+
"blockType": "COMMAND",
|
|
245
|
+
"arguments": [
|
|
246
|
+
{
|
|
247
|
+
"id": "NAME",
|
|
248
|
+
"type": "STRING"
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
"resultType": "void",
|
|
252
|
+
"effect": "control",
|
|
253
|
+
"immutable": false,
|
|
254
|
+
"errors": [],
|
|
255
|
+
"server": {
|
|
256
|
+
"supported": false
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"opcode": "setTextStyle",
|
|
261
|
+
"blockType": "COMMAND",
|
|
262
|
+
"arguments": [
|
|
263
|
+
{
|
|
264
|
+
"id": "NAME",
|
|
265
|
+
"type": "STRING"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"id": "PROPERTY",
|
|
269
|
+
"type": "STRING"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"id": "VALUE",
|
|
273
|
+
"type": "STRING"
|
|
274
|
+
}
|
|
275
|
+
],
|
|
276
|
+
"resultType": "void",
|
|
277
|
+
"effect": "control",
|
|
278
|
+
"immutable": false,
|
|
279
|
+
"errors": [],
|
|
280
|
+
"server": {
|
|
281
|
+
"supported": false
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"opcode": "setTextValue",
|
|
286
|
+
"blockType": "COMMAND",
|
|
287
|
+
"arguments": [
|
|
288
|
+
{
|
|
289
|
+
"id": "NAME",
|
|
290
|
+
"type": "STRING"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"id": "VALUE",
|
|
294
|
+
"type": "STRING"
|
|
295
|
+
}
|
|
296
|
+
],
|
|
297
|
+
"resultType": "void",
|
|
298
|
+
"effect": "control",
|
|
299
|
+
"immutable": false,
|
|
300
|
+
"errors": [],
|
|
301
|
+
"server": {
|
|
302
|
+
"supported": false
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"opcode": "setThisSpriteSkin",
|
|
307
|
+
"blockType": "COMMAND",
|
|
308
|
+
"arguments": [
|
|
309
|
+
{
|
|
310
|
+
"id": "NAME",
|
|
311
|
+
"type": "STRING"
|
|
312
|
+
}
|
|
313
|
+
],
|
|
314
|
+
"resultType": "void",
|
|
315
|
+
"effect": "control",
|
|
316
|
+
"immutable": false,
|
|
317
|
+
"errors": [],
|
|
318
|
+
"server": {
|
|
319
|
+
"supported": false
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"opcode": "startActorLoop",
|
|
324
|
+
"blockType": "COMMAND",
|
|
325
|
+
"arguments": [
|
|
326
|
+
{
|
|
327
|
+
"id": "ACTOR",
|
|
328
|
+
"type": "STRING"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"id": "ASSETS",
|
|
332
|
+
"type": "STRING"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"id": "DURATIONS",
|
|
336
|
+
"type": "STRING"
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
"resultType": "void",
|
|
340
|
+
"effect": "control",
|
|
341
|
+
"immutable": false,
|
|
342
|
+
"errors": [],
|
|
343
|
+
"server": {
|
|
344
|
+
"supported": false
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"opcode": "startActorSequence",
|
|
349
|
+
"blockType": "COMMAND",
|
|
350
|
+
"arguments": [
|
|
351
|
+
{
|
|
352
|
+
"id": "ACTOR",
|
|
353
|
+
"type": "STRING"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"id": "ASSETS",
|
|
357
|
+
"type": "STRING"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"id": "DURATIONS",
|
|
361
|
+
"type": "STRING"
|
|
362
|
+
}
|
|
363
|
+
],
|
|
364
|
+
"resultType": "void",
|
|
365
|
+
"effect": "control",
|
|
366
|
+
"immutable": false,
|
|
367
|
+
"errors": [],
|
|
368
|
+
"server": {
|
|
369
|
+
"supported": false
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"opcode": "stopActorAnimation",
|
|
374
|
+
"blockType": "COMMAND",
|
|
375
|
+
"arguments": [
|
|
376
|
+
{
|
|
377
|
+
"id": "ACTOR",
|
|
378
|
+
"type": "STRING"
|
|
379
|
+
}
|
|
380
|
+
],
|
|
381
|
+
"resultType": "void",
|
|
382
|
+
"effect": "control",
|
|
383
|
+
"immutable": false,
|
|
384
|
+
"errors": [],
|
|
385
|
+
"server": {
|
|
386
|
+
"supported": false
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"opcode": "stopAllSounds",
|
|
391
|
+
"blockType": "COMMAND",
|
|
392
|
+
"arguments": [],
|
|
393
|
+
"resultType": "void",
|
|
394
|
+
"effect": "control",
|
|
395
|
+
"immutable": false,
|
|
396
|
+
"errors": [],
|
|
397
|
+
"server": {
|
|
398
|
+
"supported": false
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"opcode": "stopSound",
|
|
403
|
+
"blockType": "COMMAND",
|
|
404
|
+
"arguments": [
|
|
405
|
+
{
|
|
406
|
+
"id": "NAME",
|
|
407
|
+
"type": "STRING"
|
|
408
|
+
}
|
|
409
|
+
],
|
|
410
|
+
"resultType": "void",
|
|
411
|
+
"effect": "control",
|
|
412
|
+
"immutable": false,
|
|
413
|
+
"errors": [],
|
|
414
|
+
"server": {
|
|
415
|
+
"supported": false
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
],
|
|
419
|
+
"menus": []
|
|
420
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AssetManagerExtension } from './extension.js';
|
|
2
|
+
import { type AssetManagerFeatureFlags } from './feature-flags.js';
|
|
3
|
+
type BlockArgs = Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* Asset Cache with actor-level background asset animation.
|
|
6
|
+
*
|
|
7
|
+
* ACTOR is resolved from a clone-local actorName variable before falling back
|
|
8
|
+
* to the existing named-sprite behaviour of setSpriteSkin.
|
|
9
|
+
* ASSETS and DURATIONS are comma-separated strings. ASSETS contains registered
|
|
10
|
+
* image or audio asset names. Each duration is the interval before the next
|
|
11
|
+
* action, and a zero groups those adjacent actions. Loop has one interval per
|
|
12
|
+
* action; sequence omits the final interval. COSTUMES remains accepted as a
|
|
13
|
+
* compatibility alias for projects saved with the earlier block.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AnimatedAssetManagerExtension extends AssetManagerExtension {
|
|
16
|
+
private readonly actorAnimations;
|
|
17
|
+
private animationGeneration;
|
|
18
|
+
constructor(featureFlags?: AssetManagerFeatureFlags);
|
|
19
|
+
setThisSpriteSkin(args: BlockArgs, util: ScratchBlockUtility): Promise<void>;
|
|
20
|
+
setSpriteSkin(args: BlockArgs, util?: ScratchBlockUtility): Promise<void>;
|
|
21
|
+
startActorLoop(args: BlockArgs, util?: ScratchBlockUtility): void;
|
|
22
|
+
startActorSequence(args: BlockArgs, util?: ScratchBlockUtility): void;
|
|
23
|
+
stopActorAnimation(args: BlockArgs, util?: ScratchBlockUtility): void;
|
|
24
|
+
finishAllActorSequences(): Promise<void>;
|
|
25
|
+
deleteAllMemoryAssets(): void;
|
|
26
|
+
private getAnimationAssetsInput;
|
|
27
|
+
private requireActorName;
|
|
28
|
+
private actorNameOf;
|
|
29
|
+
private resolveActorTarget;
|
|
30
|
+
private parseAnimation;
|
|
31
|
+
private startActorAnimation;
|
|
32
|
+
private createAnimationAction;
|
|
33
|
+
private showCurrentStep;
|
|
34
|
+
private getCurrentBatch;
|
|
35
|
+
private advance;
|
|
36
|
+
private isCurrent;
|
|
37
|
+
private stopActor;
|
|
38
|
+
private stopTarget;
|
|
39
|
+
private stopAllActorAnimations;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const ASSET_MANAGER_ERROR_CODES: readonly ["INVALID_ASSET_NAME", "ASSET_NOT_REGISTERED", "ASSET_TYPE_MISMATCH", "ASSET_TYPE_CHANGE", "SPRITE_NOT_FOUND", "SPRITE_NAME_AMBIGUOUS", "SOURCE_ASSET_NOT_FOUND", "RESOURCE_ID_INVALID", "DEPENDENCY_MISSING", "STYLE_PROPERTY_INVALID", "STYLE_VALUE_INVALID", "PLAYBACK_FAILED", "ANIMATION_FAILED", "REPLACEMENT_FAILED"];
|
|
2
|
+
export type AssetManagerErrorCode = typeof ASSET_MANAGER_ERROR_CODES[number];
|
|
3
|
+
export interface AssetManagerErrorContext {
|
|
4
|
+
operation: string;
|
|
5
|
+
assetName?: string | undefined;
|
|
6
|
+
resourceId?: string | undefined;
|
|
7
|
+
actorName?: string | undefined;
|
|
8
|
+
expectedKind?: string | undefined;
|
|
9
|
+
actualKind?: string | undefined;
|
|
10
|
+
hint?: string | undefined;
|
|
11
|
+
candidates?: string[] | undefined;
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export declare class AssetManagerError extends Error {
|
|
15
|
+
readonly code: AssetManagerErrorCode;
|
|
16
|
+
readonly operation: string;
|
|
17
|
+
readonly assetName: string | undefined;
|
|
18
|
+
readonly resourceId: string | undefined;
|
|
19
|
+
readonly actorName: string | undefined;
|
|
20
|
+
readonly expectedKind: string | undefined;
|
|
21
|
+
readonly actualKind: string | undefined;
|
|
22
|
+
readonly hint: string | undefined;
|
|
23
|
+
readonly candidates: readonly string[];
|
|
24
|
+
constructor(code: AssetManagerErrorCode, message: string, context: AssetManagerErrorContext);
|
|
25
|
+
}
|
|
26
|
+
export declare function suggestNames(value: unknown, choices: Iterable<string>, limit?: number): string[];
|
|
27
|
+
export declare function suggestionHint(candidates: readonly string[]): string | undefined;
|
|
28
|
+
export declare function errorMessage(error: unknown): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface AssetManagerAudioVoice {
|
|
2
|
+
readonly ended: Promise<void>;
|
|
3
|
+
setGain(value: number): void;
|
|
4
|
+
stop(): void;
|
|
5
|
+
}
|
|
6
|
+
export interface AssetManagerAudioVoiceOptions {
|
|
7
|
+
readonly gain?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function normalizeAudioVoiceGain(value: unknown, label?: string): number;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type BinaryStorageBackendPolicy, type OpfsBinaryObjectStoreOptions } from './binary-object-store.js';
|
|
2
|
+
export interface BinaryBundleKeyInput {
|
|
3
|
+
readonly namespace: unknown;
|
|
4
|
+
readonly name: unknown;
|
|
5
|
+
readonly integrity: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface BinaryBundleFileInput {
|
|
8
|
+
readonly path: unknown;
|
|
9
|
+
readonly size: unknown;
|
|
10
|
+
readonly integrity: unknown;
|
|
11
|
+
readonly bytes: ArrayBuffer | Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
export interface BinaryBundlePutInput extends BinaryBundleKeyInput {
|
|
14
|
+
readonly files: ReadonlyArray<BinaryBundleFileInput>;
|
|
15
|
+
}
|
|
16
|
+
export interface BinaryBundleOperationOptions {
|
|
17
|
+
readonly signal?: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
export interface BinaryBundleFileRegistration {
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly size: number;
|
|
22
|
+
readonly integrity: string;
|
|
23
|
+
}
|
|
24
|
+
export interface BinaryBundleRegistration {
|
|
25
|
+
readonly namespace: string;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly integrity: string;
|
|
28
|
+
readonly files: ReadonlyArray<BinaryBundleFileRegistration>;
|
|
29
|
+
readonly totalBytes: number;
|
|
30
|
+
}
|
|
31
|
+
export interface BinaryBundleFileResult extends BinaryBundleFileRegistration {
|
|
32
|
+
readonly bytes: Uint8Array;
|
|
33
|
+
}
|
|
34
|
+
export interface BinaryBundleResult {
|
|
35
|
+
readonly namespace: string;
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly integrity: string;
|
|
38
|
+
readonly files: ReadonlyArray<BinaryBundleFileResult>;
|
|
39
|
+
readonly totalBytes: number;
|
|
40
|
+
}
|
|
41
|
+
export interface BinaryBundleStoreOptions {
|
|
42
|
+
readonly indexedDB?: IDBFactory;
|
|
43
|
+
readonly subtleCrypto?: SubtleCrypto;
|
|
44
|
+
readonly databaseName?: string;
|
|
45
|
+
readonly now?: () => number;
|
|
46
|
+
readonly maxFilesPerBundle?: number;
|
|
47
|
+
readonly maxBundleBytes?: number;
|
|
48
|
+
readonly maxStoredBundles?: number;
|
|
49
|
+
readonly maxStoreBytes?: number;
|
|
50
|
+
readonly ttlMs?: number;
|
|
51
|
+
readonly backendPolicy?: BinaryStorageBackendPolicy;
|
|
52
|
+
readonly opfs?: OpfsBinaryObjectStoreOptions;
|
|
53
|
+
readonly opfsMetadataDatabaseName?: string;
|
|
54
|
+
readonly recoveryBatchSize?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface BinaryBundleBackendWarning {
|
|
57
|
+
readonly code: 'ASSET_BINARY_BACKEND_FALLBACK';
|
|
58
|
+
readonly causeCode: string;
|
|
59
|
+
}
|
|
60
|
+
export interface BinaryBundleBackendStatus {
|
|
61
|
+
readonly policy: BinaryStorageBackendPolicy;
|
|
62
|
+
readonly selected: 'pending' | 'indexeddb' | 'opfs';
|
|
63
|
+
readonly warning?: BinaryBundleBackendWarning;
|
|
64
|
+
}
|
|
65
|
+
export interface BinaryBundleStoreStats {
|
|
66
|
+
readonly backend: 'indexeddb' | 'opfs';
|
|
67
|
+
readonly bundles: number;
|
|
68
|
+
readonly logicalBytes: number;
|
|
69
|
+
readonly physicalObjectBytes: number;
|
|
70
|
+
readonly stagingBytes: number;
|
|
71
|
+
readonly orphanBytes: number;
|
|
72
|
+
readonly pendingDeletionBytes: number;
|
|
73
|
+
}
|
|
74
|
+
export interface BinaryBundlePruneResult {
|
|
75
|
+
readonly removedBundles: number;
|
|
76
|
+
readonly removedBytes: number;
|
|
77
|
+
}
|
|
78
|
+
export interface BinaryBundleStore {
|
|
79
|
+
put(input: BinaryBundlePutInput, options?: BinaryBundleOperationOptions): Promise<BinaryBundleRegistration>;
|
|
80
|
+
get(input: BinaryBundleKeyInput, options?: BinaryBundleOperationOptions): Promise<BinaryBundleResult>;
|
|
81
|
+
delete(input: BinaryBundleKeyInput, options?: BinaryBundleOperationOptions): Promise<void>;
|
|
82
|
+
touch(input: BinaryBundleKeyInput, options?: BinaryBundleOperationOptions): Promise<void>;
|
|
83
|
+
getStats(): Promise<BinaryBundleStoreStats>;
|
|
84
|
+
prune(): Promise<BinaryBundlePruneResult>;
|
|
85
|
+
clear(): Promise<BinaryBundlePruneResult>;
|
|
86
|
+
getBackendStatus(): BinaryBundleBackendStatus;
|
|
87
|
+
release(): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create a binary bundle store whose backend is selected once, before its first operation.
|
|
91
|
+
* IndexedDB remains the default so existing consumers keep the previous behavior.
|
|
92
|
+
*/
|
|
93
|
+
export declare function createBinaryBundleStore(options?: BinaryBundleStoreOptions): BinaryBundleStore;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export type BinaryStorageBackendPolicy = 'indexeddb' | 'opfs-prefer' | 'opfs-required';
|
|
2
|
+
export interface BinaryObjectDescriptor {
|
|
3
|
+
readonly key: string;
|
|
4
|
+
readonly size: number;
|
|
5
|
+
readonly integrity: string;
|
|
6
|
+
readonly contentType?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface BinaryObjectResult extends BinaryObjectDescriptor {
|
|
9
|
+
readonly bytes: Uint8Array;
|
|
10
|
+
}
|
|
11
|
+
export interface BinaryObjectOperationOptions {
|
|
12
|
+
readonly signal?: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
export interface BinaryObjectStoreStats {
|
|
15
|
+
readonly physicalObjectBytes: number;
|
|
16
|
+
readonly stagingBytes: number;
|
|
17
|
+
readonly orphanBytes: number;
|
|
18
|
+
readonly pendingDeletionBytes: number;
|
|
19
|
+
}
|
|
20
|
+
export interface BinaryObjectStatsOptions extends BinaryObjectOperationOptions {
|
|
21
|
+
readonly referencedKeys?: ReadonlySet<string>;
|
|
22
|
+
readonly pendingDeletionKeys?: ReadonlySet<string>;
|
|
23
|
+
}
|
|
24
|
+
export interface BinaryObjectStore {
|
|
25
|
+
readonly kind: 'indexeddb' | 'opfs';
|
|
26
|
+
put(descriptor: BinaryObjectDescriptor, source: ArrayBuffer | Uint8Array | ReadableStream<Uint8Array>, options?: BinaryObjectOperationOptions): Promise<void>;
|
|
27
|
+
get(descriptor: BinaryObjectDescriptor, options?: BinaryObjectOperationOptions): Promise<BinaryObjectResult>;
|
|
28
|
+
delete(key: string, options?: BinaryObjectOperationOptions): Promise<void>;
|
|
29
|
+
listOrphans?(options?: {
|
|
30
|
+
readonly limit?: number;
|
|
31
|
+
readonly signal?: AbortSignal;
|
|
32
|
+
}): AsyncIterable<string>;
|
|
33
|
+
cleanupStaging?(options?: {
|
|
34
|
+
readonly limit?: number;
|
|
35
|
+
readonly createdBefore?: number;
|
|
36
|
+
readonly signal?: AbortSignal;
|
|
37
|
+
}): Promise<number>;
|
|
38
|
+
getStats?(options?: BinaryObjectStatsOptions): Promise<BinaryObjectStoreStats>;
|
|
39
|
+
release(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export interface OpfsStorageManager {
|
|
42
|
+
getDirectory(): Promise<FileSystemDirectoryHandle>;
|
|
43
|
+
}
|
|
44
|
+
export interface OpfsBinaryObjectStoreOptions {
|
|
45
|
+
readonly rootDirectory?: FileSystemDirectoryHandle;
|
|
46
|
+
readonly storage?: OpfsStorageManager;
|
|
47
|
+
readonly subtleCrypto?: SubtleCrypto;
|
|
48
|
+
}
|
|
49
|
+
export interface IndexedDBBinaryObjectStoreOptions {
|
|
50
|
+
readonly indexedDB?: IDBFactory;
|
|
51
|
+
readonly databaseName?: string;
|
|
52
|
+
readonly subtleCrypto?: SubtleCrypto;
|
|
53
|
+
}
|
|
54
|
+
export declare function createOpfsBinaryObjectStore(options?: OpfsBinaryObjectStoreOptions): BinaryObjectStore;
|
|
55
|
+
/** IndexedDB adapter for consumers that want the object contract without OPFS. */
|
|
56
|
+
export declare function createIndexedDBBinaryObjectStore(options?: IndexedDBBinaryObjectStoreOptions): BinaryObjectStore;
|