@pretextbook/import 0.9.0 → 0.11.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 -1
- package/dist/convert-worker.js +1 -1
- package/dist/{import-mode-DuPFMu97.cjs → import-mode-CV7gCDzF.cjs} +1 -1
- package/dist/{import-mode-BaaBvzcy.js → import-mode-DQ8g5P8P.js} +1 -1
- package/dist/import.css +1 -1
- package/dist/index.cjs +5 -3
- package/dist/index.d.ts +10 -5
- package/dist/index.js +562 -219
- package/dist/lib/assets/images.d.ts +49 -0
- package/dist/lib/detect-snippet-format.d.ts +32 -0
- package/dist/lib/insert/dedupe-ids.d.ts +36 -0
- package/dist/lib/insert/destination.d.ts +21 -0
- package/dist/lib/insert/index.d.ts +4 -0
- package/dist/lib/insert/prepare.d.ts +44 -0
- package/dist/lib/insert/retarget.d.ts +35 -0
- package/dist/lib/layout/xml-scan.d.ts +28 -0
- package/dist/lib/pandoc/formats.d.ts +40 -0
- package/dist/lib/pandoc/index.d.ts +3 -0
- package/dist/lib/pandoc/pandoc-engine.d.ts +24 -0
- package/dist/lib/pandoc/remote-pandoc.d.ts +74 -0
- package/dist/lib/paste/place-markup.d.ts +41 -0
- package/dist/lib/pool/division-pool.d.ts +5 -0
- package/dist/lib/pool/index.d.ts +5 -1
- package/dist/lib/pool/place-divisions.d.ts +25 -0
- package/dist/lib/pool/placeholders.d.ts +4 -0
- package/dist/lib/pool/refs.d.ts +8 -0
- package/dist/lib/pool/serialize-destination.d.ts +24 -0
- package/dist/lib/pool/serialize-files.d.ts +1 -2
- package/dist/lib/pool/serialize-insert-records.d.ts +22 -0
- package/dist/lib/pool/serialize-insert.d.ts +44 -0
- package/dist/lib/pool/serialize-plus.d.ts +4 -4
- package/dist/lib/pool/serialize-records.d.ts +11 -0
- package/dist/lib/pretext-divisions.d.ts +25 -0
- package/dist/lib/select/divisions.d.ts +44 -0
- package/dist/lib/types.d.ts +82 -2
- package/dist/lib/upload.d.ts +56 -4
- package/dist/react/import-wizard.d.ts +30 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react.cjs +2 -2
- package/dist/react.js +658 -511
- package/dist/upload-BnRj1gU1.cjs +135 -0
- package/dist/upload-H_OCZBBn.js +7648 -0
- package/package.json +5 -5
- package/dist/upload-BmErkg8I.js +0 -7140
- package/dist/upload-BtS22hIH.cjs +0 -135
package/dist/convert-worker.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./upload-
|
|
1
|
+
"use strict";const n=require("./upload-BnRj1gU1.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."})}};
|
package/dist/convert-worker.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";const p=require("./upload-
|
|
1
|
+
"use strict";const p=require("./upload-BnRj1gU1.cjs");function h(e,t){const n=e.length===0?[]:e.split(`
|
|
2
2
|
`),i=t.length===0?[]:t.split(`
|
|
3
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;
|
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-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)}}
|
|
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}.visible{visibility:visible}.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)}.ml-5{margin-left:calc(var(--spacing) * 5)}.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-56{max-height:calc(var(--spacing) * 56)}.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-baseline{align-items:baseline}.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-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}: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-l{border-left-style:var(--tw-border-style);border-left-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)}.pl-3{padding-left:calc(var(--spacing) * 3)}.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,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./upload-BnRj1gU1.cjs"),h=require("./import-mode-CV7gCDzF.cjs"),ee=/\$(?![\s$])([^$\n]{1,200})\$/;function te(e){const n=ee.exec(e);if(!n)return!1;const r=n[1];return/[\\^_{}]/.test(r)||/^[A-Za-z]'?$/.test(r.trim())}const ne=[{pattern:/\\(?:begin|end)\{[a-zA-Z*]+\}/,weight:3},{pattern:/\\\[[\s\S]*?\\\]|\$\$[\s\S]*?\$\$/,weight:3},{pattern:/\\[a-zA-Z]+\s*\{/,weight:2},{pattern:/\\\([\s\S]*?\\\)/,weight:2},{pattern:/\\[a-zA-Z]+\b/,weight:1},{pattern:/\\(?:label|ref|eqref|cite)\b/,weight:2}],re=[{pattern:/^#{1,6}\s+\S/m,weight:3},{pattern:/^\s*```/m,weight:3},{pattern:/^\s*[-*+]\s+\S/m,weight:2},{pattern:/^\s*\d+[.)]\s+\S/m,weight:2},{pattern:/\*\*[^\s*][^*]*\*\*/,weight:2},{pattern:/\[[^\]\n]+\]\([^)\s]+\)/,weight:2},{pattern:/^\s*>\s+\S/m,weight:2},{pattern:/(?:^|\s)_[^_\s][^_\n]*_(?:\s|[.,;:!?]|$)/,weight:1},{pattern:/`[^`\n]+`/,weight:1}],oe=2;function D(e,n){return n.reduce((r,{pattern:o,weight:i})=>r+(o.test(e)?i:0),0)}function O(e){return{latex:D(e,ne)+(te(e)?2:0),markdown:D(e,re)}}function ie(e){const n=e.trim();if(!n||n.startsWith("<"))return;const{latex:r,markdown:o}=O(n);if(!(Math.max(r,o)<oe))return r>=o?"latex":"markdown"}const se={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 ae(e){const n=e.split(".").pop()?.toLowerCase()??"";return se[n]??"application/octet-stream"}const S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function ce(e){const n=e.length,r=[];for(let o=0;o<n;o+=3){const i=e[o],a=o+1<n,s=o+2<n,c=a?e[o+1]:0,l=s?e[o+2]:0;r.push(S[i>>2]),r.push(S[(i&3)<<4|c>>4]),r.push(a?S[(c&15)<<2|l>>6]:"="),r.push(s?S[l&63]:"=")}return r.join("")}function y(e){return{ref:e.ref,fileName:e.fileName,contentType:ae(e.fileName),data:ce(e.data)}}function $(e){return{ref:e.xmlId,source:e.content,sourceFormat:e.sourceFormat,isRoot:e.isRoot}}function N(e){return{title:e.title,docinfo:e.docinfo,documentKind:e.documentKind,divisions:e.divisions.map($),assets:e.assets.map(y)}}function le(e){return{ref:e.ref,kind:"file",title:e.fileName,short_description:e.fileName,file:{filename:e.fileName,content_type:e.contentType,data:e.data}}}function k(e){return{title:e.title,docinfo:e.docinfo,document_type:e.documentKind,divisions_attributes:e.divisions.map(n=>({ref:n.ref,source:n.source,source_format:n.sourceFormat,is_root:n.isRoot})),assets_attributes:e.assets.map(le)}}function de(e){return k(N(e))}function ue(e,n){const{root:r,entries:o}=t.insertEntries(e,n),i=new Set(o.map(s=>s.xmlId)),a=e.divisions.filter(s=>!i.has(s.xmlId)&&!(n.unwrapRoot&&s.xmlId===r.xmlId));return{divisions:[...o,...a].map($),assets:e.assets.map(y),placeholders:o.map(s=>`<plus:${s.type} ref="${s.xmlId}"/>`)}}const R=/<(\/?)p(?=[\s>/])/g;function pe(e){let n=0;R.lastIndex=0;let r;for(;(r=R.exec(e))!==null;)n+=r[1]?-1:1;return n>0}const me=new RegExp(`<(${t.PRETEXT_DIVISION_TAGS.join("|")})(?=[\\s>/])`);function j(e){return me.exec(e)?.[1]}function X(e,n,r){return e.split(`
|
|
2
|
+
`).map((o,i)=>i===0&&r?o:o&&n+o).join(`
|
|
3
|
+
`)}function fe(e,n){let r=e.trim(),o;if(n.inline){const i=r.replace(/^<p>\s*([\s\S]*?)\s*<\/p>$/,"$1");r=i!==r?i:r.replace(/^<p>/,"");const a=j(r);a&&(o=`Pasted content produced a <${a}>, which cannot sit inside a <p>. It was inserted as-is — move it out of the paragraph to make the document valid.`)}return n.baseIndent&&(r=X(r,n.baseIndent,n.midLine)),{markup:r,warning:o}}const v={mainSourcePath:"source/main.ptx",publicationPath:"publication/publication.ptx",projectFilePath:"project.ptx",docinfoPath:"source/docinfo.ptx"};function z(e){return t.findAnyElement(e,"pretext")?e:`<pretext>
|
|
4
|
+
${e}
|
|
5
|
+
</pretext>`}function U(e,n,r){const o=new Map,i=[],a=`${n}-`;return e.forEach((s,c)=>{const l=s.attributes["xml:id"];let d;if(l){const f=t.slugify(l);d=f.startsWith(a)?f:`${a}${f}`}else d=`${a}${t.padIndex(c+1,e.length)}`,r.push({action:"anomaly",severity:"info",kind:"structure",category:"missing_xml_id",macro:s.name,occurrences:1,message:`<${s.name}> at position ${c+1} has no xml:id; using \`${d}\` as filename.`});const p=o.get(d)??0;o.set(d,p+1);const u=p===0?d:`${d}-${p+1}`;i.push({span:s,slug:u,filename:`${u}.ptx`})}),i}function he(e,n,r,o){const i=t.findTopLevelElements(e,"section");if(i.length===0)return e;const s=U(i,"sec",o).map(c=>{const l=`source/${n}/${c.filename}`;return r[l]=t.withProlog(c.span.outer),{start:c.span.start,end:c.span.end,replacement:`<xi:include href="${n}/${c.filename}"/>`}});return t.spliceReplacements(e,s)}function ge(e,n,r){const o=t.findAnyElement(e,"book");if(!o)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."}),W(e,n);const i={},a=t.findTopLevelElements(o.inner,"chapter");let s=o.inner;if(n.splitChapters&&a.length>0){const p=U(a,"ch",r).map(u=>{let f=u.span.outer;if(n.splitSections){const m=u.span.inner,g=he(m,u.slug,i,r);f=u.span.outer.slice(0,u.span.startTagEnd-u.span.start)+g+u.span.outer.slice(u.span.contentEnd-u.span.start)}const T=`source/${u.filename}`;return i[T]=t.withProlog(f),{start:u.span.start,end:u.span.end,replacement:`<xi:include href="${u.filename}"/>`}});s=t.spliceReplacements(o.inner,p)}const c=e.slice(o.start,o.startTagEnd)+s+e.slice(o.contentEnd,o.end),l=e.slice(0,o.start)+c+e.slice(o.end);return i[n.mainSourcePath]=t.withProlog(t.ensureXIncludeNamespace(z(l.trim()))),i}function W(e,n,r){const o={};return o[n.mainSourcePath]=t.withProlog(z(e.trim())),o}function Te(e,n={}){const r=[],o=n.documentKind??t.detectDocumentKind(e),i={splitChapters:n.splitChapters??o==="book",splitSections:n.splitSections??!1,mainSourcePath:n.mainSourcePath??v.mainSourcePath,publicationPath:n.publicationPath??v.publicationPath,projectFilePath:n.projectFilePath??v.projectFilePath,docinfoPath:n.docinfoPath??v.docinfoPath},a=o==="book"?ge(e,i,r):W(e,i);return a[i.projectFilePath]=t.renderProjectPtx({mainSource:i.mainSourcePath,publication:i.publicationPath}),a[i.publicationPath]=t.renderPublicationPtx(),{files:a,documentKind:o,warnings:r}}class K extends Error{constructor(){super("Import cancelled."),this.name="ConversionCancelledError"}}let Pe=0;function G(e,n,r={}){const o=`convert-${Pe++}`,i=e(),{assets:a={},...s}=r;let c;const l=new Promise((p,u)=>{let f=!1;const T=m=>{f||(f=!0,i.terminate(),m())};c=()=>T(()=>u(new K)),i.addEventListener("message",m=>{const g=m.data;if(!(!g||g.requestId!==o)){if(g.type==="result"){T(()=>p(g.result));return}T(()=>u(new Error(g.message)))}}),i.addEventListener("error",m=>{const g=typeof m=="object"&&m&&"message"in m?String(m.message):"The import worker failed to start.";T(()=>u(new Error(g)))})}),d=[...new Set(Object.values(a).map(p=>p.buffer).filter(p=>p instanceof ArrayBuffer))];return i.postMessage({type:"convert",requestId:o,files:n,assets:a,options:s},d),{result:l,cancel:()=>c?.()}}function xe(e){const{createWorker:n,id:r="worker",label:o="Built-in converter",description:i="Create a new project starting with LaTeX, Markdown, or PreTeXt files.",acceptExtensions:a}=e;let s=null;const c=async(l,d)=>{s?.cancel(),s=G(n,l,d);try{return await s.result}finally{s=null}};return{id:r,label:o,description:i,acceptExtensions:a,prepare:async l=>{const{files:d,assets:p}=await t.extractUpload(l);return{fileName:l.name,files:d,assets:p,analysis:t.analyzeImportSources(d)}},convertPrepared:(l,d)=>c(l.files,{...d,assets:l.assets}),convertFile:async(l,d)=>{const{files:p,assets:u}=await t.extractUpload(l);return c(p,{...d,assets:u})},cancel:()=>{s?.cancel(),s=null}}}const B={".docx":"docx",".odt":"odt",".epub":"epub",".tex":"latex",".ltx":"latex",".md":"markdown",".markdown":"markdown",".html":"html",".htm":"html",".rst":"rst",".org":"org",".ipynb":"ipynb",".typ":"typst",".xml":"docbook",".textile":"textile"},Ee=new Set(["docx","odt","epub"]),w=[".docx",".odt",".epub",".html",".htm",".rst",".org",".ipynb",".typ",".textile",".tex",".ltx",".md",".markdown"];function _(e){const n=e.lastIndexOf(".");return n<=0?"":e.slice(n).toLowerCase()}function H(e){return B[_(e)]}function V(e){const{convertToPretext:n,id:r="pandoc",label:o="Pandoc",description:i="Convert Word, OpenOffice, EPUB, HTML, reStructuredText, and more.",acceptExtensions:a=w}=e;return{id:r,label:o,description:i,acceptExtensions:a,convertFile:async(s,c)=>{const l=await n(s,c);if(!l.trim())throw new Error(`Pandoc produced no output for ${s.name}. The file may be empty or in an unexpected format.`);const d=t.importProjectFromFiles({"source.ptx":l},{documentKind:c.documentKind,splitChapters:c.splitChapters,splitSections:c.splitSections,splitLevel:c.splitLevel});return"pretextError"in d||(d.sourceName=s.name,d.sourcePath=s.name),d}}}const q=3e4;function Y(e){const n=/<pre>([\s\S]*?)<\/pre>/i.exec(e);return(n?n[1]:e).replace(/<[^>]+>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&").trim()}function Z(e,n,r){const o=Ie(Y(n)),i=o?` (${C(o)})`:"";switch(e){case 400:return`The pandoc server will not convert ${r}${i}.${E(r)}`;case 401:case 403:return`The pandoc server rejected this site's credentials, so ${r} was never converted. Nothing is wrong with your file — this is a configuration problem with the service, and worth reporting.${E(r)}`;case 404:return`The pandoc conversion service could not be found at the address this site is configured to use. Nothing is wrong with your file — this is a configuration problem worth reporting.${E(r)}`;case 413:return`${r} is too large for the pandoc server to accept. Splitting it into chapters and importing them one at a time should get through.`;case 422:return`Pandoc could not read ${r}${i}. The file may be damaged, or may use features pandoc does not support.`;case 503:return`The pandoc server is running without its PreTeXt writer, so it cannot convert anything right now. Nothing is wrong with your file — this is a problem with the service, and worth reporting.${E(r)}`;case 504:return`Converting ${r} took longer than the pandoc server allows. Splitting it into chapters and importing them one at a time usually works.`;default:{const a=o?`(HTTP ${e}: ${C(o)})`:`(HTTP ${e})`;return`The pandoc server could not convert ${r} ${a}.${E(r)}`}}}const M=300;function Ie(e){return e.replace(/\s+/g," ").trim()}function C(e){return e.length<=M?e:`${e.slice(0,M).trimEnd()}…`}const Se=new Set([".tex",".ltx",".md",".markdown"]);function E(e){return Se.has(_(e))?" You can import this file with the built-in converter instead.":""}function ve(e){const{url:n,token:r,headers:o,credentials:i,standalone:a=!0,from:s,timeoutMs:c=q,fetchImpl:l,id:d="pandoc-remote",label:p="Pandoc (server)",description:u="Convert Word, OpenOffice, EPUB, HTML, reStructuredText, and more — no local install needed.",acceptExtensions:f=w}=e;return V({convertToPretext:async(m,g)=>{const F=l??globalThis.fetch;if(typeof F!="function")throw new Error("This environment has no fetch; pass fetchImpl to createRemotePandocEngine.");const A=s??H(m.name);if(!A)throw new Error(`Pandoc cannot determine a format for ${m.name}. Supported extensions: ${f.join(", ")}.`);const P=new FormData;r&&P.set("token",r),P.set("file",m,m.name),P.set("from",A),a&&P.set("standalone","yes");const L=new AbortController,J=setTimeout(()=>L.abort(),c);let I;try{I=await F(n,{method:"POST",body:P,headers:o,credentials:i,signal:L.signal})}catch(x){if(x instanceof Error&&x.name==="AbortError")throw new Error(`Pandoc conversion of ${m.name} timed out after ${Math.round(c/1e3)}s.`);const Q=x instanceof Error?x.message:String(x);throw new Error(`Could not reach the pandoc server: ${Q}`)}finally{clearTimeout(J)}const b=await I.text();if(!I.ok)throw new Error(Z(I.status,b,m.name));return b},id:d,label:p,description:u,acceptExtensions:f})}exports.CLEAN_RULES=t.CLEAN_RULES;exports.DIVISION_LADDER=t.DIVISION_LADDER;exports.LADDER_OVERFLOW_TAG=t.LADDER_OVERFLOW_TAG;exports.LATEX_DIVISION_COMMANDS=t.LATEX_DIVISION_COMMANDS;exports.LATEX_FORMAT_MARKERS=t.LATEX_FORMAT_MARKERS;exports.MARKDOWN_FORMAT_MARKERS=t.MARKDOWN_FORMAT_MARKERS;exports.MAX_SUGGESTED_SPLIT_LEVEL=t.MAX_SUGGESTED_SPLIT_LEVEL;exports.PRETEXT_DIVISION_TAGS=t.PRETEXT_DIVISION_TAGS;exports.PRETEXT_ROOT_TAGS=t.PRETEXT_ROOT_TAGS;exports.PROJECT_DESTINATION=t.PROJECT_DESTINATION;exports.analyzeImportSources=t.analyzeImportSources;exports.applyLatexFixes=t.applyLatexFixes;exports.attachLatexRoots=t.attachLatexRoots;exports.attachMarkdownRoots=t.attachMarkdownRoots;exports.buildDivisionPool=t.buildDivisionPool;exports.buildNativeDivisionPool=t.buildNativeDivisionPool;exports.carryOverProjectFiles=t.carryOverProjectFiles;exports.cleanLatex=t.cleanLatex;exports.cleanLatexInChunks=t.cleanLatexInChunks;exports.cleanLatexText=t.cleanLatexText;exports.convertLatexToPretext=t.convertLatexToPretext;exports.convertMarkdownToPretext=t.convertMarkdownToPretext;exports.convertSourceToPretext=t.convertSourceToPretext;exports.dedupeXmlIds=t.dedupeXmlIds;exports.defaultAttachLevel=t.defaultAttachLevel;exports.defaultManifestTarget=t.defaultManifestTarget;exports.detectDocumentKind=t.detectDocumentKind;exports.detectSourceFormat=t.detectSourceFormat;exports.divisionChildRefs=t.divisionChildRefs;exports.divisionsAtLevel=t.divisionsAtLevel;exports.expandPretextIncludes=t.expandPretextIncludes;exports.extractUpload=t.extractUpload;exports.filePrefixForDivision=t.filePrefixForDivision;exports.findLatexFixes=t.findLatexFixes;exports.findLatexHeaders=t.findLatexHeaders;exports.findProjectManifest=t.findProjectManifest;exports.fixesToWarnings=t.fixesToWarnings;exports.getConversionErrorMessage=t.getConversionErrorMessage;exports.getLatexCleanDiagnostics=t.getLatexCleanDiagnostics;exports.handleImportUploadFile=t.handleImportUploadFile;exports.importProjectFromFiles=t.importProjectFromFiles;exports.isDivisionTag=t.isDivisionTag;exports.ladderDepth=t.ladderDepth;exports.latexDivisionHierarchy=t.latexDivisionHierarchy;exports.latexFixesToCodeActions=t.latexFixesToCodeActions;exports.mergeChunksAtLevel=t.mergeChunksAtLevel;exports.normalizePretextSource=t.normalizePretextSource;exports.outlineDivisions=t.outlineDivisions;exports.parseLatexDivisions=t.parseLatexDivisions;exports.parseProjectManifest=t.parseProjectManifest;exports.prepareInsertSource=t.prepareInsertSource;exports.pruneDivisions=t.pruneDivisions;exports.rebuildImport=t.rebuildImport;exports.relayoutImport=t.relayoutImport;exports.renderProjectPtx=t.renderProjectPtx;exports.renderProjectPtxFromManifest=t.renderProjectPtxFromManifest;exports.renderPublicationPtx=t.renderPublicationPtx;exports.reselectImport=t.reselectImport;exports.resolveImportSplitLevel=t.resolveImportSplitLevel;exports.resolveSplitLevel=t.resolveSplitLevel;exports.retargetFragment=t.retargetFragment;exports.retargetFragmentToDepth=t.retargetFragmentToDepth;exports.retargetImport=t.retargetImport;exports.sanitizeRef=t.sanitizeRef;exports.serializeForDestination=t.serializeForDestination;exports.serializeInsertFiles=t.serializeInsertFiles;exports.serializeProjectToFiles=t.serializeProjectToFiles;exports.shiftLadderTag=t.shiftLadderTag;exports.suggestSplitLevel=t.suggestSplitLevel;exports.DEFAULT_IMPORT_MODE=h.DEFAULT_IMPORT_MODE;exports.assetsForImportMode=h.assetsForImportMode;exports.diffHunks=h.diffHunks;exports.diffLines=h.diffLines;exports.diffStats=h.diffStats;exports.fileChangesForImport=h.fileChangesForImport;exports.filesForImportMode=h.filesForImportMode;exports.formatWarningLine=h.formatWarningLine;exports.hasNativeImportMode=h.hasNativeImportMode;exports.projectForImportMode=h.projectForImportMode;exports.resolveImportMode=h.resolveImportMode;exports.ConversionCancelledError=K;exports.DEFAULT_REMOTE_PANDOC_TIMEOUT_MS=q;exports.PANDOC_ACCEPT_EXTENSIONS=w;exports.PANDOC_BINARY_FORMATS=Ee;exports.PANDOC_EXTENSION_FORMATS=B;exports.buildPretextProjectFiles=Te;exports.createPandocEngine=V;exports.createRemotePandocEngine=ve;exports.createWorkerEngine=xe;exports.describeRemotePandocFailure=Z;exports.detectSnippetFormat=ie;exports.extractPandocErrorDetail=Y;exports.fileExtension=_;exports.firstDivisionTag=j;exports.isInlineContext=pe;exports.pandocFormatForFileName=H;exports.placeConvertedMarkup=fe;exports.recordsToPlusPayload=k;exports.reindentForContext=X;exports.runConversionInWorker=G;exports.scoreSnippetFormats=O;exports.serializeInsertToRecords=ue;exports.serializeProjectToPlusPayload=de;exports.serializeProjectToRecords=N;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { detectSourceFormat, LATEX_FORMAT_MARKERS, MARKDOWN_FORMAT_MARKERS, } from './lib/detect-source-format';
|
|
2
|
+
export { detectSnippetFormat, scoreSnippetFormats, type SnippetFormat, type SnippetFormatScores, } from './lib/detect-snippet-format';
|
|
2
3
|
export { convertLatexToPretext, convertMarkdownToPretext, normalizePretextSource, convertSourceToPretext, getConversionErrorMessage, } from './lib/convert';
|
|
3
4
|
export type { LatexConversionResult, MarkdownConversionResult, } from './lib/convert';
|
|
4
|
-
export { importProjectFromFiles, handleImportUploadFile, extractUpload, relayoutImport, resolveImportSplitLevel, type ExtractedUpload, type ImportProjectOptions, type SplitLevelContext, } from './lib/upload';
|
|
5
|
+
export { importProjectFromFiles, handleImportUploadFile, extractUpload, relayoutImport, rebuildImport, retargetImport, reselectImport, resolveImportSplitLevel, type ExtractedUpload, type ImportProjectOptions, type RebuildImportOptions, type SplitLevelContext, } from './lib/upload';
|
|
5
6
|
export { LATEX_DIVISION_COMMANDS, findLatexHeaders, latexDivisionHierarchy, parseLatexDivisions, divisionsAtLevel, suggestSplitLevel, MAX_SUGGESTED_SPLIT_LEVEL, type LatexDivision, type LatexDivisionCommand, } from './lib/latex-split';
|
|
6
7
|
export { fileChangesForImport, type FileChangeRecord, } from './lib/file-changes';
|
|
7
8
|
export { diffLines, diffHunks, diffStats, type DiffLine, type DiffHunk, type DiffStats, } from './lib/diff';
|
|
@@ -10,7 +11,10 @@ export { analyzeImportSources, type AnalyzeOptions, type RootCandidate, type Roo
|
|
|
10
11
|
export { attachLatexRoots, attachMarkdownRoots, defaultAttachLevel, type AttachLevel, type AttachedRootRecord, type AttachRootsResult, type RootAttachment, } from './lib/project/attach-roots';
|
|
11
12
|
export { defaultManifestTarget, findProjectManifest, parseProjectManifest, type ManifestTarget, type ProjectManifest, } from './lib/project/manifest';
|
|
12
13
|
export { carryOverProjectFiles, renderProjectPtxFromManifest, type CarryOverOptions, type CarryOverResult, } from './lib/project/existing-project';
|
|
13
|
-
export { PRETEXT_DIVISION_TAGS, PRETEXT_ROOT_TAGS, filePrefixForDivision, isDivisionTag, type PretextDivisionTag, type PretextRootTag, } from './lib/pretext-divisions';
|
|
14
|
+
export { DIVISION_LADDER, LADDER_OVERFLOW_TAG, PRETEXT_DIVISION_TAGS, PRETEXT_ROOT_TAGS, filePrefixForDivision, isDivisionTag, ladderDepth, shiftLadderTag, type LadderTag, type PretextDivisionTag, type PretextRootTag, } from './lib/pretext-divisions';
|
|
15
|
+
export { firstDivisionTag, isInlineContext, placeConvertedMarkup, reindentForContext, type PlacedMarkup, type PlacementContext, } from './lib/paste/place-markup';
|
|
16
|
+
export { outlineDivisions, pruneDivisions, type DivisionOutlineItem, type DivisionPath, type PruneDivisionsResult, } from './lib/select/divisions';
|
|
17
|
+
export { retargetFragment, retargetFragmentToDepth, dedupeXmlIds, prepareInsertSource, PROJECT_DESTINATION, type ImportDestination, type ProjectDestination, type InsertDestination, type PreparedInsertSource, type RetargetFragmentResult, type DedupeXmlIdsOptions, type DedupeXmlIdsResult, type IdRenameContext, type XmlIdRename, } from './lib/insert';
|
|
14
18
|
export { DEFAULT_IMPORT_MODE, filesForImportMode, assetsForImportMode, hasNativeImportMode, projectForImportMode, resolveImportMode, formatWarningLine, type ImportMode, } from './lib/import-mode';
|
|
15
19
|
export { cleanLatex, fixesToWarnings } from './lib/clean/clean-latex';
|
|
16
20
|
export type { CleanLatexOptions, CleanLatexResult, } from './lib/clean/clean-latex';
|
|
@@ -20,8 +24,9 @@ export { expandPretextIncludes } from './lib/clean/pretext-includes';
|
|
|
20
24
|
export type { CleaningWarning, CleaningSeverity, CleaningAction, } from './lib/clean/warnings';
|
|
21
25
|
export { buildPretextProjectFiles, detectDocumentKind, renderProjectPtx, renderPublicationPtx, } from './lib/layout';
|
|
22
26
|
export type { BuildProjectFilesOptions, BuildProjectFilesResult, DocumentKind, } from './lib/layout';
|
|
23
|
-
export { buildDivisionPool, resolveSplitLevel, buildNativeDivisionPool, sanitizeRef, serializeProjectToFiles, serializeProjectToPlusPayload, divisionChildRefs, } from './lib/pool';
|
|
24
|
-
export type { BuildDivisionPoolOptions, BuildDivisionPoolResult, BuildNativeDivisionPoolOptions, SerializeProjectFilesOptions, SerializedProjectFiles, } from './lib/pool';
|
|
25
|
-
export type { SourceFormat, ProjectLayout, ConversionContext, ConvertedPretextResult, UploadStatusType, UploadStatusMessage, UploadSourceType, ImportedProject, ImportedDivision, ImportedDivisionType, ImportedAsset, PlusProjectPayload, PlusDivisionAttributes, PlusAssetAttributes, PlusAssetFile, ImportedProjectResult, ImportedProjectSuccess, ImportedProjectError, } from './lib/types';
|
|
27
|
+
export { buildDivisionPool, resolveSplitLevel, buildNativeDivisionPool, sanitizeRef, serializeProjectToFiles, serializeProjectToRecords, serializeInsertToRecords, serializeProjectToPlusPayload, recordsToPlusPayload, serializeInsertFiles, serializeForDestination, divisionChildRefs, } from './lib/pool';
|
|
28
|
+
export type { BuildDivisionPoolOptions, BuildDivisionPoolResult, BuildNativeDivisionPoolOptions, SerializeProjectFilesOptions, SerializedProjectFiles, SerializeInsertOptions, SerializedInsert, SerializedInsertRecords, SerializeForDestinationOptions, SerializedForDestination, } from './lib/pool';
|
|
29
|
+
export type { SourceFormat, ProjectLayout, ConversionContext, ConvertedPretextResult, UploadStatusType, UploadStatusMessage, UploadSourceType, ImportedProject, ImportedDivision, ImportedDivisionType, ImportedAsset, ProjectRecords, DivisionRecord, AssetRecord, PlusProjectPayload, PlusDivisionAttributes, PlusAssetAttributes, PlusAssetFile, ImportedProjectResult, ImportedProjectSuccess, ImportedProjectError, InsertRecord, } from './lib/types';
|
|
26
30
|
export { createWorkerEngine, runConversionInWorker, ConversionCancelledError, type ConversionWorker, type WorkerEngineOptions, type RunningConversion, } from './worker/worker-engine';
|
|
27
31
|
export type { WorkerRequest, WorkerResponse, ConvertRequest, ResultResponse, ErrorResponse, } from './worker/protocol';
|
|
32
|
+
export { PANDOC_ACCEPT_EXTENSIONS, PANDOC_BINARY_FORMATS, PANDOC_EXTENSION_FORMATS, fileExtension, pandocFormatForFileName, createPandocEngine, createRemotePandocEngine, describeRemotePandocFailure, extractPandocErrorDetail, DEFAULT_REMOTE_PANDOC_TIMEOUT_MS, type PandocInputFormat, type PandocBridge, type PandocEngineOptions, type RemotePandocEngineOptions, } from './lib/pandoc';
|