Skip to content

Commit a951249

Browse files
committed
Revert "fix: #129 & #130"
This reverts commit 79018f6.
1 parent 79018f6 commit a951249

11 files changed

Lines changed: 52 additions & 244 deletions

File tree

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
3535

3636
# turbo
3737
.turbo
38-
# temporary files
39-
examples/tmp_*/**
38+

bun.lock

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/hikkaku/src/blocks/control.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fromPrimitiveSource, menuInput } from '../core/block-helper'
1+
import { fromPrimitiveSource } from '../core/block-helper'
22
import { attachStack, block, substack, valueBlock } from '../core/composer'
33
import { Shadow } from '../core/sb3-enum'
44
import type { PrimitiveSource, VariableReference } from '../core/types'
@@ -368,26 +368,14 @@ export const CREATE_CLONE_MYSELF = '_myself_'
368368
* ```ts
369369
* import { createClone } from 'hikkaku/blocks'
370370
*
371-
* createClone('Sprite1')
371+
* createClone('mouse-pointer')
372372
* ```
373373
*/
374-
375374
export const createClone = (target: PrimitiveSource<string>) => {
376375
return block('control_create_clone_of', {
377376
inputs: {
378-
CLONE_OPTION: menuInput(target, menuOfCreateClone),
379-
},
380-
})
381-
}
382-
383-
export const menuOfCreateClone = (
384-
target: (string & {}) | typeof CREATE_CLONE_MYSELF = CREATE_CLONE_MYSELF,
385-
) => {
386-
return valueBlock('control_create_clone_of_menu', {
387-
fields: {
388-
CLONE_OPTION: [target, null],
377+
CLONE_OPTION: fromPrimitiveSource(target),
389378
},
390-
isShadow: true,
391379
})
392380
}
393381

packages/hikkaku/src/blocks/events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export const broadcast = (message: PrimitiveSource<string>) => {
244244
typeof message === 'string'
245245
? ([
246246
Shadow.SameBlockShadow,
247-
[InputType.Broadcast, message, message /* id */],
247+
[InputType.Broadcast, message, message],
248248
] as Input)
249249
: fromPrimitiveSource(message),
250250
},

packages/hikkaku/src/blocks/looks.ts

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
fromPrimitiveSource,
3-
menuInput,
4-
unwrapCostumeSource,
5-
} from '../core/block-helper'
1+
import { fromCostumeSource, fromPrimitiveSource } from '../core/block-helper'
62
import { block, valueBlock } from '../core/composer'
73
import type { CostumeSource, PrimitiveSource } from '../core/types'
84

