hikkaku 0.2.0 → 0.3.0

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.
@@ -1,4 +1,4 @@
1
- import { S as PrimitiveSource, _ as HikkakuBlock, k as VariableReference, m as CostumeSource, w as SoundSource, y as ListReference } from "../project-Ca9rsVT3.mjs";
1
+ import { D as SoundSource, M as VariableReference, g as CostumeSource, w as PrimitiveSource, x as ListReference, y as HikkakuBlock } from "../project-djJPtrq7.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';
@@ -1394,6 +1394,154 @@ declare const getY: () => HikkakuBlock;
1394
1394
  */
1395
1395
  declare const getDirection: () => HikkakuBlock;
1396
1396
  //#endregion
1397
+ //#region src/blocks/music.d.ts
1398
+ /**
1399
+ * Plays drum for beats.
1400
+ *
1401
+ * Input: `drum`, `beats`.
1402
+ * Output: Scratch statement block definition that is appended to the current script stack.
1403
+ *
1404
+ * @param drum See function signature for accepted input values.
1405
+ * @param beats See function signature for accepted input values.
1406
+ * @returns Scratch statement block definition that is appended to the current script stack.
1407
+ * @example
1408
+ * ```ts
1409
+ * import { playDrumForBeats } from 'hikkaku/blocks'
1410
+ *
1411
+ * playDrumForBeats(1, 0.25)
1412
+ * ```
1413
+ */
1414
+ declare const playDrumForBeats: (drum: PrimitiveSource<number>, beats: PrimitiveSource<number>) => HikkakuBlock;
1415
+ /**
1416
+ * Plays drum for beats with MIDI drum mapping.
1417
+ *
1418
+ * Input: `drum`, `beats`.
1419
+ * Output: Scratch statement block definition that is appended to the current script stack.
1420
+ *
1421
+ * @param drum See function signature for accepted input values.
1422
+ * @param beats See function signature for accepted input values.
1423
+ * @returns Scratch statement block definition that is appended to the current script stack.
1424
+ * @example
1425
+ * ```ts
1426
+ * import { midiPlayDrumForBeats } from 'hikkaku/blocks'
1427
+ *
1428
+ * midiPlayDrumForBeats(36, 0.25)
1429
+ * ```
1430
+ */
1431
+ declare const midiPlayDrumForBeats: (drum: PrimitiveSource<number>, beats: PrimitiveSource<number>) => HikkakuBlock;
1432
+ /**
1433
+ * Rests for beats.
1434
+ *
1435
+ * Input: `beats`.
1436
+ * Output: Scratch statement block definition that is appended to the current script stack.
1437
+ *
1438
+ * @param beats See function signature for accepted input values.
1439
+ * @returns Scratch statement block definition that is appended to the current script stack.
1440
+ * @example
1441
+ * ```ts
1442
+ * import { restForBeats } from 'hikkaku/blocks'
1443
+ *
1444
+ * restForBeats(0.25)
1445
+ * ```
1446
+ */
1447
+ declare const restForBeats: (beats: PrimitiveSource<number>) => HikkakuBlock;
1448
+ /**
1449
+ * Plays note for beats.
1450
+ *
1451
+ * Input: `note`, `beats`.
1452
+ * Output: Scratch statement block definition that is appended to the current script stack.
1453
+ *
1454
+ * @param note See function signature for accepted input values.
1455
+ * @param beats See function signature for accepted input values.
1456
+ * @returns Scratch statement block definition that is appended to the current script stack.
1457
+ * @example
1458
+ * ```ts
1459
+ * import { playNoteForBeats } from 'hikkaku/blocks'
1460
+ *
1461
+ * playNoteForBeats(60, 0.25)
1462
+ * ```
1463
+ */
1464
+ declare const playNoteForBeats: (note: PrimitiveSource<number>, beats: PrimitiveSource<number>) => HikkakuBlock;
1465
+ /**
1466
+ * Sets instrument.
1467
+ *
1468
+ * Input: `instrument`.
1469
+ * Output: Scratch statement block definition that is appended to the current script stack.
1470
+ *
1471
+ * @param instrument See function signature for accepted input values.
1472
+ * @returns Scratch statement block definition that is appended to the current script stack.
1473
+ * @example
1474
+ * ```ts
1475
+ * import { setInstrument } from 'hikkaku/blocks'
1476
+ *
1477
+ * setInstrument(1)
1478
+ * ```
1479
+ */
1480
+ declare const setInstrument: (instrument: PrimitiveSource<number>) => HikkakuBlock;
1481
+ /**
1482
+ * Sets instrument with MIDI instrument mapping.
1483
+ *
1484
+ * Input: `instrument`.
1485
+ * Output: Scratch statement block definition that is appended to the current script stack.
1486
+ *
1487
+ * @param instrument See function signature for accepted input values.
1488
+ * @returns Scratch statement block definition that is appended to the current script stack.
1489
+ * @example
1490
+ * ```ts
1491
+ * import { midiSetInstrument } from 'hikkaku/blocks'
1492
+ *
1493
+ * midiSetInstrument(1)
1494
+ * ```
1495
+ */
1496
+ declare const midiSetInstrument: (instrument: PrimitiveSource<number>) => HikkakuBlock;
1497
+ /**
1498
+ * Sets tempo.
1499
+ *
1500
+ * Input: `tempo`.
1501
+ * Output: Scratch statement block definition that is appended to the current script stack.
1502
+ *
1503
+ * @param tempo See function signature for accepted input values.
1504
+ * @returns Scratch statement block definition that is appended to the current script stack.
1505
+ * @example
1506
+ * ```ts
1507
+ * import { setTempo } from 'hikkaku/blocks'
1508
+ *
1509
+ * setTempo(60)
1510
+ * ```
1511
+ */
1512
+ declare const setTempo: (tempo: PrimitiveSource<number>) => HikkakuBlock;
1513
+ /**
1514
+ * Changes tempo.
1515
+ *
1516
+ * Input: `tempo`.
1517
+ * Output: Scratch statement block definition that is appended to the current script stack.
1518
+ *
1519
+ * @param tempo See function signature for accepted input values.
1520
+ * @returns Scratch statement block definition that is appended to the current script stack.
1521
+ * @example
1522
+ * ```ts
1523
+ * import { changeTempo } from 'hikkaku/blocks'
1524
+ *
1525
+ * changeTempo(20)
1526
+ * ```
1527
+ */
1528
+ declare const changeTempo: (tempo: PrimitiveSource<number>) => HikkakuBlock;
1529
+ /**
1530
+ * Returns tempo.
1531
+ *
1532
+ * Input: none.
1533
+ * Output: Scratch reporter block definition that can be used as an input value in other blocks.
1534
+ *
1535
+ * @returns Scratch reporter block definition that can be used as an input value in other blocks.
1536
+ * @example
1537
+ * ```ts
1538
+ * import { getTempo } from 'hikkaku/blocks'
1539
+ *
1540
+ * getTempo()
1541
+ * ```
1542
+ */
1543
+ declare const getTempo: () => HikkakuBlock;
1544
+ //#endregion
1397
1545
  //#region src/blocks/operator.d.ts
