@pretextbook/import 0.5.0 → 0.7.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.
@@ -0,0 +1 @@
1
+ "use strict";const n=require("./upload-CGxfSSDN.cjs");function f(e){if(e.type!=="result"||"pretextError"in e.result)return[];const t=e.result,o=new Set,s=r=>{const c=r?.buffer;c instanceof ArrayBuffer&&o.add(c)};return Object.values(t.assets??{}).forEach(s),Object.values(t.outputAssets??{}).forEach(s),t.project?.assets?.forEach(r=>s(r.data)),t.nativeProject?.assets?.forEach(r=>s(r.data)),[...o]}function u(e){self.postMessage(e,f(e))}self.onmessage=e=>{const t=e.data;if(t?.type!=="convert")return;const{requestId:o,files:s,assets:r,options:c}=t;try{const a=n.importProjectFromFiles(s,{...c,assets:r});u({type:"result",requestId:o,result:a})}catch(a){u({type:"error",requestId:o,message:a instanceof Error?a.message:"An unexpected error occurred."})}};
@@ -0,0 +1,29 @@
1
+ import { T as n } from "./upload-BBHV4rXJ.js";
2
+ function u(e) {
3
+ if (e.type !== "result" || "pretextError" in e.result)
4
+ return [];
5
+ const t = e.result, o = /* @__PURE__ */ new Set(), s = (r) => {
6
+ const a = r?.buffer;
7
+ a instanceof ArrayBuffer && o.add(a);
8
+ };
9
+ return Object.values(t.assets ?? {}).forEach(s), Object.values(t.outputAssets ?? {}).forEach(s), t.project?.assets?.forEach((r) => s(r.data)), t.nativeProject?.assets?.forEach((r) => s(r.data)), [...o];
10
+ }
11
+ function f(e) {
12
+ self.postMessage(e, u(e));
13
+ }
14
+ self.onmessage = (e) => {
15
+ const t = e.data;
16
+ if (t?.type !== "convert")
17
+ return;
18
+ const { requestId: o, files: s, assets: r, options: a } = t;
19
+ try {
20
+ const c = n(s, { ...a, assets: r });
21
+ f({ type: "result", requestId: o, result: c });
22
+ } catch (c) {
23
+ f({
24
+ type: "error",
25
+ requestId: o,
26
+ message: c instanceof Error ? c.message : "An unexpected error occurred."
27
+ });
28
+ }
29
+ };
@@ -0,0 +1,112 @@
1
+ import { X as p, a4 as h } from "./upload-BBHV4rXJ.js";
2
+ function u(e, i) {
3
+ const n = e.length === 0 ? [] : e.split(`
4
+ `), o = i.length === 0 ? [] : i.split(`
5
+ `);
6
+ if (n.length + o.length > d)
7
+ return [
8
+ ...n.map(
9
+ (s, l) => ({ op: "remove", text: s, beforeLine: l + 1 })
10
+ ),
11
+ ...o.map((s, l) => ({ op: "add", text: s, afterLine: l + 1 }))
12
+ ];
13
+ const a = Array.from(
14
+ { length: n.length + 1 },
15
+ () => new Array(o.length + 1).fill(0)
16
+ );
17
+ for (let s = n.length - 1; s >= 0; s--)
18
+ for (let l = o.length - 1; l >= 0; l--)
19
+ a[s][l] = n[s] === o[l] ? a[s + 1][l + 1] + 1 : Math.max(a[s + 1][l], a[s][l + 1]);
20
+ const c = [];
21
+ let t = 0, r = 0;
22
+ for (; t < n.length && r < o.length; )
23
+ n[t] === o[r] ? (c.push({
24
+ op: "keep",
25
+ text: n[t],
26
+ beforeLine: t + 1,
27
+ afterLine: r + 1
28
+ }), t++, r++) : a[t + 1][r] >= a[t][r + 1] ? (c.push({ op: "remove", text: n[t], beforeLine: t + 1 }), t++) : (c.push({ op: "add", text: o[r], afterLine: r + 1 }), r++);
29
+ for (; t < n.length; )
30
+ c.push({ op: "remove", text: n[t], beforeLine: ++t });
31
+ for (; r < o.length; ) c.push({ op: "add", text: o[r], afterLine: ++r });
32
+ return c;
33
+ }
34
+ const d = 2e4;
35
+ function m(e) {
36
+ let i = 0, n = 0;
37
+ for (const o of e)
38
+ o.op === "add" ? i++ : o.op === "remove" && n++;
39
+ return { added: i, removed: n };
40
+ }
41
+ function g(e, i = 2) {
42
+ const n = e.map((t, r) => t.op === "keep" ? -1 : r).filter((t) => t >= 0);
43
+ if (n.length === 0) return [];
44
+ const o = [];
45
+ let a = Math.max(0, n[0] - i), c = Math.min(e.length - 1, n[0] + i);
46
+ for (const t of n.slice(1)) {
47
+ if (t - i <= c + 1) {
48
+ c = Math.min(e.length - 1, t + i);
49
+ continue;
50
+ }
51
+ o.push({ lines: e.slice(a, c + 1) }), a = Math.max(0, t - i), c = Math.min(e.length - 1, t + i);
52
+ }
53
+ return o.push({ lines: e.slice(a, c + 1) }), o;
54
+ }
55
+ function j(e, i = e.splitLevel) {
56
+ if (e.cleanChunks.length === 0) return [];
57
+ const n = p(e.cleanChunks, i), o = v(n), { 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 t of e.project.divisions) {
64
+ const r = a[t.xmlId];
65
+ if (!r) continue;
66
+ const s = t.isRoot ? n.find((f) => f.kind === "preamble" || f.kind === "lead") : o.get(t.title);
67
+ if (!s) continue;
68
+ const l = u(s.before, s.after);
69
+ c.push({
70
+ path: r,
71
+ title: t.title,
72
+ before: s.before,
73
+ after: s.after,
74
+ stats: m(l),
75
+ hunks: g(l),
76
+ fixCount: s.fixes.length
77
+ });
78
+ }
79
+ return c.sort((t, r) => t.path.localeCompare(r.path));
80
+ }
81
+ function v(e) {
82
+ const i = /* @__PURE__ */ new Map();
83
+ for (const o of e)
84
+ o.kind !== "division" || !o.title || i.set(o.title, i.has(o.title) ? null : o);
85
+ const n = /* @__PURE__ */ new Map();
86
+ for (const [o, a] of i)
87
+ a && n.set(o, a);
88
+ return n;
89
+ }
90
+ function k(e, i) {
91
+ return i === "native" ? e.nativeProject ?? e.project : e.project;
92
+ }
93
+ function b(e, i) {
94
+ return i === "converted" ? e.outputFiles : e.nativeOutputFiles ?? e.files;
95
+ }
96
+ function M(e, i) {
97
+ return i === "converted" ? e.outputAssets : e.assets;
98
+ }
99
+ function F(e) {
100
+ const i = e.action === "replace" || e.action === "rewrite" ? `replaced with \`${e.replacement}\`` : e.message ?? e.action, n = e.occurrences > 1 ? ` (x${e.occurrences})` : "";
101
+ return `[${e.severity}] ${e.macro}: ${i}${n}`;
102
+ }
103
+ export {
104
+ M as a,
105
+ u as b,
106
+ m as c,
107
+ g as d,
108
+ b as e,
109
+ j as f,
110
+ F as g,
111
+ k as p
112
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";const p=require("./upload-CGxfSSDN.cjs");function h(e,i){const o=e.length===0?[]:e.split(`
2
+ `),n=i.length===0?[]:i.split(`
3
+ `);if(o.length+n.length>m)return[...o.map((s,f)=>({op:"remove",text:s,beforeLine:f+1})),...n.map((s,f)=>({op:"add",text:s,afterLine:f+1}))];const c=Array.from({length:o.length+1},()=>new Array(n.length+1).fill(0));for(let s=o.length-1;s>=0;s--)for(let f=n.length-1;f>=0;f--)c[s][f]=o[s]===n[f]?c[s+1][f+1]+1:Math.max(c[s+1][f],c[s][f+1]);const a=[];let t=0,r=0;for(;t<o.length&&r<n.length;)o[t]===n[r]?(a.push({op:"keep",text:o[t],beforeLine:t+1,afterLine:r+1}),t++,r++):c[t+1][r]>=c[t][r+1]?(a.push({op:"remove",text:o[t],beforeLine:t+1}),t++):(a.push({op:"add",text:n[r],afterLine:r+1}),r++);for(;t<o.length;)a.push({op:"remove",text:o[t],beforeLine:++t});for(;r<n.length;)a.push({op:"add",text:n[r],afterLine:++r});return a}const m=2e4;function u(e){let i=0,o=0;for(const n of e)n.op==="add"?i++:n.op==="remove"&&o++;return{added:i,removed:o}}function d(e,i=2){const o=e.map((t,r)=>t.op==="keep"?-1:r).filter(t=>t>=0);if(o.length===0)return[];const n=[];let c=Math.max(0,o[0]-i),a=Math.min(e.length-1,o[0]+i);for(const t of o.slice(1)){if(t-i<=a+1){a=Math.min(e.length-1,t+i);continue}n.push({lines:e.slice(c,a+1)}),c=Math.max(0,t-i),a=Math.min(e.length-1,t+i)}return n.push({lines:e.slice(c,a+1)}),n}function g(e,i=e.splitLevel){if(e.cleanChunks.length===0)return[];const o=p.mergeChunksAtLevel(e.cleanChunks,i),n=L(o),{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 t of e.project.divisions){const r=c[t.xmlId];if(!r)continue;const s=t.isRoot?o.find(l=>l.kind==="preamble"||l.kind==="lead"):n.get(t.title);if(!s)continue;const f=h(s.before,s.after);a.push({path:r,title:t.title,before:s.before,after:s.after,stats:u(f),hunks:d(f),fixCount:s.fixes.length})}return a.sort((t,r)=>t.path.localeCompare(r.path))}function L(e){const i=new Map;for(const n of e)n.kind!=="division"||!n.title||i.set(n.title,i.has(n.title)?null:n);const o=new Map;for(const[n,c]of i)c&&o.set(n,c);return o}function v(e,i){return i==="native"?e.nativeProject??e.project:e.project}function j(e,i){return i==="converted"?e.outputFiles:e.nativeOutputFiles??e.files}function k(e,i){return i==="converted"?e.outputAssets:e.assets}function F(e){const i=e.action==="replace"||e.action==="rewrite"?`replaced with \`${e.replacement}\``:e.message??e.action,o=e.occurrences>1?` (x${e.occurrences})`:"";return`[${e.severity}] ${e.macro}: ${i}${o}`}exports.assetsForImportMode=k;exports.diffHunks=d;exports.diffLines=h;exports.diffStats=u;exports.fileChangesForImport=g;exports.filesForImportMode=j;exports.formatWarningLine=F;exports.projectForImportMode=v;
package/dist/import.css CHANGED
@@ -1 +1 @@
1
- @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-outline-style:solid}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-200:oklch(88.5% .062 18.334);--color-red-800:oklch(44.4% .177 26.899);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-green-700:oklch(52.7% .154 150.069);--color-blue-50:oklch(97% .014 254.604);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-blue-800:oklch(42.4% .199 265.638);--color-blue-900:oklch(37.9% .146 265.522);--color-slate-50:oklch(98.4% .003 247.858);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-200:oklch(92.9% .013 255.508);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-400:oklch(70.4% .04 256.788);--color-slate-500:oklch(55.4% .046 257.417);--color-slate-600:oklch(44.6% .043 257.281);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-800:oklch(27.9% .041 260.031);--color-slate-900:oklch(20.8% .042 265.755);--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--font-weight-medium:500;--font-weight-semibold:600;--leading-relaxed:1.625;--radius-lg:.5rem;--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.collapse{visibility:collapse}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.m-0{margin:0}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.h-8{height:calc(var(--spacing) * 8)}.max-h-72{max-height:calc(var(--spacing) * 72)}.w-8{width:calc(var(--spacing) * 8)}.w-full{width:100%}.flex-1{flex:1}.shrink-0{flex-shrink:0}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-6{column-gap:calc(var(--spacing) * 6)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-amber-200{border-color:var(--color-amber-200)}.border-blue-200{border-color:var(--color-blue-200)}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-700{border-color:var(--color-blue-700)}.border-red-200{border-color:var(--color-red-200)}.border-slate-200{border-color:var(--color-slate-200)}.border-slate-300{border-color:var(--color-slate-300)}.border-t-transparent{border-top-color:#0000}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-100{background-color:var(--color-amber-100)}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-700{background-color:var(--color-blue-700)}.bg-red-50{background-color:var(--color-red-50)}.bg-slate-50{background-color:var(--color-slate-50)}.bg-slate-100{background-color:var(--color-slate-100)}.bg-white{background-color:var(--color-white)}.p-4{padding:calc(var(--spacing) * 4)}.p-10{padding:calc(var(--spacing) * 10)}.px-1{padding-inline:var(--spacing)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-16{padding-block:calc(var(--spacing) * 16)}.pt-1{padding-top:var(--spacing)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-amber-700{color:var(--color-amber-700)}.text-amber-800{color:var(--color-amber-800)}.text-blue-800{color:var(--color-blue-800)}.text-blue-900{color:var(--color-blue-900)}.text-green-700{color:var(--color-green-700)}.text-red-800{color:var(--color-red-800)}.text-slate-400{color:var(--color-slate-400)}.text-slate-500{color:var(--color-slate-500)}.text-slate-600{color:var(--color-slate-600)}.text-slate-700{color:var(--color-slate-700)}.text-slate-800{color:var(--color-slate-800)}.text-slate-900{color:var(--color-slate-900)}.text-white{color:var(--color-white)}.capitalize{text-transform:capitalize}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:border-slate-400:hover{border-color:var(--color-slate-400)}.hover\:bg-blue-600:hover{background-color:var(--color-blue-600)}.hover\:bg-slate-50:hover{background-color:var(--color-slate-50)}.hover\:bg-slate-200:hover{background-color:var(--color-slate-200)}.hover\:text-slate-900:hover{color:var(--color-slate-900)}}.disabled\:opacity-50:disabled{opacity:.5}}select,select option{background-color:var(--color-slate-50,#f8fafc);color:var(--color-slate-900,#0f172a)}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@keyframes spin{to{transform:rotate(360deg)}}
1
+ @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-outline-style:solid}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-200:oklch(88.5% .062 18.334);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-green-50:oklch(98.2% .018 155.826);--color-green-700:oklch(52.7% .154 150.069);--color-green-900:oklch(39.3% .095 152.535);--color-blue-50:oklch(97% .014 254.604);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-blue-800:oklch(42.4% .199 265.638);--color-blue-900:oklch(37.9% .146 265.522);--color-slate-50:oklch(98.4% .003 247.858);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-200:oklch(92.9% .013 255.508);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-400:oklch(70.4% .04 256.788);--color-slate-500:oklch(55.4% .046 257.417);--color-slate-600:oklch(44.6% .043 257.281);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-800:oklch(27.9% .041 260.031);--color-slate-900:oklch(20.8% .042 265.755);--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--font-weight-medium:500;--font-weight-semibold:600;--leading-relaxed:1.625;--radius-lg:.5rem;--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.collapse{visibility:collapse}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.m-0{margin:0}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.ml-2{margin-left:calc(var(--spacing) * 2)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-flex{display:inline-flex}.table{display:table}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-8{height:calc(var(--spacing) * 8)}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-72{max-height:calc(var(--spacing) * 72)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-8{width:calc(var(--spacing) * 8)}.w-full{width:100%}.max-w-xs{max-width:var(--container-xs)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-6{column-gap:calc(var(--spacing) * 6)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-amber-200{border-color:var(--color-amber-200)}.border-blue-200{border-color:var(--color-blue-200)}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-700{border-color:var(--color-blue-700)}.border-current{border-color:currentColor}.border-red-200{border-color:var(--color-red-200)}.border-slate-100{border-color:var(--color-slate-100)}.border-slate-200{border-color:var(--color-slate-200)}.border-slate-300{border-color:var(--color-slate-300)}.border-white{border-color:var(--color-white)}.border-t-transparent{border-top-color:#0000}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-100{background-color:var(--color-amber-100)}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-700{background-color:var(--color-blue-700)}.bg-green-50{background-color:var(--color-green-50)}.bg-red-50{background-color:var(--color-red-50)}.bg-slate-50{background-color:var(--color-slate-50)}.bg-slate-100{background-color:var(--color-slate-100)}.bg-white{background-color:var(--color-white)}.p-4{padding:calc(var(--spacing) * 4)}.p-10{padding:calc(var(--spacing) * 10)}.px-1{padding-inline:var(--spacing)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-16{padding-block:calc(var(--spacing) * 16)}.pt-1{padding-top:var(--spacing)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-amber-700{color:var(--color-amber-700)}.text-amber-800{color:var(--color-amber-800)}.text-blue-800{color:var(--color-blue-800)}.text-blue-900{color:var(--color-blue-900)}.text-green-700{color:var(--color-green-700)}.text-green-900{color:var(--color-green-900)}.text-red-800{color:var(--color-red-800)}.text-red-900{color:var(--color-red-900)}.text-slate-400{color:var(--color-slate-400)}.text-slate-500{color:var(--color-slate-500)}.text-slate-600{color:var(--color-slate-600)}.text-slate-700{color:var(--color-slate-700)}.text-slate-800{color:var(--color-slate-800)}.text-slate-900{color:var(--color-slate-900)}.text-white{color:var(--color-white)}.capitalize{text-transform:capitalize}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.select-none{-webkit-user-select:none;user-select:none}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:border-slate-400:hover{border-color:var(--color-slate-400)}.hover\:bg-blue-600:hover{background-color:var(--color-blue-600)}.hover\:bg-slate-50:hover{background-color:var(--color-slate-50)}.hover\:bg-slate-200:hover{background-color:var(--color-slate-200)}.hover\:text-slate-900:hover{color:var(--color-slate-900)}}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}}select,select option{background-color:var(--color-slate-50,#f8fafc);color:var(--color-slate-900,#0f172a)}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@keyframes spin{to{transform:rotate(360deg)}}
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./import-mode-C8xFGO8j.cjs"),S={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",pdf:"application/pdf",eps:"application/postscript",ps:"application/postscript",bmp:"image/bmp",tiff:"image/tiff",tif:"image/tiff",webp:"image/webp",ico:"image/vnd.microsoft.icon"};function v(t){const o=t.split(".").pop()?.toLowerCase()??"";return S[o]??"application/octet-stream"}const f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function M(t){const o=t.length,r=[];for(let n=0;n<o;n+=3){const i=t[n],s=n+1<o,l=n+2<o,c=s?t[n+1]:0,u=l?t[n+2]:0;r.push(f[i>>2]),r.push(f[(i&3)<<4|c>>4]),r.push(s?f[(c&15)<<2|u>>6]:"="),r.push(l?f[u&63]:"=")}return r.join("")}function R(t){return{ref:t.ref,kind:"file",title:t.fileName,short_description:t.fileName,file:{filename:t.fileName,content_type:v(t.fileName),data:M(t.data)}}}function j(t){return{title:t.title,docinfo:t.docinfo,document_type:t.documentKind,divisions_attributes:t.divisions.map(o=>({ref:o.xmlId,source:o.content,source_format:o.sourceFormat,is_root:o.isRoot})),assets_attributes:t.assets.map(R)}}const P={mainSourcePath:"source/main.ptx",publicationPath:"publication/publication.ptx",projectFilePath:"project.ptx",docinfoPath:"source/docinfo.ptx"};function g(t){return e.findAnyElement(t,"pretext")?t:`<pretext>
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./upload-CGxfSSDN.cjs"),g=require("./import-mode-YW6Lr4SU.cjs"),I={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",pdf:"application/pdf",eps:"application/postscript",ps:"application/postscript",bmp:"image/bmp",tiff:"image/tiff",tif:"image/tiff",webp:"image/webp",ico:"image/vnd.microsoft.icon"};function b(t){const o=t.split(".").pop()?.toLowerCase()??"";return I[o]??"application/octet-stream"}const h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function A(t){const o=t.length,s=[];for(let n=0;n<o;n+=3){const r=t[n],l=n+1<o,a=n+2<o,u=l?t[n+1]:0,c=a?t[n+2]:0;s.push(h[r>>2]),s.push(h[(r&3)<<4|u>>4]),s.push(l?h[(u&15)<<2|c>>6]:"="),s.push(a?h[c&63]:"=")}return s.join("")}function M(t){return{ref:t.ref,kind:"file",title:t.fileName,short_description:t.fileName,file:{filename:t.fileName,content_type:b(t.fileName),data:A(t.data)}}}function _(t){return{title:t.title,docinfo:t.docinfo,document_type:t.documentKind,divisions_attributes:t.divisions.map(o=>({ref:o.xmlId,source:o.content,source_format:o.sourceFormat,is_root:o.isRoot})),assets_attributes:t.assets.map(M)}}const v={mainSourcePath:"source/main.ptx",publicationPath:"publication/publication.ptx",projectFilePath:"project.ptx",docinfoPath:"source/docinfo.ptx"};function T(t){return e.findAnyElement(t,"pretext")?t:`<pretext>
2
2
  ${t}
3
- </pretext>`}function h(t,o,r){const n=new Map,i=[],s=`${o}-`;return t.forEach((l,c)=>{const u=l.attributes["xml:id"];let p;if(u){const d=e.slugify(u);p=d.startsWith(s)?d:`${s}${d}`}else p=`${s}${e.padIndex(c+1,t.length)}`,r.push({action:"anomaly",severity:"info",kind:"structure",category:"missing_xml_id",macro:l.name,occurrences:1,message:`<${l.name}> at position ${c+1} has no xml:id; using \`${p}\` as filename.`});const m=n.get(p)??0;n.set(p,m+1);const a=m===0?p:`${p}-${m+1}`;i.push({span:l,slug:a,filename:`${a}.ptx`})}),i}function E(t,o,r,n){const i=e.findTopLevelElements(t,"section");if(i.length===0)return t;const l=h(i,"sec",n).map(c=>{const u=`source/${o}/${c.filename}`;return r[u]=e.withProlog(c.span.outer),{start:c.span.start,end:c.span.end,replacement:`<xi:include href="${o}/${c.filename}"/>`}});return e.spliceReplacements(t,l)}function _(t,o,r){const n=e.findAnyElement(t,"book");if(!n)return r.push({action:"anomaly",severity:"warning",kind:"structure",category:"missing_root",macro:"book",occurrences:1,message:"Document was treated as a book but no <book> element found; emitting as a single file."}),T(t,o);const i={},s=e.findTopLevelElements(n.inner,"chapter");let l=n.inner;if(o.splitChapters&&s.length>0){const m=h(s,"ch",r).map(a=>{let d=a.span.outer;if(o.splitSections){const b=a.span.inner,F=E(b,a.slug,i,r);d=a.span.outer.slice(0,a.span.startTagEnd-a.span.start)+F+a.span.outer.slice(a.span.contentEnd-a.span.start)}const x=`source/${a.filename}`;return i[x]=e.withProlog(d),{start:a.span.start,end:a.span.end,replacement:`<xi:include href="${a.filename}"/>`}});l=e.spliceReplacements(n.inner,m)}const c=t.slice(n.start,n.startTagEnd)+l+t.slice(n.contentEnd,n.end),u=t.slice(0,n.start)+c+t.slice(n.end);return i[o.mainSourcePath]=e.withProlog(e.ensureXIncludeNamespace(g(u.trim()))),i}function T(t,o,r){const n={};return n[o.mainSourcePath]=e.withProlog(g(t.trim())),n}function A(t,o={}){const r=[],n=o.documentKind??e.detectDocumentKind(t),i={splitChapters:o.splitChapters??n==="book",splitSections:o.splitSections??!1,mainSourcePath:o.mainSourcePath??P.mainSourcePath,publicationPath:o.publicationPath??P.publicationPath,projectFilePath:o.projectFilePath??P.projectFilePath,docinfoPath:o.docinfoPath??P.docinfoPath},s=n==="book"?_(t,i,r):T(t,i);return s[i.projectFilePath]=e.renderProjectPtx({mainSource:i.mainSourcePath,publication:i.publicationPath}),s[i.publicationPath]=e.renderPublicationPtx(),{files:s,documentKind:n,warnings:r}}exports.LATEX_FORMAT_MARKERS=e.LATEX_FORMAT_MARKERS;exports.MARKDOWN_FORMAT_MARKERS=e.MARKDOWN_FORMAT_MARKERS;exports.PRETEXT_DIVISION_TAGS=e.PRETEXT_DIVISION_TAGS;exports.PRETEXT_ROOT_TAGS=e.PRETEXT_ROOT_TAGS;exports.analyzeImportSources=e.analyzeImportSources;exports.assetsForImportMode=e.assetsForImportMode;exports.attachLatexRoots=e.attachLatexRoots;exports.attachMarkdownRoots=e.attachMarkdownRoots;exports.buildDivisionPool=e.buildDivisionPool;exports.buildNativeDivisionPool=e.buildNativeDivisionPool;exports.carryOverProjectFiles=e.carryOverProjectFiles;exports.cleanLatex=e.cleanLatex;exports.convertLatexToPretext=e.convertLatexToPretext;exports.convertMarkdownToPretext=e.convertMarkdownToPretext;exports.convertSourceToPretext=e.convertSourceToPretext;exports.defaultAttachLevel=e.defaultAttachLevel;exports.defaultManifestTarget=e.defaultManifestTarget;exports.detectDocumentKind=e.detectDocumentKind;exports.detectSourceFormat=e.detectSourceFormat;exports.divisionChildRefs=e.divisionChildRefs;exports.expandPretextIncludes=e.expandPretextIncludes;exports.extractUpload=e.extractUpload;exports.filePrefixForDivision=e.filePrefixForDivision;exports.filesForImportMode=e.filesForImportMode;exports.findProjectManifest=e.findProjectManifest;exports.formatWarningLine=e.formatWarningLine;exports.getConversionErrorMessage=e.getConversionErrorMessage;exports.handleImportUploadFile=e.handleImportUploadFile;exports.importProjectFromFiles=e.importProjectFromFiles;exports.isDivisionTag=e.isDivisionTag;exports.normalizePretextSource=e.normalizePretextSource;exports.parseProjectManifest=e.parseProjectManifest;exports.projectForImportMode=e.projectForImportMode;exports.renderProjectPtx=e.renderProjectPtx;exports.renderProjectPtxFromManifest=e.renderProjectPtxFromManifest;exports.renderPublicationPtx=e.renderPublicationPtx;exports.resolveSplitLevel=e.resolveSplitLevel;exports.sanitizeRef=e.sanitizeRef;exports.serializeProjectToFiles=e.serializeProjectToFiles;exports.buildPretextProjectFiles=A;exports.serializeProjectToPlusPayload=j;
3
+ </pretext>`}function L(t,o,s){const n=new Map,r=[],l=`${o}-`;return t.forEach((a,u)=>{const c=a.attributes["xml:id"];let p;if(c){const m=e.slugify(c);p=m.startsWith(l)?m:`${l}${m}`}else p=`${l}${e.padIndex(u+1,t.length)}`,s.push({action:"anomaly",severity:"info",kind:"structure",category:"missing_xml_id",macro:a.name,occurrences:1,message:`<${a.name}> at position ${u+1} has no xml:id; using \`${p}\` as filename.`});const d=n.get(p)??0;n.set(p,d+1);const i=d===0?p:`${p}-${d+1}`;r.push({span:a,slug:i,filename:`${i}.ptx`})}),r}function C(t,o,s,n){const r=e.findTopLevelElements(t,"section");if(r.length===0)return t;const a=L(r,"sec",n).map(u=>{const c=`source/${o}/${u.filename}`;return s[c]=e.withProlog(u.span.outer),{start:u.span.start,end:u.span.end,replacement:`<xi:include href="${o}/${u.filename}"/>`}});return e.spliceReplacements(t,a)}function R(t,o,s){const n=e.findAnyElement(t,"book");if(!n)return s.push({action:"anomaly",severity:"warning",kind:"structure",category:"missing_root",macro:"book",occurrences:1,message:"Document was treated as a book but no <book> element found; emitting as a single file."}),S(t,o);const r={},l=e.findTopLevelElements(n.inner,"chapter");let a=n.inner;if(o.splitChapters&&l.length>0){const d=L(l,"ch",s).map(i=>{let m=i.span.outer;if(o.splitSections){const f=i.span.inner,P=C(f,i.slug,r,s);m=i.span.outer.slice(0,i.span.startTagEnd-i.span.start)+P+i.span.outer.slice(i.span.contentEnd-i.span.start)}const x=`source/${i.filename}`;return r[x]=e.withProlog(m),{start:i.span.start,end:i.span.end,replacement:`<xi:include href="${i.filename}"/>`}});a=e.spliceReplacements(n.inner,d)}const u=t.slice(n.start,n.startTagEnd)+a+t.slice(n.contentEnd,n.end),c=t.slice(0,n.start)+u+t.slice(n.end);return r[o.mainSourcePath]=e.withProlog(e.ensureXIncludeNamespace(T(c.trim()))),r}function S(t,o,s){const n={};return n[o.mainSourcePath]=e.withProlog(T(t.trim())),n}function y(t,o={}){const s=[],n=o.documentKind??e.detectDocumentKind(t),r={splitChapters:o.splitChapters??n==="book",splitSections:o.splitSections??!1,mainSourcePath:o.mainSourcePath??v.mainSourcePath,publicationPath:o.publicationPath??v.publicationPath,projectFilePath:o.projectFilePath??v.projectFilePath,docinfoPath:o.docinfoPath??v.docinfoPath},l=n==="book"?R(t,r,s):S(t,r);return l[r.projectFilePath]=e.renderProjectPtx({mainSource:r.mainSourcePath,publication:r.publicationPath}),l[r.publicationPath]=e.renderPublicationPtx(),{files:l,documentKind:n,warnings:s}}class E extends Error{constructor(){super("Import cancelled."),this.name="ConversionCancelledError"}}let j=0;function F(t,o,s={}){const n=`convert-${j++}`,r=t(),{assets:l={},...a}=s;let u;const c=new Promise((d,i)=>{let m=!1;const x=f=>{m||(m=!0,r.terminate(),f())};u=()=>x(()=>i(new E)),r.addEventListener("message",f=>{const P=f.data;if(!(!P||P.requestId!==n)){if(P.type==="result"){x(()=>d(P.result));return}x(()=>i(new Error(P.message)))}}),r.addEventListener("error",f=>{const P=typeof f=="object"&&f&&"message"in f?String(f.message):"The import worker failed to start.";x(()=>i(new Error(P)))})}),p=[...new Set(Object.values(l).map(d=>d.buffer).filter(d=>d instanceof ArrayBuffer))];return r.postMessage({type:"convert",requestId:n,files:o,assets:l,options:a},p),{result:c,cancel:()=>u?.()}}function k(t){const{createWorker:o,id:s="worker",label:n="Built-in converter",description:r="Create a new project starting with LaTeX, Markdown, or PreTeXt files.",acceptExtensions:l}=t;let a=null;const u=async(c,p)=>{a?.cancel(),a=F(o,c,p);try{return await a.result}finally{a=null}};return{id:s,label:n,description:r,acceptExtensions:l,prepare:async c=>{const{files:p,assets:d}=await e.extractUpload(c);return{fileName:c.name,files:p,assets:d,analysis:e.analyzeImportSources(p)}},convertPrepared:(c,p)=>u(c.files,{...p,assets:c.assets}),convertFile:async(c,p)=>{const{files:d,assets:i}=await e.extractUpload(c);return u(d,{...p,assets:i})},cancel:()=>{a?.cancel(),a=null}}}exports.CLEAN_RULES=e.CLEAN_RULES;exports.LATEX_DIVISION_COMMANDS=e.LATEX_DIVISION_COMMANDS;exports.LATEX_FORMAT_MARKERS=e.LATEX_FORMAT_MARKERS;exports.MARKDOWN_FORMAT_MARKERS=e.MARKDOWN_FORMAT_MARKERS;exports.MAX_SUGGESTED_SPLIT_LEVEL=e.MAX_SUGGESTED_SPLIT_LEVEL;exports.PRETEXT_DIVISION_TAGS=e.PRETEXT_DIVISION_TAGS;exports.PRETEXT_ROOT_TAGS=e.PRETEXT_ROOT_TAGS;exports.analyzeImportSources=e.analyzeImportSources;exports.applyLatexFixes=e.applyLatexFixes;exports.attachLatexRoots=e.attachLatexRoots;exports.attachMarkdownRoots=e.attachMarkdownRoots;exports.buildDivisionPool=e.buildDivisionPool;exports.buildNativeDivisionPool=e.buildNativeDivisionPool;exports.carryOverProjectFiles=e.carryOverProjectFiles;exports.cleanLatex=e.cleanLatex;exports.cleanLatexInChunks=e.cleanLatexInChunks;exports.cleanLatexText=e.cleanLatexText;exports.convertLatexToPretext=e.convertLatexToPretext;exports.convertMarkdownToPretext=e.convertMarkdownToPretext;exports.convertSourceToPretext=e.convertSourceToPretext;exports.defaultAttachLevel=e.defaultAttachLevel;exports.defaultManifestTarget=e.defaultManifestTarget;exports.detectDocumentKind=e.detectDocumentKind;exports.detectSourceFormat=e.detectSourceFormat;exports.divisionChildRefs=e.divisionChildRefs;exports.divisionsAtLevel=e.divisionsAtLevel;exports.expandPretextIncludes=e.expandPretextIncludes;exports.extractUpload=e.extractUpload;exports.filePrefixForDivision=e.filePrefixForDivision;exports.findLatexFixes=e.findLatexFixes;exports.findLatexHeaders=e.findLatexHeaders;exports.findProjectManifest=e.findProjectManifest;exports.fixesToWarnings=e.fixesToWarnings;exports.getConversionErrorMessage=e.getConversionErrorMessage;exports.getLatexCleanDiagnostics=e.getLatexCleanDiagnostics;exports.handleImportUploadFile=e.handleImportUploadFile;exports.importProjectFromFiles=e.importProjectFromFiles;exports.isDivisionTag=e.isDivisionTag;exports.latexDivisionHierarchy=e.latexDivisionHierarchy;exports.latexFixesToCodeActions=e.latexFixesToCodeActions;exports.mergeChunksAtLevel=e.mergeChunksAtLevel;exports.normalizePretextSource=e.normalizePretextSource;exports.parseLatexDivisions=e.parseLatexDivisions;exports.parseProjectManifest=e.parseProjectManifest;exports.relayoutImport=e.relayoutImport;exports.renderProjectPtx=e.renderProjectPtx;exports.renderProjectPtxFromManifest=e.renderProjectPtxFromManifest;exports.renderPublicationPtx=e.renderPublicationPtx;exports.resolveImportSplitLevel=e.resolveImportSplitLevel;exports.resolveSplitLevel=e.resolveSplitLevel;exports.sanitizeRef=e.sanitizeRef;exports.serializeProjectToFiles=e.serializeProjectToFiles;exports.suggestSplitLevel=e.suggestSplitLevel;exports.assetsForImportMode=g.assetsForImportMode;exports.diffHunks=g.diffHunks;exports.diffLines=g.diffLines;exports.diffStats=g.diffStats;exports.fileChangesForImport=g.fileChangesForImport;exports.filesForImportMode=g.filesForImportMode;exports.formatWarningLine=g.formatWarningLine;exports.projectForImportMode=g.projectForImportMode;exports.ConversionCancelledError=E;exports.buildPretextProjectFiles=y;exports.createWorkerEngine=k;exports.runConversionInWorker=F;exports.serializeProjectToPlusPayload=_;
package/dist/index.d.ts CHANGED
@@ -1,15 +1,21 @@
1
1
  export { detectSourceFormat, LATEX_FORMAT_MARKERS, MARKDOWN_FORMAT_MARKERS, } from './lib/detect-source-format';
