@open-press/cli 0.7.1 → 0.8.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 (119) hide show
  1. package/README.md +6 -1
  2. package/package.json +1 -1
  3. package/template/core/CHANGELOG.md +45 -0
  4. package/template/core/engine/commands/dev.mjs +2 -2
  5. package/template/core/engine/output/chrome-pdf.mjs +18 -3
  6. package/template/core/engine/output/static-server.mjs +39 -0
  7. package/template/core/engine/react/comment-endpoint.mjs +13 -39
  8. package/template/core/engine/react/comment-marker.mjs +30 -6
  9. package/template/core/engine/react/document-entry.mjs +11 -0
  10. package/template/core/engine/react/document-export.mjs +30 -5
  11. package/template/core/engine/react/http-json.mjs +24 -0
  12. package/template/core/engine/react/mdx-compile.mjs +96 -3
  13. package/template/core/engine/react/measurement-css.mjs +93 -1
  14. package/template/core/engine/react/object-entities.mjs +119 -0
  15. package/template/core/engine/react/pipeline/allocate.mjs +10 -7
  16. package/template/core/engine/react/pipeline/frame-measurement.mjs +2 -0
  17. package/template/core/engine/react/project-asset-endpoint.mjs +6 -24
  18. package/template/core/engine/react/source-edit-endpoint.d.mts +10 -0
  19. package/template/core/engine/react/source-edit-endpoint.mjs +75 -0
  20. package/template/core/engine/react/sources/mdx-resolver.mjs +12 -14
  21. package/template/core/engine/react/style-discovery.mjs +1 -4
  22. package/template/core/engine/runtime/file-walk.mjs +22 -0
  23. package/template/core/engine/runtime/inspection.mjs +1 -20
  24. package/template/core/engine/runtime/path-utils.mjs +20 -0
  25. package/template/core/engine/runtime/source-text-tools.d.mts +102 -0
  26. package/template/core/engine/runtime/source-text-tools.mjs +551 -16
  27. package/template/core/engine/runtime/source-workspace.mjs +4 -31
  28. package/template/core/package.json +1 -1
  29. package/template/core/src/main.tsx +2 -2
  30. package/template/core/src/openpress/{App.tsx → app/OpenPressApp.tsx} +25 -12
  31. package/template/core/src/openpress/{renderer.tsx → app/OpenPressRuntime.tsx} +10 -7
  32. package/template/core/src/openpress/app/index.ts +2 -0
  33. package/template/core/src/openpress/core/Frame.tsx +9 -11
  34. package/template/core/src/openpress/core/FrameContext.tsx +8 -3
  35. package/template/core/src/openpress/core/MdxArea.tsx +11 -12
  36. package/template/core/src/openpress/core/cn.ts +4 -0
  37. package/template/core/src/openpress/core/index.tsx +2 -1
  38. package/template/core/src/openpress/core/primitives.tsx +29 -8
  39. package/template/core/src/openpress/core/types.ts +8 -0
  40. package/template/core/src/openpress/{anchorMap.ts → document-model/anchorMapModel.ts} +1 -1
  41. package/template/core/src/openpress/{indexes.ts → document-model/documentIndexes.ts} +1 -1
  42. package/template/core/src/openpress/{types.ts → document-model/documentTypes.ts} +42 -0
  43. package/template/core/src/openpress/document-model/index.ts +6 -0
  44. package/template/core/src/openpress/document-model/objectEntityModel.ts +51 -0
  45. package/template/core/src/openpress/{projectIdentity.ts → document-model/projectIdentityModel.ts} +1 -1
  46. package/template/core/src/openpress/{reactDocumentMetadata.ts → document-model/reactDocumentMetadataModel.ts} +1 -1
  47. package/template/core/src/openpress/manuscript/index.tsx +49 -7
  48. package/template/core/src/openpress/{publicPage.tsx → reader/PublicReaderPage.tsx} +31 -51
  49. package/template/core/src/openpress/{workbenchPanels.tsx → reader/ReaderNavigationPanel.tsx} +6 -5
  50. package/template/core/src/openpress/reader/index.ts +10 -0
  51. package/template/core/src/openpress/reader/pageViewportScaleModel.ts +73 -0
  52. package/template/core/src/openpress/reader/readerTypes.ts +4 -0
  53. package/template/core/src/openpress/reader/usePageViewportScale.ts +119 -0
  54. package/template/core/src/openpress/reader/usePanelState.ts +56 -0
  55. package/template/core/src/openpress/reader/useReaderHashSync.ts +61 -0
  56. package/template/core/src/openpress/reader/useReaderKeyboardNav.ts +48 -0
  57. package/template/core/src/openpress/reader/useReaderRuntime.ts +146 -0
  58. package/template/core/src/openpress/reader/useReaderScrollAnchor.ts +64 -0
  59. package/template/core/src/openpress/shared/Panel.tsx +77 -0
  60. package/template/core/src/openpress/shared/index.ts +4 -0
  61. package/template/core/src/openpress/shared/numberUtils.ts +3 -0
  62. package/template/core/src/openpress/{runtimeMode.ts → shared/runtimeMode.ts} +0 -11
  63. package/template/core/src/openpress/workbench/Workbench.tsx +407 -0
  64. package/template/core/src/openpress/workbench/actions/DeploymentControl.tsx +157 -0
  65. package/template/core/src/openpress/workbench/actions/PageZoomControl.tsx +182 -0
  66. package/template/core/src/openpress/workbench/actions/SearchControl.tsx +345 -0
  67. package/template/core/src/openpress/workbench/actions/deploymentStatusModel.ts +112 -0
  68. package/template/core/src/openpress/workbench/actions/index.ts +5 -0
  69. package/template/core/src/openpress/workbench/actions/useDeploymentWorkbench.ts +136 -0
  70. package/template/core/src/openpress/workbench/dialog/WorkbenchDialog.tsx +72 -0
  71. package/template/core/src/openpress/workbench/dialog/index.ts +1 -0
  72. package/template/core/src/openpress/workbench/document/components/DocumentPanel.tsx +127 -0
  73. package/template/core/src/openpress/workbench/document/components/InlineSourceEditorLayer.tsx +207 -0
  74. package/template/core/src/openpress/workbench/document/components/ReaderStage.tsx +9 -0
  75. package/template/core/src/openpress/workbench/document/hooks/useDocumentWorkbenchModel.ts +34 -0
  76. package/template/core/src/openpress/workbench/document/hooks/useInlineDocumentEditor.ts +525 -0
  77. package/template/core/src/openpress/workbench/document/index.ts +10 -0
  78. package/template/core/src/openpress/workbench/index.ts +2 -0
  79. package/template/core/src/openpress/workbench/inspector/InlineInspectorLayer.tsx +459 -0
  80. package/template/core/src/openpress/workbench/inspector/index.ts +5 -0
  81. package/template/core/src/openpress/workbench/inspector/inlineCommentModel.ts +125 -0
  82. package/template/core/src/openpress/workbench/inspector/inspectorGeometryModel.ts +160 -0
  83. package/template/core/src/openpress/workbench/inspector/inspectorModel.ts +408 -0
  84. package/template/core/src/openpress/workbench/inspector/useInspectorComments.ts +248 -0
  85. package/template/core/src/openpress/workbench/mentions/MentionSuggestionList.tsx +41 -0
  86. package/template/core/src/openpress/workbench/mentions/index.ts +2 -0
  87. package/template/core/src/openpress/{composerMentions.ts → workbench/mentions/useComposerMentions.ts} +1 -4
  88. package/template/core/src/openpress/workbench/panels/Panel.tsx +1 -0
  89. package/template/core/src/openpress/workbench/panels/PendingCommentsPanel.tsx +76 -0
  90. package/template/core/src/openpress/workbench/panels/WorkbenchControlPanel.tsx +29 -0
  91. package/template/core/src/openpress/workbench/panels/index.ts +3 -0
  92. package/template/core/src/openpress/workbench/project/ProjectEntryPanel.tsx +523 -0
  93. package/template/core/src/openpress/workbench/project/ProjectPreviewDialog.tsx +35 -0
  94. package/template/core/src/openpress/workbench/project/index.ts +2 -0
  95. package/template/core/src/openpress/workbench/project/projectPreviewTypes.ts +11 -0
  96. package/template/core/src/openpress/workbench/shell/WorkbenchShell.tsx +167 -0
  97. package/template/core/src/openpress/workbench/shell/index.ts +1 -0
  98. package/template/core/src/openpress/workbench/workbenchFormatters.ts +120 -0
  99. package/template/core/src/openpress/workbench/workbenchTypes.ts +35 -0
  100. package/template/core/src/styles/openpress/print-route.css +0 -2
  101. package/template/core/src/styles/openpress/{project-workspace.css → project-preview-panel.css} +13 -407
  102. package/template/core/src/styles/openpress/public-viewer.css +25 -320
  103. package/template/core/src/styles/openpress/reader-runtime.css +243 -55
  104. package/template/core/src/styles/openpress/responsive.css +145 -270
  105. package/template/core/src/styles/openpress/workbench-panels.css +214 -178
  106. package/template/core/src/styles/openpress/workbench.css +986 -451
  107. package/template/core/src/styles/openpress.css +1 -1
  108. package/template/core/vite.config.ts +50 -0
  109. package/template/core/src/openpress/inspector.ts +0 -282
  110. package/template/core/src/openpress/projectWorkspace.tsx +0 -919
  111. package/template/core/src/openpress/readerRuntime.ts +0 -230
  112. package/template/core/src/openpress/workbench.tsx +0 -1265
  113. package/template/core/src/openpress/workbenchTypes.ts +0 -4
  114. /package/template/core/src/openpress/{readerPageRegistry.ts → reader/readerPageRegistry.ts} +0 -0
  115. /package/template/core/src/openpress/{pageRoute.ts → reader/readerPageRoute.ts} +0 -0
  116. /package/template/core/src/openpress/{readerScroll.ts → reader/readerScroll.ts} +0 -0
  117. /package/template/core/src/openpress/{readerState.ts → reader/readerStateModel.ts} +0 -0
  118. /package/template/core/src/openpress/{frameScheduler.ts → shared/frameScheduler.ts} +0 -0
  119. /package/template/core/src/openpress/{projectSources.ts → workbench/project/projectSourceModel.ts} +0 -0
