@pretextbook/import 0.11.0 → 0.12.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/engine-routing-08ynicii.cjs +3 -0
- package/dist/engine-routing-Bu0zM4aw.js +179 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +131 -122
- package/dist/lib/engine-routing.d.ts +65 -0
- package/dist/react/import-wizard.d.ts +9 -3
- package/dist/react.cjs +2 -2
- package/dist/react.js +502 -495
- package/package.json +1 -1
- package/dist/import-mode-CV7gCDzF.cjs +0 -3
- package/dist/import-mode-DQ8g5P8P.js +0 -122
package/package.json
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const p=require("./upload-BnRj1gU1.cjs");function h(e,t){const n=e.length===0?[]:e.split(`
|
|
2
|
-
`),i=t.length===0?[]:t.split(`
|
|
3
|
-
`);if(n.length+i.length>M)return[...n.map((s,f)=>({op:"remove",text:s,beforeLine:f+1})),...i.map((s,f)=>({op:"add",text:s,afterLine:f+1}))];const c=Array.from({length:n.length+1},()=>new Array(i.length+1).fill(0));for(let s=n.length-1;s>=0;s--)for(let f=i.length-1;f>=0;f--)c[s][f]=n[s]===i[f]?c[s+1][f+1]+1:Math.max(c[s+1][f],c[s][f+1]);const a=[];let o=0,r=0;for(;o<n.length&&r<i.length;)n[o]===i[r]?(a.push({op:"keep",text:n[o],beforeLine:o+1,afterLine:r+1}),o++,r++):c[o+1][r]>=c[o][r+1]?(a.push({op:"remove",text:n[o],beforeLine:o+1}),o++):(a.push({op:"add",text:i[r],afterLine:r+1}),r++);for(;o<n.length;)a.push({op:"remove",text:n[o],beforeLine:++o});for(;r<i.length;)a.push({op:"add",text:i[r],afterLine:++r});return a}const M=2e4;function u(e){let t=0,n=0;for(const i of e)i.op==="add"?t++:i.op==="remove"&&n++;return{added:t,removed:n}}function d(e,t=2){const n=e.map((o,r)=>o.op==="keep"?-1:r).filter(o=>o>=0);if(n.length===0)return[];const i=[];let c=Math.max(0,n[0]-t),a=Math.min(e.length-1,n[0]+t);for(const o of n.slice(1)){if(o-t<=a+1){a=Math.min(e.length-1,o+t);continue}i.push({lines:e.slice(c,a+1)}),c=Math.max(0,o-t),a=Math.min(e.length-1,o+t)}return i.push({lines:e.slice(c,a+1)}),i}function L(e,t=e.splitLevel){if(e.cleanChunks.length===0)return[];const n=p.mergeChunksAtLevel(e.cleanChunks,t),i=g(n),{pathByRef:c}=p.serializeProjectToFiles(e.project,{mainSourcePath:e.projectLayout.mainSourcePath,publicationPath:e.projectLayout.publicationPath,projectFilePath:e.projectLayout.projectFilePath,includeScaffold:!e.projectLayout.preserved}),a=[];for(const o of e.project.divisions){const r=c[o.xmlId];if(!r)continue;const s=o.isRoot?n.find(l=>l.kind==="preamble"||l.kind==="lead"):i.get(o.title);if(!s)continue;const f=h(s.before,s.after);a.push({path:r,title:o.title,before:s.before,after:s.after,stats:u(f),hunks:d(f),fixCount:s.fixes.length})}return a.sort((o,r)=>o.path.localeCompare(r.path))}function g(e){const t=new Map;for(const i of e)i.kind!=="division"||!i.title||t.set(i.title,t.has(i.title)?null:i);const n=new Map;for(const[i,c]of t)c&&n.set(i,c);return n}const m="converted";function v(e){return e.nativeOutputFiles!==void 0}function F(e,t=m){return t==="native"&&!v(e)?"converted":t}function I(e,t){return t==="native"?e.nativeProject??e.project:e.project}function j(e,t){return t==="converted"?e.outputFiles:e.nativeOutputFiles??e.files}function k(e,t){return t==="converted"?e.outputAssets:e.assets}function b(e){const t=e.action==="replace"||e.action==="rewrite"?`replaced with \`${e.replacement}\``:e.message??e.action,n=e.occurrences>1?` (x${e.occurrences})`:"";return`[${e.severity}] ${e.macro}: ${t}${n}`}exports.DEFAULT_IMPORT_MODE=m;exports.assetsForImportMode=k;exports.diffHunks=d;exports.diffLines=h;exports.diffStats=u;exports.fileChangesForImport=L;exports.filesForImportMode=j;exports.formatWarningLine=b;exports.hasNativeImportMode=v;exports.projectForImportMode=I;exports.resolveImportMode=F;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { a1 as p, ak as h } from "./upload-H_OCZBBn.js";
|
|
2
|
-
function u(e, t) {
|
|
3
|
-
const o = e.length === 0 ? [] : e.split(`
|
|
4
|
-
`), i = t.length === 0 ? [] : t.split(`
|
|
5
|
-
`);
|
|
6
|
-
if (o.length + i.length > d)
|
|
7
|
-
return [
|
|
8
|
-
...o.map(
|
|
9
|
-
(s, l) => ({ op: "remove", text: s, beforeLine: l + 1 })
|
|
10
|
-
),
|
|
11
|
-
...i.map((s, l) => ({ op: "add", text: s, afterLine: l + 1 }))
|
|
12
|
-
];
|
|
13
|
-
const a = Array.from(
|
|
14
|
-
{ length: o.length + 1 },
|
|
15
|
-
() => new Array(i.length + 1).fill(0)
|
|
16
|
-
);
|
|
17
|
-
for (let s = o.length - 1; s >= 0; s--)
|
|
18
|
-
for (let l = i.length - 1; l >= 0; l--)
|
|
19
|
-
a[s][l] = o[s] === i[l] ? a[s + 1][l + 1] + 1 : Math.max(a[s + 1][l], a[s][l + 1]);
|
|
20
|
-
const c = [];
|
|
21
|
-
let n = 0, r = 0;
|
|
22
|
-
for (; n < o.length && r < i.length; )
|
|
23
|
-
o[n] === i[r] ? (c.push({
|
|
24
|
-
op: "keep",
|
|
25
|
-
text: o[n],
|
|
26
|
-
beforeLine: n + 1,
|
|
27
|
-
afterLine: r + 1
|
|
28
|
-
}), n++, r++) : a[n + 1][r] >= a[n][r + 1] ? (c.push({ op: "remove", text: o[n], beforeLine: n + 1 }), n++) : (c.push({ op: "add", text: i[r], afterLine: r + 1 }), r++);
|
|
29
|
-
for (; n < o.length; )
|
|
30
|
-
c.push({ op: "remove", text: o[n], beforeLine: ++n });
|
|
31
|
-
for (; r < i.length; ) c.push({ op: "add", text: i[r], afterLine: ++r });
|
|
32
|
-
return c;
|
|
33
|
-
}
|
|
34
|
-
const d = 2e4;
|
|
35
|
-
function m(e) {
|
|
36
|
-
let t = 0, o = 0;
|
|
37
|
-
for (const i of e)
|
|
38
|
-
i.op === "add" ? t++ : i.op === "remove" && o++;
|
|
39
|
-
return { added: t, removed: o };
|
|
40
|
-
}
|
|
41
|
-
function v(e, t = 2) {
|
|
42
|
-
const o = e.map((n, r) => n.op === "keep" ? -1 : r).filter((n) => n >= 0);
|
|
43
|
-
if (o.length === 0) return [];
|
|
44
|
-
const i = [];
|
|
45
|
-
let a = Math.max(0, o[0] - t), c = Math.min(e.length - 1, o[0] + t);
|
|
46
|
-
for (const n of o.slice(1)) {
|
|
47
|
-
if (n - t <= c + 1) {
|
|
48
|
-
c = Math.min(e.length - 1, n + t);
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
i.push({ lines: e.slice(a, c + 1) }), a = Math.max(0, n - t), c = Math.min(e.length - 1, n + t);
|
|
52
|
-
}
|
|
53
|
-
return i.push({ lines: e.slice(a, c + 1) }), i;
|
|
54
|
-
}
|
|
55
|
-
function k(e, t = e.splitLevel) {
|
|
56
|
-
if (e.cleanChunks.length === 0) return [];
|
|
57
|
-
const o = p(e.cleanChunks, t), i = g(o), { pathByRef: a } = h(e.project, {
|
|
58
|
-
mainSourcePath: e.projectLayout.mainSourcePath,
|
|
59
|
-
publicationPath: e.projectLayout.publicationPath,
|
|
60
|
-
projectFilePath: e.projectLayout.projectFilePath,
|
|
61
|
-
includeScaffold: !e.projectLayout.preserved
|
|
62
|
-
}), c = [];
|
|
63
|
-
for (const n of e.project.divisions) {
|
|
64
|
-
const r = a[n.xmlId];
|
|
65
|
-
if (!r) continue;
|
|
66
|
-
const s = n.isRoot ? o.find((f) => f.kind === "preamble" || f.kind === "lead") : i.get(n.title);
|
|
67
|
-
if (!s) continue;
|
|
68
|
-
const l = u(s.before, s.after);
|
|
69
|
-
c.push({
|
|
70
|
-
path: r,
|
|
71
|
-
title: n.title,
|
|
72
|
-
before: s.before,
|
|
73
|
-
after: s.after,
|
|
74
|
-
stats: m(l),
|
|
75
|
-
hunks: v(l),
|
|
76
|
-
fixCount: s.fixes.length
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return c.sort((n, r) => n.path.localeCompare(r.path));
|
|
80
|
-
}
|
|
81
|
-
function g(e) {
|
|
82
|
-
const t = /* @__PURE__ */ new Map();
|
|
83
|
-
for (const i of e)
|
|
84
|
-
i.kind !== "division" || !i.title || t.set(i.title, t.has(i.title) ? null : i);
|
|
85
|
-
const o = /* @__PURE__ */ new Map();
|
|
86
|
-
for (const [i, a] of t)
|
|
87
|
-
a && o.set(i, a);
|
|
88
|
-
return o;
|
|
89
|
-
}
|
|
90
|
-
const L = "converted";
|
|
91
|
-
function M(e) {
|
|
92
|
-
return e.nativeOutputFiles !== void 0;
|
|
93
|
-
}
|
|
94
|
-
function F(e, t = L) {
|
|
95
|
-
return t === "native" && !M(e) ? "converted" : t;
|
|
96
|
-
}
|
|
97
|
-
function b(e, t) {
|
|
98
|
-
return t === "native" ? e.nativeProject ?? e.project : e.project;
|
|
99
|
-
}
|
|
100
|
-
function x(e, t) {
|
|
101
|
-
return t === "converted" ? e.outputFiles : e.nativeOutputFiles ?? e.files;
|
|
102
|
-
}
|
|
103
|
-
function I(e, t) {
|
|
104
|
-
return t === "converted" ? e.outputAssets : e.assets;
|
|
105
|
-
}
|
|
106
|
-
function y(e) {
|
|
107
|
-
const t = e.action === "replace" || e.action === "rewrite" ? `replaced with \`${e.replacement}\`` : e.message ?? e.action, o = e.occurrences > 1 ? ` (x${e.occurrences})` : "";
|
|
108
|
-
return `[${e.severity}] ${e.macro}: ${t}${o}`;
|
|
109
|
-
}
|
|
110
|
-
export {
|
|
111
|
-
L as D,
|
|
112
|
-
I as a,
|
|
113
|
-
u as b,
|
|
114
|
-
m as c,
|
|
115
|
-
v as d,
|
|
116
|
-
x as e,
|
|
117
|
-
k as f,
|
|
118
|
-
y as g,
|
|
119
|
-
M as h,
|
|
120
|
-
b as p,
|
|
121
|
-
F as r
|
|
122
|
-
};
|