1398
1546
  /**
1399
1547
  * Addition.
@@ -2422,9 +2570,18 @@ type SoundEffect = 'pitch' | 'pan';
2422
2570
  * @returns Scratch statement block definition that is appended to the current script stack.
2423
2571
  * @example
2424
2572
  * ```ts
2573
+ * import { Project } from 'hikkaku'
2574
+ * import { SOUNDS } from 'hikkaku/assets'
2425
2575
  * import { playSound } from 'hikkaku/blocks'
2426
2576
  *
2427
- * playSound('pop')
2577
+ * const project = new Project()
2578
+ * const sprite = project.createSprite('Sprite')
2579
+ * const sound = sprite.addSound({
2580
+ * ...SOUNDS.COMPUTER_BEEP,
2581
+ * name: 'beep',
2582
+ * })
2583
+ *
2584
+ * playSound(sound)
2428
2585
  * ```
2429
2586
  */
2430
2587
  declare const playSound: (sound: SoundSource) => HikkakuBlock;
@@ -2438,9 +2595,17 @@ declare const playSound: (sound: SoundSource) => HikkakuBlock;
2438
2595
  * @returns Scratch statement block definition that is appended to the current script stack.
2439
2596
  * @example
2440
2597
  * ```ts
2598
+ * import { Project } from 'hikkaku'
2599
+ * import { SOUNDS } from 'hikkaku/assets'
2441
2600
  * import { playSoundUntilDone } from 'hikkaku/blocks'
2442
2601
  *
2443
- * playSoundUntilDone('pop')
2602
+ * const project = new Project()
2603
+ * const sound = project.addSound({
2604
+ * ...SOUNDS.COMPUTER_BEEP,
2605
+ * name: 'beep',
2606
+ * })
2607
+ *
2608
+ * playSoundUntilDone(sound)
2444
2609
  * ```
