@open-document/core 0.17.0 → 0.17.2
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/dist/{build-BzNZnIhF.js → build-CryLx-8O.js} +1 -1
- package/dist/{check-C7kxlAFW.js → check-BU86QFnH.js} +3 -3
- package/dist/cli/bin.js +12 -12
- package/dist/{context-CFPnmNCR.js → context-DHCqEAue.js} +2 -2
- package/dist/{deploy-gcp-BUiSuqz7.js → deploy-gcp-bbxQT0gf.js} +1 -1
- package/dist/{dev-BUo7OESU.js → dev-Dmi2PnqI.js} +1 -1
- package/dist/{diff-B950T0O6.js → diff-HVSJapV4.js} +2 -2
- package/dist/{export-CHN1CiGv.js → export-CDobz0UO.js} +3 -3
- package/dist/{import-CLSnIxvN.js → import-BUHNpf-a.js} +3 -3
- package/dist/{open-doc-plugin-DnX5usgI.js → open-doc-plugin-DE1sJXK_.js} +3 -2
- package/dist/ops/index.js +2 -2
- package/dist/{ops-BgbM5Irm.js → ops-DKEhE_su.js} +1 -1
- package/dist/{preview-BVwVqS-I.js → preview-Do-31RB6.js} +1 -1
- package/dist/{proofread-BpR_3GZz.js → proofread-C0crhm3C.js} +3 -3
- package/dist/{session-DmbXf3u7.js → session-CcIBEiIB.js} +181 -112
- package/dist/{templates-BsWxs7oo.js → templates-hcl2pb6n.js} +3 -3
- package/dist/{translations-CW5OVM0L.js → translations-x2NwYrcj.js} +2 -2
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.js +2 -2
- package/package.json +1 -1
- package/skills/doc-authoring/SKILL.md +10 -12
- package/src/app/components/agent/agent-dock.tsx +1 -1
- package/src/app/components/agent/transcript.tsx +2 -4
- package/src/app/components/browser/browser-ui.tsx +8 -2
- package/src/app/components/comments/comments-panel.tsx +9 -5
- package/src/app/components/doc-assets.tsx +9 -5
- package/src/app/components/panel/panel-shell.tsx +3 -1
- package/src/app/components/sidebar/sidebar.tsx +2 -1
- package/src/app/lib/ask.ts +113 -0
- package/src/app/lib/clipboard.ts +26 -0
- package/src/app/lib/export-pdf.ts +18 -0
- package/src/app/lib/i18n-ja/browser.ts +1 -0
- package/src/app/lib/i18n-ja/doc.ts +9 -0
- package/src/app/lib/i18n-ko/browser.ts +1 -0
- package/src/app/lib/i18n-ko/doc.ts +7 -0
- package/src/app/lib/i18n-zh-cn/browser.ts +1 -0
- package/src/app/lib/i18n-zh-cn/doc.ts +7 -0
- package/src/app/lib/i18n-zh-tw/browser.ts +1 -0
- package/src/app/lib/i18n-zh-tw/doc.ts +7 -0
- package/src/app/routes/assets.tsx +19 -12
- package/src/app/routes/doc.tsx +218 -64
- package/src/app/routes/home.tsx +27 -19
- package/src/app/virtual.d.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as listDocIds, S as closeRenderSession, x as checkLayout } from "./session-
|
|
2
|
-
import "./ops-
|
|
3
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { B as listDocIds, S as closeRenderSession, x as checkLayout } from "./session-CcIBEiIB.js";
|
|
2
|
+
import "./ops-DKEhE_su.js";
|
|
3
|
+
import { t as cliContext } from "./context-DHCqEAue.js";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
//#region src/cli/check.ts
|
|
6
6
|
function line(finding) {
|
package/dist/cli/bin.js
CHANGED
|
@@ -148,47 +148,47 @@ async function run(argv) {
|
|
|
148
148
|
program.name("open-doc").description("Author documents — we handle the Vite/React stack, pagination, and export.").version(version, "-v, --version", "print version").helpOption("-h, --help", "show help").showHelpAfterError(chalk.dim("(run `open-doc --help` for usage)"));
|
|
149
149
|
program.command("dev").description("Start the dev server").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").option("--no-skills-check", "skip the built-in skills drift check").option("--mcp", "serve an MCP endpoint at /mcp (requires @open-document/mcp)").action(async (flags) => {
|
|
150
150
|
if (flags.skillsCheck !== false) await runSkillsDriftCheck(resolveBuiltinSkillsDir());
|
|
151
|
-
const { dev } = await import("../dev-
|
|
151
|
+
const { dev } = await import("../dev-Dmi2PnqI.js");
|
|
152
152
|
await dev(flags);
|
|
153
153
|
});
|
|
154
154
|
program.command("build").description("Build a static site").option("--out-dir <dir>", "output directory (defaults to `dist`)").action(async (flags) => {
|
|
155
|
-
const { build } = await import("../build-
|
|
155
|
+
const { build } = await import("../build-CryLx-8O.js");
|
|
156
156
|
await build(flags);
|
|
157
157
|
});
|
|
158
158
|
program.command("preview").description("Preview the production build").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").action(async (flags) => {
|
|
159
|
-
const { preview } = await import("../preview-
|
|
159
|
+
const { preview } = await import("../preview-Do-31RB6.js");
|
|
160
160
|
await preview(flags);
|
|
161
161
|
});
|
|
162
162
|
program.command("export [docIds...]").description("Render documents headlessly to PDF, HTML, PNG, or DOCX").addOption(new Option("-f, --format <format>", "output format").choices([...EXPORT_FORMATS])).option("-o, --out-dir <dir>", "directory to write into (defaults to `out`)").option("--all", "export every document under docs/").option("--each", "one copy per row of the document's `records`").option("--name <pattern>", "with --each: file name, e.g. \"certificate-{name}\" ({#} is the row number)").action(async (docIds, flags) => {
|
|
163
|
-
const { exportDocs } = await import("../export-
|
|
163
|
+
const { exportDocs } = await import("../export-CDobz0UO.js");
|
|
164
164
|
await exportDocs(docIds, flags);
|
|
165
165
|
});
|
|
166
166
|
program.command("diff <docId>").description("Show what changed in a document since a git revision, page by page").option("-s, --since <rev>", "revision to compare against (defaults to HEAD)").option("-o, --out-dir <dir>", "directory to write the report into (defaults to `out`)").option("--json", "print the result as JSON").action(async (docId, flags) => {
|
|
167
|
-
const { diffDoc } = await import("../diff-
|
|
167
|
+
const { diffDoc } = await import("../diff-HVSJapV4.js");
|
|
168
168
|
await diffDoc(docId, flags);
|
|
169
169
|
});
|
|
170
170
|
program.command("check [docIds...]").description("Report layout faults — clipped content, blank sheets, stranded headings").option("--json", "print the full report as JSON").addOption(new Option("--max-pages <n>", "fail when a document runs past n pages, and say where the length is").argParser(parsePositiveInt)).action(async (docIds, flags) => {
|
|
171
|
-
const { checkDocs } = await import("../check-
|
|
171
|
+
const { checkDocs } = await import("../check-BU86QFnH.js");
|
|
172
172
|
await checkDocs(docIds, flags);
|
|
173
173
|
});
|
|
174
174
|
program.command("translations [docId]").description("List translations (meta.translationOf) and what changed in their source since").option("--diff", "print the source's changes since each translation's translatedAt").option("--mark <docId>", "record that a translation now matches its source").option("--at <rev>", "with --mark: the source commit it matches (defaults to the last one)").option("--json", "print the result as JSON").action(async (docId, flags) => {
|
|
175
|
-
const { translations } = await import("../translations-
|
|
175
|
+
const { translations } = await import("../translations-x2NwYrcj.js");
|
|
176
176
|
await translations(docId, flags);
|
|
177
177
|
});
|
|
178
178
|
program.command("proofread [docIds...]").description("Report text slips — full-width letters, wrong-width punctuation, mixed scripts").option("--json", "print the full report as JSON").action(async (docIds, flags) => {
|
|
179
|
-
const { proofreadDocs } = await import("../proofread-
|
|
179
|
+
const { proofreadDocs } = await import("../proofread-C0crhm3C.js");
|
|
180
180
|
await proofreadDocs(docIds, flags);
|
|
181
181
|
});
|
|
182
182
|
program.command("templates").description("List the templates a new document can start from").option("--json", "print them as JSON").action(async (flags) => {
|
|
183
|
-
const { printTemplates } = await import("../templates-
|
|
183
|
+
const { printTemplates } = await import("../templates-hcl2pb6n.js");
|
|
184
184
|
await printTemplates(flags);
|
|
185
185
|
});
|
|
186
186
|
program.command("new [docId]").description("Create a document under docs/ from a template (see `open-doc templates`)").option("-t, --template <name>", "template to start from (defaults to blank)").option("--title <title>", "title of the new document").action(async (docId, flags) => {
|
|
187
|
-
const { newDoc } = await import("../templates-
|
|
187
|
+
const { newDoc } = await import("../templates-hcl2pb6n.js");
|
|
188
188
|
await newDoc(docId, flags);
|
|
189
189
|
});
|
|
190
190
|
program.command("import <file>").description("Turn a Markdown (.md) or Word (.docx) file into a document under docs/ — Word keeps its page look").option("--id <id>", "document id (defaults to a slug of the title)").option("--title <title>", "override the title").option("--subtitle <subtitle>", "subtitle, also used as the cover eyebrow").option("--lang <tag>", "language of the text, e.g. zh-Hant-TW (detected for CJK when omitted)").option("--author <author>", "author line on the cover").option("--theme <theme>", "theme id to back-link from meta.theme").addOption(new Option("--page-size <size>", "page size").choices(PAGE_SIZE_NAMES)).addOption(new Option("--orientation <orientation>", "page orientation").choices(ORIENTATIONS)).option("--no-cover", "skip the title page (Markdown, or Word with --plain)").option("--contents", "add a self-filling contents page (Markdown, or Word with --plain)").option("--plain", "Word only: structure in the house style (headings, lists, tables, a cover) instead of Word's own page look").action(async (file, flags) => {
|
|
191
|
-
const { importDoc } = await import("../import-
|
|
191
|
+
const { importDoc } = await import("../import-BUHNpf-a.js");
|
|
192
192
|
await importDoc(file, flags);
|
|
193
193
|
});
|
|
194
194
|
program.command("sync:skills").description("Sync built-in skills from @open-document/core into this workspace").option("--dry-run", "show what would change without writing").action(async (flags) => {
|
|
@@ -196,7 +196,7 @@ async function run(argv) {
|
|
|
196
196
|
await syncSkills(resolveBuiltinSkillsDir(), flags);
|
|
197
197
|
});
|
|
198
198
|
program.command("deploy").description("Deploy and manage this workspace on a cloud provider (e.g. `open-doc deploy gcp`)").command("gcp").description("Deploy to Google Cloud Run + Cloud Storage, sync files, or stop/delete the service").addArgument(new Argument("[action]", "up (deploy), check (preflight diagnostics), status, pull, push, stop, start, or down").choices([...GCP_DEPLOY_ACTIONS]).default("up")).option("--project <id>", "Google Cloud project ID").option("--region <region>", "Cloud Run and Cloud Storage region (defaults to asia-east1)").option("--service <name>", "Cloud Run service name").option("--bucket <name>", "Cloud Storage bucket name for persistent docs/assets/themes").addOption(new Option("--mode <mode>", "deployment mode: editable (GCS + MCP) or static").choices(["editable", "static"])).option("--memory <size>", "Cloud Run memory limit (defaults to 1Gi)").option("--token <token>", "Bearer token for the remote /mcp endpoint").option("--dry-run", "print the cloud commands without executing them").option("--json", "print output as JSON (for check and status)").option("--delete", "with pull/push: delete destination files missing from source").option("--pull", "with stop: pull latest files from Cloud Storage before locking service").option("--skip-pull", "with down: skip backing up files from Cloud Storage before deleting").option("--purge-storage", "with down: also delete the Cloud Storage bucket").option("-y, --yes", "skip confirmation prompts").action(async (action, flags) => {
|
|
199
|
-
const mod = await import("../deploy-gcp-
|
|
199
|
+
const mod = await import("../deploy-gcp-bbxQT0gf.js");
|
|
200
200
|
switch (action) {
|
|
201
201
|
case "up":
|
|
202
202
|
await mod.runGcpUp(flags);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as readCoreVersion } from "./package-version-C89gtYSk.js";
|
|
2
|
-
import { n as loadUserConfig } from "./open-doc-plugin-
|
|
3
|
-
import { J as makeContext } from "./session-
|
|
2
|
+
import { n as loadUserConfig } from "./open-doc-plugin-DE1sJXK_.js";
|
|
3
|
+
import { J as makeContext } from "./session-CcIBEiIB.js";
|
|
4
4
|
//#region src/cli/context.ts
|
|
5
5
|
/** The same context the dev API and the MCP server run on, for commands that call `ops/`. */
|
|
6
6
|
async function cliContext(userCwd = process.cwd()) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as diffDocument } from "./ops-
|
|
2
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { c as diffDocument } from "./ops-DKEhE_su.js";
|
|
2
|
+
import { t as cliContext } from "./context-DHCqEAue.js";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
//#region src/cli/diff.ts
|
|
5
5
|
const MARK = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as EXPORT_FORMATS } from "./sdk-CqNZzbkz.js";
|
|
2
|
-
import { B as listDocIds, C as exportDocument, S as closeRenderSession } from "./session-
|
|
3
|
-
import "./ops-
|
|
4
|
-
import { t as cliContext } from "./context-
|
|
2
|
+
import { B as listDocIds, C as exportDocument, S as closeRenderSession } from "./session-CcIBEiIB.js";
|
|
3
|
+
import "./ops-DKEhE_su.js";
|
|
4
|
+
import { t as cliContext } from "./context-DHCqEAue.js";
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
//#region src/cli/export.ts
|
|
7
7
|
const FORMATS = EXPORT_FORMATS;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as importMarkdown, E as importDocx } from "./session-
|
|
2
|
-
import "./ops-
|
|
3
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { D as importMarkdown, E as importDocx } from "./session-CcIBEiIB.js";
|
|
2
|
+
import "./ops-DKEhE_su.js";
|
|
3
|
+
import { t as cliContext } from "./context-DHCqEAue.js";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
//#region src/cli/import.ts
|
|
@@ -157,7 +157,7 @@ ${cases}
|
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
function openDocPlugin(opts) {
|
|
160
|
-
const { userCwd, config, coreVersion } = opts;
|
|
160
|
+
const { userCwd, config, coreVersion, coreFromSource = false } = opts;
|
|
161
161
|
const docsDir = config.docsDir ?? "docs";
|
|
162
162
|
const docsRoot = path.resolve(userCwd, docsDir);
|
|
163
163
|
const foldersManifestPath = path.join(docsRoot, ".folders.json");
|
|
@@ -235,7 +235,8 @@ function openDocPlugin(opts) {
|
|
|
235
235
|
return `export default ${JSON.stringify({
|
|
236
236
|
...config,
|
|
237
237
|
build,
|
|
238
|
-
version: coreVersion
|
|
238
|
+
version: coreVersion,
|
|
239
|
+
fromSource: coreFromSource
|
|
239
240
|
})};\n`;
|
|
240
241
|
}
|
|
241
242
|
if (id === resolved(FOLDERS_VMOD)) {
|
package/dist/ops/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as ORIENTATIONS, o as PAGE_SIZE_NAMES, r as EXPORT_FORMATS } from "../sdk-CqNZzbkz.js";
|
|
2
|
-
import { A as readChanges, B as listDocIds, C as exportDocument, D as importMarkdown, E as importDocx, F as OpsError, G as resolveEntry, H as readDocument, I as createDocument, J as makeContext, K as writeDocument, L as deleteDocument, M as assertExpectedSource, N as hashSource, O as slugify, P as withFileLock, R as docDir, S as closeRenderSession, T as renderDocPage, V as listDocuments, W as renameDocument, _ as listFolders, a as readText, b as writeAsset, c as writeTexts, d as suggestDocId, f as createFolder, g as listAssets, h as findAssetUsages, i as addComment, j as revertChange, k as listRevisions, l as createFromTemplate, m as fileDocument, o as writeEdits, p as deleteAsset, s as writeText, u as listTemplates, v as listThemes, w as proofreadDocument, x as checkLayout, y as readTheme, z as duplicateDocument } from "../session-
|
|
3
|
-
import { a as outlineSource, c as diffDocument, i as outlineDocument, n as translationStatus, o as readDocumentLines, r as editDocument, s as searchDocument, t as markTranslated } from "../ops-
|
|
2
|
+
import { A as readChanges, B as listDocIds, C as exportDocument, D as importMarkdown, E as importDocx, F as OpsError, G as resolveEntry, H as readDocument, I as createDocument, J as makeContext, K as writeDocument, L as deleteDocument, M as assertExpectedSource, N as hashSource, O as slugify, P as withFileLock, R as docDir, S as closeRenderSession, T as renderDocPage, V as listDocuments, W as renameDocument, _ as listFolders, a as readText, b as writeAsset, c as writeTexts, d as suggestDocId, f as createFolder, g as listAssets, h as findAssetUsages, i as addComment, j as revertChange, k as listRevisions, l as createFromTemplate, m as fileDocument, o as writeEdits, p as deleteAsset, s as writeText, u as listTemplates, v as listThemes, w as proofreadDocument, x as checkLayout, y as readTheme, z as duplicateDocument } from "../session-CcIBEiIB.js";
|
|
3
|
+
import { a as outlineSource, c as diffDocument, i as outlineDocument, n as translationStatus, o as readDocumentLines, r as editDocument, s as searchDocument, t as markTranslated } from "../ops-DKEhE_su.js";
|
|
4
4
|
export { EXPORT_FORMATS, ORIENTATIONS, OpsError, PAGE_SIZE_NAMES, addComment, assertExpectedSource, checkLayout, closeRenderSession, createDocument, createFolder, createFromTemplate, deleteAsset, deleteDocument, diffDocument, docDir, duplicateDocument, editDocument, exportDocument, fileDocument, findAssetUsages, hashSource, importDocx, importMarkdown, listAssets, listDocIds, listDocuments, listFolders, listRevisions, listTemplates, listThemes, makeContext, markTranslated, outlineDocument, outlineSource, proofreadDocument, readChanges, readDocument, readDocumentLines, readText, readTheme, renameDocument, renderDocPage, resolveEntry, revertChange, searchDocument, slugify, suggestDocId, translationStatus, withFileLock, writeAsset, writeDocument, writeEdits, writeText, writeTexts };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as listDocIds, F as OpsError, G as resolveEntry, M as assertExpectedSource, N as hashSource, P as withFileLock, U as readMetaField, n as createRenderSession, q as setMetaString, t as RenderUnavailableError } from "./session-
|
|
1
|
+
import { B as listDocIds, F as OpsError, G as resolveEntry, M as assertExpectedSource, N as hashSource, P as withFileLock, U as readMetaField, n as createRenderSession, q as setMetaString, t as RenderUnavailableError } from "./session-CcIBEiIB.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as listDocIds, S as closeRenderSession, w as proofreadDocument } from "./session-
|
|
2
|
-
import "./ops-
|
|
3
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { B as listDocIds, S as closeRenderSession, w as proofreadDocument } from "./session-CcIBEiIB.js";
|
|
2
|
+
import "./ops-DKEhE_su.js";
|
|
3
|
+
import { t as cliContext } from "./context-DHCqEAue.js";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
//#region src/cli/proofread.ts
|
|
6
6
|
function line(finding) {
|
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
|
2
2
|
import { a as defaultDesign, n as DiagramSyntaxError, r as parseDelimited, t as compileDiagram } from "./diagram-CKf3ptOE.js";
|
|
3
3
|
import { a as PAGE_SIZES, c as isPageSizeName, i as ORIENTATIONS, o as PAGE_SIZE_NAMES, s as isOrientation } from "./sdk-CqNZzbkz.js";
|
|
4
4
|
import { t as corePackageRoot } from "./package-version-C89gtYSk.js";
|
|
5
|
-
import { n as loadUserConfig, r as openDocPlugin, t as DOC_ID_RE } from "./open-doc-plugin-
|
|
5
|
+
import { n as loadUserConfig, r as openDocPlugin, t as DOC_ID_RE } from "./open-doc-plugin-DE1sJXK_.js";
|
|
6
6
|
import chalk from "chalk";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -6778,9 +6778,12 @@ var LayoutReader = class {
|
|
|
6778
6778
|
case "w:endnoteReference":
|
|
6779
6779
|
this.readNote(node, css, out());
|
|
6780
6780
|
break;
|
|
6781
|
-
case "w:commentReference":
|
|
6782
|
-
this.
|
|
6781
|
+
case "w:commentReference": {
|
|
6782
|
+
const comment = this.readComment(node);
|
|
6783
|
+
if (comment) out().push(comment);
|
|
6784
|
+
else this.count("comment");
|
|
6783
6785
|
break;
|
|
6786
|
+
}
|
|
6784
6787
|
case "w:fldChar": {
|
|
6785
6788
|
const type = node.attrs["w:fldCharType"];
|
|
6786
6789
|
if (type === "begin") this.fields.push({
|
|
@@ -6848,6 +6851,21 @@ var LayoutReader = class {
|
|
|
6848
6851
|
if (tabPx && em) return `calc(${round$1(em)}em + ${round$1(tabPx)}px)`;
|
|
6849
6852
|
return tabPx ? `${round$1(tabPx)}px` : `${round$1(em)}em`;
|
|
6850
6853
|
}
|
|
6854
|
+
readComment(node) {
|
|
6855
|
+
const part = this.pkg.partOf("/comments", "comments.xml");
|
|
6856
|
+
const comment = part && elements(part, "w:comment").find((el) => el.attrs["w:id"] === node.attrs["w:id"]);
|
|
6857
|
+
if (!comment) return void 0;
|
|
6858
|
+
const text = elements(comment, "w:p").map((p) => descendants(p, "w:t").map(textContent).join("")).join("\n").trim();
|
|
6859
|
+
if (!text) return void 0;
|
|
6860
|
+
const author = comment.attrs["w:author"]?.trim();
|
|
6861
|
+
const date = comment.attrs["w:date"];
|
|
6862
|
+
return {
|
|
6863
|
+
kind: "comment",
|
|
6864
|
+
text,
|
|
6865
|
+
...author ? { author } : {},
|
|
6866
|
+
...date && !Number.isNaN(Date.parse(date)) ? { date: new Date(date).toISOString() } : {}
|
|
6867
|
+
};
|
|
6868
|
+
}
|
|
6851
6869
|
readNote(node, css, out) {
|
|
6852
6870
|
const endnote = node.name === "w:endnoteReference";
|
|
6853
6871
|
const part = endnote ? this.pkg.partOf("/endnotes", "endnotes.xml") : this.pkg.partOf("/footnotes", "footnotes.xml");
|
|
@@ -7785,6 +7803,113 @@ function detectLang(text) {
|
|
|
7785
7803
|
return simplified > traditional ? "zh-Hans" : "zh-Hant";
|
|
7786
7804
|
}
|
|
7787
7805
|
//#endregion
|
|
7806
|
+
//#region src/editing/comments.ts
|
|
7807
|
+
const MARKER_RE = /\{\/\*\s*@doc-comment\s+id="(c-[a-f0-9]+)"\s+ts="([^"]+)"\s+text="([A-Za-z0-9_-]+={0,2})"\s*\*\/\}/;
|
|
7808
|
+
function b64urlEncode(value) {
|
|
7809
|
+
return Buffer.from(value, "utf8").toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
7810
|
+
}
|
|
7811
|
+
function b64urlDecode(value) {
|
|
7812
|
+
const pad = value.length % 4 === 0 ? "" : "=".repeat(4 - value.length % 4);
|
|
7813
|
+
return Buffer.from(value.replace(/-/g, "+").replace(/_/g, "/") + pad, "base64").toString("utf8");
|
|
7814
|
+
}
|
|
7815
|
+
function parseMarkers(source) {
|
|
7816
|
+
const comments = [];
|
|
7817
|
+
source.split("\n").forEach((line, index) => {
|
|
7818
|
+
const match = MARKER_RE.exec(line);
|
|
7819
|
+
if (!match) return;
|
|
7820
|
+
const [, id, ts, payload] = match;
|
|
7821
|
+
try {
|
|
7822
|
+
const decoded = JSON.parse(b64urlDecode(payload));
|
|
7823
|
+
comments.push({
|
|
7824
|
+
id,
|
|
7825
|
+
line: index + 1,
|
|
7826
|
+
ts,
|
|
7827
|
+
note: decoded.note,
|
|
7828
|
+
hint: decoded.hint
|
|
7829
|
+
});
|
|
7830
|
+
} catch {}
|
|
7831
|
+
});
|
|
7832
|
+
return comments;
|
|
7833
|
+
}
|
|
7834
|
+
/**
|
|
7835
|
+
* Where each marker's element starts. A marker is always an element's first
|
|
7836
|
+
* child, so the element holding it is the one the note is about; its start is
|
|
7837
|
+
* the `data-od-loc` the page stamps on it, which is how the viewer pins a note
|
|
7838
|
+
* to what it printed.
|
|
7839
|
+
*/
|
|
7840
|
+
function locateMarkers(source, comments) {
|
|
7841
|
+
const ast = parseSource(source);
|
|
7842
|
+
if (!ast) return comments;
|
|
7843
|
+
const owner = /* @__PURE__ */ new Map();
|
|
7844
|
+
walkJsx(ast, (element) => {
|
|
7845
|
+
if (!element.loc) return;
|
|
7846
|
+
for (const child of element.children ?? []) {
|
|
7847
|
+
if (child.type !== "JSXExpressionContainer") continue;
|
|
7848
|
+
const id = /@doc-comment\s+id="(c-[a-f0-9]+)"/.exec(source.slice(child.start, child.end))?.[1];
|
|
7849
|
+
if (id) owner.set(id, `${element.loc.start.line}:${element.loc.start.column}`);
|
|
7850
|
+
}
|
|
7851
|
+
});
|
|
7852
|
+
return comments.map((comment) => {
|
|
7853
|
+
const loc = owner.get(comment.id);
|
|
7854
|
+
return loc ? {
|
|
7855
|
+
...comment,
|
|
7856
|
+
loc
|
|
7857
|
+
} : comment;
|
|
7858
|
+
});
|
|
7859
|
+
}
|
|
7860
|
+
function newCommentId() {
|
|
7861
|
+
return `c-${randomUUID().replace(/-/g, "").slice(0, 8)}`;
|
|
7862
|
+
}
|
|
7863
|
+
function markerFor(id, ts, note, hint) {
|
|
7864
|
+
return `{/* @doc-comment id="${id}" ts="${ts}" text="${b64urlEncode(JSON.stringify(hint ? {
|
|
7865
|
+
note,
|
|
7866
|
+
hint
|
|
7867
|
+
} : { note }))}" */}`;
|
|
7868
|
+
}
|
|
7869
|
+
function markerPattern(id) {
|
|
7870
|
+
return `\\{\\/\\*\\s*@doc-comment\\s+id="${id}"\\s+ts="[^"]+"\\s+text="[A-Za-z0-9_\\-]+={0,2}"\\s*\\*\\/\\}`;
|
|
7871
|
+
}
|
|
7872
|
+
/**
|
|
7873
|
+
* Removes a marker and the whitespace the insertion added — whichever side it
|
|
7874
|
+
* landed on — so deleting a comment restores the file byte for byte.
|
|
7875
|
+
*/
|
|
7876
|
+
function removeMarker(source, id) {
|
|
7877
|
+
const pattern = markerPattern(id);
|
|
7878
|
+
for (const re of [
|
|
7879
|
+
new RegExp(`[ \\t]*${pattern}\\n`),
|
|
7880
|
+
new RegExp(`\\n[ \\t]*${pattern}`),
|
|
7881
|
+
new RegExp(pattern)
|
|
7882
|
+
]) if (re.test(source)) return source.replace(re, "");
|
|
7883
|
+
return null;
|
|
7884
|
+
}
|
|
7885
|
+
function indentOfLine(source, offset) {
|
|
7886
|
+
const lineStart = source.lastIndexOf("\n", offset - 1) + 1;
|
|
7887
|
+
return /^[ \t]*/.exec(source.slice(lineStart, offset))?.[0] ?? "";
|
|
7888
|
+
}
|
|
7889
|
+
/**
|
|
7890
|
+
* Splices the marker in as the **first child** of the target element. A
|
|
7891
|
+
* JSX-comment token outside a JSX child position parses as an empty object
|
|
7892
|
+
* literal and breaks the surrounding expression, so this never puts one before
|
|
7893
|
+
* an element.
|
|
7894
|
+
*/
|
|
7895
|
+
function insertMarker(source, target, note, hint) {
|
|
7896
|
+
const ast = parseStrict(source);
|
|
7897
|
+
if (!ast) return null;
|
|
7898
|
+
const element = findJsxAt(ast, target.line, target.column);
|
|
7899
|
+
if (!element) return null;
|
|
7900
|
+
const opening = element.openingElement;
|
|
7901
|
+
if (!opening) return null;
|
|
7902
|
+
if (opening.selfClosing === true) return null;
|
|
7903
|
+
const offset = opening.end;
|
|
7904
|
+
const id = newCommentId();
|
|
7905
|
+
const marker = markerFor(id, (/* @__PURE__ */ new Date()).toISOString(), note, hint);
|
|
7906
|
+
const indent = indentOfLine(source, element.start ?? offset);
|
|
7907
|
+
return {
|
|
7908
|
+
source: `${source.slice(0, offset)}\n${indent} ${marker}${source.slice(offset)}`,
|
|
7909
|
+
id
|
|
7910
|
+
};
|
|
7911
|
+
}
|
|
7912
|
+
//#endregion
|
|
7788
7913
|
//#region src/import/markdown.ts
|
|
7789
7914
|
const FENCE_RE = /^(```|~~~)\s*([^\s`]*)\s*$/;
|
|
7790
7915
|
const ATX_RE = /^(#{1,6})\s+(.*?)\s*#*\s*$/;
|
|
@@ -8614,6 +8739,7 @@ function renderRuns(p, base, ctx) {
|
|
|
8614
8739
|
return runs.map((run, index) => {
|
|
8615
8740
|
if (run.kind === "text") written += run.text;
|
|
8616
8741
|
switch (run.kind) {
|
|
8742
|
+
case "comment": return "";
|
|
8617
8743
|
case "break": return "<br />";
|
|
8618
8744
|
case "image": {
|
|
8619
8745
|
if (!run.src) return `<span${styleAttr({
|
|
@@ -8804,6 +8930,18 @@ function pick(css, keys) {
|
|
|
8804
8930
|
function flags(block) {
|
|
8805
8931
|
return [block.keepNext ? " data-od-keep-with-next=\"true\"" : "", block.breakBefore ? " data-od-break-before=\"true\"" : ""].join("");
|
|
8806
8932
|
}
|
|
8933
|
+
/**
|
|
8934
|
+
* Word's comments on a paragraph, as one `@doc-comment` marker first in its element, where the
|
|
8935
|
+
* Comments panel pins it and the apply-comments skill reads it. One, because markers are read
|
|
8936
|
+
* one to a line. The id comes from the comments, so the same file imports to the same source.
|
|
8937
|
+
*/
|
|
8938
|
+
function commentMarkers(p) {
|
|
8939
|
+
const comments = p.runs.filter((run) => run.kind === "comment");
|
|
8940
|
+
if (comments.length === 0) return "";
|
|
8941
|
+
const note = comments.map((run) => run.author ? `${run.author}: ${run.text}` : run.text).join("\n\n");
|
|
8942
|
+
const ts = comments.map((run) => run.date).filter((date) => !!date).sort()[0] ?? "1970-01-01T00:00:00.000Z";
|
|
8943
|
+
return `{/* @doc-comment id="${`c-${createHash("sha256").update(`${ts}\n${note}`).digest("hex").slice(0, 12)}`}" ts="${ts}" text="${b64urlEncode(JSON.stringify({ note }))}" */}`;
|
|
8944
|
+
}
|
|
8807
8945
|
function renderParagraph(p, ctx, pad) {
|
|
8808
8946
|
const heading = !!p.heading;
|
|
8809
8947
|
const boxed = p.runs.some((run) => run.kind === "box" || run.kind === "chart" || run.kind === "image" && run.place?.mode === "over");
|
|
@@ -8819,7 +8957,7 @@ function renderParagraph(p, ctx, pad) {
|
|
|
8819
8957
|
const after = Math.max(0, ...p.runs.map((run) => run.kind === "box" ? run.after ?? 0 : 0));
|
|
8820
8958
|
if (after > 0) css.paddingBottom = after;
|
|
8821
8959
|
const inline = p.runs.some((run) => run.kind !== "box");
|
|
8822
|
-
const content = `${renderRuns(p, base, ctx)}${inline ? "" : "<br />"}`;
|
|
8960
|
+
const content = `${commentMarkers(p)}${renderRuns(p, base, ctx)}${inline ? "" : "<br />"}`;
|
|
8823
8961
|
return `${pad}<${tag}${styleAttr(css)}${flags(p)}>${content}</${tag}>`;
|
|
8824
8962
|
}
|
|
8825
8963
|
function renderCell(cell, ctx, pad) {
|
|
@@ -10447,6 +10585,33 @@ function registerDocRoutes(server, ctx) {
|
|
|
10447
10585
|
const method = req.method ?? "GET";
|
|
10448
10586
|
try {
|
|
10449
10587
|
const duplicateMatch = url.pathname.match(/^\/([^/]+)\/duplicate$/);
|
|
10588
|
+
const pdfMatch = url.pathname.match(/^\/([^/]+)\/pdf$/);
|
|
10589
|
+
if (pdfMatch && method === "POST") {
|
|
10590
|
+
const requestCheck = validateMutationRequest(req);
|
|
10591
|
+
if (!requestCheck.ok) return json(res, requestCheck.status, { error: requestCheck.error });
|
|
10592
|
+
const docId = decodeURIComponent(pdfMatch[1]);
|
|
10593
|
+
const origin = server.resolvedUrls?.local?.[0]?.replace(/\/$/, "");
|
|
10594
|
+
const outDir = path.join("node_modules", ".open-doc", "pdf", randomBytes(6).toString("hex"));
|
|
10595
|
+
try {
|
|
10596
|
+
const result = await exportDocument({
|
|
10597
|
+
...ctx,
|
|
10598
|
+
...origin ? { serverOrigin: origin } : {}
|
|
10599
|
+
}, docId, {
|
|
10600
|
+
format: "pdf",
|
|
10601
|
+
outDir
|
|
10602
|
+
});
|
|
10603
|
+
const bytes = await fs.readFile(path.resolve(ctx.userCwd, result.files[0]));
|
|
10604
|
+
res.statusCode = 200;
|
|
10605
|
+
res.setHeader("Content-Type", "application/pdf");
|
|
10606
|
+
res.setHeader("Cache-Control", "no-store");
|
|
10607
|
+
return res.end(bytes);
|
|
10608
|
+
} finally {
|
|
10609
|
+
await fs.rm(path.resolve(ctx.userCwd, outDir), {
|
|
10610
|
+
recursive: true,
|
|
10611
|
+
force: true
|
|
10612
|
+
});
|
|
10613
|
+
}
|
|
10614
|
+
}
|
|
10450
10615
|
const idMatch = url.pathname.match(/^\/([^/]+)$/);
|
|
10451
10616
|
if (url.pathname === "/" && method === "POST") {
|
|
10452
10617
|
const requestCheck = validateMutationRequest(req);
|
|
@@ -10498,113 +10663,6 @@ function registerDocRoutes(server, ctx) {
|
|
|
10498
10663
|
});
|
|
10499
10664
|
}
|
|
10500
10665
|
//#endregion
|
|
10501
|
-
//#region src/editing/comments.ts
|
|
10502
|
-
const MARKER_RE = /\{\/\*\s*@doc-comment\s+id="(c-[a-f0-9]+)"\s+ts="([^"]+)"\s+text="([A-Za-z0-9_-]+={0,2})"\s*\*\/\}/;
|
|
10503
|
-
function b64urlEncode(value) {
|
|
10504
|
-
return Buffer.from(value, "utf8").toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
10505
|
-
}
|
|
10506
|
-
function b64urlDecode(value) {
|
|
10507
|
-
const pad = value.length % 4 === 0 ? "" : "=".repeat(4 - value.length % 4);
|
|
10508
|
-
return Buffer.from(value.replace(/-/g, "+").replace(/_/g, "/") + pad, "base64").toString("utf8");
|
|
10509
|
-
}
|
|
10510
|
-
function parseMarkers(source) {
|
|
10511
|
-
const comments = [];
|
|
10512
|
-
source.split("\n").forEach((line, index) => {
|
|
10513
|
-
const match = MARKER_RE.exec(line);
|
|
10514
|
-
if (!match) return;
|
|
10515
|
-
const [, id, ts, payload] = match;
|
|
10516
|
-
try {
|
|
10517
|
-
const decoded = JSON.parse(b64urlDecode(payload));
|
|
10518
|
-
comments.push({
|
|
10519
|
-
id,
|
|
10520
|
-
line: index + 1,
|
|
10521
|
-
ts,
|
|
10522
|
-
note: decoded.note,
|
|
10523
|
-
hint: decoded.hint
|
|
10524
|
-
});
|
|
10525
|
-
} catch {}
|
|
10526
|
-
});
|
|
10527
|
-
return comments;
|
|
10528
|
-
}
|
|
10529
|
-
/**
|
|
10530
|
-
* Where each marker's element starts. A marker is always an element's first
|
|
10531
|
-
* child, so the element holding it is the one the note is about; its start is
|
|
10532
|
-
* the `data-od-loc` the page stamps on it, which is how the viewer pins a note
|
|
10533
|
-
* to what it printed.
|
|
10534
|
-
*/
|
|
10535
|
-
function locateMarkers(source, comments) {
|
|
10536
|
-
const ast = parseSource(source);
|
|
10537
|
-
if (!ast) return comments;
|
|
10538
|
-
const owner = /* @__PURE__ */ new Map();
|
|
10539
|
-
walkJsx(ast, (element) => {
|
|
10540
|
-
if (!element.loc) return;
|
|
10541
|
-
for (const child of element.children ?? []) {
|
|
10542
|
-
if (child.type !== "JSXExpressionContainer") continue;
|
|
10543
|
-
const id = /@doc-comment\s+id="(c-[a-f0-9]+)"/.exec(source.slice(child.start, child.end))?.[1];
|
|
10544
|
-
if (id) owner.set(id, `${element.loc.start.line}:${element.loc.start.column}`);
|
|
10545
|
-
}
|
|
10546
|
-
});
|
|
10547
|
-
return comments.map((comment) => {
|
|
10548
|
-
const loc = owner.get(comment.id);
|
|
10549
|
-
return loc ? {
|
|
10550
|
-
...comment,
|
|
10551
|
-
loc
|
|
10552
|
-
} : comment;
|
|
10553
|
-
});
|
|
10554
|
-
}
|
|
10555
|
-
function newCommentId() {
|
|
10556
|
-
return `c-${randomUUID().replace(/-/g, "").slice(0, 8)}`;
|
|
10557
|
-
}
|
|
10558
|
-
function markerFor(id, ts, note, hint) {
|
|
10559
|
-
return `{/* @doc-comment id="${id}" ts="${ts}" text="${b64urlEncode(JSON.stringify(hint ? {
|
|
10560
|
-
note,
|
|
10561
|
-
hint
|
|
10562
|
-
} : { note }))}" */}`;
|
|
10563
|
-
}
|
|
10564
|
-
function markerPattern(id) {
|
|
10565
|
-
return `\\{\\/\\*\\s*@doc-comment\\s+id="${id}"\\s+ts="[^"]+"\\s+text="[A-Za-z0-9_\\-]+={0,2}"\\s*\\*\\/\\}`;
|
|
10566
|
-
}
|
|
10567
|
-
/**
|
|
10568
|
-
* Removes a marker and the whitespace the insertion added — whichever side it
|
|
10569
|
-
* landed on — so deleting a comment restores the file byte for byte.
|
|
10570
|
-
*/
|
|
10571
|
-
function removeMarker(source, id) {
|
|
10572
|
-
const pattern = markerPattern(id);
|
|
10573
|
-
for (const re of [
|
|
10574
|
-
new RegExp(`[ \\t]*${pattern}\\n`),
|
|
10575
|
-
new RegExp(`\\n[ \\t]*${pattern}`),
|
|
10576
|
-
new RegExp(pattern)
|
|
10577
|
-
]) if (re.test(source)) return source.replace(re, "");
|
|
10578
|
-
return null;
|
|
10579
|
-
}
|
|
10580
|
-
function indentOfLine(source, offset) {
|
|
10581
|
-
const lineStart = source.lastIndexOf("\n", offset - 1) + 1;
|
|
10582
|
-
return /^[ \t]*/.exec(source.slice(lineStart, offset))?.[0] ?? "";
|
|
10583
|
-
}
|
|
10584
|
-
/**
|
|
10585
|
-
* Splices the marker in as the **first child** of the target element. A
|
|
10586
|
-
* JSX-comment token outside a JSX child position parses as an empty object
|
|
10587
|
-
* literal and breaks the surrounding expression, so this never puts one before
|
|
10588
|
-
* an element.
|
|
10589
|
-
*/
|
|
10590
|
-
function insertMarker(source, target, note, hint) {
|
|
10591
|
-
const ast = parseStrict(source);
|
|
10592
|
-
if (!ast) return null;
|
|
10593
|
-
const element = findJsxAt(ast, target.line, target.column);
|
|
10594
|
-
if (!element) return null;
|
|
10595
|
-
const opening = element.openingElement;
|
|
10596
|
-
if (!opening) return null;
|
|
10597
|
-
if (opening.selfClosing === true) return null;
|
|
10598
|
-
const offset = opening.end;
|
|
10599
|
-
const id = newCommentId();
|
|
10600
|
-
const marker = markerFor(id, (/* @__PURE__ */ new Date()).toISOString(), note, hint);
|
|
10601
|
-
const indent = indentOfLine(source, element.start ?? offset);
|
|
10602
|
-
return {
|
|
10603
|
-
source: `${source.slice(0, offset)}\n${indent} ${marker}${source.slice(offset)}`,
|
|
10604
|
-
id
|
|
10605
|
-
};
|
|
10606
|
-
}
|
|
10607
|
-
//#endregion
|
|
10608
10666
|
//#region src/editing/edit-ops.ts
|
|
10609
10667
|
function escapeJsxText(text) {
|
|
10610
10668
|
return text.replace(/[{}<>]/g, (char) => `{'${char}'}`);
|
|
@@ -12983,6 +13041,16 @@ function readCoreVersion() {
|
|
|
12983
13041
|
}
|
|
12984
13042
|
}
|
|
12985
13043
|
const CORE_VERSION = readCoreVersion();
|
|
13044
|
+
/**
|
|
13045
|
+
* Whether this core runs from a source checkout (a `link:`, `file:` or `workspace:`
|
|
13046
|
+
* dependency, or this repo's own demo) rather than a package installed from npm.
|
|
13047
|
+
* An install always lives under a `node_modules` folder, even through pnpm's links,
|
|
13048
|
+
* because the path is the resolved file's; a checkout never does.
|
|
13049
|
+
*/
|
|
13050
|
+
function isSourceCheckout(pkgRoot) {
|
|
13051
|
+
return !pkgRoot.split(/[\\/]/).includes("node_modules");
|
|
13052
|
+
}
|
|
13053
|
+
const CORE_FROM_SOURCE = isSourceCheckout(PKG_ROOT);
|
|
12986
13054
|
function safeRealpath(target) {
|
|
12987
13055
|
try {
|
|
12988
13056
|
return existsSync(target) ? realpathSync(target) : null;
|
|
@@ -13035,7 +13103,8 @@ async function createViteConfig(opts) {
|
|
|
13035
13103
|
openDocPlugin({
|
|
13036
13104
|
userCwd,
|
|
13037
13105
|
config,
|
|
13038
|
-
coreVersion: CORE_VERSION
|
|
13106
|
+
coreVersion: CORE_VERSION,
|
|
13107
|
+
coreFromSource: CORE_FROM_SOURCE
|
|
13039
13108
|
}),
|
|
13040
13109
|
themesPlugin({
|
|
13041
13110
|
userCwd,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as createFromTemplate, u as listTemplates } from "./session-
|
|
2
|
-
import "./ops-
|
|
3
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { l as createFromTemplate, u as listTemplates } from "./session-CcIBEiIB.js";
|
|
2
|
+
import "./ops-DKEhE_su.js";
|
|
3
|
+
import { t as cliContext } from "./context-DHCqEAue.js";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
//#region src/cli/templates.ts
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as translationStatus, t as markTranslated } from "./ops-
|
|
2
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { n as translationStatus, t as markTranslated } from "./ops-DKEhE_su.js";
|
|
2
|
+
import { t as cliContext } from "./context-DHCqEAue.js";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
//#region src/cli/translations.ts
|
|
5
5
|
const STATE = {
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ type OpenDocPluginOptions = {
|
|
|
5
5
|
userCwd: string;
|
|
6
6
|
config: OpenDocConfig;
|
|
7
7
|
coreVersion: string;
|
|
8
|
+
/** Core runs from a source checkout; the browser marks its version `dev`. */
|
|
9
|
+
coreFromSource?: boolean;
|
|
8
10
|
};
|
|
9
11
|
declare function openDocPlugin(opts: OpenDocPluginOptions): Plugin;
|
|
10
12
|
//#endregion
|
package/dist/vite/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as openDocPlugin } from "../open-doc-plugin-
|
|
2
|
-
import { r as createViteConfig } from "../session-
|
|
1
|
+
import { r as openDocPlugin } from "../open-doc-plugin-DE1sJXK_.js";
|
|
2
|
+
import { r as createViteConfig } from "../session-CcIBEiIB.js";
|
|
3
3
|
export { createViteConfig, openDocPlugin };
|
package/package.json
CHANGED