@segnavia/format 0.2.0 → 0.3.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { TextDirection, firstStrongDirection, languageDirection, resolveDirection } from "./direction.js";
2
2
  import { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, PAPER_MM, PX_PER_MM, PaperBox, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
3
3
  import { Imposed, MillimeterEdges, PageFit, PagePlacementKind, PagePlacementLayout, Placement, fitPage, impose, mirrorPlacement, pagePlacementLayout } from "./imposition.js";
4
+ import { ShotUse, shotsUsed } from "./shots-used.js";
5
+ import { MAX_SLIDE_TIMING_MS } from "./timing.js";
6
+ import { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, Transition, TransitionInput } from "./transition.js";
4
7
  import { z } from "zod";
5
8
  //#region src/index.d.ts
6
9
  export declare const Size: z.ZodObject<{
@@ -526,6 +529,9 @@ export declare const Slide: z.ZodObject<{
526
529
  untilWord: z.ZodOptional<z.ZodNumber>;
527
530
  }, z.core.$strip>>>;
528
531
  }, z.core.$strip>>;
532
+ beforeMs: z.ZodOptional<z.ZodNumber>;
533
+ afterMs: z.ZodOptional<z.ZodNumber>;
534
+ holdMs: z.ZodOptional<z.ZodNumber>;
529
535
  }, z.core.$strip>;
530
536
  export type Slide = z.infer<typeof Slide>;
531
537
  export declare const DECK_SIZE: {
@@ -549,6 +555,23 @@ export declare const Deck: z.ZodObject<{
549
555
  auto: "auto";
550
556
  }>>;
551
557
  lang: z.ZodOptional<z.ZodString>;
558
+ transition: z.ZodOptional<z.ZodObject<{
559
+ kind: z.ZodEnum<{
560
+ none: "none";
561
+ fade: "fade";
562
+ slide: "slide";
563
+ }>;
564
+ duration: z.ZodDefault<z.ZodNumber>;
565
+ }, z.core.$strip>>;
566
+ playback: z.ZodOptional<z.ZodEnum<{
567
+ step: "step";
568
+ continuous: "continuous";
569
+ }>>;
570
+ captions: z.ZodOptional<z.ZodEnum<{
571
+ on: "on";
572
+ off: "off";
573
+ viewer: "viewer";
574
+ }>>;
552
575
  slides: z.ZodArray<z.ZodObject<{
553
576
  id: z.ZodString;
554
577
  content: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -637,6 +660,9 @@ export declare const Deck: z.ZodObject<{
637
660
  untilWord: z.ZodOptional<z.ZodNumber>;
638
661
  }, z.core.$strip>>>;
639
662
  }, z.core.$strip>>;
663
+ beforeMs: z.ZodOptional<z.ZodNumber>;
664
+ afterMs: z.ZodOptional<z.ZodNumber>;
665
+ holdMs: z.ZodOptional<z.ZodNumber>;
640
666
  }, z.core.$strip>>;
641
667
  }, z.core.$strip>;
642
668
  export type Deck = z.infer<typeof Deck>;
@@ -696,12 +722,6 @@ export interface DeckLimits {
696
722
  maxNotesBytes?: number;
697
723
  }
698
724
  export declare function exceedsLimits(deck: Deck, limits: DeckLimits): string[];
699
- export interface ShotUse {
700
- slide: string;
701
- key?: string;
702
- href?: string;
703
- }
704
- export declare function shotsUsed(deck: Deck): ShotUse[];
705
725
  export declare function jsonSchemas(): {
706
726
  page: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
707
727
  html: z.ZodString;
@@ -836,6 +856,23 @@ export declare function jsonSchemas(): {
836
856
  auto: "auto";
837
857
  }>>;
838
858
  lang: z.ZodOptional<z.ZodString>;
859
+ transition: z.ZodOptional<z.ZodObject<{
860
+ kind: z.ZodEnum<{
861
+ none: "none";
862
+ fade: "fade";
863
+ slide: "slide";
864
+ }>;
865
+ duration: z.ZodDefault<z.ZodNumber>;
866
+ }, z.core.$strip>>;
867
+ playback: z.ZodOptional<z.ZodEnum<{
868
+ step: "step";
869
+ continuous: "continuous";
870
+ }>>;
871
+ captions: z.ZodOptional<z.ZodEnum<{
872
+ on: "on";
873
+ off: "off";
874
+ viewer: "viewer";
875
+ }>>;
839
876
  slides: z.ZodArray<z.ZodObject<{
840
877
  id: z.ZodString;
841
878
  content: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -924,6 +961,9 @@ export declare function jsonSchemas(): {
924
961
  untilWord: z.ZodOptional<z.ZodNumber>;
925
962
  }, z.core.$strip>>>;
926
963
  }, z.core.$strip>>;
964
+ beforeMs: z.ZodOptional<z.ZodNumber>;
965
+ afterMs: z.ZodOptional<z.ZodNumber>;
966
+ holdMs: z.ZodOptional<z.ZodNumber>;
927
967
  }, z.core.$strip>>;
