@imjp/writenex-astro 0.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 (141) hide show
  1. package/README.md +539 -0
  2. package/dist/chunk-5PM6EQE5.js +151 -0
  3. package/dist/chunk-5PM6EQE5.js.map +1 -0
  4. package/dist/chunk-7XU5X6CW.js +1331 -0
  5. package/dist/chunk-7XU5X6CW.js.map +1 -0
  6. package/dist/chunk-AAOQHQPU.js +574 -0
  7. package/dist/chunk-AAOQHQPU.js.map +1 -0
  8. package/dist/chunk-CF2XXJFF.js +1410 -0
  9. package/dist/chunk-CF2XXJFF.js.map +1 -0
  10. package/dist/chunk-CRPZUUDU.js +52 -0
  11. package/dist/chunk-CRPZUUDU.js.map +1 -0
  12. package/dist/chunk-CYLDJ3HZ.js +310 -0
  13. package/dist/chunk-CYLDJ3HZ.js.map +1 -0
  14. package/dist/chunk-KIKIPIFA.js +1 -0
  15. package/dist/chunk-KIKIPIFA.js.map +1 -0
  16. package/dist/chunk-XNTQTTJU.js +145 -0
  17. package/dist/chunk-XNTQTTJU.js.map +1 -0
  18. package/dist/client/index.css +2 -0
  19. package/dist/client/index.css.map +1 -0
  20. package/dist/client/index.js +375 -0
  21. package/dist/client/index.js.map +1 -0
  22. package/dist/client/styles.css +584 -0
  23. package/dist/client/variables.css +304 -0
  24. package/dist/config/index.d.ts +54 -0
  25. package/dist/config/index.js +38 -0
  26. package/dist/config/index.js.map +1 -0
  27. package/dist/config-BmEdBDo_.d.ts +220 -0
  28. package/dist/content-BWR52vD-.d.ts +64 -0
  29. package/dist/discovery/index.d.ts +310 -0
  30. package/dist/discovery/index.js +38 -0
  31. package/dist/discovery/index.js.map +1 -0
  32. package/dist/errors-C0iYiDTv.d.ts +107 -0
  33. package/dist/filesystem/index.d.ts +1292 -0
  34. package/dist/filesystem/index.js +203 -0
  35. package/dist/filesystem/index.js.map +1 -0
  36. package/dist/image-FP7w5ZIs.d.ts +47 -0
  37. package/dist/index.d.ts +64 -0
  38. package/dist/index.js +151 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/loader-55LWCXHA.js +12 -0
  41. package/dist/loader-55LWCXHA.js.map +1 -0
  42. package/dist/loader-CrdnaAWR.d.ts +327 -0
  43. package/dist/server/index.d.ts +357 -0
  44. package/dist/server/index.js +37 -0
  45. package/dist/server/index.js.map +1 -0
  46. package/package.json +94 -0
  47. package/src/client/App.tsx +900 -0
  48. package/src/client/components/ConfigPanel/ConfigPanel.css +553 -0
  49. package/src/client/components/ConfigPanel/ConfigPanel.tsx +396 -0
  50. package/src/client/components/ConfigPanel/index.ts +6 -0
  51. package/src/client/components/CreateContentModal/CreateContentModal.css +327 -0
  52. package/src/client/components/CreateContentModal/CreateContentModal.tsx +216 -0
  53. package/src/client/components/CreateContentModal/index.ts +7 -0
  54. package/src/client/components/Editor/Editor.css +885 -0
  55. package/src/client/components/Editor/Editor.tsx +484 -0
  56. package/src/client/components/Editor/ImageDialog.css +344 -0
  57. package/src/client/components/Editor/ImageDialog.tsx +367 -0
  58. package/src/client/components/Editor/LinkDialog.css +326 -0
  59. package/src/client/components/Editor/LinkDialog.tsx +332 -0
  60. package/src/client/components/Editor/index.ts +6 -0
  61. package/src/client/components/FrontmatterForm/FrontmatterForm.css +468 -0
  62. package/src/client/components/FrontmatterForm/FrontmatterForm.tsx +914 -0
  63. package/src/client/components/FrontmatterForm/index.ts +7 -0
  64. package/src/client/components/Header/Header.css +300 -0
  65. package/src/client/components/Header/Header.tsx +300 -0
  66. package/src/client/components/Header/index.ts +7 -0
  67. package/src/client/components/KeyboardShortcuts/KeyboardShortcuts.css +239 -0
  68. package/src/client/components/KeyboardShortcuts/KeyboardShortcuts.tsx +151 -0
  69. package/src/client/components/KeyboardShortcuts/index.ts +6 -0
  70. package/src/client/components/LazyEditor.tsx +75 -0
  71. package/src/client/components/LiveRegion/LiveRegion.css +19 -0
  72. package/src/client/components/LiveRegion/LiveRegion.tsx +60 -0
  73. package/src/client/components/LiveRegion/index.ts +7 -0
  74. package/src/client/components/SearchReplace/SearchReplacePanel.css +300 -0
  75. package/src/client/components/SearchReplace/SearchReplacePanel.tsx +332 -0
  76. package/src/client/components/SearchReplace/index.ts +7 -0
  77. package/src/client/components/SelectCollectionModal/SelectCollectionModal.css +308 -0
  78. package/src/client/components/SelectCollectionModal/SelectCollectionModal.tsx +223 -0
  79. package/src/client/components/SelectCollectionModal/index.ts +7 -0
  80. package/src/client/components/Sidebar/Sidebar.css +570 -0
  81. package/src/client/components/Sidebar/Sidebar.tsx +617 -0
  82. package/src/client/components/Sidebar/index.ts +7 -0
  83. package/src/client/components/SkipLink/SkipLink.css +51 -0
  84. package/src/client/components/SkipLink/SkipLink.tsx +67 -0
  85. package/src/client/components/SkipLink/index.ts +7 -0
  86. package/src/client/components/UnsavedChangesModal/UnsavedChangesModal.css +233 -0
  87. package/src/client/components/UnsavedChangesModal/UnsavedChangesModal.tsx +160 -0
  88. package/src/client/components/UnsavedChangesModal/index.ts +1 -0
  89. package/src/client/components/VersionHistory/DiffViewer.css +430 -0
  90. package/src/client/components/VersionHistory/DiffViewer.tsx +383 -0
  91. package/src/client/components/VersionHistory/VersionActions.css +318 -0
  92. package/src/client/components/VersionHistory/VersionActions.tsx +277 -0
  93. package/src/client/components/VersionHistory/VersionHistoryPanel.css +369 -0
  94. package/src/client/components/VersionHistory/VersionHistoryPanel.tsx +469 -0
  95. package/src/client/components/VersionHistory/index.ts +9 -0
  96. package/src/client/context/ApiContext.tsx +154 -0
  97. package/src/client/context/ThemeContext.tsx +172 -0
  98. package/src/client/hooks/useAnnounce.ts +201 -0
  99. package/src/client/hooks/useApi.ts +374 -0
  100. package/src/client/hooks/useArrowNavigation.ts +286 -0
  101. package/src/client/hooks/useAutosave.ts +241 -0
  102. package/src/client/hooks/useFocusTrap.ts +178 -0
  103. package/src/client/hooks/useKeyboardShortcuts.ts +203 -0
  104. package/src/client/hooks/useSearch.ts +206 -0
  105. package/src/client/hooks/useVersionHistory.ts +451 -0
  106. package/src/client/index.tsx +70 -0
  107. package/src/client/styles.css +584 -0
  108. package/src/client/utils/focus.ts +57 -0
  109. package/src/client/utils/openInEditor.ts +130 -0
  110. package/src/client/variables.css +304 -0
  111. package/src/config/defaults.ts +109 -0
  112. package/src/config/index.ts +32 -0
  113. package/src/config/loader.ts +174 -0
  114. package/src/config/schema.ts +161 -0
  115. package/src/core/constants.ts +39 -0
  116. package/src/core/errors.ts +739 -0
  117. package/src/core/index.ts +11 -0
  118. package/src/discovery/collections.ts +216 -0
  119. package/src/discovery/index.ts +33 -0
  120. package/src/discovery/patterns.ts +702 -0
  121. package/src/discovery/schema.ts +453 -0
  122. package/src/filesystem/images.ts +798 -0
  123. package/src/filesystem/index.ts +107 -0
  124. package/src/filesystem/reader.ts +452 -0
  125. package/src/filesystem/version-config.ts +390 -0
  126. package/src/filesystem/versions.ts +1339 -0
  127. package/src/filesystem/watcher.ts +226 -0
  128. package/src/filesystem/writer.ts +540 -0
  129. package/src/index.ts +61 -0
  130. package/src/integration.ts +228 -0
  131. package/src/server/assets.ts +254 -0
  132. package/src/server/cache.ts +355 -0
  133. package/src/server/index.ts +33 -0
  134. package/src/server/middleware.ts +209 -0
  135. package/src/server/routes.ts +1428 -0
  136. package/src/types/api.ts +61 -0
  137. package/src/types/config.ts +134 -0
  138. package/src/types/content.ts +64 -0
  139. package/src/types/image.ts +48 -0
  140. package/src/types/index.ts +58 -0
  141. package/src/types/version.ts +117 -0
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @fileoverview API response type definitions for @writenex/astro
3
+ *
4
+ * This file contains all TypeScript type definitions related to API responses,
5
+ * including collections, content list, content item, mutation, and image upload responses.
6
+ *
7
+ * @module @writenex/astro/types/api
8
+ */
9
+
10
+ import type {
11
+ ContentItem,
12
+ ContentSummary,
13
+ DiscoveredCollection,
14
+ } from "./content";
15
+
16
+ /**
17
+ * API response for collections endpoint
18
+ */
19
+ export interface CollectionsResponse {
20
+ /** List of discovered collections */
21
+ collections: DiscoveredCollection[];
22
+ }
23
+
24
+ /**
25
+ * API response for content list endpoint
26
+ */
27
+ export interface ContentListResponse {
28
+ /** List of content summaries */
29
+ items: ContentSummary[];
30
+ /** Total number of items */
31
+ total: number;
32
+ }
33
+
34
+ /**
35
+ * API response for single content endpoint
36
+ */
37
+ export interface ContentResponse extends ContentItem {}
38
+
39
+ /**
40
+ * API response for create/update operations
41
+ */
42
+ export interface MutationResponse {
43
+ /** Whether the operation succeeded */
44
+ success: boolean;
45
+ /** Content item ID if operation succeeded */
46
+ id?: string;
47
+ /** Filesystem path if operation succeeded */
48
+ path?: string;
49
+ /** Error message if operation failed */
50
+ error?: string;
51
+ }
52
+
53
+ /**
54
+ * API response for image upload
55
+ */
56
+ export interface ImageUploadResponse {
57
+ /** Markdown-compatible path for the image */
58
+ path: string;
59
+ /** Public URL for the image */
60
+ url: string;
61
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * @fileoverview Configuration-related type definitions for @writenex/astro
3
+ *
4
+ * This file contains all TypeScript type definitions related to configuration,
5
+ * including collection config, image config, editor config, and discovery config.
6
+ *
7
+ * @module @writenex/astro/types/config
8
+ */
9
+
10
+ import type { VersionHistoryConfig } from "./version";
11
+
12
+ /**
13
+ * Field type definitions for frontmatter schema
14
+ */
15
+ export type FieldType =
16
+ | "string"
17
+ | "number"
18
+ | "boolean"
19
+ | "date"
20
+ | "array"
21
+ | "image"
22
+ | "object";
23
+
24
+ /**
25
+ * Schema field definition for frontmatter
26
+ */
27
+ export interface SchemaField {
28
+ /** The type of the field */
29
+ type: FieldType;
30
+ /** Whether the field is required */
31
+ required?: boolean;
32
+ /** Default value for the field */
33
+ default?: unknown;
34
+ /** For array types, the type of items */
35
+ items?: string;
36
+ /** Description shown in the editor */
37
+ description?: string;
38
+ }
39
+
40
+ /**
41
+ * Collection schema definition
42
+ */
43
+ export type CollectionSchema = Record<string, SchemaField>;
44
+
45
+ /**
46
+ * Image handling strategy
47
+ */
48
+ export type ImageStrategy = "colocated" | "public" | "custom";
49
+
50
+ /**
51
+ * Image configuration for a collection
52
+ */
53
+ export interface ImageConfig {
54
+ /** Where to store uploaded images */
55
+ strategy: ImageStrategy;
56
+ /** URL path prefix for images */
57
+ publicPath?: string;
58
+ /** Filesystem path for storing images (for 'public' and 'custom' strategies) */
59
+ storagePath?: string;
60
+ }
61
+
62
+ /**
63
+ * Collection configuration
64
+ */
65
+ export interface CollectionConfig {
66
+ /** Unique name of the collection */
67
+ name: string;
68
+ /** Filesystem path to the collection (relative to project root) */
69
+ path: string;
70
+ /** File naming pattern using tokens like {slug}, {date}, {year}, etc. */
71
+ filePattern?: string;
72
+ /** URL pattern for preview links */
73
+ previewUrl?: string;
74
+ /** Frontmatter schema definition */
75
+ schema?: CollectionSchema;
76
+ /** Image handling configuration for this collection */
77
+ images?: ImageConfig;
78
+ }
79
+
80
+ /**
81
+ * Discovery configuration for auto-detecting collections
82
+ */
83
+ export interface DiscoveryConfig {
84
+ /** Whether auto-discovery is enabled */
85
+ enabled: boolean;
86
+ /** Glob patterns to ignore during discovery */
87
+ ignore?: string[];
88
+ }
89
+
90
+ /**
91
+ * Editor behavior configuration
92
+ */
93
+ export interface EditorConfig {
94
+ /** Whether autosave is enabled */
95
+ autosave?: boolean;
96
+ /** Autosave interval in milliseconds */
97
+ autosaveInterval?: number;
98
+ }
99
+
100
+ /**
101
+ * Main Writenex configuration
102
+ */
103
+ export interface WritenexConfig {
104
+ /** Collection definitions */
105
+ collections?: CollectionConfig[];
106
+ /** Global image configuration */
107
+ images?: ImageConfig;
108
+ /** Editor behavior configuration */
109
+ editor?: EditorConfig;
110
+ /** Auto-discovery configuration */
111
+ discovery?: DiscoveryConfig;
112
+ /** Version history configuration */
113
+ versionHistory?: VersionHistoryConfig;
114
+ }
115
+
116
+ /**
117
+ * Options passed to the Writenex integration
118
+ */
119
+ export interface WritenexOptions {
120
+ /**
121
+ * Allow the integration to run in production builds.
122
+ * Use with caution - only enable for staging/preview environments.
123
+ * @default false
124
+ */
125
+ allowProduction?: boolean;
126
+ }
127
+
128
+ /**
129
+ * Resolved configuration with defaults applied
130
+ */
131
+ export interface ResolvedConfig extends Required<WritenexConfig> {
132
+ /** Resolved collection configurations */
133
+ collections: Required<CollectionConfig>[];
134
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @fileoverview Content and collection type definitions for @writenex/astro
3
+ *
4
+ * This file contains all TypeScript type definitions related to content items,
5
+ * content summaries, and discovered collections.
6
+ *
7
+ * @module @writenex/astro/types/content
8
+ */
9
+
10
+ import type { CollectionSchema } from "./config";
11
+
12
+ /**
13
+ * Parsed content item with frontmatter and body
14
+ */
15
+ export interface ContentItem {
16
+ /** Unique identifier (typically the slug) */
17
+ id: string;
18
+ /** Filesystem path to the content file */
19
+ path: string;
20
+ /** Parsed frontmatter data */
21
+ frontmatter: Record<string, unknown>;
22
+ /** Markdown body content */
23
+ body: string;
24
+ /** Raw file content (frontmatter + body) */
25
+ raw: string;
26
+ /** File modification time in milliseconds (for conflict detection) */
27
+ mtime?: number;
28
+ }
29
+
30
+ /**
31
+ * Content item summary for listing
32
+ */
33
+ export interface ContentSummary {
34
+ /** Unique identifier */
35
+ id: string;
36
+ /** Filesystem path */
37
+ path: string;
38
+ /** Title from frontmatter */
39
+ title: string;
40
+ /** Publication date */
41
+ pubDate?: string;
42
+ /** Draft status */
43
+ draft?: boolean;
44
+ /** Content excerpt */
45
+ excerpt?: string;
46
+ }
47
+
48
+ /**
49
+ * Discovered collection with metadata
50
+ */
51
+ export interface DiscoveredCollection {
52
+ /** Collection name */
53
+ name: string;
54
+ /** Filesystem path */
55
+ path: string;
56
+ /** Detected file pattern */
57
+ filePattern: string;
58
+ /** Number of content files */
59
+ count: number;
60
+ /** Detected/configured schema */
61
+ schema?: CollectionSchema;
62
+ /** URL pattern for preview links */
63
+ previewUrl?: string;
64
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @fileoverview Image-related type definitions for @writenex/astro
3
+ *
4
+ * This file contains all TypeScript type definitions related to image discovery
5
+ * and image metadata.
6
+ *
7
+ * @module @writenex/astro/types/image
8
+ */
9
+
10
+ /**
11
+ * Discovered image metadata
12
+ *
13
+ * Represents an image file found during content folder scanning.
14
+ */
15
+ export interface DiscoveredImage {
16
+ /** Original filename (e.g., "hero.jpg") */
17
+ filename: string;
18
+ /** Relative path for markdown (e.g., "./images/hero.jpg") */
19
+ relativePath: string;
20
+ /** Absolute filesystem path */
21
+ absolutePath: string;
22
+ /** File size in bytes */
23
+ size: number;
24
+ /** File extension (lowercase, with dot, e.g., ".jpg") */
25
+ extension: string;
26
+ }
27
+
28
+ /**
29
+ * Options for image discovery
30
+ */
31
+ export interface ImageDiscoveryOptions {
32
+ /** Maximum recursion depth (default: 5) */
33
+ maxDepth?: number;
34
+ /** Additional extensions to include beyond defaults */
35
+ additionalExtensions?: string[];
36
+ }
37
+
38
+ /**
39
+ * Result of image discovery operation
40
+ */
41
+ export interface ImageDiscoveryResult {
42
+ /** Whether discovery was successful */
43
+ success: boolean;
44
+ /** Discovered images */
45
+ images: DiscoveredImage[];
46
+ /** Error message if failed */
47
+ error?: string;
48
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @fileoverview Type definitions barrel file for @writenex/astro
3
+ *
4
+ * This file re-exports all type definitions from domain-specific files
5
+ * to provide a single import point for types.
6
+ *
7
+ * @module @writenex/astro/types
8
+ */
9
+
10
+ // Configuration types
11
+ export type {
12
+ FieldType,
13
+ SchemaField,
14
+ CollectionSchema,
15
+ ImageStrategy,
16
+ ImageConfig,
17
+ CollectionConfig,
18
+ DiscoveryConfig,
19
+ EditorConfig,
20
+ WritenexConfig,
21
+ WritenexOptions,
22
+ ResolvedConfig,
23
+ } from "./config";
24
+
25
+ // Content types
26
+ export type {
27
+ ContentItem,
28
+ ContentSummary,
29
+ DiscoveredCollection,
30
+ } from "./content";
31
+
32
+ // API response types
33
+ export type {
34
+ CollectionsResponse,
35
+ ContentListResponse,
36
+ ContentResponse,
37
+ MutationResponse,
38
+ ImageUploadResponse,
39
+ } from "./api";
40
+
41
+ // Version history types
42
+ export type {
43
+ VersionEntry,
44
+ VersionManifest,
45
+ Version,
46
+ VersionHistoryConfig,
47
+ VersionResult,
48
+ SaveVersionOptions,
49
+ RestoreVersionOptions,
50
+ RestoreResult,
51
+ } from "./version";
52
+
53
+ // Image types
54
+ export type {
55
+ DiscoveredImage,
56
+ ImageDiscoveryOptions,
57
+ ImageDiscoveryResult,
58
+ } from "./image";
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @fileoverview Version history type definitions for @writenex/astro
3
+ *
4
+ * This file contains all TypeScript type definitions related to version history,
5
+ * including version entries, manifests, and operation results.
6
+ *
7
+ * @module @writenex/astro/types/version
8
+ */
9
+
10
+ /**
11
+ * Version entry metadata stored in manifest
12
+ *
13
+ * Represents a single version snapshot of a content item.
14
+ */
15
+ export interface VersionEntry {
16
+ /** Unique version ID (ISO timestamp with hyphens instead of colons) */
17
+ id: string;
18
+ /** When this version was created (ISO string for JSON serialization) */
19
+ timestamp: string;
20
+ /** First 100 characters of content for preview */
21
+ preview: string;
22
+ /** File size in bytes */
23
+ size: number;
24
+ /** Optional label for manual snapshots */
25
+ label?: string;
26
+ }
27
+
28
+ /**
29
+ * Version manifest for a content item
30
+ *
31
+ * Tracks all versions for a specific content item in a JSON file.
32
+ */
33
+ export interface VersionManifest {
34
+ /** Content item identifier (slug) */
35
+ contentId: string;
36
+ /** Collection name */
37
+ collection: string;
38
+ /** List of version entries */
39
+ versions: VersionEntry[];
40
+ /** When manifest was last updated (ISO string for JSON serialization) */
41
+ updatedAt: string;
42
+ }
43
+
44
+ /**
45
+ * Full version data including content
46
+ *
47
+ * Extends VersionEntry with the actual content of the version.
48
+ */
49
+ export interface Version extends VersionEntry {
50
+ /** Full markdown content */
51
+ content: string;
52
+ /** Parsed frontmatter */
53
+ frontmatter: Record<string, unknown>;
54
+ /** Markdown body */
55
+ body: string;
56
+ }
57
+
58
+ /**
59
+ * Version history configuration
60
+ *
61
+ * Controls how version history behaves for the project.
62
+ * All fields are optional - defaults are applied via applyConfigDefaults().
63
+ */
64
+ export interface VersionHistoryConfig {
65
+ /** Enable/disable version history (default: true) */
66
+ enabled?: boolean;
67
+ /** Maximum versions to keep per content item, unlabeled only (default: 20) */
68
+ maxVersions?: number;
69
+ /** Storage path relative to project root (default: ".writenex/versions") */
70
+ storagePath?: string;
71
+ }
72
+
73
+ /**
74
+ * Result of version operations
75
+ *
76
+ * Returned by version CRUD operations to indicate success/failure.
77
+ */
78
+ export interface VersionResult {
79
+ /** Whether the operation succeeded */
80
+ success: boolean;
81
+ /** Version entry if operation created/retrieved one */
82
+ version?: VersionEntry;
83
+ /** Error message if operation failed */
84
+ error?: string;
85
+ }
86
+
87
+ /**
88
+ * Options for saving a version
89
+ */
90
+ export interface SaveVersionOptions {
91
+ /** Optional label for the version */
92
+ label?: string;
93
+ /** Skip if content is identical to last version */
94
+ skipIfIdentical?: boolean;
95
+ }
96
+
97
+ /**
98
+ * Options for restoring a version
99
+ */
100
+ export interface RestoreVersionOptions {
101
+ /** Label for the safety snapshot created before restore */
102
+ safetySnapshotLabel?: string;
103
+ /** Skip creating safety snapshot (not recommended) */
104
+ skipSafetySnapshot?: boolean;
105
+ }
106
+
107
+ /**
108
+ * Result of a restore operation
109
+ *
110
+ * Extends VersionResult with additional restore-specific fields.
111
+ */
112
+ export interface RestoreResult extends VersionResult {
113
+ /** The restored content */
114
+ content?: string;
115
+ /** The safety snapshot version entry (if created) */
116
+ safetySnapshot?: VersionEntry;
117
+ }