@wizestudio/core
v0.1.2
Published
The WizeStudio editing engine: documents, patches, commands, history, registries. No UI framework, no DOM, no CMS.
Readme
@wizestudio/core
The WizeStudio editing engine: document store, invertible patches, commands, history, selection, registries and value resolution. No UI framework, no DOM, no CMS.
Where this sits
WizeStudio is a visual page builder for headless CMS platforms. @wizestudio/schema declares what a page is; this package is everything you can do to one.
Every behaviour the editor exposes is a view over this package. If something can be expressed here it belongs here, where it can be tested without a browser — a full editing session runs in Node with no React, no DOM and no CMS. @wizestudio/editor is the React shell on top; @wizestudio/canvas-bridge transports the patches this engine produces; the CMS adapters implement the CmsAdapter port declared here.
Install
npm install @wizestudio/coreUsage
import { createEmptyDocument } from '@wizestudio/schema';
import { createEngine } from '@wizestudio/core';
const engine = createEngine(createEmptyDocument(), { widgets: manifests });
engine.run('widget.insert', { type: 'wize/heading' });
engine.run('selection.duplicate');
engine.run('history.undo');
engine.store.getDocument();createEngine is a facade that wires the store, history, selection, registries and commands together with one lifetime. Every part remains independently constructible — nothing in the system depends on the facade.
Design
Undo, redo, autosave and version history are one mechanism. Every mutation is a typed patch that carries its own inverse data (prev, the removed subtree), so invertPatch is pure and needs no access to the document. Undo is not a second implementation that can drift from "do", and version history costs a log compaction rather than a subsystem.
The core never learns what a widget is. Nesting rules come from manifests: slots with accepts, min, max, locked. Drag-and-drop validation, the navigator tree and paste all read those rules through one function, canDrop. There is no branch anywhere that mentions a specific widget type.
Not a CRDT. Real-time multiplayer is not on the roadmap, and DocumentStore is an interface, so a CRDT-backed implementation stays swappable without paying for one now.
Key exports
| Area | Exports |
|---|---|
| Engine | createEngine, Engine, EngineOptions |
| Store | createDocumentStore, DocumentStore, Transaction, DocumentChangeEvent |
| Patches | Patch, applyPatch, applyPatches, invertPatch, invertPatches, describePatch |
| History | createHistory, History |
| Selection | createSelection, Selection |
| Tree | createParentIndex, findParent, ancestorsOf, descendantsOf, cloneSubtree, walk, collectGarbage |
| Drop rules | canDrop, findDropTarget, findUnderfilledSlots |
| Registries | createRegistry, createWidgetRegistry, instantiateWidget, defaultPropsFor |
| Commands | createCommandRegistry, runCommand, BUILTIN_COMMANDS, registerBuiltinCommands |
| Blocks | extractBlock, insertBlockInstance, detachBlockInstance, replaceWithInstance |
| Styles | resolveComputedStyle, toCssDeclarations, toCssText, tokensToCssVariables, setToken, renameToken |
| Values | resolvePropValue, resolveProps, resolveNodeProps, referencedSources, discoverPaths |
| Binding | bindProp, unbindProp, setDataSource, setRepeat, repeatScopesFor |
| Ports | CmsAdapter, DocumentPersistence, ConflictError |
| Collaboration | EditLease, viewLease, LEASE_TIMINGS |
CmsAdapter is the interface a CMS integration implements. Supporting a new backend means writing an adapter against it and changing nothing here.
Licence
MIT.
WizeStudio is open core, and this package is on the production render path. It is MIT deliberately and contains no licensing code of any kind, which is what makes "a lapsed subscription cannot break your live site" a property of the build rather than a promise. schema, canvas-bridge, renderer-react, renderer-next and cli are MIT for the same reason; the authoring side — editor, plugin-strapi, components, cms-strapi — is commercial.
