@openpresentation/opf 0.16.0 → 0.18.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.
Files changed (63) hide show
  1. package/README.md +16 -2
  2. package/dist/browser.js +38 -0
  3. package/dist/{catalog-refs-_anZs-Qz.d.ts → catalog-refs-BSfGELpt.d.ts} +1 -1
  4. package/dist/{catalog-schemas-BZCjgAxu.d.ts → catalog-schemas-CinPh5WA.d.ts} +1 -1
  5. package/dist/catalog.d.ts +2 -2
  6. package/dist/catalog.js +3 -23712
  7. package/dist/{chunk-BSYQDWT4.js → chunk-64YSJZDH.js} +28 -15
  8. package/dist/{chunk-WEDGVC5W.js → chunk-6WW2EDUW.js} +108 -108
  9. package/dist/{chunk-5UEUAW57.js → chunk-CJPDTLGD.js} +1 -1
  10. package/dist/{chunk-FQSIIADJ.js → chunk-DBYZI75U.js} +30 -5
  11. package/dist/{chunk-PX5AWL7Y.js → chunk-JT3QXA22.js} +99 -29
  12. package/dist/{chunk-6OR326EA.js → chunk-JXVS7BJK.js} +1 -1
  13. package/dist/chunk-KXBZ6ZSB.js +991 -0
  14. package/dist/{chunk-5PDN7BN6.js → chunk-MBU42S5Y.js} +427 -167
  15. package/dist/{chunk-K4DQQIT4.js → chunk-NS3VYB57.js} +5 -5
  16. package/dist/chunk-QLFWWHRF.js +919 -0
  17. package/dist/{chunk-5TO6I3GB.js → chunk-RAKEVM52.js} +1 -1
  18. package/dist/{chunk-NAWQR7MN.js → chunk-VCGRMNY2.js} +1 -1
  19. package/dist/chunk-WCG3THTD.js +23712 -0
  20. package/dist/{chunk-UM24JFUE.js → chunk-YWXB4XAT.js} +2 -2
  21. package/dist/{chunk-3XDRQYWZ.js → chunk-YZXTXX2D.js} +1 -1
  22. package/dist/{chunk-SMLMI6IZ.js → chunk-ZCFSDSUX.js} +3 -3
  23. package/dist/{chunk-KINQFU6X.js → chunk-ZOHFLP3O.js} +19 -12
  24. package/dist/{composition-D4ADF5c-.d.ts → composition-C-OoqvAr.d.ts} +227 -167
  25. package/dist/composition.d.ts +2 -2
  26. package/dist/composition.js +1 -1
  27. package/dist/conversion-C5foedh6.d.ts +502 -0
  28. package/dist/conversion-KGDVJM75.js +21 -0
  29. package/dist/convert.d.ts +3 -3
  30. package/dist/convert.js +7 -7
  31. package/dist/data.d.ts +6 -6
  32. package/dist/data.js +2 -2
  33. package/dist/deck-report-wszX7uo8.d.ts +40 -0
  34. package/dist/deck.d.ts +21 -51
  35. package/dist/deck.js +10 -10
  36. package/dist/diff.js +5 -5
  37. package/dist/docs.js +33 -27
  38. package/dist/examples.d.ts +1 -1
  39. package/dist/examples.js +418 -451
  40. package/dist/format.js +2 -2
  41. package/dist/index.d.ts +179 -16
  42. package/dist/index.js +51 -796
  43. package/dist/markdown.d.ts +10 -6
  44. package/dist/markdown.js +7 -7
  45. package/dist/node-engine.d.ts +114 -0
  46. package/dist/node-engine.js +44 -0
  47. package/dist/{pagination-DzZPFheM.d.ts → pagination-BaUjDrTz.d.ts} +25 -8
  48. package/dist/pagination.d.ts +3 -3
  49. package/dist/pagination.js +4 -4
  50. package/dist/patch.js +4 -4
  51. package/dist/{presentation-COrFuj2g.d.ts → presentation-HondgJ3l.d.ts} +278 -454
  52. package/dist/repo-readme.js +1 -1
  53. package/dist/schemas.d.ts +4 -2
  54. package/dist/schemas.js +1 -1
  55. package/dist/spec/catalogs/manifest.json +1 -1
  56. package/dist/spec/schemas/opf.schema.json +74 -100
  57. package/dist/types.d.ts +2 -2
  58. package/dist/{validation-types-HxIgJfKx.d.ts → validation-types-PbGDrNUr.d.ts} +23 -7
  59. package/dist/validator.d.ts +6 -6
  60. package/dist/validator.js +3 -3
  61. package/dist/yaml.d.ts +4 -4
  62. package/dist/yaml.js +7 -7
  63. package/package.json +37 -2
