Skip to content

External player scripts (VS Code) ​

Write a project's player scripts in VS Code, use npm packages, and preview or publish from the terminal. Desktop app only.

In short: save the animation as a folder project, then right-click the scripts folder in the Library › Edit Scripts in VS Code…. HereSplash writes a package.json and the other project files and opens VS Code. From then on the files in scripts/ are the master copy: every time VS Code saves, the Library, the Properties panel, the Playback function lists and any open script tabs update at once. You can npm install any package, and Ctrl+Shift+B in VS Code asks HereSplash for a preview.

How to write the scripts themselves (Behaviour, fields, clip.timeline) is in the pixi-hm05 reference.

First-time setup ​

  1. In the desktop app: File › Save as Folder… (skip this if the document already is a folder project; a single .hm5 file is saved as a folder in step 2 first).
  2. Right-click the scripts folder in the Library › Edit Scripts in VS Code…. HereSplash then:
    • saves once, so the scripts on disk match the Library;
    • writes the files below into the folder (files that already exist only get what they are missing);
    • turns on "scripts are edited outside" for the document (saved in it);
    • opens the folder in VS Code (through the code command, else a vscode:// link, else the system's folder window).
  3. In VS Code's terminal: npm install (installs the hm05 package, TypeScript and the pixi.js types).
FileContentsWhen the file already exists
package.jsonscripts npm run preview / publish / build / typecheck / debug; devDependencies hm05, typescript, pixi.js (for its types only)only the missing scripts / devDependencies are added
tsconfig.jsontype checking only; "pixi-hm05" points at the types inside the hm05 packageleft alone (add the paths line to your own settings)
.gitignorenode_modules/, output/, .hm05/missing lines are added
.vscode/tasks.json"hm05: Preview" (Ctrl+Shift+B) and "hm05: Publish"; errors are clickableonly these two tasks are added (comments in the file are lost)
.vscode/extensions.jsonrecommends ESLint and Prettierleft alone
.vscode/launch.json"hm05: Attach to preview" (breakpoints, see below)only this entry is added (comments in the file are lost)

These files are not part of the animation: saving as .hm5 leaves them out, and saving in HereSplash never changes them.

A player script is a TypeScript (or JavaScript) module whose default export extends Behaviour:

ts
import { Behaviour } from "pixi-hm05";

export default class Hero extends Behaviour {
	static fields = { speed: { type: "number", default: 3 } };
	onEnterFrame() {
		this.clip.x += Number(this.fields.speed);
	}
}

Everyday use ​

ToDo this
Write or change a scriptEdit the .ts / .js files in scripts/ in VS Code and save. HereSplash updates at once; nothing to press.
Add a scriptCreate the file in VS Code: it shows up in the Library straight away. New Script in HereSplash writes the file to disk at once too.
Rename / moveRenamed in VS Code: HereSplash recognises it (same contents) and keeps every binding. If the contents changed too, the Library item shows (file missing): right-click › Relink… and pick the new file. Renaming in the Library renames the file on disk.
DeleteDeleted in VS Code: the Library keeps the script and marks it (file missing) (bindings stay). Deleted in HereSplash: you are asked whether to delete the file as well (if not, it comes back into the Library the next time the project opens — the disk wins).
PreviewCtrl+Shift+B in VS Code or npm run preview = Ctrl+Enter in HereSplash. npm run preview -- --watch previews again on every save (in the same preview window).
Breakpointsnpm run debug (preview, again on every save, debugging port 9333) → VS Code Run and Debug › "hm05: Attach to preview"; then click left of a line number in a .ts file. HereSplash must be started by this command (quit it first if it is running). Each save still reloads the whole page; the breakpoints stay. Without VS Code: press F12 in the preview window for DevTools.
Publishnpm run publish: publishes to output/ with the publish settings saved in the document, no dialog.
Check that it bundlesnpm run build (errors come out as scripts/Hero.ts:12:4: error: …, clickable in VS Code's Problems panel).
Type-checknpm run typecheck (HereSplash does not type-check scripts itself).
Edit in HereSplashThe script tabs still work: they write to disk 0.4 s after you stop typing, and get an Open in VS Code button. Changed on both sides: the disk wins, and HereSplash tells you once.
Choose what double-click opensPreferences › General › Open scripts with: HereSplash's code tab, VS Code, or the system's app for .ts / .js.

The hm05 command ​

text
hm05 preview [--watch] [--debug]   preview (--watch: again on every save; --debug: DevTools port for VS Code breakpoints)
hm05 publish             publish to output/ with the document's publish settings
hm05 build               bundle the scripts only, report errors
hm05 test [--frames N]   play the project headless for N frames (default 120), print the page's console, exit 1 on errors
hm05 open                open this project in HereSplash
hm05 init                write the project files from the terminal (e.g. after git clone)

Run it in the project folder (the one with doc.json) or a folder inside it, or name the project after the command (hm05 build ../game). If the desktop app is running the command connects to it, otherwise it starts the app (waits up to 30 seconds). There is nothing to set up: the desktop app writes its address to ~/.hm05/bridge.json and the command finds it. Full list: hm05 CLI.

npm packages ​

  • Desktop folder project: npm install gsap in VS Code's terminal, then import gsap from "gsap" in a script. Preview and Publish read node_modules directly and bundle everything into <name>.scripts.js; the published page fetches nothing else from the internet.
  • pixi-hm05, pixi.js and pixi-filters are always the page's own copy (pixi is never bundled twice).
  • When saving, HereSplash copies the dependencies of package.json (at the installed versions) into the document's Script Packages, so the same document can also be published from the web editor or as a .hm5 file.
  • Web editor or a single .hm5 file: right-click scripts in the Library › Script Packages…, type a package name, and the latest version is filled in (you can change it). Publish fetches that version from a CDN (esm.sh by default; jsDelivr in Preferences) and bundles it the same way. Fetched files are kept in the browser, so the second time nothing is downloaded.
  • A package that is neither in Script Packages nor installed gives the error Cannot find package "gsap": run npm install; the latest version is never fetched on its own.
  • Not supported: packages that need Node built-in modules (fs …) or files that must be built first (.vue, CSS imports). You can import .json (data), .txt (text) and other .ts files of the folder (for example src/utils.ts; they do not become Library items).

Known limits ​

  • The hm05 npm package is not published yet. Until it is, the project's package.json points hm05 at the copy that ships inside the app (a file: path); it works the same.
  • Network drives and Windows drives mounted in WSL may not report file changes: HereSplash compares the files again whenever its window gets the focus.
  • File › Export › Export Animation… with Loadable animation or Complete web page still bundles the Library's scripts and Script Packages (not node_modules); Publish, Preview and the hm05 command read the disk.

HereSplash — 2D animation for the web