@uniweb/runtime 0.1.0 → 0.1.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/README.md CHANGED
@@ -94,19 +94,24 @@ site/
94
94
 
95
95
  ### Section Markdown Format
96
96
 
97
- Each `.md` file is a section with YAML frontmatter:
97
+ Each `.md` file is a section with YAML frontmatter for configuration and markdown body for content:
98
98
 
99
99
  ```markdown
100
100
  ---
101
101
  component: Hero
102
102
  preset: default
103
- title: Welcome to Our Site
104
- subtitle: Building the future together
103
+ theme: dark
105
104
  ---
106
105
 
107
- Additional markdown content here...
106
+ # Welcome to Our Site
107
+
108
+ Building the future together.
109
+
110
+ [Get Started](#features)
108
111
  ```
109
112
 
113
+ The frontmatter specifies the component and configuration parameters. The markdown body contains the actual content, which is semantically parsed into structured data (headings → titles, paragraphs → descriptions, links → CTAs).
114
+
110
115
  ## API Reference
111
116
 
112
117
  ### Runtime Functions
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@uniweb/runtime",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Runtime loader and Vite plugins for Uniweb sites",
5
5
  "type": "module",
6
6
  "exports": {
7
- ".": "./src/index.js",
7
+ ".": "./src/index.jsx",
8
8
  "./vite": "./src/vite/index.js"
9
9
  },
10
10
  "files": [
@@ -28,16 +28,17 @@
28
28
  "url": "https://github.com/uniweb/runtime/issues"
29
29
  },
30
30
  "engines": {
31
- "node": ">=18"
31
+ "node": ">=20.19"
32
32
  },
33
33
  "dependencies": {
34
- "js-yaml": "^4.1.0"
34
+ "js-yaml": "^4.1.0",
35
+ "@uniweb/semantic-parser": "1.0.1"
35
36
  },
36
37
  "peerDependencies": {
37
38
  "react": "^18.0.0",
38
39
  "react-dom": "^18.0.0",
39
40
  "react-router-dom": "^6.0.0 || ^7.0.0",
40
- "vite": "^5.0.0 || ^6.0.0"
41
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
41
42
  },
42
43
  "peerDependenciesMeta": {
43
44
  "vite": {
@@ -45,6 +46,6 @@
45
46
  }
46
47
  },
47
48
  "optionalDependencies": {
48
- "@uniwebcms/content-reader": "^0.1.0"
49
+ "@uniweb/content-reader": "1.0.1"
49
50
  }
