@uniweb/core 0.5.8 → 0.5.10
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/analytics.js +5 -0
- package/src/block.js +12 -29
- package/src/datastore.js +2 -0
- package/src/entity-store.js +2 -0
- package/src/page.js +2 -0
- package/src/theme.js +2 -0
- package/src/uniweb.js +2 -0
- package/src/website.js +8 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
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.6"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
package/src/analytics.js
CHANGED
|
@@ -48,11 +48,16 @@ export default class Analytics {
|
|
|
48
48
|
this.sessionId = this.generateSessionId()
|
|
49
49
|
this.sessionStart = Date.now()
|
|
50
50
|
|
|
51
|
+
// Flush interval ID (for cleanup)
|
|
52
|
+
this.flushIntervalId = null
|
|
53
|
+
|
|
51
54
|
// Only set up browser handlers if in browser and configured
|
|
52
55
|
if (isBrowser && this.isEnabled()) {
|
|
53
56
|
this.setupFlushInterval()
|
|
54
57
|
this.setupUnloadHandler()
|
|
55
58
|
}
|
|
59
|
+
|
|
60
|
+
Object.seal(this)
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/**
|
package/src/block.js
CHANGED
|
@@ -106,19 +106,18 @@ export default class Block {
|
|
|
106
106
|
if (insetData?.length > 0) {
|
|
107
107
|
for (let i = 0; i < insetData.length; i++) {
|
|
108
108
|
const ref = insetData[i]
|
|
109
|
-
const
|
|
109
|
+
const title = ref.title || ''
|
|
110
110
|
const child = new Block(
|
|
111
111
|
{
|
|
112
112
|
type: ref.type,
|
|
113
113
|
params: ref.params || {},
|
|
114
|
-
content: { title
|
|
114
|
+
content: { title },
|
|
115
115
|
stableId: ref.refId,
|
|
116
|
+
refId: ref.refId,
|
|
116
117
|
},
|
|
117
118
|
`${id}_inset_${i}`,
|
|
118
119
|
this.page
|
|
119
120
|
)
|
|
120
|
-
child.inline = true
|
|
121
|
-
child.refId = ref.refId
|
|
122
121
|
this.insets.push(child)
|
|
123
122
|
}
|
|
124
123
|
}
|
|
@@ -131,6 +130,13 @@ export default class Block {
|
|
|
131
130
|
// Components check this to show loading UI (spinners, skeletons)
|
|
132
131
|
this.dataLoading = false
|
|
133
132
|
|
|
133
|
+
// Whether engine-level background is active (set by BlockRenderer/prerender)
|
|
134
|
+
// Components check this to skip their own opaque background
|
|
135
|
+
this.hasBackground = false
|
|
136
|
+
|
|
137
|
+
// Inset identity — set on inset blocks for lookup via getInset()
|
|
138
|
+
this.refId = blockData.refId || null
|
|
139
|
+
|
|
134
140
|
// Dynamic route context (params from URL matching)
|
|
135
141
|
// Set when accessing a dynamic page like /blog/:slug -> /blog/my-post
|
|
136
142
|
this.dynamicContext = blockData.dynamicContext || null
|
|
@@ -142,6 +148,8 @@ export default class Block {
|
|
|
142
148
|
|
|
143
149
|
// Context (static, defined per component type)
|
|
144
150
|
this.context = null
|
|
151
|
+
|
|
152
|
+
Object.seal(this)
|
|
145
153
|
}
|
|
146
154
|
|
|
147
155
|
/**
|
|
@@ -279,31 +287,6 @@ export default class Block {
|
|
|
279
287
|
return this.Component
|
|
280
288
|
}
|
|
281
289
|
|
|
282
|
-
/**
|
|
283
|
-
* Get structured block content for components
|
|
284
|
-
* Returns flat content structure
|
|
285
|
-
*/
|
|
286
|
-
getBlockContent() {
|
|
287
|
-
const c = this.parsedContent || {}
|
|
288
|
-
|
|
289
|
-
return {
|
|
290
|
-
pretitle: c.pretitle || '',
|
|
291
|
-
title: c.title || '',
|
|
292
|
-
subtitle: c.subtitle || '',
|
|
293
|
-
description: c.subtitle2 || '',
|
|
294
|
-
paragraphs: c.paragraphs || [],
|
|
295
|
-
images: c.images || [],
|
|
296
|
-
links: c.links || [],
|
|
297
|
-
icons: c.icons || [],
|
|
298
|
-
properties: c.propertyBlocks?.[0] || c.properties || {},
|
|
299
|
-
videos: c.videos || [],
|
|
300
|
-
lists: c.lists || [],
|
|
301
|
-
buttons: c.buttons || [],
|
|
302
|
-
items: c.items || [],
|
|
303
|
-
data: c.data || {}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
290
|
/**
|
|
308
291
|
* Get block properties
|
|
309
292
|
*/
|
package/src/datastore.js
CHANGED
package/src/entity-store.js
CHANGED
package/src/page.js
CHANGED
package/src/theme.js
CHANGED
package/src/uniweb.js
CHANGED
package/src/website.js
CHANGED
|
@@ -74,7 +74,7 @@ export default class Website {
|
|
|
74
74
|
|
|
75
75
|
// Legacy language support (for editor multilingual)
|
|
76
76
|
this.activeLang = this.activeLocale
|
|
77
|
-
this.langs =
|
|
77
|
+
this.langs = this.locales.map(l => ({
|
|
78
78
|
label: l.label || l.code,
|
|
79
79
|
value: l.code
|
|
80
80
|
}))
|
|
@@ -94,6 +94,8 @@ export default class Website {
|
|
|
94
94
|
// Versioned scopes: route → { versions, latestId }
|
|
95
95
|
// Scopes are routes where versioning starts (e.g., '/docs')
|
|
96
96
|
this.versionedScopes = versionedScopes
|
|
97
|
+
|
|
98
|
+
Object.seal(this)
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/**
|
|
@@ -105,7 +107,7 @@ export default class Website {
|
|
|
105
107
|
*/
|
|
106
108
|
buildLocalesList(config) {
|
|
107
109
|
const defaultLocale = config.defaultLanguage || 'en'
|
|
108
|
-
const
|
|
110
|
+
const languages = config.languages || []
|
|
109
111
|
|
|
110
112
|
// Normalize input: convert strings to objects, keep objects as-is
|
|
111
113
|
const normalizeLocale = (locale) => {
|
|
@@ -116,14 +118,14 @@ export default class Website {
|
|
|
116
118
|
return { code: locale.code, ...(locale.label && { label: locale.label }) }
|
|
117
119
|
}
|
|
118
120
|
|
|
119
|
-
// Start with default locale (may not be in
|
|
121
|
+
// Start with default locale (may not be in languages list)
|
|
120
122
|
const localeMap = new Map()
|
|
121
123
|
localeMap.set(defaultLocale, { code: defaultLocale })
|
|
122
124
|
|
|
123
|
-
// Add
|
|
124
|
-
for (const locale of
|
|
125
|
+
// Add configured languages (may include objects with labels)
|
|
126
|
+
for (const locale of languages) {
|
|
125
127
|
const normalized = normalizeLocale(locale)
|
|
126
|
-
// Merge with existing (to preserve labels if default locale also in
|
|
128
|
+
// Merge with existing (to preserve labels if default locale also in languages with label)
|
|
127
129
|
if (localeMap.has(normalized.code)) {
|
|
128
130
|
const existing = localeMap.get(normalized.code)
|
|
129
131
|
localeMap.set(normalized.code, { ...existing, ...normalized })
|