revise 2.2.0 → 3.0.1
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 +56 -1182
- 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 +3609 -0
- package/document.d.ts +320 -0
- package/docx.d.ts +73 -0
- package/errors.d.ts +14 -0
- package/index.d.ts +13 -975
- 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-B51R08XN.js +0 -612
- package/backend.d.ts +0 -161
- package/backend.js +0 -3
- package/chunks/AgentPageRenderer-CH8kSTJn.js +0 -1
- package/chunks/AgentPageRenderer-P23XVguo.js +0 -1
- package/chunks/AttachmentDocumentImporter-B1WOaa7d.js +0 -1
- package/chunks/AttachmentDocumentImporter-CT_PJp_e.js +0 -1
- package/chunks/BidiText-Swm5fl9J.js +0 -160
- package/chunks/ColorParserFull-BKH72fK8.js +0 -446
- package/chunks/DocumentMutator-btiDK57e.js +0 -31
- package/chunks/DocumentScrubber-CMPfm_HF.js +0 -18
- package/chunks/DocumentScrubber-Cm2kH8op.js +0 -1
- package/chunks/DocumentScrubber-bJoKijol.js +0 -1
- package/chunks/DocumentStylesheet-DreoD7sD.js +0 -7
- package/chunks/DocxConverter-BcVG-p5K.js +0 -13
- package/chunks/DocxConverter-D2bO5RE-.js +0 -1125
- package/chunks/DocxConverter-haCfRuWb.js +0 -13
- package/chunks/DocxGraft-BRKh4mHQ.js +0 -1
- package/chunks/DocxGraft-BxSQtl12.js +0 -7
- package/chunks/DocxGraft-C9MBQCnf.js +0 -1
- package/chunks/FileImporter-CszqRfVU.js +0 -1
- package/chunks/FileImporter-DObFoCCn.js +0 -1
- package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +0 -3
- package/chunks/HtmlConverter-DwXB4IDh.js +0 -267
- package/chunks/ListNumbering-Qlu6AuRZ.js +0 -23
- package/chunks/MarkdownConverter-CUC8GgsS.js +0 -57
- package/chunks/MathRenderer-DT6GyJXb.js +0 -68
- package/chunks/OdtConverter-7h9HHMpL.js +0 -125
- package/chunks/OdtConverter-Ct4qypJk.js +0 -6
- package/chunks/OdtConverter-DFl__sJc.js +0 -6
- package/chunks/OfficeImportShared-BY6FdZ8d.js +0 -1
- package/chunks/OfficeImportShared-BrZoDM0j.js +0 -30
- package/chunks/OfficeImportShared-Bvm-mOyj.js +0 -1
- package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +0 -36
- package/chunks/PdfConverter-1wyvoT7X.js +0 -21
- package/chunks/PdfConverter-BAoEHILo.js +0 -21
- package/chunks/PdfConverter-CKEvFj11.js +0 -448
- package/chunks/PdfImportService-BhLPp5uG.js +0 -2
- package/chunks/PdfImportService-xbzrN__L.js +0 -2
- package/chunks/RtfConverter-Bxn-enp8.js +0 -15
- package/chunks/RtfConverter-LZPzBDSr.js +0 -15
- package/chunks/RtfConverter-_bacXqr1.js +0 -186
- package/chunks/TableBorders-CwnF3jvH.js +0 -30
- package/chunks/TableGrid-DbroRucl.js +0 -12
- package/chunks/TextFileDecoder--rsVs3NR.js +0 -9
- package/chunks/TxtConverter-C7FOwHpH.js +0 -14
- package/chunks/UnicodeUtils-CXtusU4g.js +0 -10
- package/chunks/XmlConverter-7oo8oeQB.js +0 -2
- package/chunks/XmlConverter-DGORHJcZ.js +0 -96
- package/chunks/XmlConverter-DeLHReK_.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-ComXvtmh.js +0 -13
- package/chunks/backend-DecaBz-I.js +0 -490
- package/chunks/base64-sSPOzq-u.js +0 -198
- package/chunks/browser-module-CFmqfGkE.js +0 -1791
- package/chunks/browser-module-Dj5o3kuL.js +0 -3
- package/chunks/browser-module-UuM_O36W.js +0 -3
- package/chunks/bundle.min-DRpfgV69.js +0 -782
- package/chunks/capture-1btcWcPF.js +0 -9
- package/chunks/carrier-DQeng6yq.js +0 -6
- package/chunks/de-BkbpIKxx.js +0 -13
- package/chunks/es-CKkXujOF.js +0 -13
- package/chunks/fil-piIHMc8F.js +0 -13
- package/chunks/footnoteFlatten-DUQticYy.js +0 -6
- package/chunks/fr-DuA8qLje.js +0 -13
- package/chunks/graftExport-CYnStOdU.js +0 -82
- package/chunks/html2canvas.esm-CntiHiYW.js +0 -997
- package/chunks/index-2TBhRkX7.js +0 -387
- package/chunks/index-BWdRWxoH.js +0 -1807
- package/chunks/index-Bf14eTEW.js +0 -1096
- package/chunks/index-BwcX_r62.js +0 -387
- package/chunks/index.es-CI0QPo8w.js +0 -780
- package/chunks/index.es-CI7cDExj.js +0 -5
- package/chunks/index.es-DHpGt6Y5.js +0 -5
- package/chunks/ja-DgrSs555.js +0 -13
- package/chunks/jspdf.es.min--GshOuIm.js +0 -77
- package/chunks/jspdf.es.min-DU74zN8b.js +0 -1792
- package/chunks/jspdf.es.min-DurJZ1zW.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-BoYTjmiK.js +0 -1
- package/chunks/pseudoLocale-DG2NnZmz.js +0 -1
- package/chunks/purify.es-BwLardii.js +0 -107
- package/chunks/serverDocumentSession-CJ1EH3Tp.js +0 -15
- package/chunks/signatures-Bwt_OGik.js +0 -17
- package/chunks/suggestionAuthorship-B-IuLQlE.js +0 -1
- 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/chunks/zh-9OF3SWWO.js +0 -13
- 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
|
+
};
|