@flyo/nitro-next 1.0.0 → 1.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/client.d.mts +57 -1
- package/dist/client.d.ts +57 -1
- package/dist/client.js +108 -1
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +81 -0
- package/dist/client.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +110 -15
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +77 -7
- package/dist/server.mjs.map +1 -1
- package/package.json +9 -9
- package/dist/chunk-JMEC5XWK.js +0 -84
- package/dist/chunk-JMEC5XWK.js.map +0 -1
- package/dist/chunk-T46Q5G3T.mjs +0 -84
- package/dist/chunk-T46Q5G3T.mjs.map +0 -1
- package/dist/index.d.mts +0 -3
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -17
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -17
- package/dist/index.mjs.map +0 -1
package/dist/client.d.mts
CHANGED
|
@@ -1,2 +1,58 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Block } from '@flyo/nitro-typescript';
|
|
1
3
|
|
|
2
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Type for WYSIWYG node structure
|
|
6
|
+
*/
|
|
7
|
+
interface WysiwygNode {
|
|
8
|
+
type: string;
|
|
9
|
+
content?: WysiwygNode[];
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Type for WYSIWYG JSON that can be a node, array of nodes, or doc structure
|
|
14
|
+
*/
|
|
15
|
+
type WysiwygJson = WysiwygNode | WysiwygNode[] | {
|
|
16
|
+
type: 'doc';
|
|
17
|
+
content: WysiwygNode[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Helper function to get editable props
|
|
21
|
+
*/
|
|
22
|
+
declare function editable(block: Block): {
|
|
23
|
+
'data-flyo-uid'?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Internal client component that sets up live editing functionality
|
|
27
|
+
*/
|
|
28
|
+
declare function FlyoClientWrapper({ children, }: {
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
}): react_jsx_runtime.JSX.Element;
|
|
31
|
+
/**
|
|
32
|
+
* WYSIWYG component for rendering ProseMirror/TipTap JSON content
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* import { FlyoWysiwyg } from '@flyo/nitro-next/client';
|
|
37
|
+
* import CustomImage from './CustomImage';
|
|
38
|
+
*
|
|
39
|
+
* export default function MyComponent({ block }) {
|
|
40
|
+
* return (
|
|
41
|
+
* <FlyoWysiwyg
|
|
42
|
+
* json={block.content.json}
|
|
43
|
+
* components={{
|
|
44
|
+
* image: CustomImage
|
|
45
|
+
* }}
|
|
46
|
+
* />
|
|
47
|
+
* );
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
declare function FlyoWysiwyg({ json, components, }: {
|
|
52
|
+
json: WysiwygJson;
|
|
53
|
+
components?: Record<string, React.ComponentType<{
|
|
54
|
+
node: WysiwygNode;
|
|
55
|
+
}>>;
|
|
56
|
+
}): react_jsx_runtime.JSX.Element;
|
|
57
|
+
|
|
58
|
+
export { FlyoClientWrapper, FlyoWysiwyg, editable };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,58 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Block } from '@flyo/nitro-typescript';
|
|
1
3
|
|
|
2
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Type for WYSIWYG node structure
|
|
6
|
+
*/
|
|
7
|
+
interface WysiwygNode {
|
|
8
|
+
type: string;
|
|
9
|
+
content?: WysiwygNode[];
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Type for WYSIWYG JSON that can be a node, array of nodes, or doc structure
|
|
14
|
+
*/
|
|
15
|
+
type WysiwygJson = WysiwygNode | WysiwygNode[] | {
|
|
16
|
+
type: 'doc';
|
|
17
|
+
content: WysiwygNode[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Helper function to get editable props
|
|
21
|
+
*/
|
|
22
|
+
declare function editable(block: Block): {
|
|
23
|
+
'data-flyo-uid'?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Internal client component that sets up live editing functionality
|
|
27
|
+
*/
|
|
28
|
+
declare function FlyoClientWrapper({ children, }: {
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
}): react_jsx_runtime.JSX.Element;
|
|
31
|
+
/**
|
|
32
|
+
* WYSIWYG component for rendering ProseMirror/TipTap JSON content
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* import { FlyoWysiwyg } from '@flyo/nitro-next/client';
|
|
37
|
+
* import CustomImage from './CustomImage';
|
|
38
|
+
*
|
|
39
|
+
* export default function MyComponent({ block }) {
|
|
40
|
+
* return (
|
|
41
|
+
* <FlyoWysiwyg
|
|
42
|
+
* json={block.content.json}
|
|
43
|
+
* components={{
|
|
44
|
+
* image: CustomImage
|
|
45
|
+
* }}
|
|
46
|
+
* />
|
|
47
|
+
* );
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
declare function FlyoWysiwyg({ json, components, }: {
|
|
52
|
+
json: WysiwygJson;
|
|
53
|
+
components?: Record<string, React.ComponentType<{
|
|
54
|
+
node: WysiwygNode;
|
|
55
|
+
}>>;
|
|
56
|
+
}): react_jsx_runtime.JSX.Element;
|
|
57
|
+
|
|
58
|
+
export { FlyoClientWrapper, FlyoWysiwyg, editable };
|
package/dist/client.js
CHANGED
|
@@ -1,2 +1,109 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/client.tsx
|
|
22
|
+
var client_exports = {};
|
|
23
|
+
__export(client_exports, {
|
|
24
|
+
FlyoClientWrapper: () => FlyoClientWrapper,
|
|
25
|
+
FlyoWysiwyg: () => FlyoWysiwyg,
|
|
26
|
+
editable: () => editable
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(client_exports);
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_nitro_js_bridge = require("@flyo/nitro-js-bridge");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
function editable(block) {
|
|
33
|
+
if (typeof block.uid === "string" && block.uid.trim() !== "") {
|
|
34
|
+
return { "data-flyo-uid": block.uid };
|
|
35
|
+
}
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
function FlyoClientWrapper({
|
|
39
|
+
children
|
|
40
|
+
}) {
|
|
41
|
+
(0, import_react.useEffect)(() => {
|
|
42
|
+
if (typeof window === "undefined") {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
(0, import_nitro_js_bridge.reload)();
|
|
46
|
+
const wireAll = () => {
|
|
47
|
+
const elements = document.querySelectorAll("[data-flyo-uid]");
|
|
48
|
+
elements.forEach((el) => {
|
|
49
|
+
const uid = el.getAttribute("data-flyo-uid");
|
|
50
|
+
if (uid && el instanceof HTMLElement) {
|
|
51
|
+
(0, import_nitro_js_bridge.highlightAndClick)(uid, el);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
wireAll();
|
|
56
|
+
const observer = new MutationObserver((mutations) => {
|
|
57
|
+
const hasRelevantChanges = mutations.some(
|
|
58
|
+
(mutation) => Array.from(mutation.addedNodes).some((node) => {
|
|
59
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
60
|
+
const element = node;
|
|
61
|
+
return element.hasAttribute("data-flyo-uid") || element.querySelector("[data-flyo-uid]");
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
if (hasRelevantChanges) {
|
|
67
|
+
wireAll();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
observer.observe(document.body, {
|
|
71
|
+
childList: true,
|
|
72
|
+
subtree: true
|
|
73
|
+
});
|
|
74
|
+
return () => {
|
|
75
|
+
observer.disconnect();
|
|
76
|
+
};
|
|
77
|
+
}, []);
|
|
78
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
79
|
+
}
|
|
80
|
+
function FlyoWysiwyg({
|
|
81
|
+
json,
|
|
82
|
+
components = {}
|
|
83
|
+
}) {
|
|
84
|
+
let nodes = [];
|
|
85
|
+
if (json) {
|
|
86
|
+
if (Array.isArray(json)) {
|
|
87
|
+
nodes = json;
|
|
88
|
+
} else if ("type" in json && json.type === "doc" && Array.isArray(json.content)) {
|
|
89
|
+
nodes = json.content;
|
|
90
|
+
} else {
|
|
91
|
+
nodes = [json];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: nodes.map((node, index) => {
|
|
95
|
+
const Component = components[node.type];
|
|
96
|
+
if (Component) {
|
|
97
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { node }, index);
|
|
98
|
+
}
|
|
99
|
+
const html = (0, import_nitro_js_bridge.wysiwyg)(node);
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { dangerouslySetInnerHTML: { __html: html } }, index);
|
|
101
|
+
}) });
|
|
102
|
+
}
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {
|
|
105
|
+
FlyoClientWrapper,
|
|
106
|
+
FlyoWysiwyg,
|
|
107
|
+
editable
|
|
108
|
+
});
|
|
2
109
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/
|
|
1
|
+
{"version":3,"sources":["../src/client.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { highlightAndClick, wysiwyg, reload} from '@flyo/nitro-js-bridge';\nimport { Block } from \"@flyo/nitro-typescript\";\n\n/**\n * Type for WYSIWYG node structure\n */\ninterface WysiwygNode {\n type: string;\n content?: WysiwygNode[];\n [key: string]: unknown;\n}\n\n/**\n * Type for WYSIWYG JSON that can be a node, array of nodes, or doc structure\n */\ntype WysiwygJson = WysiwygNode | WysiwygNode[] | { type: 'doc'; content: WysiwygNode[] };\n\n/**\n * Helper function to get editable props\n */\nexport function editable(block: Block): { 'data-flyo-uid'?: string } {\n if (typeof block.uid === 'string' && block.uid.trim() !== '') {\n return { 'data-flyo-uid': block.uid };\n }\n return {};\n}\n\n/**\n * Internal client component that sets up live editing functionality\n */\nexport function FlyoClientWrapper({ \n children,\n}: { \n children: React.ReactNode;\n}) {\n useEffect(() => {\n if (typeof window === 'undefined') {\n return;\n }\n\n reload();\n\n const wireAll = () => {\n const elements = document.querySelectorAll('[data-flyo-uid]');\n elements.forEach((el) => {\n const uid = el.getAttribute('data-flyo-uid');\n if (uid && el instanceof HTMLElement) {\n highlightAndClick(uid, el);\n }\n });\n };\n\n wireAll();\n\n const observer = new MutationObserver((mutations) => {\n const hasRelevantChanges = mutations.some(mutation => \n Array.from(mutation.addedNodes).some(node => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const element = node as Element;\n return element.hasAttribute('data-flyo-uid') || \n element.querySelector('[data-flyo-uid]');\n }\n return false;\n })\n );\n\n if (hasRelevantChanges) {\n wireAll();\n }\n });\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n });\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return <>{children}</>;\n}\n\n/**\n * WYSIWYG component for rendering ProseMirror/TipTap JSON content\n * \n * @example\n * ```tsx\n * import { FlyoWysiwyg } from '@flyo/nitro-next/client';\n * import CustomImage from './CustomImage';\n * \n * export default function MyComponent({ block }) {\n * return (\n * <FlyoWysiwyg \n * json={block.content.json} \n * components={{\n * image: CustomImage\n * }} \n * />\n * );\n * }\n * ```\n */\nexport function FlyoWysiwyg({\n json,\n components = {},\n}: {\n json: WysiwygJson;\n components?: Record<string, React.ComponentType<{ node: WysiwygNode }>>;\n}) {\n let nodes: WysiwygNode[] = [];\n\n if (json) {\n if (Array.isArray(json)) {\n nodes = json;\n } else if ('type' in json && json.type === 'doc' && Array.isArray(json.content)) {\n nodes = json.content;\n } else {\n nodes = [json as WysiwygNode];\n }\n }\n\n return (\n <>\n {nodes.map((node: WysiwygNode, index: number) => {\n const Component = components[node.type];\n if (Component) {\n return <Component key={index} node={node} />;\n }\n \n const html = wysiwyg(node);\n return <div key={index} dangerouslySetInnerHTML={{ __html: html }} />;\n })}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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I,MAAM;AACR,QAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,cAAQ;AAAA,IACV,WAAW,UAAU,QAAQ,KAAK,SAAS,SAAS,MAAM,QAAQ,KAAK,OAAO,GAAG;AAC/E,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,cAAQ,CAAC,IAAmB;AAAA,IAC9B;AAAA,EACF;AAEA,SACE,2EACG,gBAAM,IAAI,CAAC,MAAmB,UAAkB;AAC/C,UAAM,YAAY,WAAW,KAAK,IAAI;AACtC,QAAI,WAAW;AACb,aAAO,4CAAC,aAAsB,QAAP,KAAmB;AAAA,IAC5C;AAEA,UAAM,WAAO,gCAAQ,IAAI;AACzB,WAAO,4CAAC,SAAgB,yBAAyB,EAAE,QAAQ,KAAK,KAA/C,KAAkD;AAAA,EACrE,CAAC,GACH;AAEJ;","names":[]}
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,83 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
|
|
3
|
+
// src/client.tsx
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { highlightAndClick, wysiwyg, reload } from "@flyo/nitro-js-bridge";
|
|
6
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
7
|
+
function editable(block) {
|
|
8
|
+
if (typeof block.uid === "string" && block.uid.trim() !== "") {
|
|
9
|
+
return { "data-flyo-uid": block.uid };
|
|
10
|
+
}
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
function FlyoClientWrapper({
|
|
14
|
+
children
|
|
15
|
+
}) {
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (typeof window === "undefined") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
reload();
|
|
21
|
+
const wireAll = () => {
|
|
22
|
+
const elements = document.querySelectorAll("[data-flyo-uid]");
|
|
23
|
+
elements.forEach((el) => {
|
|
24
|
+
const uid = el.getAttribute("data-flyo-uid");
|
|
25
|
+
if (uid && el instanceof HTMLElement) {
|
|
26
|
+
highlightAndClick(uid, el);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
wireAll();
|
|
31
|
+
const observer = new MutationObserver((mutations) => {
|
|
32
|
+
const hasRelevantChanges = mutations.some(
|
|
33
|
+
(mutation) => Array.from(mutation.addedNodes).some((node) => {
|
|
34
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
35
|
+
const element = node;
|
|
36
|
+
return element.hasAttribute("data-flyo-uid") || element.querySelector("[data-flyo-uid]");
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
if (hasRelevantChanges) {
|
|
42
|
+
wireAll();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
observer.observe(document.body, {
|
|
46
|
+
childList: true,
|
|
47
|
+
subtree: true
|
|
48
|
+
});
|
|
49
|
+
return () => {
|
|
50
|
+
observer.disconnect();
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
54
|
+
}
|
|
55
|
+
function FlyoWysiwyg({
|
|
56
|
+
json,
|
|
57
|
+
components = {}
|
|
58
|
+
}) {
|
|
59
|
+
let nodes = [];
|
|
60
|
+
if (json) {
|
|
61
|
+
if (Array.isArray(json)) {
|
|
62
|
+
nodes = json;
|
|
63
|
+
} else if ("type" in json && json.type === "doc" && Array.isArray(json.content)) {
|
|
64
|
+
nodes = json.content;
|
|
65
|
+
} else {
|
|
66
|
+
nodes = [json];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return /* @__PURE__ */ jsx(Fragment, { children: nodes.map((node, index) => {
|
|
70
|
+
const Component = components[node.type];
|
|
71
|
+
if (Component) {
|
|
72
|
+
return /* @__PURE__ */ jsx(Component, { node }, index);
|
|
73
|
+
}
|
|
74
|
+
const html = wysiwyg(node);
|
|
75
|
+
return /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: html } }, index);
|
|
76
|
+
}) });
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
FlyoClientWrapper,
|
|
80
|
+
FlyoWysiwyg,
|
|
81
|
+
editable
|
|
82
|
+
};
|
|
2
83
|
//# sourceMappingURL=client.mjs.map
|
package/dist/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/client.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { highlightAndClick, wysiwyg, reload} from '@flyo/nitro-js-bridge';\nimport { Block } from \"@flyo/nitro-typescript\";\n\n/**\n * Type for WYSIWYG node structure\n */\ninterface WysiwygNode {\n type: string;\n content?: WysiwygNode[];\n [key: string]: unknown;\n}\n\n/**\n * Type for WYSIWYG JSON that can be a node, array of nodes, or doc structure\n */\ntype WysiwygJson = WysiwygNode | WysiwygNode[] | { type: 'doc'; content: WysiwygNode[] };\n\n/**\n * Helper function to get editable props\n */\nexport function editable(block: Block): { 'data-flyo-uid'?: string } {\n if (typeof block.uid === 'string' && block.uid.trim() !== '') {\n return { 'data-flyo-uid': block.uid };\n }\n return {};\n}\n\n/**\n * Internal client component that sets up live editing functionality\n */\nexport function FlyoClientWrapper({ \n children,\n}: { \n children: React.ReactNode;\n}) {\n useEffect(() => {\n if (typeof window === 'undefined') {\n return;\n }\n\n reload();\n\n const wireAll = () => {\n const elements = document.querySelectorAll('[data-flyo-uid]');\n elements.forEach((el) => {\n const uid = el.getAttribute('data-flyo-uid');\n if (uid && el instanceof HTMLElement) {\n highlightAndClick(uid, el);\n }\n });\n };\n\n wireAll();\n\n const observer = new MutationObserver((mutations) => {\n const hasRelevantChanges = mutations.some(mutation => \n Array.from(mutation.addedNodes).some(node => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const element = node as Element;\n return element.hasAttribute('data-flyo-uid') || \n element.querySelector('[data-flyo-uid]');\n }\n return false;\n })\n );\n\n if (hasRelevantChanges) {\n wireAll();\n }\n });\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n });\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return <>{children}</>;\n}\n\n/**\n * WYSIWYG component for rendering ProseMirror/TipTap JSON content\n * \n * @example\n * ```tsx\n * import { FlyoWysiwyg } from '@flyo/nitro-next/client';\n * import CustomImage from './CustomImage';\n * \n * export default function MyComponent({ block }) {\n * return (\n * <FlyoWysiwyg \n * json={block.content.json} \n * components={{\n * image: CustomImage\n * }} \n * />\n * );\n * }\n * ```\n */\nexport function FlyoWysiwyg({\n json,\n components = {},\n}: {\n json: WysiwygJson;\n components?: Record<string, React.ComponentType<{ node: WysiwygNode }>>;\n}) {\n let nodes: WysiwygNode[] = [];\n\n if (json) {\n if (Array.isArray(json)) {\n nodes = json;\n } else if ('type' in json && json.type === 'doc' && Array.isArray(json.content)) {\n nodes = json.content;\n } else {\n nodes = [json as WysiwygNode];\n }\n }\n\n return (\n <>\n {nodes.map((node: WysiwygNode, index: number) => {\n const Component = components[node.type];\n if (Component) {\n return <Component key={index} node={node} />;\n }\n \n const html = wysiwyg(node);\n return <div key={index} dangerouslySetInnerHTML={{ __html: html }} />;\n })}\n </>\n );\n}\n"],"mappings":";;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB,SAAS,cAAa;AAiFzC;AA7DF,SAAS,SAAS,OAA4C;AACnE,MAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,IAAI,KAAK,MAAM,IAAI;AAC5D,WAAO,EAAE,iBAAiB,MAAM,IAAI;AAAA,EACtC;AACA,SAAO,CAAC;AACV;AAKO,SAAS,kBAAkB;AAAA,EAChC;AACF,GAEG;AACD,YAAU,MAAM;AACd,QAAI,OAAO,WAAW,aAAa;AACjC;AAAA,IACF;AAEA,WAAO;AAEP,UAAM,UAAU,MAAM;AACpB,YAAM,WAAW,SAAS,iBAAiB,iBAAiB;AAC5D,eAAS,QAAQ,CAAC,OAAO;AACvB,cAAM,MAAM,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AAE,QAAQ,KAAK,KAA/C,KAAkD;AAAA,EACrE,CAAC,GACH;AAEJ;","names":[]}
|
package/dist/server.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { Configuration, ConfigResponse, PagesApi, EntitiesApi, Page, Block } from '@flyo/nitro-typescript';
|
|
3
3
|
|
|
4
4
|
declare const initNitro: ({ accessToken, lang, components }: {
|
|
5
5
|
accessToken: string;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { Configuration, ConfigResponse, PagesApi, EntitiesApi, Page, Block } from '@flyo/nitro-typescript';
|
|
3
3
|
|
|
4
4
|
declare const initNitro: ({ accessToken, lang, components }: {
|
|
5
5
|
accessToken: string;
|
package/dist/server.js
CHANGED
|
@@ -1,17 +1,112 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
19
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
// src/server.tsx
|
|
21
|
+
var server_exports = {};
|
|
22
|
+
__export(server_exports, {
|
|
23
|
+
NitroBlock: () => NitroBlock,
|
|
24
|
+
NitroPage: () => NitroPage,
|
|
25
|
+
getNitroConfig: () => getNitroConfig,
|
|
26
|
+
getNitroEntities: () => getNitroEntities,
|
|
27
|
+
getNitroPages: () => getNitroPages,
|
|
28
|
+
initNitro: () => initNitro
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(server_exports);
|
|
31
|
+
var import_nitro_typescript = require("@flyo/nitro-typescript");
|
|
32
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
var globalConfiguration = null;
|
|
34
|
+
var configResponse = null;
|
|
35
|
+
var configPromise = null;
|
|
36
|
+
var globalLang = null;
|
|
37
|
+
var globalComponents = {};
|
|
38
|
+
var initNitro = ({ accessToken, lang, components }) => {
|
|
39
|
+
if (!globalConfiguration) {
|
|
40
|
+
globalConfiguration = new import_nitro_typescript.Configuration({
|
|
41
|
+
apiKey: accessToken
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
globalLang = lang ?? null;
|
|
45
|
+
globalComponents = components ?? {};
|
|
46
|
+
return () => globalConfiguration;
|
|
47
|
+
};
|
|
48
|
+
async function getNitroConfig() {
|
|
49
|
+
console.log("\n[getNitroConfig] call");
|
|
50
|
+
if (configResponse) {
|
|
51
|
+
return configResponse;
|
|
52
|
+
}
|
|
53
|
+
if (configPromise) {
|
|
54
|
+
return configPromise;
|
|
55
|
+
}
|
|
56
|
+
const configApi = new import_nitro_typescript.ConfigApi(globalConfiguration);
|
|
57
|
+
const useLang = globalLang ?? void 0;
|
|
58
|
+
configPromise = configApi.config({ lang: useLang }).then((config) => {
|
|
59
|
+
configResponse = config;
|
|
60
|
+
return config;
|
|
61
|
+
}).finally(() => {
|
|
62
|
+
configPromise = null;
|
|
63
|
+
console.log("\n[getNitroConfig] fetched config");
|
|
64
|
+
});
|
|
65
|
+
return configPromise;
|
|
66
|
+
}
|
|
67
|
+
function getNitroPages() {
|
|
68
|
+
return new import_nitro_typescript.PagesApi(globalConfiguration);
|
|
69
|
+
}
|
|
70
|
+
function getNitroEntities() {
|
|
71
|
+
return new import_nitro_typescript.EntitiesApi(globalConfiguration);
|
|
72
|
+
}
|
|
73
|
+
function NitroPage({
|
|
74
|
+
page
|
|
75
|
+
}) {
|
|
76
|
+
if (!page?.json || !Array.isArray(page.json)) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: page.json.map((block, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
80
|
+
NitroBlock,
|
|
81
|
+
{
|
|
82
|
+
block
|
|
83
|
+
},
|
|
84
|
+
block.uid || index
|
|
85
|
+
)) });
|
|
86
|
+
}
|
|
87
|
+
function NitroBlock({
|
|
88
|
+
block
|
|
89
|
+
}) {
|
|
90
|
+
if (!block) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const Component = block.component ? globalComponents[block.component] : void 0;
|
|
94
|
+
if (Component) {
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { block });
|
|
96
|
+
}
|
|
97
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { border: "1px solid #fff", padding: "1rem", marginBottom: "1rem", backgroundColor: "red" }, children: [
|
|
98
|
+
"Component ",
|
|
99
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: block.component }),
|
|
100
|
+
" not found."
|
|
101
|
+
] });
|
|
102
|
+
}
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {
|
|
105
|
+
NitroBlock,
|
|
106
|
+
NitroPage,
|
|
107
|
+
getNitroConfig,
|
|
108
|
+
getNitroEntities,
|
|
109
|
+
getNitroPages,
|
|
110
|
+
initNitro
|
|
111
|
+
});
|
|
17
112
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/
|
|
1
|
+
{"version":3,"sources":["../src/server.tsx"],"sourcesContent":["import {\n Page,\n Block,\n ConfigApi,\n ConfigResponse,\n Configuration,\n PagesApi,\n EntitiesApi\n} from '@flyo/nitro-typescript';\n\nlet globalConfiguration: Configuration | null = null;\nlet configResponse: ConfigResponse | null = null;\nlet configPromise: Promise<ConfigResponse> | null = null;\nlet globalLang: string | null = null;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet globalComponents: Record<string, any> = {};\n\nexport const initNitro = ({accessToken, lang, components}: {accessToken: string, lang?: string, components?: object}): ( () => Configuration ) => {\n\n if (!globalConfiguration) {\n globalConfiguration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalLang = lang ?? null;\n globalComponents = components ?? {};\n\n return () => globalConfiguration!;\n}\n\nexport async function getNitroConfig(): Promise<ConfigResponse> {\n\n console.log('\\n[getNitroConfig] call');\n\n if (configResponse) {\n return configResponse;\n }\n\n if (configPromise) {\n return configPromise;\n }\n\n const configApi = new ConfigApi(globalConfiguration!);\n const useLang = globalLang ?? undefined;\n\n configPromise = configApi\n .config({ lang: useLang })\n .then((config) => {\n configResponse = config;\n return config;\n })\n .finally(() => {\n configPromise = null;\n console.log('\\n[getNitroConfig] fetched config');\n });\n\n return configPromise;\n}\n\nexport function getNitroPages(): PagesApi {\n return new PagesApi(globalConfiguration!);\n}\n\nexport function getNitroEntities(): EntitiesApi {\n return new EntitiesApi(globalConfiguration!);\n}\n\n\n/**\n * NitroPage component renders all blocks from a Flyo page\n */\nexport function NitroPage({\n page,\n}: {\n page: Page\n}) {\n if (!page?.json || !Array.isArray(page.json)) {\n return null;\n }\n\n return (\n <>\n {page.json.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n />\n ))}\n </>\n );\n}\n\nexport function NitroBlock({\n block,\n}: {\n block: Block\n}) {\n if (!block) {\n return null;\n }\n\n const Component = block.component ? globalComponents[block.component] : undefined;\n\n if (Component) {\n return <Component block={block} />;\n }\n\n return (\n <div style={{ border: '1px solid #fff', padding: '1rem', marginBottom: '1rem', backgroundColor: 'red' }}>\n Component <b>{block.component}</b> not found.\n </div>\n );\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAQO;AA0EH;AAxEJ,IAAI,sBAA4C;AAChD,IAAI,iBAAwC;AAC5C,IAAI,gBAAgD;AACpD,IAAI,aAA4B;AAEhC,IAAI,mBAAwC,CAAC;AAEtC,IAAM,YAAY,CAAC,EAAC,aAAa,MAAM,WAAU,MAA4F;AAEhJ,MAAI,CAAC,qBAAqB;AACxB,0BAAsB,IAAI,sCAAc;AAAA,MACtC,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,eAAa,QAAQ;AACrB,qBAAmB,cAAc,CAAC;AAElC,SAAO,MAAM;AACjB;AAEA,eAAsB,iBAA0C;AAE5D,UAAQ,IAAI,yBAAyB;AAErC,MAAI,gBAAgB;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,IAAI,kCAAU,mBAAoB;AACpD,QAAM,UAAU,cAAc;AAE9B,kBAAgB,UACb,OAAO,EAAE,MAAM,QAAQ,CAAC,EACxB,KAAK,CAAC,WAAW;AAChB,qBAAiB;AACjB,WAAO;AAAA,EACT,CAAC,EACA,QAAQ,MAAM;AACb,oBAAgB;AAChB,YAAQ,IAAI,mCAAmC;AAAA,EACjD,CAAC;AAEH,SAAO;AACX;AAEO,SAAS,gBAA0B;AACxC,SAAO,IAAI,iCAAS,mBAAoB;AAC1C;AAEO,SAAS,mBAAgC;AAC9C,SAAO,IAAI,oCAAY,mBAAoB;AAC7C;AAMO,SAAS,UAAU;AAAA,EACxB;AACF,GAEG;AACD,MAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,QAAQ,KAAK,IAAI,GAAG;AAC5C,WAAO;AAAA,EACT;AAEA,SACE,2EACG,eAAK,KAAK,IAAI,CAAC,OAAc,UAC5B;AAAA,IAAC;AAAA;AAAA,MAEC;AAAA;AAAA,IADK,MAAM,OAAO;AAAA,EAEpB,CACD,GACH;AAEJ;AAEO,SAAS,WAAW;AAAA,EACzB;AACF,GAEG;AACD,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,MAAM,YAAY,iBAAiB,MAAM,SAAS,IAAI;AAExE,MAAI,WAAW;AACb,WAAO,4CAAC,aAAU,OAAc;AAAA,EAClC;AAEA,SACE,6CAAC,SAAI,OAAO,EAAE,QAAQ,kBAAkB,SAAS,QAAQ,cAAc,QAAQ,iBAAiB,MAAM,GAAG;AAAA;AAAA,IAC7F,4CAAC,OAAG,gBAAM,WAAU;AAAA,IAAI;AAAA,KACpC;AAEJ;","names":[]}
|
package/dist/server.mjs
CHANGED
|
@@ -1,11 +1,81 @@
|
|
|
1
|
+
// src/server.tsx
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
ConfigApi,
|
|
4
|
+
Configuration,
|
|
5
|
+
PagesApi,
|
|
6
|
+
EntitiesApi
|
|
7
|
+
} from "@flyo/nitro-typescript";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var globalConfiguration = null;
|
|
10
|
+
var configResponse = null;
|
|
11
|
+
var configPromise = null;
|
|
12
|
+
var globalLang = null;
|
|
13
|
+
var globalComponents = {};
|
|
14
|
+
var initNitro = ({ accessToken, lang, components }) => {
|
|
15
|
+
if (!globalConfiguration) {
|
|
16
|
+
globalConfiguration = new Configuration({
|
|
17
|
+
apiKey: accessToken
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
globalLang = lang ?? null;
|
|
21
|
+
globalComponents = components ?? {};
|
|
22
|
+
return () => globalConfiguration;
|
|
23
|
+
};
|
|
24
|
+
async function getNitroConfig() {
|
|
25
|
+
console.log("\n[getNitroConfig] call");
|
|
26
|
+
if (configResponse) {
|
|
27
|
+
return configResponse;
|
|
28
|
+
}
|
|
29
|
+
if (configPromise) {
|
|
30
|
+
return configPromise;
|
|
31
|
+
}
|
|
32
|
+
const configApi = new ConfigApi(globalConfiguration);
|
|
33
|
+
const useLang = globalLang ?? void 0;
|
|
34
|
+
configPromise = configApi.config({ lang: useLang }).then((config) => {
|
|
35
|
+
configResponse = config;
|
|
36
|
+
return config;
|
|
37
|
+
}).finally(() => {
|
|
38
|
+
configPromise = null;
|
|
39
|
+
console.log("\n[getNitroConfig] fetched config");
|
|
40
|
+
});
|
|
41
|
+
return configPromise;
|
|
42
|
+
}
|
|
43
|
+
function getNitroPages() {
|
|
44
|
+
return new PagesApi(globalConfiguration);
|
|
45
|
+
}
|
|
46
|
+
function getNitroEntities() {
|
|
47
|
+
return new EntitiesApi(globalConfiguration);
|
|
48
|
+
}
|
|
49
|
+
function NitroPage({
|
|
50
|
+
page
|
|
51
|
+
}) {
|
|
52
|
+
if (!page?.json || !Array.isArray(page.json)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return /* @__PURE__ */ jsx(Fragment, { children: page.json.map((block, index) => /* @__PURE__ */ jsx(
|
|
56
|
+
NitroBlock,
|
|
57
|
+
{
|
|
58
|
+
block
|
|
59
|
+
},
|
|
60
|
+
block.uid || index
|
|
61
|
+
)) });
|
|
62
|
+
}
|
|
63
|
+
function NitroBlock({
|
|
64
|
+
block
|
|
65
|
+
}) {
|
|
66
|
+
if (!block) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const Component = block.component ? globalComponents[block.component] : void 0;
|
|
70
|
+
if (Component) {
|
|
71
|
+
return /* @__PURE__ */ jsx(Component, { block });
|
|
72
|
+
}
|
|
73
|
+
return /* @__PURE__ */ jsxs("div", { style: { border: "1px solid #fff", padding: "1rem", marginBottom: "1rem", backgroundColor: "red" }, children: [
|
|
74
|
+
"Component ",
|
|
75
|
+
/* @__PURE__ */ jsx("b", { children: block.component }),
|
|
76
|
+
" not found."
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
9
79
|
export {
|
|
10
80
|
NitroBlock,
|
|
11
81
|
NitroPage,
|
package/dist/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/server.tsx"],"sourcesContent":["import {\n Page,\n Block,\n ConfigApi,\n ConfigResponse,\n Configuration,\n PagesApi,\n EntitiesApi\n} from '@flyo/nitro-typescript';\n\nlet globalConfiguration: Configuration | null = null;\nlet configResponse: ConfigResponse | null = null;\nlet configPromise: Promise<ConfigResponse> | null = null;\nlet globalLang: string | null = null;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet globalComponents: Record<string, any> = {};\n\nexport const initNitro = ({accessToken, lang, components}: {accessToken: string, lang?: string, components?: object}): ( () => Configuration ) => {\n\n if (!globalConfiguration) {\n globalConfiguration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalLang = lang ?? null;\n globalComponents = components ?? {};\n\n return () => globalConfiguration!;\n}\n\nexport async function getNitroConfig(): Promise<ConfigResponse> {\n\n console.log('\\n[getNitroConfig] call');\n\n if (configResponse) {\n return configResponse;\n }\n\n if (configPromise) {\n return configPromise;\n }\n\n const configApi = new ConfigApi(globalConfiguration!);\n const useLang = globalLang ?? undefined;\n\n configPromise = configApi\n .config({ lang: useLang })\n .then((config) => {\n configResponse = config;\n return config;\n })\n .finally(() => {\n configPromise = null;\n console.log('\\n[getNitroConfig] fetched config');\n });\n\n return configPromise;\n}\n\nexport function getNitroPages(): PagesApi {\n return new PagesApi(globalConfiguration!);\n}\n\nexport function getNitroEntities(): EntitiesApi {\n return new EntitiesApi(globalConfiguration!);\n}\n\n\n/**\n * NitroPage component renders all blocks from a Flyo page\n */\nexport function NitroPage({\n page,\n}: {\n page: Page\n}) {\n if (!page?.json || !Array.isArray(page.json)) {\n return null;\n }\n\n return (\n <>\n {page.json.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n />\n ))}\n </>\n );\n}\n\nexport function NitroBlock({\n block,\n}: {\n block: Block\n}) {\n if (!block) {\n return null;\n }\n\n const Component = block.component ? globalComponents[block.component] : undefined;\n\n if (Component) {\n return <Component block={block} />;\n }\n\n return (\n <div style={{ border: '1px solid #fff', padding: '1rem', marginBottom: '1rem', backgroundColor: 'red' }}>\n Component <b>{block.component}</b> not found.\n </div>\n );\n}"],"mappings":";AAAA;AAAA,EAGE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0EH,mBAEI,KAyBJ,YA3BA;AAxEJ,IAAI,sBAA4C;AAChD,IAAI,iBAAwC;AAC5C,IAAI,gBAAgD;AACpD,IAAI,aAA4B;AAEhC,IAAI,mBAAwC,CAAC;AAEtC,IAAM,YAAY,CAAC,EAAC,aAAa,MAAM,WAAU,MAA4F;AAEhJ,MAAI,CAAC,qBAAqB;AACxB,0BAAsB,IAAI,cAAc;AAAA,MACtC,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,eAAa,QAAQ;AACrB,qBAAmB,cAAc,CAAC;AAElC,SAAO,MAAM;AACjB;AAEA,eAAsB,iBAA0C;AAE5D,UAAQ,IAAI,yBAAyB;AAErC,MAAI,gBAAgB;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,eAAe;AACjB,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Flyo Headless Content Hub into your Next.js project.",
|
|
5
5
|
"homepage": "https://dev.flyo.cloud/nitro",
|
|
6
6
|
"keywords": [
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
-
"types": "./dist/
|
|
26
|
-
"import": "./dist/
|
|
27
|
-
"require": "./dist/
|
|
28
|
-
},
|
|
29
|
-
"./client": {
|
|
30
|
-
"types": "./dist/client.d.ts",
|
|
31
|
-
"import": "./dist/client.mjs",
|
|
32
|
-
"require": "./dist/client.js"
|
|
25
|
+
"types": "./dist/server.d.ts",
|
|
26
|
+
"import": "./dist/server.mjs",
|
|
27
|
+
"require": "./dist/server.js"
|
|
33
28
|
},
|
|
34
29
|
"./server": {
|
|
35
30
|
"types": "./dist/server.d.ts",
|
|
36
31
|
"import": "./dist/server.mjs",
|
|
37
32
|
"require": "./dist/server.js"
|
|
33
|
+
},
|
|
34
|
+
"./client": {
|
|
35
|
+
"types": "./dist/client.d.ts",
|
|
36
|
+
"import": "./dist/client.mjs",
|
|
37
|
+
"require": "./dist/client.js"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
package/dist/chunk-JMEC5XWK.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/server.tsx
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _nitrotypescript = require('@flyo/nitro-typescript');
|
|
8
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
9
|
-
var globalConfiguration = null;
|
|
10
|
-
var configResponse = null;
|
|
11
|
-
var configPromise = null;
|
|
12
|
-
var globalLang = null;
|
|
13
|
-
var globalComponents = {};
|
|
14
|
-
var initNitro = ({ accessToken, lang, components }) => {
|
|
15
|
-
if (!globalConfiguration) {
|
|
16
|
-
globalConfiguration = new (0, _nitrotypescript.Configuration)({
|
|
17
|
-
apiKey: accessToken
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
globalLang = _nullishCoalesce(lang, () => ( null));
|
|
21
|
-
globalComponents = _nullishCoalesce(components, () => ( {}));
|
|
22
|
-
return () => globalConfiguration;
|
|
23
|
-
};
|
|
24
|
-
async function getNitroConfig() {
|
|
25
|
-
console.log("\n[getNitroConfig] call");
|
|
26
|
-
if (configResponse) {
|
|
27
|
-
return configResponse;
|
|
28
|
-
}
|
|
29
|
-
if (configPromise) {
|
|
30
|
-
return configPromise;
|
|
31
|
-
}
|
|
32
|
-
const configApi = new (0, _nitrotypescript.ConfigApi)(globalConfiguration);
|
|
33
|
-
const useLang = _nullishCoalesce(globalLang, () => ( void 0));
|
|
34
|
-
configPromise = configApi.config({ lang: useLang }).then((config) => {
|
|
35
|
-
configResponse = config;
|
|
36
|
-
return config;
|
|
37
|
-
}).finally(() => {
|
|
38
|
-
configPromise = null;
|
|
39
|
-
console.log("\n[getNitroConfig] fetched config");
|
|
40
|
-
});
|
|
41
|
-
return configPromise;
|
|
42
|
-
}
|
|
43
|
-
function getNitroPages() {
|
|
44
|
-
return new (0, _nitrotypescript.PagesApi)(globalConfiguration);
|
|
45
|
-
}
|
|
46
|
-
function getNitroEntities() {
|
|
47
|
-
return new (0, _nitrotypescript.EntitiesApi)(globalConfiguration);
|
|
48
|
-
}
|
|
49
|
-
function NitroPage({
|
|
50
|
-
page
|
|
51
|
-
}) {
|
|
52
|
-
if (!_optionalChain([page, 'optionalAccess', _ => _.json]) || !Array.isArray(page.json)) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: page.json.map((block, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
56
|
-
NitroBlock,
|
|
57
|
-
{
|
|
58
|
-
block
|
|
59
|
-
},
|
|
60
|
-
block.uid || index
|
|
61
|
-
)) });
|
|
62
|
-
}
|
|
63
|
-
function NitroBlock({
|
|
64
|
-
block
|
|
65
|
-
}) {
|
|
66
|
-
if (!block) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
const Component = block.component ? globalComponents[block.component] : void 0;
|
|
70
|
-
if (Component) {
|
|
71
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, { block });
|
|
72
|
-
}
|
|
73
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "pre", { children: JSON.stringify(block, null, 2) }) });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
exports.initNitro = initNitro; exports.getNitroConfig = getNitroConfig; exports.getNitroPages = getNitroPages; exports.getNitroEntities = getNitroEntities; exports.NitroPage = NitroPage; exports.NitroBlock = NitroBlock;
|
|
84
|
-
//# sourceMappingURL=chunk-JMEC5XWK.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/nitro-next/nitro-next/lib/dist/chunk-JMEC5XWK.js","../src/server.tsx"],"names":[],"mappings":"AAAA;ACAA;AAGE;AAEA;AACA;AACA;AAAA,yDACK;AA0EH,+CAAA;AAxEJ,IAAI,oBAAA,EAA4C,IAAA;AAChD,IAAI,eAAA,EAAwC,IAAA;AAC5C,IAAI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":"/home/runner/work/nitro-next/nitro-next/lib/dist/chunk-JMEC5XWK.js","sourcesContent":[null,"import {\n Page,\n Block,\n ConfigApi,\n ConfigResponse,\n Configuration,\n PagesApi,\n EntitiesApi\n} from '@flyo/nitro-typescript';\n\nlet globalConfiguration: Configuration | null = null;\nlet configResponse: ConfigResponse | null = null;\nlet configPromise: Promise<ConfigResponse> | null = null;\nlet globalLang: string | null = null;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet globalComponents: Record<string, any> = {};\n\nexport const initNitro = ({accessToken, lang, components}: {accessToken: string, lang?: string, components?: object}): ( () => Configuration ) => {\n\n if (!globalConfiguration) {\n globalConfiguration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalLang = lang ?? null;\n globalComponents = components ?? {};\n\n return () => globalConfiguration!;\n}\n\nexport async function getNitroConfig(): Promise<ConfigResponse> {\n\n console.log('\\n[getNitroConfig] call');\n\n if (configResponse) {\n return configResponse;\n }\n\n if (configPromise) {\n return configPromise;\n }\n\n const configApi = new ConfigApi(globalConfiguration!);\n const useLang = globalLang ?? undefined;\n\n configPromise = configApi\n .config({ lang: useLang })\n .then((config) => {\n configResponse = config;\n return config;\n })\n .finally(() => {\n configPromise = null;\n console.log('\\n[getNitroConfig] fetched config');\n });\n\n return configPromise;\n}\n\nexport function getNitroPages(): PagesApi {\n return new PagesApi(globalConfiguration!);\n}\n\nexport function getNitroEntities(): EntitiesApi {\n return new EntitiesApi(globalConfiguration!);\n}\n\n\n/**\n * NitroPage component renders all blocks from a Flyo page\n */\nexport function NitroPage({\n page,\n}: {\n page: Page\n}) {\n if (!page?.json || !Array.isArray(page.json)) {\n return null;\n }\n\n return (\n <>\n {page.json.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n />\n ))}\n </>\n );\n}\n\nexport function NitroBlock({\n block,\n}: {\n block: Block\n}) {\n if (!block) {\n return null;\n }\n\n const Component = block.component ? globalComponents[block.component] : undefined;\n\n if (Component) {\n return <Component block={block} />;\n }\n\n return (\n <div>\n {/* Render block content here */}\n <pre>{JSON.stringify(block, null, 2)}</pre>\n </div>\n );\n}"]}
|
package/dist/chunk-T46Q5G3T.mjs
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// src/server.tsx
|
|
2
|
-
import {
|
|
3
|
-
ConfigApi,
|
|
4
|
-
Configuration,
|
|
5
|
-
PagesApi,
|
|
6
|
-
EntitiesApi
|
|
7
|
-
} from "@flyo/nitro-typescript";
|
|
8
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
9
|
-
var globalConfiguration = null;
|
|
10
|
-
var configResponse = null;
|
|
11
|
-
var configPromise = null;
|
|
12
|
-
var globalLang = null;
|
|
13
|
-
var globalComponents = {};
|
|
14
|
-
var initNitro = ({ accessToken, lang, components }) => {
|
|
15
|
-
if (!globalConfiguration) {
|
|
16
|
-
globalConfiguration = new Configuration({
|
|
17
|
-
apiKey: accessToken
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
globalLang = lang ?? null;
|
|
21
|
-
globalComponents = components ?? {};
|
|
22
|
-
return () => globalConfiguration;
|
|
23
|
-
};
|
|
24
|
-
async function getNitroConfig() {
|
|
25
|
-
console.log("\n[getNitroConfig] call");
|
|
26
|
-
if (configResponse) {
|
|
27
|
-
return configResponse;
|
|
28
|
-
}
|
|
29
|
-
if (configPromise) {
|
|
30
|
-
return configPromise;
|
|
31
|
-
}
|
|
32
|
-
const configApi = new ConfigApi(globalConfiguration);
|
|
33
|
-
const useLang = globalLang ?? void 0;
|
|
34
|
-
configPromise = configApi.config({ lang: useLang }).then((config) => {
|
|
35
|
-
configResponse = config;
|
|
36
|
-
return config;
|
|
37
|
-
}).finally(() => {
|
|
38
|
-
configPromise = null;
|
|
39
|
-
console.log("\n[getNitroConfig] fetched config");
|
|
40
|
-
});
|
|
41
|
-
return configPromise;
|
|
42
|
-
}
|
|
43
|
-
function getNitroPages() {
|
|
44
|
-
return new PagesApi(globalConfiguration);
|
|
45
|
-
}
|
|
46
|
-
function getNitroEntities() {
|
|
47
|
-
return new EntitiesApi(globalConfiguration);
|
|
48
|
-
}
|
|
49
|
-
function NitroPage({
|
|
50
|
-
page
|
|
51
|
-
}) {
|
|
52
|
-
if (!page?.json || !Array.isArray(page.json)) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return /* @__PURE__ */ jsx(Fragment, { children: page.json.map((block, index) => /* @__PURE__ */ jsx(
|
|
56
|
-
NitroBlock,
|
|
57
|
-
{
|
|
58
|
-
block
|
|
59
|
-
},
|
|
60
|
-
block.uid || index
|
|
61
|
-
)) });
|
|
62
|
-
}
|
|
63
|
-
function NitroBlock({
|
|
64
|
-
block
|
|
65
|
-
}) {
|
|
66
|
-
if (!block) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
const Component = block.component ? globalComponents[block.component] : void 0;
|
|
70
|
-
if (Component) {
|
|
71
|
-
return /* @__PURE__ */ jsx(Component, { block });
|
|
72
|
-
}
|
|
73
|
-
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("pre", { children: JSON.stringify(block, null, 2) }) });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export {
|
|
77
|
-
initNitro,
|
|
78
|
-
getNitroConfig,
|
|
79
|
-
getNitroPages,
|
|
80
|
-
getNitroEntities,
|
|
81
|
-
NitroPage,
|
|
82
|
-
NitroBlock
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=chunk-T46Q5G3T.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.tsx"],"sourcesContent":["import {\n Page,\n Block,\n ConfigApi,\n ConfigResponse,\n Configuration,\n PagesApi,\n EntitiesApi\n} from '@flyo/nitro-typescript';\n\nlet globalConfiguration: Configuration | null = null;\nlet configResponse: ConfigResponse | null = null;\nlet configPromise: Promise<ConfigResponse> | null = null;\nlet globalLang: string | null = null;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet globalComponents: Record<string, any> = {};\n\nexport const initNitro = ({accessToken, lang, components}: {accessToken: string, lang?: string, components?: object}): ( () => Configuration ) => {\n\n if (!globalConfiguration) {\n globalConfiguration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalLang = lang ?? null;\n globalComponents = components ?? {};\n\n return () => globalConfiguration!;\n}\n\nexport async function getNitroConfig(): Promise<ConfigResponse> {\n\n console.log('\\n[getNitroConfig] call');\n\n if (configResponse) {\n return configResponse;\n }\n\n if (configPromise) {\n return configPromise;\n }\n\n const configApi = new ConfigApi(globalConfiguration!);\n const useLang = globalLang ?? undefined;\n\n configPromise = configApi\n .config({ lang: useLang })\n .then((config) => {\n configResponse = config;\n return config;\n })\n .finally(() => {\n configPromise = null;\n console.log('\\n[getNitroConfig] fetched config');\n });\n\n return configPromise;\n}\n\nexport function getNitroPages(): PagesApi {\n return new PagesApi(globalConfiguration!);\n}\n\nexport function getNitroEntities(): EntitiesApi {\n return new EntitiesApi(globalConfiguration!);\n}\n\n\n/**\n * NitroPage component renders all blocks from a Flyo page\n */\nexport function NitroPage({\n page,\n}: {\n page: Page\n}) {\n if (!page?.json || !Array.isArray(page.json)) {\n return null;\n }\n\n return (\n <>\n {page.json.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n />\n ))}\n </>\n );\n}\n\nexport function NitroBlock({\n block,\n}: {\n block: Block\n}) {\n if (!block) {\n return null;\n }\n\n const Component = block.component ? globalComponents[block.component] : undefined;\n\n if (Component) {\n return <Component block={block} />;\n }\n\n return (\n <div>\n {/* Render block content here */}\n <pre>{JSON.stringify(block, null, 2)}</pre>\n </div>\n );\n}"],"mappings":";AAAA;AAAA,EAGE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0EH,mBAEI,WAFJ;AAxEJ,IAAI,sBAA4C;AAChD,IAAI,iBAAwC;AAC5C,IAAI,gBAAgD;AACpD,IAAI,aAA4B;AAEhC,IAAI,mBAAwC,CAAC;AA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ClC;AAEA,SACE,oBAAC,SAEC,8BAAC,SAAK,eAAK,UAAU,OAAO,MAAM,CAAC,GAAE,GACvC;AAEJ;","names":[]}
|
package/dist/index.d.mts
DELETED
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkJMEC5XWKjs = require('./chunk-JMEC5XWK.js');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.NitroBlock = _chunkJMEC5XWKjs.NitroBlock; exports.NitroPage = _chunkJMEC5XWKjs.NitroPage; exports.getNitroConfig = _chunkJMEC5XWKjs.getNitroConfig; exports.getNitroEntities = _chunkJMEC5XWKjs.getNitroEntities; exports.getNitroPages = _chunkJMEC5XWKjs.getNitroPages; exports.initNitro = _chunkJMEC5XWKjs.initNitro;
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/nitro-next/nitro-next/lib/dist/index.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,iUAAC","file":"/home/runner/work/nitro-next/nitro-next/lib/dist/index.js"}
|
package/dist/index.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NitroBlock,
|
|
3
|
-
NitroPage,
|
|
4
|
-
getNitroConfig,
|
|
5
|
-
getNitroEntities,
|
|
6
|
-
getNitroPages,
|
|
7
|
-
initNitro
|
|
8
|
-
} from "./chunk-T46Q5G3T.mjs";
|
|
9
|
-
export {
|
|
10
|
-
NitroBlock,
|
|
11
|
-
NitroPage,
|
|
12
|
-
getNitroConfig,
|
|
13
|
-
getNitroEntities,
|
|
14
|
-
getNitroPages,
|
|
15
|
-
initNitro
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|