@uniweb/runtime 0.2.12 → 0.2.13

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.12",
3
+ "version": "0.2.13",
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.11"
32
+ "@uniweb/core": "0.1.12"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.0.0 || ^19.0.0",
@@ -85,15 +85,15 @@ export default function BlockRenderer({ block, pure = false, extra = {} }) {
85
85
 
86
86
  // Build content and params with runtime guarantees
87
87
  // Sources:
88
- // 1. parsedContent.raw - simple PoC format (hardcoded content)
89
- // 2. parsedContent - semantic parser output (main.header, main.body, items, etc.)
88
+ // 1. parsedContent._isPoc - simple PoC format (hardcoded content)
89
+ // 2. parsedContent - semantic parser output (flat: title, paragraphs, links, etc.)
90
90
  // 3. block.properties - params from frontmatter (theme, alignment, etc.)
91
91
  // 4. meta - defaults from component meta.js
92
92
  let content, params
93
93
 
94
- if (block.parsedContent?.raw) {
94
+ if (block.parsedContent?._isPoc) {
95
95
  // Simple PoC format - content was passed directly
96
- content = block.parsedContent.raw
96
+ content = block.parsedContent._pocContent
97
97
  params = block.properties
98
98
  } else {
99
99
  // Get runtime metadata for this component (has defaults, data binding, etc.)
@@ -8,36 +8,75 @@
8
8
  * This enables simpler component code by ensuring predictable prop shapes.
9
9
  */
10
10
 
11
+ /**
12
+ * Guarantee item has flat content structure
13
+ *
14
+ * @param {Object} item - Raw item from parser
15
+ * @returns {Object} Item with guaranteed flat structure
16
+ */
17
+ function guaranteeItemStructure(item) {
18
+ return {
19
+ title: item.title || '',
20
+ pretitle: item.pretitle || '',
21
+ subtitle: item.subtitle || '',
22
+ paragraphs: item.paragraphs || [],
23
+ links: item.links || [],
24
+ imgs: item.imgs || [],
25
+ lists: item.lists || [],
26
+ icons: item.icons || [],
27
+ videos: item.videos || [],
28
+ buttons: item.buttons || [],
29
+ properties: item.properties || {},
30
+ cards: item.cards || [],
31
+ documents: item.documents || [],
32
+ forms: item.forms || [],
33
+ quotes: item.quotes || [],
34
+ headings: item.headings || [],
35
+ }
36
+ }
37
+
11
38
  /**
12
39
  * Guarantee content structure exists
13
- * Returns a content object with all standard paths guaranteed to exist
40
+ * Returns a flat content object with all standard fields guaranteed to exist
14
41
  *
15
- * @param {Object} parsedContent - Raw parsed content from semantic parser
16
- * @returns {Object} Content with guaranteed structure
42
+ * @param {Object} parsedContent - Raw parsed content from semantic parser (flat structure)
43
+ * @returns {Object} Content with guaranteed flat structure
17
44
  */
18
45
  export function guaranteeContentStructure(parsedContent) {
19
46
  const content = parsedContent || {}
20
47
 
21
48
  return {
22
- // Main content section
23
- main: {
24
- header: {
25
- title: content.main?.header?.title || '',
26
- pretitle: content.main?.header?.pretitle || '',
27
- subtitle: content.main?.header?.subtitle || '',
28
- },
29
- body: {
30
- paragraphs: content.main?.body?.paragraphs || [],
31
- links: content.main?.body?.links || [],
32
- imgs: content.main?.body?.imgs || [],
33
- lists: content.main?.body?.lists || [],
34
- icons: content.main?.body?.icons || [],
35
- },
36
- },
37
- // Content items (H3 sections)
38
- items: content.items || [],
39
- // Preserve any additional fields from parser
40
- ...content,
49
+ // Flat header fields
50
+ title: content.title || '',
51
+ pretitle: content.pretitle || '',
52
+ subtitle: content.subtitle || '',
53
+ subtitle2: content.subtitle2 || '',
54
+ alignment: content.alignment || null,
55
+
56
+ // Flat body fields
57
+ paragraphs: content.paragraphs || [],
58
+ links: content.links || [],
59
+ imgs: content.imgs || [],
60
+ lists: content.lists || [],
61
+ icons: content.icons || [],
62
+ videos: content.videos || [],
63
+ buttons: content.buttons || [],
64
+ properties: content.properties || {},
65
+ propertyBlocks: content.propertyBlocks || [],
66
+ cards: content.cards || [],
67
+ documents: content.documents || [],
68
+ forms: content.forms || [],
69
+ quotes: content.quotes || [],
70
+ headings: content.headings || [],
71
+
72
+ // Items with guaranteed structure
73
+ items: (content.items || []).map(guaranteeItemStructure),
74
+
75
+ // Sequence for ordered rendering
76
+ sequence: content.sequence || [],
77
+
78
+ // Preserve raw content if present
79
+ raw: content.raw,
41
80
  }
42
81
  }
43
82