@canonical/react-motion-control 0.0.0-stage → 0.48.0

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.
Files changed (116) hide show
  1. package/LICENSE +166 -0
  2. package/README.md +124 -2
  3. package/dist/esm/MotionHint/MotionHint.js +19 -0
  4. package/dist/esm/MotionHint/MotionHint.js.map +1 -0
  5. package/dist/esm/MotionHint/index.js +2 -0
  6. package/dist/esm/MotionHint/index.js.map +1 -0
  7. package/dist/esm/MotionHint/types.js +2 -0
  8. package/dist/esm/MotionHint/types.js.map +1 -0
  9. package/dist/esm/MotionScene/Context.js +4 -0
  10. package/dist/esm/MotionScene/Context.js.map +1 -0
  11. package/dist/esm/MotionScene/MotionScene.js +76 -0
  12. package/dist/esm/MotionScene/MotionScene.js.map +1 -0
  13. package/dist/esm/MotionScene/common/Controls/Controls.js +38 -0
  14. package/dist/esm/MotionScene/common/Controls/Controls.js.map +1 -0
  15. package/dist/esm/MotionScene/common/Controls/index.js +2 -0
  16. package/dist/esm/MotionScene/common/Controls/index.js.map +1 -0
  17. package/dist/esm/MotionScene/common/Controls/types.js +2 -0
  18. package/dist/esm/MotionScene/common/Controls/types.js.map +1 -0
  19. package/dist/esm/MotionScene/common/ExportSlide/ExportSlide.js +55 -0
  20. package/dist/esm/MotionScene/common/ExportSlide/ExportSlide.js.map +1 -0
  21. package/dist/esm/MotionScene/common/ExportSlide/constants.js +11 -0
  22. package/dist/esm/MotionScene/common/ExportSlide/constants.js.map +1 -0
  23. package/dist/esm/MotionScene/common/ExportSlide/index.js +3 -0
  24. package/dist/esm/MotionScene/common/ExportSlide/index.js.map +1 -0
  25. package/dist/esm/MotionScene/common/ExportSlide/types.js +2 -0
  26. package/dist/esm/MotionScene/common/ExportSlide/types.js.map +1 -0
  27. package/dist/esm/MotionScene/common/Frame/Frame.js +19 -0
  28. package/dist/esm/MotionScene/common/Frame/Frame.js.map +1 -0
  29. package/dist/esm/MotionScene/common/Frame/index.js +2 -0
  30. package/dist/esm/MotionScene/common/Frame/index.js.map +1 -0
  31. package/dist/esm/MotionScene/common/Frame/types.js +2 -0
  32. package/dist/esm/MotionScene/common/Frame/types.js.map +1 -0
  33. package/dist/esm/MotionScene/common/Title/Title.js +27 -0
  34. package/dist/esm/MotionScene/common/Title/Title.js.map +1 -0
  35. package/dist/esm/MotionScene/common/Title/index.js +2 -0
  36. package/dist/esm/MotionScene/common/Title/index.js.map +1 -0
  37. package/dist/esm/MotionScene/common/Title/types.js +2 -0
  38. package/dist/esm/MotionScene/common/Title/types.js.map +1 -0
  39. package/dist/esm/MotionScene/common/index.js +5 -0
  40. package/dist/esm/MotionScene/common/index.js.map +1 -0
  41. package/dist/esm/MotionScene/index.js +2 -0
  42. package/dist/esm/MotionScene/index.js.map +1 -0
  43. package/dist/esm/MotionScene/types.js +2 -0
  44. package/dist/esm/MotionScene/types.js.map +1 -0
  45. package/dist/esm/MotionSlide/MotionSlide.js +42 -0
  46. package/dist/esm/MotionSlide/MotionSlide.js.map +1 -0
  47. package/dist/esm/MotionSlide/index.js +2 -0
  48. package/dist/esm/MotionSlide/index.js.map +1 -0
  49. package/dist/esm/MotionSlide/types.js +2 -0
  50. package/dist/esm/MotionSlide/types.js.map +1 -0
  51. package/dist/esm/hooks/index.js +2 -0
  52. package/dist/esm/hooks/index.js.map +1 -0
  53. package/dist/esm/hooks/types.js +2 -0
  54. package/dist/esm/hooks/types.js.map +1 -0
  55. package/dist/esm/hooks/useMotion.js +228 -0
  56. package/dist/esm/hooks/useMotion.js.map +1 -0
  57. package/dist/esm/index.js +17 -0
  58. package/dist/esm/index.js.map +1 -0
  59. package/dist/esm/styles.css +81 -0
  60. package/dist/types/MotionHint/MotionHint.d.ts +7 -0
  61. package/dist/types/MotionHint/MotionHint.d.ts.map +1 -0
  62. package/dist/types/MotionHint/index.d.ts +3 -0
  63. package/dist/types/MotionHint/index.d.ts.map +1 -0
  64. package/dist/types/MotionHint/types.d.ts +7 -0
  65. package/dist/types/MotionHint/types.d.ts.map +1 -0
  66. package/dist/types/MotionScene/Context.d.ts +4 -0
  67. package/dist/types/MotionScene/Context.d.ts.map +1 -0
  68. package/dist/types/MotionScene/MotionScene.d.ts +8 -0
  69. package/dist/types/MotionScene/MotionScene.d.ts.map +1 -0
  70. package/dist/types/MotionScene/common/Controls/Controls.d.ts +8 -0
  71. package/dist/types/MotionScene/common/Controls/Controls.d.ts.map +1 -0
  72. package/dist/types/MotionScene/common/Controls/index.d.ts +3 -0
  73. package/dist/types/MotionScene/common/Controls/index.d.ts.map +1 -0
  74. package/dist/types/MotionScene/common/Controls/types.d.ts +10 -0
  75. package/dist/types/MotionScene/common/Controls/types.d.ts.map +1 -0
  76. package/dist/types/MotionScene/common/ExportSlide/ExportSlide.d.ts +9 -0
  77. package/dist/types/MotionScene/common/ExportSlide/ExportSlide.d.ts.map +1 -0
  78. package/dist/types/MotionScene/common/ExportSlide/constants.d.ts +28 -0
  79. package/dist/types/MotionScene/common/ExportSlide/constants.d.ts.map +1 -0
  80. package/dist/types/MotionScene/common/ExportSlide/index.d.ts +4 -0
  81. package/dist/types/MotionScene/common/ExportSlide/index.d.ts.map +1 -0
  82. package/dist/types/MotionScene/common/ExportSlide/types.d.ts +23 -0
  83. package/dist/types/MotionScene/common/ExportSlide/types.d.ts.map +1 -0
  84. package/dist/types/MotionScene/common/Frame/Frame.d.ts +12 -0
  85. package/dist/types/MotionScene/common/Frame/Frame.d.ts.map +1 -0
  86. package/dist/types/MotionScene/common/Frame/index.d.ts +3 -0
  87. package/dist/types/MotionScene/common/Frame/index.d.ts.map +1 -0
  88. package/dist/types/MotionScene/common/Frame/types.d.ts +11 -0
  89. package/dist/types/MotionScene/common/Frame/types.d.ts.map +1 -0
  90. package/dist/types/MotionScene/common/Title/Title.d.ts +8 -0
  91. package/dist/types/MotionScene/common/Title/Title.d.ts.map +1 -0
  92. package/dist/types/MotionScene/common/Title/index.d.ts +3 -0
  93. package/dist/types/MotionScene/common/Title/index.d.ts.map +1 -0
  94. package/dist/types/MotionScene/common/Title/types.d.ts +18 -0
  95. package/dist/types/MotionScene/common/Title/types.d.ts.map +1 -0
  96. package/dist/types/MotionScene/common/index.d.ts +5 -0
  97. package/dist/types/MotionScene/common/index.d.ts.map +1 -0
  98. package/dist/types/MotionScene/index.d.ts +4 -0
  99. package/dist/types/MotionScene/index.d.ts.map +1 -0
  100. package/dist/types/MotionScene/types.d.ts +31 -0
  101. package/dist/types/MotionScene/types.d.ts.map +1 -0
  102. package/dist/types/MotionSlide/MotionSlide.d.ts +15 -0
  103. package/dist/types/MotionSlide/MotionSlide.d.ts.map +1 -0
  104. package/dist/types/MotionSlide/index.d.ts +3 -0
  105. package/dist/types/MotionSlide/index.d.ts.map +1 -0
  106. package/dist/types/MotionSlide/types.d.ts +26 -0
  107. package/dist/types/MotionSlide/types.d.ts.map +1 -0
  108. package/dist/types/hooks/index.d.ts +3 -0
  109. package/dist/types/hooks/index.d.ts.map +1 -0
  110. package/dist/types/hooks/types.d.ts +86 -0
  111. package/dist/types/hooks/types.d.ts.map +1 -0
  112. package/dist/types/hooks/useMotion.d.ts +16 -0
  113. package/dist/types/hooks/useMotion.d.ts.map +1 -0
  114. package/dist/types/index.d.ts +21 -0
  115. package/dist/types/index.d.ts.map +1 -0
  116. package/package.json +78 -4