928
968
  }, z.core.$strip>>;
929
969
  manifest: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
@@ -1024,4 +1064,4 @@ export declare function jsonSchemas(): {
1024
1064
  }, z.core.$strip>>;
1025
1065
  };
1026
1066
  //#endregion
1027
- export { type Imposed, MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, type MillimeterEdges, PAPER_MM, PX_PER_MM, type PageFit, type PagePlacementKind, type PagePlacementLayout, type PaperBox, type Placement, type TextDirection, firstStrongDirection, fitPage, impose, languageDirection, mirrorPlacement, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, sheetMm, toMillimeters };
1067
+ export { DEFAULT_TRANSITION_DURATION_MS, type Imposed, MARK_GAP_MM, MARK_LENGTH_MM, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, MM_PER_PT, type MillimeterEdges, PAPER_MM, PX_PER_MM, type PageFit, type PagePlacementKind, type PagePlacementLayout, type PaperBox, type Placement, type ShotUse, type TextDirection, Transition, TransitionInput, firstStrongDirection, fitPage, impose, languageDirection, mirrorPlacement, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, sheetMm, shotsUsed, toMillimeters };
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, PAPER_MM, PX_PER_MM, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
2
+ import { MAX_SLIDE_TIMING_MS, SlideTiming, slideTimingIssues } from "./timing.js";
3
+ import { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, Transition } from "./transition.js";
2
4
  import { firstStrongDirection, languageDirection, resolveDirection } from "./direction.js";
3
5
  import { fitPage, impose, mirrorPlacement, pagePlacementLayout } from "./imposition.js";
6
+ import { shotsUsed } from "./shots-used.js";
4
7
  import { z } from "zod";
5
8
  //#region src/index.ts
