@open-press/cli 1.0.0 → 1.1.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.
Files changed (175) hide show
  1. package/README.md +11 -12
  2. package/dist/cli.js +298 -79
  3. package/package.json +9 -7
  4. package/template/core/AGENTS.md +0 -130
  5. package/template/core/CHANGELOG.md +0 -218
  6. package/template/core/README.md +0 -43
  7. package/template/core/engine/cli.mjs +0 -96
  8. package/template/core/engine/commands/_shared.mjs +0 -199
  9. package/template/core/engine/commands/deploy.mjs +0 -31
  10. package/template/core/engine/commands/dev.mjs +0 -49
  11. package/template/core/engine/commands/doctor.mjs +0 -229
  12. package/template/core/engine/commands/export.mjs +0 -8
  13. package/template/core/engine/commands/image.mjs +0 -29
  14. package/template/core/engine/commands/inspect.mjs +0 -35
  15. package/template/core/engine/commands/pdf.mjs +0 -26
  16. package/template/core/engine/commands/preview.mjs +0 -26
  17. package/template/core/engine/commands/render.mjs +0 -17
  18. package/template/core/engine/commands/replace.mjs +0 -41
  19. package/template/core/engine/commands/search.mjs +0 -33
  20. package/template/core/engine/commands/skills-sync.mjs +0 -71
  21. package/template/core/engine/commands/typecheck.mjs +0 -67
  22. package/template/core/engine/commands/upgrade.mjs +0 -159
  23. package/template/core/engine/commands/validate.mjs +0 -17
  24. package/template/core/engine/document-export.mjs +0 -15
  25. package/template/core/engine/output/chrome-pdf.d.mts +0 -34
  26. package/template/core/engine/output/chrome-pdf.mjs +0 -450
  27. package/template/core/engine/output/deploy-sync.mjs +0 -15
  28. package/template/core/engine/output/fonts.mjs +0 -62
  29. package/template/core/engine/output/katex-assets.mjs +0 -45
  30. package/template/core/engine/output/page-block.mjs +0 -30
  31. package/template/core/engine/output/pdf-media.mjs +0 -45
  32. package/template/core/engine/output/public-assets.mjs +0 -19
  33. package/template/core/engine/output/static-server.mjs +0 -571
  34. package/template/core/engine/react/caption-numbering.mjs +0 -73
  35. package/template/core/engine/react/comment-endpoint.d.mts +0 -11
  36. package/template/core/engine/react/comment-endpoint.mjs +0 -102
  37. package/template/core/engine/react/comment-marker.mjs +0 -374
  38. package/template/core/engine/react/document-entry.mjs +0 -331
  39. package/template/core/engine/react/document-export.mjs +0 -512
  40. package/template/core/engine/react/http-json.mjs +0 -24
  41. package/template/core/engine/react/mdx-compile.mjs +0 -629
  42. package/template/core/engine/react/measurement-css.mjs +0 -157
  43. package/template/core/engine/react/object-entities.mjs +0 -204
  44. package/template/core/engine/react/pagination/allocator.mjs +0 -167
  45. package/template/core/engine/react/pagination/regions.mjs +0 -81
  46. package/template/core/engine/react/pagination-constants.mjs +0 -3
  47. package/template/core/engine/react/pagination.mjs +0 -9
  48. package/template/core/engine/react/pipeline/allocate.mjs +0 -217
  49. package/template/core/engine/react/pipeline/final-render.mjs +0 -94
  50. package/template/core/engine/react/pipeline/frame-measurement.mjs +0 -306
  51. package/template/core/engine/react/pipeline/press-tree.mjs +0 -135
  52. package/template/core/engine/react/press-tree-inspection.mjs +0 -172
  53. package/template/core/engine/react/project-asset-endpoint.d.mts +0 -10
  54. package/template/core/engine/react/project-asset-endpoint.mjs +0 -361
  55. package/template/core/engine/react/section-css.mjs +0 -56
  56. package/template/core/engine/react/source-edit-endpoint.d.mts +0 -10
  57. package/template/core/engine/react/source-edit-endpoint.mjs +0 -75
  58. package/template/core/engine/react/sources/heading-numbering.mjs +0 -132
  59. package/template/core/engine/react/sources/mdx-resolver.mjs +0 -439
  60. package/template/core/engine/react/style-discovery.mjs +0 -160
  61. package/template/core/engine/runtime/config.d.mts +0 -48
  62. package/template/core/engine/runtime/config.mjs +0 -172
  63. package/template/core/engine/runtime/file-utils.mjs +0 -114
  64. package/template/core/engine/runtime/file-walk.mjs +0 -22
  65. package/template/core/engine/runtime/inspection.mjs +0 -328
  66. package/template/core/engine/runtime/issue-report.mjs +0 -44
  67. package/template/core/engine/runtime/page-geometry.mjs +0 -131
  68. package/template/core/engine/runtime/path-utils.mjs +0 -20
  69. package/template/core/engine/runtime/source-text-tools.d.mts +0 -102
  70. package/template/core/engine/runtime/source-text-tools.mjs +0 -832
  71. package/template/core/engine/runtime/source-workspace.mjs +0 -168
  72. package/template/core/engine/runtime/validation.mjs +0 -183
  73. package/template/core/index.html +0 -13
  74. package/template/core/openpress.config.mjs +0 -8
  75. package/template/core/package.json +0 -89
  76. package/template/core/src/main.tsx +0 -16
  77. package/template/core/src/openpress/app/OpenPressApp.tsx +0 -296
  78. package/template/core/src/openpress/app/OpenPressRuntime.tsx +0 -102
  79. package/template/core/src/openpress/app/WorkspaceGalleryPage.tsx +0 -219
  80. package/template/core/src/openpress/app/index.ts +0 -2
  81. package/template/core/src/openpress/core/Frame.tsx +0 -91
  82. package/template/core/src/openpress/core/FrameContext.tsx +0 -26
  83. package/template/core/src/openpress/core/MdxArea.tsx +0 -34
  84. package/template/core/src/openpress/core/Press.tsx +0 -55
  85. package/template/core/src/openpress/core/Workspace.tsx +0 -36
  86. package/template/core/src/openpress/core/cn.ts +0 -4
  87. package/template/core/src/openpress/core/index.tsx +0 -47
  88. package/template/core/src/openpress/core/primitives.tsx +0 -91
  89. package/template/core/src/openpress/core/types.ts +0 -236
  90. package/template/core/src/openpress/core/useSource.ts +0 -28
  91. package/template/core/src/openpress/document-model/anchorMapModel.ts +0 -27
  92. package/template/core/src/openpress/document-model/documentIndexes.ts +0 -329
  93. package/template/core/src/openpress/document-model/documentTypes.ts +0 -147
  94. package/template/core/src/openpress/document-model/index.ts +0 -7
  95. package/template/core/src/openpress/document-model/objectEntityModel.ts +0 -55
  96. package/template/core/src/openpress/document-model/projectIdentityModel.ts +0 -15
  97. package/template/core/src/openpress/document-model/reactDocumentMetadataModel.ts +0 -27
  98. package/template/core/src/openpress/document-model/workspaceManifestModel.ts +0 -57
  99. package/template/core/src/openpress/manuscript/index.tsx +0 -238
  100. package/template/core/src/openpress/mdx/index.ts +0 -96
  101. package/template/core/src/openpress/numbering/index.ts +0 -294
  102. package/template/core/src/openpress/reader/PageThumbnailsPanel.tsx +0 -168
  103. package/template/core/src/openpress/reader/PublicReaderPage.tsx +0 -267
  104. package/template/core/src/openpress/reader/ReaderNavigationPanel.tsx +0 -123
  105. package/template/core/src/openpress/reader/index.ts +0 -11
  106. package/template/core/src/openpress/reader/pageViewportScaleModel.ts +0 -73
  107. package/template/core/src/openpress/reader/readerPageRegistry.ts +0 -41
  108. package/template/core/src/openpress/reader/readerPageRoute.ts +0 -21
  109. package/template/core/src/openpress/reader/readerScroll.ts +0 -92
  110. package/template/core/src/openpress/reader/readerStateModel.ts +0 -15
  111. package/template/core/src/openpress/reader/readerTypes.ts +0 -4
  112. package/template/core/src/openpress/reader/usePageViewportScale.ts +0 -119
  113. package/template/core/src/openpress/reader/usePanelState.ts +0 -56
  114. package/template/core/src/openpress/reader/useReaderHashSync.ts +0 -61
  115. package/template/core/src/openpress/reader/useReaderKeyboardNav.ts +0 -48
  116. package/template/core/src/openpress/reader/useReaderRuntime.ts +0 -146
  117. package/template/core/src/openpress/reader/useReaderScrollAnchor.ts +0 -64
  118. package/template/core/src/openpress/shared/Panel.tsx +0 -77
  119. package/template/core/src/openpress/shared/frameScheduler.ts +0 -32
  120. package/template/core/src/openpress/shared/index.ts +0 -4
  121. package/template/core/src/openpress/shared/numberUtils.ts +0 -3
  122. package/template/core/src/openpress/shared/runtimeMode.ts +0 -11
  123. package/template/core/src/openpress/workbench/Workbench.tsx +0 -506
  124. package/template/core/src/openpress/workbench/actions/DeploymentControl.tsx +0 -157
  125. package/template/core/src/openpress/workbench/actions/ExportImageControl.tsx +0 -96
  126. package/template/core/src/openpress/workbench/actions/PageZoomControl.tsx +0 -182
  127. package/template/core/src/openpress/workbench/actions/SearchControl.tsx +0 -345
  128. package/template/core/src/openpress/workbench/actions/deploymentStatusModel.ts +0 -112
  129. package/template/core/src/openpress/workbench/actions/index.ts +0 -6
  130. package/template/core/src/openpress/workbench/actions/useDeploymentWorkbench.ts +0 -136
  131. package/template/core/src/openpress/workbench/dialog/WorkbenchDialog.tsx +0 -72
  132. package/template/core/src/openpress/workbench/dialog/index.ts +0 -1
  133. package/template/core/src/openpress/workbench/document/components/DocumentPanel.tsx +0 -127
  134. package/template/core/src/openpress/workbench/document/components/InlineSourceEditorLayer.tsx +0 -207
  135. package/template/core/src/openpress/workbench/document/components/ReaderStage.tsx +0 -9
  136. package/template/core/src/openpress/workbench/document/hooks/useDocumentWorkbenchModel.ts +0 -34
  137. package/template/core/src/openpress/workbench/document/hooks/useInlineDocumentEditor.ts +0 -525
  138. package/template/core/src/openpress/workbench/document/index.ts +0 -10
  139. package/template/core/src/openpress/workbench/index.ts +0 -2
  140. package/template/core/src/openpress/workbench/inspector/InlineInspectorLayer.tsx +0 -459
  141. package/template/core/src/openpress/workbench/inspector/index.ts +0 -5
  142. package/template/core/src/openpress/workbench/inspector/inlineCommentModel.ts +0 -125
  143. package/template/core/src/openpress/workbench/inspector/inspectorGeometryModel.ts +0 -160
  144. package/template/core/src/openpress/workbench/inspector/inspectorModel.ts +0 -408
  145. package/template/core/src/openpress/workbench/inspector/useInspectorComments.ts +0 -254
  146. package/template/core/src/openpress/workbench/mentions/MentionSuggestionList.tsx +0 -41
  147. package/template/core/src/openpress/workbench/mentions/index.ts +0 -2
  148. package/template/core/src/openpress/workbench/mentions/useComposerMentions.ts +0 -185
  149. package/template/core/src/openpress/workbench/panels/Panel.tsx +0 -1
  150. package/template/core/src/openpress/workbench/panels/PendingCommentsPanel.tsx +0 -80
  151. package/template/core/src/openpress/workbench/panels/WorkbenchControlPanel.tsx +0 -29
  152. package/template/core/src/openpress/workbench/panels/index.ts +0 -3
  153. package/template/core/src/openpress/workbench/project/ProjectEntryPanel.tsx +0 -525
  154. package/template/core/src/openpress/workbench/project/ProjectPreviewDialog.tsx +0 -35
  155. package/template/core/src/openpress/workbench/project/index.ts +0 -2
  156. package/template/core/src/openpress/workbench/project/projectPreviewTypes.ts +0 -11
  157. package/template/core/src/openpress/workbench/project/projectSourceModel.ts +0 -24
  158. package/template/core/src/openpress/workbench/shell/WorkbenchShell.tsx +0 -167
  159. package/template/core/src/openpress/workbench/shell/index.ts +0 -1
  160. package/template/core/src/openpress/workbench/workbenchFormatters.ts +0 -120
  161. package/template/core/src/openpress/workbench/workbenchTypes.ts +0 -35
  162. package/template/core/src/styles/openpress/app-shell.css +0 -251
  163. package/template/core/src/styles/openpress/media-workspace.css +0 -230
  164. package/template/core/src/styles/openpress/print-route.css +0 -184
  165. package/template/core/src/styles/openpress/project-preview-panel.css +0 -924
  166. package/template/core/src/styles/openpress/public-viewer.css +0 -688
  167. package/template/core/src/styles/openpress/reader-runtime.css +0 -989
  168. package/template/core/src/styles/openpress/responsive.css +0 -245
  169. package/template/core/src/styles/openpress/workbench-panels.css +0 -707
  170. package/template/core/src/styles/openpress/workbench.css +0 -1255
  171. package/template/core/src/styles/openpress/workspace-gallery.css +0 -300
  172. package/template/core/src/styles/openpress.css +0 -15
  173. package/template/core/src/vite-env.d.ts +0 -9
  174. package/template/core/tsconfig.json +0 -40
  175. package/template/core/vite.config.ts +0 -584
