moonscratch 0.1.1 → 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.
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/index.d.mts +1173 -0
- package/dist/index.mjs +27135 -0
- package/package.json +6 -1
- package/.agents/skills/moonbit-agent-guide/LICENSE +0 -202
- package/.agents/skills/moonbit-agent-guide/SKILL.mbt.md +0 -1126
- package/.agents/skills/moonbit-agent-guide/SKILL.md +0 -1126
- package/.agents/skills/moonbit-agent-guide/ide.md +0 -116
- package/.agents/skills/moonbit-agent-guide/references/advanced-moonbit-build.md +0 -106
- package/.agents/skills/moonbit-agent-guide/references/moonbit-language-fundamentals.mbt.md +0 -422
- package/.agents/skills/moonbit-agent-guide/references/moonbit-language-fundamentals.md +0 -422
- package/.agents/skills/moonbit-practice/SKILL.md +0 -258
- package/.agents/skills/moonbit-practice/assets/ci.yaml +0 -25
- package/.agents/skills/moonbit-practice/reference/agents.md +0 -1469
- package/.agents/skills/moonbit-practice/reference/configuration.md +0 -228
- package/.agents/skills/moonbit-practice/reference/ffi.md +0 -229
- package/.agents/skills/moonbit-practice/reference/ide.md +0 -189
- package/.agents/skills/moonbit-practice/reference/performance.md +0 -217
- package/.agents/skills/moonbit-practice/reference/refactor.md +0 -154
- package/.agents/skills/moonbit-practice/reference/stdlib.md +0 -351
- package/.agents/skills/moonbit-practice/reference/testing.md +0 -228
- package/.agents/skills/moonbit-refactoring/LICENSE +0 -21
- package/.agents/skills/moonbit-refactoring/SKILL.md +0 -323
- package/.githooks/README.md +0 -23
- package/.githooks/pre-commit +0 -3
- package/.github/workflows/copilot-setup-steps.yml +0 -40
- package/AGENTS.md +0 -91
- package/PLAN.md +0 -64
- package/TODO.md +0 -120
- package/benchmarks/calc.bench.ts +0 -144
- package/benchmarks/draw.bench.ts +0 -215
- package/benchmarks/load.bench.ts +0 -28
- package/benchmarks/render.bench.ts +0 -53
- package/benchmarks/run.bench.ts +0 -8
- package/benchmarks/types.d.ts +0 -15
- package/docs/scratch-vm-specs/eventloop.md +0 -103
- package/docs/scratch-vm-specs/moonscratch-time-separation.md +0 -50
- package/index.html +0 -91
- package/js/AGENTS.md +0 -5
- package/js/a.ts +0 -52
- package/js/assets/AGENTS.md +0 -5
- package/js/assets/base64.test.ts +0 -14
- package/js/assets/base64.ts +0 -21
- package/js/assets/build-asset.test.ts +0 -26
- package/js/assets/build-asset.ts +0 -28
- package/js/assets/create.test.ts +0 -142
- package/js/assets/create.ts +0 -122
- package/js/assets/index.test.ts +0 -15
- package/js/assets/index.ts +0 -2
- package/js/assets/types.ts +0 -26
- package/js/assets/validation.test.ts +0 -34
- package/js/assets/validation.ts +0 -25
- package/js/assets.test.ts +0 -14
- package/js/assets.ts +0 -1
- package/js/index.test.ts +0 -26
- package/js/index.ts +0 -3
- package/js/render/index.test.ts +0 -65
- package/js/render/index.ts +0 -13
- package/js/render/sharp.ts +0 -87
- package/js/render/svg.ts +0 -68
- package/js/render/types.ts +0 -35
- package/js/render/utils.ts +0 -108
- package/js/render/webgl.ts +0 -274
- package/js/sharp-optional.d.ts +0 -16
- package/js/test/helpers.ts +0 -116
- package/js/test/hikkaku-sample.test.ts +0 -37
- package/js/test/rubik-components.input-motion.test.ts +0 -60
- package/js/test/rubik-components.lists.test.ts +0 -49
- package/js/test/rubik-components.operators.test.ts +0 -104
- package/js/test/rubik-components.pen.test.ts +0 -112
- package/js/test/rubik-components.procedures-loops.test.ts +0 -72
- package/js/test/rubik-components.variables-branches.test.ts +0 -57
- package/js/test/rubik-components.visibility-entry.test.ts +0 -31
- package/js/test/test-projects.ts +0 -598
- package/js/test/variable.ts +0 -200
- package/js/test/warp.test.ts +0 -59
- package/js/vm/AGENTS.md +0 -6
- package/js/vm/README.md +0 -183
- package/js/vm/bindings.test.ts +0 -13
- package/js/vm/bindings.ts +0 -5
- package/js/vm/compare-operators.test.ts +0 -145
- package/js/vm/constants.test.ts +0 -11
- package/js/vm/constants.ts +0 -4
- package/js/vm/effect-guards.test.ts +0 -68
- package/js/vm/effect-guards.ts +0 -44
- package/js/vm/factory.test.ts +0 -486
- package/js/vm/factory.ts +0 -615
- package/js/vm/headless-vm.test.ts +0 -131
- package/js/vm/headless-vm.ts +0 -342
- package/js/vm/index.test.ts +0 -28
- package/js/vm/index.ts +0 -5
- package/js/vm/internal-types.ts +0 -32
- package/js/vm/json.test.ts +0 -40
- package/js/vm/json.ts +0 -273
- package/js/vm/normalize.test.ts +0 -48
- package/js/vm/normalize.ts +0 -65
- package/js/vm/options.test.ts +0 -30
- package/js/vm/options.ts +0 -55
- package/js/vm/pen-transparency.test.ts +0 -115
- package/js/vm/program-wasm.ts +0 -322
- package/js/vm/scheduler-render.test.ts +0 -401
- package/js/vm/scratch-assets.test.ts +0 -136
- package/js/vm/scratch-assets.ts +0 -202
- package/js/vm/types.ts +0 -358
- package/js/vm/value-guards.test.ts +0 -25
- package/js/vm/value-guards.ts +0 -18
- package/moon.mod.json +0 -10
- package/scripts/preinstall.ts +0 -4
- package/src/AGENTS.md +0 -6
- package/src/api.mbt +0 -161
- package/src/api_aot_commands.mbt +0 -184
- package/src/api_effects_json.mbt +0 -72
- package/src/api_options.mbt +0 -60
- package/src/api_program_wasm.mbt +0 -1647
- package/src/api_program_wat.mbt +0 -2206
- package/src/api_snapshot_json.mbt +0 -44
- package/src/cmd/AGENTS.md +0 -5
- package/src/cmd/main/AGENTS.md +0 -5
- package/src/cmd/main/main.mbt +0 -29
- package/src/cmd/main/moon.pkg +0 -7
- package/src/cmd/main/pkg.generated.mbti +0 -13
- package/src/json_helpers.mbt +0 -176
- package/src/moon.pkg +0 -65
- package/src/moonscratch.mbt +0 -3
- package/src/moonscratch_wbtest.mbt +0 -40
- package/src/parser_sb3.mbt +0 -890
- package/src/pkg.generated.mbti +0 -479
- package/src/runtime_eval.mbt +0 -2844
- package/src/runtime_exec.mbt +0 -3850
- package/src/runtime_render.mbt +0 -2550
- package/src/runtime_state.mbt +0 -870
- package/src/test/AGENTS.md +0 -3
- package/src/test/projects/AGENTS.md +0 -6
- package/src/test/projects/moon.pkg +0 -4
- package/src/test/projects/moonscratch_compat_test.mbt +0 -642
- package/src/test/projects/moonscratch_core_test.mbt +0 -1332
- package/src/test/projects/moonscratch_runtime_test.mbt +0 -1087
- package/src/test/projects/pkg.generated.mbti +0 -13
- package/src/test/projects/test_support.mbt +0 -35
- package/src/types_effects.mbt +0 -20
- package/src/types_error.mbt +0 -4
- package/src/types_options.mbt +0 -31
- package/src/types_runtime_structs.mbt +0 -254
- package/src/types_vm.mbt +0 -109
- package/tsconfig.json +0 -29
- package/viewer/index.ts +0 -399
- package/viewer/vite.d.ts +0 -1
- package/viewer/worker.ts +0 -161
- package/vite.config.ts +0 -61
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { Project } from 'hikkaku'
|
|
2
|
-
import {
|
|
3
|
-
clear,
|
|
4
|
-
gotoXY,
|
|
5
|
-
penDown,
|
|
6
|
-
penUp,
|
|
7
|
-
setPenColorParamTo,
|
|
8
|
-
setPenColorToColor,
|
|
9
|
-
setPenSizeTo,
|
|
10
|
-
setVariableTo,
|
|
11
|
-
whenFlagClicked,
|
|
12
|
-
} from 'hikkaku/blocks'
|
|
13
|
-
import { describe, expect, test } from 'vite-plus/test'
|
|
14
|
-
import {
|
|
15
|
-
createVmFromProject,
|
|
16
|
-
getStageVariable,
|
|
17
|
-
hasApproxColor,
|
|
18
|
-
runUntilFinished,
|
|
19
|
-
} from './helpers.ts'
|
|
20
|
-
|
|
21
|
-
describe('rubik components: pen primitives', () => {
|
|
22
|
-
test('applies pen size/color/clear sequence before final draw', () => {
|
|
23
|
-
const project = new Project()
|
|
24
|
-
const sprite = project.createSprite('pen-sprite')
|
|
25
|
-
const done = project.stage.createVariable('done', 0)
|
|
26
|
-
|
|
27
|
-
sprite.run(() => {
|
|
28
|
-
whenFlagClicked(() => {
|
|
29
|
-
clear()
|
|
30
|
-
setPenColorToColor('#ff0000')
|
|
31
|
-
setPenSizeTo(8)
|
|
32
|
-
penDown()
|
|
33
|
-
gotoXY(-80, 0)
|
|
34
|
-
gotoXY(80, 0)
|
|
35
|
-
penUp()
|
|
36
|
-
|
|
37
|
-
clear()
|
|
38
|
-
setPenColorToColor('#0000ff')
|
|
39
|
-
setPenColorParamTo('transparency', 0)
|
|
40
|
-
setPenSizeTo(6)
|
|
41
|
-
penDown()
|
|
42
|
-
gotoXY(-40, -40)
|
|
43
|
-
gotoXY(40, -40)
|
|
44
|
-
penUp()
|
|
45
|
-
|
|
46
|
-
setVariableTo(done, 1)
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
const vm = createVmFromProject(project)
|
|
51
|
-
vm.greenFlag()
|
|
52
|
-
runUntilFinished(vm)
|
|
53
|
-
|
|
54
|
-
expect(getStageVariable(vm, done.id)).toBe(1)
|
|
55
|
-
|
|
56
|
-
const frame = vm.renderFrame()
|
|
57
|
-
expect(hasApproxColor(frame, [0, 0, 255], 36, 80)).toBe(true)
|
|
58
|
-
expect(hasApproxColor(frame, [255, 0, 0], 36, 80)).toBe(false)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
test('applies transparency once per stroke without over-darkening', () => {
|
|
62
|
-
const project = new Project()
|
|
63
|
-
const sprite = project.createSprite('pen-sprite')
|
|
64
|
-
const done = project.stage.createVariable('done', 0)
|
|
65
|
-
|
|
66
|
-
sprite.run(() => {
|
|
67
|
-
whenFlagClicked(() => {
|
|
68
|
-
clear()
|
|
69
|
-
setPenSizeTo(6)
|
|
70
|
-
|
|
71
|
-
setPenColorToColor('#ff0000')
|
|
72
|
-
setPenColorParamTo('transparency', 0)
|
|
73
|
-
penDown()
|
|
74
|
-
gotoXY(-100, 0)
|
|
75
|
-
gotoXY(100, 0)
|
|
76
|
-
penUp()
|
|
77
|
-
|
|
78
|
-
setPenColorToColor('#0000ff')
|
|
79
|
-
setPenColorParamTo('transparency', 70)
|
|
80
|
-
penDown()
|
|
81
|
-
gotoXY(-100, 0)
|
|
82
|
-
gotoXY(100, 0)
|
|
83
|
-
penUp()
|
|
84
|
-
|
|
85
|
-
setVariableTo(done, 1)
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
const vm = createVmFromProject(project)
|
|
90
|
-
vm.greenFlag()
|
|
91
|
-
runUntilFinished(vm)
|
|
92
|
-
|
|
93
|
-
expect(getStageVariable(vm, done.id)).toBe(1)
|
|
94
|
-
|
|
95
|
-
const frame = vm.renderFrame()
|
|
96
|
-
const centerX = Math.floor(frame.width / 2)
|
|
97
|
-
const centerY = Math.floor(frame.height / 2)
|
|
98
|
-
const base = (centerY * frame.width + centerX) * 4
|
|
99
|
-
const r = frame.pixels[base] ?? 0
|
|
100
|
-
const g = frame.pixels[base + 1] ?? 0
|
|
101
|
-
const b = frame.pixels[base + 2] ?? 0
|
|
102
|
-
const a = frame.pixels[base + 3] ?? 0
|
|
103
|
-
|
|
104
|
-
expect(a).toBe(255)
|
|
105
|
-
expect(g).toBeLessThan(16)
|
|
106
|
-
expect(r).toBeGreaterThan(70)
|
|
107
|
-
expect(b).toBeGreaterThan(70)
|
|
108
|
-
expect(r).toBeLessThan(220)
|
|
109
|
-
expect(b).toBeLessThan(220)
|
|
110
|
-
expect(Math.abs(r - b)).toBeLessThan(90)
|
|
111
|
-
})
|
|
112
|
-
})
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Project } from 'hikkaku'
|
|
2
|
-
import {
|
|
3
|
-
callProcedure,
|
|
4
|
-
changeVariableBy,
|
|
5
|
-
defineProcedure,
|
|
6
|
-
forEach,
|
|
7
|
-
forever,
|
|
8
|
-
procedureLabel,
|
|
9
|
-
repeat,
|
|
10
|
-
setVariableTo,
|
|
11
|
-
whenFlagClicked,
|
|
12
|
-
} from 'hikkaku/blocks'
|
|
13
|
-
import { describe, expect, test } from 'vite-plus/test'
|
|
14
|
-
import {
|
|
15
|
-
createVmFromProject,
|
|
16
|
-
getStageTarget,
|
|
17
|
-
getStageVariable,
|
|
18
|
-
stepMany,
|
|
19
|
-
} from './helpers.ts'
|
|
20
|
-
|
|
21
|
-
describe('rubik components: procedures and loops', () => {
|
|
22
|
-
test('runs repeat/forEach/procedure while forever script stays active', () => {
|
|
23
|
-
const project = new Project()
|
|
24
|
-
const index = project.stage.createVariable('index', 0)
|
|
25
|
-
const sum = project.stage.createVariable('sum', 0)
|
|
26
|
-
const done = project.stage.createVariable('done', 0)
|
|
27
|
-
const foreverTicks = project.stage.createVariable('foreverTicks', 0)
|
|
28
|
-
|
|
29
|
-
project.stage.run(() => {
|
|
30
|
-
const bump = defineProcedure(
|
|
31
|
-
[procedureLabel('bump')],
|
|
32
|
-
() => {
|
|
33
|
-
changeVariableBy(sum, 5)
|
|
34
|
-
return undefined
|
|
35
|
-
},
|
|
36
|
-
true,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
whenFlagClicked(() => {
|
|
40
|
-
setVariableTo(sum, 0)
|
|
41
|
-
repeat(3, () => {
|
|
42
|
-
changeVariableBy(sum, 2)
|
|
43
|
-
})
|
|
44
|
-
forEach(index, 4, () => {
|
|
45
|
-
changeVariableBy(sum, 1)
|
|
46
|
-
})
|
|
47
|
-
callProcedure(bump, [])
|
|
48
|
-
callProcedure(bump, [])
|
|
49
|
-
setVariableTo(done, 1)
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
project.stage.run(() => {
|
|
54
|
-
whenFlagClicked(() => {
|
|
55
|
-
forever(() => {
|
|
56
|
-
changeVariableBy(foreverTicks, 1)
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
const vm = createVmFromProject(project)
|
|
62
|
-
vm.greenFlag()
|
|
63
|
-
stepMany(vm, 24)
|
|
64
|
-
|
|
65
|
-
expect(getStageVariable(vm, sum.id)).toBe(20)
|
|
66
|
-
expect(getStageVariable(vm, index.id)).toBe(4)
|
|
67
|
-
expect(getStageVariable(vm, done.id)).toBe(1)
|
|
68
|
-
expect(Number(getStageVariable(vm, foreverTicks.id))).toBeGreaterThan(0)
|
|
69
|
-
expect(getStageTarget(vm).isStage).toBe(true)
|
|
70
|
-
expect(vm.snapshot().activeThreads).toBeGreaterThan(0)
|
|
71
|
-
})
|
|
72
|
-
})
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Project } from 'hikkaku'
|
|
2
|
-
import {
|
|
3
|
-
changeVariableBy,
|
|
4
|
-
equals,
|
|
5
|
-
gt,
|
|
6
|
-
ifElse,
|
|
7
|
-
ifThen,
|
|
8
|
-
lt,
|
|
9
|
-
setVariableTo,
|
|
10
|
-
whenFlagClicked,
|
|
11
|
-
} from 'hikkaku/blocks'
|
|
12
|
-
import { describe, expect, test } from 'vite-plus/test'
|
|
13
|
-
import {
|
|
14
|
-
createVmFromProject,
|
|
15
|
-
getStageVariable,
|
|
16
|
-
runUntilFinished,
|
|
17
|
-
} from './helpers.ts'
|
|
18
|
-
|
|
19
|
-
describe('rubik components: variables and branches', () => {
|
|
20
|
-
test('executes control_if/control_if_else with variable writes', () => {
|
|
21
|
-
const project = new Project()
|
|
22
|
-
const score = project.stage.createVariable('score', 0)
|
|
23
|
-
const branch = project.stage.createVariable('branch', 0)
|
|
24
|
-
|
|
25
|
-
project.stage.run(() => {
|
|
26
|
-
whenFlagClicked(() => {
|
|
27
|
-
setVariableTo(score, 1)
|
|
28
|
-
changeVariableBy(score, 2)
|
|
29
|
-
|
|
30
|
-
ifElse(
|
|
31
|
-
lt(1, 2),
|
|
32
|
-
() => {
|
|
33
|
-
changeVariableBy(branch, 1)
|
|
34
|
-
},
|
|
35
|
-
() => {
|
|
36
|
-
changeVariableBy(branch, 100)
|
|
37
|
-
},
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
ifThen(equals(score.get(), '3'), () => {
|
|
41
|
-
changeVariableBy(branch, 2)
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
ifThen(gt(score.get(), 2), () => {
|
|
45
|
-
changeVariableBy(branch, 4)
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
const vm = createVmFromProject(project)
|
|
51
|
-
vm.greenFlag()
|
|
52
|
-
runUntilFinished(vm)
|
|
53
|
-
|
|
54
|
-
expect(getStageVariable(vm, score.id)).toBe(3)
|
|
55
|
-
expect(getStageVariable(vm, branch.id)).toBe(7)
|
|
56
|
-
})
|
|
57
|
-
})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Project } from 'hikkaku'
|
|
2
|
-
import { hide, setVariableTo, whenFlagClicked } from 'hikkaku/blocks'
|
|
3
|
-
import { describe, expect, test } from 'vite-plus/test'
|
|
4
|
-
import {
|
|
5
|
-
createVmFromProject,
|
|
6
|
-
getStageVariable,
|
|
7
|
-
getTargetByName,
|
|
8
|
-
runUntilFinished,
|
|
9
|
-
} from './helpers.ts'
|
|
10
|
-
|
|
11
|
-
describe('rubik components: visibility and entry', () => {
|
|
12
|
-
test('runs whenFlagClicked and applies looks_hide', () => {
|
|
13
|
-
const project = new Project()
|
|
14
|
-
const sprite = project.createSprite('hidden-sprite')
|
|
15
|
-
const entered = project.stage.createVariable('entered', 0)
|
|
16
|
-
|
|
17
|
-
sprite.run(() => {
|
|
18
|
-
whenFlagClicked(() => {
|
|
19
|
-
hide()
|
|
20
|
-
setVariableTo(entered, 1)
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const vm = createVmFromProject(project)
|
|
25
|
-
vm.greenFlag()
|
|
26
|
-
runUntilFinished(vm)
|
|
27
|
-
|
|
28
|
-
expect(getStageVariable(vm, entered.id)).toBe(1)
|
|
29
|
-
expect(getTargetByName(vm, 'hidden-sprite').visible).toBe(false)
|
|
30
|
-
})
|
|
31
|
-
})
|