Skip to content

Breaking: Rename Project -> MakeCodeProject #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/vanilla.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Use {@link vanilla.MakeCodeFrameDriver | MakeCodeFrameDriver} class to create a

```js
import {
Project,
MakeCodeFrameDriver,
createMakeCodeURL,
} from "@microbit/makecode-embed/vanilla";
Expand Down
4 changes: 2 additions & 2 deletions src/react/MakeCodeBlocksRendering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/
import React, { useState, useEffect, ReactNode } from 'react';
import { useMakeCodeRenderBlocksContext } from './MakeCodeRenderBlocksProvider.js';
import { BlockLayout, Project } from '../vanilla/pxt.js';
import { BlockLayout, MakeCodeProject } from '../vanilla/pxt.js';

export interface MakeCodeBlocksRenderingProps {
className?: string;
code?: string | Project;
code?: string | MakeCodeProject;
packageId?: string;
package?: string;
snippetMode?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/react/MakeCodeFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
EditorMessageTutorialEventRequest,
EditorWorkspaceSaveRequest,
EditorWorkspaceSyncRequest,
Project,
MakeCodeProject,
ProjectFilters,
} from '../vanilla/pxt.js';

Expand All @@ -38,7 +38,7 @@ export interface MakeCodeFrameProps
// https://github.com/microsoft/pxt-microbit/blob/master/pxtarget.json#L605C6-L605C14
queryParams?: Record<string, string>;

initialProjects: () => Promise<Project[]>;
initialProjects: () => Promise<MakeCodeProject[]>;

controllerId?: string;
filters?: ProjectFilters;
Expand Down
2 changes: 1 addition & 1 deletion src/react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type {
ImportProjectOptions,
InfoMessage,
LanguageRestriction,
Project,
MakeCodeProject,
ProjectCreationOptions,
ProjectFilters,
RenderBlocksOptions,
Expand Down
4 changes: 2 additions & 2 deletions src/stories/MakeCodeToolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MutableRefObject, RefObject } from 'react';
import { MakeCodeFrameDriver } from '../vanilla/makecode-frame-driver.js';
import { defaultMakeCodeProject } from '../vanilla/examples.js';
import { Project } from '../vanilla/pxt.js';
import { MakeCodeProject } from '../vanilla/pxt.js';

const toolbarRowStyle = {
fontFamily: 'sans-serif',
Expand All @@ -16,7 +16,7 @@ const MakeCodeToolbar = ({
savedProjects,
}: {
driver: RefObject<MakeCodeFrameDriver>;
savedProjects: MutableRefObject<Map<string, Project>>;
savedProjects: MutableRefObject<Map<string, MakeCodeProject>>;
}) => {
return (
<div style={{ display: 'flex', flexDirection: 'column' }}>
Expand Down
12 changes: 6 additions & 6 deletions src/stories/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Project } from '../vanilla/pxt.js';
import { MakeCodeProject } from '../vanilla/pxt.js';

export const project = {
text: {
Expand All @@ -9,7 +9,7 @@ export const project = {
'pxt.json':
'{\n "name": "Untitled",\n "dependencies": {\n "core": "*"\n , "radio": "*"\n },\n "description": "",\n "files": [\n "main.blocks",\n "main.ts",\n "README.md"\n ]\n}',
},
} as Project;
} as MakeCodeProject;

export const projectWithLayout = {
text: {
Expand Down Expand Up @@ -63,9 +63,9 @@ export const projectWithLayout = {
</block>
</xml>`,
},
} as Project;
} as MakeCodeProject;

