@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,131 +0,0 @@
1
- const CSS_LENGTH_RE = /^(\d+(?:\.\d+)?)(px|mm|cm|in|pt|pc)$/i;
2
-
3
- export const PAGE_GEOMETRY_PRESETS = {
4
- a4: {
5
- id: "a4",
6
- label: "A4 Page",
7
- width: "210mm",
8
- height: "297mm",
9
- },
10
- "social-square": {
11
- id: "social-square",
12
- label: "Social Square",
13
- width: "1080px",
14
- height: "1080px",
15
- },
16
- "slide-16-9": {
17
- id: "slide-16-9",
18
- label: "Slide 16:9",
19
- width: "1920px",
20
- height: "1080px",
21
- },
22
- };
23
-
24
- export function normalizePageGeometry(value) {
25
- if (value == null || value === false) return null;
26
-
27
- if (typeof value === "string") {
28
- return presetPageGeometry(value);
29
- }
30
-
31
- if (typeof value !== "object" || Array.isArray(value)) {
32
- throw new Error("OpenPress config page must be a preset name or an object.");
33
- }
34
-
35
- const preset = typeof value.preset === "string" ? presetPageGeometry(value.preset) : null;
36
- const width = cssLengthValue(value.width, preset?.width);
37
- const height = cssLengthValue(value.height, preset?.height);
38
- if (!width || !height) {
39
- throw new Error("OpenPress config page requires width and height when no preset is provided.");
40
- }
41
-
42
- const id = optionalId(value.id, preset?.id ?? "custom");
43
- const label = optionalLabel(value.label, preset?.label ?? "Custom Page");
44
-
45
- return pageGeometry({
46
- id,
47
- label,
48
- width,
49
- height,
50
- });
51
- }
52
-
53
- export function pageGeometryToTheme(page) {
54
- if (!page) return undefined;
55
- return {
56
- pagePreset: page.id,
57
- pageLabel: page.label,
58
- pageWidth: page.width,
59
- pageHeight: page.height,
60
- pageAspectRatio: page.aspectRatio,
61
- pageHeightRatio: page.heightRatio,
62
- };
63
- }
64
-
65
- function presetPageGeometry(id) {
66
- const preset = PAGE_GEOMETRY_PRESETS[id];
67
- if (!preset) {
68
- throw new Error(
69
- `Unknown OpenPress page preset: "${id}". ` +
70
- `Available presets: ${Object.keys(PAGE_GEOMETRY_PRESETS).join(", ")}.`,
71
- );
72
- }
73
- return pageGeometry(preset);
74
- }
75
-
76
- function pageGeometry({ id, label, width, height }) {
77
- const ratio = sameUnitRatio(width, height);
78
- return {
79
- id,
80
- label,
81
- width,
82
- height,
83
- aspectRatio: ratio ? `${trimNumber(ratio.width)} / ${trimNumber(ratio.height)}` : undefined,
84
- heightRatio: ratio ? trimNumber(ratio.height / ratio.width) : undefined,
85
- };
86
- }
87
-
88
- function cssLengthValue(value, fallback) {
89
- if (value == null) return fallback ?? null;
90
- if (typeof value !== "string" || !value.trim()) {
91
- throw new Error("OpenPress page width/height must be CSS length strings.");
92
- }
93
- const trimmed = value.trim();
94
- if (!CSS_LENGTH_RE.test(trimmed)) {
95
- throw new Error(`OpenPress page size must be an absolute CSS length, got: ${trimmed}`);
96
- }
97
- return trimmed;
98
- }
99
-
100
- function optionalId(value, fallback) {
101
- if (value == null) return fallback;
102
- if (typeof value !== "string" || !/^[a-z0-9][a-z0-9-]*$/i.test(value)) {
103
- throw new Error("OpenPress page id must be a simple slug.");
104
- }
105
- return value;
106
- }
107
-
108
- function optionalLabel(value, fallback) {
109
- if (value == null) return fallback;
110
- if (typeof value !== "string" || !value.trim()) {
111
- throw new Error("OpenPress page label must be a non-empty string.");
112
- }
113
- return value.trim();
114
- }
115
-
116
- function sameUnitRatio(width, height) {
117
- const w = parseCssLength(width);
118
- const h = parseCssLength(height);
119
- if (!w || !h || w.unit.toLowerCase() !== h.unit.toLowerCase()) return null;
120
- return { width: w.value, height: h.value };
121
- }
122
-
123
- function parseCssLength(value) {
124
- const match = CSS_LENGTH_RE.exec(value);
125
- if (!match) return null;
126
- return { value: Number(match[1]), unit: match[2] };
127
- }
128
-
129
- function trimNumber(value) {
130
- return Number(value.toFixed(6)).toString();
131
- }
@@ -1,20 +0,0 @@
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
- }
@@ -1,102 +0,0 @@
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
- }>>;