hikkaku 0.3.0 → 0.3.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/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  [![NPM Version](https://img.shields.io/npm/v/hikkaku)](https://www.npmjs.com/package/hikkaku)
6
6
 
7
+ [Docs](https://pnsk-lab.github.io/hikkaku/) | [Playground](https://pnsk-lab.github.io/playground/)
8
+
7
9
  Scratch with TypeScript.
8
10
 
9
11
  ## Installation
@@ -18,7 +20,7 @@ npm install hikkaku # npm
18
20
 
19
21
  ## Scaffold with create-hikkaku
20
22
 
21
- Generate a new project from the official template (`examples/base`):
23
+ Generate a new project from the official template (`templates/base`):
22
24
 
23
25
  ```bash
24
26
  npx create-hikkaku@latest my-hikkaku-app
@@ -141,13 +143,16 @@ https://github.com/user-attachments/assets/1ff5d190-f8ee-46c4-bc78-8dbdf2879e15
141
143
  Hikkaku has a skills for AI Agents, so you can vibe code with AI such as Codex, Claude Code, OpenCode and etc.
142
144
 
143
145
  ```bash
144
- bunx skills add pnsk-lab/hikkaku # Bun
145
- deno run -NRWE --allow-run="git" --allow-sys="homedir" npm:skills add pnsk-lab/hikkaku # Deno
146
- pnpx skills add pnsk-lab/hikkaku # pnpm
147
- yarn dlx skills add pnsk-lab/hikkaku # Yarn
148
- npx skills add pnsk-lab/hikkaku # npm
146
+ bunx skills add pnsk-lab/hikkaku/packages/skill # Bun
147
+ deno run -NRWE --allow-run="git" --allow-sys="homedir" npm:skills add pnsk-lab/hikkaku/packages/skill # Deno
148
+ pnpx skills add pnsk-lab/hikkaku/packages/skill # pnpm
149
+ yarn dlx skills add pnsk-lab/hikkaku/packages/skill # Yarn
150
+ npx skills add pnsk-lab/hikkaku/packages/skill # npm
149
151
  ```
150
152
 
151
153
  ### Build project
152
154
 
153
- Not support yet. To get .sb3 file, you need to download the project file using dev server, or manually convert JSON to .sb3 using external tools.
155
+ With Vite Plugin:
156
+ ```ts
157
+ vite build
158
+ ```
@@ -1,4 +1,4 @@
1
- import { D as SoundSource, M as VariableReference, g as CostumeSource, w as PrimitiveSource, x as ListReference, y as HikkakuBlock } from "../project-djJPtrq7.mjs";
1
+ import { E as ListReference, L as VariableReference, M as SoundSource, k as PrimitiveSource, w as HikkakuBlock, x as CostumeSource } from "../project-CpV5Dm-X.mjs";
2
2
 
3
3
  //#region src/blocks/control.d.ts
4
4
  type StopOption = 'all' | 'this script' | 'other scripts in sprite' | 'other scripts in stage';
@@ -67,7 +67,7 @@ declare const repeatWhile: (condition: PrimitiveSource<boolean>, handler: () =>
67
67
  * ```ts
68
68
  * import { forEach } from 'hikkaku/blocks'
69
69
  *
70
- * forEach(variable as any, 10, () => {})
70
+ * forEach(variable, 10, () => {})
71
71
  * ```
72
72
  */
73
73
  declare const forEach: (variable: VariableReference, value: PrimitiveSource<number>, handler: () => void) => HikkakuBlock;
@@ -212,10 +212,11 @@ declare const CREATE_CLONE_MYSELF = "_myself_";
212
212
  * ```ts
213
213
  * import { createClone } from 'hikkaku/blocks'
214
214
  *
215
- * createClone('mouse-pointer')
215
+ * createClone('Sprite1')
216
216
  * ```
217
217
  */
218
218
  declare const createClone: (target: PrimitiveSource<string>) => HikkakuBlock;
219
+ declare const menuOfCreateClone: (target?: (string & {}) | typeof CREATE_CLONE_MYSELF) => HikkakuBlock;
219
220
  /**
220
221
  * Deletes the current clone.
221
222
  *
@@ -323,7 +324,7 @@ type ListIndex = PrimitiveSource<number | string>;
323
324
  * ```ts
324
325
  * import { getVariable } from 'hikkaku/blocks'
325
326
  *
326
- * getVariable(variable as any)
327
+ * getVariable(variable)
327
328
  * ```
328
329
  */
329
330
  declare const getVariable: (variable: VariableReference) => HikkakuBlock;
@@ -340,7 +341,7 @@ declare const getVariable: (variable: VariableReference) => HikkakuBlock;
340
341
  * ```ts
341
342
  * import { setVariableTo } from 'hikkaku/blocks'
342
343
  *
343
- * setVariableTo(variable as any, 10)
344
+ * setVariableTo(variable, 10)
344
345
  * ```
345
346
  */
346
347
  declare const setVariableTo: (variable: VariableReference, value: PrimitiveSource<number | string>) => HikkakuBlock;
@@ -357,7 +358,7 @@ declare const setVariableTo: (variable: VariableReference, value: PrimitiveSourc
357
358
  * ```ts
358
359
  * import { changeVariableBy } from 'hikkaku/blocks'
359
360
  *
360
- * changeVariableBy(variable as any, 10)
361
+ * changeVariableBy(variable, 10)
361
362
  * ```
362
363
  */
363
364
  declare const changeVariableBy: (variable: VariableReference, value: PrimitiveSource<number>) => HikkakuBlock;
@@ -373,7 +374,7 @@ declare const changeVariableBy: (variable: VariableReference, value: PrimitiveSo
373
374
  * ```ts
374
375
  * import { showVariable } from 'hikkaku/blocks'
375
376
  *
376
- * showVariable(variable as any)
377
+ * showVariable(variable)
377
378
  * ```
378
379
  */
379
380
  declare const showVariable: (variable: VariableReference) => HikkakuBlock;
@@ -389,7 +390,7 @@ declare const showVariable: (variable: VariableReference) => HikkakuBlock;
389
390
  * ```ts
390
391
  * import { hideVariable } from 'hikkaku/blocks'
391
392
  *
392
- * hideVariable(variable as any)
393
+ * hideVariable(variable)
393
394
  * ```
394
395
  */
395
396
  declare const hideVariable: (variable: VariableReference) => HikkakuBlock;
@@ -405,7 +406,7 @@ declare const hideVariable: (variable: VariableReference) => HikkakuBlock;
405
406
  * ```ts
406
407
  * import { getListContents } from 'hikkaku/blocks'
407
408
  *
408
- * getListContents(list as any)
409
+ * getListContents(list)
409
410
  * ```
410
411
  */
411
412
  declare const getListContents: (list: ListReference) => HikkakuBlock;
@@ -422,7 +423,7 @@ declare const getListContents: (list: ListReference) => HikkakuBlock;
422
423
  * ```ts
423
424
  * import { addToList } from 'hikkaku/blocks'
424
425
  *
425
- * addToList(list as any, undefined as any)
426
+ * addToList(list, "banana")
426
427
  * ```
427
428
  */
428
429
  declare const addToList: (list: ListReference, item: PrimitiveSource<string | number>) => HikkakuBlock;
@@ -439,7 +440,7 @@ declare const addToList: (list: ListReference, item: PrimitiveSource<string | nu
439
440
  * ```ts
440
441
  * import { deleteOfList } from 'hikkaku/blocks'
441
442
  *
442
- * deleteOfList(list as any, undefined as any)
443
+ * deleteOfList(list, 1)
443
444
  * ```
444
445
  */
445
446
  declare const deleteOfList: (list: ListReference, index: ListIndex) => HikkakuBlock;
@@ -455,7 +456,7 @@ declare const deleteOfList: (list: ListReference, index: ListIndex) => HikkakuBl
455
456
  * ```ts
456
457
  * import { deleteAllOfList } from 'hikkaku/blocks'
457
458
  *
458
- * deleteAllOfList(list as any)
459
+ * deleteAllOfList(list)
459
460
  * ```
460
461
  */
461
462
  declare const deleteAllOfList: (list: ListReference) => HikkakuBlock;
@@ -473,7 +474,7 @@ declare const deleteAllOfList: (list: ListReference) => HikkakuBlock;
473
474
  * ```ts
474
475
  * import { insertAtList } from 'hikkaku/blocks'
475
476
  *
476
- * insertAtList(list as any, undefined as any, undefined as any)
477
+ * insertAtList(list, 42, "banana")
477
478
  * ```
478
479
  */
479
480
  declare const insertAtList: (list: ListReference, index: ListIndex, item: PrimitiveSource<string | number>) => HikkakuBlock;
@@ -491,7 +492,7 @@ declare const insertAtList: (list: ListReference, index: ListIndex, item: Primit
491
492
  * ```ts
492
493
  * import { replaceItemOfList } from 'hikkaku/blocks'
493
494
  *
494
- * replaceItemOfList(list as any, undefined as any, undefined as any)
495
+ * replaceItemOfList(list, 42, "banana")
495
496
  * ```
496
497
  */
497
498
  declare const replaceItemOfList: (list: ListReference, index: ListIndex, item: PrimitiveSource<string | number>) => HikkakuBlock;
@@ -508,7 +509,7 @@ declare const replaceItemOfList: (list: ListReference, index: ListIndex, item: P
508
509
  * ```ts
509
510
  * import { getItemOfList } from 'hikkaku/blocks'
510
511
  *
511
- * getItemOfList(list as any, undefined as any)
512
+ * getItemOfList(list, 1)
512
513
  * ```
513
514
  */
514
515
  declare const getItemOfList: (list: ListReference, index: ListIndex) => HikkakuBlock;
@@ -525,7 +526,7 @@ declare const getItemOfList: (list: ListReference, index: ListIndex) => HikkakuB
525
526
  * ```ts
526
527
  * import { getItemNumOfList } from 'hikkaku/blocks'
527
528
  *
528
- * getItemNumOfList(list as any, undefined as any)
529
+ * getItemNumOfList(list, "banana")
529
530
  * ```
530
531
  */
531
532
  declare const getItemNumOfList: (list: ListReference, item: PrimitiveSource<string | number>) => HikkakuBlock;
@@ -541,7 +542,7 @@ declare const getItemNumOfList: (list: ListReference, item: PrimitiveSource<stri
541
542
  * ```ts
542
543
  * import { lengthOfList } from 'hikkaku/blocks'
543
544
  *
544
- * lengthOfList(list as any)
545
+ * lengthOfList(list)
545
546
  * ```
546
547
  */
547
548
  declare const lengthOfList: (list: ListReference) => HikkakuBlock;
@@ -558,7 +559,7 @@ declare const lengthOfList: (list: ListReference) => HikkakuBlock;
558
559
  * ```ts
559
560
  * import { listContainsItem } from 'hikkaku/blocks'
560
561
  *
561
- * listContainsItem(list as any, undefined as any)
562
+ * listContainsItem(list,"banana")
562
563
  * ```
563
564
  */
564
565
  declare const listContainsItem: (list: ListReference, item: PrimitiveSource<string | number>) => HikkakuBlock;
@@ -574,7 +575,7 @@ declare const listContainsItem: (list: ListReference, item: PrimitiveSource<stri
574
575
  * ```ts
575
576
  * import { showList } from 'hikkaku/blocks'
576
577
  *
577
- * showList(list as any)
578
+ * showList(list)
578
579
  * ```
579
580
  */
580
581
  declare const showList: (list: ListReference) => HikkakuBlock;
@@ -590,7 +591,7 @@ declare const showList: (list: ListReference) => HikkakuBlock;
590
591
  * ```ts
591
592
  * import { hideList } from 'hikkaku/blocks'
592
593
  *
593
- * hideList(list as any)
594
+ * hideList(list)
594
595
  * ```
595
596
  */
596
597
  declare const hideList: (list: ListReference) => HikkakuBlock;
@@ -880,6 +881,7 @@ declare const hide: () => HikkakuBlock;
880
881
  * ```
881
882
  */
882
883
  declare const switchCostumeTo: (costume: CostumeSource) => HikkakuBlock;
884
+ declare const menuOfCostume: (costume?: string) => HikkakuBlock;
883
885
  /**
884
886
  * Next costume.
885
887
  *
@@ -911,6 +913,7 @@ declare const nextCostume: () => HikkakuBlock;
911
913
  * ```
912
914
  */
913
915
  declare const switchBackdropTo: (backdrop: PrimitiveSource<string>) => HikkakuBlock;
916
+ declare const menuOfBackdrop: (backdrop?: string) => HikkakuBlock;
914
917
  /**
915
918
  * Switch backdrop and wait.
916
919
  *
@@ -1117,7 +1120,7 @@ declare const getBackdropNumberName: (value: NumberName) => HikkakuBlock;
1117
1120
  * ```ts
1118
1121
  * import { moveSteps } from 'hikkaku/blocks'
1119
1122
  *
1120
- * moveSteps(undefined as any)
1123
+ * moveSteps(10)
1121
1124
  * ```
1122
1125
  */
1123
1126
  declare const moveSteps: (steps: PrimitiveSource<number>) => HikkakuBlock;
@@ -1217,7 +1220,9 @@ declare const setY: (y: PrimitiveSource<number>) => HikkakuBlock;
1217
1220
  * goTo('mouse-pointer')
1218
1221
  * ```
1219
1222
  */
1220
- declare const goTo: (target: string) => HikkakuBlock;
1223
+ declare const goTo: (target: PrimitiveSource<string>) => HikkakuBlock;
1224
+ declare const GOTO_RANDOM = "_random_";
1225
+ declare const menuOfGoTo: (target?: string) => HikkakuBlock;
1221
1226
  /**
1222
1227
  * Turns right.
1223
1228
  *
@@ -1281,7 +1286,8 @@ declare const pointInDirection: (direction: PrimitiveSource<number>) => HikkakuB
1281
1286
  * pointTowards('mouse-pointer')
1282
1287
  * ```
1283
1288
  */
1284
- declare const pointTowards: (target: string) => HikkakuBlock;
1289
+ declare const pointTowards: (target: PrimitiveSource<string>) => HikkakuBlock;
1290
+ declare const menuOfPointTowards: (target?: string) => HikkakuBlock;
1285
1291
  /**
1286
1292
  * Glides to position.
1287
1293
  *
@@ -1316,7 +1322,8 @@ declare const glide: (seconds: PrimitiveSource<number>, x: PrimitiveSource<numbe
1316
1322
  * glideTo(10, 'mouse-pointer')
1317
1323
  * ```
1318
1324
  */
1319
- declare const glideTo: (seconds: PrimitiveSource<number>, target: string) => HikkakuBlock;
1325
+ declare const glideTo: (seconds: PrimitiveSource<number>, target: PrimitiveSource<string>) => HikkakuBlock;
1326
+ declare const menuOfGlideTo: (target?: string) => HikkakuBlock;
1320
1327
  /**
1321
1328
  * Bounces on edge.
1322
1329
  *
@@ -1927,7 +1934,7 @@ declare const penUp: () => HikkakuBlock;
1927
1934
  /**
1928
1935
  * Sets pen color.
1929
1936
  *
1930
- * Input: `color`.
1937
+ * Input: `color`. like: #ffffff, #fff. This does not accept values like "red" or "green" that CSS accepts.
1931
1938
  * Output: Scratch statement block definition that is appended to the current script stack.
1932
1939
  *
1933
1940
  * @param color See function signature for accepted input values.
@@ -1936,10 +1943,10 @@ declare const penUp: () => HikkakuBlock;
1936
1943
  * ```ts
1937
1944
  * import { setPenColorTo } from 'hikkaku/blocks'
1938
1945
  *
1939
- * setPenColorTo(undefined as any)
1946
+ * setPenColorTo("#ff0000")
1940
1947
  * ```
1941
1948
  */
1942
- declare const setPenColorTo: (color: PrimitiveSource<string>) => HikkakuBlock;
1949
+ declare const setPenColorTo: (color: PrimitiveSource<`#${string}` | (string & {})>) => HikkakuBlock;
1943
1950
  /**
1944
1951
  * Alias for {@link setPenColorTo}.
1945
1952
  *
@@ -1954,7 +1961,7 @@ declare const setPenColorTo: (color: PrimitiveSource<string>) => HikkakuBlock;
1954
1961
  * setPenColorToColor('#ff0000')
1955
1962
  * ```
1956
1963
  */
1957
- declare const setPenColorToColor: (color: PrimitiveSource<string>) => HikkakuBlock;
1964
+ declare const setPenColorToColor: (color: PrimitiveSource<`#${string}` | (string & {})>) => HikkakuBlock;
1958
1965
  /**
1959
1966
  * Changes pen color parameter by amount.
1960
1967
  *
@@ -1968,10 +1975,11 @@ declare const setPenColorToColor: (color: PrimitiveSource<string>) => HikkakuBlo
1968
1975
  * ```ts
1969
1976
  * import { changePenColorParamBy } from 'hikkaku/blocks'
1970
1977
  *
1971
- * changePenColorParamBy(undefined as any, 10)
1978
+ * changePenColorParamBy('color', 10)
1972
1979
  * ```
1973
1980
  */
1974
1981
  declare const changePenColorParamBy: (param: PrimitiveSource<PenColorParam>, value: PrimitiveSource<number>) => HikkakuBlock;
1982
+ declare const menuOfPenColorParam: (colorParam?: PenColorParam) => HikkakuBlock;
1975
1983
  /**
1976
1984
  * Sets pen color parameter to value.
1977
1985
  *
@@ -1985,7 +1993,7 @@ declare const changePenColorParamBy: (param: PrimitiveSource<PenColorParam>, val
1985
1993
  * ```ts
1986
1994
  * import { setPenColorParamTo } from 'hikkaku/blocks'
1987
1995
  *
1988
- * setPenColorParamTo(undefined as any, 10)
1996
+ * setPenColorParamTo('color', 10)
1989
1997
  * ```
1990
1998
  */
1991
1999
  declare const setPenColorParamTo: (param: PrimitiveSource<PenColorParam>, value: PrimitiveSource<number>) => HikkakuBlock;
@@ -2307,6 +2315,7 @@ type DragMode = 'draggable' | 'not draggable';
2307
2315
  * ```
2308
2316
  */
2309
2317
  declare const touchingObject: (target: string) => HikkakuBlock;
2318
+ declare const menuOfTouchingObject: (target?: string) => HikkakuBlock;
2310
2319
  /**
2311
2320
  * Touching color check.
2312
2321
  *
@@ -2319,10 +2328,10 @@ declare const touchingObject: (target: string) => HikkakuBlock;
2319
2328
  * ```ts
2320
2329
  * import { touchingColor } from 'hikkaku/blocks'
2321
2330
  *
2322
- * touchingColor(undefined as any)
2331
+ * touchingColor("#ff0000")
2323
2332
  * ```
2324
2333
  */
2325
- declare const touchingColor: (color: PrimitiveSource<string>) => HikkakuBlock;
2334
+ declare const touchingColor: (color: PrimitiveSource<`#${string}`>) => HikkakuBlock;
2326
2335
  /**
2327
2336
  * Color overlap check.
2328
2337
  *
@@ -2336,10 +2345,10 @@ declare const touchingColor: (color: PrimitiveSource<string>) => HikkakuBlock;
2336
2345
  * ```ts
2337
2346
  * import { colorTouchingColor } from 'hikkaku/blocks'
2338
2347
  *
2339
- * colorTouchingColor(undefined as any, undefined as any)
2348
+ * colorTouchingColor("#ff0000", "#00ff00")
2340
2349
  * ```
2341
2350
  */
2342
- declare const colorTouchingColor: (color: PrimitiveSource<string>, targetColor: PrimitiveSource<string>) => HikkakuBlock;
2351
+ declare const colorTouchingColor: (color: PrimitiveSource<`#${string}`>, targetColor: PrimitiveSource<`#${string}`>) => HikkakuBlock;
2343
2352
  /**
2344
2353
  * Distance to target.
2345
2354
  *
@@ -2356,6 +2365,7 @@ declare const colorTouchingColor: (color: PrimitiveSource<string>, targetColor:
2356
2365
  * ```
2357
2366
  */
2358
2367
  declare const distanceTo: (target: string) => HikkakuBlock;
2368
+ declare const menuOfDistanceTo: (target?: string) => HikkakuBlock;
2359
2369
  /**
2360
2370
  * Timer value.
2361
2371
  *
@@ -2433,6 +2443,7 @@ declare const getMouseDown: () => HikkakuBlock;
2433
2443
  * ```
2434
2444
  */
2435
2445
  declare const getKeyPressed: (key: PrimitiveSource<string>) => HikkakuBlock;
2446
+ declare const menuOfKeyOptions: (key?: string) => HikkakuBlock;
2436
2447
  /**
2437
2448
  * Current date/time value.
2438
2449
  *
@@ -2462,10 +2473,11 @@ declare const current: (menu: CurrentMenu) => HikkakuBlock;
2462
2473
  * ```ts
2463
2474
  * import { getAttributeOf } from 'hikkaku/blocks'
2464
2475
  *
2465
- * getAttributeOf(undefined as any, 'mouse-pointer')
2476
+ * getAttributeOf('x position', 'cat')
2466
2477
  * ```
2467
2478
  */
2468
2479
  declare const getAttributeOf: (property: string, target: string) => HikkakuBlock;
2480
+ declare const menuOfAttributeObject: (object?: string) => HikkakuBlock;
2469
2481
  /**
2470
2482
  * Days since 2000-01-01.
2471
2483
  *
@@ -2609,6 +2621,7 @@ declare const playSound: (sound: SoundSource) => HikkakuBlock;
2609
2621
  * ```
2610
2622
  */
2611
2623
  declare const playSoundUntilDone: (sound: SoundSource) => HikkakuBlock;
2624
+ declare const menuOfSounds: (sound?: string) => HikkakuBlock;
2612
2625
  /**
2613
2626
  * Stops all sounds.
2614
2627
  *
@@ -2721,4 +2734,4 @@ declare const changeVolumeBy: (value: PrimitiveSource<number>) => HikkakuBlock;
2721
2734
  */
2722
2735
  declare const getVolume: () => HikkakuBlock;
2723
2736
  //#endregion
2724
- export { CREATE_CLONE_MYSELF, CurrentMenu, DragMode, ForwardBackward, FrontBack, ListIndex, LookEffect, MathOpOperator, NumberName, PenColorParam, ProcedureArgumentDefault, ProcedureBooleanReference, ProcedureCallInput, ProcedureDefinition, ProcedureDefinitionReference, ProcedureProc, ProcedureProcBoolean, ProcedureProcLabel, ProcedureProcStringOrNumber, ProcedureReference, ProcedureReferenceBase, ProcedureStringOrNumberReference, SoundEffect, StopOption, add, addToList, allAtOnce, and, argumentReporterBoolean, argumentReporterStringNumber, askAndWait, broadcast, broadcastAndWait, callProcedure, changeLooksEffectBy, changePenColorParamBy, changePenHueBy, changePenShadeBy, changePenSizeBy, changeSizeBy, changeSoundEffectBy, changeTempo, changeVariableBy, changeVolumeBy, changeXBy, changeYBy, clear, clearCounter, clearEffects, clearGraphicEffects, colorTouchingColor, contains, controlStartAsClone, createClone, current, daysSince2000, defineProcedure, deleteAllOfList, deleteOfList, deleteThisClone, distanceTo, divide, equals, eraseAll, forEach, forever, getAnswer, getAttributeOf, getBackdropNumberName, getCostumeNumberName, getCounter, getDirection, getItemNumOfList, getItemOfList, getKeyPressed, getListContents, getLoudness, getMouseDown, getMouseX, getMouseY, getSize, getTempo, getTimer, getUsername, getVariable, getVolume, getX, getY, glide, glideTo, goForwardBackwardLayers, goTo, goToFrontBack, gotoXY, gt, hide, hideList, hideVariable, ifElse, ifOnEdgeBounce, ifThen, incrCounter, insertAtList, isLoud, join, length, lengthOfList, letterOf, listContainsItem, lt, match, mathop, midiPlayDrumForBeats, midiSetInstrument, mod, moveSteps, multiply, nextBackdrop, nextCostume, not, or, penDown, penUp, playDrumForBeats, playNoteForBeats, playSound, playSoundUntilDone, pointInDirection, pointTowards, procedureBoolean, procedureLabel, procedureStringOrNumber, random, repeat, repeatUntil, repeatWhile, replaceItemOfList, resetTimer, restForBeats, round, say, sayForSecs, setDragMode, setInstrument, setLooksEffectTo, setPenColorParamTo, setPenColorTo, setPenColorToColor, setPenHueToNumber, setPenShadeToNumber, setPenSizeTo, setRotationStyle, setSizeTo, setSoundEffectTo, setTempo, setVariableTo, setVolumeTo, setX, setY, show, showList, showVariable, stamp, stop, stopAllSounds, subtract, switchBackdropTo, switchBackdropToAndWait, switchCostumeTo, think, thinkForSecs, touchingColor, touchingObject, turnLeft, turnRight, wait, waitUntil, whenBackdropSwitchesTo, whenBroadcastReceived, whenFlagClicked, whenGreaterThan, whenKeyPressed, whenStageClicked, whenThisSpriteClicked, whenTouchingObject };
2737
+ export { CREATE_CLONE_MYSELF, CurrentMenu, DragMode, ForwardBackward, FrontBack, GOTO_RANDOM, ListIndex, LookEffect, MathOpOperator, NumberName, PenColorParam, ProcedureArgumentDefault, ProcedureBooleanReference, ProcedureCallInput, ProcedureDefinition, ProcedureDefinitionReference, ProcedureProc, ProcedureProcBoolean, ProcedureProcLabel, ProcedureProcStringOrNumber, ProcedureReference, ProcedureReferenceBase, ProcedureStringOrNumberReference, SoundEffect, StopOption, add, addToList, allAtOnce, and, argumentReporterBoolean, argumentReporterStringNumber, askAndWait, broadcast, broadcastAndWait, callProcedure, changeLooksEffectBy, changePenColorParamBy, changePenHueBy, changePenShadeBy, changePenSizeBy, changeSizeBy, changeSoundEffectBy, changeTempo, changeVariableBy, changeVolumeBy, changeXBy, changeYBy, clear, clearCounter, clearEffects, clearGraphicEffects, colorTouchingColor, contains, controlStartAsClone, createClone, current, daysSince2000, defineProcedure, deleteAllOfList, deleteOfList, deleteThisClone, distanceTo, divide, equals, eraseAll, forEach, forever, getAnswer, getAttributeOf, getBackdropNumberName, getCostumeNumberName, getCounter, getDirection, getItemNumOfList, getItemOfList, getKeyPressed, getListContents, getLoudness, getMouseDown, getMouseX, getMouseY, getSize, getTempo, getTimer, getUsername, getVariable, getVolume, getX, getY, glide, glideTo, goForwardBackwardLayers, goTo, goToFrontBack, gotoXY, gt, hide, hideList, hideVariable, ifElse, ifOnEdgeBounce, ifThen, incrCounter, insertAtList, isLoud, join, length, lengthOfList, letterOf, listContainsItem, lt, match, mathop, menuOfAttributeObject, menuOfBackdrop, menuOfCostume, menuOfCreateClone, menuOfDistanceTo, menuOfGlideTo, menuOfGoTo, menuOfKeyOptions, menuOfPenColorParam, menuOfPointTowards, menuOfSounds, menuOfTouchingObject, midiPlayDrumForBeats, midiSetInstrument, mod, moveSteps, multiply, nextBackdrop, nextCostume, not, or, penDown, penUp, playDrumForBeats, playNoteForBeats, playSound, playSoundUntilDone, pointInDirection, pointTowards, procedureBoolean, procedureLabel, procedureStringOrNumber, random, repeat, repeatUntil, repeatWhile, replaceItemOfList, resetTimer, restForBeats, round, say, sayForSecs, setDragMode, setInstrument, setLooksEffectTo, setPenColorParamTo, setPenColorTo, setPenColorToColor, setPenHueToNumber, setPenShadeToNumber, setPenSizeTo, setRotationStyle, setSizeTo, setSoundEffectTo, setTempo, setVariableTo, setVolumeTo, setX, setY, show, showList, showVariable, stamp, stop, stopAllSounds, subtract, switchBackdropTo, switchBackdropToAndWait, switchCostumeTo, think, thinkForSecs, touchingColor, touchingObject, turnLeft, turnRight, wait, waitUntil, whenBackdropSwitchesTo, whenBroadcastReceived, whenFlagClicked, whenGreaterThan, whenKeyPressed, whenStageClicked, whenThisSpriteClicked, whenTouchingObject };
package/blocks/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as valueBlock, c as fromSoundSource, i as substack, l as InputType, n as block, o as fromCostumeSource, s as fromPrimitiveSource, t as attachStack, u as Shadow } from "../composer-DpyUR2R3.mjs";
1
+ import { a as valueBlock, d as menuInput, f as unwrapCostumeSource, h as Shadow, i as substack, m as InputType, n as block, o as fromPrimitiveSource, p as unwrapSoundSource, s as fromPrimitiveSourceColor, t as attachStack } from "../composer-bPcsVhIg.mjs";
2
2
 
3
3
  //#region src/blocks/control.ts
4
4
  /**
@@ -84,7 +84,7 @@ const repeatWhile = (condition, handler) => {
84
84
  * ```ts
85
85
  * import { forEach } from 'hikkaku/blocks'
86
86
  *
87
- * forEach(variable as any, 10, () => {})
87
+ * forEach(variable, 10, () => {})
88
88
  * ```
89
89
  */
90
90
  const forEach = (variable, value, handler) => {
@@ -278,11 +278,17 @@ const CREATE_CLONE_MYSELF = "_myself_";
278
278
  * ```ts
279
279
  * import { createClone } from 'hikkaku/blocks'
280
280
  *
281
- * createClone('mouse-pointer')
281
+ * createClone('Sprite1')
282
282
  * ```
283
283
  */
284
284
  const createClone = (target) => {
285
- return block("control_create_clone_of", { inputs: { CLONE_OPTION: fromPrimitiveSource(target) } });
285
+ return block("control_create_clone_of", { inputs: { CLONE_OPTION: menuInput(target, menuOfCreateClone) } });
286
+ };
287
+ const menuOfCreateClone = (target = CREATE_CLONE_MYSELF) => {
288
+ return valueBlock("control_create_clone_of_menu", {
289
+ fields: { CLONE_OPTION: [target, null] },
290
+ isShadow: true
291
+ });
286
292
  };
287
293
  /**
288
294
  * Deletes the current clone.
@@ -407,7 +413,7 @@ const toField = (field) => [field.name, field.id];
407
413
  * ```ts
408
414
  * import { getVariable } from 'hikkaku/blocks'
409
415
  *
410
- * getVariable(variable as any)
416
+ * getVariable(variable)
411
417
  * ```
412
418
  */
413
419
  const getVariable = (variable) => {
@@ -426,7 +432,7 @@ const getVariable = (variable) => {
426
432
  * ```ts
427
433
  * import { setVariableTo } from 'hikkaku/blocks'
428
434
  *
429
- * setVariableTo(variable as any, 10)
435
+ * setVariableTo(variable, 10)
430
436
  * ```
431
437
  */
432
438
  const setVariableTo = (variable, value) => {
@@ -448,7 +454,7 @@ const setVariableTo = (variable, value) => {
448
454
  * ```ts
449
455
  * import { changeVariableBy } from 'hikkaku/blocks'
450
456
  *
451
- * changeVariableBy(variable as any, 10)
457
+ * changeVariableBy(variable, 10)
452
458
  * ```
453
459
  */
454
460
  const changeVariableBy = (variable, value) => {
@@ -469,7 +475,7 @@ const changeVariableBy = (variable, value) => {
469
475
  * ```ts
470
476
  * import { showVariable } from 'hikkaku/blocks'
471
477
  *
472
- * showVariable(variable as any)
478
+ * showVariable(variable)
473
479
  * ```
474
480
  */
475
481
  const showVariable = (variable) => {
@@ -487,7 +493,7 @@ const showVariable = (variable) => {
487
493
  * ```ts
488
494
  * import { hideVariable } from 'hikkaku/blocks'
489
495
  *
490
- * hideVariable(variable as any)
496
+ * hideVariable(variable)
491
497
  * ```
492
498
  */
493
499
  const hideVariable = (variable) => {
@@ -505,7 +511,7 @@ const hideVariable = (variable) => {
505
511
  * ```ts
506
512
  * import { getListContents } from 'hikkaku/blocks'
507
513
  *
508
- * getListContents(list as any)
514
+ * getListContents(list)
509
515
  * ```
510
516
  */
511
517
  const getListContents = (list) => {
@@ -524,7 +530,7 @@ const getListContents = (list) => {
524
530
  * ```ts
525
531
  * import { addToList } from 'hikkaku/blocks'
526
532
  *
527
- * addToList(list as any, undefined as any)
533
+ * addToList(list, "banana")
528
534
  * ```
529
535
  */
530
536
  const addToList = (list, item) => {
@@ -546,7 +552,7 @@ const addToList = (list, item) => {
546
552
  * ```ts
547
553
  * import { deleteOfList } from 'hikkaku/blocks'
548
554
  *
549
- * deleteOfList(list as any, undefined as any)
555
+ * deleteOfList(list, 1)
550
556
  * ```
551
557
  */
552
558
  const deleteOfList = (list, index) => {
@@ -567,7 +573,7 @@ const deleteOfList = (list, index) => {
567
573
  * ```ts
568
574
  * import { deleteAllOfList } from 'hikkaku/blocks'
569
575
  *
570
- * deleteAllOfList(list as any)
576
+ * deleteAllOfList(list)
571
577
  * ```
572
578
  */
573
579
  const deleteAllOfList = (list) => {
@@ -587,7 +593,7 @@ const deleteAllOfList = (list) => {
587
593
  * ```ts
588
594
  * import { insertAtList } from 'hikkaku/blocks'
589
595
  *
590
- * insertAtList(list as any, undefined as any, undefined as any)
596
+ * insertAtList(list, 42, "banana")
591
597
  * ```
592
598
  */
593
599
  const insertAtList = (list, index, item) => {
@@ -613,7 +619,7 @@ const insertAtList = (list, index, item) => {
613
619
  * ```ts
614
620
  * import { replaceItemOfList } from 'hikkaku/blocks'
615
621
  *
616
- * replaceItemOfList(list as any, undefined as any, undefined as any)
622
+ * replaceItemOfList(list, 42, "banana")
617
623
  * ```
618
624
  */
619
625
  const replaceItemOfList = (list, index, item) => {
@@ -638,7 +644,7 @@ const replaceItemOfList = (list, index, item) => {
638
644
  * ```ts
639
645
  * import { getItemOfList } from 'hikkaku/blocks'
640
646
  *
641
- * getItemOfList(list as any, undefined as any)
647
+ * getItemOfList(list, 1)
642
648
  * ```
643
649
  */
644
650
  const getItemOfList = (list, index) => {
@@ -660,7 +666,7 @@ const getItemOfList = (list, index) => {
660
666
  * ```ts
661
667
  * import { getItemNumOfList } from 'hikkaku/blocks'
662
668
  *
663
- * getItemNumOfList(list as any, undefined as any)
669
+ * getItemNumOfList(list, "banana")
664
670
  * ```
665
671
  */
666
672
  const getItemNumOfList = (list, item) => {
@@ -681,7 +687,7 @@ const getItemNumOfList = (list, item) => {
681
687
  * ```ts
682
688
  * import { lengthOfList } from 'hikkaku/blocks'
683
689
  *
684
- * lengthOfList(list as any)
690
+ * lengthOfList(list)
685
691
  * ```
686
692
  */
687
693
  const lengthOfList = (list) => {
@@ -700,7 +706,7 @@ const lengthOfList = (list) => {
700
706
  * ```ts
701
707
  * import { listContainsItem } from 'hikkaku/blocks'
702
708
  *
703
- * listContainsItem(list as any, undefined as any)
709
+ * listContainsItem(list,"banana")
704
710
  * ```
705
711
  */
706
712
  const listContainsItem = (list, item) => {
@@ -721,7 +727,7 @@ const listContainsItem = (list, item) => {
721
727
  * ```ts
722
728
  * import { showList } from 'hikkaku/blocks'
723
729
  *
724
- * showList(list as any)
730
+ * showList(list)
725
731
  * ```
726
732
  */
727
733
  const showList = (list) => {
@@ -739,7 +745,7 @@ const showList = (list) => {
739
745
  * ```ts
740
746
  * import { hideList } from 'hikkaku/blocks'
741
747
  *
742
- * hideList(list as any)
748
+ * hideList(list)
743
749
  * ```
744
750
  */
745
751
  const hideList = (list) => {
@@ -1103,7 +1109,13 @@ const hide = () => {
1103
1109
  * ```
1104
1110
  */
1105
1111
  const switchCostumeTo = (costume) => {
1106
- return block("looks_switchcostumeto", { inputs: { COSTUME: fromCostumeSource(costume) } });
1112
+ return block("looks_switchcostumeto", { inputs: { COSTUME: menuInput(unwrapCostumeSource(costume), menuOfCostume) } });
1113
+ };
1114
+ const menuOfCostume = (costume = "") => {
1115
+ return valueBlock("looks_costume", {
1116
+ fields: { COSTUME: [costume, null] },
1117
+ isShadow: true
1118
+ });
1107
1119
  };
1108
1120
  /**
1109
1121
  * Next costume.
@@ -1138,7 +1150,13 @@ const nextCostume = () => {
1138
1150
  * ```
1139
1151
  */
1140
1152
  const switchBackdropTo = (backdrop) => {
1141
- return block("looks_switchbackdropto", { inputs: { BACKDROP: fromPrimitiveSource(backdrop) } });
1153
+ return block("looks_switchbackdropto", { inputs: { BACKDROP: menuInput(backdrop, menuOfBackdrop) } });
1154
+ };
1155
+ const menuOfBackdrop = (backdrop = "") => {
1156
+ return valueBlock("looks_backdrops", {
1157
+ fields: { BACKDROP: [backdrop, null] },
1158
+ isShadow: true
1159
+ });
1142
1160
  };
1143
1161
  /**
1144
1162
  * Switch backdrop and wait.
@@ -1156,7 +1174,7 @@ const switchBackdropTo = (backdrop) => {
1156
1174
  * ```
1157
1175
  */
1158
1176
  const switchBackdropToAndWait = (backdrop) => {
1159
- return block("looks_switchbackdroptoandwait", { inputs: { BACKDROP: fromPrimitiveSource(backdrop) } });
1177
+ return block("looks_switchbackdroptoandwait", { inputs: { BACKDROP: menuInput(backdrop, menuOfBackdrop) } });
1160
1178
  };
1161
1179
  /**
1162
1180
  * Next backdrop.
@@ -1380,7 +1398,7 @@ const getBackdropNumberName = (value) => {
1380
1398
  * ```ts
1381
1399
  * import { moveSteps } from 'hikkaku/blocks'
1382
1400
  *
1383
- * moveSteps(undefined as any)
1401
+ * moveSteps(10)
1384
1402
  * ```
1385
1403
  */
1386
1404
  const moveSteps = (steps) => {
@@ -1496,7 +1514,14 @@ const setY = (y) => {
1496
1514
  * ```
1497
1515
  */
1498
1516
  const goTo = (target) => {
1499
- return block("motion_goto", { fields: { TO: [target, null] } });
1517
+ return block("motion_goto", { inputs: { TO: menuInput(target, menuOfGoTo) } });
1518
+ };
1519
+ const GOTO_RANDOM = "_random_";
1520
+ const menuOfGoTo = (target = GOTO_RANDOM) => {
1521
+ return valueBlock("motion_goto_menu", {
1522
+ fields: { TO: [target, null] },
1523
+ isShadow: true
1524
+ });
1500
1525
  };
1501
1526
  /**
1502
1527
  * Turns right.
@@ -1568,7 +1593,14 @@ const pointInDirection = (direction) => {
1568
1593
  * ```
1569
1594
  */
1570
1595
  const pointTowards = (target) => {
1571
- return block("motion_pointtowards", { fields: { TOWARDS: [target, null] } });
1596
+ return block("motion_pointtowards", { inputs: { TOWARDS: menuInput(target, menuOfPointTowards) } });
1597
+ };
1598
+ const TOWARDS_MOUSE_POINTER = "_mouse_";
1599
+ const menuOfPointTowards = (target = TOWARDS_MOUSE_POINTER) => {
1600
+ return valueBlock("motion_pointtowards_menu", {
1601
+ fields: { TOWARDS: [target, null] },
1602
+ isShadow: true
1603
+ });
1572
1604
  };
1573
1605
  /**
1574
1606
  * Glides to position.
@@ -1611,9 +1643,15 @@ const glide = (seconds, x, y) => {
1611
1643
  * ```
1612
1644
  */
1613
1645
  const glideTo = (seconds, target) => {
1614
- return block("motion_glideto", {
1615
- inputs: { SECS: fromPrimitiveSource(seconds) },
1616
- fields: { TO: [target, null] }
1646
+ return block("motion_glideto", { inputs: {
1647
+ SECS: fromPrimitiveSource(seconds),
1648
+ TO: menuInput(target, menuOfGlideTo)
1649
+ } });
1650
+ };
1651
+ const menuOfGlideTo = (target = GOTO_RANDOM) => {
1652
+ return valueBlock("motion_glideto_menu", {
1653
+ fields: { TO: [target, null] },
1654
+ isShadow: true
1617
1655
  });
1618
1656
  };
1619
1657
  /**
@@ -2353,7 +2391,7 @@ const penUp = () => {
2353
2391
  /**
2354
2392
  * Sets pen color.
2355
2393
  *
2356
- * Input: `color`.
2394
+ * Input: `color`. like: #ffffff, #fff. This does not accept values like "red" or "green" that CSS accepts.
2357
2395
  * Output: Scratch statement block definition that is appended to the current script stack.
2358
2396
  *
2359
2397
  * @param color See function signature for accepted input values.
@@ -2362,11 +2400,11 @@ const penUp = () => {
2362
2400
  * ```ts
2363
2401
  * import { setPenColorTo } from 'hikkaku/blocks'
2364
2402
  *
2365
- * setPenColorTo(undefined as any)
2403
+ * setPenColorTo("#ff0000")
2366
2404
  * ```
2367
2405
  */
2368
2406
  const setPenColorTo = (color) => {
2369
- return block("pen_setPenColorToColor", { inputs: { COLOR: fromPrimitiveSource(color) } });
2407
+ return block("pen_setPenColorToColor", { inputs: { COLOR: fromPrimitiveSourceColor(color) } });
2370
2408
  };
2371
2409
  /**
2372
2410
  * Alias for {@link setPenColorTo}.
@@ -2396,15 +2434,21 @@ const setPenColorToColor = setPenColorTo;
2396
2434
  * ```ts
2397
2435
  * import { changePenColorParamBy } from 'hikkaku/blocks'
2398
2436
  *
2399
- * changePenColorParamBy(undefined as any, 10)
2437
+ * changePenColorParamBy('color', 10)
2400
2438
  * ```
2401
2439
  */
2402
2440
  const changePenColorParamBy = (param, value) => {
2403
2441
  return block("pen_changePenColorParamBy", { inputs: {
2404
- COLOR_PARAM: fromPrimitiveSource(param),
2442
+ COLOR_PARAM: menuInput(param, menuOfPenColorParam),
2405
2443
  VALUE: fromPrimitiveSource(value)
2406
2444
  } });
2407
2445
  };
2446
+ const menuOfPenColorParam = (colorParam = "color") => {
2447
+ return valueBlock("pen_menu_colorParam", {
2448
+ fields: { colorParam: [colorParam, null] },
2449
+ isShadow: true
2450
+ });
2451
+ };
2408
2452
  /**
2409
2453
  * Sets pen color parameter to value.
2410
2454
  *
@@ -2418,12 +2462,12 @@ const changePenColorParamBy = (param, value) => {
2418
2462
  * ```ts
2419
2463
  * import { setPenColorParamTo } from 'hikkaku/blocks'
2420
2464
  *
2421
- * setPenColorParamTo(undefined as any, 10)
2465
+ * setPenColorParamTo('color', 10)
2422
2466
  * ```
2423
2467
  */
2424
2468
  const setPenColorParamTo = (param, value) => {
2425
2469
  return block("pen_setPenColorParamTo", { inputs: {
2426
- COLOR_PARAM: fromPrimitiveSource(param),
2470
+ COLOR_PARAM: menuInput(param, menuOfPenColorParam),
2427
2471
  VALUE: fromPrimitiveSource(value)
2428
2472
  } });
2429
2473
  };
@@ -2833,7 +2877,13 @@ const getMouseY = () => {
2833
2877
  * ```
2834
2878
  */
2835
2879
  const touchingObject = (target) => {
2836
- return valueBlock("sensing_touchingobject", { inputs: { TOUCHINGOBJECTMENU: fromPrimitiveSource(target) } });
2880
+ return valueBlock("sensing_touchingobject", { inputs: { TOUCHINGOBJECTMENU: menuInput(target, menuOfTouchingObject) } });
2881
+ };
2882
+ const menuOfTouchingObject = (target = "_mouse_") => {
2883
+ return valueBlock("sensing_touchingobjectmenu", {
2884
+ fields: { TOUCHINGOBJECTMENU: [target, null] },
2885
+ isShadow: true
2886
+ });
2837
2887
  };
2838
2888
  /**
2839
2889
  * Touching color check.
@@ -2847,11 +2897,11 @@ const touchingObject = (target) => {
2847
2897
  * ```ts
2848
2898
  * import { touchingColor } from 'hikkaku/blocks'
2849
2899
  *
2850
- * touchingColor(undefined as any)
2900
+ * touchingColor("#ff0000")
2851
2901
  * ```
2852
2902
  */
2853
2903
  const touchingColor = (color) => {
2854
- return valueBlock("sensing_touchingcolor", { inputs: { COLOR: fromPrimitiveSource(color) } });
2904
+ return valueBlock("sensing_touchingcolor", { inputs: { COLOR: fromPrimitiveSourceColor(color) } });
2855
2905
  };
2856
2906
  /**
2857
2907
  * Color overlap check.
@@ -2866,13 +2916,13 @@ const touchingColor = (color) => {
2866
2916
  * ```ts
2867
2917
  * import { colorTouchingColor } from 'hikkaku/blocks'
2868
2918
  *
2869
- * colorTouchingColor(undefined as any, undefined as any)
2919
+ * colorTouchingColor("#ff0000", "#00ff00")
2870
2920
  * ```
2871
2921
  */
2872
2922
  const colorTouchingColor = (color, targetColor) => {
2873
2923
  return valueBlock("sensing_coloristouchingcolor", { inputs: {
2874
- COLOR: fromPrimitiveSource(color),
2875
- COLOR2: fromPrimitiveSource(targetColor)
2924
+ COLOR: fromPrimitiveSourceColor(color),
2925
+ COLOR2: fromPrimitiveSourceColor(targetColor)
2876
2926
  } });
2877
2927
  };
2878
2928
  /**
@@ -2891,7 +2941,13 @@ const colorTouchingColor = (color, targetColor) => {
2891
2941
  * ```
2892
2942
  */
2893
2943
  const distanceTo = (target) => {
2894
- return valueBlock("sensing_distanceto", { fields: { DISTANCETOMENU: [target, null] } });
2944
+ return valueBlock("sensing_distanceto", { inputs: { DISTANCETOMENU: menuInput(target, menuOfDistanceTo) } });
2945
+ };
2946
+ const menuOfDistanceTo = (target = "_mouse_") => {
2947
+ return valueBlock("sensing_distancetomenu", {
2948
+ fields: { DISTANCETOMENU: [target, null] },
2949
+ isShadow: true
2950
+ });
2895
2951
  };
2896
2952
  /**
2897
2953
  * Timer value.
@@ -2978,7 +3034,13 @@ const getMouseDown = () => {
2978
3034
  * ```
2979
3035
  */
2980
3036
  const getKeyPressed = (key) => {
2981
- return valueBlock("sensing_keypressed", { inputs: { KEY_OPTION: fromPrimitiveSource(key) } });
3037
+ return valueBlock("sensing_keypressed", { inputs: { KEY_OPTION: menuInput(key, menuOfKeyOptions) } });
3038
+ };
3039
+ const menuOfKeyOptions = (key = "space") => {
3040
+ return valueBlock("sensing_keyoptions", {
3041
+ fields: { KEY_OPTION: [key, null] },
3042
+ isShadow: true
3043
+ });
2982
3044
  };
2983
3045
  /**
2984
3046
  * Current date/time value.
@@ -3011,14 +3073,20 @@ const current = (menu) => {
3011
3073
  * ```ts
3012
3074
  * import { getAttributeOf } from 'hikkaku/blocks'
3013
3075
  *
3014
- * getAttributeOf(undefined as any, 'mouse-pointer')
3076
+ * getAttributeOf('x position', 'cat')
3015
3077
  * ```
3016
3078
  */
3017
3079
  const getAttributeOf = (property, target) => {
3018
- return valueBlock("sensing_of", { fields: {
3019
- PROPERTY: [property, null],
3020
- OBJECT: [target, null]
3021
- } });
3080
+ return valueBlock("sensing_of", {
3081
+ fields: { PROPERTY: [property, null] },
3082
+ inputs: { OBJECT: menuInput(target, menuOfAttributeObject) }
3083
+ });
3084
+ };
3085
+ const menuOfAttributeObject = (object = "_stage_") => {
3086
+ return valueBlock("sensing_of_object_menu", {
3087
+ fields: { OBJECT: [object, null] },
3088
+ isShadow: true
3089
+ });
3022
3090
  };
3023
3091
  /**
3024
3092
  * Days since 2000-01-01.
@@ -3151,7 +3219,7 @@ const getUsername = () => {
3151
3219
  * ```
3152
3220
  */
3153
3221
  const playSound = (sound) => {
3154
- return block("sound_play", { inputs: { SOUND_MENU: fromSoundSource(sound) } });
3222
+ return block("sound_play", { inputs: { SOUND_MENU: menuInput(unwrapSoundSource(sound), menuOfSounds) } });
3155
3223
  };
3156
3224
  /**
3157
3225
  * Plays and waits.
@@ -3177,7 +3245,13 @@ const playSound = (sound) => {
3177
3245
  * ```
3178
3246
  */
3179
3247
  const playSoundUntilDone = (sound) => {
3180
- return block("sound_playuntildone", { inputs: { SOUND_MENU: fromSoundSource(sound) } });
3248
+ return block("sound_playuntildone", { inputs: { SOUND_MENU: menuInput(unwrapSoundSource(sound), menuOfSounds) } });
3249
+ };
3250
+ const menuOfSounds = (sound = "") => {
3251
+ return valueBlock("sound_sounds_menu", {
3252
+ fields: { SOUND_MENU: [sound, null] },
3253
+ isShadow: true
3254
+ });
3181
3255
  };
3182
3256
  /**
3183
3257
  * Stops all sounds.
@@ -3312,4 +3386,4 @@ const getVolume = () => {
3312
3386
  };
3313
3387
 
3314
3388
  //#endregion
3315
- export { CREATE_CLONE_MYSELF, add, addToList, allAtOnce, and, argumentReporterBoolean, argumentReporterStringNumber, askAndWait, broadcast, broadcastAndWait, callProcedure, changeLooksEffectBy, changePenColorParamBy, changePenHueBy, changePenShadeBy, changePenSizeBy, changeSizeBy, changeSoundEffectBy, changeTempo, changeVariableBy, changeVolumeBy, changeXBy, changeYBy, clear, clearCounter, clearEffects, clearGraphicEffects, colorTouchingColor, contains, controlStartAsClone, createClone, current, daysSince2000, defineProcedure, deleteAllOfList, deleteOfList, deleteThisClone, distanceTo, divide, equals, eraseAll, forEach, forever, getAnswer, getAttributeOf, getBackdropNumberName, getCostumeNumberName, getCounter, getDirection, getItemNumOfList, getItemOfList, getKeyPressed, getListContents, getLoudness, getMouseDown, getMouseX, getMouseY, getSize, getTempo, getTimer, getUsername, getVariable, getVolume, getX, getY, glide, glideTo, goForwardBackwardLayers, goTo, goToFrontBack, gotoXY, gt, hide, hideList, hideVariable, ifElse, ifOnEdgeBounce, ifThen, incrCounter, insertAtList, isLoud, join, length, lengthOfList, letterOf, listContainsItem, lt, match, mathop, midiPlayDrumForBeats, midiSetInstrument, mod, moveSteps, multiply, nextBackdrop, nextCostume, not, or, penDown, penUp, playDrumForBeats, playNoteForBeats, playSound, playSoundUntilDone, pointInDirection, pointTowards, procedureBoolean, procedureLabel, procedureStringOrNumber, random, repeat, repeatUntil, repeatWhile, replaceItemOfList, resetTimer, restForBeats, round, say, sayForSecs, setDragMode, setInstrument, setLooksEffectTo, setPenColorParamTo, setPenColorTo, setPenColorToColor, setPenHueToNumber, setPenShadeToNumber, setPenSizeTo, setRotationStyle, setSizeTo, setSoundEffectTo, setTempo, setVariableTo, setVolumeTo, setX, setY, show, showList, showVariable, stamp, stop, stopAllSounds, subtract, switchBackdropTo, switchBackdropToAndWait, switchCostumeTo, think, thinkForSecs, touchingColor, touchingObject, turnLeft, turnRight, wait, waitUntil, whenBackdropSwitchesTo, whenBroadcastReceived, whenFlagClicked, whenGreaterThan, whenKeyPressed, whenStageClicked, whenThisSpriteClicked, whenTouchingObject };
3389
+ export { CREATE_CLONE_MYSELF, GOTO_RANDOM, add, addToList, allAtOnce, and, argumentReporterBoolean, argumentReporterStringNumber, askAndWait, broadcast, broadcastAndWait, callProcedure, changeLooksEffectBy, changePenColorParamBy, changePenHueBy, changePenShadeBy, changePenSizeBy, changeSizeBy, changeSoundEffectBy, changeTempo, changeVariableBy, changeVolumeBy, changeXBy, changeYBy, clear, clearCounter, clearEffects, clearGraphicEffects, colorTouchingColor, contains, controlStartAsClone, createClone, current, daysSince2000, defineProcedure, deleteAllOfList, deleteOfList, deleteThisClone, distanceTo, divide, equals, eraseAll, forEach, forever, getAnswer, getAttributeOf, getBackdropNumberName, getCostumeNumberName, getCounter, getDirection, getItemNumOfList, getItemOfList, getKeyPressed, getListContents, getLoudness, getMouseDown, getMouseX, getMouseY, getSize, getTempo, getTimer, getUsername, getVariable, getVolume, getX, getY, glide, glideTo, goForwardBackwardLayers, goTo, goToFrontBack, gotoXY, gt, hide, hideList, hideVariable, ifElse, ifOnEdgeBounce, ifThen, incrCounter, insertAtList, isLoud, join, length, lengthOfList, letterOf, listContainsItem, lt, match, mathop, menuOfAttributeObject, menuOfBackdrop, menuOfCostume, menuOfCreateClone, menuOfDistanceTo, menuOfGlideTo, menuOfGoTo, menuOfKeyOptions, menuOfPenColorParam, menuOfPointTowards, menuOfSounds, menuOfTouchingObject, midiPlayDrumForBeats, midiSetInstrument, mod, moveSteps, multiply, nextBackdrop, nextCostume, not, or, penDown, penUp, playDrumForBeats, playNoteForBeats, playSound, playSoundUntilDone, pointInDirection, pointTowards, procedureBoolean, procedureLabel, procedureStringOrNumber, random, repeat, repeatUntil, repeatWhile, replaceItemOfList, resetTimer, restForBeats, round, say, sayForSecs, setDragMode, setInstrument, setLooksEffectTo, setPenColorParamTo, setPenColorTo, setPenColorToColor, setPenHueToNumber, setPenShadeToNumber, setPenSizeTo, setRotationStyle, setSizeTo, setSoundEffectTo, setTempo, setVariableTo, setVolumeTo, setX, setY, show, showList, showVariable, stamp, stop, stopAllSounds, subtract, switchBackdropTo, switchBackdropToAndWait, switchCostumeTo, think, thinkForSecs, touchingColor, touchingObject, turnLeft, turnRight, wait, waitUntil, whenBackdropSwitchesTo, whenBroadcastReceived, whenFlagClicked, whenGreaterThan, whenKeyPressed, whenStageClicked, whenThisSpriteClicked, whenTouchingObject };
@@ -22,7 +22,8 @@ const InputType$1 = {
22
22
  Number: toNumericEnum(inputType.Number, 4),
23
23
  PositiveInteger: toNumericEnum(inputType.PositiveInteger ?? inputType.PossiveInteger, 6),
24
24
  String: toNumericEnum(inputType.String, 10),
25
- Broadcast: toNumericEnum(inputType.Broadcast, 11)
25
+ Broadcast: toNumericEnum(inputType.Broadcast, 11),
26
+ Color: toNumericEnum(inputType.Color, 9)
26
27
  };
27
28
 
28
29
  //#endregion
@@ -33,13 +34,37 @@ const fromPrimitiveSource = (source) => {
33
34
  if (typeof source === "string") return [Shadow$1.SameBlockShadow, [InputType$1.String, source]];
34
35
  return [Shadow$1.SameBlockShadow, source.id];
35
36
  };
36
- const fromCostumeSource = (source) => {
37
- if (typeof source === "object" && source !== null && "type" in source && source.type === "costume") return fromPrimitiveSource(source.name);
38
- return fromPrimitiveSource(source);
37
+ const fromPrimitiveSourceColor = (color) => {
38
+ if (typeof color === "string") return [Shadow$1.SameBlockShadow, [InputType$1.Color, color]];
39
+ return fromPrimitiveSource(color);
40
+ };
41
+ const unwrapCostumeSource = (source) => {
42
+ if (isCostumeReference(source)) return source.name;
43
+ return source;
44
+ };
45
+ const unwrapSoundSource = (source) => {
46
+ if (isSoundReference(source)) return source.name;
47
+ return source;
48
+ };
49
+ const isHikkakuBlock = (block) => {
50
+ return typeof block === "object" && block !== null && "isBlock" in block && block.isBlock === true && "id" in block && typeof block.id === "string";
51
+ };
52
+ const menuInput = (source, createMenu) => {
53
+ if (isHikkakuBlock(source)) {
54
+ const shadow = createMenu();
55
+ return [
56
+ Shadow$1.DiffBlockShadow,
57
+ source.id,
58
+ shadow.id
59
+ ];
60
+ }
61
+ return fromPrimitiveSource(createMenu(source));
62
+ };
63
+ const isCostumeReference = (source) => {
64
+ return typeof source === "object" && source !== null && "type" in source && source.type === "costume";
39
65
  };
40
- const fromSoundSource = (source) => {
41
- if (typeof source === "object" && source !== null && "type" in source && source.type === "sound") return fromPrimitiveSource(source.name);
42
- return fromPrimitiveSource(source);
66
+ const isSoundReference = (source) => {
67
+ return typeof source === "object" && source !== null && "type" in source && source.type === "sound";
43
68
  };
44
69
 
45
70
  //#endregion
@@ -69,22 +94,24 @@ const block = (opcode, init) => {
69
94
  ctx.blocks[id] = block;
70
95
  ctx.blockToId.set(block, id);
71
96
  if (init.isValue) ctx.valueBlockSet.add(block);
72
- if (init.inputs) {
73
- for (const [_key, value] of Object.entries(init.inputs)) if (typeof value[1] === "string") {
74
- const valueBlockId = value[1];
75
- const valueBlock = ctx.blocks[valueBlockId];
76
- if (valueBlock) {
77
- valueBlock.parent = id;
78
- ctx.usedAsValueSet.add(valueBlock);
79
- }
80
- }
81
- }
97
+ if (init.inputs) for (const [_key, value] of Object.entries(init.inputs)) value.slice(1).forEach((input) => {
98
+ if (typeof input === "string") attachValueBlock(ctx, id, input);
99
+ });
82
100
  if (ctx.adder) ctx.adder(id, block);
83
101
  return {
84
102
  isBlock: true,
85
103
  id
86
104
  };
87
105
  };
106
+ function attachValueBlock(ctx, parentId, blockId) {
107
+ const block = ctx.blocks[blockId];
108
+ if (!block) {
109
+ console.warn(`Block with ID ${blockId} not found (referenced from block ${parentId})`);
110
+ return;
111
+ }
112
+ block.parent = parentId;
113
+ ctx.usedAsValueSet.add(block);
114
+ }
88
115
  const valueBlock = (opcode, init) => {
89
116
  return block(opcode, {
90
117
  ...init,
@@ -206,4 +233,4 @@ const createBlocks = (handler) => {
206
233
  };
207
234
 
208
235
  //#endregion
209
- export { valueBlock as a, fromSoundSource as c, substack as i, InputType$1 as l, block as n, fromCostumeSource as o, createBlocks as r, fromPrimitiveSource as s, attachStack as t, Shadow$1 as u };
236
+ export { valueBlock as a, isCostumeReference as c, menuInput as d, unwrapCostumeSource as f, Shadow$1 as h, substack as i, isHikkakuBlock as l, InputType$1 as m, block as n, fromPrimitiveSource as o, unwrapSoundSource as p, createBlocks as r, fromPrimitiveSourceColor as s, attachStack as t, isSoundReference as u };
package/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as VariableMonitorMode, C as PrimitiveAvailableOnScratch, D as SoundSource, E as SoundReference, M as VariableReference, O as VariableBase, S as MonitorPosition, T as SoundData, _ as CreateListOptions, a as Handler, b as ListMonitorOptions, c as createBlocks, d as fromCostumeSource, f as fromPrimitiveSource, g as CostumeSource, h as CostumeReference, i as BlockInit, j as VariableMonitorOptions, k as VariableDefinition, l as substack, m as CostumeData, n as SpriteOptions, o as attachStack, p as fromSoundSource, r as Target, s as block, t as Project, u as valueBlock, v as CreateVariableOptions, w as PrimitiveSource, x as ListReference, y as HikkakuBlock } from "./project-djJPtrq7.mjs";
2
- export { BlockInit, CostumeData, CostumeReference, CostumeSource, CreateListOptions, CreateVariableOptions, Handler, HikkakuBlock, ListMonitorOptions, ListReference, MonitorPosition, PrimitiveAvailableOnScratch, PrimitiveSource, Project, SoundData, SoundReference, SoundSource, SpriteOptions, Target, VariableBase, VariableDefinition, VariableMonitorMode, VariableMonitorOptions, VariableReference, attachStack, block, createBlocks, fromCostumeSource, fromPrimitiveSource, fromSoundSource, substack, valueBlock };
1
+ import { A as SoundData, C as CreateVariableOptions, D as MonitorPosition, E as ListReference, F as VariableMonitorMode, I as VariableMonitorOptions, L as VariableReference, M as SoundSource, N as VariableBase, O as PrimitiveAvailableOnScratch, P as VariableDefinition, S as CreateListOptions, T as ListMonitorOptions, _ as unwrapCostumeSource, a as Handler, b as CostumeReference, c as createBlocks, d as fromPrimitiveSource, f as fromPrimitiveSourceColor, g as menuInput, h as isSoundReference, i as BlockInit, j as SoundReference, k as PrimitiveSource, l as substack, m as isHikkakuBlock, n as SpriteOptions, o as attachStack, p as isCostumeReference, r as Target, s as block, t as Project, u as valueBlock, v as unwrapSoundSource, w as HikkakuBlock, x as CostumeSource, y as CostumeData } from "./project-CpV5Dm-X.mjs";
2
+ export { BlockInit, CostumeData, CostumeReference, CostumeSource, CreateListOptions, CreateVariableOptions, Handler, HikkakuBlock, ListMonitorOptions, ListReference, MonitorPosition, PrimitiveAvailableOnScratch, PrimitiveSource, Project, SoundData, SoundReference, SoundSource, SpriteOptions, Target, VariableBase, VariableDefinition, VariableMonitorMode, VariableMonitorOptions, VariableReference, attachStack, block, createBlocks, fromPrimitiveSource, fromPrimitiveSourceColor, isCostumeReference, isHikkakuBlock, isSoundReference, menuInput, substack, unwrapCostumeSource, unwrapSoundSource, valueBlock };
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as valueBlock, c as fromSoundSource, i as substack, n as block, o as fromCostumeSource, r as createBlocks, s as fromPrimitiveSource, t as attachStack } from "./composer-DpyUR2R3.mjs";
1
+ import { a as valueBlock, c as isCostumeReference, d as menuInput, f as unwrapCostumeSource, i as substack, l as isHikkakuBlock, n as block, o as fromPrimitiveSource, p as unwrapSoundSource, r as createBlocks, s as fromPrimitiveSourceColor, t as attachStack, u as isSoundReference } from "./composer-bPcsVhIg.mjs";
2
2
 
3
3
  //#region src/core/monitors.ts
4
4
  const createVariableMonitor = (id, name, defaultValue, spriteName, options) => {
@@ -229,4 +229,4 @@ var Project = class {
229
229
  };
230
230
 
231
231
  //#endregion
232
- export { Project, Target, attachStack, block, createBlocks, fromCostumeSource, fromPrimitiveSource, fromSoundSource, substack, valueBlock };
232
+ export { Project, Target, attachStack, block, createBlocks, fromPrimitiveSource, fromPrimitiveSourceColor, isCostumeReference, isHikkakuBlock, isSoundReference, menuInput, substack, unwrapCostumeSource, unwrapSoundSource, valueBlock };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hikkaku",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "exports": {
@@ -37,7 +37,7 @@
37
37
  "@turbowarp/packager": "^3.11.0",
38
38
  "@types/bun": "latest",
39
39
  "@typescript/native-preview": "^7.0.0-dev.20260127.1",
40
- "rolldown": "1.0.0-beta.60",
40
+ "rolldown": "1.0.0-rc.4",
41
41
  "tsdown": "^0.20.0-beta.4"
42
42
  },
43
43
  "peerDependencies": {
@@ -46,7 +46,7 @@
46
46
  "dependencies": {
47
47
  "fflate": "^0.8.2",
48
48
  "sb3-types": "^0.1.16",
49
- "vite": "8.0.0-beta.8"
49
+ "vite": "8.0.0-beta.14"
50
50
  },
51
51
  "repository": {
52
52
  "url": "https://github.com/pnsk-lab/hikkaku",
@@ -65,8 +65,13 @@ type SoundData = Sound & {
65
65
  //#endregion
66
66
  //#region src/core/block-helper.d.ts
67
67
  declare const fromPrimitiveSource: <T extends PrimitiveAvailableOnScratch>(source: PrimitiveSource<T>) => sb3.Input;
68
- declare const fromCostumeSource: (source: CostumeSource) => sb3.Input;
69
- declare const fromSoundSource: (source: SoundSource) => sb3.Input;
68
+ declare const fromPrimitiveSourceColor: (color: PrimitiveSource<`#${string}` | (string & {})>) => sb3.Input;
69
+ declare const unwrapCostumeSource: (source: CostumeSource) => PrimitiveSource<string>;
70
+ declare const unwrapSoundSource: (source: SoundSource) => PrimitiveSource<string>;
71
+ declare const isHikkakuBlock: (block: unknown) => block is HikkakuBlock;
72
+ declare const menuInput: <T extends PrimitiveAvailableOnScratch>(source: PrimitiveSource<T>, createMenu: (source?: T) => HikkakuBlock) => sb3.Input;
73
+ declare const isCostumeReference: (source: unknown) => source is CostumeReference;
74
+ declare const isSoundReference: (source: unknown) => source is SoundReference;
70
75
  //#endregion
71
76
  //#region src/core/composer.d.ts
72
77
  type Handler = () => void;
@@ -152,4 +157,4 @@ declare class Project {
152
157
  getAdditionalAssets(): Map<string, Uint8Array>;
153
158
  }
154
159
  //#endregion
155
- export { VariableMonitorMode as A, PrimitiveAvailableOnScratch as C, SoundSource as D, SoundReference as E, VariableReference as M, VariableBase as O, MonitorPosition as S, SoundData as T, CreateListOptions as _, Handler as a, ListMonitorOptions as b, createBlocks as c, fromCostumeSource as d, fromPrimitiveSource as f, CostumeSource as g, CostumeReference as h, BlockInit as i, VariableMonitorOptions as j, VariableDefinition as k, substack as l, CostumeData as m, SpriteOptions as n, attachStack as o, fromSoundSource as p, Target as r, block as s, Project as t, valueBlock as u, CreateVariableOptions as v, PrimitiveSource as w, ListReference as x, HikkakuBlock as y };
160
+ export { SoundData as A, CreateVariableOptions as C, MonitorPosition as D, ListReference as E, VariableMonitorMode as F, VariableMonitorOptions as I, VariableReference as L, SoundSource as M, VariableBase as N, PrimitiveAvailableOnScratch as O, VariableDefinition as P, CreateListOptions as S, ListMonitorOptions as T, unwrapCostumeSource as _, Handler as a, CostumeReference as b, createBlocks as c, fromPrimitiveSource as d, fromPrimitiveSourceColor as f, menuInput as g, isSoundReference as h, BlockInit as i, SoundReference as j, PrimitiveSource as k, substack as l, isHikkakuBlock as m, SpriteOptions as n, attachStack as o, isCostumeReference as p, Target as r, block as s, Project as t, valueBlock as u, unwrapSoundSource as v, HikkakuBlock as w, CostumeSource as x, CostumeData as y };
package/vite/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { zip } from "fflate";
2
1
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
3
2
  import * as path from "node:path";
4
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
+ import { zip, zipSync } from "fflate/node";
5
5
  import { createServerModuleRunner } from "vite";
6
6
  import crypto from "node:crypto";
7
7
 
@@ -81,6 +81,7 @@ function hikkaku(init) {
81
81
  await builder.build(env);
82
82
  },
83
83
  async generateBundle(_options, bundle) {
84
+ if (this.environment.name !== "hikkaku") return;
84
85
  const tmpDir = path.join(process.cwd(), "dist", ".tmp");
85
86
  for (const [filePath, file] of Object.entries(bundle)) if (file.type === "chunk") {
86
87
  const fullPath = path.join(tmpDir, filePath);
@@ -90,13 +91,22 @@ function hikkaku(init) {
90
91
  const { default: project } = await import(pathToFileURL(path.join(process.cwd(), "dist/.tmp", "project.mjs")).href);
91
92
  const projectJSON = project.toScratch();
92
93
  const assets = project.getAdditionalAssets();
93
- const zipData = await new Promise((resolve, reject) => {
94
- zip({
95
- "project.json": new TextEncoder().encode(JSON.stringify(projectJSON)),
96
- ...Object.fromEntries(assets.entries())
97
- }, (err, data) => {
98
- if (err) reject(err);
99
- else resolve(data);
94
+ const projectJSONData = new TextEncoder().encode(JSON.stringify(projectJSON));
95
+ const assetsToBundle = {
96
+ ...Object.fromEntries(assets.entries()),
97
+ "project.json": projectJSONData
98
+ };
99
+ let has160KBAsset = false;
100
+ for (const data of Object.values(assetsToBundle)) if (data.length >= 16e4) {
101
+ has160KBAsset = true;
102
+ break;
103
+ }
104
+ const zipData = has160KBAsset && globalThis?.navigator?.userAgent.includes("Bun") ? zipSync(assetsToBundle) : await new Promise((resolve, reject) => {
105
+ zip(assetsToBundle, (err, data) => {
106
+ if (err) {
107
+ console.error(err);
108
+ reject(err);
109
+ } else resolve(data);
100
110
  });
101
111
  });
102
112
  this.emitFile({