2445
2610
  */
2446
2611
  declare const playSoundUntilDone: (sound: SoundSource) => HikkakuBlock;
@@ -2556,4 +2721,4 @@ declare const changeVolumeBy: (value: PrimitiveSource<number>) => HikkakuBlock;
2556
2721
  */
2557
2722
  declare const getVolume: () => HikkakuBlock;
2558
2723
  //#endregion
2559
- 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, 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, 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, mod, moveSteps, multiply, nextBackdrop, nextCostume, not, or, penDown, penUp, playSound, playSoundUntilDone, pointInDirection, pointTowards, procedureBoolean, procedureLabel, procedureStringOrNumber, random, repeat, repeatUntil, repeatWhile, replaceItemOfList, resetTimer, round, say, sayForSecs, setDragMode, setLooksEffectTo, setPenColorParamTo, setPenColorTo, setPenColorToColor, setPenHueToNumber, setPenShadeToNumber, setPenSizeTo, setRotationStyle, setSizeTo, setSoundEffectTo, 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 };
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 };
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-BudVTTBs.mjs";
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";
2
2
 
3
3
  //#region src/blocks/control.ts
4
4
  /**
@@ -1703,6 +1703,182 @@ const getDirection = () => {
1703
1703
  return valueBlock("motion_direction", {});
1704
1704
  };
1705
1705
 
1706
+ //#endregion
1707
+ //#region src/blocks/music.ts
1708
+ /**
1709
+ * Plays drum for beats.
1710
+ *
1711
+ * Input: `drum`, `beats`.
1712
+ * Output: Scratch statement block definition that is appended to the current script stack.
1713
+ *
1714
+ * @param drum See function signature for accepted input values.
1715
+ * @param beats See function signature for accepted input values.
1716
+ * @returns Scratch statement block definition that is appended to the current script stack.
1717
+ * @example
1718
+ * ```ts
1719
+ * import { playDrumForBeats } from 'hikkaku/blocks'
1720
+ *
1721
+ * playDrumForBeats(1, 0.25)
1722
+ * ```
1723
+ */
1724
+ const playDrumForBeats = (drum, beats) => {
1725
+ return block("music_playDrumForBeats", { inputs: {
1726
+ DRUM: fromPrimitiveSource(drum),
1727
+ BEATS: fromPrimitiveSource(beats)
1728
+ } });
1729
+ };
1730
+ /**
1731
+ * Plays drum for beats with MIDI drum mapping.
1732
+ *
1733
+ * Input: `drum`, `beats`.
1734
+ * Output: Scratch statement block definition that is appended to the current script stack.
1735
+ *
1736
+ * @param drum See function signature for accepted input values.
1737
+ * @param beats See function signature for accepted input values.
1738
+ * @returns Scratch statement block definition that is appended to the current script stack.
1739
+ * @example
1740
+ * ```ts
1741
+ * import { midiPlayDrumForBeats } from 'hikkaku/blocks'
1742
+ *
1743
+ * midiPlayDrumForBeats(36, 0.25)
1744
+ * ```
1745
+ */
1746
+ const midiPlayDrumForBeats = (drum, beats) => {
1747
+ return block("music_midiPlayDrumForBeats", { inputs: {
1748
+ DRUM: fromPrimitiveSource(drum),
1749
+ BEATS: fromPrimitiveSource(beats)
1750
+ } });
1751
+ };
1752
+ /**
1753
+ * Rests for beats.
1754
+ *
1755
+ * Input: `beats`.
1756
+ * Output: Scratch statement block definition that is appended to the current script stack.
1757
+ *
1758
+ * @param beats See function signature for accepted input values.
1759
+ * @returns Scratch statement block definition that is appended to the current script stack.
1760
+ * @example
1761
+ * ```ts
1762
+ * import { restForBeats } from 'hikkaku/blocks'
1763
+ *
1764
+ * restForBeats(0.25)
1765
+ * ```
1766
+ */
1767
+ const restForBeats = (beats) => {
1768
+ return block("music_restForBeats", { inputs: { BEATS: fromPrimitiveSource(beats) } });
1769
+ };
1770
+ /**
1771
+ * Plays note for beats.
1772
+ *
1773
+ * Input: `note`, `beats`.
1774
+ * Output: Scratch statement block definition that is appended to the current script stack.
1775
+ *
1776
+ * @param note See function signature for accepted input values.
1777
+ * @param beats See function signature for accepted input values.
1778
+ * @returns Scratch statement block definition that is appended to the current script stack.
1779
+ * @example
1780
+ * ```ts
1781
+ * import { playNoteForBeats } from 'hikkaku/blocks'
1782
+ *
1783
+ * playNoteForBeats(60, 0.25)
1784
+ * ```
1785
+ */
1786
+ const playNoteForBeats = (note, beats) => {
1787
+ return block("music_playNoteForBeats", { inputs: {
1788
+ NOTE: fromPrimitiveSource(note),
1789
+ BEATS: fromPrimitiveSource(beats)
1790
+ } });
1791
+ };
1792
+ /**
1793
+ * Sets instrument.
1794
+ *
1795
+ * Input: `instrument`.
1796
+ * Output: Scratch statement block definition that is appended to the current script stack.
1797
+ *
1798
+ * @param instrument See function signature for accepted input values.
1799
+ * @returns Scratch statement block definition that is appended to the current script stack.
1800
+ * @example
1801
+ * ```ts
1802
+ * import { setInstrument } from 'hikkaku/blocks'
1803
+ *
1804
+ * setInstrument(1)
1805
+ * ```
1806
+ */
1807
+ const setInstrument = (instrument) => {
1808
+ return block("music_setInstrument", { inputs: { INSTRUMENT: fromPrimitiveSource(instrument) } });
1809
+ };
1810
+ /**
1811
+ * Sets instrument with MIDI instrument mapping.
1812
+ *
1813
+ * Input: `instrument`.
1814
+ * Output: Scratch statement block definition that is appended to the current script stack.
1815
+ *
1816
+ * @param instrument See function signature for accepted input values.
1817
+ * @returns Scratch statement block definition that is appended to the current script stack.
1818
+ * @example
1819
+ * ```ts
1820
+ * import { midiSetInstrument } from 'hikkaku/blocks'
1821
+ *
1822
+ * midiSetInstrument(1)
1823
+ * ```
1824
+ */
1825
+ const midiSetInstrument = (instrument) => {
1826
+ return block("music_midiSetInstrument", { inputs: { INSTRUMENT: fromPrimitiveSource(instrument) } });
1827
+ };
1828
+ /**
1829
+ * Sets tempo.
1830
+ *
1831
+ * Input: `tempo`.
1832
+ * Output: Scratch statement block definition that is appended to the current script stack.
1833
+ *
1834
+ * @param tempo See function signature for accepted input values.
1835
+ * @returns Scratch statement block definition that is appended to the current script stack.
1836
+ * @example
1837
+ * ```ts
1838
+ * import { setTempo } from 'hikkaku/blocks'
1839
+ *
1840
+ * setTempo(60)
1841
+ * ```
1842
+ */
1843
+ const setTempo = (tempo) => {
1844
+ return block("music_setTempo", { inputs: { TEMPO: fromPrimitiveSource(tempo) } });
1845
+ };
1846
+ /**
1847
+ * Changes tempo.
1848
+ *
1849
+ * Input: `tempo`.
1850
+ * Output: Scratch statement block definition that is appended to the current script stack.
1851
+ *
1852
+ * @param tempo See function signature for accepted input values.
1853
+ * @returns Scratch statement block definition that is appended to the current script stack.
1854
+ * @example
1855
+ * ```ts
1856
+ * import { changeTempo } from 'hikkaku/blocks'
1857
+ *
1858
+ * changeTempo(20)
1859
+ * ```
1860
+ */
1861
+ const changeTempo = (tempo) => {
1862
+ return block("music_changeTempo", { inputs: { TEMPO: fromPrimitiveSource(tempo) } });
1863
+ };
1864
+ /**
1865
+ * Returns tempo.
1866
+ *
1867
+ * Input: none.
1868
+ * Output: Scratch reporter block definition that can be used as an input value in other blocks.
1869
+ *
1870
+ * @returns Scratch reporter block definition that can be used as an input value in other blocks.
1871
+ * @example
1872
+ * ```ts
1873
+ * import { getTempo } from 'hikkaku/blocks'
1874
+ *
1875
+ * getTempo()
1876
+ * ```
1877
+ */
1878
+ const getTempo = () => {
1879
+ return valueBlock("music_getTempo", {});
1880
+ };
1881
+
1706
1882
  //#endregion