@@ -1,56 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import postcss from "postcss";
3
-
4
- const UNSCOPED_RULE_PARENTS = new Set(["keyframes", "-webkit-keyframes", "page"]);
5
-
6
- // Section-scoped CSS. Style files under `chapters/<slug>/styles/*.css` (in
7
- // the section-folders preset) are scoped to `[data-section-id="<slug>"]`.
8
- // Workspaces using other source presets do not get section-scoped CSS in v1.
9
- export async function buildSectionScopedCss(workspace) {
10
- const parts = [];
11
- for (const section of workspace.sections ?? workspace.chapters ?? []) {
12
- for (const styleFile of section.styleFiles ?? []) {
13
- const source = await fs.readFile(styleFile.absolutePath, "utf8");
14
- const scoped = await scopeSectionCss(source, {
15
- sectionSlug: section.slug,
16
- from: styleFile.absolutePath,
17
- });
18
- if (!scoped.trim()) continue;
19
- parts.push(`/* === ${styleFile.documentPath} === */`);
20
- parts.push(scoped.trimEnd());
21
- parts.push("");
22
- }
23
- }
24
- return parts.join("\n");
25
- }
26
-
27
- export async function scopeSectionCss(source, { sectionSlug, from = undefined } = {}) {
28
- if (typeof source !== "string") throw new Error("scopeSectionCss requires a CSS source string.");
29
- const slug = cssAttributeValue(sectionSlug);
30
- const scope = `[data-section-id="${slug}"]`;
31
- const root = postcss.parse(source, { from });
32
-
33
- root.walkRules((rule) => {
34
- if (isInsideUnscopedAtRule(rule)) return;
35
- rule.selector = `${scope} :where(${rule.selector})`;
36
- });
37
-
38
- return root.toString();
39
- }
40
-
41
- function isInsideUnscopedAtRule(node) {
42
- let current = node.parent;
43
- while (current) {
44
- if (current.type === "atrule" && UNSCOPED_RULE_PARENTS.has(current.name.toLowerCase())) {
45
- return true;
46
- }
47
- current = current.parent;
48
- }
49
- return false;
50
- }
51
-
52
- function cssAttributeValue(value) {
53
- return String(value ?? "")
54
- .replaceAll("\\", "\\\\")
55
- .replaceAll('"', '\\"');
56
- }
@@ -1,10 +0,0 @@
1
- import type { IncomingMessage, ServerResponse } from "node:http";
2
-
3
- export function handleSourceEditRequest(
4
- req: IncomingMessage,
5
- res: ServerResponse,
6
- options?: {
7
- root?: string;
8
- refreshDocument?: boolean;
9
- },
10
- ): Promise<void>;
@@ -1,75 +0,0 @@
1
- import { loadConfig } from "../runtime/config.mjs";
2
- import { applySourceBlockTextEdit, readSourceBlockText } from "../runtime/source-text-tools.mjs";
3
- import { exportReactDocument } from "./document-export.mjs";
4
- import { readJsonBody, writeJson } from "./http-json.mjs";
5
-
6
- export async function handleSourceEditRequest(req, res, {
7
- root = ".",
8
- refreshDocument = true,
9
- } = {}) {
10
- if (req.method === "GET") {
11
- try {
12
- const requestUrl = new URL(req.url ?? "/", "http://localhost");
13
- const config = await loadConfig(root);
14
- const sourceText = await readSourceBlockText({
15
- config,
16
- path: requestUrl.searchParams.get("path"),
17
- source: {
18
- line: Number(requestUrl.searchParams.get("line")),
19
- column: Number(requestUrl.searchParams.get("column") || 1),
20
- endLine: Number(requestUrl.searchParams.get("endLine") || requestUrl.searchParams.get("line")),
21
- endColumn: Number(requestUrl.searchParams.get("endColumn") || requestUrl.searchParams.get("column") || 1),
22
- },
23
- });
24
- writeJson(res, 200, { ok: true, source: sourceText });
25
- } catch (error) {
26
- writeJson(res, 400, {
27
- ok: false,
28
- message: error instanceof Error ? error.message : String(error),
29
- });
30
- }
31
- return;
32
- }
33
-
34
- if (req.method !== "POST") {
35
- writeJson(res, 405, { ok: false, message: "OpenPress source edit endpoint requires GET or POST." });
36
- return;
37
- }
38
-
39
- try {
40
- const body = await readJsonBody(req, {
41
- bodyLabel: "OpenPress source edit request",
42
- maxBytes: 256 * 1024,
43
- });
44
- const config = await loadConfig(root);
45
- const edit = await applySourceBlockTextEdit({
46
- config,
47
- path: body?.path,
48
- source: body?.source,
49
- text: body?.text,
50
- kind: body?.kind,
51
- name: body?.name,
52
- blockId: body?.blockId,
53
- sourceMode: body?.sourceMode === true,
54
- });
55
- const exported = refreshDocument && body?.refreshDocument !== false
56
- ? await exportReactDocument(root, { syncAssets: false })
57
- : null;
58
-
59
- writeJson(res, 200, {
60
- ok: true,
61
- edit,
62
- document: exported
63
- ? {
64
- path: exported.documentPath,
65
- pageCount: exported.pageCount,
66
- }
67
- : undefined,
68
- });
69
- } catch (error) {
70
- writeJson(res, 400, {
71
- ok: false,
72
- message: error instanceof Error ? error.message : String(error),
73
- });
74
- }
75
- }
@@ -1,132 +0,0 @@
1
- // Heading numbering and outline emission for MDX sources.
2
- //
3
- // Pure functions called from `mdx-resolver.mjs` while walking each section's
4
- // compiled blocks. Produces:
5
- // - `data-chapter` / `data-section` / `data-topic` attributes on heading
6
- // blocks (h2/h3/h4)
7
- // - stable IDs on the same blocks
8
- // - outline entries (for TOC + reader navigation)
9
- //
10
- // Numbering state is per-source, advances forward through blocks in source
11
- // order. The caller threads `headingState` between calls.
12
-
13
- /**
14
- * Build a fresh per-source heading state. One state object per call to
15
- * `resolveSource` — counts subsection / topic indices and tracks whether
16
- * this section has already seen its chapter heading.
17
- */
18
- export function createHeadingState() {
19
- return {
20
- hasChapterHeading: false,
21
- subsectionCounter: 0,
22
- topicCounter: 0,
23
- };
24
- }
25
-
26
- /**
27
- * For one block emitted by the MDX compiler, decide whether it is a heading,
28
- * what id/data-* attributes it should carry, and whether it adds an entry to
29
- * the outline. Returns `null` for non-heading blocks.
30
- *
31
- * @param {object} opts
32
- * @param {object} opts.block The compiled block record.
33
- * @param {string} opts.sourceId Source registry key.
34
- * @param {object} opts.section Section descriptor (slug, title, …).
35
- * @param {Array} opts.outlineItems Mutable outline array — entries are pushed onto it.
36
- * @param {number} opts.chapterNumber 1-based chapter index for this section.
37
- * @param {string} opts.chapterLabel Display label, e.g. `"#3"` or `"03"`.
38
- * @param {object} opts.headingState Per-source counter state from `createHeadingState`.
39
- */
40
- export function headingAttributesForBlock({
41
- block,
42
- sourceId,
43
- section,
44
- outlineItems,
45
- chapterNumber,
46
- chapterLabel,
47
- headingState,
48
- }) {
49
- const title = String(block.text ?? "").trim();
50
-
51
- if (block.name === "h2") {
52
- const firstChapterHeading = !headingState.hasChapterHeading;
53
- const id = firstChapterHeading ? `section-${section.slug}` : block.id;
54
- const headingTitle = title || section.title || section.slug;
55
- outlineItems.push({
56
- id: `${sourceId}:${section.slug}:${block.id}`,
57
- tocId: firstChapterHeading
58
- ? `toc-${sourceId}-${section.slug}`
59
- : `toc-${sourceId}-${section.slug}-${block.id}`,
60
- depth: 0,
61
- title: headingTitle,
62
- label: chapterLabel,
63
- sectionSlug: section.slug,
64
- blockId: block.id,
65
- href: `#${id}`,
66
- });
67
- headingState.hasChapterHeading = true;
68
- headingState.subsectionCounter = 0;
69
- headingState.topicCounter = 0;
70
- return {
71
- attributes: {
72
- id,
73
- "data-chapter": chapterLabel,
74
- },
75
- sectionTitle: firstChapterHeading ? headingTitle : undefined,
76
- };
77
- }
78
-
79
- if (block.name === "h3") {
80
- headingState.subsectionCounter += 1;
81
- headingState.topicCounter = 0;
82
- const label = `${chapterNumber}.${headingState.subsectionCounter}`;
83
- outlineItems.push({
84
- id: `${sourceId}:${section.slug}:${block.id}`,
85
- tocId: `toc-${sourceId}-${section.slug}-${block.id}`,
86
- depth: 1,
87
- title: title || `Section ${label}`,
88
- label,
89
- sectionSlug: section.slug,
90
- blockId: block.id,
91
- href: `#${block.id}`,
92
- });
93
- return {
94
- attributes: {
95
- id: block.id,
96
- "data-section": label,
97
- },
98
- };
99
- }
100
-
101
- if (block.name === "h4") {
102
- headingState.topicCounter += 1;
103
- const label = `${chapterNumber}.${Math.max(1, headingState.subsectionCounter)}.${headingState.topicCounter}`;
104
- return {
105
- attributes: {
106
- id: block.id,
107
- "data-topic": label,
108
- },
109
- };
110
- }
111
-
112
- return null;
113
- }
114
-
115
- /**
116
- * Build a fallback single-entry outline when a section has no h2/h3 headings
117
- * the resolver could pick up. The outline still needs one row so the TOC
118
- * doesn't lose the section.
119
- */
120
- export function fallbackOutlineItems({ sourceId, section, chapterLabel, title, blocks }) {
121
- const targetBlock = blocks[0];
122
- return [{
123
- id: `${sourceId}:${section.slug}`,
124
- tocId: `toc-${sourceId}-${section.slug}`,
125
- depth: 0,
126
- title,
127
- label: chapterLabel,
128
- sectionSlug: section.slug,
129
- blockId: targetBlock?.id,
130
- href: `#section-${section.slug}`,
131
- }];
132
- }