2
2
  export { convertLatexToPretext, convertMarkdownToPretext, normalizePretextSource, convertSourceToPretext, getConversionErrorMessage, } from './lib/convert';
3
3
  export type { LatexConversionResult, MarkdownConversionResult, } from './lib/convert';
4
- export { importProjectFromFiles, handleImportUploadFile, extractUpload, type ExtractedUpload, type ImportProjectOptions, } from './lib/upload';
4
+ export { importProjectFromFiles, handleImportUploadFile, extractUpload, relayoutImport, resolveImportSplitLevel, type ExtractedUpload, type ImportProjectOptions, type SplitLevelContext, } from './lib/upload';
5
+ export { LATEX_DIVISION_COMMANDS, findLatexHeaders, latexDivisionHierarchy, parseLatexDivisions, divisionsAtLevel, suggestSplitLevel, MAX_SUGGESTED_SPLIT_LEVEL, type LatexDivision, type LatexDivisionCommand, } from './lib/latex-split';
6
+ export { fileChangesForImport, type FileChangeRecord, } from './lib/file-changes';
7
+ export { diffLines, diffHunks, diffStats, type DiffLine, type DiffHunk, type DiffStats, } from './lib/diff';
8
+ export { cleanLatexInChunks, mergeChunksAtLevel, type CleanedChunk, type CleanLatexChunksResult, } from './lib/clean/clean-chunks';
5
9
  export { analyzeImportSources, type AnalyzeOptions, type RootCandidate, type RootReason, type UploadAnalysis, } from './lib/project/analyze';