@@ -0,0 +1,22 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+
4
+ export async function walkFiles(directory, visit) {
5
+ let entries;
6
+ try {
7
+ entries = await fs.readdir(directory, { withFileTypes: true });
8
+ } catch (error) {
9
+ if (error?.code === "ENOENT") return;
10
+ throw error;
11
+ }
12
+
13
+ for (const entry of entries) {
14
+ if (entry.name.startsWith(".")) continue;
15
+ const absolutePath = path.join(directory, entry.name);
16
+ if (entry.isDirectory()) {
17
+ await walkFiles(absolutePath, visit);
18
+ } else if (entry.isFile()) {
19
+ await visit(absolutePath);
20
+ }
21
+ }
22
+ }
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { evaluateUrlWithChrome, stopChildProcess } from "../output/chrome-pdf.mjs";
4
4
  import { buildReactStatic, startStaticServer } from "../commands/_shared.mjs";
5
+ import { walkFiles } from "./file-walk.mjs";
5
6
  import { createIssue, createIssueReport } from "./issue-report.mjs";
6
7
  import { collectActiveContentFiles, resolveActiveSourceWorkspace } from "./source-workspace.mjs";
7
8
 
@@ -217,26 +218,6 @@ async function readMediaFiles(directory) {
217
218
  return files;
218
219
  }
