@uniweb/runtime 0.3.0 → 0.4.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/package.json +2 -2
- package/src/index.jsx +16 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Minimal runtime for loading Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"node": ">=20.19"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@uniweb/core": "0.2.
|
|
34
|
+
"@uniweb/core": "0.2.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@vitejs/plugin-react": "^4.5.2",
|
package/src/index.jsx
CHANGED
|
@@ -152,6 +152,18 @@ function initUniweb(configData) {
|
|
|
152
152
|
return uniwebInstance
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Get the router basename from Vite's BASE_URL
|
|
157
|
+
* Vite sets this based on the `base` config option
|
|
158
|
+
* Returns undefined for root path ('/'), otherwise strips trailing slash
|
|
159
|
+
*/
|
|
160
|
+
function getBasename() {
|
|
161
|
+
const baseUrl = import.meta.env?.BASE_URL
|
|
162
|
+
if (!baseUrl || baseUrl === '/') return undefined
|
|
163
|
+
// Remove trailing slash for BrowserRouter compatibility
|
|
164
|
+
return baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl
|
|
165
|
+
}
|
|
166
|
+
|
|
155
167
|
/**
|
|
156
168
|
* Render the application
|
|
157
169
|
* @param {Object} options
|
|
@@ -163,6 +175,9 @@ function render({ development = false, basename } = {}) {
|
|
|
163
175
|
return
|
|
164
176
|
}
|
|
165
177
|
|
|
178
|
+
// Use provided basename, or derive from Vite's BASE_URL
|
|
179
|
+
const routerBasename = basename ?? getBasename()
|
|
180
|
+
|
|
166
181
|
const root = createRoot(container)
|
|
167
182
|
|
|
168
183
|
const app = (
|
|
@@ -174,7 +189,7 @@ function render({ development = false, basename } = {}) {
|
|
|
174
189
|
</div>
|
|
175
190
|
}
|
|
176
191
|
>
|
|
177
|
-
<BrowserRouter basename={
|
|
192
|
+
<BrowserRouter basename={routerBasename}>
|
|
178
193
|
<Routes>
|
|
179
194
|
<Route path="/*" element={<WebsiteRenderer />} />
|
|
180
195
|
</Routes>
|