maze-blockly-wrapper 0.7.14 → 0.7.17

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 +1,58 @@
1
- import React from 'react';
2
- import type { DrawingConfig, GraphicsConfig, RunResult } from './types';
1
+ import React, { Component } from 'react';
2
+ import { type WithTranslation } from 'react-i18next';
3
+ import type { DrawingConfig, DrawingState, GraphicsConfig, RunResult } from './types';
3
4
  interface DrawingGameProps {
4
5
  className?: string;
5
6
  isEditable?: boolean;
6
7
  configuration?: DrawingConfig;
7
8
  onChange?: (config: DrawingConfig) => void;
8
9
  onRunFinish?: (result: RunResult) => void;
10
+ onReady?: (methods: {
11
+ getCurrentRunResult: () => RunResult;
12
+ }) => void;
9
13
  maxCommands?: number;
10
14
  showControls?: boolean;
11
15
  graphicsConfig?: Partial<GraphicsConfig>;
12
16
  initialXml?: string;
13
17
  }
14
- declare const DrawingGameWithTranslation: React.ComponentType<DrawingGameProps>;
18
+ interface DrawingGameState {
19
+ gameState: DrawingState;
20
+ currentDirection: 'north' | 'south' | 'east' | 'west';
21
+ isExecuting: boolean;
22
+ currentCommandIndex: number;
23
+ generatedCode: string;
24
+ isGenerating: boolean;
25
+ executionStartTime?: number;
26
+ }
27
+ declare class DrawingGame extends Component<DrawingGameProps & WithTranslation, DrawingGameState> {
28
+ constructor(props: DrawingGameProps & WithTranslation);
29
+ componentDidMount(): void;
30
+ componentDidUpdate(prevProps: DrawingGameProps & WithTranslation): void;
31
+ componentWillUnmount(): void;
32
+ private drawingConfig;
33
+ private graphicsConfig;
34
+ private getBlocklyConfig;
35
+ private getDefaultShape;
36
+ private executionInterval;
37
+ private blocklyRef;
38
+ private generateDrawing;
39
+ private handleCodeChange;
40
+ private handleConfigChange;
41
+ private handleExecuteCode;
42
+ private executeCommands;
43
+ private executeCommand;
44
+ private movePenForward;
45
+ private turnPen;
46
+ private setPenState;
47
+ private setPenColor;
48
+ private calculateAccuracy;
49
+ private distanceBetweenSegments;
50
+ private pointToSegmentDistance;
51
+ private stopExecution;
52
+ private resetGame;
53
+ private runCode;
54
+ getCurrentRunResult: () => RunResult;
55
+ render(): import("react/jsx-runtime").JSX.Element;
56
+ }
57
+ declare const DrawingGameWithTranslation: React.ComponentType<DrawingGameProps & React.RefAttributes<DrawingGame>>;
15
58
  export default DrawingGameWithTranslation;
@@ -1,15 +1,59 @@
1
- import React from 'react';
2
- import type { FilmConfig, GraphicsConfig, RunResult } from './types';
1
+ import React, { Component } from 'react';
2
+ import { type WithTranslation } from 'react-i18next';
3
+ import type { FilmConfig, FilmState, GraphicsConfig, RunResult } from './types';
3
4
  interface FilmGameProps {
4
5
  className?: string;
5
6
  isEditable?: boolean;
6
7
  configuration?: FilmConfig;
7
8
  onChange?: (config: FilmConfig) => void;
8
9
  onRunFinish?: (result: RunResult) => void;
10
+ onReady?: (methods: {
11
+ getCurrentRunResult: () => RunResult;
12
+ }) => void;
9
13
  maxCommands?: number;
10
14
  showControls?: boolean;
11
15
  graphicsConfig?: Partial<GraphicsConfig>;
12
16
  initialXml?: string;
13
17
  }
14
- declare const FilmGameWithTranslation: React.ComponentType<FilmGameProps>;
18
+ interface FilmGameState {
19
+ gameState: FilmState;
20
+ isExecuting: boolean;
21
+ currentCommandIndex: number;
22
+ generatedCode: string;
23
+ executionStartTime?: number;
24
+ }
25
+ declare class FilmGame extends Component<FilmGameProps & WithTranslation, FilmGameState> {
26
+ constructor(props: FilmGameProps & WithTranslation);
27
+ componentDidMount(): void;
28
+ componentDidUpdate(prevProps: FilmGameProps & WithTranslation): void;
29
+ componentWillUnmount(): void;
30
+ private filmConfig;
31
+ private graphicsConfig;
32
+ private executionInterval;
33
+ private animationInterval;
34
+ private blocklyRef;
35
+ private editorBlocklyRef;
36
+ private allCommands;
37
+ private tickCommands;
38
+ private editorState;
39
+ private getBlocklyConfig;
40
+ private handleCodeChange;
41
+ private handleConfigChange;
42
+ private handleEditorStateChange;
43
+ private handleGameTickChange;
44
+ private handleExecuteCode;
45
+ private executeCommands;
46
+ private executeCommand;
47
+ private evaluateExpression;
48
+ private playAnimation;
49
+ private pauseAnimation;
50
+ private stopAnimation;
51
+ private compareShapes;
52
+ private finishGame;
53
+ private resetGame;
54
+ private runCode;
55
+ getCurrentRunResult: () => RunResult;
56
+ render(): import("react/jsx-runtime").JSX.Element;
57
+ }
58
+ declare const FilmGameWithTranslation: React.ComponentType<FilmGameProps & React.RefAttributes<FilmGame>>;
15
59
  export default FilmGameWithTranslation;
