Upgrade to the Rust core
Change your commands, configuration, authoring, and viewer imports for the Rust core release.
Before you upgrade
The Rust core release is a breaking release. Mokly reads no configuration, authoring module, generated output, or cache from an earlier release, and it has no converter for them. Plan to rebuild every catalogue that you publish.
Install @mokly/mokly as the install guide shows. npm
selects the matching viewer and native packages. Keep optional dependencies
enabled during installation, because the mokly command is a native binary
with no JavaScript fallback.
Update your commands
- Use
serveto browse. It watches your sources by default. - Use
buildto validate the catalogue, render every view, and write a static site. Replaceexport --outwithbuild --out. - Use
publishto build a private site and upload it.publishhas no--out, and it requires a clean, committed checkout. check,export, andrevieware removed. To validate, runmokly build --strict --out {directory}. Use a directory inside the repository that Git ignores, becausebuildwrites only inside the repository.- The
--watchoption ofbuildand the--buildoption ofserveare removed. Useservefor development. serve,build, andpublishaccept--base.buildandpublishaccept--no-changes.
Update your configuration
- Move your configuration into the data-only
mokly.config.json. TypeScript and JavaScript configuration anddefineConfigare removed.--confignames another JSON file. - Point
$schemaat the shippedconfig.schema.jsonfor editor checks. - Write filesystem paths, such as root directories and the renderer, relative
to the configuration file. Write root
filesglobs relative to their root, andwatch.rulespaths relative to the repository root. - Replace the
componentStylesheetsexport with the$componentStylesheetstoken in thestylesheetslist. - Replace extglob stylesheet matches such as
@(a|b)with brace alternatives such as{a,b}. An extglob match raises thestylesheet-extglobwarning. - Replace flat generated-file matches with entry routes such as
product/**/index.html. - Remove
.css: "text"loader overrides. Import CSS normally, so that Mokly delivers the stylesheet and the assets that it references.
Stop committing generated output
Remove committed mokly-generated/ output and .mokly-cache from Git.
build writes to mokly-static/ by default, and Git must ignore that
directory. Serve and Changes render in memory, and their caches live in the
operating system’s cache directory.
Update your authoring
- Give each screen and component its own props and optional variants. A variant replaces top-level prop keys. Supply valid parent props as well as variant props.
- Write
defineScreenanddefineComponentwithrender(props, context). ThecontextholdsviewportandcolorScheme. - Export one definition from each export. An array export fails. Replace uses
of a registration’s
.entrieswith its definition. - Move saved React slot content into each variant’s
slotsfield. - A Storybook file is one component. Its stories are variants, and their args
are props.
argTypesgives control hints only. definePagereturns one complete document.- Write prop schemas in the strict JSON Schema profile of
props and variants. Close each object
schema with
additionalProperties: false. - When you render a component’s
Componentwrapper, omit each optional data prop that has no value, also inside nested objects. Do not passundefined. - Keep instance names separate from entry paths.
moklyInstanceuses lowercase kebab-case and has no path separators. - In screens, components, and pages, rewrite each relative URL to an authored
file, such as an image, so that it resolves from the rendered document’s
route to
static/{repository path}. - Keep fixture data in your own source tree. Do not import fixture files from the installed package.
Update your renderer
A renderer module returns a React node or { node, resources }. Its input has
props and an entry address with kind, path, and title. It no longer
receives id, navPath, or variantOf. Mokly assembles the document and the
stylesheet links. Put theme attributes and lang on the renderer’s wrapper
element, and update CSS selectors that depend on attributes of html or
body. Each component render sets up its own providers, so pass values such
as a palette through declared component props.
Update Changes
Both sides of a comparison render from their sources with the installed
Mokly version. A committed baseline is no longer used. An entry’s path comes
from its file. Declare movedFrom when you move an entry and change its
content in the same commit. A base whose sources fail validation shows Changes
as unavailable with the diagnostics.
Update viewer imports
- Use the
@mokly/viewerroot,@mokly/viewer/browser,@mokly/viewer/data, and@mokly/viewer/styles.css. Theserverandruntimeentries are removed. @mokly/viewer/browsermounts the standalone shell.hydrateMoklyShellis removed.- Give
MoklyVieweranindexsource and adetailsource.MoklyViewerhas noviewerId. Read the sources withreadCatalogueIndexandreadEntryDetail, which replacereadCatalogue. - Type the sources with
IndexSourceandDetailSource, and the result of a detail source withDetailResult. These@mokly/viewertypes replaceCatalogueSourceandCatalogueFetcher. - Use the
PropSchematype from@mokly/viewerandvalidatePropSchemafrom@mokly/viewer/data. They replaceObjectPropSchema,DataPropSchema,DataPropField,InferProp, andControlFor. - Import
resolveInstanceandInstanceResolutionfrom@mokly/viewer, not from@mokly/mokly. - Import
ColorScheme,Viewport, andMoklyVersionErrorfrom@mokly/viewer. - Import
ComponentControl,ComponentControlLabel,ComponentInstanceRecord,ComponentPropsData,ComponentResourceOwnership,ComponentSourceLocation,ComponentStyleOwnership,InsertedComponentStylesheet,PropPrimitive, andPropValuefrom@mokly/viewer. @mokly/viewer/dataexports only the path functions, the directory names, the path and link grammar, and the prop schema validators. Its other removed exports have no public replacement.
The changelog entry of the Rust core release lists every export that the release removes.
Republish hosted catalogues
Rebuild and republish every hosted catalogue with the matching viewer and receiver. A hosted service that stores catalogues from an earlier release must reset them. The upload exchange is unchanged.
Upgrade to comparisons without review.json
A comparison generation no longer contains review.json. The catalogue index
and the entry details carry every public comparison fact.
- Read the catalogue index version 8. It adds
baseCommit, the merge base that Changes pinned, while Changes is ready. ItscomparisonUrlnames the root of the comparison generation, which ends with/, instead of a file. - Read each view’s comparison
stateandignoredIdsfrom the entry detail, beside itsresourceEvidence. A ready current screen or component also carriesbefore, the address of its base side. These are optional fields of the entry detail. - In Serve, request
/mokly-viewer/diffs/selection?path={path}instead of/mokly-viewer/diffs/review.json?path={path}. It redirects to the root of the selected generation. - A receiver of
mokly publishreads upload envelope version 3, which has nocomparisonPath, and reads Changes from themokly-viewer/index.jsonthat the Plan request carries. Mokly Cloud must accept upload version 3 and index version 8 before it stores a publication of this release. MoklyVersionErrorno longer reports areviewboundary.
Upgrade entry detail version 3
Entry detail version 3 omits usedBy and affected from current component
variants. Their pages request the parent detail and read both lists there.
Rename EntryDetailV2 to EntryDetailV3 in viewer integrations.
Upgrade to content-addressed details
The catalogue index version 9 lists a detailId in each entry record and keeps
deploymentId. Current and removed entry details use detail version 4. A
current detail carries detailId and revision. A removed detail carries
detailId and snapshotId. Details no longer carry deploymentId or
generation.
Static builds also write mokly-viewer/deployment.json with schema version 1.
The standalone shell and an embedded viewer use this file to detect a replaced
static deployment. Serve does not write or answer this file. A missing or
unreadable file does not change viewer state.
- Rename
EntryDetailV3toEntryDetailV4in viewer integrations.readCatalogueIndexreads index version 9 only, andreadEntryDetailreads detail version 4 only. - Update the viewer and each receiver that validates catalogue versions before you deploy a catalogue with these shapes. Mokly Cloud must accept index version 9 before it stores a publication of this release.