@pretextbook/import 0.11.0 → 0.13.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.
@@ -7568,81 +7568,82 @@ function po(t, r) {
7568
7568
  return t.startsWith(n) && t.endsWith(".ptx");
7569
7569
  }
7570
7570
  export {
7571
- Ze as $,
7572
- va as A,
7573
- Ne as B,
7571
+ Ut as $,
7572
+ _o as A,
7573
+ va as B,
7574
7574
  qi as C,
7575
7575
  Nt as D,
7576
- Ta as E,
7577
- Ra as F,
7578
- Oa as G,
7579
- os as H,
7580
- Os as I,
7581
- bs as J,
7582
- ge as K,
7576
+ Ne as E,
7577
+ Ta as F,
7578
+ Ra as G,
7579
+ Oa as H,
7580
+ os as I,
7581
+ Os as J,
7582
+ bs as K,
7583
7583
  Dr as L,
7584
7584
  ui as M,
7585
- le as N,
7586
- Le as O,
7585
+ ge as N,
7586
+ le as O,
7587
7587
  Na as P,
7588
- qa as Q,
7589
- Je as R,
7590
- jt as S,
7591
- We as T,
7592
- gs as U,
7593
- Ir as V,
7594
- Ca as W,
7595
- vo as X,
7596
- Eo as Y,
7597
- Ot as Z,
7598
- Ut as _,
7588
+ Le as Q,
7589
+ qa as R,
7590
+ Je as S,
7591
+ jt as T,
7592
+ We as U,
7593
+ gs as V,
7594
+ Ir as W,
7595
+ Ca as X,
7596
+ vo as Y,
7597
+ Eo as Z,
7598
+ Ot as _,
7599
7599
  kr as a,
7600
- wo as a0,
7601
- yo as a1,
7602
- Xe as a2,
7603
- So as a3,
7604
- Er as a4,
7605
- ms as a5,
7606
- Yr as a6,
7607
- ti as a7,
7608
- en as a8,
7609
- Io as a9,
7610
- Fs as aa,
7611
- Ao as ab,
7612
- uo as ac,
7613
- Pr as ad,
7614
- ko as ae,
7615
- Vr as af,
7616
- To as ag,
7617
- Wt as ah,
7618
- Xr as ai,
7619
- ns as aj,
7620
- Qa as ak,
7621
- Xa as al,
7622
- pa as am,
7623
- Cr as b,
7624
- Me as c,
7600
+ Ze as a0,
7601
+ wo as a1,
7602
+ yo as a2,
7603
+ Xe as a3,
7604
+ So as a4,
7605
+ Er as a5,
7606
+ ms as a6,
7607
+ Yr as a7,
7608
+ ti as a8,
7609
+ en as a9,
7610
+ Io as aa,
7611
+ Fs as ab,
7612
+ Ao as ac,
7613
+ uo as ad,
7614
+ Pr as ae,
7615
+ ko as af,
7616
+ Vr as ag,
7617
+ To as ah,
7618
+ Wt as ai,
7619
+ Xr as aj,
7620
+ ns as ak,
7621
+ Qa as al,
7622
+ Xa as am,
7623
+ pa as an,
7624
+ Jt as b,
7625
+ Cr as c,
7625
7626
  zr as d,
7626
7627
  ze as e,
7627
- Jt as f,
7628
- no as g,
7629
- Ts as h,
7628
+ At as f,
7629
+ Me as g,
7630
+ no as h,
7630
7631
  es as i,
7631
- lo as j,
7632
- Sr as k,
7633
- li as l,
7634
- ha as m,
7635
- xo as n,
7636
- rs as o,
7632
+ Ts as j,
7633
+ lo as k,
7634
+ Sr as l,
7635
+ li as m,
7636
+ ha as n,
7637
+ xo as o,
7637
7638
  ue as p,
7638
- Ji as q,
7639
+ rs as q,
7639
7640
  ia as r,
7640
7641
  Mt as s,
7641
- $s as t,
7642
- Ls as u,
7643
- Nr as v,
7642
+ Ji as t,
7643
+ $s as u,
7644
+ Ls as v,
7644
7645
  $e as w,
7645
- Ur as x,
7646
- js as y,
7647
- _o as z
7646
+ Nr as x,
7647
+ Ur as y,
7648
+ js as z
7648
7649
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pretextbook/import",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Shared import helpers for converting LaTeX/Markdown/PreTeXt into PreTeXt for VS Code and web apps",
5
5
  "author": "Oscar Levin",
6
6
  "license": "MIT",
@@ -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
- };