revise 3.1.7 → 4.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 +1671 -184
- package/FONT-LICENSE-HAN-EXT-B.txt +91 -0
- package/FONT-LICENSE-KATEX.txt +95 -0
- package/FONT-LICENSE-LIBERATION.txt +102 -0
- package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +93 -0
- package/FONT-LICENSE-NOTO-SANS-SC.txt +93 -0
- package/FONT-LICENSE-NOTO.txt +94 -0
- package/FONT-LICENSE-SOURCE-CODE-PRO.txt +94 -0
- package/FONT-LICENSE-SOURCE-SERIF-4.txt +93 -0
- package/LICENSE +41 -21
- package/README.md +32 -119
- package/THIRD-PARTY-NOTICES.md +2751 -0
- package/assets/historyMaterializeWorker-ZFUHJDWr.js +619 -0
- package/chunks/AgentPageRenderer-5mZ6fxqO.js +1 -0
- package/chunks/AgentPageRenderer-C3jIBoeM.js +1 -0
- package/chunks/AttachmentDocumentImporter-CXkM4VoT.js +1 -0
- package/chunks/AttachmentDocumentImporter-Kox5By7a.js +1 -0
- package/chunks/ColorParserFull-BKH72fK8.js +446 -0
- package/chunks/DocumentScrubber-BxmlzNNz.js +1 -0
- package/chunks/DocumentScrubber-wmjRnX7C.js +1 -0
- package/chunks/DocxConverter-BH3E7nfQ.js +13 -0
- package/chunks/DocxConverter-DEHGCdib.js +13 -0
- package/chunks/DocxGraft-BMvTAnGi.js +1 -0
- package/chunks/DocxGraft-V2YXiUmK.js +1 -0
- package/chunks/FileImporter-CtX8ZPjV.js +1 -0
- package/chunks/FileImporter-Da-7eRh3.js +1 -0
- package/chunks/OdtConverter-CMkSeU8e.js +6 -0
- package/chunks/OdtConverter-DV94rkDL.js +6 -0
- package/chunks/OfficeImportShared-CA3dia_A.js +1 -0
- package/chunks/OfficeImportShared-hxIa69By.js +1 -0
- package/chunks/PdfConverter-B-uRwLux.js +21 -0
- package/chunks/PdfConverter-B8J_5yim.js +21 -0
- package/chunks/PdfImportService-BjQ4rl-Z.js +2 -0
- package/chunks/PdfImportService-RtFCP6hh.js +2 -0
- package/chunks/RtfConverter-CFDnUApT.js +15 -0
- package/chunks/RtfConverter-CpJGtC5U.js +15 -0
- package/chunks/XmlConverter-CQCrgTf7.js +2 -0
- package/chunks/XmlConverter-CePTE21k.js +2 -0
- package/chunks/__vite-browser-external-l0sNRNKZ.js +0 -0
- package/chunks/_revise-sdk-lazy-harfbuzz-X8gnYTZL.js +1 -0
- package/chunks/ar-vDYSGTpE.js +13 -0
- package/chunks/browser-module-B-uafDG6.js +3 -0
- package/chunks/browser-module-jwkhffzv.js +3 -0
- package/chunks/bundle.min-DRpfgV69.js +782 -0
- package/chunks/de-CWX4cvtt.js +13 -0
- package/chunks/es-DoAhvF6_.js +13 -0
- package/chunks/fil-DdAeD8Br.js +13 -0
- package/chunks/fr-CazsUjNQ.js +13 -0
- package/chunks/html2canvas.esm-CntiHiYW.js +997 -0
- package/chunks/index-BWdRWxoH.js +1807 -0
- package/chunks/index-C7VhCKXe.js +402 -0
- package/chunks/index-p6UytRm8.js +402 -0
- package/chunks/ja-alh_QHTB.js +13 -0
- package/chunks/jspdf.es.min-BuJNZ-oY.js +1882 -0
- package/chunks/katex-DWj8TvwO.js +1462 -0
- package/chunks/pdf-BLWDCiFF.js +1828 -0
- package/chunks/persistInlineDocumentImages-DQj2iaqg.js +1 -0
- package/chunks/pseudoLocale-Bkzfsfiw.js +1 -0
- package/chunks/pseudoLocale-D-AfwRwa.js +1 -0
- package/chunks/tree-sitter-D6zWWUMP.js +4 -0
- package/chunks/wasmInline.generated-CBYFkdSM.js +1 -0
- package/chunks/web-tree-sitter-BXGZGnNj.js +2 -0
- package/chunks/zh-20eXwzFZ.js +13 -0
- package/cli-shim.js +34 -0
- package/full.js +1 -0
- package/index.d.ts +995 -13
- package/index.js +1 -31
- package/legacy/server.d.ts +19 -19
- package/legacy/server.js +39 -23
- package/package.json +55 -45
- package/serverToolContract.d.ts +420 -0
- package/serverToolInputs.generated.d.ts +269 -0
- package/style.css +1 -0
- package/version.d.ts +4 -0
- package/version.js +2 -0
- package/agent.d.ts +0 -139
- package/chunks/chunk-SMTOJL2X.js +0 -2436
- package/chunks/chunk-U5X47PZ6.js +0 -135
- package/chunks/chunk-U6YKQBKL.js +0 -15
- package/chunks/package-5SHL5FOJ.js +0 -14
- package/chunks/render-QD5VWKSV.js +0 -109
- package/cli-output.schema.json +0 -2159
- package/cli.js +0 -4152
- package/document.d.ts +0 -439
- package/docx.d.ts +0 -73
- package/errors.d.ts +0 -14
- package/legacy/editor.d.ts +0 -19
- package/legacy/editor.js +0 -16
- package/legacy/style.css +0 -2
- package/package.d.ts +0 -23
- package/render.d.ts +0 -27
package/chunks/chunk-U5X47PZ6.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
// revise: MIT License. https://revise.io/developer/docs
|
|
2
|
-
import {
|
|
3
|
-
ReviseError
|
|
4
|
-
} from "./chunk-U6YKQBKL.js";
|
|
5
|
-
|
|
6
|
-
// src/embed-sdk/lib/package.ts
|
|
7
|
-
import { engineModules } from "@reviseio/engine";
|
|
8
|
-
import JSZip from "jszip";
|
|
9
|
-
import { installDomShims } from "@reviseio/engine";
|
|
10
|
-
async function listParts(bytes) {
|
|
11
|
-
const zip = await JSZip.loadAsync(bytes);
|
|
12
|
-
const parts = [];
|
|
13
|
-
for (const [path, entry] of Object.entries(zip.files)) {
|
|
14
|
-
if (entry.dir) continue;
|
|
15
|
-
parts.push({ path, bytes: (await entry.async("uint8array")).length });
|
|
16
|
-
}
|
|
17
|
-
return parts.sort((a, b) => a.path.localeCompare(b.path));
|
|
18
|
-
}
|
|
19
|
-
async function readPart(zip, part) {
|
|
20
|
-
const file = zip.file(part);
|
|
21
|
-
if (!file) {
|
|
22
|
-
throw new ReviseError(`No part "${part}" in this document.`, "no_such_part");
|
|
23
|
-
}
|
|
24
|
-
return file.async("string");
|
|
25
|
-
}
|
|
26
|
-
var UNITS = [
|
|
27
|
-
"w:rPr",
|
|
28
|
-
"w:pPr",
|
|
29
|
-
"w:p",
|
|
30
|
-
"w:tr",
|
|
31
|
-
"w:style",
|
|
32
|
-
"w:abstractNum",
|
|
33
|
-
"w:num",
|
|
34
|
-
"w:lvl",
|
|
35
|
-
"w:sectPr",
|
|
36
|
-
"w:tbl"
|
|
37
|
-
];
|
|
38
|
-
var CAT_MATCH_LIMIT = 20;
|
|
39
|
-
async function catPart(bytes, part, match, limit = CAT_MATCH_LIMIT) {
|
|
40
|
-
const xml = await readPart(await JSZip.loadAsync(bytes), part);
|
|
41
|
-
if (!match) return [xml];
|
|
42
|
-
const found = /* @__PURE__ */ new Set();
|
|
43
|
-
let at = xml.indexOf(match);
|
|
44
|
-
while (at >= 0 && found.size < limit) {
|
|
45
|
-
let best;
|
|
46
|
-
for (const tag of UNITS) {
|
|
47
|
-
const start = Math.max(
|
|
48
|
-
xml.lastIndexOf(`<${tag} `, at),
|
|
49
|
-
xml.lastIndexOf(`<${tag}>`, at)
|
|
50
|
-
);
|
|
51
|
-
if (start < 0) continue;
|
|
52
|
-
const close = xml.indexOf(`</${tag}>`, start);
|
|
53
|
-
if (close < 0 || close < at) continue;
|
|
54
|
-
const unit = xml.slice(start, close + tag.length + 3);
|
|
55
|
-
if (!best || unit.length < best.length) best = unit;
|
|
56
|
-
}
|
|
57
|
-
found.add(
|
|
58
|
-
best ?? xml.slice(Math.max(0, at - 200), at + match.length + 200)
|
|
59
|
-
);
|
|
60
|
-
at = xml.indexOf(match, at + match.length);
|
|
61
|
-
}
|
|
62
|
-
return [...found];
|
|
63
|
-
}
|
|
64
|
-
var MODEL_READ_PARTS = /^word\/(document|styles|numbering|footnotes|endnotes|comments|header\d*|footer\d*)\.xml$/;
|
|
65
|
-
async function assertWellFormed(part, xml) {
|
|
66
|
-
await installDomShims();
|
|
67
|
-
const parsed = new DOMParser().parseFromString(xml, "application/xml");
|
|
68
|
-
const error = parsed.getElementsByTagName("parsererror")[0];
|
|
69
|
-
if (error) {
|
|
70
|
-
throw new ReviseError(
|
|
71
|
-
`The patched ${part} is not well-formed XML: ${error.textContent?.trim().split("\n")[0] ?? "parse error"}. Nothing was changed.`,
|
|
72
|
-
"malformed_xml"
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async function patchPackage(pkg, request, readFile) {
|
|
77
|
-
const zip = await JSZip.loadAsync(pkg);
|
|
78
|
-
const before = await readPart(zip, request.part);
|
|
79
|
-
let after;
|
|
80
|
-
let replacements = 0;
|
|
81
|
-
if (request.file !== void 0) {
|
|
82
|
-
after = readFile(request.file);
|
|
83
|
-
replacements = 1;
|
|
84
|
-
} else {
|
|
85
|
-
if (!request.find) {
|
|
86
|
-
throw new ReviseError(
|
|
87
|
-
"Give --find and --replace, or --file to replace the whole part.",
|
|
88
|
-
"usage"
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
const occurrences = before.split(request.find).length - 1;
|
|
92
|
-
if (occurrences === 0) {
|
|
93
|
-
throw new ReviseError(
|
|
94
|
-
`"${request.find}" does not occur in ${request.part}.`,
|
|
95
|
-
"find_not_found"
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
if (occurrences > 1 && !request.all) {
|
|
99
|
-
throw new ReviseError(
|
|
100
|
-
`"${request.find}" occurs ${occurrences} times in ${request.part}; add context to match once, or pass --all.`,
|
|
101
|
-
"find_ambiguous"
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
after = before.split(request.find).join(request.replace ?? "");
|
|
105
|
-
replacements = request.all ? occurrences : 1;
|
|
106
|
-
}
|
|
107
|
-
await assertWellFormed(request.part, after);
|
|
108
|
-
if (request.part === "word/document.xml") {
|
|
109
|
-
const { scanElementChildren } = await engineModules.xmlScan();
|
|
110
|
-
const shape = (xml) => scanElementChildren(xml, "w:body").children.map((child) => child.tag).join(",");
|
|
111
|
-
if (shape(before) !== shape(after)) {
|
|
112
|
-
throw new ReviseError(
|
|
113
|
-
"This patch adds, removes, or reorders body elements, which a direct patch cannot do. Use the editing tools for body structure. Nothing was changed.",
|
|
114
|
-
"body_shape_changed"
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
zip.file(request.part, after);
|
|
119
|
-
const bytes = await zip.generateAsync({
|
|
120
|
-
type: "uint8array",
|
|
121
|
-
compression: "DEFLATE"
|
|
122
|
-
});
|
|
123
|
-
return {
|
|
124
|
-
bytes,
|
|
125
|
-
replacements,
|
|
126
|
-
modelRead: MODEL_READ_PARTS.test(request.part)
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export {
|
|
131
|
-
listParts,
|
|
132
|
-
CAT_MATCH_LIMIT,
|
|
133
|
-
catPart,
|
|
134
|
-
patchPackage
|
|
135
|
-
};
|
package/chunks/chunk-U6YKQBKL.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// revise: MIT License. https://revise.io/developer/docs
|
|
2
|
-
|
|
3
|
-
// src/embed-sdk/lib/errors.ts
|
|
4
|
-
var ReviseError = class extends Error {
|
|
5
|
-
constructor(message, code = "error", options = {}) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.code = code;
|
|
8
|
-
this.name = "ReviseError";
|
|
9
|
-
if (options.cause !== void 0) this.cause = options.cause;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
ReviseError
|
|
15
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
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
|
-
};
|