6
10
  export { attachLatexRoots, attachMarkdownRoots, defaultAttachLevel, type AttachLevel, type AttachedRootRecord, type AttachRootsResult, type RootAttachment, } from './lib/project/attach-roots';
7
11
  export { defaultManifestTarget, findProjectManifest, parseProjectManifest, type ManifestTarget, type ProjectManifest, } from './lib/project/manifest';
8
12
  export { carryOverProjectFiles, renderProjectPtxFromManifest, type CarryOverOptions, type CarryOverResult, } from './lib/project/existing-project';
9
13
  export { PRETEXT_DIVISION_TAGS, PRETEXT_ROOT_TAGS, filePrefixForDivision, isDivisionTag, type PretextDivisionTag, type PretextRootTag, } from './lib/pretext-divisions';
10
14
  export { filesForImportMode, assetsForImportMode, projectForImportMode, formatWarningLine, type ImportMode, } from './lib/import-mode';
11
- export { cleanLatex } from './lib/clean/clean-latex';
12
- export type { CleanLatexResult } from './lib/clean/clean-latex';
15
+ export { cleanLatex, fixesToWarnings } from './lib/clean/clean-latex';
16
+ export type { CleanLatexOptions, CleanLatexResult, } from './lib/clean/clean-latex';
17
+ export { CLEAN_RULES, findLatexFixes, applyLatexFixes, cleanLatexText, getLatexCleanDiagnostics, latexFixesToCodeActions, } from '@pretextbook/latex-style-pretext';
18
+ export type { CleanRule, CleanScope, FindFixesOptions, LatexFix, } from '@pretextbook/latex-style-pretext';
13
19
  export { expandPretextIncludes } from './lib/clean/pretext-includes';
