@flyo/nitro-next 1.0.2 → 1.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.
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +2 -1
- package/dist/client.mjs.map +1 -1
- package/dist/server.d.mts +2 -1
- package/dist/server.d.ts +2 -1
- package/dist/server.js +11 -6
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +11 -6
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { highlightAndClick, wysiwyg } 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 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;AAAA;AAEA,mBAA0B;AAC1B,
|
|
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;AAAA;AAEA,mBAA0B;AAC1B,6BAAkD;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,8BAAU,MAAM;AACd,QAAI,OAAO,WAAW,aAAa;AACjC;AAAA,IACF;AAEA,uCAAO;AAEP,UAAM,UAAU,MAAM;AACpB,YAAM,WAAW,SAAS,iBAAiB,iBAAiB;AAC5D,eAAS,QAAQ,CAAC,OAAO;AACvB,cAAM,MAAM,GAAG,aAAa,eAAe;AAC3C,YAAI,OAAO,cAAc,aAAa;AACpC,wDAAkB,KAAK,EAAE;AAAA,QAC3B;AAAA,MACF,CAAC;AAAA,IACH;AAEA,YAAQ;AAER,UAAM,WAAW,IAAI,iBAAiB,CAAC,cAAc;AACnD,YAAM,qBAAqB,UAAU;AAAA,QAAK,cACxC,MAAM,KAAK,SAAS,UAAU,EAAE,KAAK,UAAQ;AAC3C,cAAI,KAAK,aAAa,KAAK,cAAc;AACvC,kBAAM,UAAU;AAChB,mBAAO,QAAQ,aAAa,eAAe,KACpC,QAAQ,cAAc,iBAAiB;AAAA,UAChD;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAEA,UAAI,oBAAoB;AACtB,gBAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAED,aAAS,QAAQ,SAAS,MAAM;AAAA,MAC9B,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAED,WAAO,MAAM;AACX,eAAS,WAAW;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO,2EAAG,UAAS;AACrB;AAsBO,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA,aAAa,CAAC;AAChB,GAGG;AACD,MAAI,QAAuB,CAAC;AAE5B,MAAI,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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/client.tsx
|
|
4
4
|
import { useEffect } from "react";
|
|
5
|
-
import { highlightAndClick, wysiwyg } from "@flyo/nitro-js-bridge";
|
|
5
|
+
import { highlightAndClick, wysiwyg, reload } from "@flyo/nitro-js-bridge";
|
|
6
6
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
7
7
|
function editable(block) {
|
|
8
8
|
if (typeof block.uid === "string" && block.uid.trim() !== "") {
|
|
@@ -17,6 +17,7 @@ function FlyoClientWrapper({
|
|
|
17
17
|
if (typeof window === "undefined") {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
+
reload();
|
|
20
21
|
const wireAll = () => {
|
|
21
22
|
const elements = document.querySelectorAll("[data-flyo-uid]");
|
|
22
23
|
elements.forEach((el) => {
|
package/dist/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { highlightAndClick, wysiwyg } 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 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,
|
|
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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B,GAGG;AACD,MAAI,QAAuB,CAAC;AAE5B,MAAI,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,gCACG,gBAAM,IAAI,CAAC,MAAmB,UAAkB;AAC/C,UAAM,YAAY,WAAW,KAAK,IAAI;AACtC,QAAI,WAAW;AACb,aAAO,oBAAC,aAAsB,QAAP,KAAmB;AAAA,IAC5C;AAEA,UAAM,OAAO,QAAQ,IAAI;AACzB,WAAO,oBAAC,SAAgB,yBAAyB,EAAE,QAAQ,KAAK,KAA/C,KAAkD;AAAA,EACrE,CAAC,GACH;AAEJ;","names":[]}
|
package/dist/server.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Configuration, ConfigResponse, PagesApi, EntitiesApi, Page, Block } from '@flyo/nitro-typescript';
|
|
3
3
|
|
|
4
|
-
declare const initNitro: ({ accessToken, lang, components }: {
|
|
4
|
+
declare const initNitro: ({ accessToken, lang, components, showMissingComponentAlert }: {
|
|
5
5
|
accessToken: string;
|
|
6
6
|
lang?: string;
|
|
7
7
|
components?: object;
|
|
8
|
+
showMissingComponentAlert?: boolean;
|
|
8
9
|
}) => (() => Configuration);
|
|
9
10
|
declare function getNitroConfig(): Promise<ConfigResponse>;
|
|
10
11
|
declare function getNitroPages(): PagesApi;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Configuration, ConfigResponse, PagesApi, EntitiesApi, Page, Block } from '@flyo/nitro-typescript';
|
|
3
3
|
|
|
4
|
-
declare const initNitro: ({ accessToken, lang, components }: {
|
|
4
|
+
declare const initNitro: ({ accessToken, lang, components, showMissingComponentAlert }: {
|
|
5
5
|
accessToken: string;
|
|
6
6
|
lang?: string;
|
|
7
7
|
components?: object;
|
|
8
|
+
showMissingComponentAlert?: boolean;
|
|
8
9
|
}) => (() => Configuration);
|
|
9
10
|
declare function getNitroConfig(): Promise<ConfigResponse>;
|
|
10
11
|
declare function getNitroPages(): PagesApi;
|
package/dist/server.js
CHANGED
|
@@ -35,7 +35,8 @@ var configResponse = null;
|
|
|
35
35
|
var configPromise = null;
|
|
36
36
|
var globalLang = null;
|
|
37
37
|
var globalComponents = {};
|
|
38
|
-
var
|
|
38
|
+
var globalShowMissingComponentAlert = false;
|
|
39
|
+
var initNitro = ({ accessToken, lang, components, showMissingComponentAlert }) => {
|
|
39
40
|
if (!globalConfiguration) {
|
|
40
41
|
globalConfiguration = new import_nitro_typescript.Configuration({
|
|
41
42
|
apiKey: accessToken
|
|
@@ -43,6 +44,7 @@ var initNitro = ({ accessToken, lang, components }) => {
|
|
|
43
44
|
}
|
|
44
45
|
globalLang = lang ?? null;
|
|
45
46
|
globalComponents = components ?? {};
|
|
47
|
+
globalShowMissingComponentAlert = showMissingComponentAlert ?? false;
|
|
46
48
|
return () => globalConfiguration;
|
|
47
49
|
};
|
|
48
50
|
async function getNitroConfig() {
|
|
@@ -94,11 +96,14 @@ function NitroBlock({
|
|
|
94
96
|
if (Component) {
|
|
95
97
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { block });
|
|
96
98
|
}
|
|
97
|
-
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
if (globalShowMissingComponentAlert) {
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { border: "1px solid #fff", padding: "1rem", marginBottom: "1rem", backgroundColor: "red" }, children: [
|
|
101
|
+
"Component ",
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: block.component }),
|
|
103
|
+
" not found."
|
|
104
|
+
] });
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
102
107
|
}
|
|
103
108
|
// Annotate the CommonJS export names for ESM import in node:
|
|
104
109
|
0 && (module.exports = {
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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> = {};\nlet globalShowMissingComponentAlert: boolean = false;\n\nexport const initNitro = ({accessToken, lang, components, showMissingComponentAlert}: {accessToken: string, lang?: string, components?: object, showMissingComponentAlert?: boolean}): ( () => Configuration ) => {\n\n if (!globalConfiguration) {\n globalConfiguration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalLang = lang ?? null;\n globalComponents = components ?? {};\n globalShowMissingComponentAlert = showMissingComponentAlert ?? false;\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 if (globalShowMissingComponentAlert) {\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 }\n\n return null;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAQO;AA4EH;AA1EJ,IAAI,sBAA4C;AAChD,IAAI,iBAAwC;AAC5C,IAAI,gBAAgD;AACpD,IAAI,aAA4B;AAEhC,IAAI,mBAAwC,CAAC;AAC7C,IAAI,kCAA2C;AAExC,IAAM,YAAY,CAAC,EAAC,aAAa,MAAM,YAAY,0BAAyB,MAAiI;AAEhN,MAAI,CAAC,qBAAqB;AACxB,0BAAsB,IAAI,sCAAc;AAAA,MACtC,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,eAAa,QAAQ;AACrB,qBAAmB,cAAc,CAAC;AAClC,oCAAkC,6BAA6B;AAE/D,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,MAAI,iCAAiC;AACnC,WACE,6CAAC,SAAI,OAAO,EAAE,QAAQ,kBAAkB,SAAS,QAAQ,cAAc,QAAQ,iBAAiB,MAAM,GAAG;AAAA;AAAA,MAC7F,4CAAC,OAAG,gBAAM,WAAU;AAAA,MAAI;AAAA,OACpC;AAAA,EAEJ;AAEA,SAAO;AACT;","names":[]}
|
package/dist/server.mjs
CHANGED
|
@@ -11,7 +11,8 @@ var configResponse = null;
|
|
|
11
11
|
var configPromise = null;
|
|
12
12
|
var globalLang = null;
|
|
13
13
|
var globalComponents = {};
|
|
14
|
-
var
|
|
14
|
+
var globalShowMissingComponentAlert = false;
|
|
15
|
+
var initNitro = ({ accessToken, lang, components, showMissingComponentAlert }) => {
|
|
15
16
|
if (!globalConfiguration) {
|
|
16
17
|
globalConfiguration = new Configuration({
|
|
17
18
|
apiKey: accessToken
|
|
@@ -19,6 +20,7 @@ var initNitro = ({ accessToken, lang, components }) => {
|
|
|
19
20
|
}
|
|
20
21
|
globalLang = lang ?? null;
|
|
21
22
|
globalComponents = components ?? {};
|
|
23
|
+
globalShowMissingComponentAlert = showMissingComponentAlert ?? false;
|
|
22
24
|
return () => globalConfiguration;
|
|
23
25
|
};
|
|
24
26
|
async function getNitroConfig() {
|
|
@@ -70,11 +72,14 @@ function NitroBlock({
|
|
|
70
72
|
if (Component) {
|
|
71
73
|
return /* @__PURE__ */ jsx(Component, { block });
|
|
72
74
|
}
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
if (globalShowMissingComponentAlert) {
|
|
76
|
+
return /* @__PURE__ */ jsxs("div", { style: { border: "1px solid #fff", padding: "1rem", marginBottom: "1rem", backgroundColor: "red" }, children: [
|
|
77
|
+
"Component ",
|
|
78
|
+
/* @__PURE__ */ jsx("b", { children: block.component }),
|
|
79
|
+
" not found."
|
|
80
|
+
] });
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
78
83
|
}
|
|
79
84
|
export {
|
|
80
85
|
NitroBlock,
|
package/dist/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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> = {};\nlet globalShowMissingComponentAlert: boolean = false;\n\nexport const initNitro = ({accessToken, lang, components, showMissingComponentAlert}: {accessToken: string, lang?: string, components?: object, showMissingComponentAlert?: boolean}): ( () => Configuration ) => {\n\n if (!globalConfiguration) {\n globalConfiguration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalLang = lang ?? null;\n globalComponents = components ?? {};\n globalShowMissingComponentAlert = showMissingComponentAlert ?? false;\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 if (globalShowMissingComponentAlert) {\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 }\n\n return null;\n}"],"mappings":";AAAA;AAAA,EAGE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA4EH,mBAEI,KA0BF,YA5BF;AA1EJ,IAAI,sBAA4C;AAChD,IAAI,iBAAwC;AAC5C,IAAI,gBAAgD;AACpD,IAAI,aAA4B;AAEhC,IAAI,mBAAwC,CA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