Skip to content

Move the DOM-free simulator code into pxtsimcore - #11785

Draft
Eric Anderson (humanapp) wants to merge 1 commit into
humanapp/stack/3-boardviewfrom
humanapp/stack/4-simcore-move
Draft

Eric Anderson (humanapp) wants to merge 1 commit into
humanapp/stack/3-boardviewfrom
humanapp/stack/4-simcore-move

Conversation

@humanapp

Copy link
Copy Markdown
Collaborator

Fourth of the stacked PRs replacing #11665 (4/8).

  • Split pxtsim into two projects sharing the pxsim namespace: pxtsimcore/ for the runtime, board state, sound and host layers, pxtsim/ for the embed, views, Web Audio and iframes.
  • By design, pxtsimcore compiles without the dom lib, so core code that attempts to access browser APIs fails the build.
  • Most of this diff is just file moves. The code changes are in embed.ts, simlib.ts, debugger.ts and runtime.ts, where the DOM-free parts were split out into new core files.
  • Kept built/pxtsim.js and built/pxtsim.d.ts as the outputs, so nothing changes for consumers.

Changes in gulpfile.js

  • The pxtsim task now compiles pxtsimcore, then pxtsim against its declarations, and concatenates the two into built/pxtsim.js and built/pxtsim.d.ts. Downstream tasks are unchanged.
  • Added pxtsimcore to lint, updatestrings, and watch lists.

The runtime, the host and audio seams, the board state classes and the synthesis code move from pxtsim to pxtsimcore, a project compiled without the DOM library, which is the check that nothing in it reaches the browser. The simulator message types, the event bus, the animation queue, the breadboard geometry and the DOM-free half of the debugger are split out of embed.ts, simlib.ts and debugger.ts on the way. The build compiles the two halves and composes built/pxtsim.js and built/pxtsim.d.ts from them, so consumers load the same file and see the same pxsim API. Only moves and the edits that keep the old files compiling; no behaviour changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant