@olenbetong/synergi-course 2.0.0 → 2.2.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 (96) hide show
  1. package/es/chrome/CategoryHeader.css +28 -0
  2. package/es/completion/CourseCompletion.css +53 -0
  3. package/es/completion/CourseCompletion.d.ts +32 -0
  4. package/es/completion/CourseCompletion.js +60 -0
  5. package/es/document/cues.d.ts +51 -6
  6. package/es/document/cues.js +117 -14
  7. package/es/document/effects.d.ts +30 -0
  8. package/es/document/effects.js +76 -0
  9. package/es/document/schema.d.ts +2722 -346
  10. package/es/document/schema.js +172 -5
  11. package/es/document/validate.d.ts +2 -1
  12. package/es/document/validate.js +83 -16
  13. package/es/index.d.ts +8 -3
  14. package/es/index.js +6 -2
  15. package/es/media/Media.css +16 -0
  16. package/es/media/icons.d.ts +1 -0
  17. package/es/media/icons.js +3 -0
  18. package/es/player/CoursePlayer.css +76 -0
  19. package/es/player/CoursePlayer.js +28 -13
  20. package/es/player/PlayerBars.d.ts +32 -0
  21. package/es/player/PlayerBars.js +14 -0
  22. package/es/player/useFullScreen.d.ts +17 -0
  23. package/es/player/useFullScreen.js +83 -0
  24. package/es/player/useMediaQuery.d.ts +7 -0
  25. package/es/player/useMediaQuery.js +16 -0
  26. package/es/steps/Blocks.d.ts +43 -3
  27. package/es/steps/Blocks.js +114 -26
  28. package/es/steps/Markdown.d.ts +7 -1
  29. package/es/steps/Markdown.js +31 -4
  30. package/es/steps/QuizStepView.d.ts +2 -1
  31. package/es/steps/QuizStepView.js +20 -10
  32. package/es/steps/RevealMotion.d.ts +29 -0
  33. package/es/steps/RevealMotion.js +55 -0
  34. package/es/steps/SlideStepView.d.ts +5 -3
  35. package/es/steps/SlideStepView.js +43 -10
  36. package/es/steps/StepBodyProps.d.ts +16 -1
  37. package/es/steps/StepView.css +390 -16
  38. package/es/steps/StepView.d.ts +36 -4
  39. package/es/steps/StepView.js +21 -5
  40. package/es/steps/motion.d.ts +59 -0
  41. package/es/steps/motion.js +136 -0
  42. package/es/transitions/Transitions.css +114 -0
  43. package/es/transitions/plan.d.ts +66 -0
  44. package/es/transitions/plan.js +185 -0
  45. package/es/transitions/playStepTransition.d.ts +23 -0
  46. package/es/transitions/playStepTransition.js +131 -0
  47. package/es/types.d.ts +16 -3
  48. package/package.json +4 -4
  49. package/src/chrome/CategoryHeader.css +28 -0
  50. package/src/completion/CourseCompletion.css +53 -0
  51. package/src/completion/CourseCompletion.test.tsx +45 -0
  52. package/src/completion/CourseCompletion.tsx +98 -0
  53. package/src/document/box.test.ts +234 -0
  54. package/src/document/cues.ts +143 -13
  55. package/src/document/document.test.ts +1 -1
  56. package/src/document/effects.ts +106 -0
  57. package/src/document/reveal.test.ts +263 -0
  58. package/src/document/schema.ts +203 -5
  59. package/src/document/validate.ts +88 -18
  60. package/src/index.ts +46 -1
  61. package/src/media/Media.css +16 -0
  62. package/src/media/icons.tsx +8 -0
  63. package/src/player/CoursePlayer.css +76 -0
  64. package/src/player/CoursePlayer.test.tsx +70 -6
  65. package/src/player/CoursePlayer.tsx +91 -60
  66. package/src/player/PlayerBars.tsx +106 -0
  67. package/src/player/fullScreen.test.tsx +70 -0
  68. package/src/player/useFullScreen.ts +91 -0
  69. package/src/player/useMediaQuery.ts +21 -0
  70. package/src/steps/Blocks.test.ts +34 -0
  71. package/src/steps/Blocks.tsx +219 -32
  72. package/src/steps/Box.test.tsx +95 -0
  73. package/src/steps/Markdown.test.tsx +46 -0
  74. package/src/steps/Markdown.tsx +42 -4
  75. package/src/steps/Presence.test.tsx +82 -0
  76. package/src/steps/QuizStepView.test.tsx +79 -0
  77. package/src/steps/QuizStepView.tsx +34 -12
  78. package/src/steps/RevealMotion.ts +66 -0
  79. package/src/steps/SlideStepView.tsx +74 -12
  80. package/src/steps/StepBodyProps.ts +16 -1
  81. package/src/steps/StepView.css +390 -16
  82. package/src/steps/StepView.test.tsx +157 -0
  83. package/src/steps/StepView.tsx +108 -19
  84. package/src/steps/motion.test.ts +98 -0
  85. package/src/steps/motion.ts +178 -0
  86. package/src/steps/visibility.test.ts +24 -0
  87. package/src/transitions/Transitions.css +114 -0
  88. package/src/transitions/plan.ts +258 -0
  89. package/src/transitions/playStepTransition.ts +162 -0
  90. package/src/transitions/transitions.test.ts +274 -0
  91. package/src/types.ts +16 -3
  92. package/es/Transitions.css +0 -55
  93. package/es/Transitions.d.ts +0 -10
  94. package/es/Transitions.js +0 -24
  95. package/src/Transitions.css +0 -55
  96. package/src/Transitions.ts +0 -35
