@open-document/core 0.14.2 → 0.14.3

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.
@@ -1,4 +1,4 @@
1
- import { r as createViteConfig } from "./session-BSbrC5gK.js";
1
+ import { r as createViteConfig } from "./session-CdkoJhi1.js";
2
2
  import path from "node:path";
3
3
  import { build as build$1, mergeConfig } from "vite";
4
4
  //#region src/cli/build.ts
@@ -1,6 +1,6 @@
1
- import { R as listDocIds, S as closeRenderSession, x as checkLayout } from "./session-BSbrC5gK.js";
2
- import "./ops-Dux5HlkH.js";
3
- import { t as cliContext } from "./context-C-osJW5f.js";
1
+ import { R as listDocIds, S as closeRenderSession, x as checkLayout } from "./session-CdkoJhi1.js";
2
+ import "./ops-ByJnGyuE.js";
3
+ import { t as cliContext } from "./context-Clm_nmr1.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
@@ -143,39 +143,39 @@ async function run(argv) {
143
143
  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)"));
144
144
  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) => {
145
145
  if (flags.skillsCheck !== false) await runSkillsDriftCheck(resolveBuiltinSkillsDir());
146
- const { dev } = await import("../dev-CC4PrIOC.js");
146
+ const { dev } = await import("../dev-De3pLYn_.js");
147
147
  await dev(flags);
148
148
  });
149
149
  program.command("build").description("Build a static site").option("--out-dir <dir>", "output directory (defaults to `dist`)").action(async (flags) => {
150
- const { build } = await import("../build-I0cgoERP.js");
150
+ const { build } = await import("../build-4K9V8ysT.js");
151
151
  await build(flags);
152
152
  });
153
153
  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) => {
154
- const { preview } = await import("../preview-7eqn9Wzf.js");
154
+ const { preview } = await import("../preview-id9mj3IU.js");
155
155
  await preview(flags);
156
156
  });
157
157
  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) => {
158
- const { exportDocs } = await import("../export-KrajVJO7.js");
158
+ const { exportDocs } = await import("../export-B9rrNBx2.js");
159
159
  await exportDocs(docIds, flags);
160
160
  });
161
161
  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) => {
162
- const { diffDoc } = await import("../diff-DhutD4TJ.js");
162
+ const { diffDoc } = await import("../diff-nU9ybiMk.js");
163
163
  await diffDoc(docId, flags);
164
164
  });
165
165
  program.command("check [docIds...]").description("Report layout faults — clipped content, blank sheets, stranded headings").option("--json", "print the full report as JSON").action(async (docIds, flags) => {
166
- const { checkDocs } = await import("../check-Dys96QSL.js");
166
+ const { checkDocs } = await import("../check-B40JlWME.js");
167
167
  await checkDocs(docIds, flags);
168
168
  });
169
169
  program.command("templates").description("List the templates a new document can start from").option("--json", "print them as JSON").action(async (flags) => {
170
- const { printTemplates } = await import("../templates-s-VLTSRc.js");
170
+ const { printTemplates } = await import("../templates-UJ_v7H-a.js");
171
171
  await printTemplates(flags);
172
172
  });
173
173
  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) => {
174
- const { newDoc } = await import("../templates-s-VLTSRc.js");
174
+ const { newDoc } = await import("../templates-UJ_v7H-a.js");
175
175
  await newDoc(docId, flags);
176
176
  });
177
177
  program.command("import <file>").description("Turn a Markdown file into a document under docs/").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").option("--contents", "add a self-filling contents page").action(async (file, flags) => {
178
- const { importDoc } = await import("../import-Yv34za3L.js");
178
+ const { importDoc } = await import("../import-C3542Wry.js");
179
179
  await importDoc(file, flags);
180
180
  });
