moonscratch 0.1.0-alpha.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/.agents/skills/moonbit-agent-guide/LICENSE +202 -0
- package/.agents/skills/moonbit-agent-guide/SKILL.mbt.md +1126 -0
- package/.agents/skills/moonbit-agent-guide/SKILL.md +1126 -0
- package/.agents/skills/moonbit-agent-guide/ide.md +116 -0
- package/.agents/skills/moonbit-agent-guide/references/advanced-moonbit-build.md +106 -0
- package/.agents/skills/moonbit-agent-guide/references/moonbit-language-fundamentals.mbt.md +422 -0
- package/.agents/skills/moonbit-agent-guide/references/moonbit-language-fundamentals.md +422 -0
- package/.agents/skills/moonbit-practice/SKILL.md +258 -0
- package/.agents/skills/moonbit-practice/assets/ci.yaml +25 -0
- package/.agents/skills/moonbit-practice/reference/agents.md +1469 -0
- package/.agents/skills/moonbit-practice/reference/configuration.md +228 -0
- package/.agents/skills/moonbit-practice/reference/ffi.md +229 -0
- package/.agents/skills/moonbit-practice/reference/ide.md +189 -0
- package/.agents/skills/moonbit-practice/reference/performance.md +217 -0
- package/.agents/skills/moonbit-practice/reference/refactor.md +154 -0
- package/.agents/skills/moonbit-practice/reference/stdlib.md +351 -0
- package/.agents/skills/moonbit-practice/reference/testing.md +228 -0
- package/.agents/skills/moonbit-refactoring/LICENSE +21 -0
- package/.agents/skills/moonbit-refactoring/SKILL.md +323 -0
- package/.githooks/README.md +23 -0
- package/.githooks/pre-commit +3 -0
- package/.github/workflows/copilot-setup-steps.yml +40 -0
- package/.turbo/turbo-typecheck.log +2 -0
- package/AGENTS.md +91 -0
- package/LICENSE +21 -0
- package/PLAN.md +64 -0
- package/README.mbt.md +77 -0
- package/README.md +84 -0
- package/TODO.md +120 -0
- package/a.png +0 -0
- package/benchmarks/calc.bench.ts +144 -0
- package/benchmarks/draw.bench.ts +215 -0
- package/benchmarks/load.bench.ts +28 -0
- package/benchmarks/render.bench.ts +53 -0
- package/benchmarks/run.bench.ts +8 -0
- package/benchmarks/types.d.ts +15 -0
- package/docs/scratch-vm-specs/eventloop.md +103 -0
- package/docs/scratch-vm-specs/moonscratch-time-separation.md +50 -0
- package/index.html +91 -0
- package/js/AGENTS.md +5 -0
- package/js/a.ts +52 -0
- package/js/assets/AGENTS.md +5 -0
- package/js/assets/base64.test.ts +14 -0
- package/js/assets/base64.ts +21 -0
- package/js/assets/build-asset.test.ts +26 -0
- package/js/assets/build-asset.ts +28 -0
- package/js/assets/create.test.ts +142 -0
- package/js/assets/create.ts +122 -0
- package/js/assets/index.test.ts +15 -0
- package/js/assets/index.ts +2 -0
- package/js/assets/types.ts +26 -0
- package/js/assets/validation.test.ts +34 -0
- package/js/assets/validation.ts +25 -0
- package/js/assets.test.ts +14 -0
- package/js/assets.ts +1 -0
- package/js/index.test.ts +26 -0
- package/js/index.ts +3 -0
- package/js/render/index.test.ts +65 -0
- package/js/render/index.ts +13 -0
- package/js/render/sharp.ts +87 -0
- package/js/render/svg.ts +68 -0
- package/js/render/types.ts +35 -0
- package/js/render/utils.ts +108 -0
- package/js/render/webgl.ts +274 -0
- package/js/sharp-optional.d.ts +16 -0
- package/js/test/helpers.ts +116 -0
- package/js/test/hikkaku-sample.test.ts +37 -0
- package/js/test/rubik-components.input-motion.test.ts +60 -0
- package/js/test/rubik-components.lists.test.ts +49 -0
- package/js/test/rubik-components.operators.test.ts +104 -0
- package/js/test/rubik-components.pen.test.ts +112 -0
- package/js/test/rubik-components.procedures-loops.test.ts +72 -0
- package/js/test/rubik-components.variables-branches.test.ts +57 -0
- package/js/test/rubik-components.visibility-entry.test.ts +31 -0
- package/js/test/test-projects.ts +598 -0
- package/js/test/variable.ts +200 -0
- package/js/test/warp.test.ts +59 -0
- package/js/vm/AGENTS.md +6 -0
- package/js/vm/README.md +183 -0
- package/js/vm/bindings.test.ts +13 -0
- package/js/vm/bindings.ts +5 -0
- package/js/vm/compare-operators.test.ts +145 -0
- package/js/vm/constants.test.ts +11 -0
- package/js/vm/constants.ts +4 -0
- package/js/vm/effect-guards.test.ts +68 -0
- package/js/vm/effect-guards.ts +44 -0
- package/js/vm/factory.test.ts +486 -0
- package/js/vm/factory.ts +615 -0
- package/js/vm/headless-vm.test.ts +131 -0
- package/js/vm/headless-vm.ts +342 -0
- package/js/vm/index.test.ts +28 -0
- package/js/vm/index.ts +5 -0
- package/js/vm/internal-types.ts +32 -0
- package/js/vm/json.test.ts +40 -0
- package/js/vm/json.ts +273 -0
- package/js/vm/normalize.test.ts +48 -0
- package/js/vm/normalize.ts +65 -0
- package/js/vm/options.test.ts +30 -0
- package/js/vm/options.ts +55 -0
- package/js/vm/pen-transparency.test.ts +115 -0
- package/js/vm/program-wasm.ts +322 -0
- package/js/vm/scheduler-render.test.ts +401 -0
- package/js/vm/scratch-assets.test.ts +136 -0
- package/js/vm/scratch-assets.ts +202 -0
- package/js/vm/types.ts +358 -0
- package/js/vm/value-guards.test.ts +25 -0
- package/js/vm/value-guards.ts +18 -0
- package/moon.mod.json +10 -0
- package/package.json +33 -0
- package/scripts/preinstall.ts +4 -0
- package/src/AGENTS.md +6 -0
- package/src/api.mbt +161 -0
- package/src/api_aot_commands.mbt +184 -0
- package/src/api_effects_json.mbt +72 -0
- package/src/api_options.mbt +60 -0
- package/src/api_program_wasm.mbt +1647 -0
- package/src/api_program_wat.mbt +2206 -0
- package/src/api_snapshot_json.mbt +44 -0
- package/src/cmd/AGENTS.md +5 -0
- package/src/cmd/main/AGENTS.md +5 -0
- package/src/cmd/main/main.mbt +29 -0
- package/src/cmd/main/moon.pkg +7 -0
- package/src/cmd/main/pkg.generated.mbti +13 -0
- package/src/json_helpers.mbt +176 -0
- package/src/moon.pkg +65 -0
- package/src/moonscratch.mbt +3 -0
- package/src/moonscratch_wbtest.mbt +40 -0
- package/src/parser_sb3.mbt +890 -0
- package/src/pkg.generated.mbti +479 -0
- package/src/runtime_eval.mbt +2844 -0
- package/src/runtime_exec.mbt +3850 -0
- package/src/runtime_render.mbt +2550 -0
- package/src/runtime_state.mbt +870 -0
- package/src/test/AGENTS.md +3 -0
- package/src/test/projects/AGENTS.md +6 -0
- package/src/test/projects/moon.pkg +4 -0
- package/src/test/projects/moonscratch_compat_test.mbt +642 -0
- package/src/test/projects/moonscratch_core_test.mbt +1332 -0
- package/src/test/projects/moonscratch_runtime_test.mbt +1087 -0
- package/src/test/projects/pkg.generated.mbti +13 -0
- package/src/test/projects/test_support.mbt +35 -0
- package/src/types_effects.mbt +20 -0
- package/src/types_error.mbt +4 -0
- package/src/types_options.mbt +31 -0
- package/src/types_runtime_structs.mbt +254 -0
- package/src/types_vm.mbt +109 -0
- package/tsconfig.json +29 -0
- package/viewer/index.ts +399 -0
- package/viewer/vite.d.ts +1 -0
- package/viewer/worker.ts +161 -0
- package/vite.config.ts +11 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///|
|
|
2
|
+
fn _test_dependency_probe() -> Unit {
|
|
3
|
+
let minimal_project =
|
|
4
|
+
#|{
|
|
5
|
+
#| "targets": [
|
|
6
|
+
#| {
|
|
7
|
+
#| "isStage": true,
|
|
8
|
+
#| "name": "Stage",
|
|
9
|
+
#| "variables": {},
|
|
10
|
+
#| "lists": {},
|
|
11
|
+
#| "blocks": {}
|
|
12
|
+
#| }
|
|
13
|
+
#| ]
|
|
14
|
+
#|}
|
|
15
|
+
ignore(try? @json.parse("null"))
|
|
16
|
+
ignore(try? vm_new_precompiled_from_json(minimal_project))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
///|
|
|
20
|
+
fn vm_new_precompiled_from_json(
|
|
21
|
+
project_json : String,
|
|
22
|
+
assets_json? : String,
|
|
23
|
+
options_json? : String,
|
|
24
|
+
) -> @moonscratch.Vm raise @moonscratch.VmError {
|
|
25
|
+
let precompiled = match assets_json {
|
|
26
|
+
Some(assets_json) =>
|
|
27
|
+
@moonscratch.vm_compile_from_json(project_json, assets_json~)
|
|
28
|
+
None => @moonscratch.vm_compile_from_json(project_json)
|
|
29
|
+
}
|
|
30
|
+
match options_json {
|
|
31
|
+
Some(options_json) =>
|
|
32
|
+
@moonscratch.vm_new_from_compiled(precompiled, options_json~)
|
|
33
|
+
None => @moonscratch.vm_new_from_compiled(precompiled)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
///|
|
|
2
|
+
pub enum HostEffect {
|
|
3
|
+
PlaySound(String, String)
|
|
4
|
+
PlayNote(String, Int, Double, Int, Double)
|
|
5
|
+
PlayDrum(String, Int, Double, Double)
|
|
6
|
+
TextToSpeech(String, String, String, String, String)
|
|
7
|
+
TranslateRequest(String, String)
|
|
8
|
+
StopAllSounds
|
|
9
|
+
Say(String, String)
|
|
10
|
+
Think(String, String)
|
|
11
|
+
Ask(String)
|
|
12
|
+
Broadcast(String)
|
|
13
|
+
Log(String, String)
|
|
14
|
+
} derive(Show, Eq, ToJson)
|
|
15
|
+
|
|
16
|
+
///|
|
|
17
|
+
pub enum ControlFrameKind {
|
|
18
|
+
Repeat
|
|
19
|
+
Forever
|
|
20
|
+
} derive(Show, Eq, ToJson)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
///|
|
|
2
|
+
pub(all) struct ProjectBundle {
|
|
3
|
+
project_json : String
|
|
4
|
+
assets : Map[String, Json]
|
|
5
|
+
} derive(Show, Eq, ToJson)
|
|
6
|
+
|
|
7
|
+
///|
|
|
8
|
+
pub(all) struct VmOptions {
|
|
9
|
+
mut turbo : Bool
|
|
10
|
+
mut compatibility_30tps : Bool
|
|
11
|
+
mut max_clones : Int
|
|
12
|
+
mut deterministic : Bool
|
|
13
|
+
mut seed : Int
|
|
14
|
+
mut pen_width : Int
|
|
15
|
+
mut pen_height : Int
|
|
16
|
+
mut step_timeout_ticks : Int
|
|
17
|
+
} derive(Show, Eq, ToJson)
|
|
18
|
+
|
|
19
|
+
///|
|
|
20
|
+
pub fn default_vm_options() -> VmOptions {
|
|
21
|
+
{
|
|
22
|
+
turbo: false,
|
|
23
|
+
compatibility_30tps: false,
|
|
24
|
+
max_clones: 300,
|
|
25
|
+
deterministic: false,
|
|
26
|
+
seed: 0x1234_5678,
|
|
27
|
+
pen_width: 480,
|
|
28
|
+
pen_height: 360,
|
|
29
|
+
step_timeout_ticks: 2048,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
///|
|
|
2
|
+
pub(all) struct ControlFrame {
|
|
3
|
+
kind : ControlFrameKind
|
|
4
|
+
mut remaining : Int
|
|
5
|
+
substack : Int?
|
|
6
|
+
after : Int?
|
|
7
|
+
} derive(Show, Eq, ToJson)
|
|
8
|
+
|
|
9
|
+
///|
|
|
10
|
+
pub(all) enum OpcodeTag {
|
|
11
|
+
Unknown
|
|
12
|
+
MotionChangeXBy
|
|
13
|
+
MotionChangeYBy
|
|
14
|
+
MotionSetY
|
|
15
|
+
PenPenDown
|
|
16
|
+
PenPenUp
|
|
17
|
+
ControlRepeat
|
|
18
|
+
ControlRepeatUntil
|
|
19
|
+
ControlIf
|
|
20
|
+
DataSetVariableTo
|
|
21
|
+
DataChangeVariableBy
|
|
22
|
+
} derive(Show, Eq, ToJson)
|
|
23
|
+
|
|
24
|
+
///|
|
|
25
|
+
pub(all) struct ScratchBlock {
|
|
26
|
+
id : String
|
|
27
|
+
opcode : String
|
|
28
|
+
opcode_tag : OpcodeTag
|
|
29
|
+
next : String?
|
|
30
|
+
parent : String?
|
|
31
|
+
inputs : Map[String, Json]
|
|
32
|
+
const_number_inputs : Map[String, Double]
|
|
33
|
+
input_block_ids : Map[String, String]
|
|
34
|
+
fields : Map[String, Json]
|
|
35
|
+
mutation : Map[String, Json]
|
|
36
|
+
top_level : Bool
|
|
37
|
+
} derive(Show, Eq, ToJson)
|
|
38
|
+
|
|
39
|
+
///|
|
|
40
|
+
pub(all) struct BlockFieldRef {
|
|
41
|
+
name : String
|
|
42
|
+
id : String?
|
|
43
|
+
} derive(Show, Eq, ToJson)
|
|
44
|
+
|
|
45
|
+
///|
|
|
46
|
+
pub(all) struct BlockFastMeta {
|
|
47
|
+
next_pc : Int?
|
|
48
|
+
substack_pc : Int?
|
|
49
|
+
substack2_pc : Int?
|
|
50
|
+
variable : BlockFieldRef?
|
|
51
|
+
list : BlockFieldRef?
|
|
52
|
+
} derive(Show, Eq, ToJson)
|
|
53
|
+
|
|
54
|
+
///|
|
|
55
|
+
pub(all) enum NumericReporterOp {
|
|
56
|
+
PushConst(Double)
|
|
57
|
+
LoadVariable(String, String)
|
|
58
|
+
LoadVariableByRef(Int, String, Int?)
|
|
59
|
+
Add
|
|
60
|
+
Subtract
|
|
61
|
+
Multiply
|
|
62
|
+
Divide
|
|
63
|
+
Mod
|
|
64
|
+
Round
|
|
65
|
+
MathOp(String)
|
|
66
|
+
LoadXPosition
|
|
67
|
+
LoadYPosition
|
|
68
|
+
LoadDirection
|
|
69
|
+
LoadSize
|
|
70
|
+
LoadVolume
|
|
71
|
+
LoadTempo
|
|
72
|
+
LoadTimer
|
|
73
|
+
LoadMouseX
|
|
74
|
+
LoadMouseY
|
|
75
|
+
LoadControlCounter
|
|
76
|
+
} derive(Show, Eq)
|
|
77
|
+
|
|
78
|
+
///|
|
|
79
|
+
pub(all) struct NumericReporterProgram {
|
|
80
|
+
ops : Array[NumericReporterOp]
|
|
81
|
+
} derive(Show, Eq)
|
|
82
|
+
|
|
83
|
+
///|
|
|
84
|
+
pub(all) struct CompareNumericGuard {
|
|
85
|
+
owner_kind : Int
|
|
86
|
+
variable_id : String
|
|
87
|
+
slot : Int?
|
|
88
|
+
} derive(Show, Eq)
|
|
89
|
+
|
|
90
|
+
///|
|
|
91
|
+
pub(all) enum BoolReporterOp {
|
|
92
|
+
CompareLt(Int, Int, Bool, CompareNumericGuard?, CompareNumericGuard?)
|
|
93
|
+
CompareGt(Int, Int, Bool, CompareNumericGuard?, CompareNumericGuard?)
|
|
94
|
+
CompareEq(Int, Int, Bool, CompareNumericGuard?, CompareNumericGuard?)
|
|
95
|
+
And
|
|
96
|
+
Or
|
|
97
|
+
Not
|
|
98
|
+
} derive(Show, Eq)
|
|
99
|
+
|
|
100
|
+
///|
|
|
101
|
+
pub(all) struct BoolReporterProgram {
|
|
102
|
+
numeric_programs : Array[NumericReporterProgram]
|
|
103
|
+
ops : Array[BoolReporterOp]
|
|
104
|
+
} derive(Show, Eq)
|
|
105
|
+
|
|
106
|
+
///|
|
|
107
|
+
pub(all) struct ProcedureSpec {
|
|
108
|
+
start_block : String
|
|
109
|
+
param_names : Array[String]
|
|
110
|
+
param_ids : Array[String]
|
|
111
|
+
param_defaults : Array[Json]
|
|
112
|
+
warp_mode : Bool
|
|
113
|
+
} derive(Show, Eq)
|
|
114
|
+
|
|
115
|
+
///|
|
|
116
|
+
pub(all) enum PredicateHatKind {
|
|
117
|
+
WhenGreaterThan
|
|
118
|
+
WhenTouchingObject
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
///|
|
|
122
|
+
pub(all) struct KeyPressedHatStart {
|
|
123
|
+
key_option : String
|
|
124
|
+
start_block : String
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
///|
|
|
128
|
+
pub(all) struct BroadcastHatStart {
|
|
129
|
+
message : String
|
|
130
|
+
start_block : String
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
///|
|
|
134
|
+
pub(all) struct BackdropHatStart {
|
|
135
|
+
backdrop_name : String
|
|
136
|
+
start_block : String
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
///|
|
|
140
|
+
pub(all) struct PredicateHatStart {
|
|
141
|
+
kind : PredicateHatKind
|
|
142
|
+
hat_id : String
|
|
143
|
+
menu : String
|
|
144
|
+
start_block : String
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
///|
|
|
148
|
+
pub(all) struct CostumeImage {
|
|
149
|
+
name : String
|
|
150
|
+
asset_id : String
|
|
151
|
+
bitmap_resolution : Int
|
|
152
|
+
rotation_center_x : Double
|
|
153
|
+
rotation_center_y : Double
|
|
154
|
+
width : Int
|
|
155
|
+
height : Int
|
|
156
|
+
pixels : Array[Byte]
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
///|
|
|
160
|
+
pub(all) struct TargetState {
|
|
161
|
+
id : String
|
|
162
|
+
name : String
|
|
163
|
+
is_stage : Bool
|
|
164
|
+
is_original : Bool
|
|
165
|
+
mut deleted : Bool
|
|
166
|
+
mut x : Double
|
|
167
|
+
mut y : Double
|
|
168
|
+
mut direction : Double
|
|
169
|
+
mut size : Double
|
|
170
|
+
mut volume : Double
|
|
171
|
+
mut music_instrument : Int
|
|
172
|
+
mut tts_voice : String
|
|
173
|
+
mut visible : Bool
|
|
174
|
+
mut current_costume : Int
|
|
175
|
+
costume_names : Array[String]
|
|
176
|
+
costumes : Array[CostumeImage]
|
|
177
|
+
mut pen_down : Bool
|
|
178
|
+
mut pen_color : Double
|
|
179
|
+
mut pen_saturation : Double
|
|
180
|
+
mut pen_brightness : Double
|
|
181
|
+
mut pen_transparency : Double
|
|
182
|
+
mut pen_size : Double
|
|
183
|
+
mut pen_legacy_shade : Double
|
|
184
|
+
mut looks_effect_color : Double
|
|
185
|
+
mut looks_effect_fisheye : Double
|
|
186
|
+
mut looks_effect_whirl : Double
|
|
187
|
+
mut looks_effect_pixelate : Double
|
|
188
|
+
mut looks_effect_mosaic : Double
|
|
189
|
+
mut looks_effect_brightness : Double
|
|
190
|
+
mut looks_effect_ghost : Double
|
|
191
|
+
variables : Map[String, Json]
|
|
192
|
+
variable_names : Map[String, String]
|
|
193
|
+
variable_slot_by_id : Map[String, Int]
|
|
194
|
+
variable_slot_by_name : Map[String, Int]
|
|
195
|
+
variable_id_by_slot : Array[String]
|
|
196
|
+
mut variable_values : Array[Json]
|
|
197
|
+
mut variable_numeric_flags : Array[Bool]
|
|
198
|
+
lists : Map[String, Array[Json]]
|
|
199
|
+
list_names : Map[String, String]
|
|
200
|
+
list_slot_by_id : Map[String, Int]
|
|
201
|
+
list_slot_by_name : Map[String, Int]
|
|
202
|
+
list_id_by_slot : Array[String]
|
|
203
|
+
mut list_values : Array[Array[Json]]
|
|
204
|
+
blocks : Map[String, ScratchBlock]
|
|
205
|
+
const_number_block_values : Map[String, Double]
|
|
206
|
+
procedures : Map[String, ProcedureSpec]
|
|
207
|
+
block_pc_by_id : Map[String, Int]
|
|
208
|
+
blocks_by_pc : Array[ScratchBlock]
|
|
209
|
+
block_fast_meta_by_pc : Array[BlockFastMeta]
|
|
210
|
+
mut numeric_program_cache : Map[String, NumericReporterProgram]
|
|
211
|
+
mut numeric_program_compile_failed : Map[String, Bool]
|
|
212
|
+
mut bool_program_cache : Map[String, BoolReporterProgram]
|
|
213
|
+
mut bool_program_compile_failed : Map[String, Bool]
|
|
214
|
+
top_level_hats : Array[String]
|
|
215
|
+
green_flag_starts : Array[String]
|
|
216
|
+
stage_clicked_starts : Array[String]
|
|
217
|
+
sprite_clicked_starts : Array[String]
|
|
218
|
+
clone_start_starts : Array[String]
|
|
219
|
+
key_pressed_hats : Array[KeyPressedHatStart]
|
|
220
|
+
broadcast_hats : Array[BroadcastHatStart]
|
|
221
|
+
backdrop_hats : Array[BackdropHatStart]
|
|
222
|
+
predicate_hats : Array[PredicateHatStart]
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
///|
|
|
226
|
+
pub(all) struct RenderFrame {
|
|
227
|
+
width : Int
|
|
228
|
+
height : Int
|
|
229
|
+
pixels : Array[Byte]
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
///|
|
|
233
|
+
pub(all) struct Thread {
|
|
234
|
+
id : Int
|
|
235
|
+
target_index : Int
|
|
236
|
+
mut pc : Int?
|
|
237
|
+
mut wait_until_ms : Int?
|
|
238
|
+
mut wait_for_input : String?
|
|
239
|
+
mut done : Bool
|
|
240
|
+
mut warp_mode : Bool
|
|
241
|
+
mut warp_started_ms : Int
|
|
242
|
+
mut stack : Array[ControlFrame]
|
|
243
|
+
mut loop_counters : Map[String, Int]
|
|
244
|
+
parent_waiter : Int?
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
///|
|
|
248
|
+
pub(all) struct ProcedureFrame {
|
|
249
|
+
return_pc : Int?
|
|
250
|
+
control_depth : Int
|
|
251
|
+
params : Map[String, Json]
|
|
252
|
+
proccode : String
|
|
253
|
+
mut warp_mode : Bool
|
|
254
|
+
}
|
package/src/types_vm.mbt
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
///|
|
|
2
|
+
pub(all) struct PrecompiledProject {
|
|
3
|
+
targets : Array[TargetState]
|
|
4
|
+
stage_index : Int
|
|
5
|
+
assets : Map[String, Json]
|
|
6
|
+
mut initial_opaque_backdrops : Map[String, Array[Byte]]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
///|
|
|
10
|
+
pub(all) struct PenVectorStroke {
|
|
11
|
+
x0 : Double
|
|
12
|
+
y0 : Double
|
|
13
|
+
x1 : Double
|
|
14
|
+
y1 : Double
|
|
15
|
+
diameter : Double
|
|
16
|
+
offset : Double
|
|
17
|
+
r : Int
|
|
18
|
+
g : Int
|
|
19
|
+
b : Int
|
|
20
|
+
a : Int
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
///|
|
|
24
|
+
pub(all) struct Vm {
|
|
25
|
+
targets : Array[TargetState]
|
|
26
|
+
stage_index : Int
|
|
27
|
+
assets : Map[String, Json]
|
|
28
|
+
options : VmOptions
|
|
29
|
+
pen_width : Int
|
|
30
|
+
pen_height : Int
|
|
31
|
+
mut pen_pixels : Array[Byte]
|
|
32
|
+
mut pen_vectors : Array[PenVectorStroke]
|
|
33
|
+
mut render_revision : Int
|
|
34
|
+
mut render_cache_valid : Bool
|
|
35
|
+
mut render_cache_revision : Int
|
|
36
|
+
mut render_cache_pixels : Array[Byte]
|
|
37
|
+
mut pen_bounds_valid : Bool
|
|
38
|
+
mut pen_min_x : Int
|
|
39
|
+
mut pen_min_y : Int
|
|
40
|
+
mut pen_max_x : Int
|
|
41
|
+
mut pen_max_y : Int
|
|
42
|
+
mut backdrop_cache_valid : Bool
|
|
43
|
+
mut backdrop_cache_pixels : Array[Byte]
|
|
44
|
+
mut backdrop_cache_width : Int
|
|
45
|
+
mut backdrop_cache_height : Int
|
|
46
|
+
mut backdrop_cache_stage_index : Int
|
|
47
|
+
mut backdrop_cache_stage_costume_index : Int
|
|
48
|
+
mut backdrop_cache_effect_color : Double
|
|
49
|
+
mut backdrop_cache_effect_fisheye : Double
|
|
50
|
+
mut backdrop_cache_effect_whirl : Double
|
|
51
|
+
mut backdrop_cache_effect_pixelate : Double
|
|
52
|
+
mut backdrop_cache_effect_mosaic : Double
|
|
53
|
+
mut backdrop_cache_effect_brightness : Double
|
|
54
|
+
mut backdrop_cache_effect_ghost : Double
|
|
55
|
+
mut threads : Array[Thread]
|
|
56
|
+
mut next_thread_id : Int
|
|
57
|
+
mut run_id : Int
|
|
58
|
+
mut now_ms : Int
|
|
59
|
+
mut running : Bool
|
|
60
|
+
mut answer : String
|
|
61
|
+
mut effects : Array[HostEffect]
|
|
62
|
+
mut io_state : Map[String, Json]
|
|
63
|
+
mut io_prev_state : Map[String, Json]
|
|
64
|
+
mut waiting_children : Map[Int, Int]
|
|
65
|
+
mut rng_state : Int
|
|
66
|
+
mut control_counter : Int
|
|
67
|
+
mut hot_op_counts : Map[String, Int]
|
|
68
|
+
mut next_clone_id : Int
|
|
69
|
+
mut hat_predicates : Map[String, Bool]
|
|
70
|
+
mut timer_start_ms : Int
|
|
71
|
+
mut music_tempo : Double
|
|
72
|
+
mut tts_language : String
|
|
73
|
+
mut procedure_frames : Map[Int, Array[ProcedureFrame]]
|
|
74
|
+
mut pending_translate_requests : Map[String, Bool]
|
|
75
|
+
mut redraw_requested : Bool
|
|
76
|
+
mut redraw_requested_while_warp : Bool
|
|
77
|
+
mut current_thread_id : Int?
|
|
78
|
+
mut mathop_sin_cache_valid : Bool
|
|
79
|
+
mut mathop_sin_cache_input : Double
|
|
80
|
+
mut mathop_sin_cache_output : Double
|
|
81
|
+
mut mathop_cos_cache_valid : Bool
|
|
82
|
+
mut mathop_cos_cache_input : Double
|
|
83
|
+
mut mathop_cos_cache_output : Double
|
|
84
|
+
mut aot_commands : Array[AotCommand]
|
|
85
|
+
mut aot_pending : Bool
|
|
86
|
+
mut aot_full_green_flag_starts : Map[Int, Array[Int]]
|
|
87
|
+
mut aot_use_full_exec : Bool
|
|
88
|
+
mut aot_wasm_only : Bool
|
|
89
|
+
mut frame_override : FrameReport?
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
///|
|
|
93
|
+
pub(all) struct FrameReport {
|
|
94
|
+
active_threads : Int
|
|
95
|
+
tick_count : Int
|
|
96
|
+
op_count : Int
|
|
97
|
+
emitted_effects : Int
|
|
98
|
+
stop_reason : String
|
|
99
|
+
should_render : Bool
|
|
100
|
+
is_in_warp : Bool
|
|
101
|
+
} derive(Show, Eq, ToJson)
|
|
102
|
+
|
|
103
|
+
///|
|
|
104
|
+
pub(all) enum AotCommand {
|
|
105
|
+
SetVariable(Int, String, Json)
|
|
106
|
+
ChangeVariable(Int, String, Double)
|
|
107
|
+
HostOpcode(Int, Int)
|
|
108
|
+
HostTail(Int, Int)
|
|
109
|
+
} derive(Show, Eq, ToJson)
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Environment setup & latest features
|
|
4
|
+
"lib": ["ESNext", "DOM"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "Preserve",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
|
|
11
|
+
// Bundler mode
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"verbatimModuleSyntax": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
// Best practices
|
|
18
|
+
"strict": true,
|
|
19
|
+
"skipLibCheck": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"noUncheckedIndexedAccess": true,
|
|
22
|
+
"noImplicitOverride": true,
|
|
23
|
+
|
|
24
|
+
// Some stricter flags (disabled by default)
|
|
25
|
+
"noUnusedLocals": false,
|
|
26
|
+
"noUnusedParameters": false,
|
|
27
|
+
"noPropertyAccessFromIndexSignature": false
|
|
28
|
+
}
|
|
29
|
+
}
|