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.
Files changed (149) 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/AGENTS.md +0 -91
  28. package/PLAN.md +0 -64
  29. package/TODO.md +0 -120
  30. package/benchmarks/calc.bench.ts +0 -144
  31. package/benchmarks/draw.bench.ts +0 -215
  32. package/benchmarks/load.bench.ts +0 -28
  33. package/benchmarks/render.bench.ts +0 -53
  34. package/benchmarks/run.bench.ts +0 -8
  35. package/benchmarks/types.d.ts +0 -15
  36. package/docs/scratch-vm-specs/eventloop.md +0 -103
  37. package/docs/scratch-vm-specs/moonscratch-time-separation.md +0 -50
  38. package/index.html +0 -91
  39. package/js/AGENTS.md +0 -5
  40. package/js/a.ts +0 -52
  41. package/js/assets/AGENTS.md +0 -5
  42. package/js/assets/base64.test.ts +0 -14
  43. package/js/assets/base64.ts +0 -21
  44. package/js/assets/build-asset.test.ts +0 -26
  45. package/js/assets/build-asset.ts +0 -28
  46. package/js/assets/create.test.ts +0 -142
  47. package/js/assets/create.ts +0 -122
  48. package/js/assets/index.test.ts +0 -15
  49. package/js/assets/index.ts +0 -2
  50. package/js/assets/types.ts +0 -26
  51. package/js/assets/validation.test.ts +0 -34
  52. package/js/assets/validation.ts +0 -25
  53. package/js/assets.test.ts +0 -14
  54. package/js/assets.ts +0 -1
  55. package/js/index.test.ts +0 -26
  56. package/js/index.ts +0 -3
  57. package/js/render/index.test.ts +0 -65
  58. package/js/render/index.ts +0 -13
  59. package/js/render/sharp.ts +0 -87
  60. package/js/render/svg.ts +0 -68
  61. package/js/render/types.ts +0 -35
  62. package/js/render/utils.ts +0 -108
  63. package/js/render/webgl.ts +0 -274
  64. package/js/sharp-optional.d.ts +0 -16
  65. package/js/test/helpers.ts +0 -116
  66. package/js/test/hikkaku-sample.test.ts +0 -37
  67. package/js/test/rubik-components.input-motion.test.ts +0 -60
  68. package/js/test/rubik-components.lists.test.ts +0 -49
  69. package/js/test/rubik-components.operators.test.ts +0 -104
  70. package/js/test/rubik-components.pen.test.ts +0 -112
  71. package/js/test/rubik-components.procedures-loops.test.ts +0 -72
  72. package/js/test/rubik-components.variables-branches.test.ts +0 -57
  73. package/js/test/rubik-components.visibility-entry.test.ts +0 -31
  74. package/js/test/test-projects.ts +0 -598
  75. package/js/test/variable.ts +0 -200
  76. package/js/test/warp.test.ts +0 -59
  77. package/js/vm/AGENTS.md +0 -6
  78. package/js/vm/README.md +0 -183
  79. package/js/vm/bindings.test.ts +0 -13
  80. package/js/vm/bindings.ts +0 -5
  81. package/js/vm/compare-operators.test.ts +0 -145
  82. package/js/vm/constants.test.ts +0 -11
  83. package/js/vm/constants.ts +0 -4
  84. package/js/vm/effect-guards.test.ts +0 -68
  85. package/js/vm/effect-guards.ts +0 -44
  86. package/js/vm/factory.test.ts +0 -486
  87. package/js/vm/factory.ts +0 -615
  88. package/js/vm/headless-vm.test.ts +0 -131
  89. package/js/vm/headless-vm.ts +0 -342
  90. package/js/vm/index.test.ts +0 -28
  91. package/js/vm/index.ts +0 -5
  92. package/js/vm/internal-types.ts +0 -32
  93. package/js/vm/json.test.ts +0 -40
  94. package/js/vm/json.ts +0 -273
  95. package/js/vm/normalize.test.ts +0 -48
  96. package/js/vm/normalize.ts +0 -65
  97. package/js/vm/options.test.ts +0 -30
  98. package/js/vm/options.ts +0 -55
  99. package/js/vm/pen-transparency.test.ts +0 -115
  100. package/js/vm/program-wasm.ts +0 -322
  101. package/js/vm/scheduler-render.test.ts +0 -401
  102. package/js/vm/scratch-assets.test.ts +0 -136
  103. package/js/vm/scratch-assets.ts +0 -202
  104. package/js/vm/types.ts +0 -358
  105. package/js/vm/value-guards.test.ts +0 -25
  106. package/js/vm/value-guards.ts +0 -18
  107. package/moon.mod.json +0 -10
  108. package/scripts/preinstall.ts +0 -4
  109. package/src/AGENTS.md +0 -6
  110. package/src/api.mbt +0 -161
  111. package/src/api_aot_commands.mbt +0 -184
  112. package/src/api_effects_json.mbt +0 -72
  113. package/src/api_options.mbt +0 -60
  114. package/src/api_program_wasm.mbt +0 -1647
  115. package/src/api_program_wat.mbt +0 -2206
  116. package/src/api_snapshot_json.mbt +0 -44
  117. package/src/cmd/AGENTS.md +0 -5
  118. package/src/cmd/main/AGENTS.md +0 -5
  119. package/src/cmd/main/main.mbt +0 -29
  120. package/src/cmd/main/moon.pkg +0 -7
  121. package/src/cmd/main/pkg.generated.mbti +0 -13
  122. package/src/json_helpers.mbt +0 -176
  123. package/src/moon.pkg +0 -65
  124. package/src/moonscratch.mbt +0 -3
  125. package/src/moonscratch_wbtest.mbt +0 -40
  126. package/src/parser_sb3.mbt +0 -890
  127. package/src/pkg.generated.mbti +0 -479
  128. package/src/runtime_eval.mbt +0 -2844
  129. package/src/runtime_exec.mbt +0 -3850
  130. package/src/runtime_render.mbt +0 -2550
  131. package/src/runtime_state.mbt +0 -870
  132. package/src/test/AGENTS.md +0 -3
  133. package/src/test/projects/AGENTS.md +0 -6
  134. package/src/test/projects/moon.pkg +0 -4
  135. package/src/test/projects/moonscratch_compat_test.mbt +0 -642
  136. package/src/test/projects/moonscratch_core_test.mbt +0 -1332
  137. package/src/test/projects/moonscratch_runtime_test.mbt +0 -1087
  138. package/src/test/projects/pkg.generated.mbti +0 -13
  139. package/src/test/projects/test_support.mbt +0 -35
  140. package/src/types_effects.mbt +0 -20
  141. package/src/types_error.mbt +0 -4
  142. package/src/types_options.mbt +0 -31
  143. package/src/types_runtime_structs.mbt +0 -254
  144. package/src/types_vm.mbt +0 -109
  145. package/tsconfig.json +0 -29
  146. package/viewer/index.ts +0 -399
  147. package/viewer/vite.d.ts +0 -1
  148. package/viewer/worker.ts +0 -161
  149. 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
- })