- 归档 OnlyOffice live bridge、Page AI、mindmap、design governance 与相关 bug 条目 - 补齐 MinerU OCR 后端 runtime 合同与 smoke/test 基线 - 收口 ChatOnly/Doubao、ObjectIdentity、Page Aggregate compat 与 runtime owner 文档口径 验证: - cargo test --manifest-path rust/Cargo.toml -p mnote-web local_ocr -- --test-threads=1 - cargo test --manifest-path rust/Cargo.toml -p mnote-web onlyoffice_bridge -- --test-threads=1 - git diff --check - git diff --cached --check - codegraph index . --force && codegraph status . - codegraph sync . && codegraph status .
100 lines
2.3 KiB
JavaScript
100 lines
2.3 KiB
JavaScript
#!/usr/bin/env node
|
|
"use strict";
|
|
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs");
|
|
const path = require("node:path");
|
|
const vm = require("node:vm");
|
|
|
|
const RUNTIME_PATH = path.join(
|
|
process.cwd(),
|
|
"rust/crates/mnote-web/browser/document-tiptap-conversion-runtime.js",
|
|
);
|
|
|
|
function loadConversionRuntime() {
|
|
const source = fs
|
|
.readFileSync(RUNTIME_PATH, "utf8")
|
|
.replace(/\bexport const\s+([A-Za-z0-9_]+)\s*=/g, "const $1 =");
|
|
const sandbox = { console };
|
|
vm.runInNewContext(
|
|
`${source}\n;globalThis.__mnoteExports = { pageBodyTiptapDocumentSource, pageBodyTiptapDocument };`,
|
|
sandbox,
|
|
{ filename: RUNTIME_PATH },
|
|
);
|
|
return sandbox.__mnoteExports;
|
|
}
|
|
|
|
function paragraphText(doc) {
|
|
return doc?.content?.[0]?.content?.[0]?.text || "";
|
|
}
|
|
|
|
const {
|
|
pageBodyTiptapDocumentSource,
|
|
pageBodyTiptapDocument,
|
|
} = loadConversionRuntime();
|
|
|
|
const blockDocument = {
|
|
type: "doc",
|
|
content: [{
|
|
type: "paragraph",
|
|
attrs: { blockId: "block-truth" },
|
|
content: [{ type: "text", text: "Block truth" }],
|
|
}],
|
|
};
|
|
|
|
const legacyContent = [{
|
|
id: "legacy-1",
|
|
type: "paragraph",
|
|
content: [{ type: "text", text: "Legacy fallback" }],
|
|
}];
|
|
|
|
const localWithBlockAndLegacy = {
|
|
projectionSource: "local_markdown.content",
|
|
blockDocument,
|
|
content: legacyContent,
|
|
};
|
|
assert.equal(
|
|
pageBodyTiptapDocumentSource(localWithBlockAndLegacy),
|
|
"page_aggregate.block_document",
|
|
);
|
|
assert.equal(
|
|
paragraphText(pageBodyTiptapDocument(localWithBlockAndLegacy)),
|
|
"Block truth",
|
|
);
|
|
|
|
const localLegacyOnly = {
|
|
projectionSource: "local_markdown.content",
|
|
content: legacyContent,
|
|
};
|
|
assert.equal(
|
|
pageBodyTiptapDocumentSource(localLegacyOnly),
|
|
"local_markdown.content",
|
|
);
|
|
assert.equal(
|
|
paragraphText(pageBodyTiptapDocument(localLegacyOnly)),
|
|
"Legacy fallback",
|
|
);
|
|
|
|
const compatLegacyOnly = {
|
|
content: legacyContent,
|
|
};
|
|
assert.equal(
|
|
pageBodyTiptapDocumentSource(compatLegacyOnly),
|
|
"compat.legacy_content",
|
|
);
|
|
assert.equal(
|
|
paragraphText(pageBodyTiptapDocument(compatLegacyOnly)),
|
|
"Legacy fallback",
|
|
);
|
|
|
|
assert.equal(
|
|
pageBodyTiptapDocumentSource({}, "Fallback text"),
|
|
"degraded.fallback_text",
|
|
);
|
|
assert.equal(
|
|
paragraphText(pageBodyTiptapDocument({}, "Fallback text")),
|
|
"Fallback text",
|
|
);
|
|
|
|
console.log("task522 page aggregate compat fallback contract passed");
|