@@ -0,0 +1,2 @@
1
+ export { default as Frame } from "./Frame.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Frame/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Frame/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ /**
4
+ * The title's row of a scene: what it is, its title as a link to itself, what it is about, and three dots that
5
+ * open the menu of what else a reader can do with it.
6
+ */
7
+ const Title = ({ scene, words, onSave, onExportSlide, loop, onLoop, }) => {
8
+ const [open, setOpen] = useState(false);
9
+ const [recorded, setRecorded] = useState();
10
+ const save = () => {
11
+ setOpen(false);
12
+ setRecorded(0);
13
+ void onSave(setRecorded)
14
+ // A recording can fail where a page may not draw to a canvas. The reader gets the dots back; whoever
15
+ // looks at the console gets the reason.
16
+ .catch((error) => {
17
+ console.error("motion: the scene could not be recorded.", error);
18
+ })
19
+ .finally(() => setRecorded(undefined));
20
+ };
21
+ return (_jsxs(_Fragment, { children: [_jsx("span", { className: "mo-kind", children: scene.clip ? words.clip : words.scene }), _jsxs("span", { className: "mo-head", children: [_jsx("a", { className: "mo-title", href: `#${scene.id}`, children: scene.title }), _jsx("span", { className: "mo-about", children: scene.about ? ` · ${scene.about.kind}: ${scene.about.name}` : "" })] }), _jsxs("span", { className: "mo-opt", children: [_jsx("button", { type: "button", className: "mo-more", title: recorded === undefined ? words.more : words.recording, "aria-label": words.more, "aria-expanded": open, onClick: () => setOpen(!open), children: recorded === undefined ? "⋮" : `${Math.round(recorded * 100)}%` }), _jsxs("span", { className: "mo-menu", hidden: !open, children: [_jsx("button", { type: "button", className: "mo-gif", onClick: save, children: words.gif }), _jsx("button", { type: "button", className: "mo-slide-export", onClick: () => {
22
+ setOpen(false);
23
+ onExportSlide();
24
+ }, children: "Export slide\u2026" }), _jsx("button", { type: "button", className: "mo-loop", "aria-pressed": loop, onClick: () => onLoop(!loop), children: words.loop })] })] })] }));
25
+ };
26
+ export default Title;
27
+ //# sourceMappingURL=Title.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Title.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Title/Title.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,E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C,SAAS,EACnB,KAAK,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,gBAChD,KAAK,CAAC,IAAI,mBACP,IAAI,EACnB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAE5B,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,GAAG,GACzD,EACT,gBAAM,SAAS,EAAC,SAAS,EAAC,MAAM,EAAE,CAAC,IAAI,aACrC,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,QAAQ,EAAC,OAAO,EAAE,IAAI,YACnD,KAAK,CAAC,GAAG,GACH,EACT,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,GAAG,EAAE;oCACZ,OAAO,CAAC,KAAK,CAAC,CAAC;oCACf,aAAa,EAAE,CAAC;gCAClB,CAAC,mCAGM,EAET,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,SAAS,kBACL,IAAI,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAE3B,KAAK,CAAC,IAAI,GACJ,IACJ,IACF,IACN,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as Title } from "./Title.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Title/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Title/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export { Controls } from "./Controls/index.js";
2
+ export { ExportSlide, } from "./ExportSlide/index.js";
3
+ export { Frame } from "./Frame/index.js";
4
+ export { Title } from "./Title/index.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/MotionScene/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,WAAW,GAGZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,EAAmB,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAmB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as MotionScene } from "./MotionScene.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/MotionScene/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/MotionScene/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { fitSlide } from "@canonical/motion-control/dom";
3
+ import { useLayoutEffect, useRef, useState } from "react";
4
+ import { MotionScene } from "../MotionScene/index.js";
5
+ const componentCssClassName = "mo-slide";
6
+ /** A framed slide shows the figure with its title and caption, and without its controls or its menu. */
7
+ const FRAMED = { title: { menu: false }, timeline: false };
8
+ /** A bare slide shows the screen alone. */
9
+ const BARE = { title: false, caption: false, timeline: false };
10
+ /**
11
+ * A scene on a slide of a deck: the slide at its full size, a title over the scene and a caption under it, and
12
+ * the scene centred and scaled to fill what is left, whole. Framed, it is the whole figure; bare, the screen
13
+ * alone, with the symbols over it.
14
+ *
15
+ * The layout is that of a slide the recorders of `@canonical/motion-control` write to a file, so what shows here is what a
16
+ * video or a GIF of it shows. A slide is drawn at its full size; a page that shows it smaller scales what holds
17
+ * it.
18
+ *
19
+ * `import { MotionSlide } from "@canonical/react-motion-control";`
20
+ */
21
+ const MotionSlide = ({ scene, width = 3840, height = 2400, mode = "framed", title, caption, profile, speeds, keys, outline, practice, loop, autoPlay, onStep, onEnd, className, style, children, ...rest }) => {
22
+ const fitRef = useRef(null);
23
+ const [natural, setNatural] = useState({ width: 0, height: 0 });
24
+ // The scene's own size is only known once it is laid out, and again once the page's fonts have come.
25
+ useLayoutEffect(() => {
26
+ const fit = fitRef.current;
27
+ const measure = () => setNatural({ width: fit.offsetWidth, height: fit.offsetHeight });
28
+ measure();
29
+ void document.fonts?.ready.then(measure);
30
+ }, []);
31
+ const { scale, unit } = fitSlide({ width, height, title, caption }, natural);
32
+ return (_jsxs("div", { className: [componentCssClassName, `mo-slide-${mode}`, className]
33
+ .filter(Boolean)
34
+ .join(" "), style: {
35
+ width,
36
+ height,
37
+ "--mo-slide-unit": `${unit}px`,
38
+ ...style,
39
+ }, ...rest, children: [title && _jsx("p", { className: "mo-slide-title", children: title }), _jsx("div", { className: "mo-slide-stage", children: _jsx("div", { className: "mo-slide-fit", ref: fitRef, style: { transform: `scale(${scale})` }, children: _jsx(MotionScene, { scene: scene, show: mode === "bare" ? BARE : FRAMED, profile: profile, speeds: speeds, keys: keys, outline: outline, practice: practice, loop: loop, autoPlay: autoPlay, onStep: onStep, onEnd: onEnd, children: children }) }) }), caption && _jsx("p", { className: "mo-slide-caption", children: caption })] }));
40
+ };
41
+ export default MotionSlide;
42
+ //# sourceMappingURL=MotionSlide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MotionSlide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ACrD,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as MotionSlide } from "./MotionSlide.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/MotionSlide/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/MotionSlide/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { default as useMotion } from "./useMotion.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,228 @@
1
+ import { applyMoment, assertPresent, drawSprites, installStateRules, mergeProfile, PRACTICE_AT, readLayerBox, SPEEDS, } from "@canonical/motion-control/dom";
2
+ import { describeMoment, } from "@canonical/motion-control/moment";
3
+ import { advanceClock, buildTimeline, findKeyframe, stepKeyframe as findStep, locateTime, } from "@canonical/motion-control/timeline";
4
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
5
+ /** Finds a frame among the children of the screen by its name. */
6
+ const findFrame = (screen, name) => Array.from(screen.children).find((child) => child instanceof HTMLElement && child.dataset.frame === name) ?? null;
7
+ /**
8
+ * Plays a scene over frames that are living parts of the page.
9
+ *
10
+ * The hook holds where the scene is and runs its clock. After every change of position it works out what the
11
+ * scene shows there, makes the frame in view show it, and draws the symbols over it; before the next change it
12
+ * takes everything it did to the frame back, because the frame is the application's own and is not drawn afresh.
13
+ *
14
+ * @param scene - The scene to play. Its first step must show a frame.
15
+ * @param options - The application's profile, the speeds, whether to wait for the reader at steps marked for
16
+ * practice, how keys are shown, whether to play while in view, and what to call when the step changes or the scene ends.
17
+ * @returns Refs for the screen and the layer, where the scene is, what it shows, and the ways to move it.
18
+ */
19
+ const useMotion = (...[scene, options = {}]) => {
20
+ const screenRef = useRef(null);
21
+ const layerRef = useRef(null);
22
+ const profile = useMemo(() => mergeProfile(options.profile), [options.profile]);
23
+ const speeds = useMemo(() => [...new Set([1, ...(options.speeds ?? SPEEDS)])].sort((one, other) => one - other), [options.speeds]);
24
+ const { keys, outline } = options;
25
+ const [timeline, setTimeline] = useState();
26
+ const [position, setPosition] = useState({ index: 0, progress: 0 });
27
+ const [moment, setMoment] = useState();
28
+ const [playing, setPlaying] = useState(false);
29
+ const [speed, setSpeed] = useState(1);
30
+ const [awaiting, setAwaiting] = useState();
31
+ // The reader's choice, once made, wins over the application's and the cast's.
32
+ const [chosen, setLoop] = useState();
33
+ const loop = chosen ?? options.loop ?? scene.loop !== false;
34
+ const looping = useRef(loop);
35
+ looping.current = loop;
36
+ // What the clock reads between renders: the time, the speed, and the steps the reader has done this round.
37
+ const clock = useRef(0);
38
+ const pace = useRef(1);
39
+ const practised = useRef(-1);
40
+ const callbacks = useRef(options);
41
+ callbacks.current = options;
42
+ // The frame in view is known from the scene alone, so the first paint already shows the right one.
43
+ // A scene starts with a frame, so every step has one before it.
44
+ const frame = useMemo(() => scene.steps
45
+ .slice(0, position.index + 1)
46
+ .findLast((step) => "frame" in step).frame, [scene, position.index]);
47
+ // How long typing lasts depends on the words a frame shows, and those are only on the page once it is drawn.
48
+ useLayoutEffect(() => {
49
+ const screen = assertPresent(screenRef.current, "the screen");
50
+ installStateRules(screen.ownerDocument);
51
+ setTimeline(buildTimeline(scene, (name) => {
52
+ const line = findFrame(screen, name)?.querySelector(profile.line);
53
+ return line ? profile.readLine(line) : "";
54
+ }));
55
+ clock.current = 0;
56
+ practised.current = -1;
57
+ setPosition({ index: 0, progress: 0 });
58
+ }, [scene, profile]);
59
+ // Draw the position: describe the moment, make the frame show it, draw the symbols. Undo it before the next.
60
+ useLayoutEffect(() => {
61
+ if (timeline === undefined)
62
+ return;
63
+ const screen = assertPresent(screenRef.current, "the screen");
64
+ const layer = assertPresent(layerRef.current, "the layer");
65
+ const { index, progress } = position;
66
+ const key = timeline.steps[findKeyframe(timeline, index)];
67
+ const shown = findFrame(screen, key.frame) ?? screen;
68
+ // Places are measured on the page and drawn in the layer, which a slide round the scene may scale.
69
+ const measure = (aim, fallback = [0.5, 0.5]) => {
70
+ const around = readLayerBox(layer);
71
+ const target = (aim.on ? shown.querySelector(aim.on) : null) ?? shown;
72
+ const box = target.getBoundingClientRect();
73
+ const [fx, fy] = aim.at ?? fallback;
74
+ return {
75
+ x: (box.left - around.left + box.width * fx) / around.scale,
76
+ y: (box.top - around.top + box.height * fy) / around.scale,
77
+ width: around.width,
78
+ height: around.height,
79
+ };
80
+ };
81
+ const described = describeMoment(index, progress, {
82
+ timeline,
83
+ measure,
84
+ rightToLeft: getComputedStyle(shown).direction === "rtl",
85
+ scroll: profile.scroll,
86
+ label: (name) => ({
87
+ code: findFrame(screen, name)?.dataset.code ?? "",
88
+ name,
89
+ }),
90
+ });
91
+ const applied = applyMoment(shown, described, profile, outline);
92
+ shown.style.opacity = String(described.fade);
93
+ drawSprites(layer, described.sprites, {
94
+ typing: applied.typing,
95
+ strokes: applied.strokes,
96
+ outlined: applied.outlined,
97
+ keys,
98
+ line: applied.line,
99
+ });
100
+ setMoment(described);
101
+ return () => {
102
+ applied.undo();
103
+ shown.style.opacity = "";
104
+ };
105
+ }, [position, timeline, profile, keys, outline]);
106
+ const step = position.index;
107
+ useEffect(() => {
108
+ callbacks.current.onStep?.(step);
109
+ }, [step]);
110
+ const show = useCallback((time) => {
111
+ const laid = assertPresent(timeline, "the scene's timeline");
112
+ const next = locateTime(laid, time);
113
+ clock.current =
114
+ laid.starts[next.index] +
115
+ next.progress * laid.durations[next.index];
116
+ setPosition(next);
117
+ }, [timeline]);
118
+ const pause = useCallback(() => setPlaying(false), []);
119
+ const play = useCallback(() => setPlaying(true), []);
120
+ const seek = useCallback((time) => {
121
+ setAwaiting(undefined);
122
+ show(time);
123
+ }, [show]);
124
+ // The clock: one tick per painted frame of the page, for as long as the scene plays.
125
+ useEffect(() => {
126
+ if (!playing || timeline === undefined)
127
+ return;
128
+ let last = performance.now();
129
+ let request = 0;
130
+ const tick = (now) => {
131
+ const ticked = advanceClock({ ...timeline, loop: looping.current }, clock.current, now - last, pace.current);
132
+ last = now;
133
+ if (ticked.ended || ticked.looped) {
134
+ practised.current = -1;
135
+ callbacks.current.onEnd?.();
136
+ }
137
+ if (ticked.ended) {
138
+ show(ticked.clock);
139
+ setPlaying(false);
140
+ return;
141
+ }
142
+ // A step marked for practice waits for the reader: the scene stops where the symbol shows what to do.
143
+ const { index } = locateTime(timeline, ticked.clock);
144
+ const waits = timeline.steps[index];
145
+ if (callbacks.current.practice &&
146
+ waits !== undefined &&
147
+ "do" in waits &&
148
+ waits.practice &&
149
+ index > practised.current) {
150
+ setAwaiting(index);
151
+ setPlaying(false);
152
+ clock.current =
153
+ timeline.starts[index] +
154
+ timeline.durations[index] * PRACTICE_AT;
155
+ setPosition({ index, progress: PRACTICE_AT });
156
+ return;
157
+ }
158
+ show(ticked.clock);
159
+ request = requestAnimationFrame(tick);
160
+ };
161
+ request = requestAnimationFrame(tick);
162
+ return () => cancelAnimationFrame(request);
163
+ }, [playing, timeline, show]);
164
+ // Play while in view, unless the reader asked for less motion or the application said not to.
165
+ const autoPlay = options.autoPlay;
166
+ useEffect(() => {
167
+ const screen = screenRef.current;
168
+ if (autoPlay === false ||
169
+ screen === null ||
170
+ typeof IntersectionObserver === "undefined" ||
171
+ matchMedia("(prefers-reduced-motion: reduce)").matches) {
172
+ return;
173
+ }
174
+ const watcher = new IntersectionObserver((entries) => setPlaying(entries.some((entry) => entry.isIntersecting)), { threshold: 0.3 });
175
+ watcher.observe(screen);
176
+ return () => watcher.disconnect();
177
+ }, [autoPlay]);
178
+ const stepKeyframe = useCallback((direction) => {
179
+ const laid = assertPresent(timeline, "the scene's timeline");
180
+ const index = findStep(laid, position.index, direction);
181
+ setPlaying(false);
182
+ setAwaiting(undefined);
183
+ clock.current =
184
+ laid.starts[index] +
185
+ laid.durations[index] * 0.999;
186
+ setPosition({ index, progress: 1 });
187
+ }, [timeline, position.index]);
188
+ const cycleSpeed = useCallback(() => {
189
+ const next = speeds[(speeds.indexOf(pace.current) + 1) % speeds.length];
190
+ pace.current = next;
191
+ setSpeed(pace.current);
192
+ }, [speeds]);
193
+ const press = useCallback((pressed) => {
194
+ if (awaiting === undefined)
195
+ return;
196
+ const laid = assertPresent(timeline, "the scene's timeline");
197
+ const waited = laid.steps[awaiting];
198
+ if (waited.on !== undefined && pressed.closest(waited.on) === null) {
199
+ return;
200
+ }
201
+ practised.current = awaiting;
202
+ setAwaiting(undefined);
203
+ setPlaying(true);
204
+ }, [awaiting, timeline]);
205
+ return {
206
+ screenRef,
207
+ layerRef,
208
+ frame,
209
+ timeline,
210
+ position,
211
+ moment,
212
+ profile,
213
+ playing,
214
+ speed,
215
+ speeds,
216
+ loop,
217
+ awaiting,
218
+ play,
219
+ pause,
220
+ seek,
221
+ stepKeyframe,
222
+ cycleSpeed,
223
+ setLoop,
224
+ press,
225
+ };
226
+ };
227
+ export default useMotion;
228
+ //# sourceMappingURL=useMotion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMotion.js","sourceRoot":"","sources":["../../../src/hooks/useMotion.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,MAAM,GACP,M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,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QACxE,IAAI,CAAC,OAAO,GAAG,IAAc,CAAC;QAC9B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,KAAK,GAAG,WAAW,CACvB,CAAC,OAAgB,EAAQ,EAAE;QACzB,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO;QACnC,MAAM,IAAI,GAAG,aAAa,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAoB,CAAC;QACvD,IAAI,MAAM,CAAC,EAAE,KAAK,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;YACnE,OAAO;QACT,CAAC;QACD,SAAS,CAAC,OAAO,GAAG,QAAQ,CAAC;QAC7B,WAAW,CAAC,SAAS,CAAC,CAAC;QACvB,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,EACD,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACrB,CAAC;IAEF,OAAO;QACL,SAAS;QACT,QAAQ;QACR,KAAK;QACL,QAAQ;QACR,QAAQ;QACR,MAAM;QACN,OAAO;QACP,OAAO;QACP,KAAK;QACL,MAAM;QACN,IAAI;QACJ,QAAQ;QACR,IAAI;QACJ,KAAK;QACL,IAAI;QACJ,YAAY;QACZ,UAAU;QACV,OAAO;QACP,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * React components that play motion scenes over an application's own components.
3
+ *
4
+ * `MotionScene` plays a scene in the page, `MotionHint` a small scene beside the thing it explains, and
5
+ * `MotionSlide` a scene on a slide of a deck, at the slide's full size. `useMotion` is what they are made of, for
6
+ * a figure of another shape. A scene's menu exports it on a slide, as a video or a GIF.
7
+ *
8
+ * The stylesheet of `@canonical/motion-control` and this package's own are needed once in the application:
9
+ * `import "@canonical/motion-control/style.css"; import "@canonical/react-motion-control/style.css";`
10
+ *
11
+ * @module
12
+ */
13
+ export { useMotion } from "./hooks/index.js";
14
+ export { MotionHint } from "./MotionHint/index.js";
15
+ export { MotionScene } from "./MotionScene/index.js";
16
+ export { MotionSlide } from "./MotionSlide/index.js";
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,81 @@
1
+ /* The layer of symbols is laid over the stage, so the stage is what it is placed against. */
2
+ .mo-stage {
3
+ position: relative;
4
+ }
5
+
6
+ /* The frames of a scene are living parts of the page, all there at once and laid on top of each other, so the
7
+ screen is as tall as the tallest and nothing jumps between them. Only the frame in view shows. */
8
+ .mo-live {
9
+ display: grid;
10
+ }
11
+ /* A frame fills the screen, and so does what it holds, so a shorter state is not left short of the edge. */
12
+ .mo-frame-live {
13
+ grid-area: 1 / 1;
14
+ display: grid;
15
+ min-width: 0;
16
+ visibility: hidden;
17
+ }
18
+ .mo-frame-live[data-current] {
19
+ visibility: visible;
20
+ }
21
+ .mo-frame-live[hidden] {
22
+ display: none;
23
+ }
24
+
25
+ /* The form that exports a scene on a slide: over the figure, in the panel's colours. */
26
+ .mo-export {
27
+ position: fixed;
28
+ inset: 0;
29
+ z-index: 20;
30
+ margin: auto;
31
+ width: min(420px, calc(100vw - 32px));
32
+ height: max-content;
33
+ padding: 16px 20px;
34
+ border: 1px solid var(--mo-edge, var(--mo-bg, #111));
35
+ background: var(--mo-bg, #111);
36
+ color: var(--mo-fg, #f4f4f0);
37
+ font: inherit;
38
+ }
39
+ .mo-export fieldset {
40
+ display: grid;
41
+ grid-template-columns: auto minmax(0, 1fr);
42
+ gap: 8px 12px;
43
+ margin: 0;
44
+ padding: 0;
45
+ border: 0;
46
+ }
47
+ .mo-export legend {
48
+ margin-bottom: 12px;
49
+ font-weight: 600;
50
+ }
51
+ .mo-export label {
52
+ display: contents;
53
+ }
54
+ .mo-export input,
55
+ .mo-export select,
56
+ .mo-export button {
57
+ font: inherit;
58
+ min-width: 0;
59
+ }
60
+ .mo-export-state {
61
+ min-height: 1.45em;
62
+ margin: 12px 0 0;
63
+ opacity: 0.75;
64
+ }
65
+ .mo-export-actions {
66
+ display: flex;
67
+ justify-content: end;
68
+ gap: 12px;
69
+ margin-top: 8px;
70
+ }
71
+
72
+ /* A live slide: the same layout as a recorded one; a bare slide shows the screen with no figure round it. */
73
+ .mo-slide-bare .motion-figure {
74
+ border: 0;
75
+ background: none;
76
+ }
77
+
78
+ /* A hint: a scene with nothing beside its screen but the words of its caption. */
79
+ .mo-hint {
80
+ width: min(280px, 100%);
81
+ }
@@ -0,0 +1,7 @@
1
+ import type { MotionHintProps } from "./types.js";
2
+ declare function MotionHint({ className, ...rest }: MotionHintProps): import("react/jsx-runtime").JSX.Element;
3
+ declare namespace MotionHint {
4
+ var Frame: ({ name, code, className, children, ...rest }: import("../MotionScene/index.js").FrameProps) => import("react/jsx-runtime").JSX.Element;
5
+ }
6
+ export default MotionHint;
7
+ //# sourceMappingURL=MotionHint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MotionHint.d.ts","sourceRoot":"","sources":["../../../src/MotionHint/MotionHint.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;4BAiB9B,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,eAAe;;;;eAU5C,UAAU"}
@@ -0,0 +1,3 @@
1
+ export { default as MotionHint } from "./MotionHint.js";
2
+ export type { MotionHintProps } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/MotionHint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { MotionSceneProps } from "../MotionScene/index.js";
2
+ /**
3
+ * Props for `MotionHint`: those of `MotionScene`, without the choice of what shows beside the screen, which a
4
+ * hint makes itself.
5
+ */
6
+ export type MotionHintProps = Omit<MotionSceneProps, "show" | "titlePlace">;
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/MotionHint/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { SceneFrames } from "./types.js";
2
+ declare const Context: import("react").Context<SceneFrames>;
3
+ export default Context;
4
+ //# sourceMappingURL=Context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/MotionScene/Context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,QAAA,MAAM,OAAO,sCAA+D,CAAC;eAE9D,OAAO"}
@@ -0,0 +1,8 @@
1
+ import { Frame } from "./common/index.js";
2
+ import type { MotionSceneProps } from "./types.js";
3
+ declare function MotionScene({ scene, titlePlace, show, profile, speeds, keys, outline, practice, loop, autoPlay, onStep, onEnd, className, children, ...rest }: MotionSceneProps): import("react/jsx-runtime").JSX.Element;
4
+ declare namespace MotionScene {
5
+ export { Frame };
6
+ }
7
+ export default MotionScene;
8
+ //# sourceMappingURL=MotionScene.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MotionScene.d.ts","sourceRoot":"","sources":["../../../src/MotionScene/MotionScene.tsx"],"names":[],"mappings":"AAYA,OAAO,EAGL,KAAK,EAGN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;6BAa9B,EACnB,KAAK,EACL,UAAoB,EACpB,IAAI,EACJ,OAAO,EACP,MAAM,EACN,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,KAAK,EACL,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,gBAAgB;;;;eAqIJ,WAAW"}
@@ -0,0 +1,8 @@
1
+ import type { ControlsProps } from "./types.js";
2
+ /**
3
+ * The controls' row of a scene: back, play and forward; the bar, one segment per step, to press or drag to any
4
+ * moment; and what is read off the bar, the speed and the time.
5
+ */
6
+ declare const Controls: ({ motion, words }: ControlsProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default Controls;
8
+ //# sourceMappingURL=Controls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Controls.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Controls/Controls.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;GAGG;AACH,QAAA,MAAM,QAAQ,sBAAuB,aAAa,4CAmGjD,CAAC;eAEa,QAAQ"}
@@ -0,0 +1,3 @@
1
+ export { default as Controls } from "./Controls.js";
2
+ export type { ControlsProps } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Controls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Words } from "@canonical/motion-control/dom";
2
+ import type { UseMotionResult } from "../../../hooks/index.js";
3
+ /** Props for the controls' row of a scene. */
4
+ export interface ControlsProps {
5
+ /** The scene as `useMotion` plays it. */
6
+ motion: UseMotionResult;
7
+ /** The words of the panel. */
8
+ words: Words;
9
+ }
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Controls/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,8CAA8C;AAC9C,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,MAAM,EAAE,eAAe,CAAC;IACxB,8BAA8B;IAC9B,KAAK,EAAE,KAAK,CAAC;CACd"}