moonscratch 0.1.0 → 0.1.2

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.
Files changed (150) hide show
  1. package/dist/chunk-DQk6qfdC.mjs +18 -0
  2. package/dist/index.d.mts +1173 -0
  3. package/dist/index.mjs +27135 -0
  4. package/package.json +6 -1
  5. package/.agents/skills/moonbit-agent-guide/LICENSE +0 -202
  6. package/.agents/skills/moonbit-agent-guide/SKILL.mbt.md +0 -1126
  7. package/.agents/skills/moonbit-agent-guide/SKILL.md +0 -1126
  8. package/.agents/skills/moonbit-agent-guide/ide.md +0 -116
  9. package/.agents/skills/moonbit-agent-guide/references/advanced-moonbit-build.md +0 -106
  10. package/.agents/skills/moonbit-agent-guide/references/moonbit-language-fundamentals.mbt.md +0 -422
  11. package/.agents/skills/moonbit-agent-guide/references/moonbit-language-fundamentals.md +0 -422
  12. package/.agents/skills/moonbit-practice/SKILL.md +0 -258
  13. package/.agents/skills/moonbit-practice/assets/ci.yaml +0 -25
  14. package/.agents/skills/moonbit-practice/reference/agents.md +0 -1469
  15. package/.agents/skills/moonbit-practice/reference/configuration.md +0 -228
  16. package/.agents/skills/moonbit-practice/reference/ffi.md +0 -229
  17. package/.agents/skills/moonbit-practice/reference/ide.md +0 -189
  18. package/.agents/skills/moonbit-practice/reference/performance.md +0 -217
  19. package/.agents/skills/moonbit-practice/reference/refactor.md +0 -154
  20. package/.agents/skills/moonbit-practice/reference/stdlib.md +0 -351
  21. package/.agents/skills/moonbit-practice/reference/testing.md +0 -228
  22. package/.agents/skills/moonbit-refactoring/LICENSE +0 -21
  23. package/.agents/skills/moonbit-refactoring/SKILL.md +0 -323
  24. package/.githooks/README.md +0 -23
  25. package/.githooks/pre-commit +0 -3
  26. package/.github/workflows/copilot-setup-steps.yml +0 -40
  27. package/.turbo/turbo-typecheck.log +0 -2
  28. package/AGENTS.md +0 -91
  29. package/PLAN.md +0 -64
  30. package/TODO.md +0 -120
  31. package/benchmarks/calc.bench.ts +0 -144
  32. package/benchmarks/draw.bench.ts +0 -215
  33. package/benchmarks/load.bench.ts +0 -28
  34. package/benchmarks/render.bench.ts +0 -53
  35. package/benchmarks/run.bench.ts +0 -8
  36. package/benchmarks/types.d.ts +0 -15
  37. package/docs/scratch-vm-specs/eventloop.md +0 -103
  38. package/docs/scratch-vm-specs/moonscratch-time-separation.md +0 -50
  39. package/index.html +0 -91
  40. package/js/AGENTS.md +0 -5
  41. package/js/a.ts +0 -52
  42. package/js/assets/AGENTS.md +0 -5
  43. package/js/assets/base64.test.ts +0 -14
  44. package/js/assets/base64.ts +0 -21
  45. package/js/assets/build-asset.test.ts +0 -26
  46. package/js/assets/build-asset.ts +0 -28
  47. package/js/assets/create.test.ts +0 -142
  48. package/js/assets/create.ts +0 -122
  49. package/js/assets/index.test.ts +0 -15
  50. package/js/assets/index.ts +0 -2
  51. package/js/assets/types.ts +0 -26
  52. package/js/assets/validation.test.ts +0 -34
  53. package/js/assets/validation.ts +0 -25
  54. package/js/assets.test.ts +0 -14
  55. package/js/assets.ts +0 -1
  56. package/js/index.test.ts +0 -26
  57. package/js/index.ts +0 -3
  58. package/js/render/index.test.ts +0 -65
  59. package/js/render/index.ts +0 -13
  60. package/js/render/sharp.ts +0 -87
  61. package/js/render/svg.ts +0 -68
  62. package/js/render/types.ts +0 -35
  63. package/js/render/utils.ts +0 -108
  64. package/js/render/webgl.ts +0 -274
  65. package/js/sharp-optional.d.ts +0 -16
  66. package/js/test/helpers.ts +0 -116
  67. package/js/test/hikkaku-sample.test.ts +0 -37
  68. package/js/test/rubik-components.input-motion.test.ts +0 -60
  69. package/js/test/rubik-components.lists.test.ts +0 -49
  70. package/js/test/rubik-components.operators.test.ts +0 -104
  71. package/js/test/rubik-components.pen.test.ts +0 -112
  72. package/js/test/rubik-components.procedures-loops.test.ts +0 -72
  73. package/js/test/rubik-components.variables-branches.test.ts +0 -57
  74. package/js/test/rubik-components.visibility-entry.test.ts +0 -31
  75. package/js/test/test-projects.ts +0 -598
  76. package/js/test/variable.ts +0 -200
  77. package/js/test/warp.test.ts +0 -59
  78. package/js/vm/AGENTS.md +0 -6
  79. package/js/vm/README.md +0 -183
  80. package/js/vm/bindings.test.ts +0 -13
  81. package/js/vm/bindings.ts +0 -5
  82. package/js/vm/compare-operators.test.ts +0 -145
  83. package/js/vm/constants.test.ts +0 -11
  84. package/js/vm/constants.ts +0 -4
  85. package/js/vm/effect-guards.test.ts +0 -68
  86. package/js/vm/effect-guards.ts +0 -44
  87. package/js/vm/factory.test.ts +0 -486
  88. package/js/vm/factory.ts +0 -615
  89. package/js/vm/headless-vm.test.ts +0 -131
  90. package/js/vm/headless-vm.ts +0 -342
  91. package/js/vm/index.test.ts +0 -28
  92. package/js/vm/index.ts +0 -5
  93. package/js/vm/internal-types.ts +0 -32
  94. package/js/vm/json.test.ts +0 -40
  95. package/js/vm/json.ts +0 -273
  96. package/js/vm/normalize.test.ts +0 -48
  97. package/js/vm/normalize.ts +0 -65
  98. package/js/vm/options.test.ts +0 -30
  99. package/js/vm/options.ts +0 -55
  100. package/js/vm/pen-transparency.test.ts +0 -115
  101. package/js/vm/program-wasm.ts +0 -322
  102. package/js/vm/scheduler-render.test.ts +0 -401
  103. package/js/vm/scratch-assets.test.ts +0 -136
  104. package/js/vm/scratch-assets.ts +0 -202
  105. package/js/vm/types.ts +0 -358
  106. package/js/vm/value-guards.test.ts +0 -25
  107. package/js/vm/value-guards.ts +0 -18
  108. package/moon.mod.json +0 -10
  109. package/scripts/preinstall.ts +0 -4
  110. package/src/AGENTS.md +0 -6
  111. package/src/api.mbt +0 -161
  112. package/src/api_aot_commands.mbt +0 -184
  113. package/src/api_effects_json.mbt +0 -72
  114. package/src/api_options.mbt +0 -60
  115. package/src/api_program_wasm.mbt +0 -1647
  116. package/src/api_program_wat.mbt +0 -2206
  117. package/src/api_snapshot_json.mbt +0 -44
  118. package/src/cmd/AGENTS.md +0 -5
  119. package/src/cmd/main/AGENTS.md +0 -5
  120. package/src/cmd/main/main.mbt +0 -29
  121. package/src/cmd/main/moon.pkg +0 -7
  122. package/src/cmd/main/pkg.generated.mbti +0 -13
  123. package/src/json_helpers.mbt +0 -176
  124. package/src/moon.pkg +0 -65
  125. package/src/moonscratch.mbt +0 -3
  126. package/src/moonscratch_wbtest.mbt +0 -40
  127. package/src/parser_sb3.mbt +0 -890
  128. package/src/pkg.generated.mbti +0 -479
  129. package/src/runtime_eval.mbt +0 -2844
  130. package/src/runtime_exec.mbt +0 -3850
  131. package/src/runtime_render.mbt +0 -2550
  132. package/src/runtime_state.mbt +0 -870
  133. package/src/test/AGENTS.md +0 -3
  134. package/src/test/projects/AGENTS.md +0 -6
  135. package/src/test/projects/moon.pkg +0 -4
  136. package/src/test/projects/moonscratch_compat_test.mbt +0 -642
  137. package/src/test/projects/moonscratch_core_test.mbt +0 -1332
  138. package/src/test/projects/moonscratch_runtime_test.mbt +0 -1087
  139. package/src/test/projects/pkg.generated.mbti +0 -13
  140. package/src/test/projects/test_support.mbt +0 -35
  141. package/src/types_effects.mbt +0 -20
  142. package/src/types_error.mbt +0 -4
  143. package/src/types_options.mbt +0 -31
  144. package/src/types_runtime_structs.mbt +0 -254
  145. package/src/types_vm.mbt +0 -109
  146. package/tsconfig.json +0 -29
  147. package/viewer/index.ts +0 -399
  148. package/viewer/vite.d.ts +0 -1
  149. package/viewer/worker.ts +0 -161
  150. package/vite.config.ts +0 -11