14
20
  export type { CleaningWarning, CleaningSeverity, CleaningAction, } from './lib/clean/warnings';
15
21
  export { buildPretextProjectFiles, detectDocumentKind, renderProjectPtx, renderPublicationPtx, } from './lib/layout';
@@ -17,3 +23,5 @@ export type { BuildProjectFilesOptions, BuildProjectFilesResult, DocumentKind, }
17
23
  export { buildDivisionPool, resolveSplitLevel, buildNativeDivisionPool, sanitizeRef, serializeProjectToFiles, serializeProjectToPlusPayload, divisionChildRefs, } from './lib/pool';
18
24
  export type { BuildDivisionPoolOptions, BuildDivisionPoolResult, BuildNativeDivisionPoolOptions, SerializeProjectFilesOptions, SerializedProjectFiles, } from './lib/pool';
19
25
  export type { SourceFormat, ProjectLayout, ConversionContext, ConvertedPretextResult, UploadStatusType, UploadStatusMessage, UploadSourceType, ImportedProject, ImportedDivision, ImportedDivisionType, ImportedAsset, PlusProjectPayload, PlusDivisionAttributes, PlusAssetAttributes, PlusAssetFile, ImportedProjectResult, ImportedProjectSuccess, ImportedProjectError, } from './lib/types';
26
+ export { createWorkerEngine, runConversionInWorker, ConversionCancelledError, type ConversionWorker, type WorkerEngineOptions, type RunningConversion, } from './worker/worker-engine';
27
+ export type { WorkerRequest, WorkerResponse, ConvertRequest, ResultResponse, ErrorResponse, } from './worker/protocol';