@alpaca-headless/alpaca-headless-nextjs 0.0.2 → 0.0.3
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/cjs/alpacaContext.js +11 -0
- package/dist/cjs/components/Placeholder.js +31 -0
- package/dist/cjs/components/Text.js +25 -0
- package/dist/cjs/components/index.js +18 -0
- package/dist/cjs/fieldTypes.js +2 -0
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/layoutData.js +2 -0
- package/dist/{esm/AlpacaHeadless.js → cjs/loadRouteData.js} +15 -19
- package/dist/esm/alpacaContext.js +6 -0
- package/dist/esm/{Placeholder.js → components/Placeholder.js} +4 -3
- package/dist/esm/components/Text.js +18 -0
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/fieldTypes.js +1 -0
- package/dist/esm/index.js +3 -2
- package/dist/esm/layoutData.js +1 -0
- package/dist/{cjs/AlpacaHeadless.js → esm/loadRouteData.js} +11 -24
- package/package.json +1 -3
- package/types/AlpacaHeadless.d.ts +0 -8
- package/types/alpacaContext.d.ts +12 -0
- package/types/{Placeholder.d.ts → components/Placeholder.d.ts} +2 -3
- package/types/components/Text.d.ts +7 -0
- package/types/components/index.d.ts +2 -0
- package/types/fieldTypes.d.ts +3 -0
- package/types/index.d.ts +3 -2
- package/types/layoutData.d.ts +11 -0
- package/types/loadRouteData.d.ts +24 -0
- package/dist/cjs/Placeholder.js +0 -56
- package/dist/cjs/Test.js +0 -11
- package/dist/esm/Test.js +0 -4
- package/types/Test.d.ts +0 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setAlpacaContext = exports.useAlpacaContext = void 0;
|
|
4
|
+
function useAlpacaContext() {
|
|
5
|
+
return globalThis.alpacaContext;
|
|
6
|
+
}
|
|
7
|
+
exports.useAlpacaContext = useAlpacaContext;
|
|
8
|
+
function setAlpacaContext(context) {
|
|
9
|
+
globalThis.alpacaContext = context;
|
|
10
|
+
}
|
|
11
|
+
exports.setAlpacaContext = setAlpacaContext;
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
function Placeholder({ name, content, }) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const data = yield content;
|
|
17
|
+
if (data.type !== "page" && data.type !== "component")
|
|
18
|
+
return;
|
|
19
|
+
const placeholderData = data.placeholders.find((x) => x.name == name);
|
|
20
|
+
if (!placeholderData)
|
|
21
|
+
return;
|
|
22
|
+
const loader = globalThis.moduleLoader;
|
|
23
|
+
const promises = placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.components.map((component) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const module = yield loader(component.componentType);
|
|
25
|
+
return { data: component, Component: module.default };
|
|
26
|
+
}));
|
|
27
|
+
const components = yield Promise.all(promises);
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: components.map(({ Component, data }) => ((0, jsx_runtime_1.jsx)(Component, { component: data }))) }));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
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);
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,5 +14,6 @@ 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("./
|
|
18
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./layoutData"), exports);
|
|
18
|
+
__exportStar(require("./loadRouteData"), exports);
|
|
19
|
+
__exportStar(require("./components"), exports);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,29 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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) {
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadRouteData = void 0;
|
|
13
|
+
const alpacaContext_1 = require("./alpacaContext");
|
|
14
|
+
function loadRouteData(params, host) {
|
|
28
15
|
var _a, _b;
|
|
29
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
17
|
const request = {
|
|
31
18
|
Path: (_b = (_a = params.path) === null || _a === void 0 ? void 0 : _a.join("/")) !== null && _b !== void 0 ? _b : "/",
|
|
32
|
-
Host:
|
|
19
|
+
Host: host,
|
|
33
20
|
Mode: "preview",
|
|
34
21
|
};
|
|
35
22
|
const url = process.env.LAYOUT_SERVICE_URL + "/alpaca/headless/layout";
|
|
@@ -61,7 +48,16 @@ export function loadRouteData(params) {
|
|
|
61
48
|
message: message,
|
|
62
49
|
};
|
|
63
50
|
}
|
|
51
|
+
(0, alpacaContext_1.setAlpacaContext)({
|
|
52
|
+
itemId: "",
|
|
53
|
+
language: "en",
|
|
54
|
+
site: { name: "" },
|
|
55
|
+
pageEditing: true,
|
|
56
|
+
pageState: "",
|
|
57
|
+
});
|
|
64
58
|
const data = yield response.json();
|
|
59
|
+
console.log(data);
|
|
65
60
|
return Object.assign(Object.assign({}, data.page), { type: "page" });
|
|
66
61
|
});
|
|
67
62
|
}
|
|
63
|
+
exports.loadRouteData = loadRouteData;
|
|
@@ -7,7 +7,7 @@ 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
|
|
10
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
11
|
export function Placeholder({ name, content, }) {
|
|
12
12
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
13
|
const data = yield content;
|
|
@@ -16,11 +16,12 @@ export function Placeholder({ name, content, }) {
|
|
|
16
16
|
const placeholderData = data.placeholders.find((x) => x.name == name);
|
|
17
17
|
if (!placeholderData)
|
|
18
18
|
return;
|
|
19
|
+
const loader = globalThis.moduleLoader;
|
|
19
20
|
const promises = placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.components.map((component) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const module = yield
|
|
21
|
+
const module = yield loader(component.componentType);
|
|
21
22
|
return { data: component, Component: module.default };
|
|
22
23
|
}));
|
|
23
24
|
const components = yield Promise.all(promises);
|
|
24
|
-
return (
|
|
25
|
+
return (_jsx(_Fragment, { children: components.map(({ Component, data }) => (_jsx(Component, { component: data }))) }));
|
|
25
26
|
});
|
|
26
27
|
}
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./layoutData";
|
|
2
|
+
export * from "./loadRouteData";
|
|
3
|
+
export * from "./components";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,32 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
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) {
|
|
10
|
+
import { setAlpacaContext } from "./alpacaContext";
|
|
11
|
+
export function loadRouteData(params, host) {
|
|
32
12
|
var _a, _b;
|
|
33
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
14
|
const request = {
|
|
35
15
|
Path: (_b = (_a = params.path) === null || _a === void 0 ? void 0 : _a.join("/")) !== null && _b !== void 0 ? _b : "/",
|
|
36
|
-
Host:
|
|
16
|
+
Host: host,
|
|
37
17
|
Mode: "preview",
|
|
38
18
|
};
|
|
39
19
|
const url = process.env.LAYOUT_SERVICE_URL + "/alpaca/headless/layout";
|
|
@@ -65,8 +45,15 @@ function loadRouteData(params) {
|
|
|
65
45
|
message: message,
|
|
66
46
|
};
|
|
67
47
|
}
|
|
48
|
+
setAlpacaContext({
|
|
49
|
+
itemId: "",
|
|
50
|
+
language: "en",
|
|
51
|
+
site: { name: "" },
|
|
52
|
+
pageEditing: true,
|
|
53
|
+
pageState: "",
|
|
54
|
+
});
|
|
68
55
|
const data = yield response.json();
|
|
56
|
+
console.log(data);
|
|
69
57
|
return Object.assign(Object.assign({}, data.page), { type: "page" });
|
|
70
58
|
});
|
|
71
59
|
}
|
|
72
|
-
exports.loadRouteData = loadRouteData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alpaca-headless/alpaca-headless-nextjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Alpaca Headless NextJs Integration",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
"build": "npm run build:cjs && npm run build:esm",
|
|
16
16
|
"build:cjs": "node tools/cleanup cjs && tsc -p config/tsconfig.cjs.json --noEmit false",
|
|
17
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
18
|
"clean": "node tools/cleanup",
|
|
21
19
|
"package": "npm run build && npm pack"
|
|
22
20
|
},
|
|
@@ -9,14 +9,6 @@ export type ComponentData = {
|
|
|
9
9
|
placeholders: PlaceholderData[];
|
|
10
10
|
type: "component";
|
|
11
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
12
|
type Response = {
|
|
21
13
|
type: "page" | "redirect" | "error" | "notfound";
|
|
22
14
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type AlpacaContext = {
|
|
2
|
+
itemId: string;
|
|
3
|
+
language: string;
|
|
4
|
+
pageEditing: boolean;
|
|
5
|
+
pageState: string;
|
|
6
|
+
site: {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function useAlpacaContext(): AlpacaContext;
|
|
11
|
+
export declare function setAlpacaContext(context: AlpacaContext): void;
|
|
12
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
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<
|
|
5
|
+
}): Promise<import("react/jsx-runtime").JSX.Element | undefined>;
|
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./layoutData";
|
|
2
|
+
export * from "./loadRouteData";
|
|
3
|
+
export * from "./components";
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
};
|
|
14
|
+
export type Redirect = Response & {
|
|
15
|
+
type: "redirect";
|
|
16
|
+
location: string;
|
|
17
|
+
};
|
|
18
|
+
export type NotFound = Response & {
|
|
19
|
+
type: "notfound";
|
|
20
|
+
};
|
|
21
|
+
export declare function loadRouteData(params: {
|
|
22
|
+
path: string[];
|
|
23
|
+
}, host: string): Promise<Page | Error | Redirect | NotFound>;
|
|
24
|
+
export {};
|
package/dist/cjs/Placeholder.js
DELETED
|
@@ -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
package/types/Test.d.ts
DELETED