export const projectWithExtensionBlock: Project = {
export const projectWithExtensionBlock: MakeCodeProject = {
text: {
'README.md': '',
'main.blocks':
Expand Down Expand Up @@ -136,7 +136,7 @@ export const initialProject = {
},
};

export const projectWithCustomBlock: Project = {
export const projectWithCustomBlock: MakeCodeProject = {
text: {
'README.md': '',
'custom.ts':
Expand All @@ -149,7 +149,7 @@ export const projectWithCustomBlock: Project = {
},
};

export const projectWithUserLayout: Project = {
export const projectWithUserLayout: MakeCodeProject = {
text: {
'README.md': '',
'main.blocks':
Expand Down
6 changes: 3 additions & 3 deletions src/stories/react/MakeCodeBlocksRendering.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Meta, StoryObj } from '@storybook/react';
import { ReactNode, useState } from 'react';
import MakeCodeBlocksRendering from '../../react/MakeCodeBlocksRendering.js';
import { MakeCodeRenderBlocksProvider } from '../../react/MakeCodeRenderBlocksProvider.js';
import { BlockLayout, Project } from '../../vanilla/pxt.js';
import { BlockLayout, MakeCodeProject } from '../../vanilla/pxt.js';
import {
initialProject,
project,
Expand Down Expand Up @@ -190,7 +190,7 @@ export const Robust: Story = {
return (
<StoryWrapper key={version}>
<MakeCodeRenderBlocksProvider version={adaptStorybookVersion(version)}>
<MakeCodeBlocksRendering code={{} as Project} />
<MakeCodeBlocksRendering code={{} as MakeCodeProject} />
</MakeCodeRenderBlocksProvider>
</StoryWrapper>
);
Expand Down Expand Up @@ -229,7 +229,7 @@ export const EmptyToBlocksTransition: Story = {
name: 'Empty to blocks transition',
render: (args) => {
const { version } = args;
const [project, setProject] = useState<Project>(initialProject);
const [project, setProject] = useState<MakeCodeProject>(initialProject);
return (
<StoryWrapper key={version}>
<div style={{ display: 'grid', gridTemplateColumns: '50% 50%' }}>
Expand Down
4 changes: 2 additions & 2 deletions src/stories/react/MakeCodeFrame.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
default as MakeCodeFrame,
MakeCodeFrameProps,
} from '../../react/MakeCodeFrame.js';
import { Project } from '../../vanilla/pxt.js';
import { MakeCodeProject } from '../../vanilla/pxt.js';
import { controllerId } from '../config.js';
import StoryWrapper from '../StoryWrapper.js';
import MakeCodeToolbar from '../MakeCodeToolbar.js';
Expand All @@ -30,7 +30,7 @@ type Story = StoryObj<typeof MakeCodeFrame>;
const MakeCodeEditorWithControls = (
props: Omit<MakeCodeFrameProps, 'initialProjects'>
) => {
const savedProjects = useRef<Map<string, Project>>(new Map());
const savedProjects = useRef<Map<string, MakeCodeProject>>(new Map());
const ref = useRef<MakeCodeFrameDriver>(null);
const initialProjects = useCallback(async () => {
if (savedProjects.current.size === 0) {
Expand Down
8 changes: 4 additions & 4 deletions src/stories/vanilla/makecode-frame-driver.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
MakeCodeFrameDriver,
Options,
} from '../../vanilla/makecode-frame-driver.js';
import { Project } from '../../vanilla/pxt.js';
import { MakeCodeProject } from '../../vanilla/pxt.js';
import MakeCodeToolbar from '../MakeCodeToolbar.js';
import StoryWrapper from '../StoryWrapper.js';

Expand All @@ -17,7 +17,7 @@ interface StoryArgs {
controller?: 1 | 2;
queryParams?: Record<string, string>;
};
project?: Project;
project?: MakeCodeProject;
callbacks?: Partial<Options>;
}

Expand All @@ -30,7 +30,7 @@ export default meta;
type Story = StoryObj<StoryArgs>;

const renderEditor = (args: StoryArgs) => {
const savedProjects = useRef<Map<string, Project>>(new Map());
const savedProjects = useRef<Map<string, MakeCodeProject>>(new Map());
const ref = useRef<MakeCodeFrameDriver | null>(null);
const cbRef = (div: HTMLElement | null) => {
if (!div) {
Expand All @@ -50,7 +50,7 @@ const renderEditor = (args: StoryArgs) => {
iframe.height = '100%';
div.appendChild(iframe);

const savedProjects: Map<string, Project> = new Map();
const savedProjects: Map<string, MakeCodeProject> = new Map();

// Create and initialise an instance of MakeCodeFrameDriver.
ref.current = new MakeCodeFrameDriver(
Expand Down
4 changes: 2 additions & 2 deletions src/stories/vanilla/makecode-render-blocks.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import {
projectWithMelody,
projectWithTwoExtensions,
} from '../fixtures.js';
import { Project } from '../../vanilla/pxt.js';
import { MakeCodeProject } from '../../vanilla/pxt.js';
import StoryWrapper from '../StoryWrapper.js';

interface StoryArgs {
options: MakeCodeRenderBlocksOptions | undefined;
project: Project;
project: MakeCodeProject;
}

const meta: Meta<StoryArgs> = {
Expand Down
6 changes: 3 additions & 3 deletions src/vanilla/examples.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Project } from './pxt.js';
import { MakeCodeProject } from './pxt.js';

export const defaultMakeCodeProject: Project = {
export const defaultMakeCodeProject: MakeCodeProject = {
text: {
'main.blocks':
'<xml xmlns="http://www.w3.org/1999/xhtml">\n <block type="pxt-on-start" id=",{,HjW]u:lVGcDRS_Cu|" x="-247" y="113"></block>\n</xml>',
Expand All @@ -11,7 +11,7 @@ export const defaultMakeCodeProject: Project = {
},
};

export const emptyMakeCodeProject: Project = {
export const emptyMakeCodeProject: MakeCodeProject = {
text: {
'main.blocks':
'<xml xmlns="http://www.w3.org/1999/xhtml">\n <variables></variables>\n</xml>',
Expand Down
2 changes: 1 addition & 1 deletion src/vanilla/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type {
LanguageRestriction,
PackageConfig,
PackageExtension,
Project,
MakeCodeProject,
ProjectCreationOptions,
ProjectFilters,
ProjectTemplate,
Expand Down
4 changes: 2 additions & 2 deletions src/vanilla/makecode-frame-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
ImportProjectOptions,
InfoMessage,
LanguageRestriction,
Project,
MakeCodeProject,
ProjectCreationOptions,
ProjectFilters,
RenderBlocksOptions,
Expand Down Expand Up @@ -64,7 +64,7 @@ export interface Options {
* The projects will receive updates via `onWorkspaceSave` and should be stored keyed by header
* id.
*/
initialProjects: () => Promise<Project[]>;
initialProjects: () => Promise<MakeCodeProject[]>;

/**
* Set this to a value representing your app.
Expand Down
8 changes: 4 additions & 4 deletions src/vanilla/makecode-render-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* MakeCode handling that does not depend on React.
*/

import { BlockLayout, Project } from './pxt.js';
import { BlockLayout, MakeCodeProject } from './pxt.js';

const disposedMessage = 'Disposed';
const makecodeFailedToLoadMessage = 'Failed to load MakeCode to render blocks.';
Expand All @@ -22,7 +22,7 @@ export interface MakeCodeRenderBlocksReturn {
}

export interface RenderBlocksRequest {
code: string | Project;
code: string | MakeCodeProject;
options?: {
packageId?: string;
package?: string;
Expand Down Expand Up @@ -68,7 +68,7 @@ interface RenderBlocksResponseMessage {
type RequestInputType = 'text' | 'blocks';

interface RenderBlocksRequestResponse {
input: Project | string;
input: MakeCodeProject | string;
sent: boolean;
type: RequestInputType;
req: RenderBlocksRequestMessage;
Expand Down Expand Up @@ -129,7 +129,7 @@ export const createMakeCodeRenderBlocks = (
};

const findBestCode = (
code: string | Project,
code: string | MakeCodeProject,
ignoreBlocks?: boolean
): { type: RequestInputType; code: string } => {
if (typeof code === 'string') {
Expand Down
10 changes: 5 additions & 5 deletions src/vanilla/pxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface Header extends InstallHeader {

export type ScriptText = Record<string, string>;

export interface Project {
export interface MakeCodeProject {
header?: Header;
text?: ScriptText;
}
Expand Down Expand Up @@ -333,7 +333,7 @@ export interface EditorWorkspaceSyncResponse extends EditorMessageResponse {
/*
* Full list of project, required for init
*/
projects: Project[];
projects: MakeCodeProject[];
// (optional) filtering argument
editor?: EditorSyncState;
// (optional) controller id, used for determining what the parent controller is
Expand All @@ -345,12 +345,12 @@ export interface EditorWorkspaceSaveRequest extends EditorMessageRequest {
/*
* Modified project
*/
project: Project;
project: MakeCodeProject;
}

export interface ImportProjectOptions {
// project to load
project: Project;
project: MakeCodeProject;
// (optional) filtering argument
filters?: ProjectFilters;
searchBar?: boolean;
Expand All @@ -364,7 +364,7 @@ export interface EditorMessageImportProjectRequest

export interface ImportExternalProjectOptions {
// project to load
project: Project;
project: MakeCodeProject;
}

export interface EditorMessageImportExternalProjectRequest
Expand Down