@uniweb/build 0.10.2 → 0.10.3
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 +4 -4
- package/src/runtime-schema.js +57 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"@uniweb/theming": "0.1.3"
|
|
58
58
|
},
|
|
59
59
|
"optionalDependencies": {
|
|
60
|
+
"@uniweb/runtime": "0.8.3",
|
|
60
61
|
"@uniweb/content-reader": "1.1.4",
|
|
61
|
-
"@uniweb/schemas": "0.2.1"
|
|
62
|
-
"@uniweb/runtime": "0.8.2"
|
|
62
|
+
"@uniweb/schemas": "0.2.1"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@tailwindcss/vite": "^4.0.0",
|
|
69
69
|
"@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
|
|
70
70
|
"vite-plugin-svgr": "^4.0.0",
|
|
71
|
-
"@uniweb/core": "0.7.
|
|
71
|
+
"@uniweb/core": "0.7.2"
|
|
72
72
|
},
|
|
73
73
|
"peerDependenciesMeta": {
|
|
74
74
|
"vite": {
|
package/src/runtime-schema.js
CHANGED
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
* for the visual editor.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
+
import { isRichSchema } from '@uniweb/core'
|
|
31
|
+
|
|
30
32
|
/**
|
|
31
33
|
* Parse data string into structured object
|
|
32
34
|
* 'events' -> { type: 'events', limit: null }
|
|
@@ -119,7 +121,10 @@ function extractSchemaFields(schemaFields) {
|
|
|
119
121
|
|
|
120
122
|
/**
|
|
121
123
|
* Check if a schema value is in the full @uniweb/schemas format
|
|
122
|
-
* Full format has: { name, version?, description?, fields: {...} }
|
|
124
|
+
* Full format has: { name, version?, description?, fields: { fieldName: fieldDef, ... } }
|
|
125
|
+
*
|
|
126
|
+
* The distinguishing feature is that `fields` is a *keyed object*, not an array.
|
|
127
|
+
* (A rich form schema also has `fields`, but as an array.)
|
|
123
128
|
*
|
|
124
129
|
* @param {Object} schema - Schema value to check
|
|
125
130
|
* @returns {boolean}
|
|
@@ -129,10 +134,52 @@ function isFullSchemaFormat(schema) {
|
|
|
129
134
|
schema &&
|
|
130
135
|
typeof schema === 'object' &&
|
|
131
136
|
typeof schema.fields === 'object' &&
|
|
132
|
-
schema.fields !== null
|
|
137
|
+
schema.fields !== null &&
|
|
138
|
+
!Array.isArray(schema.fields)
|
|
133
139
|
)
|
|
134
140
|
}
|
|
135
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Pass a rich form schema through with minimal normalization.
|
|
144
|
+
*
|
|
145
|
+
* Rich schemas are passed to the editor (for FormBlock UI rendering) and to
|
|
146
|
+
* the runtime (for default application). We keep all authored metadata so the
|
|
147
|
+
* editor has what it needs; we do not strip editor-only fields here because
|
|
148
|
+
* the same schema feeds both audiences.
|
|
149
|
+
*
|
|
150
|
+
* Normalizations:
|
|
151
|
+
* - `type: 'string'` → `type: 'text'` (legacy alias; warn in dev)
|
|
152
|
+
*
|
|
153
|
+
* @param {Object} schema - Rich schema as authored
|
|
154
|
+
* @returns {Object} - Normalized rich schema
|
|
155
|
+
*/
|
|
156
|
+
function normalizeRichSchema(schema) {
|
|
157
|
+
return normalizeRichSchemaValue(schema)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function normalizeRichSchemaValue(value) {
|
|
161
|
+
if (Array.isArray(value)) {
|
|
162
|
+
return value.map(normalizeRichSchemaValue)
|
|
163
|
+
}
|
|
164
|
+
if (!value || typeof value !== 'object') return value
|
|
165
|
+
const out = {}
|
|
166
|
+
for (const [key, v] of Object.entries(value)) {
|
|
167
|
+
if (key === 'type' && v === 'string') {
|
|
168
|
+
if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {
|
|
169
|
+
console.warn(
|
|
170
|
+
"[uniweb] form schema field type 'string' is a legacy alias; use 'text' instead."
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
out[key] = 'text'
|
|
174
|
+
} else if (v && typeof v === 'object') {
|
|
175
|
+
out[key] = normalizeRichSchemaValue(v)
|
|
176
|
+
} else {
|
|
177
|
+
out[key] = v
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return out
|
|
181
|
+
}
|
|
182
|
+
|
|
136
183
|
/**
|
|
137
184
|
* Extract lean schemas from meta.js schemas object
|
|
138
185
|
* Strips editor-only fields while preserving structure
|
|
@@ -151,6 +198,13 @@ function extractSchemas(schemas) {
|
|
|
151
198
|
|
|
152
199
|
const lean = {}
|
|
153
200
|
for (const [schemaName, schemaValue] of Object.entries(schemas)) {
|
|
201
|
+
// Rich form schemas: pass through (with normalization). They drive both
|
|
202
|
+
// the FormBlock editor UI and the runtime default application.
|
|
203
|
+
if (isRichSchema(schemaValue)) {
|
|
204
|
+
lean[schemaName] = normalizeRichSchema(schemaValue)
|
|
205
|
+
continue
|
|
206
|
+
}
|
|
207
|
+
|
|
154
208
|
// Handle full schema format (from @uniweb/schemas or npm packages)
|
|
155
209
|
// Extract just the fields, discard name/version/description metadata
|
|
156
210
|
const schemaFields = isFullSchemaFormat(schemaValue)
|
|
@@ -166,6 +220,7 @@ function extractSchemas(schemas) {
|
|
|
166
220
|
return Object.keys(lean).length > 0 ? lean : null
|
|
167
221
|
}
|
|
168
222
|
|
|
223
|
+
|
|
169
224
|
/**
|
|
170
225
|
* Extract param defaults from params object
|
|
171
226
|
*
|