44 *
55 * SPDX-License-Identifier: MIT
66 */
7- import { Project } from "@microbit/makecode-embed/react" ;
7+ import { MakeCodeProject } from "@microbit/makecode-embed/react" ;
88import * as tf from "@tensorflow/tfjs" ;
99import { create } from "zustand" ;
1010import { devtools , persist } from "zustand/middleware" ;
@@ -82,7 +82,7 @@ interface PredictionResult {
8282 detected : Action | undefined ;
8383}
8484
85- const createUntitledProject = ( ) : Project => ( {
85+ const createUntitledProject = ( ) : MakeCodeProject => ( {
8686 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
8787 header : {
8888 target : "microbit" ,
@@ -114,7 +114,7 @@ const createUntitledProject = (): Project => ({
114114} ) ;
115115
116116const updateProject = (
117- project : Project ,
117+ project : MakeCodeProject ,
118118 projectEdited : boolean ,
119119 actions : ActionData [ ] ,
120120 model : tf . LayersModel | undefined ,
@@ -151,7 +151,7 @@ export interface State {
151151
152152 isRecording : boolean ;
153153
154- project : Project ;
154+ project : MakeCodeProject ;
155155 /**
156156 * We use this for the UI to tell when we've switched new project,
157157 * e.g. to show a toast.
@@ -220,7 +220,7 @@ export interface Actions {
220220 dataCollectionMicrobitConnected ( ) : void ;
221221
222222 loadDataset ( actions : ActionData [ ] ) : void ;
223- loadProject ( project : Project , name : string ) : void ;
223+ loadProject ( project : MakeCodeProject , name : string ) : void ;
224224 setEditorOpen ( open : boolean ) : void ;
225225 recordingStarted ( ) : void ;
226226 recordingStopped ( ) : void ;
@@ -244,11 +244,11 @@ export interface Actions {
244244 * When interacting outside of React to sync with MakeCode it's important to have
245245 * the current project after state changes.
246246 */
247- getCurrentProject ( ) : Project ;
247+ getCurrentProject ( ) : MakeCodeProject ;
248248 checkIfProjectNeedsFlush ( ) : boolean ;
249249 checkIfLangChanged ( ) : boolean ;
250250 langChangeFlushedToEditor ( ) : void ;
251- editorChange ( project : Project ) : void ;
251+ editorChange ( project : MakeCodeProject ) : void ;
252252 editorReady ( ) : void ;
253253 editorTimedOut ( ) : void ;
254254 getEditorStartUp ( ) : EditorStartUp ;
@@ -669,7 +669,7 @@ const createMlStore = (logging: Logging) => {
669669 * Generally project loads go via MakeCode as it reads the hex but when we open projects
670670 * from microbit.org we have the JSON already and use this route.
671671 */
672- loadProject ( project : Project , name : string ) {
672+ loadProject ( project : MakeCodeProject , name : string ) {
673673 const newActions = getActionsFromProject ( project ) ;
674674 set ( ( { settings } ) => {
675675 const timestamp = Date . now ( ) ;
@@ -843,7 +843,7 @@ const createMlStore = (logging: Logging) => {
843843 ) ;
844844 } ,
845845
846- editorChange ( newProject : Project ) {
846+ editorChange ( newProject : MakeCodeProject ) {
847847 const actionName = "editorChange" ;
848848 set (
849849 ( state ) => {
@@ -1364,7 +1364,7 @@ const actionIcon = ({
13641364 return useableIcons [ 0 ] ;
13651365} ;
13661366
1367- const getActionsFromProject = ( project : Project ) : ActionData [ ] => {
1367+ const getActionsFromProject = ( project : MakeCodeProject ) : ActionData [ ] => {
13681368 const { text } = project ;
13691369 if ( text === undefined || ! ( "dataset.json" in text ) ) {
13701370 return [ ] ;
@@ -1376,7 +1376,10 @@ const getActionsFromProject = (project: Project): ActionData[] => {
13761376 return dataset . data as ActionData [ ] ;
13771377} ;
13781378
1379- const renameProject = ( project : Project , name : string ) : Project => {
1379+ const renameProject = (
1380+ project : MakeCodeProject ,
1381+ name : string
1382+ ) : MakeCodeProject => {
13801383 const pxtString = project . text ?. [ filenames . pxtJson ] ;
13811384 const pxt = JSON . parse ( pxtString ?? "{}" ) as Record < string , unknown > ;
13821385
0 commit comments