dn-react-router-toolkit 0.3.3 → 0.3.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/env.d.mts +3 -0
- package/dist/client/env.d.ts +3 -0
- package/dist/client/env.js +35 -0
- package/dist/client/env.mjs +10 -0
- package/dist/client/env_loader.d.mts +7 -0
- package/dist/client/env_loader.d.ts +7 -0
- package/dist/client/{client_env.js → env_loader.js} +13 -12
- package/dist/client/env_loader.mjs +20 -0
- package/dist/client/index.d.mts +2 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +20 -9
- package/dist/client/index.mjs +18 -8
- package/package.json +1 -1
- package/dist/client/client_env.d.mts +0 -7
- package/dist/client/client_env.d.ts +0 -7
- package/dist/client/client_env.mjs +0 -19
|
@@ -0,0 +1,35 @@
|
|
|
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);
|
|
19
|
+
|
|
20
|
+
// src/client/env.ts
|
|
21
|
+
var env_exports = {};
|
|
22
|
+
__export(env_exports, {
|
|
23
|
+
env: () => env
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(env_exports);
|
|
26
|
+
function env(key) {
|
|
27
|
+
if (typeof window === "undefined") {
|
|
28
|
+
return process.env[key] || "";
|
|
29
|
+
}
|
|
30
|
+
return window.ENV?.[key] || "";
|
|
31
|
+
}
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
env
|
|
35
|
+
});
|
|
@@ -27,28 +27,29 @@ 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/client/
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
|
|
30
|
+
// src/client/env_loader.tsx
|
|
31
|
+
var env_loader_exports = {};
|
|
32
|
+
__export(env_loader_exports, {
|
|
33
|
+
EnvLoader: () => EnvLoader
|
|
34
34
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(env_loader_exports);
|
|
36
36
|
var import_react = __toESM(require("react"));
|
|
37
37
|
var import_react_router = require("react-router");
|
|
38
|
-
function
|
|
38
|
+
function EnvLoader({ dataKey = "ENV" }) {
|
|
39
39
|
const data = (0, import_react_router.useRouteLoaderData)("root");
|
|
40
|
-
|
|
40
|
+
if (!data) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
41
44
|
"script",
|
|
42
45
|
{
|
|
43
46
|
dangerouslySetInnerHTML: {
|
|
44
|
-
__html: `window.
|
|
45
|
-
env: data?.[dataKey]
|
|
46
|
-
})}`
|
|
47
|
+
__html: `window.ENV = ${JSON.stringify(data[dataKey])};`
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
)
|
|
50
|
+
);
|
|
50
51
|
}
|
|
51
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
53
|
0 && (module.exports = {
|
|
53
|
-
|
|
54
|
+
EnvLoader
|
|
54
55
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/client/env_loader.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useRouteLoaderData } from "react-router";
|
|
4
|
+
function EnvLoader({ dataKey = "ENV" }) {
|
|
5
|
+
const data = useRouteLoaderData("root");
|
|
6
|
+
if (!data) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
return /* @__PURE__ */ React.createElement(
|
|
10
|
+
"script",
|
|
11
|
+
{
|
|
12
|
+
dangerouslySetInnerHTML: {
|
|
13
|
+
__html: `window.ENV = ${JSON.stringify(data[dataKey])};`
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
EnvLoader
|
|
20
|
+
};
|
package/dist/client/index.d.mts
CHANGED
package/dist/client/index.d.ts
CHANGED
package/dist/client/index.js
CHANGED
|
@@ -30,26 +30,36 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/client/index.ts
|
|
31
31
|
var client_exports = {};
|
|
32
32
|
__export(client_exports, {
|
|
33
|
-
|
|
33
|
+
EnvLoader: () => EnvLoader,
|
|
34
|
+
env: () => env,
|
|
34
35
|
useUserAgent: () => useUserAgent
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(client_exports);
|
|
37
38
|
|
|
38
|
-
// src/client/
|
|
39
|
+
// src/client/env.ts
|
|
40
|
+
function env(key) {
|
|
41
|
+
if (typeof window === "undefined") {
|
|
42
|
+
return process.env[key] || "";
|
|
43
|
+
}
|
|
44
|
+
return window.ENV?.[key] || "";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/client/env_loader.tsx
|
|
39
48
|
var import_react = __toESM(require("react"));
|
|
40
49
|
var import_react_router = require("react-router");
|
|
41
|
-
function
|
|
50
|
+
function EnvLoader({ dataKey = "ENV" }) {
|
|
42
51
|
const data = (0, import_react_router.useRouteLoaderData)("root");
|
|
43
|
-
|
|
52
|
+
if (!data) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
44
56
|
"script",
|
|
45
57
|
{
|
|
46
58
|
dangerouslySetInnerHTML: {
|
|
47
|
-
__html: `window.
|
|
48
|
-
env: data?.[dataKey]
|
|
49
|
-
})}`
|
|
59
|
+
__html: `window.ENV = ${JSON.stringify(data[dataKey])};`
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
|
-
)
|
|
62
|
+
);
|
|
53
63
|
}
|
|
54
64
|
|
|
55
65
|
// src/client/use_user_agent.tsx
|
|
@@ -64,6 +74,7 @@ function useUserAgent() {
|
|
|
64
74
|
}
|
|
65
75
|
// Annotate the CommonJS export names for ESM import in node:
|
|
66
76
|
0 && (module.exports = {
|
|
67
|
-
|
|
77
|
+
EnvLoader,
|
|
78
|
+
env,
|
|
68
79
|
useUserAgent
|
|
69
80
|
});
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
// src/client/
|
|
1
|
+
// src/client/env.ts
|
|
2
|
+
function env(key) {
|
|
3
|
+
if (typeof window === "undefined") {
|
|
4
|
+
return process.env[key] || "";
|
|
5
|
+
}
|
|
6
|
+
return window.ENV?.[key] || "";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// src/client/env_loader.tsx
|
|
2
10
|
import React from "react";
|
|
3
11
|
import { useRouteLoaderData } from "react-router";
|
|
4
|
-
function
|
|
12
|
+
function EnvLoader({ dataKey = "ENV" }) {
|
|
5
13
|
const data = useRouteLoaderData("root");
|
|
6
|
-
|
|
14
|
+
if (!data) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ React.createElement(
|
|
7
18
|
"script",
|
|
8
19
|
{
|
|
9
20
|
dangerouslySetInnerHTML: {
|
|
10
|
-
__html: `window.
|
|
11
|
-
env: data?.[dataKey]
|
|
12
|
-
})}`
|
|
21
|
+
__html: `window.ENV = ${JSON.stringify(data[dataKey])};`
|
|
13
22
|
}
|
|
14
23
|
}
|
|
15
|
-
)
|
|
24
|
+
);
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
// src/client/use_user_agent.tsx
|
|
@@ -26,6 +35,7 @@ function useUserAgent() {
|
|
|
26
35
|
return { userAgent, isMobile, isTablet, isDesktop };
|
|
27
36
|
}
|
|
28
37
|
export {
|
|
29
|
-
|
|
38
|
+
EnvLoader,
|
|
39
|
+
env,
|
|
30
40
|
useUserAgent
|
|
31
41
|
};
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// src/client/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
|
|
19
|
-
};
|