@pretextbook/import 0.16.0 → 0.17.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/README.md +39 -0
- package/dist/engine-routing-5CVs5pr5.cjs +3 -0
- package/dist/{engine-routing-DorSgyrU.js → engine-routing-DDxL53jG.js} +52 -43
- package/dist/import.css +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +182 -39
- package/dist/lib/engine-routing.d.ts +13 -0
- package/dist/react/import-wizard.d.ts +46 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react.cjs +2 -2
- package/dist/react.js +628 -534
- package/package.json +3 -3
- package/dist/engine-routing-3ULYdLy2.cjs +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pretextbook/import",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Shared import helpers for converting LaTeX/Markdown/PreTeXt into PreTeXt for VS Code and web apps",
|
|
5
5
|
"author": "Oscar Levin",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"test": "vitest run"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@pretextbook/completions": "^0.5.
|
|
58
|
-
"@pretextbook/format": "^0.6.
|
|
57
|
+
"@pretextbook/completions": "^0.5.1",
|
|
58
|
+
"@pretextbook/format": "^0.6.1",
|
|
59
59
|
"@pretextbook/latex-pretext": "^0.4.0",
|
|
60
60
|
"@pretextbook/latex-style-pretext": "^0.5.2",
|
|
61
61
|
"@pretextbook/remark-pretext": "^0.2.0",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const h=require("./upload-COaS_4pG.cjs");function d(e,t){const n=e.length===0?[]:e.split(`
|
|
2
|
-
`),o=t.length===0?[]:t.split(`
|
|
3
|
-
`);if(n.length+o.length>j)return[...n.map((c,f)=>({op:"remove",text:c,beforeLine:f+1})),...o.map((c,f)=>({op:"add",text:c,afterLine:f+1}))];const r=Array.from({length:n.length+1},()=>new Array(o.length+1).fill(0));for(let c=n.length-1;c>=0;c--)for(let f=o.length-1;f>=0;f--)r[c][f]=n[c]===o[f]?r[c+1][f+1]+1:Math.max(r[c+1][f],r[c][f+1]);const a=[];let i=0,s=0;for(;i<n.length&&s<o.length;)n[i]===o[s]?(a.push({op:"keep",text:n[i],beforeLine:i+1,afterLine:s+1}),i++,s++):r[i+1][s]>=r[i][s+1]?(a.push({op:"remove",text:n[i],beforeLine:i+1}),i++):(a.push({op:"add",text:o[s],afterLine:s+1}),s++);for(;i<n.length;)a.push({op:"remove",text:n[i],beforeLine:++i});for(;s<o.length;)a.push({op:"add",text:o[s],afterLine:++s});return a}const j=2e4;function m(e){let t=0,n=0;for(const o of e)o.op==="add"?t++:o.op==="remove"&&n++;return{added:t,removed:n}}function g(e,t=2){const n=e.map((i,s)=>i.op==="keep"?-1:s).filter(i=>i>=0);if(n.length===0)return[];const o=[];let r=Math.max(0,n[0]-t),a=Math.min(e.length-1,n[0]+t);for(const i of n.slice(1)){if(i-t<=a+1){a=Math.min(e.length-1,i+t);continue}o.push({lines:e.slice(r,a+1)}),r=Math.max(0,i-t),a=Math.min(e.length-1,i+t)}return o.push({lines:e.slice(r,a+1)}),o}function k(e,t=e.splitLevel){if(e.cleanChunks.length===0)return[];const n=h.mergeChunksAtLevel(e.cleanChunks,t),o=A(n),{pathByRef:r}=h.serializeProjectToFiles(e.project,{mainSourcePath:e.projectLayout.mainSourcePath,publicationPath:e.projectLayout.publicationPath,projectFilePath:e.projectLayout.projectFilePath,includeScaffold:!e.projectLayout.preserved}),a=[];for(const i of e.project.divisions){const s=r[i.xmlId];if(!s)continue;const c=i.isRoot?n.find(p=>p.kind==="preamble"||p.kind==="lead"):o.get(i.title);if(!c)continue;const f=d(c.before,c.after);a.push({path:s,title:i.title,before:c.before,after:c.after,stats:m(f),hunks:g(f),fixCount:c.fixes.length})}return a.sort((i,s)=>i.path.localeCompare(s.path))}function A(e){const t=new Map;for(const o of e)o.kind!=="division"||!o.title||t.set(o.title,t.has(o.title)?null:o);const n=new Map;for(const[o,r]of t)r&&n.set(o,r);return n}const v="converted";function M(e){return e.nativeOutputFiles!==void 0}function C(e,t=v){return t==="native"&&!M(e)?"converted":t}function T(e,t){return t==="native"?e.nativeProject??e.project:e.project}function y(e,t){return t==="converted"?e.outputFiles:e.nativeOutputFiles??e.files}function P(e,t){return t==="converted"?e.outputAssets:e.assets}function S(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}`}const E=[".tex",".md",".markdown",".ptx",".xml",".zip",".gz",".tar.gz",".tgz"];function l(e){return e.acceptExtensions??E}function F(e,t){const n=e.toLowerCase();return t.some(o=>n.endsWith(o))}function u(e,t){return F(t,l(e))}function L(e){const t=new Set,n=[];for(const o of e)for(const r of l(o))t.has(r)||(t.add(r),n.push(r));return n}function x(e){for(let t=1;t<e.length;t++){const n=e.slice(0,t);if(l(e[t]).some(r=>n.some(a=>l(a).includes(r))))return e[t]}}function I(e,t){return e.find(n=>u(n,t))}function b(e,t){const n=I(e,t),o=x(e);if(!(!n||!o||o.id===n.id))return u(o,t)?o:void 0}function _(e,t){return`Cannot import ${e}: no converter reads that file type. Supported types are ${L(t).join(", ")}.`}exports.DEFAULT_ACCEPT_EXTENSIONS=E;exports.DEFAULT_IMPORT_MODE=v;exports.allAcceptExtensions=L;exports.alternateEngine=x;exports.alternateFor=b;exports.assetsForImportMode=P;exports.diffHunks=g;exports.diffLines=d;exports.diffStats=m;exports.engineAccepts=u;exports.engineExtensions=l;exports.fileChangesForImport=k;exports.filesForImportMode=y;exports.formatWarningLine=S;exports.hasNativeImportMode=M;exports.matchesExtension=F;exports.projectForImportMode=T;exports.resolveImportMode=C;exports.routeEngine=I;exports.unsupportedFileMessage=_;
|