1707
1883
  //#region src/blocks/operator.ts
1708
1884
  /**
@@ -2960,9 +3136,18 @@ const getUsername = () => {
2960
3136
  * @returns Scratch statement block definition that is appended to the current script stack.
2961
3137
  * @example
2962
3138
  * ```ts
3139
+ * import { Project } from 'hikkaku'
3140
+ * import { SOUNDS } from 'hikkaku/assets'
2963
3141
  * import { playSound } from 'hikkaku/blocks'
2964
3142
  *
2965
- * playSound('pop')
3143
+ * const project = new Project()
3144
+ * const sprite = project.createSprite('Sprite')
3145
+ * const sound = sprite.addSound({
3146
+ * ...SOUNDS.COMPUTER_BEEP,
3147
+ * name: 'beep',
3148
+ * })
3149
+ *
3150
+ * playSound(sound)
2966
3151
  * ```
2967
3152
  */
2968
3153
  const playSound = (sound) => {
@@ -2978,9 +3163,17 @@ const playSound = (sound) => {
2978
3163
  * @returns Scratch statement block definition that is appended to the current script stack.
2979
3164
  * @example
2980
3165
  * ```ts
3166
+ * import { Project } from 'hikkaku'
3167
+ * import { SOUNDS } from 'hikkaku/assets'
2981
3168
  * import { playSoundUntilDone } from 'hikkaku/blocks'
2982
3169
  *
2983
- * playSoundUntilDone('pop')
3170
+ * const project = new Project()
3171
+ * const sound = project.addSound({
3172
+ * ...SOUNDS.COMPUTER_BEEP,
3173
+ * name: 'beep',
3174
+ * })
3175
+ *
3176
+ * playSoundUntilDone(sound)
2984
3177
  * ```
2985
3178
  */
2986
3179
  const playSoundUntilDone = (sound) => {
@@ -3119,4 +3312,4 @@ const getVolume = () => {
3119
3312
  };
3120
3313
 
3121
3314
  //#endregion
3122
- export { CREATE_CLONE_MYSELF, add, addToList, allAtOnce, and, argumentReporterBoolean, argumentReporterStringNumber, askAndWait, broadcast, broadcastAndWait, callProcedure, changeLooksEffectBy, changePenColorParamBy, changePenHueBy, changePenShadeBy, changePenSizeBy, changeSizeBy, changeSoundEffectBy, 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, 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, mod, moveSteps, multiply, nextBackdrop, nextCostume, not, or, penDown, penUp, playSound, playSoundUntilDone, pointInDirection, pointTowards, procedureBoolean, procedureLabel, procedureStringOrNumber, random, repeat, repeatUntil, repeatWhile, replaceItemOfList, resetTimer, round, say, sayForSecs, setDragMode, setLooksEffectTo, setPenColorParamTo, setPenColorTo, setPenColorToColor, setPenHueToNumber, setPenShadeToNumber, setPenSizeTo, setRotationStyle, setSizeTo, setSoundEffectTo, 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 };
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 };
@@ -0,0 +1,18 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (!no_symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __exportAll as t };
package/client/index.mjs CHANGED
@@ -35,7 +35,14 @@ const getScratchInternalStates = (root) => {
35
35
  }
36
36
  return false;
37
37
  });