package/README.md CHANGED
@@ -49,6 +49,20 @@ console.log(Object.keys(saved.catalogs.default.themes)); // ["classic"]
49
49
  console.log(Object.keys(defaultCatalog.tones));
50
50
  ```
51
51
 
52
+ In Node (and Bun and Deno), the root adds files: `convert` turns one file into another (a deck to PDF, PNG, SVG or PPTX, a PowerPoint file to a deck, one deck form to another, or bytes with no output path), `open` reads a deck file or imports a `.pptx`, and `save` writes one. The same import works in every runtime, so one namespace import covers an application:
53
+
54
+ ```ts
55
+ import * as opf from "@openpresentation/opf";
56
+
57
+ await opf.convert("deck.opf.md", "deck.pdf");
58
+ const deck = await opf.open("deck.opf.md");
59
+ deck.slides.push({ title: "Q4" });
60
+ await opf.save(deck, "deck.opf.md");
61
+ const { files } = await opf.convert(deck, { format: "pptx" }); // bytes, nothing written
62
+ ```
63
+
64
+ Drawing and PowerPoint go through the optional peers `@openpresentation/opf-render` and `@openpresentation/opf-pptx`, which core loads the first time a call needs them; npm does not install them for you. The root has conditional exports (OPF 0.18 removed `/node`): `node`, `bun` and `deno` get this full build, and `browser`, `worker`, `workerd` and `default` get a browser-safe build with the same names and the same types, where `open`, `save` and `convert` reject with `OPFApiError` code `node-only`. Every other subpath runs in a browser. `parseSlideSelection(3 | "1-3" | [1, 3], total)` reads slide selections in both. See [OPF files in Node](../../docs/node.md).
65
+
52
66
  Use focused imports when you only need one surface:
53
67
 
54
68
  ```ts
@@ -59,7 +73,7 @@ import { validate, assertValid, validationRules } from "@openpresentation/opf/va
59
73
  import type { Presentation, Audience, Tone } from "@openpresentation/opf/types";
60
74
  ```
61
75
 
62
- The root entry holds the application-level API: schemas, catalog references and their resolution (`resolveReference`, `embed`, `copySlides`, `updateFromCatalog`), validation, variables, pagination, data helpers, font policy, `stats` and `resolveSlideContext`. It carries no catalog records: the pinned pptx.gallery snapshot is the opt-in `@openpresentation/opf/catalog` (`defaultCatalog`, display metadata and layout previews), and every entry point that resolves references takes `{ catalogs }`, the catalogs the host registered; the first one is the default for documents that omit `catalogs.default`. See [catalogs and the default catalog](../../docs/default-catalog.md).
76
+ The root entry holds the application-level API: schemas, catalog references and their resolution (`resolveReference`, `embed`, `copySlides`, `updateFromCatalog`), validation, variables, pagination, data helpers, font policy, `stats`, `resolveSlideContext` and `resolveSlideVariables`. Engines compose and draw `context.slide` from `resolveSlideContext(deck, index, { slideNumber, slideCount })`: the slide with the slide-scoped built-ins `{{slide.number}}`, `{{slide.section}}` and `{{deck.slideCount}}` substituted for the same numbers its `options` carry (`resolveSlideVariables(slide, { slideNumber, slideCount })` does that substitution alone). Header and footer text is substituted by `layoutFurniture`, which records each slide number in `FurnitureTextPart.fields`. See [templates and variables](../../docs/templates-and-variables.md#slide-scoped-built-ins). It carries no catalog records: the pinned pptx.gallery snapshot is the opt-in `@openpresentation/opf/catalog` (`defaultCatalog`, display metadata and layout previews), and every entry point that resolves references takes `{ catalogs }`, the catalogs the host registered; the first one is the default for documents that omit `catalogs.default`. See [catalogs and the default catalog](../../docs/default-catalog.md).
63
77
 
64
78
  The layout engine's names are not on the root. `composeSlide`, `fitText`, `layoutQuote` and the other `layoutX`/`fitX` functions, numbering, footnotes and citations, colour contrast, code syntax, pattern fills, metric trends, chart options, script fonts and text direction come from `@openpresentation/opf/composition`; the symbol-font tables come from `@openpresentation/opf/symbol-font-encodings`.
65
79
 
@@ -77,7 +91,7 @@ The layout engine's names are not on the root. `composeSlide`, `fitText`, `layou
77
91
 
