@nordcraft/runtime 1.0.63 → 1.0.64
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/dist/custom-element.main.esm.js +39 -36
- package/dist/custom-element.main.esm.js.map +3 -3
- package/dist/editor-preview.main.js +23 -11
- package/dist/editor-preview.main.js.map +1 -1
- package/dist/page.main.esm.js +2 -2
- package/dist/page.main.esm.js.map +3 -3
- package/package.json +3 -3
- package/src/editor-preview.main.ts +38 -13
package/package.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://github.com/nordcraftengine/nordcraft",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@nordcraft/core": "1.0.
|
|
8
|
-
"@nordcraft/std-lib": "1.0.
|
|
7
|
+
"@nordcraft/core": "1.0.64",
|
|
8
|
+
"@nordcraft/std-lib": "1.0.64",
|
|
9
9
|
"fast-deep-equal": "3.1.3",
|
|
10
10
|
"path-to-regexp": "6.3.0"
|
|
11
11
|
},
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"files": ["dist", "src"],
|
|
22
22
|
"main": "dist/page.main.js",
|
|
23
23
|
"types": "dist/page.main.d.ts",
|
|
24
|
-
"version": "1.0.
|
|
24
|
+
"version": "1.0.64"
|
|
25
25
|
}
|
|
@@ -26,7 +26,11 @@ import {
|
|
|
26
26
|
} from '@nordcraft/core/dist/formula/formulaTypes'
|
|
27
27
|
import { appendUnit } from '@nordcraft/core/dist/styling/customProperty'
|
|
28
28
|
import type { OldTheme, Theme } from '@nordcraft/core/dist/styling/theme'
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
getThemeCss,
|
|
31
|
+
getThemeEntries,
|
|
32
|
+
renderThemeValues,
|
|
33
|
+
} from '@nordcraft/core/dist/styling/theme'
|
|
30
34
|
import type { StyleVariant } from '@nordcraft/core/dist/styling/variantSelector'
|
|
31
35
|
import type {
|
|
32
36
|
ActionHandler,
|
|
@@ -190,6 +194,7 @@ const EMPTY_COMPONENT_DATA: ComponentData = {
|
|
|
190
194
|
},
|
|
191
195
|
Attributes: {},
|
|
192
196
|
Variables: {},
|
|
197
|
+
Apis: {},
|
|
193
198
|
}
|
|
194
199
|
|
|
195
200
|
// imported by "/.toddle/preview" (see worker/src/preview.ts)
|
|
@@ -272,7 +277,11 @@ export const createRoot = (
|
|
|
272
277
|
| ReturnType<typeof getScrollStateRestorer>
|
|
273
278
|
| undefined
|
|
274
279
|
|
|
275
|
-
|
|
280
|
+
const switchComponent =
|
|
281
|
+
message.data.component.name !== component?.name
|
|
282
|
+
// Re-initialize state, subscribers, signals and ctx when switching component
|
|
283
|
+
// But only if a component was already loaded
|
|
284
|
+
if (switchComponent && component) {
|
|
276
285
|
// Store scroll state for the previous component
|
|
277
286
|
storeScrollState(component?.name)
|
|
278
287
|
// Remove all subscribers from the previous showSignal
|
|
@@ -289,6 +298,7 @@ export const createRoot = (
|
|
|
289
298
|
setupDataSignalSubscribers()
|
|
290
299
|
// Re-initialize the data signal for the new component
|
|
291
300
|
ctxDataSignal?.destroy()
|
|
301
|
+
ctx = null
|
|
292
302
|
}
|
|
293
303
|
|
|
294
304
|
component = updateComponentLinks(message.data.component)
|
|
@@ -310,7 +320,8 @@ export const createRoot = (
|
|
|
310
320
|
|
|
311
321
|
dataSignal.update((data) => {
|
|
312
322
|
const newData: ComponentData = {
|
|
313
|
-
|
|
323
|
+
// When switching component, reset data to empty API data etc.
|
|
324
|
+
...(switchComponent ? EMPTY_COMPONENT_DATA : data),
|
|
314
325
|
Location: data.Location
|
|
315
326
|
? {
|
|
316
327
|
...data.Location,
|
|
@@ -950,33 +961,47 @@ export const createRoot = (
|
|
|
950
961
|
.filter(([key]) => previewStyleStyles[key])
|
|
951
962
|
.map(([key, val]) => [
|
|
952
963
|
key,
|
|
953
|
-
{
|
|
964
|
+
{
|
|
965
|
+
...val,
|
|
966
|
+
values: {
|
|
967
|
+
...val.values,
|
|
968
|
+
[theme.key]: previewStyleStyles[key],
|
|
969
|
+
},
|
|
970
|
+
},
|
|
954
971
|
]),
|
|
955
972
|
)
|
|
956
973
|
const cssBlocks: string[] = []
|
|
957
|
-
if (theme.value.default) {
|
|
958
|
-
cssBlocks.push(
|
|
974
|
+
if (theme.key === theme.value.default) {
|
|
975
|
+
cssBlocks.push(
|
|
976
|
+
renderThemeValues(
|
|
977
|
+
`:host, :root`,
|
|
978
|
+
getThemeEntries(theme.value, theme.key),
|
|
979
|
+
),
|
|
980
|
+
)
|
|
959
981
|
}
|
|
960
|
-
if (theme.value.defaultDark) {
|
|
982
|
+
if (theme.key === theme.value.defaultDark) {
|
|
961
983
|
cssBlocks.push(
|
|
962
|
-
|
|
984
|
+
renderThemeValues(
|
|
963
985
|
`:host, :root`,
|
|
964
|
-
theme.value,
|
|
986
|
+
getThemeEntries(theme.value, theme.key),
|
|
965
987
|
'@media (prefers-color-scheme: dark)',
|
|
966
988
|
),
|
|
967
989
|
)
|
|
968
990
|
}
|
|
969
|
-
if (theme.value.defaultLight) {
|
|
991
|
+
if (theme.key === theme.value.defaultLight) {
|
|
970
992
|
cssBlocks.push(
|
|
971
|
-
|
|
993
|
+
renderThemeValues(
|
|
972
994
|
`:host, :root`,
|
|
973
|
-
theme.value,
|
|
995
|
+
getThemeEntries(theme.value, theme.key),
|
|
974
996
|
'@media (prefers-color-scheme: light)',
|
|
975
997
|
),
|
|
976
998
|
)
|
|
977
999
|
}
|
|
978
1000
|
cssBlocks.push(
|
|
979
|
-
|
|
1001
|
+
renderThemeValues(
|
|
1002
|
+
`[data-theme~="${theme.key}"]`,
|
|
1003
|
+
getThemeEntries(theme.value, theme.key),
|
|
1004
|
+
),
|
|
980
1005
|
)
|
|
981
1006
|
styleTag.innerHTML = cssBlocks.join('\n')
|
|
982
1007
|
} else {
|