dn-react-router-toolkit 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ declare function ClientEnv({ dataKey }: {
4
+ dataKey?: string;
5
+ }): React.JSX.Element;
6
+
7
+ export { ClientEnv as default };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ declare function ClientEnv({ dataKey }: {
4
+ dataKey?: string;
5
+ }): React.JSX.Element;
6
+
7
+ export { ClientEnv as default };
@@ -27,42 +27,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/seo-kit/seo_loader.tsx
31
- var seo_loader_exports = {};
32
- __export(seo_loader_exports, {
33
- createSEOLoader: () => createSEOLoader
30
+ // src/components/client_env.tsx
31
+ var client_env_exports = {};
32
+ __export(client_env_exports, {
33
+ default: () => ClientEnv
34
34
  });
35
- module.exports = __toCommonJS(seo_loader_exports);
36
-
37
- // src/seo-kit/loader.ts
38
- function createLoader(fn = () => ({})) {
39
- let loadedData;
40
- return {
41
- getData() {
42
- return loadedData;
43
- },
44
- wrap(mapper) {
45
- return async function Thing(props) {
46
- loadedData = await fn(props);
47
- return mapper(loadedData);
48
- };
49
- }
50
- };
51
- }
52
-
53
- // src/seo-kit/seo_loader.tsx
35
+ module.exports = __toCommonJS(client_env_exports);
54
36
  var import_react = __toESM(require("react"));
55
- function createSEOLoader(fn = () => ({})) {
56
- const loader = createLoader(fn);
57
- return {
58
- ...loader,
59
- meta: loader.wrap((data) => data.seo.meta),
60
- Page(Fc) {
61
- return loader.wrap((data) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, data.seo?.generateJSONLD(), /* @__PURE__ */ import_react.default.createElement(Fc, { ...data })));
37
+ var import_react_router = require("react-router");
38
+ function ClientEnv({ dataKey = "ENV" }) {
39
+ const data = (0, import_react_router.useRouteLoaderData)("root");
40
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, data && /* @__PURE__ */ import_react.default.createElement(
41
+ "script",
42
+ {
43
+ dangerouslySetInnerHTML: {
44
+ __html: `window.process = ${JSON.stringify({
45
+ env: data?.[dataKey]
46
+ })}`
47
+ }
62
48
  }
63
- };
49
+ ));
64
50
  }
65
- // Annotate the CommonJS export names for ESM import in node:
66
- 0 && (module.exports = {
67
- createSEOLoader
68
- });
@@ -0,0 +1,19 @@
1
+ // src/components/client_env.tsx
2
+ import React from "react";
3
+ import { useRouteLoaderData } from "react-router";
4
+ function ClientEnv({ dataKey = "ENV" }) {
5
+ const data = useRouteLoaderData("root");
6
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, data && /* @__PURE__ */ React.createElement(
7
+ "script",
8
+ {
9
+ dangerouslySetInnerHTML: {
10
+ __html: `window.process = ${JSON.stringify({
11
+ env: data?.[dataKey]
12
+ })}`
13
+ }
14
+ }
15
+ ));
16
+ }
17
+ export {
18
+ ClientEnv as default
19
+ };
@@ -1,5 +1,5 @@
1
- import * as Schema from 'schema-dts';
2
1
  import React from 'react';
2
+ import * as Schema from 'schema-dts';
3
3
  import { MetaFunction } from 'react-router';
4
4
 
5
5
  type SEOImage = {
@@ -15,8 +15,8 @@ declare function configSEO(config: {
15
15
  siteName: string;
16
16
  description: string;
17
17
  keywords?: string[];
18
- thumbnail?: SEOImage | (() => SEOImage | null | Promise<SEOImage | null>);
19
- structedData?: Schema.Thing[] | (() => Schema.Thing[] | Promise<Schema.Thing[]>);
18
+ thumbnail?: SEOImage | (() => SEOImage | null);
19
+ structedData?: Schema.Thing[] | (() => Schema.Thing[]);
20
20
  copyright?: string;
21
21
  }): {
22
22
  config: {
@@ -24,26 +24,26 @@ declare function configSEO(config: {
24
24
  siteName: string;
25
25
  description: string;
26
26
  keywords?: string[];
27
- thumbnail?: SEOImage | (() => SEOImage | null | Promise<SEOImage | null>);
28
- structedData?: Schema.Thing[] | (() => Schema.Thing[] | Promise<Schema.Thing[]>);
27
+ thumbnail?: SEOImage | (() => SEOImage | null);
28
+ structedData?: Schema.Thing[] | (() => Schema.Thing[]);
29
29
  copyright?: string;
30
30
  };
31
- init(props?: {
31
+ init: (props: {
32
32
  title?: string;
33
33
  description?: string;
34
34
  keywords?: string[];
35
35
  path?: string;
36
36
  type?: string;
37
- canonicalPath?: string;
37
+ canonicalPath: string;
38
38
  breadcrumbs?: {
39
- label: string;
39
+ title: string;
40
40
  href: string;
41
41
  }[];
42
42
  thumbnail?: SEOImage;
43
43
  images?: SEOImage[];
44
44
  updatedAt?: Date;
45
45
  createdAt?: Date;
46
- structedData?: Schema.Thing[] | (() => Schema.Thing[] | Promise<Schema.Thing[]>);
46
+ structedData?: Schema.Thing[] | (() => Schema.Thing[]);
47
47
  article?: boolean;
48
48
  blogPosting?: boolean;
49
49
  creativeWork?: boolean;
@@ -56,48 +56,16 @@ declare function configSEO(config: {
56
56
  updatedAt?: Date;
57
57
  createdAt?: Date;
58
58
  }[];
59
- }): Promise<{
60
- config: {
61
- origin: string;
62
- siteName: string;
63
- description: string;
64
- keywords?: string[];
65
- thumbnail?: SEOImage | (() => SEOImage | null | Promise<SEOImage | null>);
66
- structedData?: Schema.Thing[] | (() => Schema.Thing[] | Promise<Schema.Thing[]>);
67
- copyright?: string;
68
- };
69
- props: {
70
- title?: string;
71
- description?: string;
72
- keywords?: string[];
73
- path?: string;
74
- type?: string;
75
- canonicalPath?: string;
76
- breadcrumbs?: {
77
- label: string;
78
- href: string;
79
- }[];
80
- thumbnail?: SEOImage;
81
- images?: SEOImage[];
82
- updatedAt?: Date;
83
- createdAt?: Date;
84
- structedData?: Schema.Thing[] | (() => Schema.Thing[] | Promise<Schema.Thing[]>);
85
- article?: boolean;
86
- blogPosting?: boolean;
87
- creativeWork?: boolean;
88
- visualArtwork?: boolean;
89
- collection?: {
90
- title: string;
91
- url: string;
92
- description?: string;
93
- thumbnail?: SEOImage;
94
- updatedAt?: Date;
95
- createdAt?: Date;
96
- }[];
97
- };
98
- meta: MetaFunction<unknown, Record<string, unknown>>;
99
- generateJSONLD: () => React.JSX.Element;
100
- }>;
59
+ }) => {
60
+ pageTitle: string;
61
+ type: string | undefined;
62
+ description: string;
63
+ keywords: string[] | undefined;
64
+ url: string;
65
+ thumbnail: SEOImage | null | undefined;
66
+ };
67
+ meta: MetaFunction<unknown, Record<string, unknown>>;
68
+ StructedData: () => React.JSX.Element;
101
69
  };
102
70
 
103
71
  export { type SEO, type SEOImage, configSEO };
@@ -1,5 +1,5 @@
1
- import * as Schema from 'schema-dts';
2
1
  import React from 'react';
2
+ import * as Schema from 'schema-dts';
3
3
  import { MetaFunction } from 'react-router';
4
4
 
5
5
  type SEOImage = {
@@ -15,8 +15,8 @@ declare function configSEO(config: {
15
15
  siteName: string;
16
16
  description: string;
17
17
  keywords?: string[];
18
- thumbnail?: SEOImage | (() => SEOImage | null | Promise<SEOImage | null>);
19
- structedData?: Schema.Thing[] | (() => Schema.Thing[] | Promise<Schema.Thing[]>);
18
+ thumbnail?: SEOImage | (() => SEOImage | null);
19
+ structedData?: Schema.Thing[] | (() => Schema.Thing[]);
20
20
  copyright?: string;
21
21
  }): {
22
22
  config: {
@@ -24,26 +24,26 @@ declare function configSEO(config: {
24
24
  siteName: string;
25
25
  description: string;
26
26
  keywords?: string[];
27
- thumbnail?: SEOImage | (() => SEOImage | null | Promise<SEOImage | null>);
28
- structedData?: Schema.Thing[] | (() => Schema.Thing[] | Promise<Schema.Thing[]>);
27
+ thumbnail?: SEOImage | (() => SEOImage | null);
28
+ structedData?: Schema.Thing[] | (() => Schema.Thing[]);
29
29
  copyright?: string;
30
30
  };
31
- init(props?: {
31
+ init: (props: {
32
32
  title?: string;
33
33
  description?: string;
34
34
  keywords?: string[];
35
35
  path?: string;
36
36
  type?: string;
37
- canonicalPath?: string;
37
+ canonicalPath: string;
38
38
  breadcrumbs?: {
39
- label: string;
39
+ title: string;
40
40
  href: string;
41
41
  }[];
42
42
  thumbnail?: SEOImage;
43
43
  images?: SEOImage[];
44
44
  updatedAt?: Date;
45
45
  createdAt?: Date;
46
- structedData?: Schema.Thing[] | (() => Schema.Thing[] | Promise<Schema.Thing[]>);
46
+ structedData?: Schema.Thing[] | (() => Schema.Thing[]);
47
47
  article?: boolean;
48
48
  blogPosting?: boolean;
49
49
  creativeWork?: boolean;
@@ -56,48 +56,16 @@ declare function configSEO(config: {
56
56
  updatedAt?: Date;
57
57
  createdAt?: Date;
58
58
  }[];
59
- }): Promise<{
60
- config: {
61
- origin: string;
62
- siteName: string;
63
- description: string;
64
- keywords?: string[];
65
- thumbnail?: SEOImage | (() => SEOImage | null | Promise<SEOImage | null>);
66
- structedData?: Schema.Thing[] | (() => Schema.Thing[] | Promise<Schema.Thing[]>);
67
- copyright?: string;
68
- };
69
- props: {
70
- title?: string;
71
- description?: string;
72
- keywords?: string[];
73
- path?: string;
74
- type?: string;
75
- canonicalPath?: string;
76
- breadcrumbs?: {
77
- label: string;
78
- href: string;
79
- }[];
80
- thumbnail?: SEOImage;
81
- images?: SEOImage[];
82
- updatedAt?: Date;
83
- createdAt?: Date;
84
- structedData?: Schema.Thing[] | (() => Schema.Thing[] | Promise<Schema.Thing[]>);
85
- article?: boolean;
86
- blogPosting?: boolean;
87
- creativeWork?: boolean;
88
- visualArtwork?: boolean;
89
- collection?: {
90
- title: string;
91
- url: string;
92
- description?: string;
93
- thumbnail?: SEOImage;
94
- updatedAt?: Date;
95
- createdAt?: Date;
96
- }[];
97
- };
98
- meta: MetaFunction<unknown, Record<string, unknown>>;
99
- generateJSONLD: () => React.JSX.Element;
100
- }>;
59
+ }) => {
60
+ pageTitle: string;
61
+ type: string | undefined;
62
+ description: string;
63
+ keywords: string[] | undefined;
64
+ url: string;
65
+ thumbnail: SEOImage | null | undefined;
66
+ };
67
+ meta: MetaFunction<unknown, Record<string, unknown>>;
68
+ StructedData: () => React.JSX.Element;
101
69
  };
102
70
 
103
71
  export { type SEO, type SEOImage, configSEO };