@@ -3,7 +3,7 @@
3
3
  * slide rows, and each row has one step document per language, so nothing in here is keyed by
4
4
  * language and every text is a plain string.
5
5
  */
6
- import { array, boolean, literal, minLength, minValue, number, optional, picklist, pipe, strictObject, string, variant, } from "valibot";
6
+ import { array, boolean, literal, maxValue, minLength, minValue, number, optional, picklist, pipe, regex, strictObject, string, union, variant, } from "valibot";
7
7
  export const STEP_SCHEMA_VERSION = 2;
8
8
  let id = pipe(string(), minLength(1));
9
9
  let text = string();
@@ -14,6 +14,15 @@ let text = string();
14
14
  */
15
15
  let source = pipe(string(), minLength(1));
16
16
  let seconds = pipe(number(), minValue(0));
17
+ /** The colour scales a box, a callout or a framed canvas text can take. `brand` is the company theme's own. */
18
+ export const TONES = ["neutral", "info", "success", "warning", "danger", "brand"];
19
+ /** The colour of a surface. Default `neutral`. */
20
+ let tone = optional(picklist(TONES));
21
+ /**
22
+ * `bordered` (the default): a tinted surface with a frame and a coloured edge. `filled`: a solid
23
+ * surface in the tone's colour, with the text in its contrast colour.
24
+ */
25
+ let surfaceVariant = optional(picklist(["bordered", "filled"]));
17
26
  /**
18
27
  * A stretch of narration or video: what is said, and when. The text is also the subtitle. A cue
19
28
  * without text is a marker: something on the slide can show or go away at it, but no subtitle is
@@ -50,17 +59,40 @@ export const narrationSchema = strictObject({
50
59
  * When a block shows. Without any of these it is there from the start.
51
60
  * `reveal: "step"` shows it on the next press of Next, in document order. `revealAt` shows it
52
61
  * when the cue with that id starts. `hideAt` removes it again when that cue starts.
62
+ *
63
+ * A part waiting to be shown keeps its place, so the slide does not jump when it comes. A part
64
+ * that also has `hideAt` is a passing one and takes no place before it shows or after it has
65
+ * gone, so parts that follow each other in time (one scene per stretch of the narration) stand
66
+ * in the same spot.
67
+ *
68
+ * `reveal: "with-previous"` is not a press of its own: the part shows when the nearest part above
69
+ * it (in document order) that waits to be shown does, by Next or by its cue. Without such a part
70
+ * it is there from the start. `delay` shows a waiting part that many milliseconds after it is due.
53
71
  */
54
72
  let timing = {
55
- reveal: optional(literal("step")),
73
+ reveal: optional(picklist(["step", "with-previous"])),
56
74
  revealAt: optional(id),
57
75
  hideAt: optional(id),
76
+ delay: optional(pipe(number(), minValue(0), maxValue(5000))),
77
+ };
78
+ let milliseconds = {
79
+ /** Milliseconds before it starts, 0 to 5000. */
80
+ delay: optional(pipe(number(), minValue(0), maxValue(5000))),
81
+ /** Milliseconds it takes, 50 to 3000. Default 300. */
82
+ duration: optional(pipe(number(), minValue(50), maxValue(3000))),
83
+ };
84
+ /** How a heading or text is dressed: `caps` writes it in capitals, `shadow` gives the letters a shadow, for words on a picture. */
85
+ let look = {
86
+ caps: optional(boolean()),
87
+ shadow: optional(boolean()),
58
88
  };
59
89
  export const headingBlockSchema = strictObject({
60
90
  id,
61
91
  type: literal("heading"),
92
+ /** One line of Markdown. */
62
93
  text,
63
94
  level: optional(picklist([1, 2, 3])),
95
+ ...look,
64
96
  ...timing,
65
97
  });