38
- vm.runtime.storage.webHelper.assetTool.tools.splice(0, 1);
38
+ const storage = vm.runtime.storage;
39
+ storage.webHelper.assetTool.tools.splice(0, 1);
40
+ storage.webHelper.stores.splice(0, storage.webHelper.stores.length);
41
+ storage.addWebStore([
42
+ storage.AssetType.ImageVector,
43
+ storage.AssetType.ImageBitmap,
44
+ storage.AssetType.Sound
45
+ ], (asset) => `/hikkaku-assets/${asset.assetId}.${asset.dataFormat}`, null, null);
39
46
  return {
40
47
  reduxState,
41
48
  vm,
package/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as SoundReference, D as VariableMonitorMode, E as VariableDefinition, O as VariableMonitorOptions, S as PrimitiveSource, T as VariableBase, _ as HikkakuBlock, a as attachStack, b as MonitorPosition, c as substack, d as fromPrimitiveSource, f as fromSoundSource, g as CreateVariableOptions, h as CreateListOptions, i as Handler, k as VariableReference, l as valueBlock, m as CostumeSource, n as Target, o as block, p as CostumeReference, r as BlockInit, s as createBlocks, t as Project, u as fromCostumeSource, v as ListMonitorOptions, w as SoundSource, x as PrimitiveAvailableOnScratch, y as ListReference } from "./project-Ca9rsVT3.mjs";
2
- export { BlockInit, CostumeReference, CostumeSource, CreateListOptions, CreateVariableOptions, Handler, HikkakuBlock, ListMonitorOptions, ListReference, MonitorPosition, PrimitiveAvailableOnScratch, PrimitiveSource, Project, SoundReference, SoundSource, Target, VariableBase, VariableDefinition, VariableMonitorMode, VariableMonitorOptions, VariableReference, attachStack, block, createBlocks, fromCostumeSource, fromPrimitiveSource, fromSoundSource, substack, valueBlock };
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 };
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-BudVTTBs.mjs";
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";
2
2
 
