@liqweed/motion-kit 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motion-kit",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Deterministic animated diagrams: scenes as pure functions of time for live pages, Slidev, slide frames, baked SVG and video; plus project logos/icons.",
|
|
5
5
|
"author": { "name": "Ophir Radnitz" },
|
|
6
6
|
"repository": "https://github.com/liqweed/motion-kit",
|
package/docs/spec/technique.md
CHANGED
|
@@ -52,8 +52,9 @@ A scene is a plain object (`runtime/scene.mjs:1-18`).
|
|
|
52
52
|
run `validateScene`. The CLI (`--options`), the vendored gate and the Astro
|
|
53
53
|
adapter call `sceneFromModule`, so one module with the same options, format
|
|
54
54
|
and locale gives the same scene everywhere. A `build` page calls the factory
|
|
55
|
-
with the same object, its `kit` being the bundled
|
|
56
|
-
built the scene once
|
|
55
|
+
with the same object, its `kit` being the bundled `KIT` (the same names as in
|
|
56
|
+
Node: `test/runtime.test.mjs` checks), after the CLI has built the scene once
|
|
57
|
+
through `sceneFromModule`.
|
|
57
58
|
- A custom module MUST take the runtime from `kit`, or import only from
|
|
58
59
|
`runtime/` with single-line relative `import { … } from "./x.mjs";`
|
|
59
60
|
statements and use only the export forms the inliner supports, or `build`
|
|
@@ -485,9 +486,10 @@ that removes every listener, observer and mark they added.
|
|
|
485
486
|
works under `connect-src 'none'` and from `file://`.
|
|
486
487
|
- MUST pre-render the player's first state (`playerMarkup`, `PLAYER_CSS`,
|
|
487
488
|
`themeCss`) and set `<html lang>` to the scene locale (`lib/build.mjs`).
|
|
488
|
-
- A custom module is built with the caller's `--options` and `kit`:
|
|
489
|
-
runtime module is a bundle entry,
|
|
490
|
-
|
|
489
|
+
- A custom module is built with the caller's `--options` and `kit`: the
|
|
490
|
+
runtime's `kit` module is a bundle entry, and its `KIT` is what the module
|
|
491
|
+
receives, the isometric helpers (§4.9) included. The page-link helpers
|
|
492
|
+
(§10.2.2) are bundled too (`MotionKitRuntime.scrollSteps`,
|
|
491
493
|
`MotionKitRuntime.linkSteps`).
|
|
492
494
|
- The CLI MUST refuse a scene that fails the gate (`cli/motion-kit.mjs:112-113`)
|
|
493
495
|
and bundled code containing `</script>` (`:115`).
|
package/lib/build.mjs
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* (final frame, step list, colours) is pre-rendered into the markup, so it
|
|
7
7
|
* reads correctly before (or without) JS, and mounting moves nothing.
|
|
8
8
|
*
|
|
9
|
-
* A custom module gets its scene options and `kit` (
|
|
10
|
-
* as it does from the CLI.
|
|
9
|
+
* A custom module gets its scene options and `kit` (`KIT`, the same object the
|
|
10
|
+
* CLI hands it), as it does from the CLI.
|
|
11
11
|
*/
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import { bundle } from "./bundle.mjs";
|
|
@@ -26,8 +26,11 @@ const scriptJson = (/** @type {unknown} */ value) => JSON.stringify(value).repla
|
|
|
26
26
|
* options: scene options for a custom module's factory
|
|
27
27
|
*/
|
|
28
28
|
export function buildHtml(loaded, o) {
|
|
29
|
-
//
|
|
30
|
-
|
|
29
|
+
// The bundler exposes only an entry's own exports, never its dependencies'.
|
|
30
|
+
// `kit` is an entry so that KIT, the object a module gets in Node, reaches
|
|
31
|
+
// the page whole (iso included); a name added to KIT needs no change here.
|
|
32
|
+
// The other entries are the page's own: player, links, scene types.
|
|
33
|
+
const entries = ["motion", "svg", "style", "wrap", "scene", "types/index", "player", "links", "kit"].map((m) => `${RUNTIME}${m}.mjs`);
|
|
31
34
|
const runtimeCount = entries.length;
|
|
32
35
|
if (loaded.kind === "module") entries.push(loaded.file);
|
|
33
36
|
// MotionKitRuntime is the runtime alone: a custom module's exports, spread
|
|
@@ -39,7 +42,7 @@ export function buildHtml(loaded, o) {
|
|
|
39
42
|
const make =
|
|
40
43
|
loaded.kind === "spec"
|
|
41
44
|
? `MotionKit.createScene(${scriptJson(loaded.spec)}, ${scriptJson({ format: o.format, locale: o.locale })})`
|
|
42
|
-
: `MotionKitRuntime.validateScene(MotionKit.default(Object.assign(${scriptJson(o.options ?? {})}, ${scriptJson({ format: o.format, locale: o.locale })}, { kit: MotionKitRuntime })))`;
|
|
45
|
+
: `MotionKitRuntime.validateScene(MotionKit.default(Object.assign(${scriptJson(o.options ?? {})}, ${scriptJson({ format: o.format, locale: o.locale })}, { kit: MotionKitRuntime.KIT })))`;
|
|
43
46
|
const lang = scene.locale ?? o.locale ?? "en";
|
|
44
47
|
return `<!doctype html>
|
|
45
48
|
<html lang="${escapeHtml(lang)}">
|
package/package.json
CHANGED
package/runtime/kit.mjs
CHANGED
|
@@ -45,11 +45,13 @@ export const KIT = Object.freeze({
|
|
|
45
45
|
|
|
46
46
|
const RESERVED = ["format", "locale", "kit"];
|
|
47
47
|
|
|
48
|
+
/** @import { Scene } from "./scene.mjs" */
|
|
49
|
+
|
|
48
50
|
/**
|
|
49
51
|
* Build and validate a scene from a module's default export.
|
|
50
52
|
* @param {unknown} make the module's default export
|
|
51
53
|
* @param {{ format?: string, locale?: string, options?: Record<string, unknown> | null }} [opts]
|
|
52
|
-
* @returns {
|
|
54
|
+
* @returns {Scene}
|
|
53
55
|
*/
|
|
54
56
|
export function sceneFromModule(make, { format = "16:9", locale = "en", options } = {}) {
|
|
55
57
|
if (typeof make !== "function") throw new TypeError("a scene module's default export must be (opts) => scene");
|
|
@@ -106,8 +106,8 @@ export default function make({ format = "1:1", kit }) {
|
|
|
106
106
|
}
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
Every command supports this, `motion-kit build` included (it bundles the
|
|
110
|
-
|
|
109
|
+
Every command supports this, `motion-kit build` included (it bundles the runtime and passes
|
|
110
|
+
`KIT` as `kit`, the isometric helpers included). A module that imports instead must use
|
|
111
111
|
relative imports to a vendored runtime.
|
|
112
112
|
|
|
113
113
|
## Isometric and 3D-looking scenes
|