@turbowarp/types 0.0.13 → 0.0.15

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,15 +0,0 @@
1
- import VM from 'scratch-vm';
2
-
3
- const vm = new VM();
4
- const callback = (i: unknown) => console.log(i);
5
-
6
- vm.on('VISUAL_REPORT', callback);
7
- vm.off('VISUAL_REPORT', callback);
8
- vm.listeners('VISUAL_REPORT').forEach((i) => i({
9
- id: 'def',
10
- value: 'xyz'
11
- }));
12
- vm.emit('VISUAL_REPORT', {
13
- id: 'abc',
14
- value: 'def'
15
- });
@@ -1,16 +0,0 @@
1
- declare const stream: JSZip.StreamHelper<'uint8array'>;
2
-
3
- stream.on('data', data => {
4
- data as Uint8Array
5
- });
6
- stream.on('data', (data, metadata) => {
7
- metadata.percent as number
8
- });
9
-
10
- stream.pause();
11
- stream.resume();
12
-
13
- // @ts-expect-error
14
- stream.on('whatever', () => {
15
-
16
- });
@@ -1,25 +0,0 @@
1
- import AudioEngine from 'scratch-audio';
2
-
3
- declare const vm: VM;
4
- const audioEngine = new AudioEngine();
5
- vm.attachAudioEngine(audioEngine);
6
-
7
- audioEngine.decodeSoundPlayer({
8
- data: {
9
- buffer: new ArrayBuffer(10)
10
- }
11
- })
12
- .then((player) => {
13
- player.on('stop', () => {
14
-
15
- });
16
- return player.finished();
17
- });
18
-
19
- declare const pitchEffect: AudioEngine.PitchEffect;
20
- pitchEffect.ratio as number
21
- pitchEffect.updatePlayers([]);
22
-
23
- declare const soundPlayer: AudioEngine.SoundPlayer;
24
-
25
- new audioEngine.effects[0](audioEngine, soundPlayer, pitchEffect);
@@ -1,16 +0,0 @@
1
- declare const state: ScratchGUI.ReduxState;
2
- declare function dispatch(event: ScratchGUI.ReduxEvent): void;
3
-
4
- const vm = state.scratchGui.vm;
5
- vm.greenFlag();
6
- vm.renderer._allDrawables[0].updateVisible(false);
7
-
8
- dispatch({
9
- type: 'scratch-gui/navigation/ACTIVATE_TAB',
10
- activeTabIndex: 0
11
- });
12
-
13
- state.scratchPaint.cursor.charAt(0);
14
- dispatch({
15
- type: 'scratch-paint/undo/CLEAR'
16
- });
@@ -1,9 +0,0 @@
1
- import unpack from 'scratch-parser';
2
-
3
- unpack('{}', false, (error, unpacked) => {
4
- if (error) {
5
- console.error(error);
6
- } else {
7
- const [target, zip] = unpacked;
8
- }
9
- });
@@ -1,4 +0,0 @@
1
- import getFonts from 'scratch-render-fonts';
2
-
3
- const fonts = getFonts();
4
- console.log(atob(fonts['Curly']));
@@ -1,8 +0,0 @@
1
- const canvas = document.createElement('canvas');
2
- const renderer = new RenderWebGL(canvas, 100, 200, 100, 200);
3
-
4
- // updateDrawableProperties should be deprecated
5
- renderer.updateDrawableProperties(10, {
6
- whirl: 10,
7
- position: [20, 30]
8
- });
@@ -1,37 +0,0 @@
1
- import ScratchStorage from 'scratch-storage';
2
-
3
- declare const vm: VM;
4
-
5
- const storage = new ScratchStorage();
6
- vm.attachStorage(storage);
7
-
8
- ScratchStorage.DataFormat.JPG === 'jpg';
9
- storage.DataFormat.JPG === 'jpg';
10
-
11
- storage.addWebStore(
12
- [
13
- ScratchStorage.AssetType.ImageVector,
14
- ScratchStorage.AssetType.ImageBitmap,
15
- storage.AssetType.Sound,
16
- ],
17
- asset => {
18
- const assetId = asset.assetId;
19
- const dataFormat = asset.dataFormat;
20
- return `https://assets.scratch.mit.edu/${assetId}.${dataFormat}`;
21
- }
22
- );
23
-
24
- storage.createAsset(
25
- storage.AssetType.ImageBitmap,
26
- storage.DataFormat.PNG,
27
- new Uint8Array([]),
28
- null,
29
- true
30
- ) as ScratchStorage.Asset;
31
- storage.createAsset(
32
- storage.AssetType.ImageBitmap,
33
- storage.DataFormat.PNG,
34
- new Uint8Array([]),
35
- "1234567",
36
- false
37
- ) as ScratchStorage.Asset;
@@ -1,8 +0,0 @@
1
- import * as SvgRenderer from 'scratch-svg-renderer';
2
-
3
- const svg = SvgRenderer.loadSvgString('imagine that this is an SVG', false);
4
- const serialized = SvgRenderer.serializeSvgToString(svg);
5
- const inlinedFonts = SvgRenderer.inlineSvgFonts('an svg here');
6
- const fixedFonts = SvgRenderer.convertFonts(SvgRenderer.SvgElement.create('svg'));
7
-
8
- const bitmapAdapter = new SvgRenderer.BitmapAdapter();
@@ -1,105 +0,0 @@
1
- (function(Scratch) {
2
- 'use strict';
3
-
4
- class Fetch {
5
- /** @returns {Scratch.Info} */
6
- getInfo () {
7
- return {
8
- id: 'fetch',
9
- name: 'Fetch',
10
- blocks: [
11
- {
12
- opcode: 'get',
13
- blockType: Scratch.BlockType.REPORTER,
14
- text: 'GET [URL]',
15
- arguments: {
16
- URL: {
17
- type: Scratch.ArgumentType.STRING,
18
- defaultValue: 'https://extensions.turbowarp.org/hello.txt'
19
- }
20
- }
21
- },
22
- '---',
23
- {
24
- opcode: 'test',
25
- text: 'test [STRING] [IMAGE] [BOOLEAN] [NUMBER] [MATRIX] [NOTE] [ANGLE] [COLOR]',
26
- blockType: Scratch.BlockType.COMMAND,
27
- hideFromPalette: false,
28
- isTerminal: true,
29
- arguments: {
30
- STRING: {
31
- type: Scratch.ArgumentType.STRING,
32
- defaultValue: 'test',
33
- menu: 'test1'
34
- },
35
- IMAGE: {
36
- type: Scratch.ArgumentType.IMAGE,
37
- dataURI: 'https://extensions.turbowarp.org/dango.png'
38
- },
39
- BOOLEAN: {
40
- type: Scratch.ArgumentType.BOOLEAN
41
- },
42
- NUMBER: {
43
- type: Scratch.ArgumentType.NUMBER,
44
- defaultValue: 5,
45
- },
46
- MATRIX: {
47
- type: Scratch.ArgumentType.MATRIX,
48
- defaultValue: '0101001010000001000101110'
49
- },
50
- NOTE: {
51
- type: Scratch.ArgumentType.NOTE,
52
- defaultValue: '30'
53
- },
54
- ANGLE: {
55
- type: Scratch.ArgumentType.ANGLE,
56
- defaultValue: 30
57
- },
58
- COLOR: {
59
- type: Scratch.ArgumentType.COLOR,
60
- defaultValue: '#123456'
61
- }
62
- }
63
- },
64
- {
65
- blockType: Scratch.BlockType.BUTTON,
66
- func: 'MAKE_A_VARIABLE',
67
- text: 'button text'
68
- }
69
- ],
70
- menus: {
71
- test1: ['1', '2', '3'],
72
- test2: {
73
- acceptReporters: false,
74
- items: [
75
- { text: 'text', value: 'value' },
76
- 'another value'
77
- ]
78
- }
79
- }
80
- };
81
- }
82
-
83
- /**
84
- * @param {{URL: string;}} args
85
- */
86
- get (args) {
87
- return fetch(args.URL)
88
- .then(r => r.text())
89
- .catch(() => '');
90
- }
91
-
92
- /**
93
- * @param {unknown} args
94
- */
95
- test (args) {
96
- console.log(args);
97
- }
98
- }
99
-
100
- if (Scratch.extensions.unsandboxed) {
101
- // ...
102
- }
103
-
104
- Scratch.extensions.register(new Fetch());
105
- })(Scratch);
@@ -1,84 +0,0 @@
1
- import VM from 'scratch-vm';
2
- import AudioEngine from 'scratch-audio';
3
-
4
- const vm = new VM();
5
- const runtime = vm.runtime;
6
-
7
- runtime.on('SCRIPT_GLOW_ON', (glowData) => {
8
- const id: string = glowData.id;
9
- });
10
- vm.on('SCRIPT_GLOW_OFF', (glowData) => {
11
- const id: string = glowData.id;
12
- });
13
-
14
- vm.emit('targetsUpdate', {
15
- targetList: [],
16
- editingTarget: 'abc 123'
17
- });
18
-
19
- const target = vm.runtime.getSpriteTargetByName('Sprite1');
20
- if (target) {
21
- const variable = target.lookupVariableByNameAndType('test', 'list');
22
- if (variable) {
23
- const name: string = variable.name;
24
- const upToDate: boolean | undefined = variable._monitorUpToDate;
25
- variable.value.filter(i => i.toString());
26
- }
27
-
28
- target.lookupOrCreateVariable(')(!@*#)!(@#*()', 'my variable').value;
29
-
30
- // @ts-expect-error
31
- target.lookupVariableById('#@)$(*%)(#').id;
32
-
33
- target.effects.ghost += 10;
34
-
35
- const block = target.blocks.getBlock('123');
36
- if (!block) {
37
- throw new Error('no block :(');
38
- }
39
- if (block.opcode === 'procedures_call') {
40
- const mutation = block.mutation as VM.ProcedureCallMutation;
41
- JSON.parse(mutation.argumentids);
42
- }
43
-
44
- const bubbleState = target.getCustomState('Scratch.looks');
45
- if (bubbleState) {
46
- bubbleState.text.charAt(0);
47
- target.setCustomState('Scratch.looks', bubbleState);
48
- }
49
-
50
- target.on('TARGET_MOVED', (target, fromX, fromY, forced) => {
51
- const id: string = target.id;
52
- const x: number = fromX;
53
- const y: number = fromY;
54
- const f: boolean | undefined = forced;
55
- })
56
- target.on('EVENT_TARGET_VISUAL_CHANGE', (target) => {
57
- const id: string = target.id;
58
- });
59
-
60
- runtime.on('STOP_FOR_TARGET', (t: VM.RenderedTarget) => {
61
-
62
- });
63
- } else {
64
- const doesNotExist: undefined = target;
65
- }
66
-
67
- runtime._editingTarget as VM.Target;
68
- runtime.getEditingTarget() as VM.Target;
69
-
70
- const audioEngine = new AudioEngine();
71
- vm.attachAudioEngine(audioEngine);
72
- audioEngine.audioContext.suspend();
73
-
74
- vm.setTurboMode(true);
75
- vm.runtime.turboMode as boolean
76
- vm.setCompatibilityMode(true);
77
- vm.runtime.compatibilityMode as boolean
78
-
79
- const costume = vm.runtime.getTargetForStage()?.getCostumes()?.[0];
80
- costume?.skinId as number;
81
-
82
- declare const util: VM.BlockUtility;
83
- util.startHats('hats', {BROADCAST_OPTION: 'test'}) as VM.Thread[];
84
- util.ioQuery('mouse', 'getIsDown', []);
@@ -1,29 +0,0 @@
1
- (function () {
2
- const ext = {};
3
-
4
- ext._getStatus = () => ({
5
- status: 2,
6
- msg: 'Ready'
7
- });
8
-
9
- ext.testReporter = () => Math.random();
10
-
11
- /**
12
- * @param {number} delay
13
- * @param {function} callback
14
- */
15
- ext.testReporterWait = (delay, callback) => {
16
- setTimeout(() => {
17
- callback(Math.random())
18
- }, delay * 1000);
19
- };
20
-
21
- var descriptor = {
22
- blocks: [
23
- ['r', 'test reporter', 'testReporter'],
24
- ['R', 'test reporter 2 %n', 'testReporterWait', '1'],
25
- ],
26
- };
27
-
28
- ScratchExtensions.register('ScratchX Test', descriptor, ext);
29
- }());
@@ -1,4 +0,0 @@
1
- import VM from 'scratch-vm';
2
-
3
- const vm = new VM();
4
- vm.clear();
@@ -1,4 +0,0 @@
1
- import VM = require('scratch-vm');
2
-
3
- const vm = new VM();
4
- vm.clear();