@openpresentation/opf 0.26.9 → 0.27.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/README.md +6 -0
- package/dist/browser.js +20 -17
- package/dist/{chunk-H7XMO36O.js → chunk-353VBJ6K.js} +5 -5
- package/dist/chunk-43JWUIGF.js +8 -0
- package/dist/chunk-4ACS57MG.js +236 -0
- package/dist/{chunk-F4HFDP6I.js → chunk-4ZM5G3XX.js} +1 -1
- package/dist/{chunk-NVT2YDVC.js → chunk-7XUEKIXH.js} +2 -2
- package/dist/{chunk-Y25DYRME.js → chunk-ABFDFZIW.js} +1 -1
- package/dist/{chunk-A54NGT2K.js → chunk-APLNGCEZ.js} +2 -2
- package/dist/{chunk-G5WJMJV3.js → chunk-CXPBU5W4.js} +1 -1
- package/dist/{chunk-PHP45MO7.js → chunk-EO3JWEO5.js} +1 -1
- package/dist/chunk-GJO5NUVT.js +1 -0
- package/dist/chunk-GM7WFPGG.js +10 -0
- package/dist/{chunk-3S2XVDPN.js → chunk-GNKESMZT.js} +6 -6
- package/dist/chunk-JBARNYFR.js +23 -0
- package/dist/{chunk-TKQ2VFV5.js → chunk-JSHMFTSY.js} +1 -1
- package/dist/{chunk-VZBFQLCA.js → chunk-KZPZRHL6.js} +6 -6
- package/dist/{chunk-XRMV2GMB.js → chunk-LRTQXGJO.js} +236 -144
- package/dist/{chunk-EQ6S5SEZ.js → chunk-O3SA5SJ4.js} +1 -1
- package/dist/{chunk-GIWNHRTX.js → chunk-OSM3LZ2Y.js} +4 -4
- package/dist/{chunk-IVPA6NG6.js → chunk-PAGVSTVF.js} +348 -97
- package/dist/{chunk-Y4TZCE7R.js → chunk-SYW4BCGZ.js} +2 -2
- package/dist/{chunk-D25BNPTW.js → chunk-TMREBZBQ.js} +4 -4
- package/dist/{chunk-77KL2PMM.js → chunk-WJ4XTCOD.js} +2 -2
- package/dist/{chunk-XMCBFQPY.js → chunk-ZGTOZA2S.js} +6 -6
- package/dist/{composition-DIftf6iP.d.ts → composition-BGmpe5e4.d.ts} +51 -5
- package/dist/composition.d.ts +1 -1
- package/dist/composition.js +2 -1
- package/dist/{conversion-Bnx8mWl9.d.ts → conversion-8SQD4dqu.d.ts} +6 -6
- package/dist/conversion-LN6PFRZL.js +24 -0
- package/dist/convert.d.ts +2 -2
- package/dist/convert.js +9 -7
- package/dist/data.d.ts +1 -1
- package/dist/data.js +3 -2
- package/dist/{deck-report-5vwMGcQz.d.ts → deck-report-BaKgPh_N.d.ts} +2 -2
- package/dist/deck.d.ts +6 -6
- package/dist/deck.js +13 -11
- package/dist/diff.d.ts +1 -1
- package/dist/diff.js +6 -4
- package/dist/docs.js +8 -6
- package/dist/examples.d.ts +1 -1
- package/dist/examples.js +2 -0
- package/dist/{finding-l9dlQ2NF.d.ts → finding-Bh56sGtF.d.ts} +1 -1
- package/dist/font-policy.js +1 -0
- package/dist/format.js +3 -2
- package/dist/ids.d.ts +113 -0
- package/dist/ids.js +6 -0
- package/dist/index.d.ts +15 -12
- package/dist/index.js +24 -21
- package/dist/markdown.d.ts +4 -4
- package/dist/markdown.js +10 -8
- package/dist/node-engine.d.ts +8 -8
- package/dist/node-engine.js +24 -21
- package/dist/{pagination-D_kJe4jH.d.ts → pagination-BsUTsQvk.d.ts} +1 -1
- package/dist/pagination.d.ts +2 -2
- package/dist/pagination.js +6 -4
- package/dist/patch.d.ts +87 -4
- package/dist/patch.js +5 -3
- package/dist/precompiled.d.ts +2 -0
- package/dist/precompiled.js +7 -0
- package/dist/{presentation-Bwo8Ko6D.d.ts → presentation-C-nHZyMw.d.ts} +1 -1
- package/dist/repo-readme.js +2 -0
- package/dist/schema-engine-ajv.js +37 -0
- package/dist/schema-engine-precompiled.js +3 -0
- package/dist/schema.js +5 -3
- package/dist/schemas.js +2 -1
- package/dist/source.d.ts +1 -1
- package/dist/source.js +12 -10
- package/dist/spec/schemas/opf.schema.json +1 -1
- package/dist/spec-files.js +1 -0
- package/dist/symbol-font-encodings.js +2 -0
- package/dist/types.d.ts +2 -2
- package/dist/{validation-types-3ARvTsB0.d.ts → validation-types-6_jEaHeE.d.ts} +2 -2
- package/dist/validator.d.ts +5 -5
- package/dist/validator.js +5 -3
- package/dist/yaml.d.ts +4 -4
- package/dist/yaml.js +9 -7
- package/package.json +29 -8
- package/dist/conversion-63DPSXBJ.js +0 -21
package/README.md
CHANGED
|
@@ -64,6 +64,8 @@ const { files } = await opf.convert(deck, { format: "pptx" }); // bytes, nothing
|
|
|
64
64
|
|
|
65
65
|
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).
|
|
66
66
|
|
|
67
|
+
On Cloudflare Workers, Vercel Edge and other hosts that refuse code generation from strings, `validate` runs validators compiled at build time instead of compiling the schemas with Ajv. The `workerd`, `worker` and `edge-light` conditions choose them, so a Worker needs no alias and no option; code bundled for Node that runs on a worker (and a page under a strict Content-Security-Policy) imports `@openpresentation/opf/precompiled` once. The verdicts and findings are the same, and a CI lane runs the package in the real `workerd` runtime. See [Edge runtimes](../../docs/node.md#edge-runtimes-validators-that-never-compile-code).
|
|
68
|
+
|
|
67
69
|
Use focused imports when you only need one surface:
|
|
68
70
|
|
|
69
71
|
```ts
|
|
@@ -111,6 +113,10 @@ Two browser-safe subpaths for source editors, the CLI and agents. `@openpresenta
|
|
|
111
113
|
|
|
112
114
|
Added in 0.12.0 (not in 0.11.4 or earlier): `@openpresentation/opf/patch` is the one RFC 6902 implementation the CLI and the editor share (`applyPatch`, `applyPatchWithInverse`, `invertPatch`, strict pointer helpers, optional schema validation of the result); `@openpresentation/opf/diff` has `diff` (slide matching by id, content and similarity, moves, a readable report and a JSON Patch) and `merge` (three-way merge with conflict objects that never drop a side); `@openpresentation/opf/format` has `format` (canonical key order and layout, idempotent). See [the guide](../../docs/patch-diff-merge-format.md).
|
|
113
115
|
|
|
116
|
+
### Ids, document hash and patch scope (CE-04, CE-05)
|
|
117
|
+
|
|
118
|
+
`@openpresentation/opf/ids` (all of it also on the package root, the pointer and hash parts also on `/patch`) makes edits addressable and checkable. `assignIds(document, { generate? })` fills the missing `id` of slides and content payloads deterministically (`{ document, patch, assigned }`; existing ids are never changed). In an array, the pointer token `@intro` names the element whose `id` is `intro`, so `/slides/@intro/blocks/@kpi/text` survives reordering: `applyPatch` and `readPointer` resolve it, `resolveIdPointer` and `toIdPointer` convert a pointer, `resolveIdPatch` and `toIdPatch` a whole patch. `documentHash(document)` is `sha256:` and a SHA-256 of the key-sorted JSON (pure JavaScript, the same in Node, browsers and edge runtimes); `applyPatch(document, patch, { expectHash })` and `edit(deck, patch, { expectHash })` apply only to the document that hash was taken from, else throw `OPFPatchHashError` and change nothing. `touches(patch, document?)` returns the pointers (index and id form), ids, slide ids and kinds a patch reads and writes, for conflict detection and permission checks. See [the guide](../../docs/patch-diff-merge-format.md#ids-id-addressed-paths-hashes-and-patch-scope).
|
|
119
|
+
|
|
114
120
|
### Layout previews
|
|
115
121
|
|
|
116
122
|
`@openpresentation/gallery/previews` ships pre-rendered SVG thumbnails for the
|
package/dist/browser.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import { OPFApiError } from './chunk-
|
|
2
|
-
export { OPFApiError, OPFExportError, OPFImportError, OPFMoveToCustomError, copySlides, edit, embed, fill, fillRecords, localAssetSources, moveToCustom, parseSlideSelection, sameRecord, stats, updateFromCatalog } from './chunk-
|
|
1
|
+
import { OPFApiError } from './chunk-TMREBZBQ.js';
|
|
2
|
+
export { OPFApiError, OPFExportError, OPFImportError, OPFMoveToCustomError, copySlides, edit, embed, fill, fillRecords, localAssetSources, moveToCustom, parseSlideSelection, sameRecord, stats, updateFromCatalog } from './chunk-TMREBZBQ.js';
|
|
3
3
|
export { specFileEntries, specFileKinds, specFilePaths } from './chunk-UJSAR6GF.js';
|
|
4
4
|
export { FONT_POLICY, applyFontPolicyDecisions, fontAvailabilityDiagnostics, fontPolicyFor } from './chunk-PJSPHHRK.js';
|
|
5
|
-
export { OPFDataImportError, ingest, parseTabularData } from './chunk-
|
|
6
|
-
export { OPFPaginationError, paginate, paginateSlide } from './chunk-
|
|
7
|
-
export { DECK_FORMATS, deckFormatOf, parse, stringify } from './chunk-
|
|
8
|
-
export { fromMarkdown, toMarkdown } from './chunk-
|
|
9
|
-
import './chunk-
|
|
5
|
+
export { OPFDataImportError, ingest, parseTabularData } from './chunk-JSHMFTSY.js';
|
|
6
|
+
export { OPFPaginationError, paginate, paginateSlide } from './chunk-WJ4XTCOD.js';
|
|
7
|
+
export { DECK_FORMATS, deckFormatOf, parse, stringify } from './chunk-OSM3LZ2Y.js';
|
|
8
|
+
export { fromMarkdown, toMarkdown } from './chunk-GNKESMZT.js';
|
|
9
|
+
import './chunk-KZPZRHL6.js';
|
|
10
|
+
export { OPFFormatError, format } from './chunk-O3SA5SJ4.js';
|
|
10
11
|
import './chunk-RYZPBJLB.js';
|
|
11
|
-
export { explain } from './chunk-
|
|
12
|
-
import './chunk-
|
|
13
|
-
import './chunk-
|
|
14
|
-
export { OPFMarkdownError } from './chunk-
|
|
15
|
-
import './chunk-
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
|
|
20
|
-
export { audience, chartType, colorScheme, fontScheme, language, layout, narrative, presentation, purpose, schemaEntries, schemaNames, schemas, socialPlatform, theme, tone } from './chunk-
|
|
12
|
+
export { explain } from './chunk-CXPBU5W4.js';
|
|
13
|
+
import './chunk-353VBJ6K.js';
|
|
14
|
+
import './chunk-EO3JWEO5.js';
|
|
15
|
+
export { OPFMarkdownError } from './chunk-SYW4BCGZ.js';
|
|
16
|
+
import './chunk-ABFDFZIW.js';
|
|
17
|
+
export { OPFIdError, assignIds, touches } from './chunk-4ACS57MG.js';
|
|
18
|
+
export { diff, merge } from './chunk-APLNGCEZ.js';
|
|
19
|
+
export { CATALOG_SCHEMA, DEFAULT_VALIDATION_THRESHOLDS, OPFPatchError, OPFPatchHashError, OPFPatchValidationError, OPFValidationError, applyPatch, assertValid, assertValidCatalogRecord, catalogDisplayKinds, catalogSchemaNames, documentHash, findValidationRule, idToken, isIdToken, resolveIdPatch, resolveIdPointer, resolveSlideContext, toIdPatch, toIdPointer, validate, validateCatalogRecord, validationCategories, validationRules } from './chunk-PAGVSTVF.js';
|
|
20
|
+
import './chunk-JBARNYFR.js';
|
|
21
|
+
export { audience, chartType, colorScheme, fontScheme, language, layout, narrative, presentation, purpose, schemaEntries, schemaNames, schemas, socialPlatform, theme, tone } from './chunk-4ZM5G3XX.js';
|
|
22
|
+
export { CATALOG_GROUP_PATTERN, CATALOG_REFERENCE_PATTERN, CHART_TYPES, DEFAULT_VARIABLE_DATE_FORMAT, ENGINE_DEFAULT_CHART_TYPES, ENGINE_DEFAULT_COLOR_SCHEME, ENGINE_DEFAULT_FONT_SCHEME, ENGINE_DEFAULT_THEME, LANGUAGES, LOGO_SHAPES, OPFCatalogsOptionError, OPFUnresolvedReferenceError, OPFVariableError, SLIDE_SCOPED_BUILTINS, SOCIAL_PLATFORMS, VARIABLE_KINDS, catalogGroupSource, catalogKinds, catalogRecords, catalogReferenceSites, chartNumber, coerceVariableValue, datasetDiagnostics, formatDataNumber, formatVariableNumber, fromExcelNumberFormat, hasContentVariables, inlineChartData, inlineDatasets, inlineTableData, isDatasetRef, isTemplate, isXYChartType, listBuiltinVariables, listVariables, normalizeLanguageFamily, numberFormatError, parseReference, resolveChartData, resolveDesignRecords, resolveFontScheme, resolveReference, resolveSlideVariables, resolveTableData, resolveVariables, suggestChartNumberFix, tableCellDisplayValue, toExcelNumberFormat, unresolvedReference, unusedDatasets, variableDeclarations } from './chunk-LRTQXGJO.js';
|
|
23
|
+
import './chunk-GM7WFPGG.js';
|
|
21
24
|
|
|
22
25
|
// src/browser.ts
|
|
23
26
|
var nodeOnly = (name, message) => new OPFApiError(`\`${name}\` ${message}`, "node-only", { details: { function: name, build: "browser" } });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { parseQuoteLines, levelsFromIndents, parseCodeFence, splitWhen } from './chunk-
|
|
2
|
-
import { Ctx, splitLines, lineRange, readYamlMapping, readCsv, DECIMAL } from './chunk-
|
|
3
|
-
import { runText, isRecord, FORMATTING } from './chunk-
|
|
4
|
-
import { METRIC_KEYS, nearest, BLOCK_AS_VALUES, SLIDE_OPTION_KEYS, BLOCK_OPTION_KEYS } from './chunk-
|
|
5
|
-
import { PROMOTED_REGION_KEY } from './chunk-
|
|
1
|
+
import { parseQuoteLines, levelsFromIndents, parseCodeFence, splitWhen } from './chunk-EO3JWEO5.js';
|
|
2
|
+
import { Ctx, splitLines, lineRange, readYamlMapping, readCsv, DECIMAL } from './chunk-SYW4BCGZ.js';
|
|
3
|
+
import { runText, isRecord, FORMATTING } from './chunk-ABFDFZIW.js';
|
|
4
|
+
import { METRIC_KEYS, nearest, BLOCK_AS_VALUES, SLIDE_OPTION_KEYS, BLOCK_OPTION_KEYS } from './chunk-PAGVSTVF.js';
|
|
5
|
+
import { PROMOTED_REGION_KEY } from './chunk-LRTQXGJO.js';
|
|
6
6
|
|
|
7
7
|
// src/markdown/inline.ts
|
|
8
8
|
var PUNCT = /[\p{P}\p{S}]/u;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { applyPatch, normalizePatch, walkPatch, toIdPointer, resolveIdPointer, parsePointer, readPointer, idToken, formatPointer, isIdToken } from './chunk-PAGVSTVF.js';
|
|
2
|
+
import { isRecord, visitContentPayloads, promotedRegionKeys } from './chunk-LRTQXGJO.js';
|
|
3
|
+
|
|
4
|
+
// src/ids.ts
|
|
5
|
+
var INDEX_TOKEN = /^(0|[1-9][0-9]*)$/;
|
|
6
|
+
var OPFIdError = class extends Error {
|
|
7
|
+
code;
|
|
8
|
+
/** The JSON Pointer of the slide or payload the error is about, when known. */
|
|
9
|
+
path;
|
|
10
|
+
constructor(code, message, path) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "OPFIdError";
|
|
13
|
+
this.code = code;
|
|
14
|
+
if (path !== void 0) this.path = path;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
function assignIds(document, options = {}) {
|
|
18
|
+
if (!isRecord(document)) throw new OPFIdError("invalid-document", "assignIds expects a presentation object.");
|
|
19
|
+
const taken = /* @__PURE__ */ new Set();
|
|
20
|
+
const slides = Array.isArray(document.slides) ? document.slides : [];
|
|
21
|
+
const known = (node) => {
|
|
22
|
+
if (typeof node.id === "string") taken.add(node.id);
|
|
23
|
+
};
|
|
24
|
+
slides.forEach((slide, index) => {
|
|
25
|
+
if (!isRecord(slide)) return;
|
|
26
|
+
known(slide);
|
|
27
|
+
visitContentPayloads(slide, `/slides/${index}`, known);
|
|
28
|
+
});
|
|
29
|
+
const counters = { slide: 0, block: 0 };
|
|
30
|
+
const byDefault = (kind) => {
|
|
31
|
+
let id;
|
|
32
|
+
do {
|
|
33
|
+
counters[kind] += 1;
|
|
34
|
+
id = `${kind}-${counters[kind]}`;
|
|
35
|
+
} while (taken.has(id));
|
|
36
|
+
return id;
|
|
37
|
+
};
|
|
38
|
+
const idOf = /* @__PURE__ */ new Map();
|
|
39
|
+
const parentIdOf = (pointer) => {
|
|
40
|
+
for (let tokens = parsePointer(pointer).slice(0, -1); tokens.length; tokens = tokens.slice(0, -1)) {
|
|
41
|
+
const id = idOf.get(formatPointer(tokens));
|
|
42
|
+
if (id !== void 0) return id;
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
};
|
|
46
|
+
const patch = [];
|
|
47
|
+
const assigned = [];
|
|
48
|
+
const visit = (kind, node, pointer) => {
|
|
49
|
+
if (typeof node.id === "string") {
|
|
50
|
+
idOf.set(pointer, node.id);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (Object.hasOwn(node, "id")) return;
|
|
54
|
+
let id;
|
|
55
|
+
if (options.generate) {
|
|
56
|
+
const parentId = parentIdOf(pointer);
|
|
57
|
+
id = options.generate({ kind, pointer, node, ...parentId !== void 0 ? { parentId } : {} });
|
|
58
|
+
if (typeof id !== "string" || id === "") throw new OPFIdError("invalid-id", `generate returned ${JSON.stringify(id)} for ${pointer}; an id is a non-empty string.`, pointer);
|
|
59
|
+
if (taken.has(id)) throw new OPFIdError("duplicate-id", `generate returned '${id}' for ${pointer}, which another slide or block already has.`, pointer);
|
|
60
|
+
} else id = byDefault(kind);
|
|
61
|
+
taken.add(id);
|
|
62
|
+
idOf.set(pointer, id);
|
|
63
|
+
patch.push({ op: "add", path: `${pointer}/id`, value: id });
|
|
64
|
+
assigned.push({ pointer, kind, id });
|
|
65
|
+
};
|
|
66
|
+
slides.forEach((slide, index) => {
|
|
67
|
+
if (!isRecord(slide)) return;
|
|
68
|
+
const pointer = `/slides/${index}`;
|
|
69
|
+
visit("slide", slide, pointer);
|
|
70
|
+
visitContentPayloads(slide, pointer, (payload, path) => visit("block", payload, path));
|
|
71
|
+
});
|
|
72
|
+
return { document: applyPatch(document, patch), patch, assigned };
|
|
73
|
+
}
|
|
74
|
+
var KIND_ORDER = ["document", "slide-order", "slide", "block", "design", "assets", "catalogs", "metadata"];
|
|
75
|
+
var AREAS = { design: "design", assets: "assets", catalogs: "catalogs" };
|
|
76
|
+
function elementAt(array, token) {
|
|
77
|
+
if (isIdToken(token)) {
|
|
78
|
+
const id = token.slice(1);
|
|
79
|
+
const node = Array.isArray(array) ? array.find((item) => isRecord(item) && item.id === id) : void 0;
|
|
80
|
+
return { id, ...isRecord(node) ? { node } : {} };
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(array) && INDEX_TOKEN.test(token)) {
|
|
83
|
+
const node = array[Number(token)];
|
|
84
|
+
if (isRecord(node)) return { ...typeof node.id === "string" && node.id !== "" ? { id: node.id } : {}, node };
|
|
85
|
+
}
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
function locate(tokens, document, readOnlyOrReplace) {
|
|
89
|
+
const ids = [], slideIds = [];
|
|
90
|
+
const out = (kind2, shape2) => ({ kind: kind2, shape: shape2, ids, slideIds });
|
|
91
|
+
if (!tokens.length) return out("document", "document");
|
|
92
|
+
if (tokens[0] !== "slides") return out(AREAS[tokens[0]] ?? "metadata", "other");
|
|
93
|
+
if (tokens.length === 1) return out("slide-order", "slides");
|
|
94
|
+
const slide = elementAt(isRecord(document) ? document.slides : void 0, tokens[1]);
|
|
95
|
+
if (slide.id !== void 0) {
|
|
96
|
+
ids.push(slide.id);
|
|
97
|
+
slideIds.push(slide.id);
|
|
98
|
+
}
|
|
99
|
+
if (tokens.length === 2) return out(readOnlyOrReplace ? "slide" : "slide-order", "slide");
|
|
100
|
+
if (tokens[2] === "design") return out("design", "other");
|
|
101
|
+
let kind = "slide", shape = "other";
|
|
102
|
+
let node = slide.node, slideLevel = true;
|
|
103
|
+
for (let i = 2; i < tokens.length; ) {
|
|
104
|
+
const token = tokens[i];
|
|
105
|
+
if (slideLevel && promotedRegionKeys.includes(token)) {
|
|
106
|
+
const child = node?.[token];
|
|
107
|
+
if (isRecord(child) && typeof child.id === "string") ids.push(child.id);
|
|
108
|
+
kind = "block";
|
|
109
|
+
node = isRecord(child) ? child : void 0;
|
|
110
|
+
slideLevel = false;
|
|
111
|
+
i += 1;
|
|
112
|
+
shape = i === tokens.length ? "payload" : "other";
|
|
113
|
+
} else if (token === "blocks") {
|
|
114
|
+
kind = "block";
|
|
115
|
+
i += 1;
|
|
116
|
+
if (i === tokens.length) {
|
|
117
|
+
shape = "payloads";
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
const child = elementAt(node?.blocks, tokens[i]);
|
|
121
|
+
if (child.id !== void 0) ids.push(child.id);
|
|
122
|
+
node = child.node;
|
|
123
|
+
slideLevel = false;
|
|
124
|
+
i += 1;
|
|
125
|
+
shape = i === tokens.length ? "payload" : "other";
|
|
126
|
+
} else break;
|
|
127
|
+
}
|
|
128
|
+
return out(kind, shape);
|
|
129
|
+
}
|
|
130
|
+
function idsWithin(shape, value, into) {
|
|
131
|
+
const payload = (node, slide) => {
|
|
132
|
+
if (!isRecord(node)) return;
|
|
133
|
+
if (typeof node.id === "string") {
|
|
134
|
+
into.ids.push(node.id);
|
|
135
|
+
if (slide) into.slideIds.push(node.id);
|
|
136
|
+
}
|
|
137
|
+
visitContentPayloads(node, "", (child) => {
|
|
138
|
+
if (typeof child.id === "string") into.ids.push(child.id);
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
if (shape === "document") {
|
|
142
|
+
if (isRecord(value) && Array.isArray(value.slides)) for (const slide of value.slides) payload(slide, true);
|
|
143
|
+
} else if (shape === "slides") {
|
|
144
|
+
if (Array.isArray(value)) for (const slide of value) payload(slide, true);
|
|
145
|
+
} else if (shape === "slide") payload(value, true);
|
|
146
|
+
else if (shape === "payloads") {
|
|
147
|
+
if (Array.isArray(value)) for (const child of value) payload(child, false);
|
|
148
|
+
} else if (shape === "payload") payload(value, false);
|
|
149
|
+
}
|
|
150
|
+
var unique = (list) => [...new Set(list)];
|
|
151
|
+
function insertionIdPointer(state, path, value) {
|
|
152
|
+
const named = parsePointer(toIdPointer(state, path, { keepLast: true }));
|
|
153
|
+
const resolved = parsePointer(resolveIdPointer(state, path));
|
|
154
|
+
if (named.length && isRecord(value) && typeof value.id === "string" && value.id !== "") {
|
|
155
|
+
const parent = readPointer(state, resolved.slice(0, -1));
|
|
156
|
+
if (parent.found && Array.isArray(parent.value)) named[named.length - 1] = idToken(value.id);
|
|
157
|
+
}
|
|
158
|
+
return formatPointer(named);
|
|
159
|
+
}
|
|
160
|
+
function touches(patch, document) {
|
|
161
|
+
const reads = [];
|
|
162
|
+
const writes = [];
|
|
163
|
+
const record = (list, index, operation, pointer, state, values, idPointer) => {
|
|
164
|
+
const tokens = parsePointer(pointer);
|
|
165
|
+
const where = locate(tokens, state, operation.op === "replace" || operation.op === "test" || list === reads);
|
|
166
|
+
const found = { ids: where.ids, slideIds: where.slideIds };
|
|
167
|
+
for (const value of values) idsWithin(where.shape, value, found);
|
|
168
|
+
list.push({ operation: index, op: operation.op, pointer, idPointer: idPointer ?? pointer, kind: where.kind, ids: unique(found.ids), slideIds: unique(found.slideIds) });
|
|
169
|
+
};
|
|
170
|
+
if (document === void 0) {
|
|
171
|
+
normalizePatch(patch).forEach((operation, index) => {
|
|
172
|
+
switch (operation.op) {
|
|
173
|
+
case "add":
|
|
174
|
+
case "replace":
|
|
175
|
+
record(writes, index, operation, operation.path, void 0, [operation.value]);
|
|
176
|
+
break;
|
|
177
|
+
case "remove":
|
|
178
|
+
record(writes, index, operation, operation.path, void 0, []);
|
|
179
|
+
break;
|
|
180
|
+
case "test":
|
|
181
|
+
record(reads, index, operation, operation.path, void 0, [operation.value]);
|
|
182
|
+
break;
|
|
183
|
+
case "copy":
|
|
184
|
+
record(reads, index, operation, operation.from, void 0, []);
|
|
185
|
+
record(writes, index, operation, operation.path, void 0, []);
|
|
186
|
+
break;
|
|
187
|
+
case "move":
|
|
188
|
+
record(writes, index, operation, operation.from, void 0, []);
|
|
189
|
+
record(writes, index, operation, operation.path, void 0, []);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
} else {
|
|
194
|
+
const carried = /* @__PURE__ */ new Map();
|
|
195
|
+
const insertion = /* @__PURE__ */ new Map();
|
|
196
|
+
const valueAt = (state, pointer) => {
|
|
197
|
+
const found = readPointer(state, pointer);
|
|
198
|
+
return found.found ? [found.value] : [];
|
|
199
|
+
};
|
|
200
|
+
walkPatch(document, patch, {
|
|
201
|
+
before: (index, operation, working) => {
|
|
202
|
+
if (operation.op === "add") {
|
|
203
|
+
insertion.set(index, insertionIdPointer(working, operation.path, operation.value));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const source = operation.op === "copy" || operation.op === "move" ? operation.from : operation.path;
|
|
207
|
+
const pointer = resolveIdPointer(working, source);
|
|
208
|
+
const old = valueAt(working, pointer);
|
|
209
|
+
if (operation.op === "copy" || operation.op === "move") carried.set(index, old[0]);
|
|
210
|
+
if (operation.op === "copy") insertion.set(index, insertionIdPointer(working, operation.path, old[0]));
|
|
211
|
+
const idPointer = toIdPointer(working, pointer);
|
|
212
|
+
if (operation.op === "test") record(reads, index, operation, pointer, working, old, idPointer);
|
|
213
|
+
else if (operation.op === "copy") record(reads, index, operation, pointer, working, old, idPointer);
|
|
214
|
+
else if (operation.op === "replace") record(writes, index, operation, pointer, working, [...old, operation.value], idPointer);
|
|
215
|
+
else record(writes, index, operation, pointer, working, old, idPointer);
|
|
216
|
+
},
|
|
217
|
+
after: (step, working) => {
|
|
218
|
+
const { operation, resolved, index } = step;
|
|
219
|
+
if (operation.op !== "add" && operation.op !== "copy" && operation.op !== "move") return;
|
|
220
|
+
const value = operation.op === "add" ? operation.value : carried.get(index);
|
|
221
|
+
const idPointer = operation.op === "move" ? toIdPointer(working, resolved.path) : insertion.get(index);
|
|
222
|
+
record(writes, index, operation, resolved.path, working, [value], idPointer);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
const all = [...reads, ...writes];
|
|
227
|
+
return {
|
|
228
|
+
reads,
|
|
229
|
+
writes,
|
|
230
|
+
ids: unique(all.flatMap((touch) => touch.ids)),
|
|
231
|
+
slideIds: unique(all.flatMap((touch) => touch.slideIds)),
|
|
232
|
+
kinds: KIND_ORDER.filter((kind) => all.some((touch) => touch.kind === kind))
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export { OPFIdError, assignIds, touches };
|
|
@@ -5550,7 +5550,7 @@ var presentation = {
|
|
|
5550
5550
|
"$ref": "#/$defs/TableCellBorder"
|
|
5551
5551
|
}
|
|
5552
5552
|
},
|
|
5553
|
-
"description": "Independent cell edges.
|
|
5553
|
+
"description": "Independent cell edges. An omitted edge keeps the table's default rule: a line under every row (and over the first row), none between columns. Width 0 removes an edge."
|
|
5554
5554
|
}
|
|
5555
5555
|
},
|
|
5556
5556
|
"description": "Cell appearance. Sizes use reference pixels at a 720-pixel canvas short edge and scale with the slide."
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OPFApiError } from './chunk-
|
|
2
|
-
import { CATALOG_SCHEMA } from './chunk-
|
|
1
|
+
import { OPFApiError } from './chunk-TMREBZBQ.js';
|
|
2
|
+
import { CATALOG_SCHEMA } from './chunk-PAGVSTVF.js';
|
|
3
3
|
import { CATALOG_SCHEMA as CATALOG_SCHEMA$1, gallery } from '@openpresentation/gallery';
|
|
4
4
|
|
|
5
5
|
function galleryMismatch(declared, reads = CATALOG_SCHEMA) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsonEqual, formatPointer } from './chunk-
|
|
2
|
-
import { annotationText } from './chunk-
|
|
1
|
+
import { jsonEqual, formatPointer } from './chunk-PAGVSTVF.js';
|
|
2
|
+
import { annotationText } from './chunk-LRTQXGJO.js';
|
|
3
3
|
|
|
4
4
|
// src/diff-match.ts
|
|
5
5
|
var DEFAULT_MATCH_THRESHOLD = 0.5;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SOURCE_EXPLAIN, ruleDocumentation, findValidationRule, us } from './chunk-
|
|
1
|
+
import { SOURCE_EXPLAIN, ruleDocumentation, findValidationRule, us } from './chunk-PAGVSTVF.js';
|
|
2
2
|
|
|
3
3
|
// src/finding-text-explain-util.ts
|
|
4
4
|
var ex = (fix, problem, fixed) => ({ fix, problem, fixed });
|