@pretextbook/import 0.6.0 → 0.8.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/convert-worker.cjs +1 -0
- package/dist/convert-worker.js +29 -0
- package/dist/import-mode-BCGuSwkM.js +112 -0
- package/dist/import-mode-D1gOJw3N.cjs +3 -0
- package/dist/import.css +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +240 -156
- package/dist/lib/clean/latex-preamble.d.ts +21 -4
- package/dist/react/import-wizard.d.ts +22 -4
- package/dist/react/index.d.ts +2 -0
- package/dist/react/processing-panel.d.ts +6 -0
- package/dist/react.cjs +2 -2
- package/dist/react.js +498 -409
- package/dist/{import-mode-C0KIll3S.js → upload-BmErkg8I.js} +2382 -2265
- package/dist/upload-BtS22hIH.cjs +135 -0
- package/dist/worker/convert-worker.d.ts +1 -0
- package/dist/worker/protocol.d.ts +30 -0
- package/dist/worker/worker-engine.d.ts +52 -0
- package/package.json +7 -2
- package/dist/import-mode-Bu7Pi9k4.cjs +0 -135
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { C as
|
|
1
|
+
import { d as w, r as I, a as _, f as E, b as T, w as x, s as v, e as C, c as k, p as y, g as b, h as A } from "./upload-BmErkg8I.js";
|
|
2
|
+
import { C as q, L as V, i as Y, M as J, j as Q, P as Z, k as ee, l as te, m as se, n as ne, o as ae, q as oe, t as re, u as ie, v as ce, x as le, y as ue, z as pe, A as fe, B as me, D as de, E as ge, F as Pe, G as he, H as xe, I as be, J as Ee, K as Te, N as ve, O as Se, Q as Le, R as Fe, S as we, T as Ie, U as _e, V as Ce, W as ke, X as ye, Y as Ae, Z as Me, _ as je, $ as Re, a0 as $e, a1 as De, a2 as Ne, a3 as Oe, a4 as Be, a5 as We } from "./upload-BmErkg8I.js";
|
|
3
|
+
import { a as Ke, d as ze, b as Ue, c as Ge, f as He, e as qe, g as Ve, p as Ye } from "./import-mode-BCGuSwkM.js";
|
|
3
4
|
const M = {
|
|
4
5
|
png: "image/png",
|
|
5
6
|
jpg: "image/jpeg",
|
|
@@ -14,18 +15,18 @@ const M = {
|
|
|
14
15
|
webp: "image/webp",
|
|
15
16
|
ico: "image/vnd.microsoft.icon"
|
|
16
17
|
};
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
return M[
|
|
18
|
+
function j(e) {
|
|
19
|
+
const s = e.split(".").pop()?.toLowerCase() ?? "";
|
|
20
|
+
return M[s] ?? "application/octet-stream";
|
|
20
21
|
}
|
|
21
|
-
const
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
for (let
|
|
25
|
-
const
|
|
26
|
-
|
|
22
|
+
const P = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
23
|
+
function R(e) {
|
|
24
|
+
const s = e.length, o = [];
|
|
25
|
+
for (let t = 0; t < s; t += 3) {
|
|
26
|
+
const n = e[t], c = t + 1 < s, r = t + 2 < s, l = c ? e[t + 1] : 0, i = r ? e[t + 2] : 0;
|
|
27
|
+
o.push(P[n >> 2]), o.push(P[(n & 3) << 4 | l >> 4]), o.push(c ? P[(l & 15) << 2 | i >> 6] : "="), o.push(r ? P[i & 63] : "=");
|
|
27
28
|
}
|
|
28
|
-
return
|
|
29
|
+
return o.join("");
|
|
29
30
|
}
|
|
30
31
|
function $(e) {
|
|
31
32
|
return {
|
|
@@ -35,82 +36,82 @@ function $(e) {
|
|
|
35
36
|
short_description: e.fileName,
|
|
36
37
|
file: {
|
|
37
38
|
filename: e.fileName,
|
|
38
|
-
content_type:
|
|
39
|
-
data:
|
|
39
|
+
content_type: j(e.fileName),
|
|
40
|
+
data: R(e.data)
|
|
40
41
|
}
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
+
function K(e) {
|
|
44
45
|
return {
|
|
45
46
|
title: e.title,
|
|
46
47
|
docinfo: e.docinfo,
|
|
47
48
|
document_type: e.documentKind,
|
|
48
|
-
divisions_attributes: e.divisions.map((
|
|
49
|
-
ref:
|
|
50
|
-
source:
|
|
51
|
-
source_format:
|
|
52
|
-
is_root:
|
|
49
|
+
divisions_attributes: e.divisions.map((s) => ({
|
|
50
|
+
ref: s.xmlId,
|
|
51
|
+
source: s.content,
|
|
52
|
+
source_format: s.sourceFormat,
|
|
53
|
+
is_root: s.isRoot
|
|
53
54
|
})),
|
|
54
55
|
assets_attributes: e.assets.map($)
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
|
-
const
|
|
58
|
+
const h = {
|
|
58
59
|
mainSourcePath: "source/main.ptx",
|
|
59
60
|
publicationPath: "publication/publication.ptx",
|
|
60
61
|
projectFilePath: "project.ptx",
|
|
61
62
|
docinfoPath: "source/docinfo.ptx"
|
|
62
63
|
};
|
|
63
|
-
function
|
|
64
|
-
return
|
|
64
|
+
function S(e) {
|
|
65
|
+
return E(e, "pretext") ? e : `<pretext>
|
|
65
66
|
${e}
|
|
66
67
|
</pretext>`;
|
|
67
68
|
}
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
return e.forEach((
|
|
71
|
-
const
|
|
72
|
-
let
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
|
|
69
|
+
function L(e, s, o) {
|
|
70
|
+
const t = /* @__PURE__ */ new Map(), n = [], c = `${s}-`;
|
|
71
|
+
return e.forEach((r, l) => {
|
|
72
|
+
const i = r.attributes["xml:id"];
|
|
73
|
+
let u;
|
|
74
|
+
if (i) {
|
|
75
|
+
const m = k(i);
|
|
76
|
+
u = m.startsWith(c) ? m : `${c}${m}`;
|
|
76
77
|
} else
|
|
77
|
-
|
|
78
|
+
u = `${c}${y(l + 1, e.length)}`, o.push({
|
|
78
79
|
action: "anomaly",
|
|
79
80
|
severity: "info",
|
|
80
81
|
kind: "structure",
|
|
81
82
|
category: "missing_xml_id",
|
|
82
|
-
macro:
|
|
83
|
+
macro: r.name,
|
|
83
84
|
occurrences: 1,
|
|
84
|
-
message: `<${
|
|
85
|
+
message: `<${r.name}> at position ${l + 1} has no xml:id; using \`${u}\` as filename.`
|
|
85
86
|
});
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
span:
|
|
91
|
-
slug:
|
|
92
|
-
filename: `${
|
|
87
|
+
const p = t.get(u) ?? 0;
|
|
88
|
+
t.set(u, p + 1);
|
|
89
|
+
const a = p === 0 ? u : `${u}-${p + 1}`;
|
|
90
|
+
n.push({
|
|
91
|
+
span: r,
|
|
92
|
+
slug: a,
|
|
93
|
+
filename: `${a}.ptx`
|
|
93
94
|
});
|
|
94
|
-
}),
|
|
95
|
+
}), n;
|
|
95
96
|
}
|
|
96
|
-
function D(e,
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
97
|
+
function D(e, s, o, t) {
|
|
98
|
+
const n = T(e, "section");
|
|
99
|
+
if (n.length === 0)
|
|
99
100
|
return e;
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
return
|
|
103
|
-
start:
|
|
104
|
-
end:
|
|
105
|
-
replacement: `<xi:include href="${
|
|
101
|
+
const r = L(n, "sec", t).map((l) => {
|
|
102
|
+
const i = `source/${s}/${l.filename}`;
|
|
103
|
+
return o[i] = x(l.span.outer), {
|
|
104
|
+
start: l.span.start,
|
|
105
|
+
end: l.span.end,
|
|
106
|
+
replacement: `<xi:include href="${s}/${l.filename}"/>`
|
|
106
107
|
};
|
|
107
108
|
});
|
|
108
|
-
return
|
|
109
|
+
return v(e, r);
|
|
109
110
|
}
|
|
110
|
-
function
|
|
111
|
-
const
|
|
112
|
-
if (!
|
|
113
|
-
return
|
|
111
|
+
function N(e, s, o) {
|
|
112
|
+
const t = E(e, "book");
|
|
113
|
+
if (!t)
|
|
114
|
+
return o.push({
|
|
114
115
|
action: "anomaly",
|
|
115
116
|
severity: "warning",
|
|
116
117
|
kind: "structure",
|
|
@@ -118,117 +119,200 @@ function y(e, t, n) {
|
|
|
118
119
|
macro: "book",
|
|
119
120
|
occurrences: 1,
|
|
120
121
|
message: "Document was treated as a book but no <book> element found; emitting as a single file."
|
|
121
|
-
}),
|
|
122
|
-
const
|
|
123
|
-
let
|
|
124
|
-
if (
|
|
125
|
-
const
|
|
126
|
-
let
|
|
127
|
-
if (
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
122
|
+
}), F(e, s);
|
|
123
|
+
const n = {}, c = T(t.inner, "chapter");
|
|
124
|
+
let r = t.inner;
|
|
125
|
+
if (s.splitChapters && c.length > 0) {
|
|
126
|
+
const p = L(c, "ch", o).map((a) => {
|
|
127
|
+
let m = a.span.outer;
|
|
128
|
+
if (s.splitSections) {
|
|
129
|
+
const f = a.span.inner, d = D(
|
|
130
|
+
f,
|
|
131
|
+
a.slug,
|
|
132
|
+
n,
|
|
133
|
+
o
|
|
133
134
|
);
|
|
134
|
-
|
|
135
|
+
m = a.span.outer.slice(0, a.span.startTagEnd - a.span.start) + d + a.span.outer.slice(a.span.contentEnd - a.span.start);
|
|
135
136
|
}
|
|
136
|
-
const
|
|
137
|
-
return
|
|
138
|
-
start:
|
|
139
|
-
end:
|
|
140
|
-
replacement: `<xi:include href="${
|
|
137
|
+
const g = `source/${a.filename}`;
|
|
138
|
+
return n[g] = x(m), {
|
|
139
|
+
start: a.span.start,
|
|
140
|
+
end: a.span.end,
|
|
141
|
+
replacement: `<xi:include href="${a.filename}"/>`
|
|
141
142
|
};
|
|
142
143
|
});
|
|
143
|
-
|
|
144
|
+
r = v(t.inner, p);
|
|
144
145
|
}
|
|
145
|
-
const
|
|
146
|
-
return s
|
|
147
|
-
|
|
148
|
-
),
|
|
146
|
+
const l = e.slice(t.start, t.startTagEnd) + r + e.slice(t.contentEnd, t.end), i = e.slice(0, t.start) + l + e.slice(t.end);
|
|
147
|
+
return n[s.mainSourcePath] = x(
|
|
148
|
+
C(S(i.trim()))
|
|
149
|
+
), n;
|
|
150
|
+
}
|
|
151
|
+
function F(e, s, o) {
|
|
152
|
+
const t = {};
|
|
153
|
+
return t[s.mainSourcePath] = x(
|
|
154
|
+
S(e.trim())
|
|
155
|
+
), t;
|
|
156
|
+
}
|
|
157
|
+
function z(e, s = {}) {
|
|
158
|
+
const o = [], t = s.documentKind ?? w(e), n = {
|
|
159
|
+
splitChapters: s.splitChapters ?? t === "book",
|
|
160
|
+
splitSections: s.splitSections ?? !1,
|
|
161
|
+
mainSourcePath: s.mainSourcePath ?? h.mainSourcePath,
|
|
162
|
+
publicationPath: s.publicationPath ?? h.publicationPath,
|
|
163
|
+
projectFilePath: s.projectFilePath ?? h.projectFilePath,
|
|
164
|
+
docinfoPath: s.docinfoPath ?? h.docinfoPath
|
|
165
|
+
}, c = t === "book" ? N(e, n, o) : F(e, n);
|
|
166
|
+
return c[n.projectFilePath] = I({
|
|
167
|
+
mainSource: n.mainSourcePath,
|
|
168
|
+
publication: n.publicationPath
|
|
169
|
+
}), c[n.publicationPath] = _(), { files: c, documentKind: t, warnings: o };
|
|
149
170
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
), a;
|
|
171
|
+
class O extends Error {
|
|
172
|
+
constructor() {
|
|
173
|
+
super("Import cancelled."), this.name = "ConversionCancelledError";
|
|
174
|
+
}
|
|
155
175
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
176
|
+
let B = 0;
|
|
177
|
+
function W(e, s, o = {}) {
|
|
178
|
+
const t = `convert-${B++}`, n = e(), { assets: c = {}, ...r } = o;
|
|
179
|
+
let l;
|
|
180
|
+
const i = new Promise((p, a) => {
|
|
181
|
+
let m = !1;
|
|
182
|
+
const g = (f) => {
|
|
183
|
+
m || (m = !0, n.terminate(), f());
|
|
184
|
+
};
|
|
185
|
+
l = () => g(() => a(new O())), n.addEventListener("message", (f) => {
|
|
186
|
+
const d = f.data;
|
|
187
|
+
if (!(!d || d.requestId !== t)) {
|
|
188
|
+
if (d.type === "result") {
|
|
189
|
+
g(() => p(d.result));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
g(() => a(new Error(d.message)));
|
|
193
|
+
}
|
|
194
|
+
}), n.addEventListener("error", (f) => {
|
|
195
|
+
const d = typeof f == "object" && f && "message" in f ? String(f.message) : "The import worker failed to start.";
|
|
196
|
+
g(() => a(new Error(d)));
|
|
197
|
+
});
|
|
198
|
+
}), u = [
|
|
199
|
+
...new Set(
|
|
200
|
+
Object.values(c).map((p) => p.buffer).filter(
|
|
201
|
+
(p) => p instanceof ArrayBuffer
|
|
202
|
+
)
|
|
203
|
+
)
|
|
204
|
+
];
|
|
205
|
+
return n.postMessage(
|
|
206
|
+
{ type: "convert", requestId: t, files: s, assets: c, options: r },
|
|
207
|
+
u
|
|
208
|
+
), { result: i, cancel: () => l?.() };
|
|
209
|
+
}
|
|
210
|
+
function U(e) {
|
|
211
|
+
const {
|
|
212
|
+
createWorker: s,
|
|
213
|
+
id: o = "worker",
|
|
214
|
+
label: t = "Built-in converter",
|
|
215
|
+
description: n = "Create a new project starting with LaTeX, Markdown, or PreTeXt files.",
|
|
216
|
+
acceptExtensions: c
|
|
217
|
+
} = e;
|
|
218
|
+
let r = null;
|
|
219
|
+
const l = async (i, u) => {
|
|
220
|
+
r?.cancel(), r = W(s, i, u);
|
|
221
|
+
try {
|
|
222
|
+
return await r.result;
|
|
223
|
+
} finally {
|
|
224
|
+
r = null;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
return {
|
|
228
|
+
id: o,
|
|
229
|
+
label: t,
|
|
230
|
+
description: n,
|
|
231
|
+
acceptExtensions: c,
|
|
232
|
+
prepare: async (i) => {
|
|
233
|
+
const { files: u, assets: p } = await b(i);
|
|
234
|
+
return {
|
|
235
|
+
fileName: i.name,
|
|
236
|
+
files: u,
|
|
237
|
+
assets: p,
|
|
238
|
+
analysis: A(u)
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
convertPrepared: (i, u) => l(i.files, { ...u, assets: i.assets }),
|
|
242
|
+
convertFile: async (i, u) => {
|
|
243
|
+
const { files: p, assets: a } = await b(i);
|
|
244
|
+
return l(p, { ...u, assets: a });
|
|
245
|
+
},
|
|
246
|
+
cancel: () => {
|
|
247
|
+
r?.cancel(), r = null;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
169
250
|
}
|
|
170
251
|
export {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
252
|
+
q as CLEAN_RULES,
|
|
253
|
+
O as ConversionCancelledError,
|
|
254
|
+
V as LATEX_DIVISION_COMMANDS,
|
|
255
|
+
Y as LATEX_FORMAT_MARKERS,
|
|
256
|
+
J as MARKDOWN_FORMAT_MARKERS,
|
|
257
|
+
Q as MAX_SUGGESTED_SPLIT_LEVEL,
|
|
258
|
+
Z as PRETEXT_DIVISION_TAGS,
|
|
259
|
+
ee as PRETEXT_ROOT_TAGS,
|
|
260
|
+
A as analyzeImportSources,
|
|
261
|
+
te as applyLatexFixes,
|
|
262
|
+
Ke as assetsForImportMode,
|
|
263
|
+
se as attachLatexRoots,
|
|
264
|
+
ne as attachMarkdownRoots,
|
|
265
|
+
ae as buildDivisionPool,
|
|
266
|
+
oe as buildNativeDivisionPool,
|
|
267
|
+
z as buildPretextProjectFiles,
|
|
268
|
+
re as carryOverProjectFiles,
|
|
269
|
+
ie as cleanLatex,
|
|
270
|
+
ce as cleanLatexInChunks,
|
|
271
|
+
le as cleanLatexText,
|
|
272
|
+
ue as convertLatexToPretext,
|
|
273
|
+
pe as convertMarkdownToPretext,
|
|
274
|
+
fe as convertSourceToPretext,
|
|
275
|
+
U as createWorkerEngine,
|
|
276
|
+
me as defaultAttachLevel,
|
|
277
|
+
de as defaultManifestTarget,
|
|
278
|
+
w as detectDocumentKind,
|
|
279
|
+
ge as detectSourceFormat,
|
|
280
|
+
ze as diffHunks,
|
|
281
|
+
Ue as diffLines,
|
|
282
|
+
Ge as diffStats,
|
|
200
283
|
Pe as divisionChildRefs,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
284
|
+
he as divisionsAtLevel,
|
|
285
|
+
xe as expandPretextIncludes,
|
|
286
|
+
b as extractUpload,
|
|
287
|
+
He as fileChangesForImport,
|
|
288
|
+
be as filePrefixForDivision,
|
|
289
|
+
qe as filesForImportMode,
|
|
207
290
|
Ee as findLatexFixes,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
291
|
+
Te as findLatexHeaders,
|
|
292
|
+
ve as findProjectManifest,
|
|
293
|
+
Se as fixesToWarnings,
|
|
294
|
+
Ve as formatWarningLine,
|
|
295
|
+
Le as getConversionErrorMessage,
|
|
296
|
+
Fe as getLatexCleanDiagnostics,
|
|
297
|
+
we as handleImportUploadFile,
|
|
298
|
+
Ie as importProjectFromFiles,
|
|
299
|
+
_e as isDivisionTag,
|
|
300
|
+
Ce as latexDivisionHierarchy,
|
|
218
301
|
ke as latexFixesToCodeActions,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
302
|
+
ye as mergeChunksAtLevel,
|
|
303
|
+
Ae as normalizePretextSource,
|
|
304
|
+
Me as parseLatexDivisions,
|
|
305
|
+
je as parseProjectManifest,
|
|
306
|
+
Ye as projectForImportMode,
|
|
307
|
+
Re as relayoutImport,
|
|
308
|
+
I as renderProjectPtx,
|
|
309
|
+
$e as renderProjectPtxFromManifest,
|
|
310
|
+
_ as renderPublicationPtx,
|
|
311
|
+
De as resolveImportSplitLevel,
|
|
312
|
+
Ne as resolveSplitLevel,
|
|
313
|
+
W as runConversionInWorker,
|
|
314
|
+
Oe as sanitizeRef,
|
|
315
|
+
Be as serializeProjectToFiles,
|
|
316
|
+
K as serializeProjectToPlusPayload,
|
|
233
317
|
We as suggestSplitLevel
|
|
234
318
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CleaningWarning } from './warnings';
|
|
1
2
|
export interface PreambleInfo {
|
|
2
3
|
/** Argument of \documentclass{...}, e.g. "book" or "article". Defaults to "article". */
|
|
3
4
|
documentClass: string;
|
|
@@ -5,7 +6,7 @@ export interface PreambleInfo {
|
|
|
5
6
|
title: string;
|
|
6
7
|
/** Inner content of \author{...}, or empty string. */
|
|
7
8
|
author: string;
|
|
8
|
-
/** Collected \newcommand / \renewcommand / \DeclareMathOperator definitions. */
|
|
9
|
+
/** Collected \newcommand / \renewcommand / \DeclareMathOperator / \def definitions. */
|
|
9
10
|
macros: string;
|
|
10
11
|
}
|
|
11
12
|
export declare function splitLatexAtDocument(source: string): {
|
|
@@ -18,10 +19,26 @@ export declare function splitLatexAtDocument(source: string): {
|
|
|
18
19
|
* Returns the inner content (without surrounding braces), or "".
|
|
19
20
|
*/
|
|
20
21
|
export declare function extractLatexField(source: string, cmdName: string): string;
|
|
22
|
+
export interface ExtractMacrosResult {
|
|
23
|
+
/** Collected macro definitions, joined with newlines. */
|
|
24
|
+
macros: string;
|
|
25
|
+
/** One warning summarizing any `\def` blocks found (empty if none). */
|
|
26
|
+
warnings: CleaningWarning[];
|
|
27
|
+
}
|
|
21
28
|
/**
|
|
22
29
|
* Collects LaTeX macro definition lines from `preamble`, including multi-line
|
|
23
30
|
* definitions (tracks brace depth to know when a definition is complete).
|
|
24
|
-
*
|
|
31
|
+
*
|
|
32
|
+
* `\def` is kept verbatim alongside `\newcommand` et al. — rewriting its
|
|
33
|
+
* syntax isn't safe in general (delimited parameter text, `\global`/`\edef`
|
|
34
|
+
* semantics, and no way to tell here whether it's redefining an existing
|
|
35
|
+
* command, which would make a mechanical `\newcommand` rewrite fail to
|
|
36
|
+
* build) — but it's reported as a warning, since PreTeXt tooling downstream
|
|
37
|
+
* (e.g. WeBWorK/PG macro extraction) only recognises `\newcommand`.
|
|
25
38
|
*/
|
|
26
|
-
export declare function extractMacros(preamble: string):
|
|
27
|
-
export
|
|
39
|
+
export declare function extractMacros(preamble: string): ExtractMacrosResult;
|
|
40
|
+
export interface ExtractPreambleInfoResult {
|
|
41
|
+
info: PreambleInfo;
|
|
42
|
+
warnings: CleaningWarning[];
|
|
43
|
+
}
|
|
44
|
+
export declare function extractPreambleInfo(preamble: string): ExtractPreambleInfoResult;
|
|
@@ -39,12 +39,30 @@ export interface ImportEngine {
|
|
|
39
39
|
convertFile: (file: File, options: ImportProjectOptions) => Promise<ImportedProjectResult>;
|
|
40
40
|
/** Unpack and survey an upload without converting it. */
|
|
41
41
|
prepare?: (file: File) => Promise<PreparedUpload>;
|
|
42
|
-
/**
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Convert an already-prepared upload with the user's source choices.
|
|
44
|
+
*
|
|
45
|
+
* May return synchronously (the built-in engine does) or a promise (the
|
|
46
|
+
* worker engine does). The wizard always awaits, which is what lets the
|
|
47
|
+
* processing screen paint and its timer tick before the work starts.
|
|
48
|
+
*/
|
|
49
|
+
convertPrepared?: (prepared: PreparedUpload, options: ImportProjectOptions) => ImportedProjectResult | Promise<ImportedProjectResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Stop an in-flight conversion. Engines that run the pipeline in-process
|
|
52
|
+
* cannot honour this — the pipeline has no yield points — so only the worker
|
|
53
|
+
* engine supplies it, and the processing screen shows Cancel only when it is
|
|
54
|
+
* present.
|
|
55
|
+
*/
|
|
56
|
+
cancel?: () => void;
|
|
44
57
|
}
|
|
45
58
|
export interface ImportWizardProps {
|
|
46
|
-
/**
|
|
47
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Called when the user confirms the import. May return a promise — writing
|
|
61
|
+
* the file map out is the host's slow step (VS Code writes to disk,
|
|
62
|
+
* pretext-plus uploads), so the wizard awaits it and holds the button in a
|
|
63
|
+
* pending state until it settles rather than appearing to do nothing.
|
|
64
|
+
*/
|
|
65
|
+
onConfirm: (result: ImportedProjectSuccess, mode: ImportMode) => void | Promise<void>;
|
|
48
66
|
/** Called when the user cancels at the review step. */
|
|
49
67
|
onCancel?: () => void;
|
|
50
68
|
/** Pass fixed options to skip the document-kind / split-sections controls. */
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { ImportWizard } from './import-wizard';
|
|
2
2
|
export type { ImportWizardProps, ImportMode, ImportEngine, PreparedUpload, } from './import-wizard';
|
|
3
|
+
export { ProcessingPanel } from './processing-panel';
|
|
4
|
+
export type { ProcessingPanelProps } from './processing-panel';
|
|
3
5
|
export { ImportSourceForm } from './import-source-form';
|
|
4
6
|
export { ImportUploadPanel } from './import-upload-panel';
|
|
5
7
|
export type { ImportSourceFormProps, ImportSourceFormLabels, } from './import-source-form';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface ProcessingPanelProps {
|
|
2
|
+
message?: string;
|
|
3
|
+
/** Omitted when the work cannot be interrupted (e.g. a host write). */
|
|
4
|
+
onCancel?: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function ProcessingPanel({ message, onCancel, }: ProcessingPanelProps): import("react").JSX.Element;
|