@uniweb/build 0.8.0 → 0.8.1

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/build",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Build tooling for the Uniweb Component Web Platform",
5
5
  "type": "module",
6
6
  "exports": {
@@ -50,9 +50,9 @@
50
50
  "sharp": "^0.33.2"
51
51
  },
52
52
  "optionalDependencies": {
53
- "@uniweb/content-reader": "1.1.2",
54
- "@uniweb/schemas": "0.2.1",
55
- "@uniweb/runtime": "0.6.1"
53
+ "@uniweb/content-reader": "1.1.3",
54
+ "@uniweb/runtime": "0.6.1",
55
+ "@uniweb/schemas": "0.2.1"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
@@ -61,7 +61,7 @@
61
61
  "@tailwindcss/vite": "^4.0.0",
62
62
  "@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
63
63
  "vite-plugin-svgr": "^4.0.0",
64
- "@uniweb/core": "0.5.1"
64
+ "@uniweb/core": "0.5.2"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "vite": {
@@ -190,6 +190,11 @@ export function extractRuntimeSchema(fullMeta) {
190
190
 
191
191
  const runtime = {}
192
192
 
193
+ // Embed flag: signals this component is designed for inline embedding via @ refs
194
+ if (fullMeta.embed) {
195
+ runtime.embed = true
196
+ }
197
+
193
198
  // Background opt-out: 'self' means the component renders its own background
194
199
  // layer (solid colors, insets, effects), so the runtime skips its Background.
195
200
  if (fullMeta.background) {
@@ -178,6 +178,45 @@ async function readYamlFile(filePath) {
178
178
  }
179
179
  }
180
180
 
181
+ /**
182
+ * Extract inline child references from a ProseMirror document.
183
+ *
184
+ * Walks top-level nodes for `inline_child_ref` (produced by content-reader
185
+ * for `![alt](@ComponentName){params}` syntax). Each ref is removed from the
186
+ * document and replaced with an `inline_child_placeholder` node carrying a
187
+ * unique refId. The extracted refs are returned as an array.
188
+ *
189
+ * @param {Object} doc - ProseMirror document (mutated in place)
190
+ * @returns {Array} Array of { refId, type, params, alt }
191
+ */
192
+ function extractInlineChildren(doc) {
193
+ if (!doc?.content || !Array.isArray(doc.content)) return []
194
+
195
+ const inlineChildren = []
196
+ let refIndex = 0
197
+
198
+ for (let i = 0; i < doc.content.length; i++) {
199
+ const node = doc.content[i]
200
+ if (node.type === 'inline_child_ref') {
201
+ const { component, alt, ...params } = node.attrs || {}
202
+ const refId = `inline_${refIndex++}`
203
+ inlineChildren.push({
204
+ refId,
205
+ type: component,
206
+ params: Object.keys(params).length > 0 ? params : {},
207
+ alt: alt || null,
208
+ })
209
+ // Replace in-place with placeholder
210
+ doc.content[i] = {
211
+ type: 'inline_child_placeholder',
212
+ attrs: { refId },
213
+ }
214
+ }
215
+ }
216
+
217
+ return inlineChildren
218
+ }
219
+
181
220
  /**
182
221
  * Check if a file is a markdown file that should be processed.
183
222
  * Excludes:
@@ -579,6 +618,9 @@ async function processMarkdownFile(filePath, id, siteRoot, defaultStableId = nul
579
618
  // Convert markdown to ProseMirror
580
619
  const proseMirrorContent = markdownToProseMirror(markdown)
581
620
 
621
+ // Extract @ component references → inline children (mutates doc)
622
+ const inlineChildren = extractInlineChildren(proseMirrorContent)
623
+
582
624
  // Support 'data:' shorthand for collection fetch
583
625
  // data: team → fetch: { collection: team }
584
626
  // data: [team, articles] → fetch: { collection: team } (first item, others via inheritData)
@@ -601,6 +643,7 @@ async function processMarkdownFile(filePath, id, siteRoot, defaultStableId = nul
601
643
  params: { ...params, ...props },
602
644
  content: proseMirrorContent,
603
645
  fetch: parseFetchConfig(resolvedFetch),
646
+ ...(inlineChildren.length > 0 ? { inlineChildren } : {}),
604
647
  subsections: []
605
648
  }
606
649
 
@@ -1822,7 +1865,8 @@ export {
1822
1865
  extractItemName,
1823
1866
  parseWildcardArray,
1824
1867
  applyWildcardOrder,
1825
- getDirectChildName
1868
+ getDirectChildName,
1869
+ extractInlineChildren
1826
1870
  }
1827
1871
 
1828
1872
  export default collectSiteContent