66
98
  export const textBlockSchema = strictObject({
@@ -68,11 +100,14 @@ export const textBlockSchema = strictObject({
68
100
  type: literal("text"),
69
101
  /** Markdown. */
70
102
  text,
103
+ ...look,
71
104
  ...timing,
72
105
  });
73
106
  export const listItemSchema = strictObject({
74
107
  id,
75
108
  text,
109
+ /** A point under the point above it: 1 for a sub-point, 2 for a point under a sub-point. */
110
+ indent: optional(picklist([1, 2])),
76
111
  ...timing,
77
112
  });
78
113
  export const listBlockSchema = strictObject({
@@ -106,7 +141,8 @@ export const calloutBlockSchema = strictObject({
106
141
  /** Markdown. */
107
142
  text,
108
143
  /** The colour of the box. Default `neutral`. */
109
- tone: optional(picklist(["neutral", "info", "success", "warning"])),
144
+ tone,
145
+ variant: surfaceVariant,
110
146
  ...timing,
111
147
  });
112
148
  /** A link that plays a video in a dialog on top of the slide. */
@@ -117,6 +153,46 @@ export const videoLinkBlockSchema = strictObject({
117
153
  media: mediaSchema,
118
154
  ...timing,
119
155
  });
156
+ /**
157
+ * A block that shows nothing and acts on other parts while it is shown (by its timing, like any
158
+ * part): it moves, scales or fades its targets, and they go back when it stops. `move` is in the
159
+ * slide's text size (1 is about the height of a letter of the ordinary text), or for an item on a
160
+ * canvas in percent of the canvas's width (`x`) and height (`y`). Several effects on one part
161
+ * combine: moves add up, scales multiply, and the last opacity in the document wins.
162
+ */
163
+ export const effectBlockSchema = strictObject({
164
+ id,
165
+ type: literal("effect"),
166
+ /** The id of a part of the slide, or several. Not an effect. */
167
+ target: union([id, pipe(array(id), minLength(1))]),
168
+ move: optional(strictObject({ x: optional(number()), y: optional(number()) })),
169
+ scale: optional(pipe(number(), minValue(0))),
170
+ opacity: optional(pipe(number(), minValue(0), maxValue(1))),
171
+ ...timing,
172
+ /** Milliseconds the change takes, 50 to 3000. Default 300. `delay` holds it back after it is due. */
173
+ duration: milliseconds.duration,
174
+ });
175
+ /** Every block that can stand inside a box. A box holds no box, callout, columns or canvas. */
176
+ export const boxContentSchema = variant("type", [
177
+ headingBlockSchema,
178
+ textBlockSchema,
179
+ listBlockSchema,
180
+ imageBlockSchema,
181
+ quoteBlockSchema,
182
+ videoLinkBlockSchema,
183
+ effectBlockSchema,
184
+ ]);
185
+ /** A coloured box around other blocks, e.g. a heading and a list of steps. */
186
+ export const boxBlockSchema = strictObject({
187
+ id,
188
+ type: literal("box"),
189
+ /** The colour of the box. Default `neutral`. */
190
+ tone,
191
+ variant: surfaceVariant,
192
+ /** Headings, texts, lists, images, quotes and video links, and effects. No box, callout, columns or canvas. */
193
+ blocks: array(boxContentSchema),
194
+ ...timing,
195
+ });
120
196
  /** Every block that can stand inside a column. Columns do not nest. */
121
197
  export const contentBlockSchema = variant("type", [
122
198
  headingBlockSchema,
@@ -125,7 +201,9 @@ export const contentBlockSchema = variant("type", [
125
201
  imageBlockSchema,
126
202
  quoteBlockSchema,
127
203
  calloutBlockSchema,
204
+ boxBlockSchema,
128
205
  videoLinkBlockSchema,
206
+ effectBlockSchema,
129
207
  ]);
130
208
  export const columnSchema = strictObject({
131
209
  id,
@@ -137,6 +215,55 @@ export const columnsBlockSchema = strictObject({
137
215
  columns: pipe(array(columnSchema), minLength(2)),
138
216
  ...timing,
139
217
  });
218
+ /**
219
+ * Where an item stands on its canvas, in percent of the canvas: `x` from the left edge or `right`
220
+ * from the right one, `y` from the top or `bottom` from the bottom. Without a width a text is as
221
+ * wide as its words and an image keeps its proportions.
222
+ */
223
+ let canvasPlace = {
224
+ x: optional(number()),
225
+ y: optional(number()),
226
+ right: optional(number()),
227
+ bottom: optional(number()),
228
+ width: optional(number()),
229
+ height: optional(number()),
230
+ };
231
+ export const canvasTextSchema = strictObject({
232
+ id,
233
+ type: literal("text"),
234
+ /** Markdown. */
235
+ text,
236
+ /** `solid`: on a white surface that covers what is under it. `frame`: the same with a coloured frame. */
237
+ surface: optional(picklist(["none", "solid", "frame"])),
238
+ /** The colour of the frame. Default `neutral`. */
239
+ tone,
240
+ /** The text size, as a factor of the canvas's normal size. Default 1. */
241
+ size: optional(pipe(number(), minValue(0.1))),
242
+ ...canvasPlace,
243
+ ...timing,
244
+ });
245
+ export const canvasImageSchema = strictObject({
246
+ id,
247
+ type: literal("image"),
248
+ src: source,
249
+ alt: optional(text),
250
+ ...canvasPlace,
251
+ ...timing,
252
+ });
253
+ /**
254
+ * A figure with a coordinate system of its own: images and texts placed by percent on an area of
255
+ * fixed proportions, later items on top of earlier ones. Everything scales with the canvas, the
256
+ * text included, so the parts keep their places at any size. Always light, like a sheet of paper,
257
+ * so a surface can cover a part of a picture. Does not stand in a column.
258
+ */
259
+ export const canvasBlockSchema = strictObject({
260
+ id,
261
+ type: literal("canvas"),
262
+ /** Width to height, e.g. `16/9` (the default) or `4/3`. */
263
+ aspect: optional(pipe(string(), regex(/^\d+(\.\d+)?\s*\/\s*\d+(\.\d+)?$/))),
264
+ items: array(variant("type", [canvasTextSchema, canvasImageSchema])),
265
+ ...timing,
266
+ });
140
267
  export const blockSchema = variant("type", [
141
268
  headingBlockSchema,
142
269
  textBlockSchema,
@@ -144,8 +271,11 @@ export const blockSchema = variant("type", [
144
271
  imageBlockSchema,
145
272
  quoteBlockSchema,
146
273
  calloutBlockSchema,
274
+ boxBlockSchema,
147
275
  videoLinkBlockSchema,
276
+ effectBlockSchema,
148
277
  columnsBlockSchema,
278
+ canvasBlockSchema,
149
279
  ]);
150
280
  let version = literal(STEP_SCHEMA_VERSION);
151
281
  /**
@@ -153,16 +283,50 @@ let version = literal(STEP_SCHEMA_VERSION);
153
283
  * played to the end and the step is done, the same way as a press of Next. Never from the last step.
154
284
  */
155
285
  let advance = optional(literal("auto"));
286
+ /**
287
+ * One animation of a step change. `on: "enter"` runs as the step comes in, `on: "exit"` as it
288
+ * leaves. `target` is `step` (the default: the whole step box), `content` or `background` (a
289
+ * slide's blocks or its background image) or the id of a part of the step. `slide` comes from
290
+ * (or leaves to) `from`: right on enter and left on exit by default, mirrored when the learner
291
+ * goes back. Several items on one target run together, each with its own delay and duration.
292
+ */
293
+ export const transitionSchema = strictObject({
294
+ on: picklist(["enter", "exit"]),
295
+ effect: picklist(["fade", "slide", "zoom", "none"]),
296
+ from: optional(picklist(["left", "right", "top", "bottom"])),
297
+ target: optional(pipe(string(), minLength(1))),
298
+ ...milliseconds,
299
+ });
300
+ /**
301
+ * Left out, the step fades out and the next fades in. Given, it replaces that default on both
302
+ * sides: only what is listed animates, and an empty list changes the step at once.
303
+ */
304
+ let transitions = optional(array(transitionSchema));
156
305
  /** Blocks on a page, optionally narrated. */
157
306
  export const slideStepSchema = strictObject({
158
307
  schemaVersion: version,
159
308
  type: literal("slide"),
160
- /** `title`: a title page, the first heading large and centred, typically over a background image. */
161
- layout: optional(picklist(["default", "centered", "title"])),
309
+ /**
310
+ * `title`: a title page, the first heading large and centred, typically over a background image.
311
+ * `banner`: a title page whose background image is a band across the step, in its own
312
+ * proportions and with a coloured border above and below, with the blocks on top of it.
313
+ */
314
+ layout: optional(picklist(["default", "centered", "title", "banner"])),
162
315
  /** A background image behind the blocks. */
163
316
  background: optional(source),
317
+ /**
318
+ * How wide the blocks may get: `narrow` for a few lines or a single callout, `medium`, or
319
+ * `wide`, the default. The slide is never wider than the step it is shown in.
320
+ */
321
+ width: optional(picklist(["narrow", "medium", "wide"])),
322
+ /**
323
+ * Over a background image the blocks sit on a panel so they stay readable. `false` leaves the
324
+ * panel out, for blocks that bring a surface of their own (callouts). No effect without a background.
325
+ */
326
+ panel: optional(boolean()),
164
327
  narration: optional(narrationSchema),
165
328
  advance,
329
+ transitions,
166
330
  blocks: array(blockSchema),
167
331
  });
168
332
  /** One video, with its subtitles as cues. Done when the video has played to the end. */
@@ -174,6 +338,7 @@ export const videoStepSchema = strictObject({
174
338
  /** An image shown behind and around the video. */
175
339
  background: optional(source),
176
340
  advance,
341
+ transitions,
177
342
  });
178
343
  /** A document the learner opens and then confirms having read. */
179
344
  export const pdfStepSchema = strictObject({
@@ -185,6 +350,7 @@ export const pdfStepSchema = strictObject({
185
350
  file: source,
186
351
  /** The wording of the confirmation, e.g. "Jeg har lest og forstått". */
187
352
  confirm: text,
353
+ transitions,
188
354
  });
189
355
  /**
190
356
  * A quiz. The questions, options and pass rules are data of their own, so the document only
@@ -198,5 +364,6 @@ export const quizStepSchema = strictObject({
198
364
  text: optional(text),
199
365
  /** Plays on the intro, before the quiz is started. Never holds the quiz back. */
200
366
  narration: optional(narrationSchema),
367
+ transitions,
201
368
  });
202
369
  export const stepSchema = variant("type", [slideStepSchema, videoStepSchema, pdfStepSchema, quizStepSchema]);
@@ -14,7 +14,8 @@ export type StepValidation = {
14
14
  /**
15
15
  * Checks a step document: its shape first, then what the shape cannot express - ids that are
16
16
  * used twice, cues that end before they start or are out of order, media that ends before it
17
- * starts, and `revealAt` / `hideAt` naming a cue that does not exist.
17
+ * starts, `revealAt` / `hideAt` naming a cue that does not exist, a delay on a part that does not
18
+ * wait, an effect or a transition whose target is not on the step.
18
19
  */
19
20
  export declare function validateStep(input: unknown): StepValidation;
20
21
  /** The step document as JSON Schema, for a JSON editor's completion and for AI tools. */
@@ -1,11 +1,13 @@
1
1
  import { toJsonSchema } from "@valibot/to-json-schema";
2
2
  import { getDotPath, safeParse } from "valibot";
3
- import { getCues } from "./cues";
3
+ import { getCues, hasTrigger } from "./cues";
4
+ import { effectTargets, getEffectBlocks } from "./effects";
4
5
  import { stepSchema } from "./schema";
5
6
  /**
6
7
  * Checks a step document: its shape first, then what the shape cannot express - ids that are
7
8
  * used twice, cues that end before they start or are out of order, media that ends before it
8
- * starts, and `revealAt` / `hideAt` naming a cue that does not exist.
9
+ * starts, `revealAt` / `hideAt` naming a cue that does not exist, a delay on a part that does not
10
+ * wait, an effect or a transition whose target is not on the step.
9
11
  */
10
12
  export function validateStep(input) {
11
13
  let parsed = safeParse(stepSchema, input);
@@ -49,10 +51,75 @@ export function validateStep(input) {
49
51
  issues.push({ path: `${path}.${key}`, message: `There is no cue with the id "${cueId}".` });
50
52
  }
51
53
  }
54
+ if (part.delay != null && !hasTrigger(part) && !isEffect(part)) {
55
+ issues.push({ path: `${path}.delay`, message: "Only a part that waits to be shown can have a delay." });
56
+ }
52
57
  }
58
+ issues.push(...effectIssues(step));
53
59
  }
60
+ issues.push(...transitionIssues(step));
54
61
  return issues.length > 0 ? { ok: false, issues } : { ok: true, step };
55
62
  }
63
+ function isEffect(part) {
64
+ return part.type === "effect";
65
+ }
66
+ /** The ids an effect or a transition can act on: every part of the slide except the effects, which show nothing. */
67
+ function targetableIds(step) {
68
+ let ids = new Set();
69
+ for (let { part } of walk(step))
70
+ if (!isEffect(part))
71
+ ids.add(part.id);
72
+ return ids;
73
+ }
74
+ /** An effect must name parts of the slide, and not itself or another effect. */
75
+ function effectIssues(step) {
76
+ let issues = [];
77
+ let targetable = targetableIds(step);
78
+ let paths = new Map();
79
+ for (let { part, path } of walk(step))
80
+ paths.set(part.id, path);
81
+ for (let effect of getEffectBlocks(step.blocks)) {
82
+ let path = paths.get(effect.id) ?? "";
83
+ let many = Array.isArray(effect.target);
84
+ effectTargets(effect).forEach((target, index) => {
85
+ let targetPath = many ? `${path}.target.${index}` : `${path}.target`;
86
+ if (targetable.has(target))
87
+ return;
88
+ let message = paths.has(target)
89
+ ? "An effect cannot act on an effect."
90
+ : `There is no part with the id "${target}".`;
91
+ issues.push({ path: targetPath, message });
92
+ });
93
+ }
94
+ return issues;
95
+ }
96
+ const SLIDE_TARGETS = new Set(["content", "background"]);
97
+ /**
98
+ * A transition must name something the step has: `content` and `background` are a slide's, and a
99
+ * part id must be a part of the slide (a column counts). `from` only means something for `slide`.
100
+ */
101
+ function transitionIssues(step) {
102
+ let issues = [];
103
+ let partIds = new Set();
104
+ if (step.type === "slide")
105
+ partIds = targetableIds(step);
106
+ step.transitions?.forEach((transition, index) => {
107
+ let path = `transitions.${index}`;
108
+ let target = transition.target ?? "step";
109
+ if (SLIDE_TARGETS.has(target)) {
110
+ if (step.type !== "slide") {
111
+ issues.push({ path: `${path}.target`, message: `Only a slide has a "${target}" to animate.` });
112
+ }
113
+ }
114
+ else if (target !== "step" && !partIds.has(target)) {
115
+ issues.push({ path: `${path}.target`, message: `There is no part with the id "${target}".` });
116
+ }
117
+ if (transition.from != null && transition.effect !== "slide") {
118
+ issues.push({ path: `${path}.from`, message: 'Only the "slide" effect has a direction.' });
119
+ }
120
+ });
121
+ return issues;
122
+ }
56
123
  /** Every media of a step with its path, the video links on a slide included. */
57
124
  function* mediaOf(step) {
58
125
  if (step.type === "video")
@@ -68,28 +135,28 @@ function* mediaOf(step) {
68
135
  }
69
136
  }
70
137
  }
71
- /** Every timed part of a slide with its path. Columns are walked too, and they have ids of their own. */
72
- function* walk(step) {
73
- for (let [index, block] of step.blocks.entries()) {
74
- let path = `blocks.${index}`;
138
+ /**
139
+ * Every timed part of a slide with its path. Columns and boxes are walked too, a box in a column
140
+ * included, and columns have ids of their own.
141
+ */
142
+ function walk(step) {
143
+ return walkBlocks(step.blocks, "blocks");
144
+ }
145
+ function* walkBlocks(blocks, basePath) {
146
+ for (let [index, block] of blocks.entries()) {
147
+ let path = `${basePath}.${index}`;
75
148
  yield { part: block, path };
76
- if (block.type === "list") {
149
+ if (block.type === "list" || block.type === "canvas") {
77
150
  for (let [itemIndex, item] of block.items.entries())
78
151
  yield { part: item, path: `${path}.items.${itemIndex}` };
79
152
  }
153
+ if (block.type === "box")
154
+ yield* walkBlocks(block.blocks, `${path}.blocks`);
80
155
  if (block.type === "columns") {
81
156
  for (let [columnIndex, column] of block.columns.entries()) {
82
157
  let columnPath = `${path}.columns.${columnIndex}`;
83
158
  yield { part: { id: column.id }, path: columnPath };
84
- for (let [childIndex, child] of column.blocks.entries()) {
85
- let childPath = `${columnPath}.blocks.${childIndex}`;
86
- yield { part: child, path: childPath };
87
- if (child.type === "list") {
88
- for (let [itemIndex, item] of child.items.entries()) {
89
- yield { part: item, path: `${childPath}.items.${itemIndex}` };
90
- }
91
- }
92
- }
159
+ yield* walkBlocks(column.blocks, `${columnPath}.blocks`);
93
160
  }
94
161
  }
95
162
  }
package/es/index.d.ts CHANGED
@@ -1,8 +1,13 @@
1
1
  export { CoursePlayer, type CoursePlayerProps } from "./player/CoursePlayer";
2
- export { StepView, type StepViewProps } from "./steps/StepView";
2
+ export { type SampleChrome, StepView, type StepViewProps } from "./steps/StepView";
3
+ export type { InsertContainer, InsertPlace } from "./steps/Blocks";
4
+ export { CourseCompletion, type CourseCompletionProps, hasCompletionText, sanitizeCompletionHtml, } from "./completion/CourseCompletion";
3
5
  export { type CueClock, useCueClock } from "./media/useCueClock";
4
6
  export { elementHandle, isVimeoAddress, type MediaHandle, type MediaListener, type MediaTrim, vimeoHandle, } from "./media/mediaHandle";
5
7
  export type { PlayerBranding, PlayerCategory, PlayerCourse, PlayerLanguage, PlayerMode, PlayerStep, ProgressAdapter, QuizAdapter, QuizAnswerResult, QuizAttempt, QuizOption, QuizQuestion, QuizResult, ResolveAsset, } from "./types";
6
- export { getActiveCue, getCueEnd, getCues, getRevealSteps, getStartedCueIds, getTimedParts, hasCueText, isVisible, type RevealState, } from "./document/cues";
7
- export { type Block, blockSchema, type CalloutBlock, type ColumnsBlock, type ContentBlock, type Cue, type ImageSize, type Media, type Narration, type PdfStep, type QuizStep, type SlideStep, STEP_SCHEMA_VERSION, type Step, type StepType, stepSchema, type Timed, type VideoStep, } from "./document/schema";
8
+ export { getActiveCue, getCueEnd, getCues, getRevealLeaders, getRevealNavigation, getRevealState, getRevealSteps, getStartedCueIds, getTimedParts, hasCueText, hasTrigger, isDue, isNarratedSlide, isVisible, type RevealNavigation, type RevealState, } from "./document/cues";
9
+ export { DEFAULT_EFFECT_DURATION, effectTargets, getActiveEffects, getEffectBlocks, getPartEffects, type PartEffect, } from "./document/effects";
10
+ export { type Block, blockSchema, type BoxBlock, type BoxContentBlock, boxBlockSchema, boxContentSchema, type CalloutBlock, calloutBlockSchema, type ColumnsBlock, type ContentBlock, contentBlockSchema, type Cue, type EffectBlock, effectBlockSchema, type ImageSize, type Media, type Narration, type PdfStep, type QuizStep, type SlideStep, STEP_SCHEMA_VERSION, type Step, type StepTransition, type StepType, stepSchema, type SurfaceVariant, TONES, type Tone, transitionSchema, type Timed, type VideoStep, } from "./document/schema";
8
11
  export { getStepJsonSchema, type StepIssue, type StepValidation, validateStep } from "./document/validate";
12
+ export { DEFAULT_TRANSITION_DURATION, DEFAULT_TRANSITIONS, getStepTransitions, planStepTransition, type TransitionDirection, type TransitionPlan, type TransitionStep, } from "./transitions/plan";
13
+ export { playStepTransition, type StepTransitionOptions } from "./transitions/playStepTransition";
package/es/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  export { CoursePlayer } from "./player/CoursePlayer";
2
2
  export { StepView } from "./steps/StepView";
3
+ export { CourseCompletion, hasCompletionText, sanitizeCompletionHtml, } from "./completion/CourseCompletion";
3
4
  export { useCueClock } from "./media/useCueClock";
4
5
  export { elementHandle, isVimeoAddress, vimeoHandle, } from "./media/mediaHandle";
5
- export { getActiveCue, getCueEnd, getCues, getRevealSteps, getStartedCueIds, getTimedParts, hasCueText, isVisible, } from "./document/cues";
6
- export { blockSchema, STEP_SCHEMA_VERSION, stepSchema, } from "./document/schema";
6
+ export { getActiveCue, getCueEnd, getCues, getRevealLeaders, getRevealNavigation, getRevealState, getRevealSteps, getStartedCueIds, getTimedParts, hasCueText, hasTrigger, isDue, isNarratedSlide, isVisible, } from "./document/cues";
7
+ export { DEFAULT_EFFECT_DURATION, effectTargets, getActiveEffects, getEffectBlocks, getPartEffects, } from "./document/effects";
8
+ export { blockSchema, boxBlockSchema, boxContentSchema, calloutBlockSchema, contentBlockSchema, effectBlockSchema, STEP_SCHEMA_VERSION, stepSchema, TONES, transitionSchema, } from "./document/schema";
7
9
  export { getStepJsonSchema, validateStep } from "./document/validate";
10
+ export { DEFAULT_TRANSITION_DURATION, DEFAULT_TRANSITIONS, getStepTransitions, planStepTransition, } from "./transitions/plan";
11
+ export { playStepTransition } from "./transitions/playStepTransition";
@@ -94,3 +94,19 @@
94
94
  height: 100%;
95
95
  color: white;
96
96
  }
97
+
98
+ /* A phone on its side: slimmer controls and smaller subtitles, so they cover less of the slide */
99
+ @media (orientation: landscape) and (max-height: 500px) {
100
+ .ob-course-media-controls {
101
+ padding-block: 0.125rem;
102
+ }
103
+
104
+ .ob-course-subtitles {
105
+ inset-block-end: var(--ds-size-2, 0.5rem);
106
+ }
107
+
108
+ .ob-course-subtitles__text {
109
+ font-size: max(0.75rem, 3.6vh);
110
+ font-size: max(0.75rem, 3.6dvh);
111
+ }
112
+ }
@@ -8,4 +8,5 @@ export declare function ArrowLeftIcon(props: IconProps): React.JSX.Element;
8
8
  export declare function ArrowRightIcon(props: IconProps): React.JSX.Element;
9
9
  export declare function GlobeIcon(props: IconProps): React.JSX.Element;
10
10
  export declare function CloseIcon(props: IconProps): React.JSX.Element;
11
+ export declare function ExitFullscreenIcon(props: IconProps): React.JSX.Element;
11
12
  export {};
package/es/media/icons.js CHANGED
@@ -26,3 +26,6 @@ export function GlobeIcon(props) {
26
26
  export function CloseIcon(props) {
27
27
  return (_jsx(Icon, { ...props, children: _jsx("path", { d: "M6.3 6.3a1 1 0 0 1 1.4 0L12 10.6l4.3-4.3a1 1 0 1 1 1.4 1.4L13.4 12l4.3 4.3a1 1 0 0 1-1.4 1.4L12 13.4l-4.3 4.3a1 1 0 0 1-1.4-1.4l4.3-4.3-4.3-4.3a1 1 0 0 1 0-1.4Z" }) }));
28
28
  }
29
+ export function ExitFullscreenIcon(props) {
30
+ return (_jsx(Icon, { ...props, children: _jsx("path", { d: "M8 4h2v6H4V8h4V4Zm6 0h2v4h4v2h-6V4ZM4 14h6v6H8v-4H4v-2Zm10 0h6v2h-4v4h-2v-6Z" }) }));
31
+ }
@@ -155,3 +155,79 @@
155
155
  height: 1.5em;
156
156
  }
157
157
  }
158
+
159
+ /*
160
+ * Full screen: the step fills the screen, with the buttons under it and a small button in the corner
161
+ * to leave. Native full screen puts the player on the whole screen itself; the immersive mode (Safari
162
+ * on iPhone, which only puts videos on the screen) lays it over the page.
163
+ */
164
+ .ob-course-player {
165
+ position: relative;
166
+ }
167
+
168
+ .ob-course-player.is-full-screen {
169
+ height: 100vh;
170
+ height: 100dvh;
171
+ padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
172
+
173
+ > .ob-course-player__header,
174
+ .ob-course-category-header {
175
+ display: none;
176
+ }
177
+ }
178
+
179
+ .ob-course-player.is-immersive {
180
+ position: fixed;
181
+ inset: 0;
182
+ z-index: 2147483000;
183
+ overscroll-behavior: contain;
184
+ }
185
+
186
+ .ob-course-player__leave-full-screen {
187
+ position: absolute;
188
+ top: max(var(--ds-size-2, 0.5rem), env(safe-area-inset-top));
189
+ right: max(var(--ds-size-2, 0.5rem), env(safe-area-inset-right));
190
+ z-index: 3;
191
+ opacity: 0.85;
192
+ }
193
+
194
+ /*
195
+ * A phone on its side has little height: the header and the buttons get slim (they also take the
196
+ * small size, set from the same query in CoursePlayer), so the slide keeps most of the screen.
197
+ */
198
+ @media (orientation: landscape) and (max-height: 500px) {
199
+ .ob-course-player__header {
200
+ padding: 0.125rem max(var(--ds-size-3, 0.75rem), env(safe-area-inset-right)) 0.125rem
201
+ max(var(--ds-size-3, 0.75rem), env(safe-area-inset-left));
202
+ font-size: 0.875rem;
203
+ }
204
+
205
+ .ob-course-player__controls {
206
+ gap: var(--ds-size-2, 0.5rem);
207
+ padding: 0.25rem max(var(--ds-size-3, 0.75rem), env(safe-area-inset-right))
208
+ max(0.25rem, env(safe-area-inset-bottom)) max(var(--ds-size-3, 0.75rem), env(safe-area-inset-left));
209
+ }
210
+
211
+ .ob-course-player__status {
212
+ font-size: 0.75rem;
213
+ line-height: 1.25;
214
+ }
215
+ }
216
+
217
+ /* The same slim chrome in an editor's preview of a phone on its side, which the media query cannot see. */
218
+ .ob-course-player.is-compact {
219
+ > .ob-course-player__header {
220
+ padding: 0.125rem var(--ds-size-3, 0.75rem);
221
+ font-size: 0.875rem;
222
+ }
223
+
224
+ > .ob-course-player__controls {
225
+ gap: var(--ds-size-2, 0.5rem);
226
+ padding: 0.25rem var(--ds-size-3, 0.75rem);
227
+ }
228
+
229
+ .ob-course-player__status {
230
+ font-size: 0.75rem;
231
+ line-height: 1.25;
232
+ }
233
+ }