@openpresentation/opf 0.2.2 → 0.4.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 (90) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +74 -3
  3. package/dist/catalogs-x1oFFQnd.d.ts +1198 -0
  4. package/dist/catalogs.d.ts +2 -32413
  5. package/dist/catalogs.js +1 -18505
  6. package/dist/chunk-75N5I6M4.js +229 -0
  7. package/dist/chunk-EMTMQRX4.js +1007 -0
  8. package/dist/chunk-GCXOU5MZ.js +6515 -0
  9. package/dist/chunk-HJNJHB5H.js +454 -0
  10. package/dist/chunk-OZULJBSG.js +3368 -0
  11. package/dist/chunk-PIQXLBBJ.js +445 -0
  12. package/dist/chunk-SOSOBKQ2.js +145 -0
  13. package/dist/chunk-TWMRZ43O.js +18576 -0
  14. package/dist/composition.d.ts +190 -0
  15. package/dist/composition.js +1 -0
  16. package/dist/data.d.ts +32 -0
  17. package/dist/data.js +1 -0
  18. package/dist/docs.d.ts +17 -0
  19. package/dist/docs.js +120 -0
  20. package/dist/examples.d.ts +43 -0
  21. package/dist/examples.js +44828 -0
  22. package/dist/index.d.ts +7 -4
  23. package/dist/index.js +8 -29015
  24. package/dist/pagination.d.ts +52 -0
  25. package/dist/pagination.js +5 -0
  26. package/dist/{validator-MwlR2F56.d.ts → presentation-BjP4yTQ1.d.ts} +87 -40
  27. package/dist/previews.js +1 -447
  28. package/dist/repo-readme.d.ts +4 -0
  29. package/dist/repo-readme.js +7 -0
  30. package/dist/schemas-C1DxapX2.d.ts +206 -0
  31. package/dist/schemas.d.ts +1 -12373
  32. package/dist/schemas.js +1 -6275
  33. package/dist/spec/README.md +57 -0
  34. package/dist/spec/catalogs/audiences/engineering-team.json +1 -1
  35. package/dist/spec/catalogs/audiences/index.json +1 -1
  36. package/dist/spec/catalogs/chart-types/index.json +1 -1
  37. package/dist/spec/catalogs/color-schemes/index.json +1 -1
  38. package/dist/spec/catalogs/font-schemes/index.json +1 -1
  39. package/dist/spec/catalogs/languages/index.json +1 -1
  40. package/dist/spec/catalogs/layouts/chart-1x.json +4 -1
  41. package/dist/spec/catalogs/layouts/chart-2x.json +5 -1
  42. package/dist/spec/catalogs/layouts/chart-3x.json +5 -1
  43. package/dist/spec/catalogs/layouts/code-1x.json +4 -1
  44. package/dist/spec/catalogs/layouts/extract/canonical.json +94 -21
  45. package/dist/spec/catalogs/layouts/image-1x.json +4 -1
  46. package/dist/spec/catalogs/layouts/image-2x.json +5 -1
  47. package/dist/spec/catalogs/layouts/image-3x.json +5 -1
  48. package/dist/spec/catalogs/layouts/index.json +1 -1
  49. package/dist/spec/catalogs/layouts/list-2x.json +4 -1
  50. package/dist/spec/catalogs/layouts/list-3x.json +4 -1
  51. package/dist/spec/catalogs/layouts/list-4x.json +5 -1
  52. package/dist/spec/catalogs/layouts/list-5x.json +5 -1
  53. package/dist/spec/catalogs/layouts/list-6x.json +5 -1
  54. package/dist/spec/catalogs/layouts/media-1x.json +4 -1
  55. package/dist/spec/catalogs/layouts/number-2x.json +4 -1
  56. package/dist/spec/catalogs/layouts/number-3x.json +4 -1
  57. package/dist/spec/catalogs/layouts/number-4x.json +5 -1
  58. package/dist/spec/catalogs/layouts/number-5x.json +5 -1
  59. package/dist/spec/catalogs/layouts/number-6x.json +5 -1
  60. package/dist/spec/catalogs/layouts/table-1x.json +4 -1
  61. package/dist/spec/catalogs/layouts/text-2x.json +4 -1
  62. package/dist/spec/catalogs/layouts/text-3x.json +4 -1
  63. package/dist/spec/catalogs/narratives/index.json +2 -2
  64. package/dist/spec/catalogs/purposes/index.json +1 -1
  65. package/dist/spec/catalogs/social-platforms/index.json +1 -1
  66. package/dist/spec/catalogs/themes/index.json +1 -1
  67. package/dist/spec/catalogs/tones/casual.json +1 -1
  68. package/dist/spec/catalogs/tones/conversational.json +1 -1
  69. package/dist/spec/catalogs/tones/index.json +1 -1
  70. package/dist/spec/catalogs/tones/technical.json +1 -1
  71. package/dist/spec/openapi.yaml +66 -26
  72. package/dist/spec/previews/layouts/index.json +71 -71
  73. package/dist/spec/schemas/catalog-index.schema.json +53 -0
  74. package/dist/spec/schemas/layout-preview-index.schema.json +54 -0
  75. package/dist/spec/schemas/layout.schema.json +63 -0
  76. package/dist/spec/schemas/opf.schema.json +182 -3
  77. package/dist/spec-files.d.ts +14 -2386
  78. package/dist/spec-files.js +1 -3349
  79. package/dist/types.d.ts +4 -1102
  80. package/dist/types.js +0 -2
  81. package/dist/validator.d.ts +33 -3
  82. package/dist/validator.js +4 -6712
  83. package/package.json +29 -4
  84. package/dist/catalogs.js.map +0 -1
  85. package/dist/index.js.map +0 -1
  86. package/dist/previews.js.map +0 -1
  87. package/dist/schemas.js.map +0 -1
  88. package/dist/spec-files.js.map +0 -1
  89. package/dist/types.js.map +0 -1
  90. package/dist/validator.js.map +0 -1
