@uniweb/runtime 0.2.8 → 0.2.11
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/components/Layout.jsx +2 -2
- package/src/index.jsx +28 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/runtime",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "Minimal runtime for loading Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"node": ">=20.19"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@uniweb/core": "0.1.
|
|
32
|
+
"@uniweb/core": "0.1.8"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
* - right: Right sidebar/panel (from @right page)
|
|
13
13
|
*
|
|
14
14
|
* Custom Layouts:
|
|
15
|
-
* Foundations can provide a custom Layout via src/
|
|
15
|
+
* Foundations can provide a custom Layout via src/exports.js:
|
|
16
16
|
*
|
|
17
17
|
* ```jsx
|
|
18
|
-
* // src/
|
|
18
|
+
* // src/exports.js
|
|
19
19
|
* import Layout from './components/Layout'
|
|
20
20
|
*
|
|
21
21
|
* export default {
|
package/src/index.jsx
CHANGED
|
@@ -7,7 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react'
|
|
9
9
|
import { createRoot } from 'react-dom/client'
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
BrowserRouter,
|
|
12
|
+
Routes,
|
|
13
|
+
Route,
|
|
14
|
+
Link as RouterLink,
|
|
15
|
+
useNavigate,
|
|
16
|
+
useParams,
|
|
17
|
+
useLocation
|
|
18
|
+
} from 'react-router-dom'
|
|
11
19
|
|
|
12
20
|
// Components
|
|
13
21
|
import { ChildBlocks } from './components/PageRenderer.jsx'
|
|
@@ -107,10 +115,10 @@ async function loadFoundation(source) {
|
|
|
107
115
|
import(/* @vite-ignore */ url)
|
|
108
116
|
])
|
|
109
117
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)
|
|
118
|
+
const componentNames = foundation.components
|
|
119
|
+
? Object.keys(foundation.components)
|
|
120
|
+
: 'unknown'
|
|
121
|
+
console.log('[Runtime] Foundation loaded. Available components:', componentNames)
|
|
114
122
|
|
|
115
123
|
return foundation
|
|
116
124
|
} catch (error) {
|
|
@@ -131,6 +139,16 @@ function initUniweb(configData) {
|
|
|
131
139
|
// Set up child block renderer for nested blocks
|
|
132
140
|
uniwebInstance.childBlockRenderer = ChildBlocks
|
|
133
141
|
|
|
142
|
+
// Register routing components for kit and foundation components
|
|
143
|
+
// This enables the bridge pattern: components access routing via
|
|
144
|
+
// website.getRoutingComponents() instead of direct imports
|
|
145
|
+
uniwebInstance.routingComponents = {
|
|
146
|
+
Link: RouterLink,
|
|
147
|
+
useNavigate,
|
|
148
|
+
useParams,
|
|
149
|
+
useLocation
|
|
150
|
+
}
|
|
151
|
+
|
|
134
152
|
return uniwebInstance
|
|
135
153
|
}
|
|
136
154
|
|
|
@@ -212,10 +230,9 @@ async function initRuntime(foundationSource, options = {}) {
|
|
|
212
230
|
const remoteModule = await foundationSource
|
|
213
231
|
// Handle double default wrapping
|
|
214
232
|
const innerModule = remoteModule?.default?.default ? remoteModule.default : remoteModule
|
|
215
|
-
// Convert to foundation interface
|
|
233
|
+
// Convert to foundation interface with components object
|
|
216
234
|
foundation = {
|
|
217
|
-
|
|
218
|
-
listComponents: () => Object.keys(innerModule.default || {}),
|
|
235
|
+
components: innerModule.default || {},
|
|
219
236
|
...innerModule
|
|
220
237
|
}
|
|
221
238
|
} else if (foundationSource && typeof foundationSource === 'object') {
|
|
@@ -230,9 +247,9 @@ async function initRuntime(foundationSource, options = {}) {
|
|
|
230
247
|
// Set the foundation on the runtime
|
|
231
248
|
uniwebInstance.setFoundation(foundation)
|
|
232
249
|
|
|
233
|
-
// Set foundation
|
|
234
|
-
if (foundation.
|
|
235
|
-
uniwebInstance.setFoundationConfig(foundation.
|
|
250
|
+
// Set foundation capabilities (Layout, props, etc.) if provided
|
|
251
|
+
if (foundation.capabilities) {
|
|
252
|
+
uniwebInstance.setFoundationConfig(foundation.capabilities)
|
|
236
253
|
}
|
|
237
254
|
|
|
238
255
|
// Render the app
|