@@ -7,6 +7,9 @@ interface MazeGameProps {
7
7
  configuration?: MazeConfig;
8
8
  onChange?: (config: MazeConfig) => void;
9
9
  onRunFinish?: (result: RunResult) => void;
10
+ onReady?: (methods: {
11
+ getCurrentRunResult: () => RunResult;
12
+ }) => void;
10
13
  maxMoves?: number;
11
14
  showControls?: boolean;
12
15
  graphicsConfig?: Partial<GraphicsConfig>;
@@ -57,6 +60,6 @@ declare class MazeGame extends Component<MazeGameProps & WithTranslation, MazeGa
57
60
  getCurrentRunResult: () => RunResult;
58
61
  render(): import("react/jsx-runtime").JSX.Element;
59
62
  }
60
- declare const MazeGameWithTranslation: React.ComponentType<MazeGameProps>;
63
+ declare const MazeGameWithTranslation: React.ComponentType<MazeGameProps & React.RefAttributes<MazeGame>>;
61
64
  export { MazeGame as MazeGameBase };
62
65
  export default MazeGameWithTranslation;
@@ -1,6 +1,6 @@
1
- import React from 'react';
1
+ import React, { Component } from 'react';
2
2
  import { type WithTranslation } from 'react-i18next';
3
- import { type GraphicsConfig, type MusicConfig, type RunResult } from './types';
3
+ import { type GraphicsConfig, type InstrumentType, type MusicBlocklyConfig, type MusicConfig, type MusicState, type Note, type Pause, type RunResult } from './types';
4
4
  interface MusicGameProps extends WithTranslation {
5
5
  className?: string;
6
6
  isEditable?: boolean;
@@ -8,9 +8,93 @@ interface MusicGameProps extends WithTranslation {
8
8
  configuration?: MusicConfig;
9
9
  onChange?: (config: MusicConfig) => void;
10
10
  onRunFinish?: (result: RunResult) => void;
11
+ onReady?: (methods: {
12
+ getCurrentRunResult: () => RunResult;
13
+ }) => void;
11
14
  maxCommands?: number;
12
15
  showControls?: boolean;
13
16
  graphicsConfig?: Partial<GraphicsConfig>;
14
17
  }
15
- declare const MusicGameWithTranslation: React.ComponentType<Omit<MusicGameProps, keyof WithTranslation>>;
18
+ interface MusicGameState {
19
+ gameState: MusicState;
20
+ isExecuting: boolean;
21
+ currentBeat: number;
22
+ generatedCode: string;
23
+ executionStartTime?: number;
24
+ editorNotes: (Note | Pause)[];
25
+ }
26
+ declare class MusicGame extends Component<MusicGameProps, MusicGameState> {
27
+ private musicConfig;
28
+ private graphicsConfig;
29
+ private audioEngine;
30
+ private playbackInterval;
31
+ private currentNoteTimeout;
32
+ private blocklyRef;
33
+ private editorBlocklyRef;
34
+ private editorState;
35
+ constructor(props: MusicGameProps & WithTranslation);
36
+ componentDidMount(): void;
37
+ componentDidUpdate(prevProps: MusicGameProps & WithTranslation): void;
38
+ componentWillUnmount(): void;
39
+ /**
40
+ * Get Blockly configuration
41
+ */
42
+ getBlocklyConfig: () => MusicBlocklyConfig;
43
+ /**
44
+ * Handle workspace change
45
+ */
46
+ handleWorkspaceChange: (code: string) => void;
47
+ /**
48
+ * Parse code and update state without resetting playback if possible
49
+ */
50
+ parseCodeAndSetState: (callback?: () => void) => void;
51
+ /**
52
+ * Parse and execute the generated code
53
+ */
54
+ executeCode: (callback?: () => void) => void;
55
+ /**
56
+ * Play the music
57
+ */
58
+ playMusic: () => Promise<void>;
59
+ /**
60
+ * Start playback
61
+ */
62
+ private startPlayback;
63
+ /**
64
+ * Pause playback
65
+ */
66
+ pausePlayback: () => void;
67
+ /**
68
+ * Stop playback
69
+ */
70
+ stopPlayback: () => void;
71
+ /**
72
+ * Handle playback completion
73
+ */
74
+ /**
75
+ * Handle playback completion
76
+ */
77
+ private handlePlaybackComplete;
78
+ /**
79
+ * Reset the game
80
+ */
81
+ resetGame: () => void;
82
+ /**
83
+ * Handle keyboard input for interactive playing
84
+ */
85
+ handleKeyboardInput: (event: KeyboardEvent) => void;
86
+ /**
87
+ * Preload commonly used instruments
88
+ */
89
+ private preloadCommonInstruments;
90
+ /**
91
+ * Preload instruments based on current configuration
92
+ */
93
+ preloadInstruments: (instrumentTypes: InstrumentType[]) => Promise<void>;
94
+ handleEditorStateChange: (newState: Partial<MusicState>) => void;
95
+ handleEditorNotesChange: (notes: (Note | Pause)[]) => void;
96
+ getCurrentRunResult: () => RunResult;
97
+ render(): JSX.Element;
98
+ }
99
+ declare const MusicGameWithTranslation: React.ComponentType<Omit<MusicGameProps, keyof WithTranslation> & React.RefAttributes<MusicGame>>;
16
100
  export default MusicGameWithTranslation;