@uniweb/runtime 0.2.7 → 0.2.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/runtime",
3
- "version": "0.2.7",
3
+ "version": "0.2.10",
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.6"
32
+ "@uniweb/core": "0.1.8"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.0.0 || ^19.0.0",
@@ -12,24 +12,26 @@
12
12
  * - right: Right sidebar/panel (from @right page)
13
13
  *
14
14
  * Custom Layouts:
15
- * Foundations can export a Layout component that receives pre-rendered areas as props:
15
+ * Foundations can provide a custom Layout via src/exports.js:
16
16
  *
17
17
  * ```jsx
18
- * export const site = {
19
- * Layout: ({ page, website, header, body, footer, left, right }) => (
20
- * <div className="my-layout">
21
- * <header>{header}</header>
22
- * <aside>{left}</aside>
23
- * <main>{body}</main>
24
- * <aside>{right}</aside>
25
- * <footer>{footer}</footer>
26
- * </div>
27
- * )
18
+ * // src/exports.js
19
+ * import Layout from './components/Layout'
20
+ *
21
+ * export default {
22
+ * Layout,
23
+ * props: {
24
+ * themeToggleEnabled: true,
25
+ * }
28
26
  * }
29
27
  * ```
28
+ *
29
+ * The Layout component receives pre-rendered areas as props:
30
+ * - page, website: Runtime context
31
+ * - header, body, footer: Pre-rendered React elements
32
+ * - left, right (or leftPanel, rightPanel): Sidebar panels
30
33
  */
31
34
 
32
- import React from 'react'
33
35
  import Blocks from './Blocks.jsx'
34
36
 
35
37
  /**
package/src/index.jsx CHANGED
@@ -107,10 +107,10 @@ async function loadFoundation(source) {
107
107
  import(/* @vite-ignore */ url)
108
108
  ])
109
109
 
110
- console.log(
111
- '[Runtime] Foundation loaded. Available components:',
112
- typeof foundation.listComponents === 'function' ? foundation.listComponents() : 'unknown'
113
- )
110
+ const componentNames = foundation.components
111
+ ? Object.keys(foundation.components)
112
+ : 'unknown'
113
+ console.log('[Runtime] Foundation loaded. Available components:', componentNames)
114
114
 
115
115
  return foundation
116
116
  } catch (error) {
@@ -212,10 +212,9 @@ async function initRuntime(foundationSource, options = {}) {
212
212
  const remoteModule = await foundationSource
213
213
  // Handle double default wrapping
214
214
  const innerModule = remoteModule?.default?.default ? remoteModule.default : remoteModule
215
- // Convert to foundation interface
215
+ // Convert to foundation interface with components object
216
216
  foundation = {
217
- getComponent: (name) => innerModule.default?.[name],
218
- listComponents: () => Object.keys(innerModule.default || {}),
217
+ components: innerModule.default || {},
219
218
  ...innerModule
220
219
  }
221
220
  } else if (foundationSource && typeof foundationSource === 'object') {
@@ -230,9 +229,9 @@ async function initRuntime(foundationSource, options = {}) {
230
229
  // Set the foundation on the runtime
231
230
  uniwebInstance.setFoundation(foundation)
232
231
 
233
- // Set foundation config if provided
234
- if (foundation.config || foundation.site) {
235
- uniwebInstance.setFoundationConfig(foundation.config || foundation.site)
232
+ // Set foundation capabilities (Layout, props, etc.) if provided
233
+ if (foundation.capabilities) {
234
+ uniwebInstance.setFoundationConfig(foundation.capabilities)
236
235
  }
237
236
 
238
237
  // Render the app