@openpresentation/opf 0.26.3 → 0.26.5
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 +3 -1
- package/dist/browser.js +14 -11
- package/dist/{chunk-NJWI6MPT.js → chunk-CIWC7DRZ.js} +1985 -366
- package/dist/{chunk-7RY7QWWJ.js → chunk-DXTPLVAK.js} +1 -1
- package/dist/{chunk-54OV2WQC.js → chunk-EFMR32A5.js} +1 -1
- package/dist/{chunk-PXOXTJTN.js → chunk-HPEZCAYC.js} +1 -1
- package/dist/{chunk-2ZQBMZTZ.js → chunk-K5Q3LLYK.js} +2 -2
- package/dist/chunk-KPALXWX3.js +712 -0
- package/dist/{chunk-34LIUOT7.js → chunk-L7YEVQHP.js} +6 -6
- package/dist/chunk-MD3CJ5YJ.js +452 -0
- package/dist/{chunk-WASENX2R.js → chunk-MLH5LIGF.js} +29 -647
- package/dist/chunk-RYZPBJLB.js +4 -0
- package/dist/{chunk-FXNUM2PN.js → chunk-STIYINEL.js} +4 -4
- package/dist/{chunk-YVNFACTC.js → chunk-TAV5S2JG.js} +1 -1
- package/dist/{chunk-GLLR3AQ5.js → chunk-UFEWQDQI.js} +1 -1
- package/dist/chunk-UY6SQVR2.js +639 -0
- package/dist/{chunk-PB5X2VSV.js → chunk-WAZDP2WS.js} +12 -20
- package/dist/{conversion-BjsKgxBZ.d.ts → conversion-C7o2EpDb.d.ts} +2 -2
- package/dist/conversion-PMJWLHDV.js +21 -0
- package/dist/convert.js +5 -5
- package/dist/deck.js +9 -7
- package/dist/diff.js +2 -2
- package/dist/docs.js +3 -3
- package/dist/explain-JSuESV-Y.d.ts +71 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +18 -15
- package/dist/markdown.js +7 -5
- package/dist/node-engine.d.ts +2 -2
- package/dist/node-engine.js +18 -15
- package/dist/pagination.js +2 -2
- package/dist/patch.js +1 -1
- package/dist/schema.js +1 -1
- package/dist/source.d.ts +184 -5
- package/dist/source.js +391 -11
- package/dist/validator.js +1 -1
- package/dist/yaml.js +5 -4
- package/package.json +5 -5
- package/dist/chunk-DEI2M2H6.js +0 -194
- package/dist/conversion-F4UCOGR7.js +0 -18
package/dist/chunk-DEI2M2H6.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { isRecord, same } from './chunk-PXOXTJTN.js';
|
|
2
|
-
import { parseDocument, YAMLMap, Scalar, stringify } from 'yaml';
|
|
3
|
-
|
|
4
|
-
// src/not-checked.ts
|
|
5
|
-
var NOT_CHECKED = { syntax: "checked", schema: "not-run", references: "not-run", policy: "not-run", accessibility: "not-run", content: "not-run", layout: "not-run", backgroundPixels: "not-read", imageBytes: "embedded-only", nativeExport: "not-checked" };
|
|
6
|
-
function splitLines(source) {
|
|
7
|
-
const lines = [];
|
|
8
|
-
let start = 0;
|
|
9
|
-
let no = 1;
|
|
10
|
-
let i = 0;
|
|
11
|
-
while (i < source.length) {
|
|
12
|
-
const c = source[i];
|
|
13
|
-
if (c === "\n" || c === "\r") {
|
|
14
|
-
lines.push({ text: source.slice(start, i), start, end: i, no: no++ });
|
|
15
|
-
if (c === "\r" && source[i + 1] === "\n") i++;
|
|
16
|
-
i++;
|
|
17
|
-
start = i;
|
|
18
|
-
} else i++;
|
|
19
|
-
}
|
|
20
|
-
if (start < source.length) lines.push({ text: source.slice(start), start, end: source.length, no });
|
|
21
|
-
return lines;
|
|
22
|
-
}
|
|
23
|
-
var Ctx = class {
|
|
24
|
-
constructor(source) {
|
|
25
|
-
this.source = source;
|
|
26
|
-
for (let i = 0; i < source.length; i++) {
|
|
27
|
-
if (source[i] === "\r") {
|
|
28
|
-
if (source[i + 1] === "\n") i++;
|
|
29
|
-
this.lineStarts.push(i + 1);
|
|
30
|
-
} else if (source[i] === "\n") this.lineStarts.push(i + 1);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
source;
|
|
34
|
-
findings = [];
|
|
35
|
-
/** JSON Pointer in the converted document to the source range that produced it. */
|
|
36
|
-
ranges = /* @__PURE__ */ new Map();
|
|
37
|
-
lineStarts = [0];
|
|
38
|
-
location(range) {
|
|
39
|
-
let lo = 0;
|
|
40
|
-
let hi = this.lineStarts.length;
|
|
41
|
-
while (lo + 1 < hi) {
|
|
42
|
-
const mid = lo + hi >> 1;
|
|
43
|
-
if ((this.lineStarts[mid] ?? 0) <= range.start) lo = mid;
|
|
44
|
-
else hi = mid;
|
|
45
|
-
}
|
|
46
|
-
return { offset: range.start, length: Math.max(0, range.end - range.start), line: lo + 1, column: range.start - (this.lineStarts[lo] ?? 0) + 1 };
|
|
47
|
-
}
|
|
48
|
-
report(ruleId, severity, message, help, range, path = "") {
|
|
49
|
-
this.findings.push({ ruleId, severity, category: "format", scope: "document", path, message, help, location: this.location(range) });
|
|
50
|
-
}
|
|
51
|
-
error(rule, message, help, range, path = "") {
|
|
52
|
-
this.report(`markdown/${rule}`, "error", message, help, range, path);
|
|
53
|
-
}
|
|
54
|
-
warn(rule, message, help, range, path = "") {
|
|
55
|
-
this.report(`markdown/${rule}`, "warning", message, help, range, path);
|
|
56
|
-
}
|
|
57
|
-
get errors() {
|
|
58
|
-
return this.findings.filter((d) => d.severity === "error").length;
|
|
59
|
-
}
|
|
60
|
-
/** The source range of a JSON Pointer, falling back to the nearest ancestor that has one. */
|
|
61
|
-
rangeOf(pointer) {
|
|
62
|
-
for (let path = pointer; ; path = path.slice(0, path.lastIndexOf("/"))) {
|
|
63
|
-
const found = this.ranges.get(path);
|
|
64
|
-
if (found) return found;
|
|
65
|
-
if (!path) return void 0;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var lineRange = (first, last = first) => ({ start: first.start, end: last.end });
|
|
70
|
-
function readYamlMapping(text, base, ctx, rule, context) {
|
|
71
|
-
const keys = /* @__PURE__ */ new Map();
|
|
72
|
-
const doc = parseDocument(text, { schema: "core", uniqueKeys: true, merge: false, prettyErrors: false });
|
|
73
|
-
let ok = true;
|
|
74
|
-
for (const error of doc.errors) {
|
|
75
|
-
ok = false;
|
|
76
|
-
const [start, end] = error.pos;
|
|
77
|
-
ctx.error(rule, `YAML: ${error.message.split("\n")[0]}`, "Fix the YAML syntax. Front matter and embedded blocks hold JSON-compatible YAML: mappings, sequences and scalars, no anchors or tags.", { start: base + start, end: base + Math.max(end, start) });
|
|
78
|
-
}
|
|
79
|
-
if (!ok) return { value: {}, keys, ok };
|
|
80
|
-
if (doc.contents === null) return { value: {}, keys, ok };
|
|
81
|
-
if (!(doc.contents instanceof YAMLMap)) {
|
|
82
|
-
ctx.error(`${rule}-not-mapping`, "Expected a YAML mapping of keys and values.", "Write `key: value` lines; a list or a bare value is not accepted here.", context);
|
|
83
|
-
return { value: {}, keys, ok: false };
|
|
84
|
-
}
|
|
85
|
-
for (const pair of doc.contents.items) {
|
|
86
|
-
const key = pair.key;
|
|
87
|
-
const name = key instanceof Scalar ? String(key.value) : void 0;
|
|
88
|
-
if (name !== void 0 && key?.range) keys.set(name, { start: base + key.range[0], end: base + (pair.value?.range?.[1] ?? key.range[1]) });
|
|
89
|
-
}
|
|
90
|
-
let value;
|
|
91
|
-
try {
|
|
92
|
-
value = doc.toJS({ maxAliasCount: 0 });
|
|
93
|
-
} catch (error) {
|
|
94
|
-
ctx.error(rule, `YAML: ${error.message}`, "Anchors and aliases are not accepted; write each value out.", context);
|
|
95
|
-
return { value: {}, keys, ok: false };
|
|
96
|
-
}
|
|
97
|
-
const bad = nonJson(value);
|
|
98
|
-
if (bad) {
|
|
99
|
-
ctx.error(rule, `YAML value is not JSON-compatible (${bad}).`, "Quote special numbers such as .inf or .nan to keep them as strings.", context);
|
|
100
|
-
return { value: {}, keys, ok: false };
|
|
101
|
-
}
|
|
102
|
-
return { value, keys, ok };
|
|
103
|
-
}
|
|
104
|
-
function nonJson(value) {
|
|
105
|
-
if (typeof value === "number") return Number.isFinite(value) ? void 0 : "a number that is not finite";
|
|
106
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") return void 0;
|
|
107
|
-
if (Array.isArray(value)) return value.map(nonJson).find(Boolean);
|
|
108
|
-
if (isRecord(value)) return Object.values(value).map(nonJson).find(Boolean);
|
|
109
|
-
return `a ${typeof value}`;
|
|
110
|
-
}
|
|
111
|
-
function writeYaml(value) {
|
|
112
|
-
for (const blockQuote of [true, false]) {
|
|
113
|
-
const text = stringify(value, { indent: 2, lineWidth: 0, minContentWidth: 0, blockQuote, defaultStringType: "PLAIN", defaultKeyType: "PLAIN" });
|
|
114
|
-
const doc = parseDocument(text, { schema: "core", uniqueKeys: true, merge: false });
|
|
115
|
-
if (!doc.errors.length && same(doc.toJS({ maxAliasCount: 0 }), value)) return text.endsWith("\n") ? text : `${text}
|
|
116
|
-
`;
|
|
117
|
-
}
|
|
118
|
-
return void 0;
|
|
119
|
-
}
|
|
120
|
-
var DECIMAL = /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;
|
|
121
|
-
function scalarText(value) {
|
|
122
|
-
if (typeof value === "number") return DECIMAL.test(String(value)) ? String(value) : JSON.stringify(String(value));
|
|
123
|
-
const plain = value !== "" && value === value.trim() && !value.startsWith('"') && !/[\r\n]/.test(value) && !DECIMAL.test(value);
|
|
124
|
-
return plain ? value : JSON.stringify(value);
|
|
125
|
-
}
|
|
126
|
-
function readCsv(text) {
|
|
127
|
-
const rows = [];
|
|
128
|
-
let row = [];
|
|
129
|
-
let i = 0;
|
|
130
|
-
const n = text.length;
|
|
131
|
-
const endRecord = () => {
|
|
132
|
-
rows.push(row);
|
|
133
|
-
row = [];
|
|
134
|
-
};
|
|
135
|
-
while (i < n) {
|
|
136
|
-
while (text[i] === " " || text[i] === " ") i++;
|
|
137
|
-
if (text[i] === '"') {
|
|
138
|
-
let value = "";
|
|
139
|
-
i++;
|
|
140
|
-
for (; ; ) {
|
|
141
|
-
if (i >= n) return { rows, error: "A quoted field is not closed." };
|
|
142
|
-
if (text[i] === '"') {
|
|
143
|
-
if (text[i + 1] === '"') {
|
|
144
|
-
value += '"';
|
|
145
|
-
i += 2;
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
i++;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
value += text[i++];
|
|
152
|
-
}
|
|
153
|
-
while (text[i] === " " || text[i] === " ") i++;
|
|
154
|
-
if (i < n && text[i] !== "," && text[i] !== "\n" && text[i] !== "\r") return { rows, error: "Text follows a closing quote." };
|
|
155
|
-
row.push({ value, quoted: true });
|
|
156
|
-
} else {
|
|
157
|
-
let j = i;
|
|
158
|
-
while (j < n && text[j] !== "," && text[j] !== "\n" && text[j] !== "\r") j++;
|
|
159
|
-
row.push({ value: text.slice(i, j).trim(), quoted: false });
|
|
160
|
-
i = j;
|
|
161
|
-
}
|
|
162
|
-
if (text[i] === ",") {
|
|
163
|
-
i++;
|
|
164
|
-
if (i >= n || text[i] === "\n" || text[i] === "\r") row.push({ value: "", quoted: false });
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
if (text[i] === "\r" && text[i + 1] === "\n") i++;
|
|
168
|
-
i++;
|
|
169
|
-
endRecord();
|
|
170
|
-
}
|
|
171
|
-
if (row.length) endRecord();
|
|
172
|
-
return { rows };
|
|
173
|
-
}
|
|
174
|
-
var needsQuotes = (value) => /[",\r\n]/.test(value) || value !== value.trim() || value === "";
|
|
175
|
-
function csvField(cell, header = false) {
|
|
176
|
-
if (cell === null) return "";
|
|
177
|
-
if (typeof cell === "number") return String(cell);
|
|
178
|
-
if (typeof cell === "boolean") return String(cell);
|
|
179
|
-
const text = String(cell);
|
|
180
|
-
const ambiguous = !header && (DECIMAL.test(text) || /^(?:true|false)$/.test(text));
|
|
181
|
-
return needsQuotes(text) || ambiguous ? `"${text.replaceAll('"', '""')}"` : text;
|
|
182
|
-
}
|
|
183
|
-
var OPFMarkdownError = class extends Error {
|
|
184
|
-
code;
|
|
185
|
-
details;
|
|
186
|
-
constructor(code, message, details = {}) {
|
|
187
|
-
super(message);
|
|
188
|
-
this.name = "OPFMarkdownError";
|
|
189
|
-
this.code = code;
|
|
190
|
-
this.details = details;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
export { Ctx, DECIMAL, NOT_CHECKED, OPFMarkdownError, csvField, lineRange, readCsv, readYamlMapping, scalarText, splitLines, writeYaml };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export { convertFiles, deckFileFormat, exportFormatOf, openDeck, planConversion, readInput, saveDeck, writePlanned } from './chunk-34LIUOT7.js';
|
|
2
|
-
import './chunk-2ZQBMZTZ.js';
|
|
3
|
-
import './chunk-GLLR3AQ5.js';
|
|
4
|
-
import './chunk-UJSAR6GF.js';
|
|
5
|
-
import './chunk-PJSPHHRK.js';
|
|
6
|
-
import './chunk-TKQ2VFV5.js';
|
|
7
|
-
import './chunk-54OV2WQC.js';
|
|
8
|
-
import './chunk-FXNUM2PN.js';
|
|
9
|
-
import './chunk-WASENX2R.js';
|
|
10
|
-
import './chunk-7RY7QWWJ.js';
|
|
11
|
-
import './chunk-PB5X2VSV.js';
|
|
12
|
-
import './chunk-DEI2M2H6.js';
|
|
13
|
-
import './chunk-PXOXTJTN.js';
|
|
14
|
-
import './chunk-YVNFACTC.js';
|
|
15
|
-
import './chunk-NJWI6MPT.js';
|
|
16
|
-
import './chunk-XRMV2GMB.js';
|
|
17
|
-
import './chunk-EQ6S5SEZ.js';
|
|
18
|
-
import './chunk-F4HFDP6I.js';
|