@senseihq/emaki-vue 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -22,7 +22,8 @@ import { MotionScene, MotionShow, ScenePlayer, ShowPage } from '@senseihq/emaki-
22
22
 
23
23
  Every component takes `mode`: `light`, `dark` or `auto` (the default). Auto follows the page's `data-mode` (as rokkit's
24
24
  `themable` sets it), else the OS, and the scenes redraw when it changes. A film draws dark only if it has a dark look
25
- (see @senseihq/emaki); `ShowPage` captures light unless asked.
25
+ (see @senseihq/emaki); `ShowPage` captures light unless asked, and its `src` (`json`/`js`) forces where scenes come
26
+ from.
26
27
 
27
28
  Call `setupMotion({ source, site, logos })` once on the client first. Composables: `useScenePlayer(player)` (a
28
29
  reactive snapshot of a `ScenePlayerState`) and `useShowState(showRef)`.
@@ -174,10 +174,12 @@ export declare const MotionShow: import("vue").DefineComponent<import("vue").Ext
174
174
  start: number;
175
175
  design: number;
176
176
  holds: [number, number][];
177
+ voice?: number;
177
178
  id: string;
178
179
  name: string;
179
180
  dur: number;
180
181
  desc?: string;
182
+ settle?: number;
181
183
  }[];
182
184
  };
183
185
  readonly state: {
@@ -186,7 +188,11 @@ export declare const MotionShow: import("vue").DefineComponent<import("vue").Ext
186
188
  playing: boolean;
187
189
  sound: boolean;
188
190
  layout: Layout;
191
+ started: boolean;
189
192
  };
193
+ start(): Promise<void>;
194
+ replay(): void;
195
+ restart(): void;
190
196
  fit(w: number, h: number): void;
191
197
  go: (i: number) => void;
192
198
  next: () => void;
@@ -227,6 +233,11 @@ export declare const ShowPage: import("vue").DefineComponent<import("vue").Extra
227
233
  type: PropType<Mode>;
228
234
  default: undefined;
229
235
  };
236
+ /** Force scenes from their JSON or their code modules (parity checks). */
237
+ src: {
238
+ type: PropType<"json" | "js">;
239
+ default: undefined;
240
+ };
230
241
  capture: {
231
242
  type: BooleanConstructor;
232
243
  default: boolean;
@@ -251,6 +262,11 @@ export declare const ShowPage: import("vue").DefineComponent<import("vue").Extra
251
262
  type: PropType<Mode>;
252
263
  default: undefined;
253
264
  };
