SpaceMIX v0.1.0 (latest)

Extensions in their own repository

for bothsince protocol 1

Keep extensions in a folder outside this repository, with their own version control, and build, watch and install them like the ones in extensions/.

The folders in extensions/ are only one place to keep extension sources, and git ignores all of them but example/. A bigger extension, or one you want under its own version control, can live anywhere on your machine. List its folder in SPACEMIX_EXTENSION_SOURCES and the development loop treats it like the extensions in this repository:

  • npm run dev watches it and rebuilds an extension when one of its files changes.
  • The package lands in the same dist/extensions/, so a debug build of the app installs it within a second or two.
  • npm run build:extensions, --only <folder> and publishing work on it too.

Setting it up

Add the folder to apps/desktop/.env (or set it in the environment, which wins):

SPACEMIX_EXTENSION_SOURCES=~/Projects/my-extensions

The value is a list of folders separated like PATH (:, or ; on Windows). Each folder is either one extension (it has an index.ts or index.tsx) or a folder of extensions, one per subfolder, laid out like extensions/<name>/:

my-extensions/          git repository
  tsconfig.json         for type-checking, below
  package.json          only if you need packages of your own
  crm/
    index.ts
    manifest.ts
    view/
  reports/
    index.tsx

Restart npm run dev after changing the variable; it reads the list when it starts. The build prints watching <folder> for each one.

Packages

react, @spacemix/sdk, @spacemix/ui, lucide-react and motion/react are never bundled; the frame provides them (HOST_MODULES, see Package format). Anything else an extension imports is bundled into its package. The build looks for it in the extension's own folder first (so your repository can have its own package.json and node_modules), then in this repository's node_modules.

Type-checking

@spacemix/sdk and @spacemix/ui aren't published to npm, so point TypeScript at this checkout. A tsconfig.json at the root of your extensions repository, with /path/to/spacemix replaced by the path to this repository:

{
  "extends": "/path/to/spacemix/tsconfig.base.json",
  "compilerOptions": {
    "types": [],
    "paths": {
      "@spacemix/sdk": ["/path/to/spacemix/packages/sdk/src/index.ts"],
      "@spacemix/sdk/react": ["/path/to/spacemix/packages/sdk/src/react.ts"],
      "@spacemix/ui": ["/path/to/spacemix/packages/ui/src/index.ts"],
      "*": ["/path/to/spacemix/node_modules/@types/*", "/path/to/spacemix/node_modules/*"]
    }
  },
  "include": ["./*/**/*"]
}

Then run npx tsc -p . in your repository. Editors pick up the same file.

Things to know

  • An extension's id must be unique. If a folder builds a package whose id another folder already built, the build stops with an error naming both instead of overwriting it.
  • A folder name that's already taken (say your own notes/ next to this repository's) is shown and selected with --only as <source folder>/<name>, for example --only my-extensions/notes.
  • node_modules, dist and dot folders such as .git don't trigger rebuilds, and they're left out of the sources stored in the package.
  • Everything in Self-contained applies: the extension may depend on nothing but the host.
  • If the extension's id has a price in the Marketplace, then on a server that uses the Hub, a build installed this way is governed by it like any other install: the licence follows the id. A build the registry doesn't have (a version number not yet published, or a changed package) counts as paid, so on such a server the publisher isn't on it is turned off until that server buys it (Turned off until it's paid for). On a server that doesn't use the Hub, nothing is asked; only what the server already knows applies. On your own servers, the ones you signed in to with the publishing SpaceMIX ID in the last 30 days, it runs.
  • A folder here can also be a Studio project's linked folder (the Studio's Settings tab, A folder on disk), so the Studio and an editor or agent in the folder work on the same files, and the dev loop installs each build as before.

This page as markdown · All pages as one file