3
3
  //#region src/core/monitors.ts
4
4
  const createVariableMonitor = (id, name, defaultValue, spriteName, options) => {
@@ -86,9 +86,15 @@ var Target = class {
86
86
  #monitors = [];
87
87
  #costumes = [];
88
88
  #sounds = [];
89
- constructor(isStage, name) {
89
+ #size;
90
+ #x;
91
+ #y;
92
+ constructor(isStage, name, options) {
90
93
  this.isStage = isStage;
91
94
  this.name = name;
95
+ this.#size = options?.size;
96
+ this.#x = options?.x;
97
+ this.#y = options?.y;
92
98
  }
93
99
  run(handler) {
94
100
  const blocks = createBlocks(() => {
@@ -171,9 +177,18 @@ var Target = class {
171
177
  ...target,
172
178
  isStage: false,
173
179
  name: this.name,
174
- visible: true
180
+ visible: true,
181
+ size: this.#size,
182
+ x: this.#x,
183
+ y: this.#y
175
184
  };
176
185
  }
186
+ getAdditionalAssets() {
187
+ const assets = /* @__PURE__ */ new Map();
188
+ for (const costume of this.#costumes) if (costume._data) assets.set(`${costume.assetId}.${costume.dataFormat}`, costume._data);
189
+ for (const sound of this.#sounds) if (sound._data) assets.set(`${sound.assetId}.${sound.dataFormat}`, sound._data);
190
+ return assets;
191
+ }
177
192
  };
178
193
  var Project = class {
179
194
  stage;
@@ -183,11 +198,17 @@ var Project = class {
183
198
  this.stage = target;
184
199
  this.#targets.push(target);
185
200
  }
186
- createSprite(name) {
187
- const sprite = new Target(false, name);
201
+ createSprite(name, options) {
202
+ const sprite = new Target(false, name, options);
188
203
  this.#targets.push(sprite);
189
204
  return sprite;
190
205
  }
206
+ addCostume(costume) {
207
+ return this.stage.addCostume(costume);
208
+ }
209
+ addSound(sound) {
210
+ return this.stage.addSound(sound);
211
+ }
191
212
  toScratch() {
192
213
  const targets = this.#targets.map((target) => target.toScratch());
193
214
  return {
@@ -200,6 +221,11 @@ var Project = class {
200
221
  }
201
222
  };
202
223
  }
224
+ getAdditionalAssets() {
225
+ const assets = /* @__PURE__ */ new Map();
226
+ for (const target of this.#targets) for (const [key, value] of target.getAdditionalAssets()) assets.set(key, value);
227
+ return assets;
228
+ }
203
229
  };
204
230
 
205
231
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hikkaku",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "exports": {
@@ -23,6 +23,10 @@
23
23
  "./vite": {
24
24
  "import": "./vite/index.mjs",
25
25
  "types": "./vite/index.d.mts"
26
+ },
27
+ "./types": {
28
+ "import": "./types.d.mjs",
29
+ "types": "./types.d.mts"
26
30
  }
27
31
  },
28
32
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  import * as sb3 from "sb3-types";
2
+ import { Costume, Sound } from "sb3-types";
2
3
 
3
4
  //#region src/core/types.d.ts
4
5
  type PrimitiveAvailableOnScratch = number | boolean | string;
@@ -55,6 +56,12 @@ interface HikkakuBlock {
55
56
  isBlock: true;
56
57
  id: string;
57
58
  }
59
+ type CostumeData = Costume & {
60
+ _data?: Uint8Array;
61
+ };
62
+ type SoundData = Sound & {
63
+ _data?: Uint8Array;
64
+ };
58
65
  //#endregion
59
66
  //#region src/core/block-helper.d.ts
60
67
  declare const fromPrimitiveSource: <T extends PrimitiveAvailableOnScratch>(source: PrimitiveSource<T>) => sb3.Input;
@@ -114,26 +121,35 @@ interface ListMonitor {
114
121
  type Monitor = VariableMonitor | ListMonitor;
115
122
  //#endregion
116
123
  //#region src/core/project.d.ts
124
+ interface SpriteOptions {
125
+ size?: number;
126
+ x?: number;
127
+ y?: number;
128
+ }
117
129
  declare class Target<IsStage extends boolean = boolean> {
118
130
  #private;
119
131
  readonly isStage: IsStage;
120
132
  readonly name: IsStage extends true ? 'Stage' : string;
121
133
  currentCostume: number;
122
- constructor(isStage: IsStage, name: IsStage extends true ? 'Stage' : string);
134
+ constructor(isStage: IsStage, name: IsStage extends true ? 'Stage' : string, options?: IsStage extends false ? SpriteOptions : undefined);
123
135
  run(handler: (target: Target<IsStage>) => void): void;
124
136
  createVariable(name: string, defaultValue?: sb3.ScalarVal, isCloudVariableOrOptions?: boolean | CreateVariableOptions): VariableDefinition;
125
137
  createList(name: string, defaultValue?: sb3.ScalarVal[], options?: CreateListOptions): ListReference;
126
- addCostume(costume: sb3.Costume): CostumeReference;
127
- addSound(sound: sb3.Sound): SoundReference;
138
+ addCostume(costume: CostumeData): CostumeReference;
139
+ addSound(sound: SoundData): SoundReference;
128
140
  get monitors(): readonly Monitor[];
129
141
  toScratch(): IsStage extends true ? sb3.Stage : sb3.Sprite;
142
+ getAdditionalAssets(): Map<string, Uint8Array>;
130
143
  }
131
144
  declare class Project {
132
145
  #private;
133
146
  readonly stage: Target<true>;
134
147
  constructor();
135
- createSprite(name: string): Target<false>;
148
+ createSprite(name: string, options?: SpriteOptions): Target<false>;
149
+ addCostume(costume: CostumeData): CostumeReference;
150
+ addSound(sound: SoundData): SoundReference;
136
151
  toScratch(): sb3.ScratchProject;
152
+ getAdditionalAssets(): Map<string, Uint8Array>;
137
153
  }
138
154
  //#endregion
139
- export { SoundReference as C, VariableMonitorMode as D, VariableDefinition as E, VariableMonitorOptions as O, PrimitiveSource as S, VariableBase as T, HikkakuBlock as _, attachStack as a, MonitorPosition as b, substack as c, fromPrimitiveSource as d, fromSoundSource as f, CreateVariableOptions as g, CreateListOptions as h, Handler as i, VariableReference as k, valueBlock as l, CostumeSource as m, Target as n, block as o, CostumeReference as p, BlockInit as r, createBlocks as s, Project as t, fromCostumeSource as u, ListMonitorOptions as v, SoundSource as w, PrimitiveAvailableOnScratch as x, ListReference as y };
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 };
package/types.d.mts ADDED
@@ -0,0 +1,21 @@
1
+ //#region src/types.d.ts
2
+ declare module '*.svg?scratch' {
3
+ import * as sb3 from 'sb3-types';
4
+ const content: sb3.Costume;
5
+ export default content;
6
+ }
7
+ declare module '*.png?scratch' {
8
+ import * as sb3 from 'sb3-types';
9
+ const content: sb3.Costume;
10
+ export default content;
11
+ }
12
+ declare module '*.wav?scratch' {
13
+ import * as sb3 from 'sb3-types';
14
+ const content: sb3.Sound;
15
+ export default content;
16
+ }
17
+ declare module '*.mp3?scratch' {
18
+ import * as sb3 from 'sb3-types';
19
+ const content: sb3.Sound;
20
+ export default content;
21
+ }