@nordcraft/runtime 1.0.74 → 1.0.75
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/components/createComponent.js +3 -3
- package/dist/components/createComponent.js.map +1 -1
- package/dist/components/createElement.js +1 -1
- package/dist/components/createElement.js.map +1 -1
- package/dist/components/renderComponent.js +2 -2
- package/dist/components/renderComponent.js.map +1 -1
- package/dist/custom-element.main.esm.js +13 -13
- package/dist/custom-element.main.esm.js.map +3 -3
- package/dist/editor/types.d.ts +4 -0
- package/dist/editor/types.js.map +1 -1
- package/dist/editor-preview.main.js +29 -10
- package/dist/editor-preview.main.js.map +1 -1
- package/dist/page.main.esm.js +3 -3
- package/dist/page.main.esm.js.map +3 -3
- package/package.json +3 -3
- package/src/components/createComponent.ts +3 -3
- package/src/components/createElement.ts +1 -1
- package/src/components/renderComponent.ts +2 -2
- package/src/editor/types.ts +4 -0
- package/src/editor-preview.main.ts +39 -10
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.75",
|
|
8
|
+
"@nordcraft/std-lib": "1.0.75",
|
|
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.75"
|
|
25
25
|
}
|
|
@@ -198,7 +198,7 @@ export function createComponent({
|
|
|
198
198
|
(e) => e.trigger === eventTrigger,
|
|
199
199
|
)
|
|
200
200
|
if (eventHandler) {
|
|
201
|
-
eventHandler.actions
|
|
201
|
+
eventHandler.actions?.forEach((action) =>
|
|
202
202
|
handleAction(action, { ...dataSignal.get(), Event: data }, ctx),
|
|
203
203
|
)
|
|
204
204
|
}
|
|
@@ -221,7 +221,7 @@ export function createComponent({
|
|
|
221
221
|
(e) => e.trigger === eventTrigger,
|
|
222
222
|
)
|
|
223
223
|
if (eventHandler) {
|
|
224
|
-
eventHandler.actions
|
|
224
|
+
eventHandler.actions?.forEach((action) =>
|
|
225
225
|
handleAction(action, { ...dataSignal.get(), Event: data }, ctx),
|
|
226
226
|
)
|
|
227
227
|
}
|
|
@@ -242,7 +242,7 @@ export function createComponent({
|
|
|
242
242
|
(e) => e.trigger === eventTrigger,
|
|
243
243
|
)
|
|
244
244
|
if (eventHandler) {
|
|
245
|
-
eventHandler.actions
|
|
245
|
+
eventHandler.actions?.forEach((action) =>
|
|
246
246
|
handleAction(action, { ...dataSignal.get(), Event: data }, ctx),
|
|
247
247
|
)
|
|
248
248
|
}
|
|
@@ -105,7 +105,7 @@ export function renderComponent({
|
|
|
105
105
|
.map((data) => data.Attributes)
|
|
106
106
|
.subscribe((props) => {
|
|
107
107
|
if (prev) {
|
|
108
|
-
component.onAttributeChange?.actions
|
|
108
|
+
component.onAttributeChange?.actions?.forEach((action) => {
|
|
109
109
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
110
110
|
handleAction(
|
|
111
111
|
action,
|
|
@@ -137,7 +137,7 @@ export function renderComponent({
|
|
|
137
137
|
prev = props
|
|
138
138
|
})
|
|
139
139
|
}
|
|
140
|
-
component.onLoad?.actions
|
|
140
|
+
component.onLoad?.actions?.forEach((action) => {
|
|
141
141
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
142
142
|
handleAction(action, dataSignal.get(), ctx)
|
|
143
143
|
})
|
package/src/editor/types.ts
CHANGED
|
@@ -913,24 +913,53 @@ export const createRoot = (
|
|
|
913
913
|
})
|
|
914
914
|
break
|
|
915
915
|
case 'preview_style':
|
|
916
|
-
const { styles: previewStyleStyles, theme } = message.data
|
|
916
|
+
const { styles: previewStyleStyles, theme, resources } = message.data
|
|
917
917
|
cancelAnimationFrame(previewStyleAnimationFrame)
|
|
918
918
|
previewStyleAnimationFrame = requestAnimationFrame(() => {
|
|
919
|
+
// Allow for temporarily adding preview resources (e.g. fonts).
|
|
920
|
+
const resourceElements = Array.from(
|
|
921
|
+
document.head.querySelectorAll('[data-id="preview-resource"]'),
|
|
922
|
+
)
|
|
923
|
+
// Remove any resources that are no longer needed
|
|
924
|
+
resourceElements.forEach((el) => {
|
|
925
|
+
if (
|
|
926
|
+
!resources ||
|
|
927
|
+
resources.length === 0 ||
|
|
928
|
+
!resources.some((res) => res.href === el.getAttribute('href'))
|
|
929
|
+
) {
|
|
930
|
+
el.remove()
|
|
931
|
+
}
|
|
932
|
+
})
|
|
933
|
+
resources
|
|
934
|
+
?.filter(
|
|
935
|
+
(resource) =>
|
|
936
|
+
!resourceElements.some(
|
|
937
|
+
(el) => el.getAttribute('href') === resource.href,
|
|
938
|
+
),
|
|
939
|
+
)
|
|
940
|
+
.forEach((resource) => {
|
|
941
|
+
const resourceElement = document.createElement('link')
|
|
942
|
+
resourceElement.setAttribute('data-id', 'preview-resource')
|
|
943
|
+
resourceElement.rel = 'stylesheet'
|
|
944
|
+
resourceElement.href = resource.href
|
|
945
|
+
document.head.appendChild(resourceElement)
|
|
946
|
+
})
|
|
947
|
+
|
|
919
948
|
// Update or create a new style tag and set the given styles with important priority
|
|
920
|
-
let
|
|
949
|
+
let styleElement = document.head.querySelector(
|
|
921
950
|
'[data-id="selected-node-styles"]',
|
|
922
951
|
)
|
|
923
952
|
|
|
924
953
|
// Cleanup when null styles are sent
|
|
925
954
|
if (!previewStyleStyles) {
|
|
926
|
-
|
|
955
|
+
styleElement?.remove()
|
|
927
956
|
return
|
|
928
957
|
}
|
|
929
958
|
|
|
930
|
-
if (!
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
document.head.appendChild(
|
|
959
|
+
if (!styleElement) {
|
|
960
|
+
styleElement = document.createElement('style')
|
|
961
|
+
styleElement.setAttribute('data-id', 'selected-node-styles')
|
|
962
|
+
document.head.appendChild(styleElement)
|
|
934
963
|
}
|
|
935
964
|
|
|
936
965
|
// If style variant targets a pseudo-element, apply styles to it instead
|
|
@@ -1003,12 +1032,12 @@ export const createRoot = (
|
|
|
1003
1032
|
getThemeEntries(theme.value, theme.key),
|
|
1004
1033
|
),
|
|
1005
1034
|
)
|
|
1006
|
-
|
|
1035
|
+
styleElement.innerHTML = cssBlocks.join('\n')
|
|
1007
1036
|
} else {
|
|
1008
1037
|
const previewStyles = Object.entries(previewStyleStyles)
|
|
1009
1038
|
.map(([key, value]) => `${key}: ${value} !important;`)
|
|
1010
1039
|
.join('\n')
|
|
1011
|
-
|
|
1040
|
+
styleElement.innerHTML = `[data-id="${selectedNodeId}"]${pseudoElement}, [data-id="${selectedNodeId}"] ~ [data-id^="${selectedNodeId}("]${pseudoElement} {
|
|
1012
1041
|
${previewStyles}
|
|
1013
1042
|
transition: none !important;
|
|
1014
1043
|
}`
|
|
@@ -1427,7 +1456,7 @@ export const createRoot = (
|
|
|
1427
1456
|
parentElement: domNode,
|
|
1428
1457
|
instance: { [newCtx.component.name]: 'root' },
|
|
1429
1458
|
})
|
|
1430
|
-
newCtx.component.onLoad?.actions
|
|
1459
|
+
newCtx.component.onLoad?.actions?.forEach((action) => {
|
|
1431
1460
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1432
1461
|
handleAction(action, dataSignal.get(), newCtx)
|
|
1433
1462
|
})
|