@@ -0,0 +1,52 @@
1
+ import { LayoutDiagnostic, ComposeSlideOptions, TextMeasurement } from './composition.js';
2
+
3
+ interface PaginationOptions extends ComposeSlideOptions {
4
+ /** Readability floor used while choosing page breaks. Default 24 reference pixels. */
5
+ minFontSize?: number;
6
+ /** All-or-nothing resource limit. Defaults to 100 output slides. */
7
+ maxSlides?: number;
8
+ /** Existing deck IDs to avoid when generating continuation IDs. */
9
+ reservedIds?: string[];
10
+ }
11
+ interface PaginationMapping {
12
+ sourcePath: string;
13
+ outputPath: string;
14
+ /** Half-open offsets into the original leaf; text offsets use UTF-16. */
15
+ range?: {
16
+ unit: 'utf16' | 'items';
17
+ start: number;
18
+ end: number;
19
+ };
20
+ }
21
+ interface PaginatedPage {
22
+ slideIndex: number;
23
+ mappings: PaginationMapping[];
24
+ }
25
+ interface PaginationResult {
26
+ slides: Record<string, any>[];
27
+ pages: PaginatedPage[];
28
+ }
29
+ declare class OPFPaginationError extends Error {
30
+ readonly diagnostics: LayoutDiagnostic[];
31
+ readonly code = "pagination-unresolved";
32
+ constructor(message: string, diagnostics?: LayoutDiagnostic[]);
33
+ }
34
+ /** Explicit, lossless authoring transform. It never changes slide count during rendering. */
35
+ declare function paginateSlide(input: unknown, options?: PaginationOptions): PaginationResult;
36
+ interface PresentationPaginationOptions {
37
+ textMeasurement?: TextMeasurement;
38
+ minFontSize?: number;
39
+ maxSlides?: number;
40
+ /** Optional host-resolved layout/canvas overrides for each source slide. */
41
+ slideOptions?: (slide: Record<string, any>, index: number) => ComposeSlideOptions;
42
+ }
43
+ interface PresentationPaginationResult {
44
+ presentation: Record<string, any>;
45
+ pages: (PaginatedPage & {
46
+ sourceSlideIndex: number;
47
+ })[];
48
+ }
49
+ /** Resolve local catalogs and paginate a complete presentation without mutating it. */
50
+ declare function paginatePresentation(input: unknown, options?: PresentationPaginationOptions): PresentationPaginationResult;
51
+
52
+ export { OPFPaginationError, type PaginatedPage, type PaginationMapping, type PaginationOptions, type PaginationResult, type PresentationPaginationOptions, type PresentationPaginationResult, paginatePresentation, paginateSlide };
@@ -0,0 +1,5 @@
1
+ export { OPFPaginationError, paginatePresentation, paginateSlide } from './chunk-75N5I6M4.js';
2
+ import './chunk-EMTMQRX4.js';
3
+ import './chunk-HJNJHB5H.js';
4
+ import './chunk-GCXOU5MZ.js';
5
+ import './chunk-TWMRZ43O.js';
@@ -1,13 +1,3 @@
1
- import { CatalogKind } from './catalogs.js';
2
- import { SchemaName } from './schemas.js';
3
-
4
- type JsonPrimitive = string | number | boolean | null;
5
- type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
6
- interface JsonObject {
7
- readonly [key: string]: JsonValue;
8
- }
9
- type JsonSchema = JsonObject;
10
-
11
1
  /**
12
2
  * Inline audience metadata for the presentation. Use 'id' to reference an audiences catalog record and override selected fields, or use 'name' for a custom inline audience.
13
3
  *
@@ -315,7 +305,7 @@ type TextRun = (string | {
315
305
  */
