@dev-to/react-loader 0.2.0 → 1.0.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/README.md +36 -4
- package/dist/ReactLoader.d.ts +9 -3
- package/dist/ReactLoader.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -5
- package/dist/index.umd.js +183 -371
- package/package.json +2 -2
- package/dist/index.umd.js.LICENSE.txt +0 -9
package/README.md
CHANGED
|
@@ -46,14 +46,46 @@ export function Demo() {
|
|
|
46
46
|
|
|
47
47
|
## 默认桥接端点
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
-
|
|
49
|
+
### v2.0+ 统一发现端点(推荐)
|
|
50
|
+
- **Discovery**: `/__dev_to__/discovery.json` - 统一发现端点,包含所有配置信息
|
|
51
|
+
|
|
52
|
+
### React 专用端点(兼容)
|
|
53
|
+
- **Contract**: `/__dev_to__/react/contract.js` - 桥接合约
|
|
54
|
+
- **Init**: `/__dev_to__/react/init.js` - 初始化脚本
|
|
51
55
|
|
|
52
56
|
这些端点常量由 `@dev-to/react-shared` 统一定义,保证与 `@dev-to/react-plugin` 保持一致。
|
|
53
57
|
|
|
54
58
|
可通过 `contractEndpoint` 自定义 contract 路径;init 路径由 contract 返回值决定(未提供时回退到默认值)。
|
|
55
59
|
|
|
60
|
+
### 新增功能(v2.0+)
|
|
61
|
+
|
|
62
|
+
使用新的发现端点 API:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { loadDiscoveryContract } from '@dev-to/react-loader'
|
|
66
|
+
|
|
67
|
+
// 加载统一发现合约
|
|
68
|
+
const discovery = await loadDiscoveryContract('http://localhost:5173')
|
|
69
|
+
|
|
70
|
+
console.log(discovery.framework.type) // 'react'
|
|
71
|
+
console.log(discovery.framework.version) // '18.2.0'
|
|
72
|
+
console.log(discovery.server.origins) // 所有可用的 origin
|
|
73
|
+
console.log(discovery.components) // 组件映射
|
|
74
|
+
```
|
|
75
|
+
|
|
56
76
|
## 导出内容
|
|
57
77
|
|
|
58
|
-
|
|
59
|
-
-
|
|
78
|
+
### React 组件
|
|
79
|
+
- `ReactLoader` - 主加载器组件
|
|
80
|
+
|
|
81
|
+
### 底层能力
|
|
82
|
+
- `loadDiscoveryContract` - (新) 加载统一发现合约
|
|
83
|
+
- `loadBridgeContract` - 加载桥接合约(兼容旧版)
|
|
84
|
+
- `ensureBridgeInit` - 确保 HMR 运行时初始化
|
|
85
|
+
- `resolveReactEntry` - 解析组件入口 URL
|
|
86
|
+
- `resolveReactEntryForLoader` - 带错误处理的入口解析
|
|
87
|
+
|
|
88
|
+
### 常量
|
|
89
|
+
- `DEFAULT_DISCOVERY_ENDPOINT` - (新) 默认发现端点
|
|
90
|
+
- `DEFAULT_CONTRACT_ENDPOINT` - 默认合约端点
|
|
91
|
+
- `DEFAULT_INIT_ENDPOINT` - 默认初始化端点
|
package/dist/ReactLoader.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import { type DevToReactBridgeContract } from '@dev-to/react-shared';
|
|
2
|
+
import { type DevToDiscoveryContract, type DevToReactBridgeContract } from '@dev-to/react-shared';
|
|
3
3
|
/**
|
|
4
4
|
* --- DevTo React Bridge Protocol Types & Utils ---
|
|
5
5
|
*/
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
6
|
+
export declare const DEFAULT_DISCOVERY_ENDPOINT: "/__dev_to__/discovery.json";
|
|
7
|
+
export declare const DEFAULT_CONTRACT_ENDPOINT: "/__dev_to__/react/contract.js";
|
|
8
|
+
export declare const DEFAULT_INIT_ENDPOINT: "/__dev_to__/react/init.js";
|
|
9
|
+
/**
|
|
10
|
+
* Load unified discovery contract from dev server (framework-agnostic).
|
|
11
|
+
* This is the new recommended way to discover server capabilities.
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadDiscoveryContract(origin: string, discoveryEndpoint?: string): Promise<DevToDiscoveryContract>;
|
|
8
14
|
/** 加载远程 dev server 的桥接合约(无副作用) */
|
|
9
15
|
export declare function loadBridgeContract(origin: string, contractEndpoint?: string): Promise<DevToReactBridgeContract>;
|
|
10
16
|
/** 初始化远程 dev server 的 HMR/Refresh 运行时 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactLoader.d.ts","sourceRoot":"","sources":["../src/ReactLoader.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"ReactLoader.d.ts","sourceRoot":"","sources":["../src/ReactLoader.tsx"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { DEFAULT_CONTRACT_ENDPOINT, DEFAULT_INIT_ENDPOINT, ReactLoader, ensureBridgeInit, loadBridgeContract, resolveReactEntry, resolveReactEntryForLoader, } from './ReactLoader.js';
|
|
1
|
+
export { DEFAULT_CONTRACT_ENDPOINT, DEFAULT_DISCOVERY_ENDPOINT, DEFAULT_INIT_ENDPOINT, ReactLoader, ensureBridgeInit, loadBridgeContract, loadDiscoveryContract, resolveReactEntry, resolveReactEntryForLoader, } from './ReactLoader.js';
|
|
2
2
|
export type { ReactEntryResolution, ReactEntryResolutionError, ReactEntryResolutionResult, ReactLoaderError, ReactLoaderProps, } from './ReactLoader.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAA;AAEzB,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,qBAAqB,EACrB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAA;AAEzB,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kBAAkB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { DEV_TO_REACT_BASE_PATH, DEV_TO_REACT_CONTRACT_PATH,
|
|
3
|
+
import { DEV_TO_DEBUG_HTML_PATH, DEV_TO_DISCOVERY_PATH, DEV_TO_REACT_BASE_PATH, DEV_TO_REACT_CONTRACT_PATH, DEV_TO_REACT_INIT_PATH, DEV_TO_REACT_NAMESPACE } from "@dev-to/react-shared";
|
|
4
4
|
function isRecord(value) {
|
|
5
5
|
return 'object' == typeof value && null !== value;
|
|
6
6
|
}
|
|
@@ -22,6 +22,7 @@ function resolveRemoteRuntime(runtimeModule) {
|
|
|
22
22
|
ReactDOMClient: domCandidate
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
const DEFAULT_DISCOVERY_ENDPOINT = DEV_TO_DISCOVERY_PATH;
|
|
25
26
|
const DEFAULT_CONTRACT_ENDPOINT = DEV_TO_REACT_CONTRACT_PATH;
|
|
26
27
|
const DEFAULT_INIT_ENDPOINT = DEV_TO_REACT_INIT_PATH;
|
|
27
28
|
function resolveEndpointUrl(origin, endpoint) {
|
|
@@ -34,8 +35,7 @@ function isBridgeContract(value) {
|
|
|
34
35
|
const paths = value['paths'];
|
|
35
36
|
const events = value['events'];
|
|
36
37
|
if (!isRecord(paths) || 'string' != typeof paths['reactRuntime']) return false;
|
|
37
|
-
|
|
38
|
-
return true;
|
|
38
|
+
return !(!isRecord(events) || 'string' != typeof events['fullReload']);
|
|
39
39
|
}
|
|
40
40
|
function resolveContract(initModule) {
|
|
41
41
|
const moduleRecord = isRecord(initModule) ? initModule : {};
|
|
@@ -45,8 +45,25 @@ function resolveContract(initModule) {
|
|
|
45
45
|
return contractCandidate;
|
|
46
46
|
}
|
|
47
47
|
const nativeImport = new Function('url', 'return import(url)');
|
|
48
|
+
const discoveryCache = new Map();
|
|
48
49
|
const contractCache = new Map();
|
|
49
50
|
const initCache = new Map();
|
|
51
|
+
async function loadDiscoveryContract(origin, discoveryEndpoint) {
|
|
52
|
+
const endpoint = discoveryEndpoint || DEFAULT_DISCOVERY_ENDPOINT;
|
|
53
|
+
const discoveryUrl = resolveEndpointUrl(origin, endpoint);
|
|
54
|
+
if (discoveryCache.has(discoveryUrl)) return discoveryCache.get(discoveryUrl);
|
|
55
|
+
const p = fetch(discoveryUrl).then(async (resp)=>{
|
|
56
|
+
if (!resp.ok) throw new Error(`Discovery endpoint returned ${resp.status}: ${resp.statusText}`);
|
|
57
|
+
const data = await resp.json();
|
|
58
|
+
if (!data || 'object' != typeof data) throw new Error('Invalid discovery response: not a JSON object');
|
|
59
|
+
return data;
|
|
60
|
+
}).catch((e)=>{
|
|
61
|
+
discoveryCache.delete(discoveryUrl);
|
|
62
|
+
throw e instanceof Error ? e : new Error(String(e));
|
|
63
|
+
});
|
|
64
|
+
discoveryCache.set(discoveryUrl, p);
|
|
65
|
+
return p;
|
|
66
|
+
}
|
|
50
67
|
async function loadBridgeContract(origin, contractEndpoint) {
|
|
51
68
|
const endpoint = contractEndpoint || DEFAULT_CONTRACT_ENDPOINT;
|
|
52
69
|
const initUrl = resolveEndpointUrl(origin, endpoint);
|
|
@@ -500,7 +517,7 @@ function InlineViteErrorView(props) {
|
|
|
500
517
|
fontStyle: 'italic'
|
|
501
518
|
}
|
|
502
519
|
};
|
|
503
|
-
const debugPanelUrl = `${currentOrigin}${
|
|
520
|
+
const debugPanelUrl = `${currentOrigin}${DEV_TO_DEBUG_HTML_PATH}`;
|
|
504
521
|
const componentNameLabel = componentName || '';
|
|
505
522
|
return /*#__PURE__*/ jsxs("div", {
|
|
506
523
|
className: "vdev-container",
|
|
@@ -857,4 +874,4 @@ function ReactLoader(props) {
|
|
|
857
874
|
]
|
|
858
875
|
});
|
|
859
876
|
}
|
|
860
|
-
export { DEFAULT_CONTRACT_ENDPOINT, DEFAULT_INIT_ENDPOINT, ReactLoader, ensureBridgeInit, loadBridgeContract, resolveReactEntry, resolveReactEntryForLoader };
|
|
877
|
+
export { DEFAULT_CONTRACT_ENDPOINT, DEFAULT_DISCOVERY_ENDPOINT, DEFAULT_INIT_ENDPOINT, ReactLoader, ensureBridgeInit, loadBridgeContract, loadDiscoveryContract, resolveReactEntry, resolveReactEntryForLoader };
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/*! For license information please see index.umd.js.LICENSE.txt */
|
|
2
1
|
(function(root, factory) {
|
|
3
2
|
if ('object' == typeof exports && 'object' == typeof module) module.exports = factory(require("React"));
|
|
4
3
|
else if ('function' == typeof define && define.amd) define([
|
|
@@ -9,44 +8,6 @@
|
|
|
9
8
|
})(globalThis, (__rspack_external_react)=>(()=>{
|
|
10
9
|
"use strict";
|
|
11
10
|
var __webpack_modules__ = {
|
|
12
|
-
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.js" (__unused_rspack_module, exports1, __webpack_require__) {
|
|
13
|
-
/**
|
|
14
|
-
* @license React
|
|
15
|
-
* react-jsx-runtime.production.min.js
|
|
16
|
-
*
|
|
17
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the MIT license found in the
|
|
20
|
-
* LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/ var f = __webpack_require__("react"), k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = {
|
|
22
|
-
key: !0,
|
|
23
|
-
ref: !0,
|
|
24
|
-
__self: !0,
|
|
25
|
-
__source: !0
|
|
26
|
-
};
|
|
27
|
-
function q(c, a, g) {
|
|
28
|
-
var b, d = {}, e = null, h = null;
|
|
29
|
-
void 0 !== g && (e = "" + g);
|
|
30
|
-
void 0 !== a.key && (e = "" + a.key);
|
|
31
|
-
void 0 !== a.ref && (h = a.ref);
|
|
32
|
-
for(b in a)m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
33
|
-
if (c && c.defaultProps) for(b in a = c.defaultProps)void 0 === d[b] && (d[b] = a[b]);
|
|
34
|
-
return {
|
|
35
|
-
$$typeof: k,
|
|
36
|
-
type: c,
|
|
37
|
-
key: e,
|
|
38
|
-
ref: h,
|
|
39
|
-
props: d,
|
|
40
|
-
_owner: n.current
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
exports1.Fragment = l;
|
|
44
|
-
exports1.jsx = q;
|
|
45
|
-
exports1.jsxs = q;
|
|
46
|
-
},
|
|
47
|
-
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js" (module1, __unused_rspack_exports, __webpack_require__) {
|
|
48
|
-
module1.exports = __webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.js");
|
|
49
|
-
},
|
|
50
11
|
react (module1) {
|
|
51
12
|
module1.exports = __rspack_external_react;
|
|
52
13
|
}
|
|
@@ -61,6 +22,15 @@
|
|
|
61
22
|
__webpack_modules__[moduleId](module1, module1.exports, __webpack_require__);
|
|
62
23
|
return module1.exports;
|
|
63
24
|
}
|
|
25
|
+
(()=>{
|
|
26
|
+
__webpack_require__.n = (module1)=>{
|
|
27
|
+
var getter = module1 && module1.__esModule ? ()=>module1['default'] : ()=>module1;
|
|
28
|
+
__webpack_require__.d(getter, {
|
|
29
|
+
a: getter
|
|
30
|
+
});
|
|
31
|
+
return getter;
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
64
34
|
(()=>{
|
|
65
35
|
__webpack_require__.d = (exports1, definition)=>{
|
|
66
36
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -86,21 +56,26 @@
|
|
|
86
56
|
(()=>{
|
|
87
57
|
__webpack_require__.r(__webpack_exports__);
|
|
88
58
|
__webpack_require__.d(__webpack_exports__, {
|
|
59
|
+
resolveReactEntryForLoader: ()=>resolveReactEntryForLoader,
|
|
89
60
|
resolveReactEntry: ()=>resolveReactEntry,
|
|
90
61
|
loadBridgeContract: ()=>loadBridgeContract,
|
|
91
62
|
DEFAULT_CONTRACT_ENDPOINT: ()=>DEFAULT_CONTRACT_ENDPOINT,
|
|
63
|
+
DEFAULT_DISCOVERY_ENDPOINT: ()=>DEFAULT_DISCOVERY_ENDPOINT,
|
|
92
64
|
ensureBridgeInit: ()=>ensureBridgeInit,
|
|
93
65
|
ReactLoader: ()=>ReactLoader,
|
|
94
66
|
DEFAULT_INIT_ENDPOINT: ()=>DEFAULT_INIT_ENDPOINT,
|
|
95
|
-
|
|
67
|
+
loadDiscoveryContract: ()=>loadDiscoveryContract
|
|
96
68
|
});
|
|
97
|
-
var jsx_runtime = __webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js");
|
|
98
69
|
var external_React_ = __webpack_require__("react");
|
|
99
|
-
|
|
100
|
-
const
|
|
70
|
+
var external_React_default = /*#__PURE__*/ __webpack_require__.n(external_React_);
|
|
71
|
+
const DEV_TO_NAMESPACE = 'dev_to';
|
|
72
|
+
const DEV_TO_BASE_PATH = `/__${DEV_TO_NAMESPACE}__`;
|
|
73
|
+
const DEV_TO_DISCOVERY_PATH = `${DEV_TO_BASE_PATH}/discovery.json`;
|
|
74
|
+
const DEV_TO_DEBUG_HTML_PATH = `${DEV_TO_BASE_PATH}/debug.html`;
|
|
75
|
+
const DEV_TO_REACT_NAMESPACE = 'react';
|
|
76
|
+
const DEV_TO_REACT_BASE_PATH = `${DEV_TO_BASE_PATH}/${DEV_TO_REACT_NAMESPACE}`;
|
|
101
77
|
const DEV_TO_REACT_CONTRACT_PATH = `${DEV_TO_REACT_BASE_PATH}/contract.js`;
|
|
102
78
|
const DEV_TO_REACT_INIT_PATH = `${DEV_TO_REACT_BASE_PATH}/init.js`;
|
|
103
|
-
const DEV_TO_REACT_DEBUG_HTML_PATH = `${DEV_TO_REACT_BASE_PATH}/debug.html`;
|
|
104
79
|
function isRecord(value) {
|
|
105
80
|
return 'object' == typeof value && null !== value;
|
|
106
81
|
}
|
|
@@ -122,6 +97,7 @@
|
|
|
122
97
|
ReactDOMClient: domCandidate
|
|
123
98
|
};
|
|
124
99
|
}
|
|
100
|
+
const DEFAULT_DISCOVERY_ENDPOINT = DEV_TO_DISCOVERY_PATH;
|
|
125
101
|
const DEFAULT_CONTRACT_ENDPOINT = DEV_TO_REACT_CONTRACT_PATH;
|
|
126
102
|
const DEFAULT_INIT_ENDPOINT = DEV_TO_REACT_INIT_PATH;
|
|
127
103
|
function resolveEndpointUrl(origin, endpoint) {
|
|
@@ -134,8 +110,7 @@
|
|
|
134
110
|
const paths = value['paths'];
|
|
135
111
|
const events = value['events'];
|
|
136
112
|
if (!isRecord(paths) || 'string' != typeof paths['reactRuntime']) return false;
|
|
137
|
-
|
|
138
|
-
return true;
|
|
113
|
+
return !(!isRecord(events) || 'string' != typeof events['fullReload']);
|
|
139
114
|
}
|
|
140
115
|
function resolveContract(initModule) {
|
|
141
116
|
const moduleRecord = isRecord(initModule) ? initModule : {};
|
|
@@ -145,8 +120,25 @@
|
|
|
145
120
|
return contractCandidate;
|
|
146
121
|
}
|
|
147
122
|
const nativeImport = new Function('url', 'return import(url)');
|
|
123
|
+
const discoveryCache = new Map();
|
|
148
124
|
const contractCache = new Map();
|
|
149
125
|
const initCache = new Map();
|
|
126
|
+
async function loadDiscoveryContract(origin, discoveryEndpoint) {
|
|
127
|
+
const endpoint = discoveryEndpoint || DEFAULT_DISCOVERY_ENDPOINT;
|
|
128
|
+
const discoveryUrl = resolveEndpointUrl(origin, endpoint);
|
|
129
|
+
if (discoveryCache.has(discoveryUrl)) return discoveryCache.get(discoveryUrl);
|
|
130
|
+
const p = fetch(discoveryUrl).then(async (resp)=>{
|
|
131
|
+
if (!resp.ok) throw new Error(`Discovery endpoint returned ${resp.status}: ${resp.statusText}`);
|
|
132
|
+
const data = await resp.json();
|
|
133
|
+
if (!data || 'object' != typeof data) throw new Error('Invalid discovery response: not a JSON object');
|
|
134
|
+
return data;
|
|
135
|
+
}).catch((e)=>{
|
|
136
|
+
discoveryCache.delete(discoveryUrl);
|
|
137
|
+
throw e instanceof Error ? e : new Error(String(e));
|
|
138
|
+
});
|
|
139
|
+
discoveryCache.set(discoveryUrl, p);
|
|
140
|
+
return p;
|
|
141
|
+
}
|
|
150
142
|
async function loadBridgeContract(origin, contractEndpoint) {
|
|
151
143
|
const endpoint = contractEndpoint || DEFAULT_CONTRACT_ENDPOINT;
|
|
152
144
|
const initUrl = resolveEndpointUrl(origin, endpoint);
|
|
@@ -431,7 +423,7 @@
|
|
|
431
423
|
const { errorMessage, currentOrigin, componentName, setupGuide, statusCode } = props;
|
|
432
424
|
const isComponentNotFound = errorMessage.includes('not found in devComponentMap');
|
|
433
425
|
const isFetchError = errorMessage.includes('Failed to fetch dynamically imported module');
|
|
434
|
-
const isInternalBridgeFile = errorMessage.includes(DEV_TO_REACT_BASE_PATH) || errorMessage.includes(
|
|
426
|
+
const isInternalBridgeFile = errorMessage.includes(DEV_TO_REACT_BASE_PATH) || errorMessage.includes("react");
|
|
435
427
|
const isContractError = errorMessage.includes('Vite dev contract not found') || errorMessage.includes('Failed to load Vite bridge contract') || errorMessage.includes('Failed to load contract from') || isFetchError && isInternalBridgeFile;
|
|
436
428
|
const isModuleFetchError = isFetchError && !isInternalBridgeFile;
|
|
437
429
|
let title = 'Vite Server Error';
|
|
@@ -600,312 +592,143 @@
|
|
|
600
592
|
fontStyle: 'italic'
|
|
601
593
|
}
|
|
602
594
|
};
|
|
603
|
-
const debugPanelUrl = `${currentOrigin}${
|
|
595
|
+
const debugPanelUrl = `${currentOrigin}${DEV_TO_DEBUG_HTML_PATH}`;
|
|
604
596
|
const componentNameLabel = componentName || '';
|
|
605
|
-
return /*#__PURE__*/ (
|
|
597
|
+
return /*#__PURE__*/ external_React_default().createElement("div", {
|
|
606
598
|
className: "vdev-container",
|
|
607
|
-
style: styles.container
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
"."
|
|
741
|
-
]
|
|
742
|
-
}),
|
|
743
|
-
/*#__PURE__*/ (0, jsx_runtime.jsxs)("li", {
|
|
744
|
-
className: "vdev-li",
|
|
745
|
-
style: styles.li,
|
|
746
|
-
children: [
|
|
747
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("b", {
|
|
748
|
-
children: "Check Terminal"
|
|
749
|
-
}),
|
|
750
|
-
": look at the terminal where",
|
|
751
|
-
' ',
|
|
752
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("code", {
|
|
753
|
-
className: "vdev-code",
|
|
754
|
-
style: styles.code,
|
|
755
|
-
children: currentOrigin
|
|
756
|
-
}),
|
|
757
|
-
' ',
|
|
758
|
-
"is running for build errors."
|
|
759
|
-
]
|
|
760
|
-
}),
|
|
761
|
-
/*#__PURE__*/ (0, jsx_runtime.jsxs)("li", {
|
|
762
|
-
className: "vdev-li",
|
|
763
|
-
style: styles.li,
|
|
764
|
-
children: [
|
|
765
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("b", {
|
|
766
|
-
children: "Check Export"
|
|
767
|
-
}),
|
|
768
|
-
": ensure the entry module exports a React component (default export recommended)."
|
|
769
|
-
]
|
|
770
|
-
})
|
|
771
|
-
]
|
|
772
|
-
}) : null,
|
|
773
|
-
isComponentNotFound ? /*#__PURE__*/ (0, jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
774
|
-
children: [
|
|
775
|
-
/*#__PURE__*/ (0, jsx_runtime.jsxs)("li", {
|
|
776
|
-
className: "vdev-li",
|
|
777
|
-
style: styles.li,
|
|
778
|
-
children: [
|
|
779
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("b", {
|
|
780
|
-
children: "Update Config"
|
|
781
|
-
}),
|
|
782
|
-
": map",
|
|
783
|
-
' ',
|
|
784
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("code", {
|
|
785
|
-
className: "vdev-code",
|
|
786
|
-
style: styles.code,
|
|
787
|
-
children: componentNameLabel
|
|
788
|
-
}),
|
|
789
|
-
' ',
|
|
790
|
-
"in",
|
|
791
|
-
' ',
|
|
792
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("code", {
|
|
793
|
-
className: "vdev-code",
|
|
794
|
-
style: styles.code,
|
|
795
|
-
children: "devComponentMap"
|
|
796
|
-
}),
|
|
797
|
-
"."
|
|
798
|
-
]
|
|
799
|
-
}),
|
|
800
|
-
/*#__PURE__*/ (0, jsx_runtime.jsxs)("li", {
|
|
801
|
-
className: "vdev-li",
|
|
802
|
-
style: styles.li,
|
|
803
|
-
children: [
|
|
804
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("b", {
|
|
805
|
-
children: "Wildcard Fallback"
|
|
806
|
-
}),
|
|
807
|
-
": add",
|
|
808
|
-
' ',
|
|
809
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("code", {
|
|
810
|
-
className: "vdev-code",
|
|
811
|
-
style: styles.code,
|
|
812
|
-
children: "'*': '/'"
|
|
813
|
-
}),
|
|
814
|
-
' ',
|
|
815
|
-
"to map all components to the default entry."
|
|
816
|
-
]
|
|
817
|
-
})
|
|
818
|
-
]
|
|
819
|
-
}) : null,
|
|
820
|
-
isContractError ? /*#__PURE__*/ (0, jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
821
|
-
children: [
|
|
822
|
-
/*#__PURE__*/ (0, jsx_runtime.jsxs)("li", {
|
|
823
|
-
className: "vdev-li",
|
|
824
|
-
style: styles.li,
|
|
825
|
-
children: [
|
|
826
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("b", {
|
|
827
|
-
children: "Check Server"
|
|
828
|
-
}),
|
|
829
|
-
": ensure your Vite server is running at",
|
|
830
|
-
' ',
|
|
831
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("code", {
|
|
832
|
-
className: "vdev-code",
|
|
833
|
-
style: styles.code,
|
|
834
|
-
children: currentOrigin
|
|
835
|
-
}),
|
|
836
|
-
"."
|
|
837
|
-
]
|
|
838
|
-
}),
|
|
839
|
-
/*#__PURE__*/ (0, jsx_runtime.jsxs)("li", {
|
|
840
|
-
className: "vdev-li",
|
|
841
|
-
style: styles.li,
|
|
842
|
-
children: [
|
|
843
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("b", {
|
|
844
|
-
children: "Verify Origin"
|
|
845
|
-
}),
|
|
846
|
-
": confirm localStorage key",
|
|
847
|
-
' ',
|
|
848
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("code", {
|
|
849
|
-
className: "vdev-code",
|
|
850
|
-
style: styles.code,
|
|
851
|
-
children: "VITE_DEV_SERVER_ORIGIN"
|
|
852
|
-
}),
|
|
853
|
-
' ',
|
|
854
|
-
"is set to",
|
|
855
|
-
' ',
|
|
856
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("code", {
|
|
857
|
-
className: "vdev-code",
|
|
858
|
-
style: styles.code,
|
|
859
|
-
children: currentOrigin
|
|
860
|
-
}),
|
|
861
|
-
"."
|
|
862
|
-
]
|
|
863
|
-
}),
|
|
864
|
-
/*#__PURE__*/ (0, jsx_runtime.jsxs)("li", {
|
|
865
|
-
className: "vdev-li",
|
|
866
|
-
style: styles.li,
|
|
867
|
-
children: [
|
|
868
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("b", {
|
|
869
|
-
children: "Open Debug Panel"
|
|
870
|
-
}),
|
|
871
|
-
":",
|
|
872
|
-
' ',
|
|
873
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("a", {
|
|
874
|
-
className: "vdev-link",
|
|
875
|
-
style: styles.link,
|
|
876
|
-
href: debugPanelUrl,
|
|
877
|
-
target: "_blank",
|
|
878
|
-
rel: "noreferrer",
|
|
879
|
-
children: debugPanelUrl
|
|
880
|
-
})
|
|
881
|
-
]
|
|
882
|
-
})
|
|
883
|
-
]
|
|
884
|
-
}) : null,
|
|
885
|
-
isModuleFetchError || isComponentNotFound || isContractError ? null : /*#__PURE__*/ (0, jsx_runtime.jsxs)("li", {
|
|
886
|
-
className: "vdev-li",
|
|
887
|
-
style: styles.li,
|
|
888
|
-
children: [
|
|
889
|
-
"Open Debug Panel:",
|
|
890
|
-
' ',
|
|
891
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("a", {
|
|
892
|
-
className: "vdev-link",
|
|
893
|
-
style: styles.link,
|
|
894
|
-
href: debugPanelUrl,
|
|
895
|
-
target: "_blank",
|
|
896
|
-
rel: "noreferrer",
|
|
897
|
-
children: debugPanelUrl
|
|
898
|
-
})
|
|
899
|
-
]
|
|
900
|
-
})
|
|
901
|
-
]
|
|
902
|
-
})
|
|
903
|
-
]
|
|
904
|
-
})
|
|
905
|
-
]
|
|
906
|
-
})
|
|
907
|
-
]
|
|
908
|
-
});
|
|
599
|
+
style: styles.container
|
|
600
|
+
}, /*#__PURE__*/ external_React_default().createElement("div", {
|
|
601
|
+
className: "vdev-header",
|
|
602
|
+
style: styles.header
|
|
603
|
+
}, /*#__PURE__*/ external_React_default().createElement("div", {
|
|
604
|
+
className: "vdev-icon",
|
|
605
|
+
style: styles.icon
|
|
606
|
+
}, '\u26A0\uFE0F'), /*#__PURE__*/ external_React_default().createElement("div", {
|
|
607
|
+
className: "vdev-title",
|
|
608
|
+
style: styles.title
|
|
609
|
+
}, /*#__PURE__*/ external_React_default().createElement("span", {
|
|
610
|
+
className: "vdev-type-tag",
|
|
611
|
+
style: styles.typeTag
|
|
612
|
+
}, typeLabel), title)), /*#__PURE__*/ external_React_default().createElement("div", {
|
|
613
|
+
className: "vdev-content",
|
|
614
|
+
style: styles.content
|
|
615
|
+
}, /*#__PURE__*/ external_React_default().createElement("div", {
|
|
616
|
+
className: "vdev-message",
|
|
617
|
+
style: styles.message
|
|
618
|
+
}, errorMessage), /*#__PURE__*/ external_React_default().createElement("div", {
|
|
619
|
+
className: "vdev-info",
|
|
620
|
+
style: styles.info
|
|
621
|
+
}, /*#__PURE__*/ external_React_default().createElement("div", {
|
|
622
|
+
className: "vdev-info-row",
|
|
623
|
+
style: styles.infoRow
|
|
624
|
+
}, /*#__PURE__*/ external_React_default().createElement("span", {
|
|
625
|
+
className: "vdev-label",
|
|
626
|
+
style: styles.label
|
|
627
|
+
}, "Server Address:"), /*#__PURE__*/ external_React_default().createElement("code", {
|
|
628
|
+
className: "vdev-value",
|
|
629
|
+
style: styles.value
|
|
630
|
+
}, currentOrigin)), componentNameLabel ? /*#__PURE__*/ external_React_default().createElement("div", {
|
|
631
|
+
className: "vdev-info-row",
|
|
632
|
+
style: styles.infoRow
|
|
633
|
+
}, /*#__PURE__*/ external_React_default().createElement("span", {
|
|
634
|
+
className: "vdev-label",
|
|
635
|
+
style: styles.label
|
|
636
|
+
}, "Component Name:"), /*#__PURE__*/ external_React_default().createElement("code", {
|
|
637
|
+
className: "vdev-value",
|
|
638
|
+
style: styles.value
|
|
639
|
+
}, componentNameLabel)) : null), /*#__PURE__*/ external_React_default().createElement("div", {
|
|
640
|
+
className: "vdev-tips",
|
|
641
|
+
style: styles.tips
|
|
642
|
+
}, /*#__PURE__*/ external_React_default().createElement("div", {
|
|
643
|
+
className: "vdev-tips-title",
|
|
644
|
+
style: styles.tipsTitle
|
|
645
|
+
}, "Next Steps:"), setupGuide ? /*#__PURE__*/ external_React_default().createElement("pre", {
|
|
646
|
+
className: "vdev-code-block",
|
|
647
|
+
style: styles.codeBlock
|
|
648
|
+
}, setupGuide.steps.map((step, idx)=>{
|
|
649
|
+
const stepKey = `step-${idx}`;
|
|
650
|
+
const commentIdx = step.indexOf('//');
|
|
651
|
+
if (-1 === commentIdx) return /*#__PURE__*/ external_React_default().createElement("div", {
|
|
652
|
+
key: stepKey
|
|
653
|
+
}, step || ' ');
|
|
654
|
+
const codePart = step.substring(0, commentIdx);
|
|
655
|
+
const commentPart = step.substring(commentIdx);
|
|
656
|
+
return /*#__PURE__*/ external_React_default().createElement("div", {
|
|
657
|
+
key: stepKey
|
|
658
|
+
}, /*#__PURE__*/ external_React_default().createElement("span", null, codePart), /*#__PURE__*/ external_React_default().createElement("span", {
|
|
659
|
+
className: "vdev-code-comment",
|
|
660
|
+
style: styles.codeComment
|
|
661
|
+
}, commentPart));
|
|
662
|
+
})) : /*#__PURE__*/ external_React_default().createElement("ul", {
|
|
663
|
+
className: "vdev-list",
|
|
664
|
+
style: styles.list
|
|
665
|
+
}, isModuleFetchError ? /*#__PURE__*/ external_React_default().createElement(external_React_default().Fragment, null, /*#__PURE__*/ external_React_default().createElement("li", {
|
|
666
|
+
className: "vdev-li",
|
|
667
|
+
style: styles.li
|
|
668
|
+
}, /*#__PURE__*/ external_React_default().createElement("b", null, "Verify Path"), ": check the entry mapping for", ' ', /*#__PURE__*/ external_React_default().createElement("code", {
|
|
669
|
+
className: "vdev-code",
|
|
670
|
+
style: styles.code
|
|
671
|
+
}, componentNameLabel || 'this component'), ' ', "in", ' ', /*#__PURE__*/ external_React_default().createElement("code", {
|
|
672
|
+
className: "vdev-code",
|
|
673
|
+
style: styles.code
|
|
674
|
+
}, "vite.config.ts"), "."), /*#__PURE__*/ external_React_default().createElement("li", {
|
|
675
|
+
className: "vdev-li",
|
|
676
|
+
style: styles.li
|
|
677
|
+
}, /*#__PURE__*/ external_React_default().createElement("b", null, "Check Terminal"), ": look at the terminal where", ' ', /*#__PURE__*/ external_React_default().createElement("code", {
|
|
678
|
+
className: "vdev-code",
|
|
679
|
+
style: styles.code
|
|
680
|
+
}, currentOrigin), ' ', "is running for build errors."), /*#__PURE__*/ external_React_default().createElement("li", {
|
|
681
|
+
className: "vdev-li",
|
|
682
|
+
style: styles.li
|
|
683
|
+
}, /*#__PURE__*/ external_React_default().createElement("b", null, "Check Export"), ": ensure the entry module exports a React component (default export recommended).")) : null, isComponentNotFound ? /*#__PURE__*/ external_React_default().createElement(external_React_default().Fragment, null, /*#__PURE__*/ external_React_default().createElement("li", {
|
|
684
|
+
className: "vdev-li",
|
|
685
|
+
style: styles.li
|
|
686
|
+
}, /*#__PURE__*/ external_React_default().createElement("b", null, "Update Config"), ": map", ' ', /*#__PURE__*/ external_React_default().createElement("code", {
|
|
687
|
+
className: "vdev-code",
|
|
688
|
+
style: styles.code
|
|
689
|
+
}, componentNameLabel), ' ', "in", ' ', /*#__PURE__*/ external_React_default().createElement("code", {
|
|
690
|
+
className: "vdev-code",
|
|
691
|
+
style: styles.code
|
|
692
|
+
}, "devComponentMap"), "."), /*#__PURE__*/ external_React_default().createElement("li", {
|
|
693
|
+
className: "vdev-li",
|
|
694
|
+
style: styles.li
|
|
695
|
+
}, /*#__PURE__*/ external_React_default().createElement("b", null, "Wildcard Fallback"), ": add", ' ', /*#__PURE__*/ external_React_default().createElement("code", {
|
|
696
|
+
className: "vdev-code",
|
|
697
|
+
style: styles.code
|
|
698
|
+
}, "'*': '/'"), ' ', "to map all components to the default entry.")) : null, isContractError ? /*#__PURE__*/ external_React_default().createElement(external_React_default().Fragment, null, /*#__PURE__*/ external_React_default().createElement("li", {
|
|
699
|
+
className: "vdev-li",
|
|
700
|
+
style: styles.li
|
|
701
|
+
}, /*#__PURE__*/ external_React_default().createElement("b", null, "Check Server"), ": ensure your Vite server is running at", ' ', /*#__PURE__*/ external_React_default().createElement("code", {
|
|
702
|
+
className: "vdev-code",
|
|
703
|
+
style: styles.code
|
|
704
|
+
}, currentOrigin), "."), /*#__PURE__*/ external_React_default().createElement("li", {
|
|
705
|
+
className: "vdev-li",
|
|
706
|
+
style: styles.li
|
|
707
|
+
}, /*#__PURE__*/ external_React_default().createElement("b", null, "Verify Origin"), ": confirm localStorage key", ' ', /*#__PURE__*/ external_React_default().createElement("code", {
|
|
708
|
+
className: "vdev-code",
|
|
709
|
+
style: styles.code
|
|
710
|
+
}, "VITE_DEV_SERVER_ORIGIN"), ' ', "is set to", ' ', /*#__PURE__*/ external_React_default().createElement("code", {
|
|
711
|
+
className: "vdev-code",
|
|
712
|
+
style: styles.code
|
|
713
|
+
}, currentOrigin), "."), /*#__PURE__*/ external_React_default().createElement("li", {
|
|
714
|
+
className: "vdev-li",
|
|
715
|
+
style: styles.li
|
|
716
|
+
}, /*#__PURE__*/ external_React_default().createElement("b", null, "Open Debug Panel"), ":", ' ', /*#__PURE__*/ external_React_default().createElement("a", {
|
|
717
|
+
className: "vdev-link",
|
|
718
|
+
style: styles.link,
|
|
719
|
+
href: debugPanelUrl,
|
|
720
|
+
target: "_blank",
|
|
721
|
+
rel: "noreferrer"
|
|
722
|
+
}, debugPanelUrl))) : null, isModuleFetchError || isComponentNotFound || isContractError ? null : /*#__PURE__*/ external_React_default().createElement("li", {
|
|
723
|
+
className: "vdev-li",
|
|
724
|
+
style: styles.li
|
|
725
|
+
}, "Open Debug Panel:", ' ', /*#__PURE__*/ external_React_default().createElement("a", {
|
|
726
|
+
className: "vdev-link",
|
|
727
|
+
style: styles.link,
|
|
728
|
+
href: debugPanelUrl,
|
|
729
|
+
target: "_blank",
|
|
730
|
+
rel: "noreferrer"
|
|
731
|
+
}, debugPanelUrl))))));
|
|
909
732
|
}
|
|
910
733
|
function ReactLoader(props) {
|
|
911
734
|
const { url, origin, name, componentProps, contractEndpoint, loading, renderError, externalError } = props;
|
|
@@ -916,9 +739,7 @@
|
|
|
916
739
|
componentProps,
|
|
917
740
|
contractEndpoint
|
|
918
741
|
});
|
|
919
|
-
const defaultLoading = /*#__PURE__*/ (
|
|
920
|
-
children: "Loading..."
|
|
921
|
-
});
|
|
742
|
+
const defaultLoading = /*#__PURE__*/ external_React_default().createElement("div", null, "Loading...");
|
|
922
743
|
const renderErrorNode = (0, external_React_.useCallback)((err)=>{
|
|
923
744
|
if (renderError) return renderError(err);
|
|
924
745
|
const isLoaderErrorObject = !(err instanceof Error);
|
|
@@ -927,7 +748,7 @@
|
|
|
927
748
|
const componentName = (isLoaderErrorObject ? err.componentName : void 0) || name;
|
|
928
749
|
const setupGuide = isLoaderErrorObject ? err.setupGuide : void 0;
|
|
929
750
|
const statusCode = isLoaderErrorObject ? err.statusCode : err.statusCode;
|
|
930
|
-
return /*#__PURE__*/ (
|
|
751
|
+
return /*#__PURE__*/ external_React_default().createElement(InlineViteErrorView, {
|
|
931
752
|
errorMessage: errorMessage,
|
|
932
753
|
currentOrigin: currentOrigin,
|
|
933
754
|
componentName: componentName,
|
|
@@ -940,22 +761,13 @@
|
|
|
940
761
|
origin,
|
|
941
762
|
url
|
|
942
763
|
]);
|
|
943
|
-
if (externalError) return /*#__PURE__*/ (
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
children: [
|
|
951
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)("div", {
|
|
952
|
-
ref: state.containerRef,
|
|
953
|
-
className: "vdev-loader-container",
|
|
954
|
-
"data-is": "ReactLoader"
|
|
955
|
-
}),
|
|
956
|
-
state.isReady ? null : loading ?? defaultLoading
|
|
957
|
-
]
|
|
958
|
-
});
|
|
764
|
+
if (externalError) return /*#__PURE__*/ external_React_default().createElement(external_React_default().Fragment, null, renderErrorNode(externalError));
|
|
765
|
+
if (state.error) return /*#__PURE__*/ external_React_default().createElement(external_React_default().Fragment, null, renderErrorNode(state.error));
|
|
766
|
+
return /*#__PURE__*/ external_React_default().createElement(external_React_default().Fragment, null, /*#__PURE__*/ external_React_default().createElement("div", {
|
|
767
|
+
ref: state.containerRef,
|
|
768
|
+
className: "vdev-loader-container",
|
|
769
|
+
"data-is": "ReactLoader"
|
|
770
|
+
}), state.isReady ? null : loading ?? defaultLoading);
|
|
959
771
|
}
|
|
960
772
|
})();
|
|
961
773
|
return __webpack_exports__;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev-to/react-loader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@dev-to/react-shared": "0.
|
|
32
|
+
"@dev-to/react-shared": "1.0.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "rslib build",
|