78
92
  ### Reading and writing a deck in any form
79
93
 
80
- `readDeck(text, { format, filename, catalogs, validate })` and `writeDeck(presentation, { format | filename })` (the root and `@openpresentation/opf/deck`) read and write a deck as JSON (canonical), YAML or Markdown. The format is the `format` option, else the file name (`.opf.md` is Markdown, `.yaml` and `.yml` are YAML, anything else JSON; a plain `.md` is not a deck), and never the content. `readDeck` returns `{ presentation, format, valid, findings, counts, schemaValid, checks }`: the `validate` report of the deck, with every finding located in the text that was read (`opf/json-syntax`, `yaml/<rule>` or `markdown/<rule>` for syntax errors) and no exception for malformed content. It runs in a browser.
94
+ `parse(text, { format, filename, catalogs })` and `stringify(presentation, { format | filename })` (the root and `@openpresentation/opf/deck`) read and write a deck as JSON (canonical), YAML or Markdown. The format is the `format` option, else the file name (`.opf.md` is Markdown, `.yaml` and `.yml` are YAML, anything else JSON; a plain `.md` is not a deck), and never the content. `parse` returns the presentation and throws `OPFValidationError` for a syntax, schema or reference error; the error's `report.findings` are located by line and column in the text (`opf/json-syntax`, `yaml/<rule>` or `markdown/<rule>` for syntax errors). Warnings do not throw: `validate(text)` returns the full report. Both run in a browser; files are the Node build's job (above).
81
95
 
82
96
  ### OPF as YAML
83
97
 