265
+ /** Force scenes from their JSON or their code modules (parity checks). */
266
+ src: {
267
+ type: PropType<"json" | "js">;
268
+ default: undefined;
269
+ };
254
270
  capture: {
255
271
  type: BooleanConstructor;
256
272
  default: boolean;
@@ -259,5 +275,6 @@ export declare const ShowPage: import("vue").DefineComponent<import("vue").Extra
259
275
  layout: Layout;
260
276
  locale: string;
261
277
  mode: Mode;
278
+ src: "json" | "js";
262
279
  capture: boolean;
263
280
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1,7 +1,7 @@
1
1
  // Vue 3 components over @senseihq/emaki, written as render functions so they need no SFC compiler.
2
2
  // Client-only (they need the DOM): in Nuxt wrap them in <ClientOnly>. Call setupMotion(...) once on the client first.
3
3
  import { defineComponent, h, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue';
4
- import { attachScene, createShow, figurePlayer, installCapture } from '@senseihq/emaki';
4
+ import { attachScene, createShow, figurePlayer, installCapture, showKey } from '@senseihq/emaki';
5
5
  import { useScenePlayer, useShowState, useSize } from './composables.js';
6
6
  function attach(player, locale, mode, autoplay) {
7
7
  const box = ref(null), host = ref(null);
@@ -96,24 +96,9 @@ export const MotionShow = defineComponent({
96
96
  watch(() => props.layout, (l) => show.value?.setLayout(l));
97
97
  watch([size, () => st.value?.layout], () => show.value?.fit(size.value.w, size.value.h));
98
98
  expose({ show });
99
- const onKeydown = (e) => {
100
- const s = show.value;
101
- if (!s)
102
- return;
103
- const k = e.key.toLowerCase();
104
- if (k === 'arrowright')
105
- s.next();
106
- else if (k === 'arrowleft')
107
- s.prev();
108
- else if (k === ' ') {
109
- s.toggle();
110
- e.preventDefault();
111
- }
112
- else if (k === 'm')
113
- s.setSound(!s.state.sound);
114
- else if (k === 'o')
115
- s.setLayout(s.state.layout === 'landscape' ? 'portrait' : 'landscape');
116
- };
99
+ // Every key (←/→, Space, M, O, R, Home, F) from the core, so all players answer the same way.
100
+ const onKeydown = (e) => { if (show.value && showKey(show.value, e, e.currentTarget))
101
+ e.preventDefault(); };
117
102
  const btn = 'min-width:34px;height:34px;border-radius:17px;border:1px solid currentColor;background:none;color:inherit;cursor:pointer;padding:0 10px';
118
103
  return () => {
119
104
  const s = show.value, x = st.value;
@@ -142,13 +127,15 @@ export const ShowPage = defineComponent({
142
127
  locale: { type: String, default: 'en' },
143
128
  /** Capture renders light unless asked; the interactive player follows the page (auto). */
144
129
  mode: { type: String, default: undefined },
130
+ /** Force scenes from their JSON or their code modules (parity checks). */
131
+ src: { type: String, default: undefined },
145
132
  capture: { type: Boolean, default: false },
146
133
  },
147
134
  setup(props) {
148
135
  const host = ref(null);
149
136
  let s = null;
150
137
  onMounted(async () => { if (props.capture)
151
- s = await installCapture(host.value, props.film, props.layout, props.locale, props.mode ?? 'light'); });
138
+ s = await installCapture(host.value, props.film, props.layout, props.locale, { mode: props.mode ?? 'light', src: props.src }); });
152
139
  onBeforeUnmount(() => s?.destroy());
153
140
  return () => props.capture
154
141
  ? h('div', { ref: host })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senseihq/emaki-vue",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Vue 3 components and composables for motion stories: article figures, the story player, a controlled scene player and the video capture page.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "vue": "^3.4.0"
32
32
  },
33
33
  "dependencies": {
34
- "@senseihq/emaki": "0.1.0"
34
+ "@senseihq/emaki": "0.1.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "vue": "^3.5.13"
package/src/components.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Vue 3 components over @senseihq/emaki, written as render functions so they need no SFC compiler.
2
2
  // Client-only (they need the DOM): in Nuxt wrap them in <ClientOnly>. Call setupMotion(...) once on the client first.
3
3
  import { defineComponent, h, onBeforeUnmount, onMounted, ref, shallowRef, watch, type PropType } from 'vue';
4
- import { attachScene, createShow, figurePlayer, installCapture, type AttachedScene, type Layout, type Mode, type ScenePlayerState } from '@senseihq/emaki';
4
+ import { attachScene, createShow, figurePlayer, installCapture, showKey, type AttachedScene, type Layout, type Mode, type ScenePlayerState } from '@senseihq/emaki';
5
5
  import { useScenePlayer, useShowState, useSize, type Show } from './composables.js';
6
6
 
7
7
  function attach(player: () => ScenePlayerState, locale: () => string, mode: () => Mode, autoplay: boolean) {
@@ -96,14 +96,8 @@ export const MotionShow = defineComponent({
96
96
  watch(() => props.layout, (l) => show.value?.setLayout(l));
97
97
  watch([size, () => st.value?.layout], () => show.value?.fit(size.value.w, size.value.h));
98
98
  expose({ show });
99
- const onKeydown = (e: KeyboardEvent) => {
100
- const s = show.value; if (!s) return;
101
- const k = e.key.toLowerCase();
102
- if (k === 'arrowright') s.next(); else if (k === 'arrowleft') s.prev();
103
- else if (k === ' ') { s.toggle(); e.preventDefault(); }
104
- else if (k === 'm') s.setSound(!s.state.sound);
105
- else if (k === 'o') s.setLayout(s.state.layout === 'landscape' ? 'portrait' : 'landscape');
106
- };
99
+ // Every key (←/→, Space, M, O, R, Home, F) from the core, so all players answer the same way.
100
+ const onKeydown = (e: KeyboardEvent) => { if (show.value && showKey(show.value, e, e.currentTarget as Element)) e.preventDefault(); };
107
101
  const btn = 'min-width:34px;height:34px;border-radius:17px;border:1px solid currentColor;background:none;color:inherit;cursor:pointer;padding:0 10px';
108
102
  return () => {
109
103
  const s = show.value, x = st.value;
@@ -133,12 +127,14 @@ export const ShowPage = defineComponent({
133
127
  locale: { type: String, default: 'en' },
134
128
  /** Capture renders light unless asked; the interactive player follows the page (auto). */
135
129
  mode: { type: String as PropType<Mode>, default: undefined },
130
+ /** Force scenes from their JSON or their code modules (parity checks). */
131
+ src: { type: String as PropType<'json' | 'js'>, default: undefined },
136
132
  capture: { type: Boolean, default: false },
137
133
  },
138
134
  setup(props) {
139
135
  const host = ref<HTMLElement | null>(null);
140
136
  let s: Show | null = null;
141
- onMounted(async () => { if (props.capture) s = await installCapture(host.value!, props.film, props.layout, props.locale, props.mode ?? 'light'); });
137
+ onMounted(async () => { if (props.capture) s = await installCapture(host.value!, props.film, props.layout, props.locale, { mode: props.mode ?? 'light', src: props.src }); });
142
138
  onBeforeUnmount(() => s?.destroy());
143
139
  return () => props.capture
144
140
  ? h('div', { ref: host })