@reviseio/engine 3.0.0 → 3.1.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/CHANGELOG.md +33 -0
- package/assets/{historyMaterializeWorker-Kl0syEbc.js → historyMaterializeWorker-BMHTnStL.js} +131 -130
- package/chunks/{AgentHtmlConverter-BnK7NaYA.js → AgentHtmlConverter-B5qstcmM.js} +129 -128
- package/chunks/{AgentPageRenderer-DLwq6nAa.js → AgentPageRenderer-JMhCw-hi.js} +4 -4
- package/chunks/BlockDiff-C8eiZ-sf.js +45 -0
- package/chunks/{CanvasRenderer-Bqsj1S0p.js → CanvasRenderer-C2vAzLWM.js} +12 -12
- package/chunks/DocumentCompare-DX4RWeSV.js +10 -0
- package/chunks/{DocumentLayoutEngine-7iOYvyVb.js → DocumentLayoutEngine-BhcWXkeu.js} +45 -45
- package/chunks/{DocumentMutator-DIrZBuLr.js → DocumentMutator-FEFU1YM0.js} +6 -6
- package/chunks/DocumentOutline-BOZoTohH.js +4 -0
- package/chunks/{DocumentScrubber-Cz8Q05hF.js → DocumentScrubber-C4N3Qagm.js} +1 -1
- package/chunks/{DocumentSession-lXSXqua5.js → DocumentSession-gZHWP7By.js} +1 -1
- package/chunks/{DocxConverter-BfDw7777.js → DocxConverter-BOyLn5eZ.js} +709 -703
- package/chunks/{DocxGraft-D0uCnGCo.js → DocxGraft-BbE-AaM5.js} +2 -2
- package/chunks/{HtmlConverter-7Xj_g9Jr.js → HtmlConverter-BlzwsPEn.js} +3 -3
- package/chunks/MarkdownConverter-BHVskVXI.js +59 -0
- package/chunks/{OdtConverter-GwRDMnwS.js → OdtConverter-BdmBFOD1.js} +1 -1
- package/chunks/{OfficeImportShared-nlMtIUni.js → OfficeImportShared-B2XJgnDO.js} +4 -4
- package/chunks/{PdfConverter-yOlWiVIj.js → PdfConverter-DZMCHDAo.js} +6 -6
- package/chunks/{RtfConverter--wLd0qrw.js → RtfConverter-RqE-xZcW.js} +66 -66
- package/chunks/{TableBorders-C5pNsuxP.js → TableBorders-ARyTi49V.js} +1 -1
- package/chunks/TextDecoding-IPbuUqcC.js +2 -0
- package/chunks/TextFileDecoder-BZBBejlR.js +10 -0
- package/chunks/{TxtConverter-BoRVCDZw.js → TxtConverter-EPQtb6A6.js} +1 -1
- package/chunks/{Typography-DAGM5kfI.js → Typography-XR6scRNV.js} +9 -9
- package/chunks/XmlConverter-9sFRFaza.js +55 -0
- package/chunks/{capture-Dtinb4bY.js → capture-DhGn0CWA.js} +1 -1
- package/chunks/{carrier-RNy67HN4.js → carrier-D58g-gw4.js} +1 -1
- package/chunks/{chromeImageLayout-bgHYmqTp.js → chromeImageLayout-DeYYS8YP.js} +1 -1
- package/chunks/{engine-TnK8N-gT.js → engine-C5fxuZJo.js} +140 -140
- package/chunks/{footnoteFlatten-BcKaWzVs.js → footnoteFlatten-coCVFd3c.js} +1 -1
- package/chunks/{graftExport-DxAALMHp.js → graftExport-FBGE2qvt.js} +1 -1
- package/chunks/{index-CTti7wRd.js → index-Cezk1s_y.js} +4 -4
- package/chunks/{serverDocumentSession-BmYdjC6e.js → serverDocumentSession-LMu3kocH.js} +559 -560
- package/chunks/{signatures-CU2LMLBp.js → signatures-DsJnnIqV.js} +1 -1
- package/chunks/textExtraction-Bqaqt1Kg.js +2 -0
- package/engine.js +2 -2
- package/package.json +2 -2
- package/chunks/BlockDiff-BdlcKY-t.js +0 -42
- package/chunks/DocumentCompare-BqyiP87r.js +0 -6
- package/chunks/MarkdownConverter-cnW_oePY.js +0 -57
- package/chunks/TextFileDecoder--rsVs3NR.js +0 -9
- package/chunks/XmlConverter-CO8Z28dX.js +0 -55
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import{d as A}from"./TextDecoding-IPbuUqcC.js";import{a as k}from"./engine-C5fxuZJo.js";import{b as S}from"./TableGrid-DbroRucl.js";import{d as T}from"./BlockDiff-C8eiZ-sf.js";function M(d,e,n){const t=(i,c)=>i.
|
|
2
|
+
length>0&&i.every(l=>l.type==="paragraph"&&l.children.length>0&&l.children.every(r=>r.marks?.[c]&&!r.marks.layeredInsertion));if(!t(d,"deletion")||!t(e,"insertion"))return null;const s=T(d,e,{nextId:n,
|
|
3
|
+
nextBlockId:k,label:"Revise bill",authorOf:i=>i?.suggestionAuthorName});return s?s.blocks:null}const E={division:0,title:0,subtitle:0,chapter:0,subchapter:0,part:0,subpart:0,section:0,subsection:1,paragraph:2,
|
|
4
|
+
subparagraph:3,clause:4,subclause:5,item:6,subitem:7},C={division:"Division",title:"Title",subtitle:"Subtitle",chapter:"Chapter",subchapter:"Subchapter",part:"Part",subpart:"Subpart",section:"Sec."},y=new Set(
|
|
5
|
+
["added-phrase","deleted-phrase","bold","italic","underline","strike","superscript","subscript","quote","term","short-title","act-name","external-xref","internal-xref","enum-in-header","header-in-text",
|
|
6
|
+
"definition","linebreak","nobreak","sponsor","cosponsor","committee-name","text-to-insert","text-to-strike-out","omitted-text","inline-comment"]),I=new Set(["graphic","formula","footnote","footnote-re\
|
|
7
|
+
f","spanspec","entrytbl"]),m=d=>Array.from(d.children),g=(d,e)=>m(d).find(n=>n.localName===e),b=d=>d.replace(/[\t\r\n ]+/g," "),q={id:"us-congress-bill",label:"U.S. Congressional bills (bill.dtd)",matches(d){
|
|
8
|
+
const e=d.documentElement;if(e.localName!=="bill"||e.namespaceURI||!g(e,"legis-body"))return!1;const n=d.doctype;if(n)return n.name==="bill"&&(n.publicId==="-//US Congress//DTDs/bill.dtd//EN"||!n.publicId&&
|
|
9
|
+
/(?:^|\/)bill\.dtd$/i.test(n.systemId));const t=g(e,"form");return!!t&&!!g(t,"congress")&&!!g(t,"legis-num")},parse(d){return new L().parse(d)}};class L{constructor(){this.revisionCount=0,this.revisions=
|
|
10
|
+
new WeakMap,this.committees=new Map,this.usedIds=new Set}id(){let e;do e=k();while(this.usedIds.has(e));return this.usedIds.add(e),e}parse(e){const n=e.documentElement;for(const o of Array.from(n.getElementsByTagName(
|
|
11
|
+
"committee-name"))){const h=o.getAttribute("committee-id");h&&this.committees.set(h,b(o.textContent??"").trim())}for(const o of Array.from(n.getElementsByTagName("*")))if(I.has(o.localName))throw new Error(
|
|
12
|
+
`Unsupported Congressional XML element: <${o.localName}>. This bill requires content the XML importer does not yet support.`);const t=this.context(n,{marks:{},indent:0,quoted:0}),s=[],i=m(n),c=i.map(o=>this.
|
|
13
|
+
blocks(o,t));for(let o=0;o<i.length;o++){const h=i[o],p=c[o],f=i[o+1];if(h.localName==="legis-body"&&f?.localName==="legis-body"&&f.getAttribute("display-enacting-clause")==="no-display-enacting-claus\
|
|
14
|
+
e"){const v=c[o+1],N=h.getAttribute("display-enacting-clause")!=="no-display-enacting-clause"?1:0,w=M(p.slice(N),v,()=>`congressdiff-${++this.revisionCount}`);if(w){s.push(...p.slice(0,N),...w),o++;continue}}
|
|
15
|
+
s.push(...p)}if(!s.length)throw new Error("The Congressional XML bill contains no readable content.");const l=g(n,"form"),r=l&&g(l,"legis-num")?.textContent?.trim(),a=n.getElementsByTagName("short-tit\
|
|
16
|
+
le")[0]?.textContent?.trim(),u=r?[r,a].filter(Boolean).join(" — "):e.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/","title")[0]?.textContent?.trim();return{type:"doc",children:s,...u?{title:u}:
|
|
17
|
+
{}}}context(e,n){const t={...n.marks},s=e.localName,i=e.getAttribute("changed")??(s==="added-phrase"?"added":s==="deleted-phrase"?"deleted":null);if(i==="added"||i==="deleted"){const l=i==="added"?"in\
|
|
18
|
+
sertion":"deletion",r=e.getAttribute("reporting-committee")||e.getAttribute("committee-id"),a=r?this.committees.get(r)??r:void 0;if(!t[l]||a&&a!==t.suggestionAuthorName){if(t.deletion&&l==="insertion")
|
|
19
|
+
throw new Error("Unsupported Congressional XML revision: insertion nested inside a deletion.");let u=this.revisions.get(e);u||(u={[l]:!0,suggestionId:`congressrev-${++this.revisionCount}`,suggestionSource:"\
|
|
20
|
+
manual",suggestionAuthorType:"human",suggestionLabel:l==="insertion"?"Insert":"Delete",...a?{suggestionAuthorName:a}:{}},this.revisions.set(e,u)),t.insertion&&l==="deletion"&&(t.layeredInsertion=JSON.
|
|
21
|
+
stringify({id:t.suggestionId,source:t.suggestionSource,authorType:t.suggestionAuthorType,authorName:t.suggestionAuthorName,label:t.suggestionLabel})),delete t.insertion,delete t.deletion,delete t.suggestionAuthorName,
|
|
22
|
+
Object.assign(t,u)}}s==="bold"&&(t.bold=!0),s==="italic"&&(t.italic=!0),s==="underline"&&(t.underline=!0),s==="superscript"&&(t.superscript=!0),s==="subscript"&&(t.subscript=!0);const c=e.getAttribute(
|
|
23
|
+
"href");return c&&/^(https?:\/\/|#)/i.test(c.trim())&&(t.link=c.trim()),s==="internal-xref"&&e.getAttribute("idref")&&(t.link=`#${e.getAttribute("idref")}`),{...n,marks:t,style:e.getAttribute("style")??
|
|
24
|
+
n.style}}text(e,n){return{type:"text",text:e,marks:{...n.marks}}}inline(e,n){const t=this.context(e,n);if(e.localName==="linebreak")return[this.text(`
|
|
25
|
+
`,t)];const s=[],i=e.localName==="quote"||e.localName==="term";i&&s.push(this.text(t.quoted?"‘":"“",t));for(const c of Array.from(e.childNodes))c.nodeType===3||c.nodeType===4?s.push(this.text(b(c.
|
|
26
|
+
textContent??""),t)):c.nodeType===1&&s.push(...this.inline(c,i?{...t,quoted:t.quoted+1}:t));return i&&s.push(this.text(t.quoted?"’":"”",t)),s}paragraph(e,n,t,s){for(;e.length&&!e[0].text.trim();)e.
|
|
27
|
+
shift();for(;e.length&&!e[e.length-1].text.trim();)e.pop();if(!e.length)return null;e[0].text=e[0].text.replace(/^ +/,""),e[e.length-1].text=e[e.length-1].text.replace(/ +$/,""),n.quoted&&e.unshift(this.
|
|
28
|
+
text(n.quoted>1?"‘":"“",n));const i=t?.getAttribute("id");return i&&(e[0].marks={...e[0].marks,bookmark:i}),{type:"paragraph",id:this.id(),children:e,...s?{heading:s,keepNext:!0}:{},...n.indent?{leftIndent:Math.
|
|
29
|
+
min(n.indent,6)}:{}}}blocks(e,n){const t=e.localName;if(t==="metadata")return[];const s=this.context(e,n);if(Object.prototype.hasOwnProperty.call(E,t))return this.structure(e,{...s,indent:E[t]+(s.quoted?
|
|
30
|
+
1:0)});if(t==="table")return m(e).filter(r=>r.localName==="tgroup").length?m(e).flatMap(r=>r.localName==="tgroup"?[this.table(r,this.context(r,s))]:this.blocks(r,s)):[this.table(e,s)];if(t==="quoted-b\
|
|
31
|
+
lock"){const r=m(e).filter(o=>o.localName!=="after-quoted-block").flatMap(o=>this.blocks(o,{...s,quoted:s.quoted+1,indent:s.indent+1})),a=r[r.length-1],u=g(e,"after-quoted-block");if(a?.type==="paragr\
|
|
32
|
+
aph")a.children.push(this.text(s.quoted?"’":"”",s)),u&&a.children.push(...this.inline(u,s));else if(u){const o=this.paragraph([this.text(s.quoted?"’":"”",s),...this.inline(u,s)],s);o&&r.push(o)}
|
|
33
|
+
return r}if(!m(e).some(r=>!y.has(r.localName))){const r=this.paragraph(this.inline(e,n),s,e);if(r&&(t==="legis-num"||t==="legis-type")){r.align="center";for(const a of r.children)a.marks={...a.marks,bold:!0}}
|
|
34
|
+
return r?[r]:[]}const i=[];if(t==="legis-body"&&e.getAttribute("display-enacting-clause")!=="no-display-enacting-clause"){const r=this.paragraph([this.text("Be it enacted by the Senate and House of Re\
|
|
35
|
+
presentatives of the United States of America in Congress assembled,",s)],s);r&&i.push(r)}let c=[];const l=()=>{const r=this.paragraph(c,s);r&&i.push(r),c=[]};for(const r of Array.from(e.childNodes))if(r.
|
|
36
|
+
nodeType===3||r.nodeType===4)c.push(this.text(b(r.textContent??""),s));else if(r.nodeType===1){const a=r;y.has(a.localName)?c.push(...this.inline(a,s)):(l(),i.push(...this.blocks(a,s)))}return l(),i}structure(e,n){
|
|
37
|
+
const t=[],s=Object.prototype.hasOwnProperty.call(C,e.localName),i=g(e,"enum"),c=g(e,"header");let l=[];if(i&&(s&&l.push(this.text(e.localName==="section"&&n.style==="USC"?"§ ":`${C[e.localName]} `,n)),
|
|
38
|
+
l.push(...this.inline(i,n),this.text(" ",n))),c){const u=this.inline(c,n);for(const o of u)o.marks={...o.marks,bold:!0};l.push(...u)}const r=(u=!1)=>{const o=this.paragraph(l,n,t.length?void 0:e,u?e.localName===
|
|
39
|
+
"section"?2:1:void 0);o&&t.push(o),l=[]};s&&r(!0);let a=!0;for(const u of Array.from(e.childNodes))if(!(u===i||u===c)){if(u.nodeType===3||u.nodeType===4)u.textContent?.trim()&&l.push(this.text(b(u.textContent),
|
|
40
|
+
n));else if(u.nodeType===1){const o=u;if(o.localName==="text")a||r(),a&&!s&&c&&l.push(this.text(".—",n)),l.push(...this.inline(o,n)),a=!1;else if(y.has(o.localName))l.push(...this.inline(o,n));else{
|
|
41
|
+
r();const h=this.blocks(o,n),p=t[t.length-1];o.getAttribute("display-inline")==="yes-display-inline"&&p?.type==="paragraph"&&!p.heading&&h[0]?.type==="paragraph"&&(p.children.push(this.text(" ",n),...h[0].
|
|
42
|
+
children),h.shift()),t.push(...h)}}}return r(),t}table(e,n){const t=g(e,"tgroup")??e,s=new Map(m(t).filter(r=>r.localName==="colspec").map((r,a)=>[r.getAttribute("colname"),Number(r.getAttribute("coln\
|
|
43
|
+
um"))||a+1])),i=m(t).flatMap(r=>r.localName==="row"?[r]:["thead","tbody","tfoot"].includes(r.localName)?m(r).filter(a=>a.localName==="row"):[]);if(!i.length)throw new Error("Unsupported Congressional \
|
|
44
|
+
XML table: no rows.");const c={type:"table",id:this.id(),columnWidths:[],children:i.map(r=>({type:"table-row",id:this.id(),children:m(r).filter(a=>a.localName==="entry").map(a=>{const u=s.get(a.getAttribute(
|
|
45
|
+
"namest")),o=s.get(a.getAttribute("nameend")),h=u&&o?o-u+1:1,p=Number(a.getAttribute("morerows")??0)+1;if(a.hasAttribute("namest")&&(!u||!o)||!Number.isInteger(h)||h<1||h>100||!Number.isInteger(p)||p<
|
|
46
|
+
1||p>i.length)throw new Error("Unsupported Congressional XML table: invalid cell span.");const f=this.blocks(a,{...this.context(r,r.parentElement&&r.parentElement!==t?this.context(r.parentElement,n):n),
|
|
47
|
+
indent:0});return{type:"table-cell",id:this.id(),children:f.length?f:[{type:"paragraph",id:this.id(),children:[{type:"text",text:""}]}],...h>1?{colSpan:h}:{},...p>1?{rowSpan:p}:{}}})}))},l=S(c).cols;if(!l||
|
|
48
|
+
l>100)throw new Error("Unsupported Congressional XML table: invalid column count.");return c.columnWidths=Array(l).fill(100/l),c}}const x=[q];class X{static async parseFile(e){return this.fromBytes(new Uint8Array(
|
|
49
|
+
await e.arrayBuffer()))}static fromBytes(e){let n="utf-8";if(e[0]===255&&e[1]===254||e[0]===60&&e[1]===0&&e[2]===63&&e[3]===0)n="utf-16le";else if(e[0]===254&&e[1]===255||e[0]===0&&e[1]===60&&e[2]===0&&
|
|
50
|
+
e[3]===63)n="utf-16be";else if(!(e[0]===239&&e[1]===187&&e[2]===191)){const s=A(e.subarray(0,512),"windows-1252");n=/^<\?xml\s[^?]*\bencoding\s*=\s*["']([^"']+)["']/i.exec(s)?.[1]??n}let t;try{t=A(e,n,
|
|
51
|
+
{fatal:!0})}catch{throw new Error(`Invalid or unsupported XML encoding: ${n}.`)}return this.fromXml(t)}static fromXml(e){if(/<!ENTITY\s/i.test(e))throw new Error("XML entity declarations are not suppo\
|
|
52
|
+
rted.");const n=new DOMParser().parseFromString(e.replace(/^\uFEFF/,""),"application/xml");if(!n.documentElement||n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: the documen\
|
|
53
|
+
t is not well-formed.");const t=[[n.documentElement,0]];for(;t.length;){const[i,c]=t.pop();if(c>128)throw new Error("XML nesting exceeds the supported depth (128).");for(const l of Array.from(i.children))
|
|
54
|
+
t.push([l,c+1])}const s=x.find(i=>i.matches(n));if(!s)throw new Error(`Unsupported XML schema: <${n.documentElement.tagName}>. Supported: ${x.map(i=>i.label).join(", ")}.`);return s.parse(n)}}export{x as XML_SCHEMA_PARSERS,
|
|
55
|
+
X as XmlConverter};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as S,s as p,o as l,d as h,e as y,c as m,h as b,g as w,f as A,n as $,p as C,C as k}from"./signatures-
|
|
1
|
+
import{a as S,s as p,o as l,d as h,e as y,c as m,h as b,g as w,f as A,n as $,p as C,C as k}from"./signatures-DsJnnIqV.js";async function x(e){const t=globalThis.crypto?.subtle;if(t)try{const a=await t.
|
|
2
2
|
digest("SHA-256",e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));return Array.from(new Uint8Array(a),i=>i.toString(16).padStart(2,"0")).join("")}catch{}let s=3421674724,n=2216829733;for(let a=0;a<
|
|
3
3
|
e.length;a++){n^=e[a];const i=n*435+s*435%65536*65536>>>0;s=(s*435+Math.floor(n*435/4294967296)+n&4294967295)>>>0,n=i}return`fnv1a-${s.toString(16).padStart(8,"0")}${n.toString(16).padStart(8,"0")}`}function L(e,t,s){
|
|
4
4
|
const n=e.get(t);if(!n){e.set(t,{start:s,end:s});return}s<n.start&&(n.start=s),s>n.end&&(n.end=s)}function M(e){const t=e.docxSource;if(!t)return;const s={};for(const n of[...e.children,...e.chrome??[],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as b}from"./capture-
|
|
1
|
+
import{h as b}from"./capture-DhGn0CWA.js";const o="docx-carrier",i=25*1024*1024,u=512*1024,g=1;async function l(n,t,e){const c=e?.byteCap??i;if(t.byteLength>c)return{stored:!1,reason:"oversize"};const a=e?.
|
|
2
2
|
hash??await b(t),r=n.getMap(o),s=Math.ceil(t.byteLength/u);return n.transact(()=>{r.clear();const y={version:g,hash:a,byteLength:t.byteLength,chunkCount:s,chunkSize:u};r.set("meta",y);for(let h=0;h<s;h++)
|
|
3
3
|
r.set(`c${h}`,new Uint8Array(t.subarray(h*u,Math.min((h+1)*u,t.byteLength))))}),{stored:!0,hash:a}}function f(n){const t=n.getMap(o).get("meta");return!t||t.version!==g||typeof t.hash!="string"||typeof t.
|
|
4
4
|
byteLength!="number"||typeof t.chunkCount!="number"?null:{hash:t.hash,byteLength:t.byteLength}}function L(n){const t=n.getMap(o),e=t.get("meta");if(!e||e.version!==g)return null;const c=new Uint8Array(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as y,at as B,e as v,ad as T,h as z}from"./engine-
|
|
1
|
+
import{R as y,at as B,e as v,ad as T,h as z}from"./engine-C5fxuZJo.js";const F=8,H=4,W=10,C=8,$=8;function I(t,r,e){const o=(t??[]).filter(s=>s.side===r);if(o.length===0)return[];const a=s=>o.some(c=>c.
|
|
2
2
|
slot===s),h=e.textSlot??(e.isFirstPage&&a("first")?"first":e.pageNumber%2===0&&a("even")?"even":"default");return o.filter(s=>s.slot===h)}function L(t){const r=t.unit??1,e=F*r,o=Math.max(10*r,0);let a,
|
|
3
3
|
h;t.side==="header"?(a=e,h=t.marginTop-e,t.hasText&&(h=Math.max(o,t.marginTop/2)-(W+H)*r)):(a=t.pageHeight-t.marginBottom+e,h=t.pageHeight-e,t.hasText&&(a=t.pageHeight-Math.max(o,t.marginBottom/2)+(W+
|
|
4
4
|
H)*r));const s=h-a,c=t.pageWidth-t.marginLeft-t.marginRight;return s<C*r||c<=0?null:{bandTop:a,bandHeight:s,contentWidth:c}}function N(t,r){const e=t.unit??1,{bandHeight:o,contentWidth:a}=r,h=t.records.
|