@@ -0,0 +1,38 @@
1
+ import { OPFApiError } from './chunk-QLFWWHRF.js';
2
+ export { OPFApiError, OPFExportError, OPFImportError, OPFMoveToCustomError, copySlides, edit, embed, fill, fillRecords, moveToCustom, parseSlideSelection, sameRecord, stats, updateFromCatalog } from './chunk-QLFWWHRF.js';
3
+ export { specFileEntries, specFileKinds, specFilePaths } from './chunk-HXHOZ7AH.js';
4
+ export { OPFDataImportError, ingest, parseTabularData } from './chunk-ZCFSDSUX.js';
5
+ export { DECK_FORMATS, deckFormatOf, parse, stringify } from './chunk-ZOHFLP3O.js';
6
+ export { fromMarkdown, toMarkdown } from './chunk-DBYZI75U.js';
7
+ import './chunk-NS3VYB57.js';
8
+ export { OPFMarkdownError } from './chunk-CJPDTLGD.js';
9
+ export { diff, merge } from './chunk-YWXB4XAT.js';
10
+ export { OPFPatchError, OPFPatchValidationError, applyPatch } from './chunk-YZXTXX2D.js';
11
+ export { OPFFormatError, format } from './chunk-JXVS7BJK.js';
12
+ export { OPFPaginationError, paginate, paginateSlide } from './chunk-64YSJZDH.js';
13
+ import './chunk-VCGRMNY2.js';
14
+ import './chunk-RAKEVM52.js';
15
+ export { DEFAULT_CHART_PALETTE, DEFAULT_VALIDATION_THRESHOLDS, OPFValidationError, assertValid, assertValidCatalogRecord, findValidationRule, resolveSlideContext, validate, validateCatalogRecord, validationCategories, validationRules } from './chunk-JT3QXA22.js';
16
+ export { CHART_TYPES, DEFAULT_VARIABLE_DATE_FORMAT, ENGINE_DEFAULT_CHART_TYPES, ENGINE_DEFAULT_COLOR_SCHEME, ENGINE_DEFAULT_FONT_SCHEME, ENGINE_DEFAULT_THEME, LANGUAGES, LOGO_SHAPES, OPFVariableError, SLIDE_SCOPED_BUILTINS, SOCIAL_PLATFORMS, VARIABLE_KINDS, chartNumber, coerceVariableValue, datasetDiagnostics, formatDataNumber, formatVariableNumber, fromExcelNumberFormat, hasContentVariables, inlineChartData, inlineDatasets, inlineTableData, isDatasetRef, isTemplate, isXYChartType, listBuiltinVariables, listVariables, normalizeLanguageFamily, numberFormatError, resolveChartData, resolveDesignRecords, resolveFontScheme, resolveSlideVariables, resolveTableData, resolveVariables, suggestChartNumberFix, tableCellDisplayValue, toExcelNumberFormat, unusedDatasets, variableDeclarations } from './chunk-MBU42S5Y.js';
17
+ export { catalogDisplayKinds, catalogSchemaNames } from './chunk-TRDXRRQK.js';
18
+ export { CATALOG_GROUP_PATTERN, CATALOG_REFERENCE_PATTERN, OPFCatalogsOptionError, OPFUnresolvedReferenceError, catalogGroupSource, catalogKinds, catalogRecords, catalogReferenceSites, parseReference, resolveReference, unresolvedReference } from './chunk-SPFV27O5.js';
19
+ export { audience, chartType, colorScheme, fontScheme, language, layout, narrative, presentation, purpose, schemaEntries, schemaNames, schemas, socialPlatform, theme, tone } from './chunk-6WW2EDUW.js';
20
+ export { FONT_POLICY, applyFontPolicyDecisions, fontAvailabilityDiagnostics, fontPolicyFor } from './chunk-WXSPETQ6.js';
21
+
22
+ // src/browser.ts
23
+ var nodeOnly = (name, message) => new OPFApiError(`\`${name}\` ${message}`, "node-only", { details: { function: name, build: "browser" } });
24
+ var PARSE = "In a browser or a worker, read the text yourself and call parse(text, { filename }).";
25
+ var STRINGIFY = "In a browser or a worker, call stringify(deck, { filename }) and store or download the text.";
26
+ var CONVERT = "In a browser or a worker, change deck forms with parse and stringify (YAML, Markdown, JSON), and draw slides with @openpresentation/opf-render's /export-browser entry.";
27
+ var open = async () => {
28
+ throw nodeOnly("open", `reads files and needs Node. ${PARSE}`);
29
+ };
30
+ var save = async () => {
31
+ throw nodeOnly("save", `writes files and needs Node. ${STRINGIFY}`);
32
+ };
33
+ var convert = (async (_input, output) => {
34
+ const inMemory = output !== null && typeof output === "object";
35
+ throw nodeOnly("convert", inMemory ? `needs Node in OPF 0.18, also for the in-memory convert(deck, { format }). ${CONVERT}` : `reads and writes files and needs Node. ${CONVERT}`);
36
+ });
37
+
38
+ export { convert, open, save };
@@ -125,4 +125,4 @@ declare function catalogReferenceSites(document: unknown, options?: {
125
125
  /** Records a picker can offer for `kind`: the document's embedded records, then those of the registered catalogs its groups name, with the reference to write for each. */
126
126
  declare function catalogRecords(document: unknown, kind: CatalogKind, options?: CatalogOptions): ResolvedReference[];
127
127
 
128
- export { type Catalog as C, OPFCatalogsOptionError as O, type RecordProvenance as R, type UnresolvedReferenceDiagnostic as U, type CatalogKind as a, type CatalogOptions as b, CATALOG_GROUP_PATTERN as c, CATALOG_REFERENCE_PATTERN as d, type CatalogRecordMap as e, type CatalogRecords as f, type CatalogReferenceSite as g, OPFUnresolvedReferenceError as h, type ResolvedReference as i, catalogGroupSource as j, catalogKinds as k, catalogRecords as l, catalogReferenceSites as m, parseReference as p, resolveReference as r, unresolvedReference as u };
128
+ export { type CatalogKind as C, OPFCatalogsOptionError as O, type RecordProvenance as R, type UnresolvedReferenceDiagnostic as U, type Catalog as a, type CatalogOptions as b, CATALOG_GROUP_PATTERN as c, CATALOG_REFERENCE_PATTERN as d, type CatalogRecordMap as e, type CatalogRecords as f, type CatalogReferenceSite as g, OPFUnresolvedReferenceError as h, type ResolvedReference as i, catalogGroupSource as j, catalogKinds as k, catalogRecords as l, catalogReferenceSites as m, parseReference as p, resolveReference as r, unresolvedReference as u };
@@ -1,4 +1,4 @@
1
- import { a as CatalogKind } from './catalog-refs-_anZs-Qz.js';
1
+ import { C as CatalogKind } from './catalog-refs-BSfGELpt.js';
2
2
  import { SchemaName } from './schemas.js';
3
3
 
4
4
  /** Kinds of catalog display metadata: published by catalogs for pickers, never referenced by documents. */
package/dist/catalog.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Catalog } from './catalog-refs-_anZs-Qz.js';
2
- import { C as CatalogDisplayKind } from './catalog-schemas-BZCjgAxu.js';
1
+ import { a as Catalog } from './catalog-refs-BSfGELpt.js';
2
+ import { C as CatalogDisplayKind } from './catalog-schemas-CinPh5WA.js';
3
3
  import './schemas.js';
4
4
  import './json-BFSdESOE.js';
5
5