219
220
 
220
- async function walkFiles(directory, visit) {
221
- let entries;
222
- try {
223
- entries = await fs.readdir(directory, { withFileTypes: true });
224
- } catch (error) {
225
- if (error?.code === "ENOENT") return;
226
- throw error;
227
- }
228
-
229
- for (const entry of entries) {
230
- if (entry.name.startsWith(".")) continue;
231
- const absolutePath = path.join(directory, entry.name);
232
- if (entry.isDirectory()) {
233
- await walkFiles(absolutePath, visit);
234
- } else if (entry.isFile()) {
235
- await visit(absolutePath);
236
- }
237
- }
238
- }
239
-
240
221
  function summarizeComponentUsage(contentFiles) {
241
222
  const usages = new Map();
242
223
  for (const file of contentFiles) {
@@ -0,0 +1,20 @@
1
+ import path from "node:path";
2
+
3
+ export function rootRelativePath(config, absolutePath) {
4
+ return path.relative(config.root, absolutePath).replaceAll("\\", "/");
5
+ }
6
+
7
+ export function documentRelativePath(absolutePath, documentRoot) {
8
+ return path.relative(documentRoot, absolutePath).split(path.sep).join("/");
9
+ }
10
+
11
+ export function resolveDocumentRelativePath(documentRoot, rel, label) {
12
+ if (typeof rel !== "string" || !rel.trim()) throw new Error(`${label} must be a non-empty document-relative path.`);
13
+ if (rel.includes("..")) throw new Error(`${label} contains "..", rejected.`);
14
+ const absolutePath = path.resolve(documentRoot, rel);
15
+ const relCheck = path.relative(documentRoot, absolutePath);
16
+ if (relCheck.startsWith("..") || path.isAbsolute(relCheck)) {
17
+ throw new Error(`${label} escapes the document root.`);
18
+ }
19
+ return absolutePath;
20
+ }
@@ -0,0 +1,102 @@
1
+ import type { ResolvedConfig } from "./config.mjs";
2
+
3
+ export type SourceTextScope = "content" | "all";
4
+
5
+ export type SourceTextMatch = {
6
+ id: string;
7
+ scope: string;
8
+ file: string;
9
+ path: string;
10
+ line: number;
11
+ column: number;
12
+ index: number;
13
+ text: string;
14
+ preview: string;
15
+ };
16
+
17
+ export type SourceTextFileSummary = {
18
+ scope: string;
19
+ file: string;
20
+ path: string;
21
+ matchCount: number;
22
+ };
23
+
24
+ export type SourceSearchReport = {
25
+ kind: "search";
26
+ query: string;
27
+ scope: SourceTextScope;
28
+ caseSensitive: boolean;
29
+ matchCount: number;
30
+ files: Array<SourceTextFileSummary>;
31
+ matches: Array<SourceTextMatch>;
32
+ };
33
+
34
+ export type SourceBlockTextEditInput = {
35
+ config: ResolvedConfig;
36
+ path: string;
37
+ source: {
38
+ line: number;
39
+ column?: number;
40
+ endLine?: number;
41
+ endColumn?: number;
42
+ };
43
+ text: string;
44
+ kind?: string;
45
+ name?: string;
46
+ blockId?: string;
47
+ cellIndex?: number;
48
+ sourceMode?: boolean;
49
+ };
50
+
51
+ export type SourceBlockTextEdit = {
52
+ blockId?: string;
53
+ path: string;
54
+ requestedPath: string;
55
+ file: string;
56
+ line: number;
57
+ column: number;
58
+ endLine: number;
59
+ endColumn: number;
60
+ before: string;
61
+ after: string;
62
+ text: string;
63
+ cellIndex?: number;
64
+ };
65
+
66
+ export function searchSourceText(options: {
67
+ config: ResolvedConfig;
68
+ query: string;
69
+ scope?: SourceTextScope;
70
+ caseSensitive?: boolean;
71
+ }): Promise<SourceSearchReport>;
72
+
73
+ export function applySourceBlockTextEdit(options: SourceBlockTextEditInput): Promise<SourceBlockTextEdit>;
74
+
75
+ export function applySourceBlockTextEditToText(documentText: string, options: Omit<SourceBlockTextEditInput, "config" | "path">): {
76
+ text: string;
77
+ edit: Omit<SourceBlockTextEdit, "path" | "requestedPath" | "file">;
78
+ };
79
+
80
+ export function readSourceBlockText(options: Pick<SourceBlockTextEditInput, "config" | "path" | "source">): Promise<{
81
+ path: string;
82
+ requestedPath: string;
83
+ file: string;
84
+ text: string;
85
+ }>;
86
+
87
+ export function readSourceBlockTextFromText(documentText: string, options: Pick<SourceBlockTextEditInput, "source">): string;
88
+
89
+ export function applySourceBlockSourceEditToText(documentText: string, options: Pick<SourceBlockTextEditInput, "source" | "text" | "blockId">): {
90
+ text: string;
91
+ edit: Omit<SourceBlockTextEdit, "path" | "requestedPath" | "file">;
92
+ };
93
+
94
+ export function collectSourceTextFiles(config: ResolvedConfig, options?: {
95
+ scope?: SourceTextScope;
96
+ }): Promise<Array<{
97
+ scope: string;
98
+ name: string;
99
+ absolutePath: string;
100
+ relativePath: string;
101
+ text: string;
102
+ }>>;