@uniweb/core 0.5.0 → 0.5.2
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/block.js +26 -0
- package/src/uniweb.js +12 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"jest": "^29.7.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@uniweb/semantic-parser": "1.1.
|
|
33
|
+
"@uniweb/semantic-parser": "1.1.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
package/src/block.js
CHANGED
|
@@ -77,6 +77,23 @@ export default class Block {
|
|
|
77
77
|
? blockData.subsections.map((block, i) => new Block(block, `${id}_${i}`, this.page))
|
|
78
78
|
: []
|
|
79
79
|
|
|
80
|
+
// Inline child blocks (from @ component references in markdown)
|
|
81
|
+
if (blockData.inlineChildren?.length > 0) {
|
|
82
|
+
const start = this.childBlocks.length
|
|
83
|
+
for (let i = 0; i < blockData.inlineChildren.length; i++) {
|
|
84
|
+
const ref = blockData.inlineChildren[i]
|
|
85
|
+
const child = new Block(
|
|
86
|
+
{ type: ref.type, params: ref.params || {}, content: {}, stableId: ref.refId },
|
|
87
|
+
`${id}_${start + i}`,
|
|
88
|
+
this.page
|
|
89
|
+
)
|
|
90
|
+
child.inline = true
|
|
91
|
+
child.refId = ref.refId
|
|
92
|
+
child.alt = ref.alt || ''
|
|
93
|
+
this.childBlocks.push(child)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
80
97
|
// Fetch configuration (from section frontmatter)
|
|
81
98
|
// Supports local files (path) or remote URLs (url)
|
|
82
99
|
this.fetch = blockData.fetch || null
|
|
@@ -265,6 +282,15 @@ export default class Block {
|
|
|
265
282
|
return this.properties
|
|
266
283
|
}
|
|
267
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Get an inline child block by its refId
|
|
287
|
+
* @param {string} refId - The reference ID (e.g., 'inline_0')
|
|
288
|
+
* @returns {Block|null}
|
|
289
|
+
*/
|
|
290
|
+
getInlineChild(refId) {
|
|
291
|
+
return this.childBlocks.find(c => c.refId === refId) || null
|
|
292
|
+
}
|
|
293
|
+
|
|
268
294
|
/**
|
|
269
295
|
* Get child block renderer from runtime
|
|
270
296
|
*/
|
package/src/uniweb.js
CHANGED
|
@@ -62,9 +62,9 @@ export default class Uniweb {
|
|
|
62
62
|
setFoundation(foundation) {
|
|
63
63
|
this.foundation = foundation
|
|
64
64
|
|
|
65
|
-
// Store per-component metadata if present
|
|
66
|
-
if (foundation.meta) {
|
|
67
|
-
this.meta = foundation.meta
|
|
65
|
+
// Store per-component metadata if present (lives under default export)
|
|
66
|
+
if (foundation.default?.meta) {
|
|
67
|
+
this.meta = foundation.default.meta
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -73,7 +73,7 @@ export default class Uniweb {
|
|
|
73
73
|
* @param {Object} foundation - The loaded ESM extension module
|
|
74
74
|
*/
|
|
75
75
|
registerExtension(foundation) {
|
|
76
|
-
const meta = foundation.meta || {}
|
|
76
|
+
const meta = foundation.default?.meta || {}
|
|
77
77
|
this.extensions.push({ foundation, meta })
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -114,13 +114,13 @@ export default class Uniweb {
|
|
|
114
114
|
return undefined
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
// Primary foundation first
|
|
118
|
-
const primary = this.foundation
|
|
117
|
+
// Primary foundation first (components are named exports)
|
|
118
|
+
const primary = this.foundation[name]
|
|
119
119
|
if (primary) return primary
|
|
120
120
|
|
|
121
121
|
// Fall through to extensions (declared order)
|
|
122
122
|
for (const ext of this.extensions) {
|
|
123
|
-
const component = ext.foundation
|
|
123
|
+
const component = ext.foundation[name]
|
|
124
124
|
if (component) return component
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -134,17 +134,15 @@ export default class Uniweb {
|
|
|
134
134
|
listComponents() {
|
|
135
135
|
const names = new Set()
|
|
136
136
|
|
|
137
|
-
if (this.foundation
|
|
138
|
-
for (const name of Object.keys(this.foundation
|
|
139
|
-
names.add(name)
|
|
137
|
+
if (this.foundation) {
|
|
138
|
+
for (const name of Object.keys(this.foundation)) {
|
|
139
|
+
if (name !== 'default') names.add(name)
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
for (const ext of this.extensions) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
names.add(name)
|
|
147
|
-
}
|
|
144
|
+
for (const name of Object.keys(ext.foundation)) {
|
|
145
|
+
if (name !== 'default') names.add(name)
|
|
148
146
|
}
|
|
149
147
|
}
|
|
150
148
|
|