316
306
  color?: string;
317
307
  /**
318
- * Run font size in points.
308
+ * Requested run font size in points.
319
309
  */
320
310
  fontSize?: number;
321
311
  /**
@@ -387,7 +377,7 @@ type ChartDataCell = (string | number | boolean | null);
387
377
  */
388
378
  type TableCell = (string | number | boolean | null);
389
379
  /**
390
- * A single content payload. The optional 'type' discriminator can make intent explicit, but validators and engines infer it from fields such as text, bullets, items, image, video, chart, table, code, metric, quote, or timeline.
380
+ * A content leaf or recursively composed group. A group contains blocks and optional composition; it cannot mix blocks with leaf payload fields. Groups may nest up to 32 levels.
391
381
  *
392
382
  * This interface was referenced by `Presentation`'s JSON-Schema
393
383
  * via the `definition` "ContentPayload".
@@ -398,7 +388,7 @@ type ContentPayload = ({
398
388
  /**
399
389
  * Optional content kind. When omitted, engines infer the kind from the fields present.
400
390
  */
401
- type?: ("text" | "list" | "image" | "chart" | "table" | "video" | "code" | "metric" | "quote" | "timeline");
391
+ type?: ("text" | "list" | "image" | "chart" | "table" | "video" | "code" | "metric" | "quote" | "timeline" | "group");
402
392
  /**
403
393
  * Text payload. Use a string for plain text or TextRun[] for inline rich text. TextRun items may be plain strings or formatted run objects.
404
394
  */
@@ -502,6 +492,13 @@ type ContentPayload = ({
502
492
  */
503
493
  events: [TimelineEvent, ...(TimelineEvent)[]];
504
494
  });
495
+ /**
496
+ * Ordered children of a group. Each child is a leaf or another group.
497
+ *
498
+ * @minItems 1
499
+ */
500
+ blocks?: [ContentPayload, ...(ContentPayload)[]];
501
+ composition?: Composition;
505
502
  });
506
503
  /**
507
504
  * Catalog source location. Accepts:
@@ -2183,6 +2180,7 @@ interface Slide {
2183
2180
  * Whether the slide is hidden from the presented sequence.
2184
2181
  */
2185
2182
  hidden?: boolean;
2183
+ composition?: Composition1;
2186
2184
  }
2187
2185
  /**
2188
2186
  * Full-slide chart payload. Presence of this field infers type 'chart'.
@@ -2372,6 +2370,42 @@ interface Table1 {
2372
2370
  */
2373
2371
  rows: TableCell[][];
2374
2372
  }
2373
+ /**
2374
+ * Arrangement within this group. Only minFontSize and overflow inherit from the parent; strict overflow cannot be weakened.
2375
+ */
2376
+ interface Composition {
2377
+ /**
2378
+ * auto chooses a grid from available space and content; grid uses columns; row and column use one horizontal or vertical track.
2379
+ */
2380
+ mode?: ("auto" | "grid" | "row" | "column");
2381
+ /**
2382
+ * Column count for grid. In auto mode this caps the number of columns.
2383
+ */
2384
+ columns?: number;
2385
+ /**
2386
+ * Space between cells as a fraction of the container short edge (canvas at slide root). Default 0.03333333333333333.
2387
+ */
2388
+ gap?: number;
2389
+ /**
2390
+ * Inset as a fraction of the container short edge. Default 0.08 on a slide, 0 inside a group.
2391
+ */
2392
+ padding?: number;
2393
+ /**
2394
+ * Relative track sizes: columns for row/grid/auto, rows for column. Omitted tracks have weight 1; extra weights are ignored.
2395
+ *
2396
+ * @minItems 1
2397
+ * @maxItems 12
2398
+ */
2399
+ weights?: [number] | [number, number] | [number, number, number] | [number, number, number, number] | [number, number, number, number, number] | [number, number, number, number, number, number] | [number, number, number, number, number, number, number] | [number, number, number, number, number, number, number, number] | [number, number, number, number, number, number, number, number, number] | [number, number, number, number, number, number, number, number, number, number] | [number, number, number, number, number, number, number, number, number, number, number] | [number, number, number, number, number, number, number, number, number, number, number, number];
2400
+ /**
2401
+ * Minimum readable text size in reference pixels at a 720-pixel canvas short edge. Default 16. Overflow is diagnosed when text cannot fit at this size.
2402
+ */
2403
+ minFontSize?: number;
2404
+ /**
2405
+ * warn returns diagnostics for content that does not fit; error rejects layout. Content is never silently removed. Default warn.
2406
+ */
2407
+ overflow?: ("warn" | "error");
2408
+ }
2375
2409
  /**
2376
2410
  * Slide-level design applied on top of the deck-wide design.
2377
2411
  */