50
- }
51
+ }
@@ -86,18 +86,21 @@ export default function BlockRenderer({ block, pure = false, extra = {} }) {
86
86
  // Components expect content as a simple object with all data
87
87
  // Sources:
88
88
  // 1. parsedContent.raw - simple PoC format (hardcoded content)
89
- // 2. block.properties - params from frontmatter (title, subtitle, features, etc.)
90
- // 3. parsedContent - full ProseMirror structure (markdown body)
89
+ // 2. parsedContent - semantic parser output (main.header, main.body, items, etc.)
90
+ // 3. block.properties - params from frontmatter (theme, alignment, etc.)
91
91
  let content
92
92
 
93
93
  if (block.parsedContent?.raw) {
94
94
  // Simple PoC format - content was passed directly
95
95
  content = block.parsedContent.raw
96
96
  } else {
97
- // Collected content - merge params (frontmatter) with parsed content
97
+ // Collected content - merge parsed content with frontmatter params
98
+ // Parsed content goes first so components can access content.main.header, etc.
99
+ // Frontmatter params overlay for things like content.title from YAML
98
100
  content = {
99
- ...block.properties, // Frontmatter data (title, subtitle, features, items, etc.)
100
- _prosemirror: block.parsedContent // Keep ProseMirror for components that need it
101
+ ...block.parsedContent, // Semantic parser output (main, items, etc.)
102
+ ...block.properties, // Frontmatter params overlay
103
+ _prosemirror: block.parsedContent // Keep original for components that need raw access
101
104
  }
102
105
  }
103
106
 
package/src/core/block.js CHANGED
@@ -5,6 +5,8 @@
5
5
  * child blocks, and state management. Connects to foundation components.
6
6
  */
7
7
 
8
+ import { parseContent as parseSemanticContent } from '@uniweb/semantic-parser'
9
+
8
10
  export default class Block {
9
11
  constructor(blockData, id) {
10
12
  this.id = id
@@ -45,13 +47,17 @@ export default class Block {
45
47
  }
46
48
 
47
49
  /**
48
- * Parse content into structured format
50
+ * Parse content into structured format using semantic-parser
49
51
  * Supports multiple content formats:
50
- * 1. Pre-parsed groups structure
51
- * 2. ProseMirror document
52
+ * 1. Pre-parsed groups structure (from editor)
53
+ * 2. ProseMirror document (from markdown collection)
52
54
  * 3. Simple key-value content (PoC style)
53
55
  *
54
- * TODO: Integrate @uniwebcms/semantic-parser for full parsing
56
+ * Uses @uniweb/semantic-parser for rich content extraction including:
57
+ * - Pretitle detection (H3 before H1)
58
+ * - Banner/background image detection
59
+ * - Semantic grouping (main + items)
60
+ * - Lists, links, buttons, etc.
55
61
  */
56
62
  parseContent(content) {
57
63
  // If content is already parsed with groups structure
@@ -59,7 +65,7 @@ export default class Block {
59
65
  return content.groups
60
66
  }
61
67
 
62
- // ProseMirror document
68
+ // ProseMirror document - use semantic-parser
63
69
  if (content?.type === 'doc') {
64
70
  return this.extractFromProseMirror(content)
65
71
  }
@@ -83,10 +89,36 @@ export default class Block {
83
89
  }
84
90
 
85
91
  /**
86
- * Basic extraction from ProseMirror content
87
- * This is simplified - full implementation uses semantic-parser
92
+ * Extract structured content from ProseMirror document
93
+ * Uses @uniweb/semantic-parser for intelligent content extraction
88
94
  */
89
95
  extractFromProseMirror(doc) {
96
+ try {
97
+ // Parse with semantic-parser
98
+ const { groups, sequence, byType } = parseSemanticContent(doc)
99
+
100
+ // Transform groups structure to match expected format
101
+ const main = groups.main || { header: {}, body: {} }
102
+ const items = groups.items || []
103
+
104
+ return {
105
+ main,
106
+ items,
107
+ // Include additional data for advanced use cases
108
+ sequence,
109
+ byType,
110
+ metadata: groups.metadata
111
+ }
112
+ } catch (err) {
113
+ console.warn('[Block] Semantic parser error, using fallback:', err.message)
114
+ return this.extractFromProseMirrorFallback(doc)
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Fallback extraction when semantic-parser fails
120
+ */
121
+ extractFromProseMirrorFallback(doc) {
90
122
  const main = { header: {}, body: {} }
91
123
  const items = []
92
124
 
@@ -7,7 +7,7 @@
7
7
  * - page.yml: Page metadata
8
8
  * - *.md: Section content with YAML frontmatter
9
9
  *
10
- * Uses @uniwebcms/content-reader for markdown → ProseMirror conversion
10
+ * Uses @uniweb/content-reader for markdown → ProseMirror conversion
11
11
  * when available, otherwise uses a simplified parser.
12
12
  */
13
13
 
@@ -19,7 +19,7 @@ import yaml from 'js-yaml'
19
19
  // Try to import content-reader, fall back to simplified parser
20
20
  let markdownToProseMirror
21
21
  try {
22
- const contentReader = await import('@uniwebcms/content-reader')
22
+ const contentReader = await import('@uniweb/content-reader')
23
23
  markdownToProseMirror = contentReader.markdownToProseMirror
24
24
  } catch {
25
25
  // Simplified fallback - just wraps content as text
File without changes