@@ -0,0 +1,1173 @@
1
+ //#region js/assets/types.d.ts
2
+ interface RgbaAsset {
3
+ width: number;
4
+ height: number;
5
+ rgbaBase64: string;
6
+ }
7
+ type RgbaTuple = readonly [number, number, number, number];
8
+ type RgbaMatrix = ReadonlyArray<ReadonlyArray<RgbaTuple | ReadonlyArray<number>>>;
9
+ interface ImageDataLike {
10
+ width: number;
11
+ height: number;
12
+ data: ArrayLike<number>;
13
+ }
14
+ interface Canvas2DContextLike {
15
+ getImageData(sx: number, sy: number, sw: number, sh: number): ImageDataLike;
16
+ }
17
+ interface CanvasLike {
18
+ width: number;
19
+ height: number;
20
+ getContext(contextId: string, options?: unknown): Canvas2DContextLike | null;
21
+ }
22
+ //#endregion
23
+ //#region js/assets/create.d.ts
24
+ declare const fromRgbaBytes: (width: number, height: number, rgba: ArrayLike<number>) => RgbaAsset;
25
+ declare const fromImageData: (imageData: ImageDataLike) => RgbaAsset;
26
+ declare const fromCanvas: (canvas: CanvasLike) => RgbaAsset;
27
+ declare const fromRgbaMatrix: (pixels: RgbaMatrix) => RgbaAsset;
28
+ declare const fromImageBytes: (bytes: ArrayBuffer | Uint8Array) => Promise<RgbaAsset>;
29
+ declare const fromImageFile: (path: string) => Promise<RgbaAsset>;
30
+ //#endregion
31
+ //#region js/render/types.d.ts
32
+ interface RenderFrame {
33
+ width: number;
34
+ height: number;
35
+ pixels: Uint8Array;
36
+ }
37
+ interface RenderFrameLike {
38
+ width: number;
39
+ height: number;
40
+ pixels: ArrayLike<number>;
41
+ }
42
+ interface RenderImageData {
43
+ width: number;
44
+ height: number;
45
+ data: Uint8ClampedArray;
46
+ }
47
+ interface RenderWithSharpOptions {
48
+ format?: 'png' | 'jpeg' | 'jpg' | 'webp';
49
+ }
50
+ interface RenderWithWebGLOptions {
51
+ canvas?: CanvasLike;
52
+ }
53
+ interface RenderWithWebGLResult {
54
+ canvas: unknown;
55
+ toImageData: () => RenderImageData;
56
+ toImageElement: () => unknown;
57
+ }
58
+ type WebGLRenderResult = RenderWithWebGLResult;
59
+ //#endregion
60
+ //#region js/render/sharp.d.ts
61
+ declare const renderWithSharp: (input: RenderFrame, options?: RenderWithSharpOptions) => Promise<Buffer>;
62
+ //#endregion
63
+ //#region js/render/svg.d.ts
64
+ declare const renderWithSVG: (frame: RenderFrame) => string;
65
+ //#endregion
66
+ //#region js/render/utils.d.ts
67
+ declare const normalizeRenderFrame: (input: RenderFrameLike) => RenderFrame;
68
+ declare const normalizeRenderFrameTrusted: (input: RenderFrameLike) => RenderFrame;
69
+ //#endregion
70
+ //#region js/render/webgl.d.ts
71
+ declare const renderWithWebGL: (input: RenderFrame, options?: RenderWithWebGLOptions) => RenderWithWebGLResult;
72
+ declare namespace moonscratch_d_exports {
73
+ export { _M0FP28nakasyou11moonscratch16vm__abi__version as vm_abi_version, _M0FP28nakasyou11moonscratch13vm__broadcast as vm_broadcast, _M0FP28nakasyou11moonscratch23vm__compile__from__json as vm_compile_from_json, _M0FP28nakasyou11moonscratch30vm__compile__project__to__wasm as vm_compile_project_to_wasm, _M0FP28nakasyou11moonscratch29vm__compile__project__to__wat as vm_compile_project_to_wat, _M0FP28nakasyou11moonscratch22vm__exec__draw__opcode as vm_exec_draw_opcode, _M0FP28nakasyou11moonscratch30vm__exec__opcode__once__by__pc as vm_exec_opcode_once_by_pc, _M0FP28nakasyou11moonscratch30vm__exec__script__tail__by__pc as vm_exec_script_tail_by_pc, _M0FP28nakasyou11moonscratch33vm__get__variable__number__by__id as vm_get_variable_number_by_id, _M0FP28nakasyou11moonscratch15vm__green__flag as vm_green_flag, _M0FP28nakasyou11moonscratch23vm__new__from__compiled as vm_new_from_compiled, _M0FP28nakasyou11moonscratch18vm__post__io__json as vm_post_io_json, _M0FP28nakasyou11moonscratch17vm__render__frame as vm_render_frame, _M0FP28nakasyou11moonscratch28vm__set__aot__commands__json as vm_set_aot_commands_json, _M0FP28nakasyou11moonscratch13vm__set__time as vm_set_time, _M0FP28nakasyou11moonscratch31vm__set__variable__json__by__id as vm_set_variable_json_by_id, _M0FP28nakasyou11moonscratch33vm__set__variable__number__by__id as vm_set_variable_number_by_id, _M0FP28nakasyou11moonscratch18vm__snapshot__json as vm_snapshot_json, _M0FP28nakasyou11moonscratch9vm__start as vm_start, _M0FP28nakasyou11moonscratch15vm__step__frame as vm_step_frame, _M0FP28nakasyou11moonscratch13vm__stop__all as vm_stop_all, _M0FP28nakasyou11moonscratch23vm__take__effects__json as vm_take_effects_json };
74
+ }
75
+ declare function _M0FP28nakasyou11moonscratch16vm__abi__version(): number;
76
+ declare function _M0FP28nakasyou11moonscratch29vm__compile__project__to__wat(project_json: any, assets_json: any): Result$Ok$21$ | Result$Err$21$ | Result$Ok$22$ | Result$Err$22$ | Result$Ok$30$ | Result$Ok$23$ | Result$Err$23$ | Result$Err$5$ | Result$Err$24$ | Result$Ok$27$ | Result$Ok$28$ | Result$Ok$5$ | Result$Ok$26$ | Result$Ok$29$ | Result$Ok$31$ | Result$Ok$34$;
77
+ declare function _M0FP28nakasyou11moonscratch30vm__compile__project__to__wasm(project_json: any, assets_json: any): Result$Ok$21$ | Result$Err$21$ | Result$Ok$22$ | Result$Err$22$ | Result$Ok$30$ | Result$Ok$23$ | Result$Err$23$ | Result$Err$5$ | Result$Err$24$ | Result$Ok$27$ | Result$Ok$28$ | Result$Ok$5$ | Result$Ok$26$ | Result$Ok$29$ | Result$Ok$31$ | Result$Ok$34$;
78
+ declare function _M0FP28nakasyou11moonscratch23vm__compile__from__json(project_json: any, assets_json: any): Result$Ok$21$ | Result$Err$21$ | Result$Ok$22$ | Result$Err$22$ | Result$Ok$30$ | Result$Ok$23$ | Result$Err$23$ | Result$Err$5$ | Result$Err$24$ | Result$Ok$27$ | Result$Ok$28$ | Result$Ok$5$ | Result$Ok$26$ | Result$Ok$29$ | Result$Ok$31$ | Result$Ok$32$;
79
+ declare function _M0FP28nakasyou11moonscratch23vm__new__from__compiled(precompiled: any, options_json: any): Result$Ok$21$ | Result$Err$21$ | Result$Ok$22$ | Result$Err$22$ | Result$Ok$36$ | Result$Ok$41$;
80
+ declare function _M0FP28nakasyou11moonscratch9vm__start(vm: any): void;
81
+ declare function _M0FP28nakasyou11moonscratch15vm__green__flag(vm: any): void;
82
+ declare function _M0FP28nakasyou11moonscratch15vm__step__frame(vm: any): any;
83
+ declare function _M0FP28nakasyou11moonscratch13vm__set__time(vm: any, now_ms: any): void;
84
+ declare function _M0FP28nakasyou11moonscratch18vm__post__io__json(vm: any, device: any, payload_json: any): void;
85
+ declare function _M0FP28nakasyou11moonscratch28vm__set__aot__commands__json(vm: any, commands_json: any): Result$Ok$21$ | Result$Err$21$ | Result$Ok$22$ | Result$Err$22$ | Result$Ok$23$ | Result$Err$23$ | Result$Err$5$ | Result$Ok$5$ | Result$Ok$40$ | Result$Ok$37$ | Result$Ok$38$ | Result$Ok$39$;
86
+ declare function _M0FP28nakasyou11moonscratch33vm__get__variable__number__by__id(vm: any, target_index: any, variable_id: any): any;
87
+ declare function _M0FP28nakasyou11moonscratch33vm__set__variable__number__by__id(vm: any, target_index: any, variable_id: any, value: any): undefined;
88
+ declare function _M0FP28nakasyou11moonscratch31vm__set__variable__json__by__id(vm: any, target_index: any, variable_id: any, value_json: any): undefined;
89
+ declare function _M0FP28nakasyou11moonscratch30vm__exec__script__tail__by__pc(vm: any, target_index: any, start_pc: any): any;
90
+ declare function _M0FP28nakasyou11moonscratch30vm__exec__opcode__once__by__pc(vm: any, target_index: any, pc: any): 1 | 0;
91
+ declare function _M0FP28nakasyou11moonscratch22vm__exec__draw__opcode(vm: any, target_index: any, opcode: any, arg0: any, arg1: any, extra: any): 1 | 0;
92
+ declare function _M0FP28nakasyou11moonscratch13vm__broadcast(vm: any, message: any): void;
93
+ declare function _M0FP28nakasyou11moonscratch13vm__stop__all(vm: any): void;
94
+ declare function _M0FP28nakasyou11moonscratch23vm__take__effects__json(vm: any): string;
95
+ declare function _M0FP28nakasyou11moonscratch18vm__snapshot__json(vm: any): string;
96
+ declare function _M0FP28nakasyou11moonscratch17vm__render__frame(vm: any): {
97
+ width: any;
98
+ height: any;
99
+ pixels: any;
100
+ };
101
+ declare function Result$Ok$21$(param0: any): void;
102
+ declare class Result$Ok$21$ {
103
+ constructor(param0: any);
104
+ _0: any;
105
+ $tag: number;
106
+ }
107
+ declare function Result$Err$21$(param0: any): void;
108
+ declare class Result$Err$21$ {
109
+ constructor(param0: any);
110
+ _0: any;
111
+ $tag: number;
112
+ }
113
+ declare function Result$Ok$22$(param0: any): void;
114
+ declare class Result$Ok$22$ {
115
+ constructor(param0: any);
116
+ _0: any;
117
+ $tag: number;
118
+ }
119
+ declare function Result$Err$22$(param0: any): void;
120
+ declare class Result$Err$22$ {
121
+ constructor(param0: any);
122
+ _0: any;
123
+ $tag: number;
124
+ }
125
+ declare function Result$Ok$30$(param0: any): void;
126
+ declare class Result$Ok$30$ {
127
+ constructor(param0: any);
128
+ _0: any;
129
+ $tag: number;
130
+ }
131
+ declare function Result$Ok$23$(param0: any): void;
132
+ declare class Result$Ok$23$ {
133
+ constructor(param0: any);
134
+ _0: any;
135
+ $tag: number;
136
+ }
137
+ declare function Result$Err$23$(param0: any): void;
138
+ declare class Result$Err$23$ {
139
+ constructor(param0: any);
140
+ _0: any;
141
+ $tag: number;
142
+ }
143
+ declare function Result$Err$5$(param0: any): void;
144
+ declare class Result$Err$5$ {
145
+ constructor(param0: any);
146
+ _0: any;
147
+ $tag: number;
148
+ }
149
+ declare function Result$Err$24$(param0: any): void;
150
+ declare class Result$Err$24$ {
151
+ constructor(param0: any);
152
+ _0: any;
153
+ $tag: number;
154
+ }
155
+ declare function Result$Ok$27$(param0: any): void;
156
+ declare class Result$Ok$27$ {
157
+ constructor(param0: any);
158
+ _0: any;
159
+ $tag: number;
160
+ }
161
+ declare function Result$Ok$28$(param0: any): void;
162
+ declare class Result$Ok$28$ {
163
+ constructor(param0: any);
164
+ _0: any;
165
+ $tag: number;
166
+ }
167
+ declare function Result$Ok$5$(param0: any): void;
168
+ declare class Result$Ok$5$ {
169
+ constructor(param0: any);
170
+ _0: any;
171
+ $tag: number;
172
+ }
173
+ declare function Result$Ok$26$(param0: any): void;
174
+ declare class Result$Ok$26$ {
175
+ constructor(param0: any);
176
+ _0: any;
177
+ $tag: number;
178
+ }
179
+ declare function Result$Ok$29$(param0: any): void;
180
+ declare class Result$Ok$29$ {
181
+ constructor(param0: any);
182
+ _0: any;
183
+ $tag: number;
184
+ }
185
+ declare function Result$Ok$31$(param0: any): void;
186
+ declare class Result$Ok$31$ {
187
+ constructor(param0: any);
188
+ _0: any;
189
+ $tag: number;
190
+ }
191
+ declare function Result$Ok$34$(param0: any): void;
192
+ declare class Result$Ok$34$ {
193
+ constructor(param0: any);
194
+ _0: any;
195
+ $tag: number;
196
+ }
197
+ declare function Result$Ok$32$(param0: any): void;
198
+ declare class Result$Ok$32$ {
199
+ constructor(param0: any);
200
+ _0: any;
201
+ $tag: number;
202
+ }
203
+ declare function Result$Ok$36$(param0: any): void;
204
+ declare class Result$Ok$36$ {
205
+ constructor(param0: any);
206
+ _0: any;
207
+ $tag: number;
208
+ }
209
+ declare function Result$Ok$41$(param0: any): void;
210
+ declare class Result$Ok$41$ {
211
+ constructor(param0: any);
212
+ _0: any;
213
+ $tag: number;
214
+ }
215
+ declare function Result$Ok$40$(param0: any): void;
216
+ declare class Result$Ok$40$ {
217
+ constructor(param0: any);
218
+ _0: any;
219
+ $tag: number;
220
+ }
221
+ declare function Result$Ok$37$(param0: any): void;
222
+ declare class Result$Ok$37$ {
223
+ constructor(param0: any);
224
+ _0: any;
225
+ $tag: number;
226
+ }
227
+ declare function Result$Ok$38$(param0: any): void;
228
+ declare class Result$Ok$38$ {
229
+ constructor(param0: any);
230
+ _0: any;
231
+ $tag: number;
232
+ }
233
+ declare function Result$Ok$39$(param0: any): void;
234
+ declare class Result$Ok$39$ {
235
+ constructor(param0: any);
236
+ _0: any;
237
+ $tag: number;
238
+ }
239
+ //#endregion
240
+ //#region ../../node_modules/.bun/sb3-types@0.1.16+1fb4c65d43e298b9/node_modules/sb3-types/dist/inputtype-CDi9JRHZ.d.mts
241
+ /**
242
+ * @module
243
+ * Shadow type indicating the appearance of the shadow.
244
+ */
245
+ /** unobscured shadow */
246
+ type SameBlockShadow = 1;
247
+ declare const SameBlockShadow: SameBlockShadow;
248
+ /** no shadow */
249
+ type NoShadow = 2;
250
+ declare const NoShadow: NoShadow;
251
+ /** obscured shadow */
252
+ type DiffBlockShadow = 3;
253
+ declare const DiffBlockShadow: DiffBlockShadow;
254
+ /**
255
+ * Shadow type indicating the appearance of the shadow.
256
+ */
257
+ /**
258
+ * @module
259
+ * Primitive type identifiers.
260
+ */
261
+ /** When accepting all numbers */
262
+ type Number = 4;
263
+ declare const Number: Number;
264
+ /** When accepting all positive numbers */
265
+ type PositiveNumber = 5;
266
+ declare const PositiveNumber: PositiveNumber;
267
+ /** When accepting all positive integers */
268
+ type PositiveInteger = 6;
269
+ declare const PositiveInteger: PositiveInteger;
270
+ /** When accepting all integers */
271
+ type Integer = 7;
272
+ declare const Integer: Integer;
273
+ /**
274
+ * A wheel from -180 to 180 is displayed when editing the value.
275
+ */
276
+ type Angle = 8;
277
+ declare const Angle: Angle;
278
+ /**
279
+ * Color picker appears when editing value.
280
+ * @example "#rrggbb"
281
+ */
282
+ type Color = 9;
283
+ declare const Color: Color;
284
+ /** When accepting all strings (and numbers) */
285
+ type String = 10;
286
+ declare const String: String;
287
+ /** It is a message. */
288
+ type Broadcast = 11;
289
+ declare const Broadcast: Broadcast;
290
+ /**
291
+ * It is a round variable block.
292
+ */
293
+ type Variable = 12;
294
+ declare const Variable: Variable;
295
+ /**
296
+ * It is a round list block.
297
+ */
298
+ type List$1 = 13;
299
+ declare const List$1: List$1;
300
+ /** Primitive type identifiers. */
301
+ //#endregion
302
+ //#region ../../node_modules/.bun/sb3-types@0.1.16+1fb4c65d43e298b9/node_modules/sb3-types/dist/mod.d.mts
303
+ //#region primitive.d.ts
304
+ /**
305
+ * Represents a number primitive in Scratch 3.0.
306
+ */
307
+ interface NumPrimitive {
308
+ /** Primitive type identifier. */
309
+ 0: Number | PositiveNumber | PositiveInteger | Integer | Angle;
310
+ /** The value of the number primitive, which can be a string or a number. */
311
+ 1: string | number;
312
+ }
313
+ /**
314
+ * Represents a color primitive in Scratch 3.0.
315
+ */
316
+ interface ColorPrimitive {
317
+ /** Primitive type identifier. */
318
+ 0: Color;
319
+ /** The color value in hex format (e.g., #RRGGBB). */
320
+ 1: `#${string}`;
321
+ }
322
+ /**
323
+ * Represents a text primitive in Scratch 3.0.
324
+ */
325
+ interface TextPrimitive {
326
+ /** Primitive type identifier. */
327
+ 0: String;
328
+ /** The value of the text primitive, which can be a string or a number. */
329
+ 1: string | number;
330
+ }
331
+ /**
332
+ * Represents a broadcast primitive in Scratch 3.0.
333
+ */
334
+ interface BroadcastPrimitive {
335
+ /** Primitive type identifier. */
336
+ 0: Broadcast;
337
+ /** The name of broadcast message. */
338
+ 1: string;
339
+ /** The broadcast message ID. */
340
+ 2: string;
341
+ }
342
+ /**
343
+ * Represents a variable primitive in Scratch 3.0.
344
+ */
345
+ interface VariablePrimitive {
346
+ /** Primitive type identifier. */
347
+ 0: Variable;
348
+ /** The name of the variable. */
349
+ 1: string;
350
+ /** The ID of the variable. */
351
+ 2: string;
352
+ /** x position */
353
+ 3?: number;
354
+ /** y position */
355
+ 4?: number;
356
+ }
357
+ /**
358
+ * Represents a list primitive in Scratch 3.0.
359
+ */
360
+ interface ListPrimitive {
361
+ /** Primitive type identifier. */
362
+ 0: List$1;
363
+ /** The name of the list. */
364
+ 1: string;
365
+ /** The ID of the list. */
366
+ 2: string;
367
+ /** x position */
368
+ 3?: number;
369
+ /** y position */
370
+ 4?: number;
371
+ }
372
+ /**
373
+ * Represents input primitives in Scratch 3.0.
374
+ */
375
+ type InputPrimitive = NumPrimitive | ColorPrimitive | TextPrimitive | BroadcastPrimitive | VariablePrimitive | ListPrimitive;
376
+ /**
377
+ * Top-level primitive block
378
+ */
379
+ type TopLevelPrimitive = VariablePrimitive | ListPrimitive; //#endregion
380
+ //#region mod.d.ts
381
+ /**
382
+ * Scratch 3.0 Project Schema
383
+ */
384
+ interface ScratchProject {
385
+ meta: Meta;
386
+ targets: (Stage | Sprite)[];
387
+ }
388
+ /**
389
+ * Metadata for the Scratch Project
390
+ */
391
+ interface Meta {
392
+ /**
393
+ * Semantic versioning of the project
394
+ * @pattern ^(3\.[0-9]+\.[0-9]+)$
395
+ */
396
+ semver: string;
397
+ /**
398
+ * Version of the Scratch Virtual Machine
399
+ * @pattern ^([0-9]+\.[0-9]+\.[0-9]+)($|-)
400
+ */
401
+ vm?: string;
402
+ /**
403
+ * Agent used for creating the project
404
+ */
405
+ agent?: string;
406
+ /**
407
+ * Origin of the project
408
+ */
409
+ origin?: string;
410
+ }
411
+ /**
412
+ * Stage type, representing the backdrop and stage-specific properties
413
+ */
414
+ interface Stage extends Target {
415
+ /**
416
+ * Name of the stage
417
+ */
418
+ name: 'Stage';
419
+ /**
420
+ * Indicates that this target is a stage
421
+ */
422
+ isStage: true;
423
+ /**
424
+ * Tempo of the stage
425
+ */
426
+ tempo?: number;
427
+ /**
428
+ * Transparency level of the video
429
+ */
430
+ videoTransparency?: number;
431
+ /**
432
+ * State of the video
433
+ */
434
+ videoState?: 'on' | 'off' | 'on-flipped';
435
+ /**
436
+ * Layer order of the stage
437
+ */
438
+ layerOrder?: 0;
439
+ }
440
+ /**
441
+ * Sprite type, representing the individual characters in the project
442
+ */
443
+ interface Sprite extends Target {
444
+ /**
445
+ * Name of the sprite
446
+ * @not "\_stage\_"
447
+ */
448
+ name: string;
449
+ /**
450
+ * Indicates that this target is not a stage
451
+ */
452
+ isStage: false;
453
+ /**
454
+ * Visibility of the sprite
455
+ */
456
+ visible?: boolean;
457
+ /**
458
+ * X position of the sprite
459
+ */
460
+ x?: number;
461
+ /**
462
+ * Y position of the sprite
463
+ */
464
+ y?: number;
465
+ /**
466
+ * Size of the sprite
467
+ */
468
+ size?: number;
469
+ /**
470
+ * Direction the sprite is facing
471
+ */
472
+ direction?: number;
473
+ /**
474
+ * Whether the sprite is draggable
475
+ */
476
+ draggable?: boolean;
477
+ /**
478
+ * Rotation style of the sprite
479
+ */
480
+ rotationStyle?: 'all around' | "don't rotate" | 'left-right';
481
+ /**
482
+ * Layer order of the sprite
483
+ * @minimum 1
484
+ */
485
+ layerOrder?: number;
486
+ }
487
+ /**
488
+ * Common properties for both stages and sprites
489
+ */
490
+ interface Target {
491
+ /**
492
+ * Index of the current costume
493
+ * @minimum 0
494
+ */
495
+ currentCostume: number;
496
+ /**
497
+ * Blocks associated with this target
498
+ */
499
+ blocks: {
500
+ [id: string]: Block | TopLevelPrimitive;
501
+ };
502
+ /**
503
+ * Variables associated with this target
504
+ */
505
+ variables: {
506
+ [id: string]: ScalarVariable;
507
+ };
508
+ /**
509
+ * Lists associated with this target
510
+ */
511
+ lists: {
512
+ [id: string]: List;
513
+ };
514
+ /**
515
+ * Broadcast messages associated with this target
516
+ */
517
+ broadcasts: {
518
+ [id: string]: string;
519
+ };
520
+ /**
521
+ * Comments associated with this target
522
+ */
523
+ comments?: {
524
+ [id: string]: Comment;
525
+ };
526
+ /**
527
+ * Costumes associated with this target
528
+ */
529
+ costumes: Costume[];
530
+ /**
531
+ * Sounds associated with this target
532
+ */
533
+ sounds: Sound[];
534
+ /**
535
+ * Volume of the target
536
+ */
537
+ volume?: number;
538
+ }
539
+ /**
540
+ * Definition for a block
541
+ * @see https://en.scratch-wiki.info/wiki/Scratch_File_Format#Blocks
542
+ */
543
+ interface Block {
544
+ /**
545
+ * A string naming the block.
546
+ */
547
+ opcode: string;
548
+ /**
549
+ * Comment associated with the block
550
+ */
551
+ comment?: string;
552
+ /**
553
+ * An object associating names with arrays representing inputs into which other blocks may be dropped, including C mouths.
554
+ * The first element of each array is 1 if the input is a shadow, 2 if there is no shadow, and 3 if there is a shadow but it is obscured by the input.
555
+ * The second is either the ID of the input or an array representing it as described in the table below.
556
+ * If there is an obscured shadow, the third element is its ID or an array representing it.
557
+ * @related {@link Input}
558
+ */
559
+ inputs?: {
560
+ [id: string]: Input;
561
+ };
562
+ /**
563
+ * Fields are text boxes, drop-down menus, etc.
564
+ * These are used directly in {@link https://en.scratch-wiki.info/wiki/Blocks blocks} where there is an {@link https://en.scratch-wiki.info/wiki/Argument input} into which one cannot drop a {@link https://en.scratch-wiki.info/wiki/Reporter_Block reporter}.
565
+ * However, more often than not, one should be able to do this;
566
+ * in this case no field exists directly in the block, but an input does, and that input may have a shadow block in it.
567
+ * An object associating names with arrays representing fields.
568
+ * The first element of each array is the field's value.
569
+ * For certain fields, such as variable and broadcast dropdown menus, there is also a second element, which is the ID of the field's value.
570
+ * @example ```json
571
+ * { "KEY_OPTION": ["enter", null] }
572
+ * { "VARIABLE": ["variable_name", "variable_id"] }
573
+ * ```
574
+ */
575
+ fields?: {
576
+ [id: string]: Fields;
577
+ };
578
+ /**
579
+ * The ID of the following block or `null`.
580
+ */
581
+ next?: string | null;
582
+ /**
583
+ * False if the block has a parent and true otherwise.
584
+ */
585
+ topLevel?: boolean;
586
+ /**
587
+ * If the block is a {@link https://en.scratch-wiki.info/wiki/Stack_Block stack block} and is preceded, this is the ID of the preceding block.
588
+ * If the block is the first stack block in a {@link https://en.scratch-wiki.info/wiki/C_Block C mouth}, this is the ID of the C block.
589
+ * If the block is an input to another block, this is the ID of that other block.
590
+ * Otherwise it is `null`.
591
+ */
592
+ parent?: string | null;
593
+ /**
594
+ * True if this is a shadow block and false otherwise.
595
+ */
596
+ shadow?: boolean;
597
+ /**
598
+ * X position of the block
599
+ */
600
+ x?: number;
601
+ /**
602
+ * Y position of the block
603
+ */
604
+ y?: number;
605
+ /**
606
+ * Mutation data for the block
607
+ * A special block is used to hold data.
608
+ */
609
+ mutation?: Mutation;
610
+ }
611
+ /**
612
+ * look {@link Block.mutation}
613
+ */
614
+ type Mutation = Mutation_procedures_call | Mutation_procedures_prototype | Mutation_control_stop;
615
+ interface MutationBase {
616
+ /** The tag name, which is always 'mutation'. */
617
+ tagName?: 'mutation';
618
+ /** An array of child elements (typically empty). */
619
+ children?: [];
620
+ }
621
+ interface Mutation_procedures_call extends MutationBase {
622
+ /** The procedure code for custom blocks. */
623
+ proccode?: string;
624
+ argumentids?: string | string[];
625
+ /** Indicates if the procedure is a warp (runs without screen refresh). */
626
+ warp?: 'true' | 'false' | 'null' | boolean | null;
627
+ }
628
+ interface Mutation_procedures_prototype extends MutationBase {
629
+ /**
630
+ * An array of the names of the arguments. This is only present when the block has an opcode of procedures_prototype.
631
+ */
632
+ argumentnames: string | string[];
633
+ /**
634
+ * An array of the defaults of the arguments; for string/number arguments, this is an empty string, and for boolean arguments it is false. This is only present when the block has an opcode of procedures_prototype.
635
+ */
636
+ argumentdefaults: (string | boolean)[];
637
+ }
638
+ interface Mutation_control_stop extends MutationBase {
639
+ /** Indicates if the procedure has a next block. */
640
+ hasnext?: 'true' | 'false' | 'null' | boolean | null;
641
+ }
642
+ /**
643
+ * Definition for a comment
644
+ */
645
+ interface Comment {
646
+ /**
647
+ * ID of the block this comment is attached to
648
+ */
649
+ blockId?: string | null;
650
+ /**
651
+ * Text of the comment
652
+ * @maxLength 8000
653
+ */
654
+ text: string;
655
+ /**
656
+ * Indicates if the comment is minimized
657
+ */
658
+ minimized?: boolean;
659
+ /**
660
+ * X position of the comment
661
+ */
662
+ x?: number | null;
663
+ /**
664
+ * Y position of the comment
665
+ */
666
+ y?: number | null;
667
+ /**
668
+ * Width of the comment
669
+ */
670
+ width?: number;
671
+ /**
672
+ * Height of the comment
673
+ */
674
+ height?: number;
675
+ }
676
+ /**
677
+ * Costume definition
678
+ */
679
+ interface Costume {
680
+ /**
681
+ * Asset ID of the costume
682
+ * @pattern ^[a-fA-F0-9]{32}$
683
+ */
684
+ assetId: string;
685
+ /**
686
+ * Bitmap resolution of the costume
687
+ */
688
+ bitmapResolution?: number;
689
+ /**
690
+ * Data format of the costume
691
+ * @enum ["png", "svg", "jpeg", "jpg", "bmp", "gif"]
692
+ */
693
+ dataFormat: 'png' | 'svg' | 'jpeg' | 'jpg' | 'bmp' | 'gif';
694
+ /**
695
+ * MD5 extension of the costume
696
+ * @pattern ^[a-fA-F0-9]{32}\.[a-zA-Z]+$
697
+ */
698
+ md5ext?: string;
699
+ /**
700
+ * Name of the costume
701
+ */
702
+ name: string;
703
+ /**
704
+ * X coordinate of the costume's rotation center
705
+ */
706
+ rotationCenterX?: number;
707
+ /**
708
+ * Y coordinate of the costume's rotation center
709
+ */
710
+ rotationCenterY?: number;
711
+ }
712
+ /**
713
+ * Sound definition
714
+ */
715
+ interface Sound {
716
+ /**
717
+ * Asset ID of the sound
718
+ * @pattern ^[a-fA-F0-9]{32}$
719
+ */
720
+ assetId: string;
721
+ /**
722
+ * Data format of the sound
723
+ */
724
+ dataFormat: 'wav' | 'wave' | 'mp3';
725
+ /**
726
+ * MD5 extension of the sound
727
+ * @pattern ^[a-fA-F0-9]{32}\.[a-zA-Z0-9]+$
728
+ */
729
+ md5ext?: string;
730
+ /**
731
+ * Name of the sound
732
+ */
733
+ name: string;
734
+ /**
735
+ * Sample rate of the sound
736
+ */
737
+ rate?: number;
738
+ /**
739
+ * Sample count of the sound
740
+ */
741
+ sampleCount?: number;
742
+ }
743
+ /**
744
+ * Represents a scalar value, which can be a string, number, or boolean.
745
+ */
746
+ type ScalarVal = string | number | boolean;
747
+ /**
748
+ * Represents a scalar variable.
749
+ */
750
+ type ScalarVariable = [displayName: string, defaultValue: ScalarVal, isCloudVariable?: boolean];
751
+ /**
752
+ * Represents a list.
753
+ */
754
+ type List = [displayName: string, defaultValue: ScalarVal[]];
755
+ type InputPrimitiveOrReference = InputPrimitive | /* blockId */string;
756
+ /**
757
+ * The input value held by the block
758
+ * @related
759
+ */
760
+ type Input = [SameBlockShadow | NoShadow, InputPrimitiveOrReference] | [DiffBlockShadow, InputPrimitiveOrReference, InputPrimitiveOrReference];
761
+ /**
762
+ * look {@link Block.fields}
763
+ */
764
+ type Fields = [string, null] | [string, string]; //#endregion
765
+ //#endregion
766
+ //#region js/vm/types.d.ts
767
+ type MaybePromise<T> = T | Promise<T>;
768
+ type JsonPrimitive = string | number | boolean | null;
769
+ type JsonValue = JsonPrimitive | {
770
+ [key: string]: JsonValue;
771
+ } | JsonValue[];
772
+ type ProjectJson = JsonValue | ScratchProject;
773
+ interface VMOptions {
774
+ turbo: boolean;
775
+ compatibility30tps: boolean;
776
+ maxClones: number;
777
+ deterministic: boolean;
778
+ seed: number;
779
+ penWidth: number;
780
+ penHeight: number;
781
+ stepTimeoutTicks: number;
782
+ }
783
+ interface VMOptionsInput extends Partial<VMOptions> {
784
+ compatibility_30tps?: boolean;
785
+ max_clones?: number;
786
+ pen_width?: number;
787
+ pen_height?: number;
788
+ step_timeout_ticks?: number;
789
+ stepTimeoutTicks?: number;
790
+ }
791
+ type FrameStopReason = 'finished' | 'timeout' | 'rerender' | 'warp-exit';
792
+ interface FrameReport {
793
+ activeThreads: number;
794
+ ticks: number;
795
+ ops: number;
796
+ emittedEffects: number;
797
+ stopReason: FrameStopReason;
798
+ shouldRender: boolean;
799
+ isInWarp: boolean;
800
+ }
801
+ type RunEndedBy = 'idle' | 'frame_limit';
802
+ interface RunReport {
803
+ frames: number;
804
+ ticks: number;
805
+ ops: number;
806
+ activeThreads: number;
807
+ endedBy: RunEndedBy;
808
+ }
809
+ interface RunUntilIdleOptions {
810
+ maxFrames?: number;
811
+ }
812
+ type VMInputEvent = {
813
+ type: 'answer';
814
+ answer: string;
815
+ } | {
816
+ type: 'mouse';
817
+ x: number;
818
+ y: number;
819
+ isDown?: boolean;
820
+ } | {
821
+ type: 'keys_down';
822
+ keys: string[];
823
+ } | {
824
+ type: 'touching';
825
+ touching: Record<string, string[]>;
826
+ } | {
827
+ type: 'mouse_targets';
828
+ stage?: boolean;
829
+ target?: string;
830
+ targets?: string[];
831
+ } | {
832
+ type: 'backdrop';
833
+ backdrop: string | string[];
834
+ };
835
+ interface VMSnapshotTarget {
836
+ id: string;
837
+ name: string;
838
+ isStage: boolean;
839
+ x: number;
840
+ y: number;
841
+ direction: number;
842
+ size: number;
843
+ volume: number;
844
+ musicInstrument: number;
845
+ textToSpeechVoice: string;
846
+ visible: boolean;
847
+ currentCostume: number;
848
+ variables: Record<string, JsonValue>;
849
+ lists: Record<string, JsonValue[]>;
850
+ }
851
+ interface VMSnapshot {
852
+ runId: number;
853
+ nowMs: number;
854
+ running: boolean;
855
+ answer: string;
856
+ musicTempo: number;
857
+ textToSpeechLanguage: string;
858
+ activeThreads: number;
859
+ targets: VMSnapshotTarget[];
860
+ }
861
+ interface PlaySoundEffect {
862
+ type: 'play_sound';
863
+ target: string;
864
+ sound: string;
865
+ }
866
+ interface MusicPlayNoteEffect {
867
+ type: 'music_play_note';
868
+ target: string;
869
+ note: number;
870
+ beats: number;
871
+ instrument: number;
872
+ tempo: number;
873
+ }
874
+ interface MusicPlayDrumEffect {
875
+ type: 'music_play_drum';
876
+ target: string;
877
+ drum: number;
878
+ beats: number;
879
+ tempo: number;
880
+ }
881
+ interface TextToSpeechEffect {
882
+ type: 'text_to_speech';
883
+ target: string;
884
+ words: string;
885
+ voice: string;
886
+ language: string;
887
+ waitKey: string;
888
+ }
889
+ interface TranslateRequestEffect {
890
+ type: 'translate_request';
891
+ words: string;
892
+ language: string;
893
+ }
894
+ interface StopAllSoundsEffect {
895
+ type: 'stop_all_sounds';
896
+ }
897
+ interface SayEffect {
898
+ type: 'say';
899
+ target: string;
900
+ message: string;
901
+ }
902
+ interface ThinkEffect {
903
+ type: 'think';
904
+ target: string;
905
+ message: string;
906
+ }
907
+ interface AskEffect {
908
+ type: 'ask';
909
+ question: string;
910
+ }
911
+ interface BroadcastEffect {
912
+ type: 'broadcast';
913
+ message: string;
914
+ }
915
+ interface LogEffect {
916
+ type: 'log';
917
+ level: string;
918
+ message: string;
919
+ }
920
+ interface UnknownEffect {
921
+ type: string;
922
+ [key: string]: JsonValue;
923
+ }
924
+ type KnownEffect = PlaySoundEffect | MusicPlayNoteEffect | MusicPlayDrumEffect | TextToSpeechEffect | TranslateRequestEffect | StopAllSoundsEffect | SayEffect | ThinkEffect | AskEffect | BroadcastEffect | LogEffect;
925
+ type VMEffect = KnownEffect | UnknownEffect;
926
+ type TranslateCache = Record<string, Record<string, string>>;
927
+ interface EffectHandlers {
928
+ translate?: (effect: TranslateRequestEffect) => MaybePromise<string | null | undefined>;
929
+ textToSpeech?: (effect: TextToSpeechEffect) => MaybePromise<void>;
930
+ musicNote?: (effect: MusicPlayNoteEffect) => MaybePromise<void>;
931
+ musicDrum?: (effect: MusicPlayDrumEffect) => MaybePromise<void>;
932
+ effect?: (effect: VMEffect) => MaybePromise<void>;
933
+ }
934
+ interface CompileProjectToWatOptions {
935
+ projectJson: string | ProjectJson;
936
+ assets?: string | Record<string, JsonValue>;
937
+ }
938
+ interface ProgramManifest {
939
+ abiVersion: number;
940
+ opcodeSetVersion: number;
941
+ projectByteLength: number;
942
+ assetsByteLength: number;
943
+ buildFingerprint: string;
944
+ }
945
+ interface CompileProjectToWatResult {
946
+ wat: string;
947
+ abiVersion: number;
948
+ manifest: ProgramManifest;
949
+ }
950
+ type ProgramWasmBytes = Uint8Array | ArrayBuffer;
951
+ type WatToWasm = (wat: string) => ProgramWasmBytes;
952
+ interface CompileProjectToWasmOptions extends CompileProjectToWatOptions {
953
+ watToWasm?: WatToWasm;
954
+ }
955
+ interface CompileProjectToWasmResult extends CompileProjectToWatResult {
956
+ wasmBytes: Uint8Array;
957
+ }
958
+ interface RuntimeHandle {
959
+ raw: unknown;
960
+ abiVersion: number;
961
+ }
962
+ interface ProgramPayload {
963
+ projectJson: string;
964
+ assetsJson: string;
965
+ commandsJson?: string;
966
+ }
967
+ interface ProgramWasmExecHost {
968
+ getVarNumber: (targetIndex: number, variableId: string) => number;
969
+ setVarNumber: (targetIndex: number, variableId: string, value: number) => void;
970
+ setVarJson: (targetIndex: number, variableId: string, valueJson: string) => void;
971
+ execHostOpcode: (targetIndex: number, pc: number) => number;
972
+ execHostTail: (targetIndex: number, startPc: number) => number;
973
+ execDrawOpcode: (targetIndex: number, opcode: string, arg0: number, arg1: number, extra: number) => number;
974
+ }
975
+ type ProgramWasmExecRunner = () => number;
976
+ interface ProgramModule {
977
+ raw: WebAssembly.Instance;
978
+ abiVersion: number;
979
+ manifest: ProgramManifest;
980
+ readPayload: () => ProgramPayload;
981
+ hasWasmExec: () => boolean;
982
+ createWasmExecRunner: (host: ProgramWasmExecHost) => ProgramWasmExecRunner | null;
983
+ }
984
+ interface CreateProgramModuleOptions {
985
+ wasmBytes: ProgramWasmBytes;
986
+ manifest?: ProgramManifest;
987
+ }
988
+ interface CreateProgramModuleFromProjectOptions extends CompileProjectToWasmOptions {}
989
+ interface PrecompileProgramForRuntimeOptions {
990
+ program: ProgramModule;
991
+ runtime?: RuntimeHandle;
992
+ }
993
+ interface CreateHeadlessVMOptions {
994
+ program: ProgramModule;
995
+ runtime?: RuntimeHandle;
996
+ options?: string | VMOptionsInput;
997
+ initialNowMs?: number;
998
+ viewerLanguage?: string;
999
+ translateCache?: TranslateCache;
1000
+ }
1001
+ interface CreateHeadlessVMFromProjectOptions extends Omit<CreateHeadlessVMOptions, 'program'>, CreateProgramModuleFromProjectOptions {}
1002
+ interface ScratchAssetResponse {
1003
+ ok: boolean;
1004
+ status: number;
1005
+ statusText: string;
1006
+ arrayBuffer(): Promise<ArrayBuffer>;
1007
+ }
1008
+ type FetchAsset = (url: string) => Promise<ScratchAssetResponse>;
1009
+ type DecodeImageBytes = (bytes: ArrayBuffer | Uint8Array) => Promise<{
1010
+ width: number;
1011
+ height: number;
1012
+ rgbaBase64: string;
1013
+ }>;
1014
+ interface ResolveMissingScratchAssetsOptions {
1015
+ projectJson: string | ProjectJson;
1016
+ assets?: string | Record<string, JsonValue>;
1017
+ scratchCdnBaseUrl?: string;
1018
+ fetchAsset?: FetchAsset;
1019
+ decodeImageBytes?: DecodeImageBytes;
1020
+ }
1021
+ interface CreateHeadlessVMWithScratchAssetsOptions extends Omit<CreateHeadlessVMFromProjectOptions, 'assets'> {
1022
+ projectJson: string | ProjectJson;
1023
+ assets?: string | Record<string, JsonValue>;
1024
+ scratchCdnBaseUrl?: string;
1025
+ fetchAsset?: FetchAsset;
1026
+ decodeImageBytes?: DecodeImageBytes;
1027
+ }
1028
+ //#endregion
1029
+ //#region js/vm/headless-vm.d.ts
1030
+ interface HeadlessVMHooks {
1031
+ afterGreenFlag?: () => void;
1032
+ beforeStepFrame?: () => void;
1033
+ }
1034
+ declare class HeadlessVM {
1035
+ private readonly vmHandle;
1036
+ private readonly hooks;
1037
+ private translateCache;
1038
+ constructor(vmHandle: unknown, hooks?: HeadlessVMHooks);
1039
+ get raw(): unknown;
1040
+ start(): void;
1041
+ greenFlag(): void;
1042
+ stepFrame(): FrameReport;
1043
+ runFrames(frameCount: number): RunReport;
1044
+ runUntilIdle(options?: RunUntilIdleOptions): RunReport;
1045
+ postIO(device: string, payload: JsonValue): void;
1046
+ postIORawJson(device: string, payloadJson: string): void;
1047
+ setAnswer(answer: string): void;
1048
+ setMouseState(input: {
1049
+ x: number;
1050
+ y: number;
1051
+ isDown?: boolean;
1052
+ }): void;
1053
+ setKeysDown(keys: string[]): void;
1054
+ setTouching(touching: Record<string, string[]>): void;
1055
+ setMouseTargets(input: {
1056
+ stage?: boolean;
1057
+ target?: string;
1058
+ targets?: string[];
1059
+ }): void;
1060
+ setBackdrop(backdrop: string | string[]): void;
1061
+ dispatchInputEvents(events: VMInputEvent[]): void;
1062
+ dispatchInputEvent(event: VMInputEvent): void;
1063
+ broadcast(message: string): void;
1064
+ stopAll(): void;
1065
+ setTime(nowMs: number): void;
1066
+ takeEffects(): VMEffect[];
1067
+ snapshot(): VMSnapshot;
1068
+ snapshotJson(): string;
1069
+ renderFrame(): RenderFrame;
1070
+ setViewerLanguage(language: string): void;
1071
+ setTranslateResult(words: string, language: string, translated: string): string;
1072
+ setTranslateCache(cache: TranslateCache): void;
1073
+ clearTranslateCache(): void;
1074
+ ackTextToSpeech(waitKey: string | null | undefined): void;
1075
+ handleEffects(handlers?: EffectHandlers): Promise<VMEffect[]>;
1076
+ private syncTranslateCache;
1077
+ }
1078
+ //#endregion
1079
+ //#region js/vm/factory.d.ts
1080
+ declare const createRuntime: () => RuntimeHandle;
1081
+ declare const compileProjectToWat: ({
1082
+ projectJson,
1083
+ assets
1084
+ }: CompileProjectToWatOptions) => CompileProjectToWatResult;
1085
+ declare const compileProjectToWasm: ({
1086
+ watToWasm,
1087
+ ...rest
1088
+ }: CompileProjectToWasmOptions) => CompileProjectToWasmResult;
1089
+ declare const createProgramModule: ({
1090
+ wasmBytes,
1091
+ manifest
1092
+ }: CreateProgramModuleOptions) => ProgramModule;
1093
+ declare const createProgramModuleFromProject: (options: CreateProgramModuleFromProjectOptions) => ProgramModule;
1094
+ declare const precompileProgramForRuntime: ({
1095
+ program,
1096
+ runtime
1097
+ }: PrecompileProgramForRuntimeOptions) => void;
1098
+ declare const createHeadlessVM: ({
1099
+ runtime,
1100
+ program,
1101
+ options,
1102
+ initialNowMs,
1103
+ viewerLanguage,
1104
+ translateCache
1105
+ }: CreateHeadlessVMOptions) => HeadlessVM;
1106
+ declare const createVM: ({
1107
+ runtime,
1108
+ program,
1109
+ options,
1110
+ initialNowMs,
1111
+ viewerLanguage,
1112
+ translateCache
1113
+ }: CreateHeadlessVMOptions) => HeadlessVM;
1114
+ declare const createHeadlessVMFromProject: ({
1115
+ projectJson,
1116
+ assets,
1117
+ watToWasm,
1118
+ runtime,
1119
+ options,
1120
+ initialNowMs,
1121
+ viewerLanguage,
1122
+ translateCache
1123
+ }: CreateHeadlessVMFromProjectOptions) => HeadlessVM;
1124
+ declare const createVMFromProject: ({
1125
+ projectJson,
1126
+ assets,
1127
+ watToWasm,
1128
+ runtime,
1129
+ options,
1130
+ initialNowMs,
1131
+ viewerLanguage,
1132
+ translateCache
1133
+ }: CreateHeadlessVMFromProjectOptions) => HeadlessVM;
1134
+ declare const createHeadlessVMWithScratchAssets: ({
1135
+ projectJson,
1136
+ assets,
1137
+ scratchCdnBaseUrl,
1138
+ fetchAsset,
1139
+ decodeImageBytes,
1140
+ watToWasm,
1141
+ runtime,
1142
+ options,
1143
+ initialNowMs,
1144
+ viewerLanguage,
1145
+ translateCache
1146
+ }: CreateHeadlessVMWithScratchAssetsOptions) => Promise<HeadlessVM>;
1147
+ declare const createVMWithScratchAssets: ({
1148
+ projectJson,
1149
+ assets,
1150
+ scratchCdnBaseUrl,
1151
+ fetchAsset,
1152
+ decodeImageBytes,
1153
+ watToWasm,
1154
+ runtime,
1155
+ options,
1156
+ initialNowMs,
1157
+ viewerLanguage,
1158
+ translateCache
1159
+ }: CreateHeadlessVMWithScratchAssetsOptions) => Promise<HeadlessVM>;
1160
+ //#endregion
1161
+ //#region js/vm/program-wasm.d.ts
1162
+ declare const instantiateProgramModule: (wasmBytes: ProgramWasmBytes, manifest?: ProgramManifest) => ProgramModule;
1163
+ //#endregion
1164
+ //#region js/vm/scratch-assets.d.ts
1165
+ declare const resolveMissingScratchAssets: ({
1166
+ projectJson,
1167
+ assets,
1168
+ scratchCdnBaseUrl,
1169
+ fetchAsset,
1170
+ decodeImageBytes
1171
+ }: ResolveMissingScratchAssetsOptions) => Promise<Record<string, JsonValue>>;
1172
+ //#endregion
1173
+ export { AskEffect, BroadcastEffect, Canvas2DContextLike, CanvasLike, CompileProjectToWasmOptions, CompileProjectToWasmResult, CompileProjectToWatOptions, CompileProjectToWatResult, CreateHeadlessVMFromProjectOptions, CreateHeadlessVMOptions, CreateHeadlessVMWithScratchAssetsOptions, CreateProgramModuleFromProjectOptions, CreateProgramModuleOptions, DecodeImageBytes, EffectHandlers, FetchAsset, FrameReport, FrameStopReason, HeadlessVM, ImageDataLike, JsonPrimitive, JsonValue, LogEffect, MusicPlayDrumEffect, MusicPlayNoteEffect, PlaySoundEffect, PrecompileProgramForRuntimeOptions, ProgramManifest, ProgramModule, ProgramPayload, ProgramWasmBytes, ProgramWasmExecHost, ProgramWasmExecRunner, ProjectJson, type RenderFrame, type RenderFrameLike, type RenderImageData, type RenderWithSharpOptions, type RenderWithWebGLOptions, RenderWithWebGLResult, ResolveMissingScratchAssetsOptions, RgbaAsset, RgbaMatrix, RgbaTuple, RunEndedBy, RunReport, RunUntilIdleOptions, RuntimeHandle, SayEffect, ScratchAssetResponse, StopAllSoundsEffect, TextToSpeechEffect, ThinkEffect, TranslateCache, TranslateRequestEffect, UnknownEffect, VMEffect, VMInputEvent, VMOptions, VMOptionsInput, VMSnapshot, VMSnapshotTarget, WatToWasm, type WebGLRenderResult, compileProjectToWasm, compileProjectToWat, createHeadlessVM, createHeadlessVMFromProject, createHeadlessVMWithScratchAssets, createProgramModule, createProgramModuleFromProject, createRuntime, createVM, createVMFromProject, createVMWithScratchAssets, fromCanvas, fromImageBytes, fromImageData, fromImageFile, fromRgbaBytes, fromRgbaMatrix, instantiateProgramModule, moonscratch_d_exports as moonscratch, normalizeRenderFrame, normalizeRenderFrameTrusted, precompileProgramForRuntime, renderWithSVG, renderWithSharp, renderWithWebGL, resolveMissingScratchAssets };