revise 2.1.0 → 3.0.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 +47 -1088
- package/LICENSE +24 -41
- package/README.md +103 -26
- package/agent.d.ts +139 -0
- package/chunks/chunk-U5X47PZ6.js +135 -0
- package/chunks/chunk-U6YKQBKL.js +15 -0
- package/chunks/chunk-ZLQVPMBN.js +1650 -0
- package/chunks/package-5SHL5FOJ.js +14 -0
- package/chunks/render-QD5VWKSV.js +109 -0
- package/cli-output.schema.json +1984 -0
- package/cli.js +3604 -0
- package/document.d.ts +320 -0
- package/docx.d.ts +73 -0
- package/errors.d.ts +14 -0
- package/index.d.ts +13 -967
- package/index.js +31 -1
- package/legacy/editor.d.ts +19 -0
- package/legacy/editor.js +16 -0
- package/legacy/server.d.ts +37 -0
- package/legacy/server.js +25 -0
- package/legacy/style.css +2 -0
- package/package.d.ts +23 -0
- package/package.json +49 -55
- package/render.d.ts +27 -0
- package/FONT-LICENSE-HAN-EXT-B.txt +0 -91
- package/FONT-LICENSE-KATEX.txt +0 -95
- package/FONT-LICENSE-LIBERATION.txt +0 -102
- package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +0 -93
- package/FONT-LICENSE-NOTO-SANS-SC.txt +0 -93
- package/FONT-LICENSE-NOTO.txt +0 -94
- package/FONT-LICENSE-SOURCE-CODE-PRO.txt +0 -94
- package/FONT-LICENSE-SOURCE-SERIF-4.txt +0 -93
- package/THIRD-PARTY-NOTICES.md +0 -3376
- package/assets/historyMaterializeWorker-C4uxcZEh.js +0 -607
- package/backend.d.ts +0 -155
- package/backend.js +0 -3
- package/chunks/AgentPageRenderer-BFB0arQL.js +0 -1
- package/chunks/AgentPageRenderer-Dn6SaRjW.js +0 -1
- package/chunks/AttachmentDocumentImporter-BHDJAdky.js +0 -1
- package/chunks/AttachmentDocumentImporter-CxOZqzt1.js +0 -1
- package/chunks/BidiText-C8PBPSQY.js +0 -160
- package/chunks/ColorParserFull-BKH72fK8.js +0 -446
- package/chunks/DocumentMutator-4vBJQ74L.js +0 -31
- package/chunks/DocumentScrubber-COPepQKE.js +0 -1
- package/chunks/DocumentScrubber-Cf_QqHhF.js +0 -1
- package/chunks/DocumentScrubber-DS4LFDKS.js +0 -18
- package/chunks/DocumentStylesheet-byN5dtC6.js +0 -7
- package/chunks/DocxConverter-BCEB7jWY.js +0 -1083
- package/chunks/DocxConverter-C3NflpDr.js +0 -11
- package/chunks/DocxConverter-D9ZNn4nX.js +0 -11
- package/chunks/DocxGraft-Ba63IRP4.js +0 -1
- package/chunks/DocxGraft-DjERgl-z.js +0 -7
- package/chunks/DocxGraft-cYlmw4Ab.js +0 -1
- package/chunks/FileImporter-CHXj9sNX.js +0 -1
- package/chunks/FileImporter-DetvRoJc.js +0 -1
- package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +0 -3
- package/chunks/HtmlConverter-Sd9t49vH.js +0 -267
- package/chunks/ListNumbering-Qlu6AuRZ.js +0 -23
- package/chunks/MarkdownConverter-BdJgh8xt.js +0 -57
- package/chunks/MathRenderer-B0Y1h1JU.js +0 -62
- package/chunks/OdtConverter-BKtyx012.js +0 -1
- package/chunks/OdtConverter-Ce9j8PRt.js +0 -1
- package/chunks/OdtConverter-D709qfYb.js +0 -31
- package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +0 -36
- package/chunks/PdfConverter-BA8XLTAM.js +0 -21
- package/chunks/PdfConverter-CkDClffR.js +0 -438
- package/chunks/PdfConverter-CxLxd-LJ.js +0 -21
- package/chunks/PdfImportService-CQCgsRX1.js +0 -2
- package/chunks/PdfImportService-xl7fstr-.js +0 -2
- package/chunks/RtfConverter-BZOnMUGH.js +0 -14
- package/chunks/RtfConverter-Bs81AfXt.js +0 -14
- package/chunks/RtfConverter-DfuE5olb.js +0 -45
- package/chunks/TableBorders-Cdkc62cX.js +0 -30
- package/chunks/TableGrid-DbroRucl.js +0 -12
- package/chunks/TextFileDecoder--rsVs3NR.js +0 -9
- package/chunks/TxtConverter-C-oiFUAp.js +0 -14
- package/chunks/UnicodeUtils-CXtusU4g.js +0 -10
- package/chunks/XmlConverter-C0FnrVYk.js +0 -70
- package/chunks/XmlConverter-CQa8baOF.js +0 -2
- package/chunks/XmlConverter-DjEYaIyf.js +0 -2
- package/chunks/__vite-browser-external-l0sNRNKZ.js +0 -0
- package/chunks/_commonjsHelpers-DaMA6jEr.js +0 -2
- package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +0 -1
- package/chunks/_revise-sdk-lazy-harfbuzz-X8gnYTZL.js +0 -1
- package/chunks/ar-BdmGnaKI.js +0 -14
- package/chunks/backend-BIhAX-Gi.js +0 -484
- package/chunks/base64-Qx0OzT4p.js +0 -196
- package/chunks/browser-module-CFmqfGkE.js +0 -1791
- package/chunks/browser-module-CYGCfEyx.js +0 -3
- package/chunks/browser-module-DgvTMhpA.js +0 -3
- package/chunks/bundle.min-DRpfgV69.js +0 -782
- package/chunks/capture-BAJ2in5p.js +0 -9
- package/chunks/carrier-C5VZRMxZ.js +0 -6
- package/chunks/de-DldIXRFC.js +0 -14
- package/chunks/es-CnyKlSPK.js +0 -14
- package/chunks/footnoteFlatten-Bekh8ZfM.js +0 -6
- package/chunks/graftExport-CRRm1Oe_.js +0 -82
- package/chunks/html2canvas.esm-CntiHiYW.js +0 -997
- package/chunks/index-B1idHquf.js +0 -1094
- package/chunks/index-BWdRWxoH.js +0 -1807
- package/chunks/index-C-4H81OE.js +0 -378
- package/chunks/index-iZC8xN0t.js +0 -378
- package/chunks/index.es-Bwt05m_b.js +0 -5
- package/chunks/index.es-CI0QPo8w.js +0 -780
- package/chunks/index.es-DAQD57G4.js +0 -5
- package/chunks/jspdf.es.min-CnNRolk9.js +0 -77
- package/chunks/jspdf.es.min-DU74zN8b.js +0 -1792
- package/chunks/jspdf.es.min-DlTF8uTw.js +0 -77
- package/chunks/jszip.min-CPW0h1Kx.js +0 -476
- package/chunks/katex-DWj8TvwO.js +0 -1462
- package/chunks/pdf-BLWDCiFF.js +0 -1828
- package/chunks/persistInlineDocumentImages-DQj2iaqg.js +0 -1
- package/chunks/pseudoLocale-BoJwIubw.js +0 -1
- package/chunks/pseudoLocale-DWAm7Dpa.js +0 -1
- package/chunks/purify.es-BwLardii.js +0 -107
- package/chunks/serverDocumentSession-DASrQAbW.js +0 -15
- package/chunks/signatures-CBF7NZUy.js +0 -17
- package/chunks/tree-sitter-D6zWWUMP.js +0 -4
- package/chunks/wasmInline.generated-CBYFkdSM.js +0 -1
- package/chunks/web-tree-sitter-BXGZGnNj.js +0 -2
- package/full.js +0 -1
- package/root.d.ts +0 -5
- package/root.js +0 -2
- package/serverToolContract.d.ts +0 -391
- package/serverToolInputs.generated.d.ts +0 -250
- package/style.css +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// revise: MIT License. https://revise.io/developer/docs
|
|
2
|
+
import {
|
|
3
|
+
CAT_MATCH_LIMIT,
|
|
4
|
+
catPart,
|
|
5
|
+
listParts,
|
|
6
|
+
patchPackage
|
|
7
|
+
} from "./chunk-U5X47PZ6.js";
|
|
8
|
+
import "./chunk-U6YKQBKL.js";
|
|
9
|
+
export {
|
|
10
|
+
CAT_MATCH_LIMIT,
|
|
11
|
+
catPart,
|
|
12
|
+
listParts,
|
|
13
|
+
patchPackage
|
|
14
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// revise: MIT License. https://revise.io/developer/docs
|
|
2
|
+
import {
|
|
3
|
+
ReviseError
|
|
4
|
+
} from "./chunk-U6YKQBKL.js";
|
|
5
|
+
|
|
6
|
+
// src/embed-sdk/lib/render.ts
|
|
7
|
+
import { engineModules } from "@reviseio/engine";
|
|
8
|
+
var VIEW_NAMES = {
|
|
9
|
+
tracked: "show-tracked-changes",
|
|
10
|
+
accepted: "show-with-tracked-changes-accepted",
|
|
11
|
+
original: "show-before-tracked-changes"
|
|
12
|
+
};
|
|
13
|
+
async function loadCanvasFactory() {
|
|
14
|
+
const attempts = [];
|
|
15
|
+
for (const moduleName of ["@napi-rs/canvas", "canvas"]) {
|
|
16
|
+
try {
|
|
17
|
+
const mod = await import(
|
|
18
|
+
/* @vite-ignore */
|
|
19
|
+
moduleName
|
|
20
|
+
);
|
|
21
|
+
const create = mod.createCanvas ?? mod.default?.createCanvas;
|
|
22
|
+
if (create) return create;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
attempts.push(
|
|
25
|
+
`${moduleName}: ${error.message.split("\n")[0]}`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
throw new ReviseError(
|
|
30
|
+
`Rendering pages needs a Node canvas. Install one next to revise: npm i @napi-rs/canvas
|
|
31
|
+
(${attempts.join("; ")})`,
|
|
32
|
+
"canvas_missing"
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
async function renderPages(ydoc, documentId, options) {
|
|
36
|
+
const createCanvas = await loadCanvasFactory();
|
|
37
|
+
const [
|
|
38
|
+
{ DocumentSession },
|
|
39
|
+
{ renderDocumentPagesForAgent, createHeadlessPageRenderHost },
|
|
40
|
+
{ createStandardLayout },
|
|
41
|
+
{ resolvePageLayoutSettings, getPageDimensionsPx }
|
|
42
|
+
] = await Promise.all([
|
|
43
|
+
engineModules.documentSession(),
|
|
44
|
+
engineModules.pageRenderer(),
|
|
45
|
+
engineModules.documentLayout(),
|
|
46
|
+
engineModules.pageLayout()
|
|
47
|
+
]);
|
|
48
|
+
const session = new DocumentSession(documentId, ydoc, void 0, {
|
|
49
|
+
disableHistory: true,
|
|
50
|
+
disableProposalPersistence: true
|
|
51
|
+
});
|
|
52
|
+
const editor = createHeadlessPageRenderHost(session);
|
|
53
|
+
const settings = resolvePageLayoutSettings(
|
|
54
|
+
session.getWorkingDocument().pageLayout
|
|
55
|
+
);
|
|
56
|
+
const dimensions = getPageDimensionsPx(settings);
|
|
57
|
+
let result;
|
|
58
|
+
try {
|
|
59
|
+
result = await renderDocumentPagesForAgent({
|
|
60
|
+
editor,
|
|
61
|
+
pageLayoutSettings: settings,
|
|
62
|
+
layout: createStandardLayout({
|
|
63
|
+
...dimensions,
|
|
64
|
+
pageMargin: settings.marginLeftPx,
|
|
65
|
+
pageMarginTop: settings.marginTopPx,
|
|
66
|
+
pageMarginRight: settings.marginRightPx,
|
|
67
|
+
pageMarginBottom: settings.marginBottomPx,
|
|
68
|
+
pageMarginLeft: settings.marginLeftPx,
|
|
69
|
+
indentStepPx: settings.indentStepPx,
|
|
70
|
+
blockSpacingPx: settings.blockSpacingPx
|
|
71
|
+
}),
|
|
72
|
+
request: {
|
|
73
|
+
startPage: options.startPage ?? 1,
|
|
74
|
+
pageCount: options.pageCount ?? 1,
|
|
75
|
+
mode: options.layout ? "layout" : "appearance",
|
|
76
|
+
quality: options.quality ?? ((options.pageCount ?? 1) > 1 ? "compact" : "detailed"),
|
|
77
|
+
view: VIEW_NAMES[options.view ?? "tracked"]
|
|
78
|
+
},
|
|
79
|
+
createCanvas: () => createCanvas(1, 1)
|
|
80
|
+
});
|
|
81
|
+
} catch (error) {
|
|
82
|
+
const message = error.message;
|
|
83
|
+
if (/outside this \d+-page document/.test(message)) {
|
|
84
|
+
throw new ReviseError(message, "page_out_of_range");
|
|
85
|
+
}
|
|
86
|
+
if (error instanceof ReviseError) throw error;
|
|
87
|
+
throw new ReviseError(`Rendering failed: ${message}`, "render_failed", {
|
|
88
|
+
cause: error
|
|
89
|
+
});
|
|
90
|
+
} finally {
|
|
91
|
+
session.dispose();
|
|
92
|
+
}
|
|
93
|
+
const match = /^data:([^;]+);base64,([\s\S]*)$/.exec(result.dataUrl);
|
|
94
|
+
if (!match) throw new Error("The renderer returned an unexpected image.");
|
|
95
|
+
return {
|
|
96
|
+
bytes: new Uint8Array(Buffer.from(match[2], "base64")),
|
|
97
|
+
mimeType: match[1],
|
|
98
|
+
width: result.width,
|
|
99
|
+
height: result.height,
|
|
100
|
+
pages: result.pages,
|
|
101
|
+
totalPages: result.totalPages,
|
|
102
|
+
placeholderImageCount: result.placeholderImageCount,
|
|
103
|
+
failedImageCount: result.failedImageCount,
|
|
104
|
+
description: result.snapshot.description
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
renderPages
|
|
109
|
+
};
|