@avocadostudio-ai/preview-adapter 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.
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useCallback } from "react";
4
+ import { usePathname, useRouter } from "next/navigation";
5
+ import { PreviewBridgeCore } from "./preview-bridge-core.js";
6
+ import { useLivePreviewBridgeApi } from "./live-preview-store.js";
7
+ export function PreviewBridge({ slug, editorOrigin }) {
8
+ // Skip when not embedded in an iframe (page opened directly in browser)
9
+ if (!editorOrigin || window.parent === window)
10
+ return null;
11
+ return _jsx(PreviewBridgeNextInner, { slug: slug, editorOrigin: editorOrigin });
12
+ }
13
+ function PreviewBridgeNextInner({ slug, editorOrigin }) {
14
+ const router = useRouter();
15
+ const pathname = usePathname();
16
+ const navigate = useCallback((href) => router.push(href), [router]);
17
+ const refresh = useCallback(() => router.refresh(), [router]);
18
+ // Null unless EditorPageWrapper mounted the live-preview store provider — in
19
+ // which case streamed content flows through React instead of the DOM overlay.
20
+ const liveStore = useLivePreviewBridgeApi();
21
+ return (_jsx(PreviewBridgeCore, { slug: slug, editorOrigin: editorOrigin, navigate: navigate, refresh: refresh, pathname: pathname, liveStore: liveStore }));
22
+ }
@@ -0,0 +1,13 @@
1
+ export declare function getPreviewWrapperProps(editorMode: boolean, blockId: string, blockType: string): {
2
+ readonly "data-block-id"?: undefined;
3
+ readonly "data-block-type"?: undefined;
4
+ readonly className?: undefined;
5
+ readonly style?: undefined;
6
+ } | {
7
+ readonly "data-block-id": string;
8
+ readonly "data-block-type": string;
9
+ readonly className: "editor-selectable";
10
+ readonly style: {
11
+ readonly viewTransitionName: `block-${string}`;
12
+ };
13
+ };
@@ -0,0 +1,10 @@
1
+ export function getPreviewWrapperProps(editorMode, blockId, blockType) {
2
+ if (!editorMode)
3
+ return {};
4
+ return {
5
+ "data-block-id": blockId,
6
+ "data-block-type": blockType,
7
+ className: "editor-selectable",
8
+ style: { viewTransitionName: `block-${blockId}` }
9
+ };
10
+ }
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@avocadostudio-ai/preview-adapter",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ "./package.json": "./package.json",
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./core": {
14
+ "import": "./dist/preview-bridge-core.js",
15
+ "types": "./dist/preview-bridge-core.d.ts"
16
+ },
17
+ "./styles.css": "./src/styles.css"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/avocadostudio-ai/avocado.git",
22
+ "directory": "packages/preview-adapter"
23
+ },
24
+ "publishConfig": {
25
+ "registry": "https://registry.npmjs.org",
26
+ "access": "public"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "src/styles.css"
31
+ ],
32
+ "dependencies": {
33
+ "@avocadostudio-ai/shared": "0.1.0"
34
+ },
35
+ "peerDependencies": {
36
+ "next": ">=15.0.0",
37
+ "react": ">=19.0.0"
38
+ },
39
+ "peerDependenciesMeta": {
40
+ "next": {
41
+ "optional": true
42
+ }
43
+ },
44
+ "devDependencies": {
45
+ "@types/react": "^19.0.10",
46
+ "typescript": "^5.7.3"
47
+ },
48
+ "description": "Preview bridge and editor overlay for Avocado Studio live preview",
49
+ "license": "Apache-2.0",
50
+ "homepage": "https://github.com/avocadostudio-ai/avocado/tree/main/packages/preview-adapter#readme",
51
+ "bugs": {
52
+ "url": "https://github.com/avocadostudio-ai/avocado/issues"
53
+ },
54
+ "scripts": {
55
+ "build": "tsc -p tsconfig.build.json",
56
+ "typecheck": "tsc --noEmit",
57
+ "test": "NODE_ENV=test tsx --test src/**/*.test.ts"
58
+ }
59
+ }