181
181
  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) => {
@@ -1,6 +1,6 @@
1
1
  import { n as readCoreVersion } from "./package-version-C89gtYSk.js";
2
2
  import { n as loadUserConfig } from "./open-doc-plugin-DnX5usgI.js";
3
- import { W as makeContext } from "./session-BSbrC5gK.js";
3
+ import { W as makeContext } from "./session-CdkoJhi1.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,4 +1,4 @@
1
- import { r as createViteConfig } from "./session-BSbrC5gK.js";
1
+ import { r as createViteConfig } from "./session-CdkoJhi1.js";
2
2
  import { createServer, mergeConfig } from "vite";
3
3
  //#region src/cli/dev.ts
4
4
  async function dev(opts = {}) {
@@ -1,5 +1,5 @@
1
- import { t as diffDocument } from "./ops-Dux5HlkH.js";
2
- import { t as cliContext } from "./context-C-osJW5f.js";
1
+ import { t as diffDocument } from "./ops-ByJnGyuE.js";
2
+ import { t as cliContext } from "./context-Clm_nmr1.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 { C as exportDocument, R as listDocIds, S as closeRenderSession } from "./session-BSbrC5gK.js";
3
- import "./ops-Dux5HlkH.js";
4
- import { t as cliContext } from "./context-C-osJW5f.js";
2
+ import { C as exportDocument, R as listDocIds, S as closeRenderSession } from "./session-CdkoJhi1.js";
3
+ import "./ops-ByJnGyuE.js";
4
+ import { t as cliContext } from "./context-Clm_nmr1.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 { T as importMarkdown } from "./session-BSbrC5gK.js";
2
- import "./ops-Dux5HlkH.js";
3
- import { t as cliContext } from "./context-C-osJW5f.js";
1
+ import { T as importMarkdown } from "./session-CdkoJhi1.js";
2
+ import "./ops-ByJnGyuE.js";
3
+ import { t as cliContext } from "./context-Clm_nmr1.js";
4
4
  import chalk from "chalk";
5
5
  import path from "node:path";
6
6
  //#region src/cli/import.ts
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 assertExpectedSource, B as readDocument, C as exportDocument, D as listRevisions, E as slugify, F as deleteDocument, H as resolveEntry, I as docDir, L as duplicateDocument, M as withFileLock, N as OpsError, O as readChanges, P as createDocument, R as listDocIds, S as closeRenderSession, T as importMarkdown, U as writeDocument, V as renameDocument, W as makeContext, _ 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 hashSource, k as revertChange, l as createFromTemplate, m as fileDocument, o as writeEdits, p as deleteAsset, s as writeText, u as listTemplates, v as listThemes, w as renderDocPage, x as checkLayout, y as readTheme, z as listDocuments } from "../session-BSbrC5gK.js";
3
- import { t as diffDocument } from "../ops-Dux5HlkH.js";
2
+ import { A as assertExpectedSource, B as readDocument, C as exportDocument, D as listRevisions, E as slugify, F as deleteDocument, H as resolveEntry, I as docDir, L as duplicateDocument, M as withFileLock, N as OpsError, O as readChanges, P as createDocument, R as listDocIds, S as closeRenderSession, T as importMarkdown, U as writeDocument, V as renameDocument, W as makeContext, _ 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 hashSource, k as revertChange, l as createFromTemplate, m as fileDocument, o as writeEdits, p as deleteAsset, s as writeText, u as listTemplates, v as listThemes, w as renderDocPage, x as checkLayout, y as readTheme, z as listDocuments } from "../session-CdkoJhi1.js";
3
+ import { t as diffDocument } from "../ops-ByJnGyuE.js";
4
4
  export { EXPORT_FORMATS, ORIENTATIONS, OpsError, PAGE_SIZE_NAMES, addComment, assertExpectedSource, checkLayout, closeRenderSession, createDocument, createFolder, createFromTemplate, deleteAsset, deleteDocument, diffDocument, docDir, duplicateDocument, exportDocument, fileDocument, findAssetUsages, hashSource, importMarkdown, listAssets, listDocIds, listDocuments, listFolders, listRevisions, listTemplates, listThemes, makeContext, readChanges, readDocument, readText, readTheme, renameDocument, renderDocPage, resolveEntry, revertChange, slugify, suggestDocId, withFileLock, writeAsset, writeDocument, writeEdits, writeText, writeTexts };
@@ -1,4 +1,4 @@
1
- import { H as resolveEntry, N as OpsError, n as createRenderSession, t as RenderUnavailableError } from "./session-BSbrC5gK.js";
1
+ import { H as resolveEntry, N as OpsError, n as createRenderSession, t as RenderUnavailableError } from "./session-CdkoJhi1.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,4 +1,4 @@
1
- import { r as createViteConfig } from "./session-BSbrC5gK.js";
1
+ import { r as createViteConfig } from "./session-CdkoJhi1.js";
2
2
  import { mergeConfig, preview as preview$1 } from "vite";
3
3
  //#region src/cli/preview.ts
4
4
  async function preview(opts = {}) {
@@ -2248,15 +2248,23 @@ function firstCommaToken(value) {
2248
2248
  const [first] = value.split(",", 1);
2249
2249
  return first?.trim() || null;
2250
2250
  }
2251
+ /**
2252
+ * `null` when nothing says which scheme the browser used: a plain socket with no
2253
+ * `x-forwarded-proto`. Cloud Shell's Web Preview terminates TLS and forwards the
2254
+ * host without the proto, so the page is https while the socket is http.
2255
+ */
2251
2256
  function requestProto(req) {
2252
2257
  const forwarded = firstCommaToken(headerValue(req, "x-forwarded-proto"))?.toLowerCase();
2253
2258
  if (forwarded === "http" || forwarded === "https") return forwarded;
2254
- return "encrypted" in req.socket && req.socket.encrypted ? "https" : "http";
2259
+ return "encrypted" in req.socket && req.socket.encrypted ? "https" : null;
2255
2260
  }
2256
- function normalizedOrigin(origin) {
2261
+ function parsedOrigin(origin) {
2257
2262
  try {
2258
2263
  const url = new URL(origin);
2259
- return `${url.protocol}//${url.host}`.toLowerCase();
2264
+ return {
2265
+ scheme: url.protocol.slice(0, -1).toLowerCase(),
2266
+ host: url.host.toLowerCase()
2267
+ };
2260
2268
  } catch {
2261
2269
  return null;
2262
2270
  }
@@ -2285,8 +2293,8 @@ function validateMutationRequest(req, opts = {}) {
2285
2293
  status: 403,
2286
2294
  error: "opaque origin is not allowed"
2287
2295
  };
2288
- const actualOrigin = normalizedOrigin(originRaw);
2289
- if (!actualOrigin) return {
2296
+ const actual = parsedOrigin(originRaw);
2297
+ if (!actual) return {
2290
2298
  ok: false,
2291
2299
  status: 403,
2292
2300
  error: "invalid origin header"
@@ -2297,7 +2305,8 @@ function validateMutationRequest(req, opts = {}) {
2297
2305
  status: 400,
2298
2306
  error: "missing host header"
2299
2307
  };
2300
- if (actualOrigin !== `${requestProto(req)}://${host}`.toLowerCase()) return {
2308
+ const proto = requestProto(req);
2309
+ if (!(proto ? actual.scheme === proto : actual.scheme === "http" || actual.scheme === "https") || actual.host !== host.toLowerCase()) return {
2301
2310
  ok: false,
2302
2311
  status: 403,
2303
2312
  error: "origin mismatch"
@@ -1,6 +1,6 @@
1
- import { l as createFromTemplate, u as listTemplates } from "./session-BSbrC5gK.js";
2
- import "./ops-Dux5HlkH.js";
3
- import { t as cliContext } from "./context-C-osJW5f.js";
1
+ import { l as createFromTemplate, u as listTemplates } from "./session-CdkoJhi1.js";
2
+ import "./ops-ByJnGyuE.js";
3
+ import { t as cliContext } from "./context-Clm_nmr1.js";
4
4
  import chalk from "chalk";
5
5
  //#region src/cli/templates.ts
6
6
  /**
@@ -1,3 +1,3 @@
1
1
  import { r as openDocPlugin } from "../open-doc-plugin-DnX5usgI.js";
2
- import { r as createViteConfig } from "../session-BSbrC5gK.js";
2
+ import { r as createViteConfig } from "../session-CdkoJhi1.js";
3
3
  export { createViteConfig, openDocPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-document/core",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "description": "Runtime and CLI for open-doc — write documents in docs/, we handle the pages, print layout, and export.",
5
5
  "type": "module",
6
6
  "exports": {