@saacms/host-astro 0.1.5 → 0.1.7
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/dist/host-astro-adapter.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -7
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-astro-adapter.d.ts","sourceRoot":"","sources":["../src/host-astro-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,OAAO,KAAK,EAIV,WAAW,EAEX,UAAU,EAEX,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"host-astro-adapter.d.ts","sourceRoot":"","sources":["../src/host-astro-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,OAAO,KAAK,EAIV,WAAW,EAEX,UAAU,EAEX,MAAM,YAAY,CAAA;AAkKnB;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAMtE;AAuCD,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,wBAAgB,sBAAsB,CACpC,IAAI,GAAE,uBAA4B,GACjC,WAAW,CAuGb"}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,8 @@ import { type AstroHostAdapterOptions } from "./host-astro-adapter.ts";
|
|
|
19
19
|
import type { HostAdapter } from "./types.ts";
|
|
20
20
|
export { createAstroHostAdapter } from "./host-astro-adapter.ts";
|
|
21
21
|
export type { AstroHostAdapterOptions } from "./host-astro-adapter.ts";
|
|
22
|
-
export
|
|
22
|
+
export { renderBlockTree } from "./host-astro-adapter.ts";
|
|
23
|
+
export type { Block, GeneratedFile, GenerateRouteOptions, HostAdapter, Page, PuckLayout, PuckLayoutNode, } from "./types.ts";
|
|
23
24
|
/**
|
|
24
25
|
* Convenience alias — the canonical name used by user code in
|
|
25
26
|
* `saacms.config.ts`. Equivalent to `createAstroHostAdapter(opts)`.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAKtE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,YAAY,EACV,KAAK,EACL,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,IAAI,EACJ,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAA;AAEnB;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,uBAAuB,GAAG,WAAW,CAE5E"}
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,17 @@ import { readFileSync } from "node:fs";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
5
|
import { SCHEME_COOKIE, DARK_MODE_COOKIE } from "@saacms/core";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
6
|
+
function templatesDir() {
|
|
7
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), "..", "templates");
|
|
8
|
+
}
|
|
9
|
+
var _mountTemplate;
|
|
10
|
+
function loadMountTemplate() {
|
|
11
|
+
return _mountTemplate ??= readFileSync(resolve(templatesDir(), "api-mount.ts.txt"), "utf8");
|
|
12
|
+
}
|
|
13
|
+
var _previewTemplate;
|
|
14
|
+
function loadPreviewTemplate() {
|
|
15
|
+
return _previewTemplate ??= readFileSync(resolve(templatesDir(), "preview-route.astro.txt"), "utf8");
|
|
16
|
+
}
|
|
10
17
|
function assertSafeUrl(url) {
|
|
11
18
|
if (url.includes("\\")) {
|
|
12
19
|
throw new Error(`generateRoute: url '${url}' contains a backslash; use forward slashes`);
|
|
@@ -118,10 +125,10 @@ function createAstroHostAdapter(opts = {}) {
|
|
|
118
125
|
return assetRootPath;
|
|
119
126
|
},
|
|
120
127
|
mountTemplate() {
|
|
121
|
-
return
|
|
128
|
+
return loadMountTemplate();
|
|
122
129
|
},
|
|
123
130
|
previewRouteTemplate(blockSlug) {
|
|
124
|
-
return
|
|
131
|
+
return loadPreviewTemplate().replaceAll("${blockSlug}", blockSlug);
|
|
125
132
|
},
|
|
126
133
|
generateRoute(page, options) {
|
|
127
134
|
assertSafeUrl(page.url);
|
|
@@ -177,7 +184,7 @@ function createAstroHostAdapter(opts = {}) {
|
|
|
177
184
|
generatePreviewRoute(block) {
|
|
178
185
|
return {
|
|
179
186
|
path: `src/pages/saacms/preview/${block.slug}.astro`,
|
|
180
|
-
source:
|
|
187
|
+
source: loadPreviewTemplate().replaceAll("${blockSlug}", block.slug)
|
|
181
188
|
};
|
|
182
189
|
}
|
|
183
190
|
};
|
|
@@ -188,6 +195,7 @@ function astroHostAdapter(opts) {
|
|
|
188
195
|
return createAstroHostAdapter(opts ?? {});
|
|
189
196
|
}
|
|
190
197
|
export {
|
|
198
|
+
renderBlockTree,
|
|
191
199
|
createAstroHostAdapter,
|
|
192
200
|
astroHostAdapter
|
|
193
201
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saacms/host-astro",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@saacms/core": "0.1.
|
|
28
|
+
"@saacms/core": "0.1.7"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"astro": "^4.0.0 || ^5.0.0"
|