@alpaca-headless/alpaca-headless-nextjs 0.0.2 → 0.0.4

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,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAlpacaContext = void 0;
4
+ function useAlpacaContext() {
5
+ let context = globalThis.alpacaContext;
6
+ if (!context) {
7
+ context = {};
8
+ globalThis.alpacaContext = context;
9
+ }
10
+ return context;
11
+ }
12
+ exports.useAlpacaContext = useAlpacaContext;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Placeholder = void 0;
13
+ const jsx_runtime_1 = require("react/jsx-runtime");
14
+ const __1 = require("..");
15
+ function Placeholder({ name, content, }) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const data = yield content;
18
+ if (data.type !== "page" && data.type !== "component")
19
+ return;
20
+ const placeholderData = data.placeholders.find((x) => x.name == name);
21
+ if (!placeholderData)
22
+ return;
23
+ const context = (0, __1.useAlpacaContext)();
24
+ const loader = context.componentModuleLoader;
25
+ const promises = placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.components.map((component) => __awaiter(this, void 0, void 0, function* () {
26
+ const module = yield loader(component.componentType);
27
+ return { data: component, Component: module.default };
28
+ }));
29
+ const components = yield Promise.all(promises);
30
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: components.map(({ Component, data }) => ((0, jsx_runtime_1.jsx)(Component, { component: data }))) }));
31
+ });
32
+ }
33
+ exports.Placeholder = Placeholder;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Text = void 0;
16
+ const react_1 = __importDefault(require("react"));
17
+ function Text({ field, tag, editable, }) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ if (editable)
20
+ return react_1.default.createElement(tag || "div", null, field.value);
21
+ else
22
+ return react_1.default.createElement(tag || "div", null, field.value);
23
+ });
24
+ }
25
+ exports.Text = Text;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Placeholder"), exports);
18
+ __exportStar(require("./Text"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/cjs/index.js CHANGED
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./AlpacaHeadless"), exports);
18
- __exportStar(require("./Placeholder"), exports);
17
+ __exportStar(require("./layoutData"), exports);
18
+ __exportStar(require("./loadRouteData"), exports);
19
+ __exportStar(require("./components"), exports);
20
+ __exportStar(require("./alpacaContext"), exports);
21
+ __exportStar(require("./fieldTypes"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -9,40 +9,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.loadRouteData = exports.Component = void 0;
13
- class Component {
14
- constructor(data, reactComponent) {
15
- this.data = data;
16
- this.reactComponent = reactComponent;
17
- }
18
- getPlaceholderData(placeholder) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- return this.data.placeholders.find((x) => x.name == placeholder);
21
- });
22
- }
23
- getReactComponent() {
24
- return this.reactComponent;
25
- }
26
- getData() {
27
- return;
28
- }
29
- }
30
- exports.Component = Component;
31
- function loadRouteData(params) {
12
+ exports.loadRouteData = void 0;
13
+ const alpacaContext_1 = require("./alpacaContext");
14
+ const headers_1 = require("next/headers");
15
+ function loadRouteData(params, searchParams, host) {
32
16
  var _a, _b;
33
17
  return __awaiter(this, void 0, void 0, function* () {
34
18
  const request = {
35
19
  Path: (_b = (_a = params.path) === null || _a === void 0 ? void 0 : _a.join("/")) !== null && _b !== void 0 ? _b : "/",
36
- Host: "alpaca.headless.site",
37
- Mode: "preview",
20
+ Host: host,
21
+ Mode: searchParams["mode"] || "preview",
22
+ ItemId: searchParams["itemid"],
23
+ Language: searchParams["language"],
38
24
  };
39
25
  const url = process.env.LAYOUT_SERVICE_URL + "/alpaca/headless/layout";
40
- console.log(`Fetching page layout from ${url}`);
26
+ console.log(`Fetching page layout from ${url}. Host:${request.Host} Path: ${request.Path}`);
41
27
  const response = yield fetch(url, {
42
28
  method: "POST",
43
29
  body: JSON.stringify(request),
30
+ credentials: "include",
44
31
  headers: {
45
32
  "Content-Type": "application/json",
33
+ Cookie: (0, headers_1.cookies)().toString(),
46
34
  },
47
35
  next: { tags: ["pages"], revalidate: 10 },
48
36
  });
@@ -66,6 +54,15 @@ function loadRouteData(params) {
66
54
  };
67
55
  }
68
56
  const data = yield response.json();
57
+ console.log(data);
58
+ const context = (0, alpacaContext_1.useAlpacaContext)();
59
+ context.pageContext = {
60
+ itemId: data.page.id,
61
+ language: data.page.language,
62
+ site: data.site,
63
+ pageEditing: true,
64
+ pageState: "",
65
+ };
69
66
  return Object.assign(Object.assign({}, data.page), { type: "page" });
70
67
  });
71
68
  }
@@ -0,0 +1,8 @@
1
+ export function useAlpacaContext() {
2
+ let context = globalThis.alpacaContext;
3
+ if (!context) {
4
+ context = {};
5
+ globalThis.alpacaContext = context;
6
+ }
7
+ return context;
8
+ }
@@ -7,7 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import React from "react";
10
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
11
+ import { useAlpacaContext, } from "..";
11
12
  export function Placeholder({ name, content, }) {
12
13
  return __awaiter(this, void 0, void 0, function* () {
13
14
  const data = yield content;
@@ -16,11 +17,13 @@ export function Placeholder({ name, content, }) {
16
17
  const placeholderData = data.placeholders.find((x) => x.name == name);
17
18
  if (!placeholderData)
18
19
  return;
20
+ const context = useAlpacaContext();
21
+ const loader = context.componentModuleLoader;
19
22
  const promises = placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.components.map((component) => __awaiter(this, void 0, void 0, function* () {
20
- const module = yield import(`./components/${component.componentType}`);
23
+ const module = yield loader(component.componentType);
21
24
  return { data: component, Component: module.default };
22
25
  }));
23
26
  const components = yield Promise.all(promises);
24
- return (React.createElement(React.Fragment, null, components.map(({ Component, data }) => (React.createElement(Component, { component: data })))));
27
+ return (_jsx(_Fragment, { children: components.map(({ Component, data }) => (_jsx(Component, { component: data }))) }));
25
28
  });
26
29
  }
@@ -0,0 +1,18 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import React from "react";
11
+ export function Text({ field, tag, editable, }) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ if (editable)
14
+ return React.createElement(tag || "div", null, field.value);
15
+ else
16
+ return React.createElement(tag || "div", null, field.value);
17
+ });
18
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Placeholder";
2
+ export * from "./Text";
@@ -0,0 +1 @@
1
+ export {};
package/dist/esm/index.js CHANGED
@@ -1,2 +1,5 @@
1
- export * from "./AlpacaHeadless";
2
- export * from "./Placeholder";
1
+ export * from "./layoutData";
2
+ export * from "./loadRouteData";
3
+ export * from "./components";
4
+ export * from "./alpacaContext";
5
+ export * from "./fieldTypes";
@@ -0,0 +1 @@
1
+ export {};
@@ -7,38 +7,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- export class Component {
11
- constructor(data, reactComponent) {
12
- this.data = data;
13
- this.reactComponent = reactComponent;
14
- }
15
- getPlaceholderData(placeholder) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- return this.data.placeholders.find((x) => x.name == placeholder);
18
- });
19
- }
20
- getReactComponent() {
21
- return this.reactComponent;
22
- }
23
- getData() {
24
- return;
25
- }
26
- }
27
- export function loadRouteData(params) {
10
+ import { useAlpacaContext } from "./alpacaContext";
11
+ import { cookies } from "next/headers";
12
+ export function loadRouteData(params, searchParams, host) {
28
13
  var _a, _b;
29
14
  return __awaiter(this, void 0, void 0, function* () {
30
15
  const request = {
31
16
  Path: (_b = (_a = params.path) === null || _a === void 0 ? void 0 : _a.join("/")) !== null && _b !== void 0 ? _b : "/",
32
- Host: "alpaca.headless.site",
33
- Mode: "preview",
17
+ Host: host,
18
+ Mode: searchParams["mode"] || "preview",
19
+ ItemId: searchParams["itemid"],
20
+ Language: searchParams["language"],
34
21
  };
35
22
  const url = process.env.LAYOUT_SERVICE_URL + "/alpaca/headless/layout";
36
- console.log(`Fetching page layout from ${url}`);
23
+ console.log(`Fetching page layout from ${url}. Host:${request.Host} Path: ${request.Path}`);
37
24
  const response = yield fetch(url, {
38
25
  method: "POST",
39
26
  body: JSON.stringify(request),
27
+ credentials: "include",
40
28
  headers: {
41
29
  "Content-Type": "application/json",
30
+ Cookie: cookies().toString(),
42
31
  },
43
32
  next: { tags: ["pages"], revalidate: 10 },
44
33
  });
@@ -62,6 +51,15 @@ export function loadRouteData(params) {
62
51
  };
63
52
  }
64
53
  const data = yield response.json();
54
+ console.log(data);
55
+ const context = useAlpacaContext();
56
+ context.pageContext = {
57
+ itemId: data.page.id,
58
+ language: data.page.language,
59
+ site: data.site,
60
+ pageEditing: true,
61
+ pageState: "",
62
+ };
65
63
  return Object.assign(Object.assign({}, data.page), { type: "page" });
66
64
  });
67
65
  }
