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
@@ -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
- })