@alpaca-headless/alpaca-headless-nextjs 1.0.4472 → 1.0.4473

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.
@@ -7,10 +7,6 @@ interface MultiComponentEditorProps {
7
7
  thumbZoom?: number;
8
8
  thumbWidth?: string;
9
9
  thumbHeight?: string;
10
- onSelectedComponentChange?: (payload: {
11
- selectedId: string | null;
12
- selectedIndex: number;
13
- }) => void;
14
10
  }
15
- export declare function MultiComponentEditor({ children, component, placeholderName, thumbZoom, thumbWidth, thumbHeight, onSelectedComponentChange, }: MultiComponentEditorProps): import("react/jsx-runtime").JSX.Element | undefined;
11
+ export declare function MultiComponentEditor({ children, component, placeholderName, thumbZoom, thumbWidth, thumbHeight, }: MultiComponentEditorProps): import("react/jsx-runtime").JSX.Element | undefined;
16
12
  export {};
@@ -1,8 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import React, { Fragment, useCallback, useEffect, useState, } from "react";
4
- export function MultiComponentEditor({ children, component, placeholderName, thumbZoom, thumbWidth, thumbHeight, onSelectedComponentChange, }) {
5
- var _a, _b;
3
+ import React, { useState, useEffect, Fragment, useCallback, } from "react";
4
+ export function MultiComponentEditor({ children, component, placeholderName, thumbZoom, thumbWidth, thumbHeight, }) {
6
5
  const [selectedId, setSelectedId] = useState(null);
7
6
  const placeholder = component.placeholders.find((x) => x.name === placeholderName);
8
7
  if (!placeholder)
@@ -22,23 +21,9 @@ export function MultiComponentEditor({ children, component, placeholderName, thu
22
21
  };
23
22
  }, []);
24
23
  const selectedIndex = components.findIndex((x) => x.id === selectedId);
25
- const resolvedIndex = selectedIndex < 0 ? 0 : selectedIndex;
26
- const resolvedComponent = (_a = components[resolvedIndex]) !== null && _a !== void 0 ? _a : null;
27
- const resolvedId = (_b = resolvedComponent === null || resolvedComponent === void 0 ? void 0 : resolvedComponent.id) !== null && _b !== void 0 ? _b : null;
28
- useEffect(() => {
29
- if (resolvedId !== null && selectedId !== resolvedId) {
30
- setSelectedId(resolvedId);
31
- }
32
- }, [resolvedId, selectedId]);
33
- useEffect(() => {
34
- onSelectedComponentChange === null || onSelectedComponentChange === void 0 ? void 0 : onSelectedComponentChange({
35
- selectedId: resolvedId,
36
- selectedIndex: resolvedIndex,
37
- });
38
- }, [resolvedId, resolvedIndex, onSelectedComponentChange]);
39
24
  const childrenArray = React.Children.toArray(children);
40
25
  const filteredChildren = childrenArray.filter((child) => child.type !== "script");
41
- return (_jsxs(_Fragment, { children: [filteredChildren[resolvedIndex], _jsxs("div", { className: "a-editor-mce", children: [_jsx("script", { "data-placeholder-start": placeholder.key, "data-orientation": "horizontal" }), filteredChildren.map((x, index) => thumbnail(x, index)), _jsx("script", { "data-placeholder-end": placeholder.key })] })] }));
26
+ return (_jsxs(_Fragment, { children: [filteredChildren[selectedIndex < 0 ? 0 : selectedIndex], _jsxs("div", { className: "a-editor-mce", children: [_jsx("script", { "data-placeholder-start": placeholder.key, "data-orientation": "horizontal" }), filteredChildren.map((x, index) => thumbnail(x, index)), _jsx("script", { "data-placeholder-end": placeholder.key })] })] }));
42
27
  function thumbnail(x, index) {
43
28
  var _a, _b, _c, _d, _e, _f, _g;
44
29
  const style = {};
@@ -51,7 +36,7 @@ export function MultiComponentEditor({ children, component, placeholderName, thu
51
36
  const componentArray = (_c = (_b = (_a = x.props) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.children;
52
37
  const component = components[index];
53
38
  return (_jsxs(Fragment, { children: [_jsxs("div", { className: "a-editor-mce-thumbnail" +
54
- (index === resolvedIndex ? " a-editor-mce-thumbnail--selected" : ""), style: style, onClick: () => {
39
+ (index === selectedIndex ? " a-editor-mce-thumbnail--selected" : ""), style: style, onClick: () => {
55
40
  selectComponents([components[index].id]);
56
41
  }, children: [_jsx("script", { "data-component-start": component.id, "data-itemid": ((_e = (_d = component._editor) === null || _d === void 0 ? void 0 : _d.linkedComponentItem) === null || _e === void 0 ? void 0 : _e.id) || component.id, "data-layoutid": (_g = (_f = component._editor) === null || _f === void 0 ? void 0 : _f.hostingPageItem) === null || _g === void 0 ? void 0 : _g.id }), _jsx("div", { style: { pointerEvents: "none", zoom: thumbZoom || 0.25 }, children: componentArray.slice(1, -1) }), _jsx("script", { "data-component-end": component.id })] }), _jsx("div", { "data-dropzone": components[index].id })] }, index));
57
42
  }
@@ -1,29 +1,21 @@
1
1
  import axios from "axios";
2
- // import { HttpsProxyAgent } from "https-proxy-agent";
3
2
  import { NextResponse } from "next/server";
4
- async function GET(req, target
5
- //{ proxy }: { proxy?: string }
6
- ) {
3
+ async function GET(req, target) {
7
4
  const reqUrl = new URL(req.url);
8
5
  const url = target + reqUrl.pathname + "?" + reqUrl.searchParams.toString();
9
6
  const headers = {
10
7
  Authorization: req.headers.get("Authorization") || "",
11
8
  Cookie: req.headers.get("Cookie") || "",
12
9
  };
13
- // const agent = proxy ? new HttpsProxyAgent(proxy) : undefined;
14
10
  const externalResponse = await axios.get(url, {
15
11
  headers: headers,
16
- // httpAgent: agent,
17
- // httpsAgent: agent,
18
12
  responseType: "stream",
19
13
  });
20
14
  return new NextResponse(nodeReadableToReadableStream(externalResponse.data), {
21
15
  status: externalResponse.status,
22
16
  });
23
17
  }
24
- async function POST(req
25
- //{ proxy }: { proxy?: string }
26
- ) {
18
+ async function POST(req) {
27
19
  const reqUrl = new URL(req.url);
28
20
  const body = await req.text();
29
21
  const url = process.env.EDITOR_SERVICE_URL +
@@ -35,11 +27,8 @@ async function POST(req
35
27
  Authorization: req.headers.get("Authorization") || "",
36
28
  Cookie: req.headers.get("Cookie") || "",
37
29
  };
38
- // const agent = proxy ? new HttpsProxyAgent(proxy) : undefined;
39
30
  const externalResponse = await axios.post(url, body, {
40
31
  headers: headers,
41
- // httpAgent: agent,
42
- // httpsAgent: agent,
43
32
  responseType: "stream",
44
33
  });
45
34
  const responseHeaders = getResponseHeaders(externalResponse);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpaca-headless/alpaca-headless-nextjs",
3
- "version": "1.0.4472",
3
+ "version": "1.0.4473",
4
4
  "type": "module",
5
5
  "description": "Alpaca Headless",
6
6
  "main": "dist/index.js",
@@ -44,20 +44,18 @@
44
44
  },
45
45
  "homepage": "https://github.com/yourusername/your-module-name#readme",
46
46
  "devDependencies": {
47
- "@types/node": "^20.14.2",
48
- "@types/react": "19.2.2",
49
- "@types/react-dom": "19.2.2",
50
- "eslint": "^9.22.0",
51
- "eslint-config-next": "16.0.10",
52
- "typescript": "^5"
47
+ "@types/node": "^25.5.0",
48
+ "@types/react": "19.2.14",
49
+ "eslint": "^9.39.4",
50
+ "eslint-config-next": "16.2.1",
51
+ "typescript": "5.9.3"
53
52
  },
54
53
  "dependencies": {
55
- "@alpaca-headless/alpaca-headless": "^1.0.4472",
56
- "axios": "^1.8.1",
57
- "https-proxy-agent": "^7.0.4",
58
- "next": "16.0.10",
59
- "react": "19.2.3",
60
- "react-dom": "19.2.3",
54
+ "@alpaca-headless/alpaca-headless": "^1.0.4473",
55
+ "axios": "^1.13.6",
56
+ "next": "16.2.1",
57
+ "react": "19.2.4",
58
+ "react-dom": "19.2.4",
61
59
  "react-uuid": "^2.0.0"
62
60
  }
63
61
  }
@@ -2,12 +2,12 @@
2
2
  import { ComponentData } from "@alpaca-headless/alpaca-headless";
3
3
 
4
4
  import React, {
5
- Fragment,
5
+ useState,
6
6
  ReactElement,
7
7
  ReactNode,
8
- useCallback,
9
8
  useEffect,
10
- useState,
9
+ Fragment,
10
+ useCallback,
11
11
  } from "react";
12
12
 
13
13
  interface MultiComponentEditorProps {
@@ -17,10 +17,6 @@ interface MultiComponentEditorProps {
17
17
  thumbZoom?: number;
18
18
  thumbWidth?: string;
19
19
  thumbHeight?: string;
20
- onSelectedComponentChange?: (payload: {
21
- selectedId: string | null;
22
- selectedIndex: number;
23
- }) => void;
24
20
  }
25
21
 
26
22
  export function MultiComponentEditor({
@@ -30,7 +26,6 @@ export function MultiComponentEditor({
30
26
  thumbZoom,
31
27
  thumbWidth,
32
28
  thumbHeight,
33
- onSelectedComponentChange,
34
29
  }: MultiComponentEditorProps) {
35
30
  const [selectedId, setSelectedId] = useState<string | null>(null);
36
31
  const placeholder = component.placeholders.find(
@@ -60,22 +55,6 @@ export function MultiComponentEditor({
60
55
  const selectedIndex = components.findIndex(
61
56
  (x: ComponentData) => x.id === selectedId
62
57
  );
63
- const resolvedIndex = selectedIndex < 0 ? 0 : selectedIndex;
64
- const resolvedComponent = components[resolvedIndex] ?? null;
65
- const resolvedId = resolvedComponent?.id ?? null;
66
-
67
- useEffect(() => {
68
- if (resolvedId !== null && selectedId !== resolvedId) {
69
- setSelectedId(resolvedId);
70
- }
71
- }, [resolvedId, selectedId]);
72
-
73
- useEffect(() => {
74
- onSelectedComponentChange?.({
75
- selectedId: resolvedId,
76
- selectedIndex: resolvedIndex,
77
- });
78
- }, [resolvedId, resolvedIndex, onSelectedComponentChange]);
79
58
 
80
59
  const childrenArray = React.Children.toArray(children) as ReactElement[];
81
60
 
@@ -85,7 +64,7 @@ export function MultiComponentEditor({
85
64
 
86
65
  return (
87
66
  <>
88
- {filteredChildren[resolvedIndex]}
67
+ {filteredChildren[selectedIndex < 0 ? 0 : selectedIndex]}
89
68
  <div className="a-editor-mce">
90
69
  <script
91
70
  data-placeholder-start={placeholder.key}
@@ -121,7 +100,7 @@ export function MultiComponentEditor({
121
100
  <div
122
101
  className={
123
102
  "a-editor-mce-thumbnail" +
124
- (index === resolvedIndex ? " a-editor-mce-thumbnail--selected" : "")
103
+ (index === selectedIndex ? " a-editor-mce-thumbnail--selected" : "")
125
104
  }
126
105
  style={style}
127
106
  onClick={() => {
@@ -1,11 +1,9 @@
1
1
  import axios from "axios";
2
- // import { HttpsProxyAgent } from "https-proxy-agent";
3
2
  import { NextResponse } from "next/server";
4
3
 
5
4
  async function GET(
6
5
  req: Request,
7
6
  target: string
8
- //{ proxy }: { proxy?: string }
9
7
  ) {
10
8
  const reqUrl = new URL(req.url);
11
9
 
@@ -17,12 +15,8 @@ async function GET(
17
15
  Cookie: req.headers.get("Cookie") || "",
18
16
  };
19
17
 
20
- // const agent = proxy ? new HttpsProxyAgent(proxy) : undefined;
21
-
22
18
  const externalResponse = await axios.get(url, {
23
19
  headers: headers,
24
- // httpAgent: agent,
25
- // httpsAgent: agent,
26
20
  responseType: "stream",
27
21
  });
28
22
 
@@ -31,10 +25,7 @@ async function GET(
31
25
  });
32
26
  }
33
27
 
34
- async function POST(
35
- req: Request
36
- //{ proxy }: { proxy?: string }
37
- ) {
28
+ async function POST(req: Request) {
38
29
  const reqUrl = new URL(req.url);
39
30
  const body = await req.text();
40
31
 
@@ -50,12 +41,8 @@ async function POST(
50
41
  Cookie: req.headers.get("Cookie") || "",
51
42
  };
52
43
 
53
- // const agent = proxy ? new HttpsProxyAgent(proxy) : undefined;
54
-
55
44
  const externalResponse = await axios.post(url, body, {
56
45
  headers: headers,
57
- // httpAgent: agent,
58
- // httpsAgent: agent,
59
46
  responseType: "stream",
60
47
  });
61
48
 
package/tsconfig.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "moduleResolution": "bundler",
6
6
  "jsx": "react-jsx",
7
7
  "declaration": true,
8
+ "rootDir": "./src",
8
9
  "outDir": "./dist",
9
10
  "strict": true,
10
11
  "lib": ["dom", "dom.iterable", "es2021"],
@@ -0,0 +1 @@
1
+ {"root":["./src/editorintegration.tsx","./src/editorintegrationclient.tsx","./src/handlebasicauthroute.ts","./src/index.ts","./src/useexposerefreshfunction.ts","./src/client-components/multicomponenteditor.tsx","./src/client-components/index.ts","./src/middleware/handlerequest.ts","./src/middleware/index.ts","./src/proxy/index.ts"],"version":"5.9.3"}