@nuasite/cms 0.1.0 → 0.2.2

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.
package/README.md CHANGED
@@ -1,7 +1,11 @@
1
- # @nuasite/astro-cms
1
+ # @nuasite/cms
2
2
 
3
3
  Astro integration that adds inline visual editing to any Astro site. Scans your components, marks editable elements with CMS IDs, and serves a live editor overlay during development. All write operations (text, images, colors, components, markdown) are handled locally via a built-in dev server — no external backend required.
4
4
 
5
+ ## Prerequisites
6
+
7
+ - **Tailwind CSS v4** — Your site must use Tailwind. The CMS color editor, text styling, and class-based editing features all operate on Tailwind utility classes. Without Tailwind, those features won't work.
8
+
5
9
  ## Quick Start
6
10
 
7
11
  ```typescript
@@ -13,7 +17,7 @@ export default defineConfig({
13
17
  })
14
18
  ```
15
19
 
16
- That's it. Run `astro dev` and the CMS editor loads automatically. Edits write directly to your source files, and Vite HMR picks up the changes instantly.
20
+ Run `astro dev` and the CMS editor loads automatically. Edits write directly to your source files, and Vite HMR picks up the changes instantly.
17
21
 
18
22
  ## How It Works
19
23
 
@@ -104,44 +108,44 @@ Changes are grouped by source file, sorted by line number (descending to avoid o
104
108
 
105
109
  Media uploads use a pluggable adapter pattern. Three adapters are included:
106
110
 
107
- ### Local Filesystem (default)
111
+ ### Contember (R2 + Database) — Recommended
108
112
 
109
- Stores files in `public/uploads/`. Served directly by Vite's static file server. Zero configuration needed.
113
+ Files are stored in Cloudflare R2 with metadata tracked in the Contember database. This is the only adapter that gives you proper asset IDs, metadata, and AI-powered image annotation. Use this for production sites.
110
114
 
111
115
  ```typescript
112
- import nuaCms, { localMedia } from '@nuasite/astro-cms'
116
+ import nuaCms, { contemberMedia } from '@nuasite/astro-cms'
113
117
 
114
118
  nuaCms({
115
- media: localMedia({
116
- dir: 'public/uploads', // default
117
- urlPrefix: '/uploads', // default
119
+ media: contemberMedia({
120
+ apiBaseUrl: 'https://api.example.com',
121
+ projectSlug: 'my-project',
122
+ sessionToken: process.env.NUA_SESSION_TOKEN,
118
123
  }),
119
124
  })
120
125
  ```
121
126
 
122
- Files are named with UUIDs to avoid collisions. Listed by modification time (newest first).
127
+ This adapter calls the worker's `/cms/:projectSlug/media/*` endpoints, which handle R2 upload, Asset record creation, and image annotation. Authentication uses the `NUA_SITE_SESSION_TOKEN` cookie.
123
128
 
124
- ### Contember (R2 + Database)
129
+ ### Local Filesystem (default)
125
130
 
126
- Proxies to the existing Contember worker API. Files are stored in Cloudflare R2, metadata in the Contember database. Includes AI-powered image annotation.
131
+ Stores files in `public/uploads/`. Served directly by Vite's static file server. Zero configuration needed. Files are committed to your repo alongside your source code.
127
132
 
128
133
  ```typescript
129
- import nuaCms, { contemberMedia } from '@nuasite/astro-cms'
134
+ import nuaCms, { localMedia } from '@nuasite/astro-cms'
130
135
 
131
136
  nuaCms({
132
- media: contemberMedia({
133
- apiBaseUrl: 'https://api.example.com',
134
- projectSlug: 'my-project',
135
- sessionToken: process.env.NUA_SESSION_TOKEN,
137
+ media: localMedia({
138
+ dir: 'public/uploads', // default
139
+ urlPrefix: '/uploads', // default
136
140
  }),
137
141
  })
138
142
  ```
139
143
 
140
- This adapter calls the worker's `/cms/:projectSlug/media/*` endpoints, which handle R2 upload, Asset record creation, and image annotation. Authentication uses the `NUA_SITE_SESSION_TOKEN` cookie.
144
+ Files are named with UUIDs to avoid collisions. Listed by modification time (newest first).
141
145
 
142
146
  ### S3 / R2 Direct
143
147
 
144
- Direct S3-compatible storage. Works with AWS S3, Cloudflare R2, MinIO, or any S3-compatible provider. Requires `@aws-sdk/client-s3` as a peer dependency.
148
+ Direct S3-compatible object storage. Works with AWS S3, Cloudflare R2, MinIO, or any S3-compatible provider. Listing, uploading, and deleting all work, but there is no database layer — content types are not preserved on list, and there are no image dimensions or annotations. Requires `@aws-sdk/client-s3` as a peer dependency.
145
149
 
146
150
  ```typescript
147
151
  import nuaCms, { s3Media } from '@nuasite/astro-cms'
@@ -10,7 +10,9 @@ export declare function parseAstroFile(content: string): Promise<ParsedAstroFile
10
10
  */
11
11
  export declare function parseFrontmatter(content: string, filePath?: string): BabelFile | null;
12
12
  /**
13
- * Get a cached parsed file, parsing it if not cached
13
+ * Get a cached parsed file, parsing it if not cached.
14
+ * Concurrent requests for the same file are deduplicated to avoid
15
+ * redundant parsing and potential race conditions.
14
16
  */
15
17
  export declare function getCachedParsedFile(filePath: string): Promise<CachedParsedFile | null>;
16
18
  //# sourceMappingURL=ast-parser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast-parser.d.ts","sourceRoot":"","sources":["../../../src/source-finder/ast-parser.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO3E;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAoB9E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAiBrF;AAMD;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAwD5F"}
1
+ {"version":3,"file":"ast-parser.d.ts","sourceRoot":"","sources":["../../../src/source-finder/ast-parser.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO3E;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAoB9E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAiBrF;AASD;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAiB5F"}
@@ -7,6 +7,12 @@ export declare function normalizeText(text: string): string;
7
7
  * Strip markdown syntax for text comparison
8
8
  */
9
9
  export declare function stripMarkdownSyntax(text: string): string;
10
+ /**
11
+ * Find the 1-indexed line number where a text value is defined as a string literal.
12
+ * Searches for the text inside quote delimiters ("text", 'text', or `text`).
13
+ * Returns the line number, or undefined if not found.
14
+ */
15
+ export declare function findTextDefinitionLine(content: string, lines: string[], text: string): number | undefined;
10
16
  /**
11
17
  * Extract complete tag snippet including content and indentation.
12
18
  * Exported for use in html-processor to populate sourceSnippet.
@@ -1 +1 @@
1
- {"version":3,"file":"snippet-utils.d.ts","sourceRoot":"","sources":["../../../src/source-finder/snippet-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAWxD;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAclD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYxD;AAMD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CA0DjG;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG5G;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GACT;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CA2C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