@flyo/nitro-next 1.0.4 → 1.1.0
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/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +5 -19
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +5 -19
- package/dist/server.mjs.map +1 -1
- package/package.json +6 -6
package/dist/server.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ declare const initNitro: ({ accessToken, lang, components, showMissingComponentA
|
|
|
7
7
|
components?: object;
|
|
8
8
|
showMissingComponentAlert?: boolean;
|
|
9
9
|
}) => (() => Configuration);
|
|
10
|
-
declare
|
|
10
|
+
declare const getNitroConfig: () => Promise<ConfigResponse>;
|
|
11
11
|
declare function getNitroPages(): PagesApi;
|
|
12
12
|
declare function getNitroEntities(): EntitiesApi;
|
|
13
13
|
/**
|
package/dist/server.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare const initNitro: ({ accessToken, lang, components, showMissingComponentA
|
|
|
7
7
|
components?: object;
|
|
8
8
|
showMissingComponentAlert?: boolean;
|
|
9
9
|
}) => (() => Configuration);
|
|
10
|
-
declare
|
|
10
|
+
declare const getNitroConfig: () => Promise<ConfigResponse>;
|
|
11
11
|
declare function getNitroPages(): PagesApi;
|
|
12
12
|
declare function getNitroEntities(): EntitiesApi;
|
|
13
13
|
/**
|
package/dist/server.js
CHANGED
|
@@ -28,11 +28,10 @@ __export(server_exports, {
|
|
|
28
28
|
initNitro: () => initNitro
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(server_exports);
|
|
31
|
+
var import_react = require("react");
|
|
31
32
|
var import_nitro_typescript = require("@flyo/nitro-typescript");
|
|
32
33
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
34
|
var globalConfiguration = null;
|
|
34
|
-
var configResponse = null;
|
|
35
|
-
var configPromise = null;
|
|
36
35
|
var globalLang = null;
|
|
37
36
|
var globalComponents = {};
|
|
38
37
|
var globalShowMissingComponentAlert = false;
|
|
@@ -47,25 +46,12 @@ var initNitro = ({ accessToken, lang, components, showMissingComponentAlert }) =
|
|
|
47
46
|
globalShowMissingComponentAlert = showMissingComponentAlert ?? false;
|
|
48
47
|
return () => globalConfiguration;
|
|
49
48
|
};
|
|
50
|
-
|
|
51
|
-
console.log("\n[getNitroConfig] call");
|
|
52
|
-
if (configResponse) {
|
|
53
|
-
return configResponse;
|
|
54
|
-
}
|
|
55
|
-
if (configPromise) {
|
|
56
|
-
return configPromise;
|
|
57
|
-
}
|
|
49
|
+
var getNitroConfig = (0, import_react.cache)(async () => {
|
|
58
50
|
const configApi = new import_nitro_typescript.ConfigApi(globalConfiguration);
|
|
59
51
|
const useLang = globalLang ?? void 0;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}).finally(() => {
|
|
64
|
-
configPromise = null;
|
|
65
|
-
console.log("\n[getNitroConfig] fetched config");
|
|
66
|
-
});
|
|
67
|
-
return configPromise;
|
|
68
|
-
}
|
|
52
|
+
const config = await configApi.config({ lang: useLang });
|
|
53
|
+
return config;
|
|
54
|
+
});
|
|
69
55
|
function getNitroPages() {
|
|
70
56
|
return new import_nitro_typescript.PagesApi(globalConfiguration);
|
|
71
57
|
}
|
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
|
|
1
|
+
{"version":3,"sources":["../src/server.tsx"],"sourcesContent":["import { cache } from 'react';\nimport {\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 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 const getNitroConfig = cache(async (): Promise<ConfigResponse> => {\n\n const configApi = new ConfigApi(globalConfiguration!);\n const useLang = globalLang ?? undefined;\n\n const config = await configApi.config({ lang: useLang });\n \n return config;\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,mBAAsB;AACtB,8BAQO;AAuDH;AArDJ,IAAI,sBAA4C;AAChD,IAAI,aAA4B;AAEhC,IAAI,mBAAwC,CAAC;AAC7C,IAAI,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AAAA,OACpC;AAAA,EAEJ;AAEA,SAAO;AACT;","names":[]}
|
package/dist/server.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/server.tsx
|
|
2
|
+
import { cache } from "react";
|
|
2
3
|
import {
|
|
3
4
|
ConfigApi,
|
|
4
5
|
Configuration,
|
|
@@ -7,8 +8,6 @@ import {
|
|
|
7
8
|
} from "@flyo/nitro-typescript";
|
|
8
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
var globalConfiguration = null;
|
|
10
|
-
var configResponse = null;
|
|
11
|
-
var configPromise = null;
|
|
12
11
|
var globalLang = null;
|
|
13
12
|
var globalComponents = {};
|
|
14
13
|
var globalShowMissingComponentAlert = false;
|
|
@@ -23,25 +22,12 @@ var initNitro = ({ accessToken, lang, components, showMissingComponentAlert }) =
|
|
|
23
22
|
globalShowMissingComponentAlert = showMissingComponentAlert ?? false;
|
|
24
23
|
return () => globalConfiguration;
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
console.log("\n[getNitroConfig] call");
|
|
28
|
-
if (configResponse) {
|
|
29
|
-
return configResponse;
|
|
30
|
-
}
|
|
31
|
-
if (configPromise) {
|
|
32
|
-
return configPromise;
|
|
33
|
-
}
|
|
25
|
+
var getNitroConfig = cache(async () => {
|
|
34
26
|
const configApi = new ConfigApi(globalConfiguration);
|
|
35
27
|
const useLang = globalLang ?? void 0;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}).finally(() => {
|
|
40
|
-
configPromise = null;
|
|
41
|
-
console.log("\n[getNitroConfig] fetched config");
|
|
42
|
-
});
|
|
43
|
-
return configPromise;
|
|
44
|
-
}
|
|
28
|
+
const config = await configApi.config({ lang: useLang });
|
|
29
|
+
return config;
|
|
30
|
+
});
|
|
45
31
|
function getNitroPages() {
|
|
46
32
|
return new PagesApi(globalConfiguration);
|
|
47
33
|
}
|
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
|
|
1
|
+
{"version":3,"sources":["../src/server.tsx"],"sourcesContent":["import { cache } from 'react';\nimport {\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 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 const getNitroConfig = cache(async (): Promise<ConfigResponse> => {\n\n const configApi = new ConfigApi(globalConfiguration!);\n const useLang = globalLang ?? undefined;\n\n const config = await configApi.config({ lang: useLang });\n \n return config;\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,SAAS,aAAa;AACtB;AAAA,EAGE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAuDH,mBAEI,KA0BF,YA5BF;AArDJ,IAAI,sBAA4C;AAChD,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,cAAc;AAAA,MACtC,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,eAAa,QAAQ;AACrB,qBAAmB,cAAc,CAAC;AAClC,oCAAkC,6BAA6B;AAE/D,SAAO,MAAM;AACjB;AAEO,IAAM,iBAAiB,MAAM,YAAqC;AAErE,QAAM,YAAY,IAAI,UAAU,mBAAoB;AACpD,QAAM,UAAU,cAAc;AAE9B,QAAM,SAAS,MAAM,UAAU,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEvD,SAAO;AACX,CAAC;AAEM,SAAS,gBAA0B;AACxC,SAAO,IAAI,SAAS,mBAAoB;AAC1C;AAEO,SAAS,mBAAgC;AAC9C,SAAO,IAAI,YAAY,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,gCACG,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,oBAAC,aAAU,OAAc;AAAA,EAClC;AAEA,MAAI,iCAAiC;AACnC,WACE,qBAAC,SAAI,OAAO,EAAE,QAAQ,kBAAkB,SAAS,QAAQ,cAAc,QAAQ,iBAAiB,MAAM,GAAG;AAAA;AAAA,MAC7F,oBAAC,OAAG,gBAAM,WAAU;AAAA,MAAI;AAAA,OACpC;AAAA,EAEJ;AAEA,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flyo/nitro-next",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Connecting Flyo Headless Content Hub into your Next.js project.",
|
|
5
5
|
"homepage": "https://dev.flyo.cloud/nitro",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"test": "jest",
|
|
19
19
|
"test:watch": "jest --watch",
|
|
20
20
|
"test:coverage": "jest --coverage",
|
|
21
|
-
"lint": "eslint src"
|
|
21
|
+
"lint": "eslint src *.js"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"next": ">=16.0.4",
|
|
49
|
-
"react": "
|
|
50
|
-
"react-dom": "
|
|
49
|
+
"react": "^19.2.1",
|
|
50
|
+
"react-dom": "^19.2.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@testing-library/jest-dom": "^6.1.5",
|
|
54
54
|
"@testing-library/react": "^14.1.2",
|
|
55
55
|
"@types/jest": "^29.5.11",
|
|
56
56
|
"@types/node": "^20.10.0",
|
|
57
|
-
"@types/react": "^
|
|
58
|
-
"@types/react-dom": "^
|
|
57
|
+
"@types/react": "^19.2.1",
|
|
58
|
+
"@types/react-dom": "^19.2.1",
|
|
59
59
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
60
60
|
"@typescript-eslint/parser": "^7.18.0",
|
|
61
61
|
"eslint": "^8.57.1",
|