@parhelia/astro 0.0.0-stage → 1.0.12951

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/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ Parhelia - AI-Powered Content Editor
2
+
3
+ Copyright © 2025 Canvas REPLY GmbH. All rights reserved.
4
+
5
+ For full license terms and legal notice, please visit:
6
+ https://parhelia.ai/license
7
+
8
+ This software is proprietary and confidential.
package/README.md CHANGED
@@ -1,3 +1,32 @@
1
- # Temporary Holding Version
1
+ # @parhelia/astro
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Astro adapter of [`@parhelia/head`](https://www.npmjs.com/package/@parhelia/head), for a rendering head written in Astro, with or without React:
4
+ the integration and the slot, bridge and refresh components. Everything else (the server check `@parhelia/head/server`, the
5
+ rendered identity, rich text, a CMS's markers) is `@parhelia/head`'s, as for every head.
6
+
7
+
8
+ ```js
9
+ // astro.config.mjs
10
+ import node from '@astrojs/node';
11
+ import parhelia from '@parhelia/astro';
12
+ export default defineConfig({ output: 'server', adapter: node({ mode: 'standalone' }), integrations: [parhelia()] });
13
+ ```
14
+
15
+ ```astro
16
+ ---
17
+ import ParheliaSlot from '@parhelia/astro/ParheliaSlot.astro';
18
+ import ParheliaRefresh from '@parhelia/astro/ParheliaRefresh.astro';
19
+ import ParheliaBridge from '@parhelia/astro/ParheliaBridge.astro';
20
+ ---
21
+ <ParheliaRefresh signature={signature}>
22
+ <ParheliaSlot name="main" enabled={edit}>{blocks}</ParheliaSlot>
23
+ </ParheliaRefresh>
24
+ <ParheliaBridge />
25
+ ```
26
+
27
+ `parhelia()` sets Astro's `base` to the rendering proxy's path and inlines the build values. `ParheliaRefresh` reads the page
28
+ again on `window.requestRefresh` and updates it in place (Astro has no client router doing it), until the signature
29
+ changed. Render the refresh and the bridge in editing renders only.
30
+
31
+ `ParheliaRefresh` patches what changed into the live document (`installParheliaDomRefresh` of `@parhelia/head`), so an inline
32
+ edit in progress survives a refresh.
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@parhelia/astro",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.12951",
4
+ "description": "The Astro adapter of @parhelia/head for a rendering head written in Astro, with or without React: the integration (base path below Parhelia's rendering proxy, the build values inlined) and ParheliaSlot, ParheliaBridge and ParheliaRefresh as Astro components.",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "type": "module",
10
+ "main": "./src/index.js",
11
+ "types": "./src/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./src/index.d.ts",
15
+ "default": "./src/index.js"
16
+ },
17
+ "./ParheliaSlot.astro": "./src/ParheliaSlot.astro",
18
+ "./ParheliaBridge.astro": "./src/ParheliaBridge.astro",
19
+ "./ParheliaRefresh.astro": "./src/ParheliaRefresh.astro"
20
+ },
21
+ "files": [
22
+ "src/*.js",
23
+ "src/*.d.ts",
24
+ "src/*.astro",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "sideEffects": false,
29
+ "scripts": {
30
+ "check-types": "tsc --noEmit -p tsconfig.json && astro check --noSync"
31
+ },
32
+ "dependencies": {
33
+ "@parhelia/head": "1.0.12951"
34
+ },
35
+ "peerDependencies": {
36
+ "astro": ">=5"
37
+ },
38
+ "devDependencies": {
39
+ "@astrojs/check": "0.9.10",
40
+ "@types/node": "*",
41
+ "astro": "7.3.5",
42
+ "typescript": "npm:@typescript/typescript6@6.0.2"
43
+ }
44
+ }
@@ -0,0 +1,13 @@
1
+ ---
2
+ /**
3
+ * Loads Parhelia's editing bridge when the editor frames this page directly (a frame of another origin on `?parhelia=1`);
4
+ * a proxied head is framed from the editor's origin, which injects the bridge itself, so nothing loads there. The bridge
5
+ * loads from the build's `PARHELIA_ORIGIN` (`parhelia()` of `@parhelia/astro`). Render it in editing renders only.
6
+ * For other options call `loadParheliaBridge` of `@parhelia/head` in a script of the head's own.
7
+ */
8
+ ---
9
+ <script>
10
+ import { loadParheliaBridge } from '@parhelia/head';
11
+
12
+ loadParheliaBridge();
13
+ </script>
@@ -0,0 +1,30 @@
1
+ ---
2
+ /**
3
+ * The in-place canvas refresh for an Astro page: the `window.requestRefresh(newUri?)` contract Parhelia's editor calls after
4
+ * a save (`installParheliaDomRefresh` of `@parhelia/head`). Wrap what the editor shows; `signature` is a stable string of
5
+ * what this render showed. A refresh reads the page again and patches what changed into the live document, keeping every
6
+ * node the new render left alone (with what the editing bridge added to it), until the signature changed and settled or the
7
+ * deadline passed; a new URI is navigated to. Render it in editing renders only.
8
+ */
9
+ import { REFRESH_DEADLINE_ATTRIBUTE, REFRESH_ROOT_ATTRIBUTE, REFRESH_SIGNATURE_ATTRIBUTE } from '@parhelia/head';
10
+
11
+ interface Props {
12
+ signature: string;
13
+ deadlineMs?: number;
14
+ }
15
+
16
+ const { signature, deadlineMs = 8000 } = Astro.props;
17
+ const attributes = {
18
+ [REFRESH_ROOT_ATTRIBUTE]: '',
19
+ [REFRESH_SIGNATURE_ATTRIBUTE]: signature,
20
+ [REFRESH_DEADLINE_ATTRIBUTE]: String(deadlineMs),
21
+ };
22
+ ---
23
+ <div {...attributes} style="display: contents">
24
+ <slot />
25
+ </div>
26
+ <script>
27
+ import { installParheliaDomRefresh } from '@parhelia/head';
28
+
29
+ installParheliaDomRefresh();
30
+ </script>
@@ -0,0 +1,34 @@
1
+ ---
2
+ /**
3
+ * One of the page's slots for Parhelia's editor, also when it holds nothing: in Parhelia's frames (`enabled`) the slot's
4
+ * sentinels around its content and, for an empty slot, the block where the editor draws its drop zone; elsewhere the
5
+ * content alone. The counterpart of `ParheliaSlot` in `@parhelia/react`, with the same markup (`@parhelia/head`'s slot markers).
6
+ */
7
+ import { EMPTY_SLOT_MIN_HEIGHT, emptySlotAttributes, slotEndAttributes, slotStartAttributes } from '@parhelia/head';
8
+
9
+ interface Props {
10
+ /** The slot's key as Parhelia names it. */
11
+ name: string;
12
+ /** Its label (default `name`). */
13
+ description?: string;
14
+ /** In Parhelia's editing frames only. */
15
+ enabled?: boolean;
16
+ /** The empty block's height (default `6rem`). */
17
+ emptyMinHeight?: string;
18
+ }
19
+
20
+ const { name, description, enabled = false, emptyMinHeight = EMPTY_SLOT_MIN_HEIGHT } = Astro.props;
21
+ const content = Astro.slots.has('default') ? await Astro.slots.render('default') : '';
22
+ const empty = content.trim() === '';
23
+ ---
24
+ {
25
+ enabled ? (
26
+ <>
27
+ <script is:inline {...slotStartAttributes(name, description)} />
28
+ {empty ? <div {...emptySlotAttributes(name)} style={`min-height: ${emptyMinHeight}`} /> : <Fragment set:html={content} />}
29
+ <script is:inline {...slotEndAttributes(name)} />
30
+ </>
31
+ ) : (
32
+ <Fragment set:html={content} />
33
+ )
34
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { AstroIntegration } from "astro";
2
+
3
+ /** The Astro integration of a rendering head: `base` below the rendering proxy, the build's values inlined. */
4
+ export default function parhelia(options?: { env?: Readonly<Record<string, string | undefined>> }): AstroIntegration;
package/src/index.js ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `@parhelia/astro` — the Astro integration of a rendering head written in Astro, with or without React:
3
+ *
4
+ * // astro.config.mjs
5
+ * import parhelia from '@parhelia/astro';
6
+ * export default defineConfig({ output: 'server', adapter: node({ mode: 'standalone' }), integrations: [parhelia()] });
7
+ *
8
+ * It sets Astro's `base` to the rendering proxy's path (`PARHELIA_RENDERING_PROXY_PATH`; a `base` the config sets itself is
9
+ * kept) and adds the `parhelia()` Vite plugin's defines (`PARHELIA_BASE_PATH`, `PARHELIA_ORIGIN`), so `withBasePath` and
10
+ * the bridge read the build's values on the server and in the browser. Its components (`@parhelia/astro/*.astro`)
11
+ * are the counterparts of `@parhelia/react`'s: `ParheliaSlot`, `ParheliaBridge` and `ParheliaRefresh`. The server-side parts
12
+ * (`isEditingRequest`, the identity, a CMS's markers) are `@parhelia/head`'s, as for every head.
13
+ */
14
+ import settings from "@parhelia/head/settings";
15
+ import { parheliaViteSettings } from "@parhelia/head/vite";
16
+
17
+ /** @param {{ env?: Readonly<Record<string, string | undefined>> }} [options] */
18
+ export default function parhelia(options = {}) {
19
+ const env = options.env ?? process.env;
20
+ const basePath = settings.basePathFromEnv(env);
21
+ return {
22
+ name: "@parhelia/astro",
23
+ hooks: {
24
+ /** @param {{ config: { base?: string }, updateConfig: (config: object) => unknown }} context */
25
+ "astro:config:setup": ({ config, updateConfig }) => {
26
+ updateConfig({
27
+ ...(basePath && (!config.base || config.base === "/") ? { base: basePath } : {}),
28
+ vite: {
29
+ plugins: [
30
+ {
31
+ name: "parhelia",
32
+ enforce: "pre",
33
+ // Astro owns Vite's base; the plugin adds the defines and the package's bundling.
34
+ config: () => {
35
+ const { base: _base, ...rest } = parheliaViteSettings(env, "");
36
+ return rest;
37
+ },
38
+ },
39
+ ],
40
+ },
41
+ });
42
+ },
43
+ },
44
+ };
45
+ }