package/next-env.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- /// <reference types="next" />
2
- /// <reference types="next/image-types/global" />
3
-
4
- // NOTE: This file should not be edited
5
- // see https://nextjs.org/docs/basic-features/typescript for more information.
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+
4
+ // NOTE: This file should not be edited
5
+ // see https://nextjs.org/docs/basic-features/typescript for more information.
package/package.json CHANGED
@@ -1,41 +1,39 @@
1
- {
2
- "name": "@alpaca-headless/alpaca-headless-nextjs",
3
- "version": "0.0.2",
4
- "description": "Alpaca Headless NextJs Integration",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/esm/index.js",
7
- "types": "types/index.d.ts",
8
- "files": [
9
- "dist",
10
- "types",
11
- "/*.js",
12
- "/*.d.ts"
13
- ],
14
- "scripts": {
15
- "build": "npm run build:cjs && npm run build:esm",
16
- "build:cjs": "node tools/cleanup cjs && tsc -p config/tsconfig.cjs.json --noEmit false",
17
- "build:esm": "node tools/cleanup esm && tsc -p config/tsconfig.esm.json --noEmit false",
18
- "build:umd": "node tools/cleanup umd && webpack --config config/webpack.config.js --noEmit false",
19
- "build:types": "node tools/cleanup types && tsc -p config/tsconfig.types.json --noEmit false",
20
- "clean": "node tools/cleanup",
21
- "package": "npm run build && npm pack"
22
- },
23
- "author": "Canvas REPLY DE GmbH",
24
- "license": "MIT",
25
- "dependencies": {
26
- "autoprefixer": "10.4.14",
27
- "next": "13.4.9",
28
- "node-cleanup": "^2.1.2",
29
- "react": "18.2.0",
30
- "react-dom": "18.2.0",
31
- "server-only": "^0.0.1"
32
- },
33
- "devDependencies": {
34
- "@types/node": "20.4.1",
35
- "@types/react": "18.2.14",
36
- "@types/react-dom": "18.2.6",
37
- "eslint": "8.44.0",
38
- "eslint-config-next": "13.4.9",
39
- "typescript": "5.1.6"
40
- }
41
- }
1
+ {
2
+ "name": "@alpaca-headless/alpaca-headless-nextjs",
3
+ "version": "0.0.4",
4
+ "description": "Alpaca Headless NextJs Integration",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "types/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "types",
11
+ "/*.js",
12
+ "/*.d.ts"
13
+ ],
14
+ "scripts": {
15
+ "build": "npm run build:cjs && npm run build:esm",
16
+ "build:cjs": "node tools/cleanup cjs && tsc -p config/tsconfig.cjs.json --noEmit false",
17
+ "build:esm": "node tools/cleanup esm && tsc -p config/tsconfig.esm.json --noEmit false",
18
+ "clean": "node tools/cleanup",
19
+ "package": "npm run build && npm pack"
20
+ },
21
+ "author": "Canvas REPLY DE GmbH",
22
+ "license": "MIT",
23
+ "dependencies": {
24
+ "autoprefixer": "10.4.14",
25
+ "next": "13.4.9",
26
+ "node-cleanup": "^2.1.2",
27
+ "react": "18.2.0",
28
+ "react-dom": "18.2.0",
29
+ "server-only": "^0.0.1"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "20.4.1",
33
+ "@types/react": "18.2.14",
34
+ "@types/react-dom": "18.2.6",
35
+ "eslint": "8.44.0",
36
+ "eslint-config-next": "13.4.9",
37
+ "typescript": "5.1.6"
38
+ }
39
+ }
@@ -0,0 +1,14 @@
1
+ type AlpacaContext = {
2
+ componentModuleLoader: (name: string) => Promise<any>;
3
+ pageContext: {
4
+ itemId: string;
5
+ language: string;
6
+ pageEditing: boolean;
7
+ pageState: string;
8
+ site: {
9
+ name: string;
10
+ };
11
+ };
12
+ };
13
+ export declare function useAlpacaContext(): AlpacaContext;
14
+ export {};
@@ -1,6 +1,5 @@
1
- import React from "react";
2
- import { ComponentData, Page, Redirect, NotFound, Error } from "./AlpacaHeadless";
1
+ import { ComponentData, Page, Redirect, NotFound, Error } from "..";
3
2
  export declare function Placeholder({ name, content, }: {
4
3
  name: string;
5
4
  content: Promise<Error | Page | Redirect | NotFound | ComponentData> | ComponentData;
6
- }): Promise<React.JSX.Element | undefined>;
5
+ }): Promise<import("react/jsx-runtime").JSX.Element | undefined>;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { TextField } from "../fieldTypes";
3
+ export declare function Text({ field, tag, editable, }: {
4
+ field: TextField;
5
+ tag?: string;
6
+ editable?: boolean;
7
+ }): Promise<React.DOMElement<React.DOMAttributes<Element>, Element>>;
@@ -0,0 +1,2 @@
1
+ export * from "./Placeholder";
2
+ export * from "./Text";
@@ -0,0 +1,3 @@
1
+ export type TextField = {
2
+ value: string;
3
+ };
package/types/index.d.ts CHANGED
@@ -1,2 +1,5 @@
1
- export * from "./AlpacaHeadless";
2
- export * from "./Placeholder";
1
+ export * from "./layoutData";
2
+ export * from "./loadRouteData";
3
+ export * from "./components";
4
+ export * from "./alpacaContext";
5
+ export * from "./fieldTypes";
@@ -0,0 +1,11 @@
1
+ export type PlaceholderData = {
2
+ name: string;
3
+ components: ComponentData[];
4
+ };
5
+ export type ComponentData = {
6
+ name: string;
7
+ componentType: string;
8
+ graphql: object;
9
+ placeholders: PlaceholderData[];
10
+ type: "component";
11
+ };
@@ -0,0 +1,27 @@
1
+ import { PlaceholderData } from "./layoutData";
2
+ type Response = {
3
+ type: "page" | "redirect" | "error" | "notfound";
4
+ };
5
+ export type Error = Response & {
6
+ type: "error";
7
+ message: string;
8
+ errorCode: number;
9
+ };
10
+ export type Page = Response & {
11
+ type: "page";
12
+ placeholders: PlaceholderData[];
13
+ meta: {
14
+ title: string;
15
+ };
16
+ };
17
+ export type Redirect = Response & {
18
+ type: "redirect";
19
+ location: string;
20
+ };
21
+ export type NotFound = Response & {
22
+ type: "notfound";
23
+ };
24
+ export declare function loadRouteData(params: {
25
+ path: string[];
26
+ }, searchParams: any, host: string): Promise<Page | Error | Redirect | NotFound>;
27
+ export {};
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.Placeholder = void 0;
39
- const react_1 = __importDefault(require("react"));
40
- function Placeholder({ name, content, }) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- const data = yield content;
43
- if (data.type !== "page" && data.type !== "component")
44
- return;
45
- const placeholderData = data.placeholders.find((x) => x.name == name);
46
- if (!placeholderData)
47
- return;
48
- const promises = placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.components.map((component) => __awaiter(this, void 0, void 0, function* () {
49
- const module = yield Promise.resolve(`${`./components/${component.componentType}`}`).then(s => __importStar(require(s)));
50
- return { data: component, Component: module.default };
51
- }));
52
- const components = yield Promise.all(promises);
53
- return (react_1.default.createElement(react_1.default.Fragment, null, components.map(({ Component, data }) => (react_1.default.createElement(Component, { component: data })))));
54
- });
55
- }
56
- exports.Placeholder = Placeholder;
package/dist/cjs/Test.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Test = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- function Test({ name }) {
9
- return react_1.default.createElement(react_1.default.Fragment, null, name);
10
- }
11
- exports.Test = Test;
package/dist/esm/Test.js DELETED
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- export function Test({ name }) {
3
- return React.createElement(React.Fragment, null, name);
4
- }
@@ -1,45 +0,0 @@
1
- export type PlaceholderData = {
2
- name: string;
3
- components: ComponentData[];
4
- };
5
- export type ComponentData = {
6
- name: string;
7
- componentType: string;
8
- graphql: object;
9
- placeholders: PlaceholderData[];
10
- type: "component";
11
- };
12
- export declare class Component {
13
- private data;
14
- private reactComponent;
15
- constructor(data: ComponentData, reactComponent: any);
16
- getPlaceholderData(placeholder: string): Promise<PlaceholderData | undefined>;
17
- getReactComponent(): any;
18
- getData(): void;
19
- }
20
- type Response = {
21
- type: "page" | "redirect" | "error" | "notfound";
22
- };
23
- export type Error = Response & {
24
- type: "error";
25
- message: string;
26
- errorCode: number;
27
- };
28
- export type Page = Response & {
29
- type: "page";
30
- placeholders: PlaceholderData[];
31
- };
32
- export type Redirect = Response & {
33
- type: "redirect";
34
- location: string;
35
- };
36
- export type NotFound = Response & {
37
- type: "notfound";
38
- };
39
- export type TextField = {
40
- value: string;
41
- };
42
- export declare function loadRouteData(params: {
43
- path: string[];
44
- }): Promise<Page | Error | Redirect | NotFound>;
45
- export {};
package/types/Test.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- export declare function Test({ name }: {
3
- name: string;
4
- }): React.JSX.Element;