6
9
  const Size = z.object({
@@ -246,7 +249,10 @@ const Slide = z.object({
246
249
  id: z.string(),
247
250
  content: SlideContent,
248
251
  notes: z.string().optional(),
249
- narration: Narration.optional()
252
+ narration: Narration.optional(),
253
+ beforeMs: SlideTiming.optional(),
254
+ afterMs: SlideTiming.optional(),
255
+ holdMs: SlideTiming.optional()
250
256
  });
251
257
  const DECK_SIZE = {
252
258
  width: 1280,
@@ -258,6 +264,13 @@ const DeckShape = z.object({
258
264
  scripts: Scripts.default("refuse"),
259
265
  dir: Direction.optional(),
260
266
  lang: z.string().optional(),
267
+ transition: Transition.optional(),
268
+ playback: z.enum(["step", "continuous"]).optional(),
269
+ captions: z.enum([
270
+ "on",
271
+ "off",
272
+ "viewer"
273
+ ]).optional(),
261
274
  slides: z.array(Slide).min(1)
262
275
  });
263
276
  function annotationCueIssues(narration, annotations) {
@@ -289,6 +302,18 @@ const Deck = DeckShape.superRefine((deck, ctx) => {
289
302
  ],
290
303
  message
291
304
  });
305
+ for (const field of slideTimingIssues(slide)) {
306
+ const kind = field === "holdMs" ? "without" : "with";
307
+ ctx.addIssue({
308
+ code: "custom",
309
+ path: [
310
+ "slides",
311
+ index,
312
+ field
313
+ ],
314
+ message: `${field} is allowed only ${kind} narration`
315
+ });
316
+ }
292
317
  });
293
318
  const ids = /* @__PURE__ */ new Set();
294
319
  deck.slides.forEach((slide, index) => {
@@ -318,19 +343,6 @@ function exceedsLimits(deck, limits) {
318
343
  });
319
344
  return reasons;
320
345
  }
321
- function shotsUsed(deck) {
322
- return deck.slides.flatMap((slide) => {
323
- if (slide.content.kind === "shot") return [{
324
- slide: slide.id,
325
- key: slide.content.shot.key
326
- }];
327
- if (slide.content.kind === "shot-ref") return [{
328
- slide: slide.id,
329
- href: slide.content.href
330
- }];
331
- return [];
332
- });
333
- }
334
346
  function jsonSchemas() {
335
347
  return {
336
348
  page: z.toJSONSchema(Page, { io: "input" }),
@@ -341,4 +353,4 @@ function jsonSchemas() {
341
353
  };
342
354
  }
343
355
  //#endregion
344
- export { Annotation, Box, Cue, DECK_SIZE, Deck, Direction, Imposition, MARK_GAP_MM, MARK_LENGTH_MM, MAX_IMPOSITION_CELLS, MM_PER_PT, Manifest, Margin, NAMED_PAPERS, Narration, PAPER_MM, PX_PER_MM, Page, PageSize, Paper, Point, Print, PublishedShot, SHOT_KEY, Scripts, Shot, Size, Slide, SlideContent, Word, annotationCueIssues, exceedsLimits, firstStrongDirection, fitPage, impose, jsonSchemas, languageDirection, mirrorPlacement, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, sheetMm, shotsUsed, toMillimeters };
356
+ export { Annotation, Box, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, Direction, Imposition, MARK_GAP_MM, MARK_LENGTH_MM, MAX_IMPOSITION_CELLS, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, Margin, NAMED_PAPERS, Narration, PAPER_MM, PX_PER_MM, Page, PageSize, Paper, Point, Print, PublishedShot, SHOT_KEY, Scripts, Shot, Size, Slide, SlideContent, Transition, Word, annotationCueIssues, exceedsLimits, firstStrongDirection, fitPage, impose, jsonSchemas, languageDirection, mirrorPlacement, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, sheetMm, shotsUsed, toMillimeters };
@@ -0,0 +1,9 @@
1
+ import { Deck } from "./index.js";
2
+ //#region src/shots-used.d.ts
3
+ export interface ShotUse {
4
+ slide: string;
5
+ key?: string;
6
+ href?: string;
7
+ }
8
+ export declare function shotsUsed(deck: Deck): ShotUse[];
9
+ //#endregion
@@ -0,0 +1,16 @@
1
+ //#region src/shots-used.ts
2
+ function shotsUsed(deck) {
3
+ return deck.slides.flatMap((slide) => {
4
+ if (slide.content.kind === "shot") return [{
5
+ slide: slide.id,
6
+ key: slide.content.shot.key
7
+ }];
8
+ if (slide.content.kind === "shot-ref") return [{
9
+ slide: slide.id,
10
+ href: slide.content.href
11
+ }];
12
+ return [];
13
+ });
14
+ }
15
+ //#endregion
16
+ export { shotsUsed };
@@ -0,0 +1,4 @@
1
+ import { z } from "zod";
2
+ //#region src/timing.d.ts
3
+ export declare const MAX_SLIDE_TIMING_MS = 600000;
4
+ //#endregion
package/dist/timing.js ADDED
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ //#region src/timing.ts
3
+ const MAX_SLIDE_TIMING_MS = 6e5;
4
+ const SlideTiming = z.number().finite().min(0).max(MAX_SLIDE_TIMING_MS);
5
+ function slideTimingIssues(slide) {
6
+ if (slide.narration) return slide.holdMs === void 0 ? [] : ["holdMs"];
7
+ return ["beforeMs", "afterMs"].filter((field) => slide[field] !== void 0);
8
+ }
9
+ //#endregion
10
+ export { MAX_SLIDE_TIMING_MS, SlideTiming, slideTimingIssues };
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ //#region src/transition.d.ts
3
+ export declare const MIN_TRANSITION_DURATION_MS = 0;
4
+ export declare const MAX_TRANSITION_DURATION_MS = 2000;
5
+ export declare const DEFAULT_TRANSITION_DURATION_MS = 300;
6
+ export declare const Transition: z.ZodObject<{
7
+ kind: z.ZodEnum<{
8
+ none: "none";
9
+ fade: "fade";
10
+ slide: "slide";
11
+ }>;
12
+ duration: z.ZodDefault<z.ZodNumber>;
13
+ }, z.core.$strip>;
14
+ export type Transition = z.infer<typeof Transition>;
15
+ export type TransitionInput = z.input<typeof Transition>;
16
+ //#endregion
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ //#region src/transition.ts
3
+ const MIN_TRANSITION_DURATION_MS = 0;
4
+ const MAX_TRANSITION_DURATION_MS = 2e3;
5
+ const DEFAULT_TRANSITION_DURATION_MS = 300;
6
+ const Transition = z.object({
7
+ kind: z.enum([
8
+ "none",
9
+ "fade",
10
+ "slide"
11
+ ]),
12
+ duration: z.number().int().min(0).max(MAX_TRANSITION_DURATION_MS).default(300)
13
+ });
14
+ //#endregion
15
+ export { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, Transition };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segnavia/format",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {