@@ -9,42 +9,38 @@ import * as tf from "@tensorflow/tfjs";
99import { create } from "zustand" ;
1010import { devtools , persist } from "zustand/middleware" ;
1111import { useShallow } from "zustand/react/shallow" ;
12+ import { BufferedData } from "./buffered-data" ;
1213import { deployment } from "./deployment" ;
1314import { flags } from "./flags" ;
15+ import { createPromise , PromiseInfo } from "./hooks/use-promise-ref" ;
1416import { Logging } from "./logging/logging" ;
15- import {
16- filenames ,
17- generateCustomFiles ,
18- generateProject ,
19- } from "./makecode/utils" ;
17+ import { generateCustomFiles , generateProject } from "./makecode/utils" ;
2018import { Confidences , predict , trainModel } from "./ml" ;
19+ import { mlSettings } from "./mlConfig" ;
2120import {
21+ Action ,
22+ ActionData ,
2223 DataSamplesView ,
2324 DownloadState ,
2425 DownloadStep ,
25- Action ,
26- ActionData ,
26+ EditorStartUp ,
2727 MicrobitToFlash ,
2828 PostImportDialogState ,
2929 RecordingData ,
3030 SaveState ,
3131 SaveStep ,
32- TourTrigger ,
32+ tourSequence ,
3333 TourState ,
34- TrainModelDialogStage ,
35- EditorStartUp ,
34+ TourTrigger ,
3635 TourTriggerName ,
37- tourSequence ,
36+ TrainModelDialogStage ,
3837} from "./model" ;
38+ import { renameProject , untitledProjectName } from "./project-name" ;
3939import { defaultSettings , Settings } from "./settings" ;
40+ import { getTour as getTourSpec } from "./tours" ;
4041import { getTotalNumSamples } from "./utils/actions" ;
4142import { defaultIcons , MakeCodeIcon } from "./utils/icons" ;
42- import { untitledProjectName } from "./project-name" ;
43- import { mlSettings } from "./mlConfig" ;
44- import { BufferedData } from "./buffered-data" ;
4543import { getDetectedAction } from "./utils/prediction" ;
46- import { getTour as getTourSpec } from "./tours" ;
47- import { createPromise , PromiseInfo } from "./hooks/use-promise-ref" ;
4844
4945export const modelUrl = "indexeddb://micro:bit-ai-creator-model" ;
5046
@@ -220,7 +216,6 @@ export interface Actions {
220216 dataCollectionMicrobitConnected ( ) : void ;
221217
222218 loadDataset ( actions : ActionData [ ] ) : void ;
223- loadProject ( project : MakeCodeProject , name : string ) : void ;
224219 setEditorOpen ( open : boolean ) : void ;
225220 recordingStarted ( ) : void ;
226221 recordingStopped ( ) : void ;
@@ -663,33 +658,6 @@ const createMlStore = (logging: Logging) => {
663658 } ) ;
664659 } ,
665660
666- /**
667- * Generally project loads go via MakeCode as it reads the hex but when we open projects
668- * from microbit.org we have the JSON already and use this route.
669- */
670- loadProject ( project : MakeCodeProject , name : string ) {
671- const newActions = getActionsFromProject ( project ) ;
672- set ( ( { settings } ) => {
673- const timestamp = Date . now ( ) ;
674- return {
675- settings : {
676- ...settings ,
677- toursCompleted : Array . from (
678- new Set ( [ ...settings . toursCompleted , "DataSamplesRecorded" ] )
679- ) ,
680- } ,
681- actions : newActions ,
682- dataWindow : getDataWindowFromActions ( newActions ) ,
683- model : undefined ,
684- project : renameProject ( project , name ) ,
685- projectEdited : true ,
686- appEditNeedsFlushToEditor : true ,
687- timestamp,
688- // We don't update projectLoadTimestamp here as we don't want a toast notification for .org import
689- } ;
690- } ) ;
691- } ,
692-
693661 closeTrainModelDialogs ( ) {
694662 set ( {
695663 trainModelDialogStage : TrainModelDialogStage . Closed ,
@@ -1383,26 +1351,3 @@ const getActionsFromProject = (project: MakeCodeProject): ActionData[] => {
13831351 }
13841352 return dataset . data as ActionData [ ] ;
13851353} ;
1386-
1387- const renameProject = (
1388- project : MakeCodeProject ,
1389- name : string
1390- ) : MakeCodeProject => {
1391- const pxtString = project . text ?. [ filenames . pxtJson ] ;
1392- const pxt = JSON . parse ( pxtString ?? "{}" ) as Record < string , unknown > ;
1393-
1394- return {
1395- ...project ,
1396- header : {
1397- ...project . header ! ,
1398- name,
1399- } ,
1400- text : {
1401- ...project . text ,
1402- [ filenames . pxtJson ] : JSON . stringify ( {
1403- ...pxt ,
1404- name,
1405- } ) ,
1406- } ,
1407- } ;
1408- } ;
0 commit comments