@@ -2469,6 +2503,45 @@ interface Design1 {
2469
2503
  listBullet?: ("character" | "image");
2470
2504
  [k: string]: unknown;
2471
2505
  }
2506
+ /**
2507
+ * Portable dynamic composition. Slide fields override the resolved layout. Nested groups arrange their children independently, inheriting only minFontSize and overflow. Explicit promoted regions retain their positions.
2508
+ *
2509
+ * This interface was referenced by `Presentation`'s JSON-Schema
2510
+ * via the `definition` "Composition".
2511
+ */
2512
+ interface Composition1 {
2513
+ /**
2514
+ * auto chooses a grid from available space and content; grid uses columns; row and column use one horizontal or vertical track.
2515
+ */
2516
+ mode?: ("auto" | "grid" | "row" | "column");
2517
+ /**
2518
+ * Column count for grid. In auto mode this caps the number of columns.
2519
+ */
2520
+ columns?: number;
2521
+ /**
2522
+ * Space between cells as a fraction of the container short edge (canvas at slide root). Default 0.03333333333333333.
2523
+ */
2524
+ gap?: number;
2525
+ /**
2526
+ * Inset as a fraction of the container short edge. Default 0.08 on a slide, 0 inside a group.
2527
+ */
2528
+ padding?: number;
2529
+ /**
2530
+ * Relative track sizes: columns for row/grid/auto, rows for column. Omitted tracks have weight 1; extra weights are ignored.
2531
+ *
2532
+ * @minItems 1
2533
+ * @maxItems 12
2534
+ */
2535
+ weights?: [number] | [number, number] | [number, number, number] | [number, number, number, number] | [number, number, number, number, number] | [number, number, number, number, number, number] | [number, number, number, number, number, number, number] | [number, number, number, number, number, number, number, number] | [number, number, number, number, number, number, number, number, number] | [number, number, number, number, number, number, number, number, number, number] | [number, number, number, number, number, number, number, number, number, number, number] | [number, number, number, number, number, number, number, number, number, number, number, number];
2536
+ /**
2537
+ * Minimum readable text size in reference pixels at a 720-pixel canvas short edge. Default 16. Overflow is diagnosed when text cannot fit at this size.
2538
+ */
2539
+ minFontSize?: number;
2540
+ /**
2541
+ * warn returns diagnostics for content that does not fit; error rejects layout. Content is never silently removed. Default warn.
2542
+ */
2543
+ overflow?: ("warn" | "error");
2544
+ }
2472
2545
  /**
2473
2546
  * Optional reusable asset registry for images, data files, videos, documents, fonts, and other resources referenced elsewhere in the deck via 'asset:<id>' strings.
2474
2547
  */
@@ -2669,30 +2742,4 @@ interface CatalogEntry10 {
2669
2742
  [k: string]: unknown;
2670
2743
  }
2671
2744
 
2672
- interface ValidationIssue {
2673
- path: string;
2674
- message: string;
2675
- keyword: string;
2676
- schemaPath: string;
2677
- params: Record<string, unknown>;
2678
- }
2679
- interface ValidationResult {
2680
- valid: boolean;
2681
- errors: ValidationIssue[];
2682
- schemaName?: SchemaName;
2683
- catalogKind?: CatalogKind;
2684
- }
2685
- type SchemaOrKind = SchemaName | CatalogKind | JsonSchema;
2686
- declare class OPFValidationError extends Error {
2687
- readonly issues: ValidationIssue[];
2688
- readonly result: ValidationResult;
2689
- constructor(result: ValidationResult);
2690
- }
2691
- declare function validate(value: unknown, schemaOrKind?: SchemaOrKind): ValidationResult;
2692
- declare function assertValid<T = unknown>(value: T, schemaOrKind?: SchemaOrKind): T;
2693
- declare function validatePresentation(value: unknown): ValidationResult;
2694
- declare function assertValidPresentation(value: unknown): asserts value is Presentation;
2695
- declare function validateCatalogRecord(kind: CatalogKind, value: unknown): ValidationResult;
2696
- declare function assertValidCatalogRecord(kind: CatalogKind, value: unknown): void;
2697
-
2698
- export { OPFValidationError as O, type Presentation as P, type SchemaOrKind as S, type ValidationIssue as V, type ValidationResult as a, assertValid as b, assertValidCatalogRecord as c, assertValidPresentation as d, validateCatalogRecord as e, validatePresentation as f, validate as v };
2745
+ export type { Presentation as P };