@@ -175,18 +171,10 @@ export const hide = () => {
175171
export const switchCostumeTo = (costume: CostumeSource) => {
176172
return block('looks_switchcostumeto', {
177173
inputs: {
178-
COSTUME: menuInput(unwrapCostumeSource(costume), menuOfCostume),
174+
COSTUME: fromCostumeSource(costume),
179175
},
180176
})
181177
}
182-
export const menuOfCostume = (costume: string = '') => {
183-
return valueBlock('looks_costume', {
184-
fields: {
185-
COSTUME: [costume, null],
186-
},
187-
isShadow: true,
188-
})
189-
}
190178

191179
/**
192180
* Next costume.
@@ -224,17 +212,8 @@ export const nextCostume = () => {
224212
export const switchBackdropTo = (backdrop: PrimitiveSource<string>) => {
225213
return block('looks_switchbackdropto', {
226214
inputs: {
227-
BACKDROP: menuInput(backdrop, menuOfBackdrop),
228-
},
229-
})
230-
}
231-
232-
export const menuOfBackdrop = (backdrop: string = '') => {
233-
return valueBlock('looks_backdrops', {
234-
fields: {
235-
BACKDROP: [backdrop, null],
215+
BACKDROP: fromPrimitiveSource(backdrop),
236216
},
237-
isShadow: true,
238217
})
239218
}
240219

@@ -256,7 +235,7 @@ export const menuOfBackdrop = (backdrop: string = '') => {
256235
export const switchBackdropToAndWait = (backdrop: PrimitiveSource<string>) => {
257236
return block('looks_switchbackdroptoandwait', {
258237
inputs: {
259-
BACKDROP: menuInput(backdrop, menuOfBackdrop),
238+
BACKDROP: fromPrimitiveSource(backdrop),
260239
},
261240
})
262241
}

packages/hikkaku/src/blocks/motion.ts

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fromPrimitiveSource, menuInput } from '../core/block-helper'
1+
import { fromPrimitiveSource } from '../core/block-helper'
22
import { block, valueBlock } from '../core/composer'
33
import type { PrimitiveSource } from '../core/types'
44

@@ -160,21 +160,11 @@ export const setY = (y: PrimitiveSource<number>) => {
160160
* goTo('mouse-pointer')
161161
* ```
162162
*/
163-
export const goTo = (target: PrimitiveSource<string>) => {
163+
export const goTo = (target: string) => {
164164
return block('motion_goto', {
165-
inputs: {
166-
TO: menuInput(target, menuOfGoTo),
167-
},
168-
})
169-
}
170-
export const GOTO_RANDOM = '_random_'
171-
export const menuOfGoTo = (target: string = GOTO_RANDOM) => {
172-
console.log('menuOfGoTo', target)
173-
return valueBlock('motion_goto_menu', {
174165
fields: {
175166
TO: [target, null],
176167
},
177-
isShadow: true,
178168
})
179169
}
180170

@@ -262,20 +252,11 @@ export const pointInDirection = (direction: PrimitiveSource<number>) => {
262252
* pointTowards('mouse-pointer')
263253
* ```
264254
*/
265-
export const pointTowards = (target: PrimitiveSource<string>) => {
255+
export const pointTowards = (target: string) => {
266256
return block('motion_pointtowards', {
267-
inputs: {
268-
TOWARDS: menuInput(target, menuOfPointTowards),
269-
},
270-
})
271-
}
272-
const TOWARDS_MOUSE_POINTER = '_mouse_'
273-
export const menuOfPointTowards = (target: string = TOWARDS_MOUSE_POINTER) => {
274-
return valueBlock('motion_pointtowards_menu', {
275257
fields: {
276258
TOWARDS: [target, null],
277259
},
278-
isShadow: true,
279260
})
280261
}
281262

@@ -330,17 +311,10 @@ export const glideTo = (seconds: PrimitiveSource<number>, target: string) => {
330311
return block('motion_glideto', {
331312
inputs: {
332313
SECS: fromPrimitiveSource(seconds),
333-
TO: menuInput(target, menuOfGlideTo),
334314
},
335-
})
336-
}
337-
338-
export const menuOfGlideTo = (target: string = GOTO_RANDOM) => {
339-
return valueBlock('motion_glideto_menu', {
340315
fields: {
341-
GLIDETO_MENU: [target, null],
316+
TO: [target, null],
342317
},
343-
isShadow: true,
344318
})
345319
}
346320

packages/hikkaku/src/blocks/pen.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import {
2-
fromPrimitiveSource,
3-
fromPrimitiveSourceColor,
4-
menuInput,
5-
} from '../core/block-helper'
6-
import { block, valueBlock } from '../core/composer'
1+
import { fromPrimitiveSource } from '../core/block-helper'
2+
import { block } from '../core/composer'
73
import type { PrimitiveSource } from '../core/types'
84

95
export type PenColorParam =
@@ -102,7 +98,7 @@ export const penUp = () => {
10298
/**
10399
* Sets pen color.
104100
*
105-
* Input: `color`. like: #ffffff, #fff, or 24-bit number.toString(), This does not accept values like "red" or "green" that CSS accepts.
101+
* Input: `color`.
106102
* Output: Scratch statement block definition that is appended to the current script stack.
107103
*
108104
* @param color See function signature for accepted input values.
@@ -111,13 +107,13 @@ export const penUp = () => {
111107
* ```ts
112108
* import { setPenColorTo } from 'hikkaku/blocks'
113109
*
114-
* setPenColorTo("#ff0000")
110+
* setPenColorTo(undefined as any)
115111
* ```
116112
*/
117-
export const setPenColorTo = (color: PrimitiveSource<`#${string}`>) => {
113+
export const setPenColorTo = (color: PrimitiveSource<string>) => {
118114
return block('pen_setPenColorToColor', {
119115
inputs: {
120-
COLOR: fromPrimitiveSourceColor(color),
116+
COLOR: fromPrimitiveSource(color),
121117
},
122118
})
123119
}
@@ -160,19 +156,11 @@ export const changePenColorParamBy = (
160156
) => {
161157
return block('pen_changePenColorParamBy', {
162158
inputs: {
163-
COLOR_PARAM: menuInput(param, menuOfPenColorParam),
159+
COLOR_PARAM: fromPrimitiveSource(param),
164160
VALUE: fromPrimitiveSource(value),
165161
},
166162
})
167163
}
168-
export const menuOfPenColorParam = (colorParam: PenColorParam = 'color') => {
169-
return valueBlock('pen_menu_colorParam', {
170-
fields: {
171-
colorParam: [colorParam, null],
172-
},
173-
isShadow: true,
174-
})
175-
}
176164

177165
/**
178166
* Sets pen color parameter to value.
@@ -196,7 +184,7 @@ export const setPenColorParamTo = (
196184
) => {
197185
return block('pen_setPenColorParamTo', {
198186
inputs: {
199-
COLOR_PARAM: menuInput(param, menuOfPenColorParam),
187+
COLOR_PARAM: fromPrimitiveSource(param),
200188
VALUE: fromPrimitiveSource(value),
201189
},
202190
})

packages/hikkaku/src/blocks/sensing.ts

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fromPrimitiveSource, menuInput } from '../core/block-helper'
1+
import { fromPrimitiveSource } from '../core/block-helper'
22
import { block, valueBlock } from '../core/composer'
33
import type { PrimitiveSource } from '../core/types'
44

@@ -65,19 +65,11 @@ export type DragMode = 'draggable' | 'not draggable'
6565
export const touchingObject = (target: string) => {
6666
return valueBlock('sensing_touchingobject', {
6767
inputs: {
68-
TOUCHINGOBJECTMENU: menuInput(target, menuOfTouchingObject),
68+
TOUCHINGOBJECTMENU: fromPrimitiveSource(target),
6969
},
7070
})
7171
}
7272

73-
export const menuOfTouchingObject = (target: string = '_mouse_') => {
74-
return valueBlock('sensing_touchingobjectmenu', {
75-
fields: {
76-
TOUCHINGOBJECTMENU: [target, null],
77-
},
78-
isShadow: true,
79-
})
80-
}
8173
/**
8274
* Touching color check.
8375
*
@@ -146,18 +138,9 @@ export const colorTouchingColor = (
146138
*/
147139
export const distanceTo = (target: string) => {
148140
return valueBlock('sensing_distanceto', {
149-
inputs: {
150-
DISTANCETOMENU: menuInput(target, menuOfDistanceTo),
151-
},
152-
})
153-
}
154-
155-
export const menuOfDistanceTo = (target: string = '_mouse_') => {
156-
return valueBlock('sensing_distancetomenu', {
157141
fields: {
158142
DISTANCETOMENU: [target, null],
159143
},
160-
isShadow: true,
161144
})
162145
}
163146

@@ -256,20 +239,11 @@ export const getMouseDown = () => {
256239
export const getKeyPressed = (key: PrimitiveSource<string>) => {
257240
return valueBlock('sensing_keypressed', {
258241
inputs: {
259-
KEY_OPTION: menuInput(key, menuOfKeyOptions),
242+
KEY_OPTION: fromPrimitiveSource(key),
260243
},
261244
})
262245
}
263246

264-
export const menuOfKeyOptions = (key: string = 'space') => {
265-
return valueBlock('sensing_keyoptions', {
266-
fields: {
267-
KEY_OPTION: [key, null],
268-
},
269-
isShadow: true,
270-
})
271-
}
272-
273247
/**
274248
* Current date/time value.
275249
*
@@ -292,6 +266,7 @@ export const current = (menu: CurrentMenu) => {
292266
},
293267
})
294268
}
269+
295270
/**
296271
* Reads target attribute.
297272
*
@@ -312,18 +287,8 @@ export const getAttributeOf = (property: string, target: string) => {
312287
return valueBlock('sensing_of', {
313288
fields: {
314289
PROPERTY: [property, null],
290+
OBJECT: [target, null],
315291
},
316-
inputs: {
317-
OBJECT: menuInput(target, menuOfAttributeObject),
318-
},
319-
})
320-
}
321-
export const menuOfAttributeObject = (object: string = '_stage_') => {
322-
return valueBlock('sensing_of_object_menu', {
323-
fields: {
324-
OBJECT: [object, null],
325-
},
326-
isShadow: true,
327292
})
328293
}
329294

0 commit comments

Comments
 (0)