@nordcraft/runtime 1.0.88 → 1.0.90
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 +24 -24
- package/dist/custom-element.main.esm.js.map +4 -4
- package/dist/page.main.esm.js +3 -3
- package/dist/page.main.esm.js.map +4 -4
- package/dist/src/components/createComponent.js +37 -36
- package/dist/src/components/createComponent.js.map +1 -1
- package/dist/src/components/createElement.js +0 -2
- package/dist/src/components/createElement.js.map +1 -1
- package/dist/src/components/createNode.js +12 -4
- package/dist/src/components/createNode.js.map +1 -1
- package/dist/src/components/createNode.test.d.ts +1 -0
- package/dist/src/components/createNode.test.js +608 -0
- package/dist/src/components/createNode.test.js.map +1 -0
- package/dist/src/components/meta.d.ts +3 -0
- package/dist/src/components/meta.js +18 -0
- package/dist/src/components/meta.js.map +1 -0
- package/dist/src/components/meta.test.d.ts +1 -0
- package/dist/src/components/meta.test.js +80 -0
- package/dist/src/components/meta.test.js.map +1 -0
- package/dist/src/components/renderComponent.js +2 -4
- package/dist/src/components/renderComponent.js.map +1 -1
- package/dist/src/editor/postMessageToEditor.d.ts +2 -0
- package/dist/src/editor/postMessageToEditor.js +4 -0
- package/dist/src/editor/postMessageToEditor.js.map +1 -0
- package/dist/src/editor-preview.main.js +12 -13
- package/dist/src/editor-preview.main.js.map +1 -1
- package/dist/src/page.main.js +46 -59
- package/dist/src/page.main.js.map +1 -1
- package/dist/src/styles/CustomPropertyStyleSheet.d.ts +0 -1
- package/dist/src/styles/CustomPropertyStyleSheet.js +1 -1
- package/dist/src/styles/CustomPropertyStyleSheet.js.map +1 -1
- package/dist/src/styles/CustomPropertyStyleSheet.test.js +2 -5
- package/dist/src/styles/CustomPropertyStyleSheet.test.js.map +1 -1
- package/dist/src/utils/BatchQueue.d.ts +1 -0
- package/dist/src/utils/BatchQueue.js +2 -1
- package/dist/src/utils/BatchQueue.js.map +1 -1
- package/dist/src/utils/getComponent.d.ts +5 -0
- package/dist/src/utils/getComponent.js +8 -0
- package/dist/src/utils/getComponent.js.map +1 -0
- package/dist/src/utils/getComponent.test.d.ts +1 -0
- package/dist/src/utils/getComponent.test.js +24 -0
- package/dist/src/utils/getComponent.test.js.map +1 -0
- package/dist/src/utils/markSelectedElement.d.ts +1 -0
- package/dist/src/utils/markSelectedElement.js +9 -0
- package/dist/src/utils/markSelectedElement.js.map +1 -0
- package/dist/src/utils/subscribeCustomProperty.d.ts +3 -3
- package/dist/src/utils/subscribeCustomProperty.js +2 -3
- package/dist/src/utils/subscribeCustomProperty.js.map +1 -1
- package/package.json +3 -3
- package/src/components/createComponent.ts +57 -51
- package/src/components/createElement.ts +0 -2
- package/src/components/createNode.test.ts +686 -0
- package/src/components/createNode.ts +17 -6
- package/src/components/meta.test.ts +90 -0
- package/src/components/meta.ts +23 -0
- package/src/components/renderComponent.ts +2 -4
- package/src/editor/postMessageToEditor.ts +5 -0
- package/src/editor-preview.main.ts +12 -15
- package/src/page.main.ts +47 -59
- package/src/styles/CustomPropertyStyleSheet.test.ts +2 -7
- package/src/styles/CustomPropertyStyleSheet.ts +1 -2
- package/src/utils/BatchQueue.ts +2 -2
- package/src/utils/getComponent.test.ts +29 -0
- package/src/utils/getComponent.ts +15 -0
- package/src/utils/markSelectedElement.ts +8 -0
- package/src/utils/subscribeCustomProperty.ts +1 -5
|
@@ -21,6 +21,7 @@ import { signal } from '../signal/signal'
|
|
|
21
21
|
import type { ComponentChild, ComponentContext, ContextApi } from '../types'
|
|
22
22
|
import { createFormulaCache } from '../utils/createFormulaCache'
|
|
23
23
|
import { formulaHasValue } from '../utils/formulaHasValue'
|
|
24
|
+
import { getComponent } from '../utils/getComponent'
|
|
24
25
|
import { subscribeCustomProperty } from '../utils/subscribeCustomProperty'
|
|
25
26
|
import { renderComponent } from './renderComponent'
|
|
26
27
|
|
|
@@ -44,7 +45,11 @@ export function createComponent({
|
|
|
44
45
|
namespace,
|
|
45
46
|
}: RenderComponentNodeProps): ReadonlyArray<Element | Text> {
|
|
46
47
|
const nodeLookupKey = [ctx.package, node.name].filter(isDefined).join('/')
|
|
47
|
-
const component =
|
|
48
|
+
const component = getComponent(
|
|
49
|
+
nodeLookupKey,
|
|
50
|
+
ctx.components,
|
|
51
|
+
ctx.env.runtime !== 'preview',
|
|
52
|
+
)
|
|
48
53
|
if (!component) {
|
|
49
54
|
// eslint-disable-next-line no-console
|
|
50
55
|
console.warn(
|
|
@@ -76,55 +81,6 @@ export function createComponent({
|
|
|
76
81
|
])
|
|
77
82
|
})
|
|
78
83
|
|
|
79
|
-
Object.entries(node.customProperties ?? {})
|
|
80
|
-
.filter(([_, { formula }]) => formulaHasValue(formula))
|
|
81
|
-
.forEach(([customPropertyName, customProperty]) =>
|
|
82
|
-
subscribeCustomProperty({
|
|
83
|
-
selector: getNodeSelector(path, {
|
|
84
|
-
componentName: ctx.component.name,
|
|
85
|
-
nodeId: node.id,
|
|
86
|
-
}),
|
|
87
|
-
signal: dataSignal.map((data) =>
|
|
88
|
-
appendUnit(
|
|
89
|
-
applyFormula(customProperty.formula, {
|
|
90
|
-
...formulaCtx,
|
|
91
|
-
data,
|
|
92
|
-
}),
|
|
93
|
-
customProperty.unit,
|
|
94
|
-
),
|
|
95
|
-
),
|
|
96
|
-
customPropertyName,
|
|
97
|
-
root: ctx.root,
|
|
98
|
-
runtime: ctx.env.runtime,
|
|
99
|
-
}),
|
|
100
|
-
)
|
|
101
|
-
node.variants?.forEach((variant) => {
|
|
102
|
-
Object.entries(variant.customProperties ?? {})
|
|
103
|
-
.filter(([_, { formula }]) => formulaHasValue(formula))
|
|
104
|
-
.forEach(([customPropertyName, customProperty]) =>
|
|
105
|
-
subscribeCustomProperty({
|
|
106
|
-
selector: getNodeSelector(path, {
|
|
107
|
-
componentName: ctx.component.name,
|
|
108
|
-
nodeId: node.id,
|
|
109
|
-
variant,
|
|
110
|
-
}),
|
|
111
|
-
signal: dataSignal.map((data) =>
|
|
112
|
-
appendUnit(
|
|
113
|
-
applyFormula(customProperty.formula, {
|
|
114
|
-
...formulaCtx,
|
|
115
|
-
data,
|
|
116
|
-
}),
|
|
117
|
-
customProperty.unit,
|
|
118
|
-
),
|
|
119
|
-
),
|
|
120
|
-
customPropertyName,
|
|
121
|
-
variant,
|
|
122
|
-
root: ctx.root,
|
|
123
|
-
runtime: ctx.env.runtime,
|
|
124
|
-
}),
|
|
125
|
-
)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
84
|
const componentDataSignal = signal<ComponentData>({
|
|
129
85
|
Location: dataSignal.get().Location,
|
|
130
86
|
Attributes: attributesSignal.get(),
|
|
@@ -321,7 +277,7 @@ export function createComponent({
|
|
|
321
277
|
{ destroy: () => componentDataSignal.destroy() },
|
|
322
278
|
)
|
|
323
279
|
|
|
324
|
-
|
|
280
|
+
const renderedComponent = renderComponent({
|
|
325
281
|
dataSignal: componentDataSignal,
|
|
326
282
|
component,
|
|
327
283
|
components: ctx.components,
|
|
@@ -346,4 +302,54 @@ export function createComponent({
|
|
|
346
302
|
? { ...instance, [ctx.component.name]: 'root' }
|
|
347
303
|
: { [ctx.component.name]: node.id ?? '' },
|
|
348
304
|
})
|
|
305
|
+
|
|
306
|
+
// Custom properties instance overrides are added after the child tree is rendered to ensure correct order
|
|
307
|
+
Object.entries(node.customProperties ?? {})
|
|
308
|
+
.filter(([_, { formula }]) => formulaHasValue(formula))
|
|
309
|
+
.forEach(([customPropertyName, customProperty]) =>
|
|
310
|
+
subscribeCustomProperty({
|
|
311
|
+
selector: getNodeSelector(path, {
|
|
312
|
+
componentName: ctx.component.name,
|
|
313
|
+
nodeId: node.id,
|
|
314
|
+
}),
|
|
315
|
+
signal: dataSignal.map((data) =>
|
|
316
|
+
appendUnit(
|
|
317
|
+
applyFormula(customProperty.formula, {
|
|
318
|
+
...formulaCtx,
|
|
319
|
+
data,
|
|
320
|
+
}),
|
|
321
|
+
customProperty.unit,
|
|
322
|
+
),
|
|
323
|
+
),
|
|
324
|
+
customPropertyName,
|
|
325
|
+
root: ctx.root,
|
|
326
|
+
}),
|
|
327
|
+
)
|
|
328
|
+
node.variants?.forEach((variant) => {
|
|
329
|
+
Object.entries(variant.customProperties ?? {})
|
|
330
|
+
.filter(([_, { formula }]) => formulaHasValue(formula))
|
|
331
|
+
.forEach(([customPropertyName, customProperty]) =>
|
|
332
|
+
subscribeCustomProperty({
|
|
333
|
+
selector: getNodeSelector(path, {
|
|
334
|
+
componentName: ctx.component.name,
|
|
335
|
+
nodeId: node.id,
|
|
336
|
+
variant,
|
|
337
|
+
}),
|
|
338
|
+
signal: dataSignal.map((data) =>
|
|
339
|
+
appendUnit(
|
|
340
|
+
applyFormula(customProperty.formula, {
|
|
341
|
+
...formulaCtx,
|
|
342
|
+
data,
|
|
343
|
+
}),
|
|
344
|
+
customProperty.unit,
|
|
345
|
+
),
|
|
346
|
+
),
|
|
347
|
+
customPropertyName,
|
|
348
|
+
variant,
|
|
349
|
+
root: ctx.root,
|
|
350
|
+
}),
|
|
351
|
+
)
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
return renderedComponent
|
|
349
355
|
}
|
|
@@ -169,7 +169,6 @@ export function createElement({
|
|
|
169
169
|
),
|
|
170
170
|
),
|
|
171
171
|
root: ctx.root,
|
|
172
|
-
runtime: ctx.env.runtime,
|
|
173
172
|
})
|
|
174
173
|
})
|
|
175
174
|
|
|
@@ -193,7 +192,6 @@ export function createElement({
|
|
|
193
192
|
),
|
|
194
193
|
),
|
|
195
194
|
root: ctx.root,
|
|
196
|
-
runtime: ctx.env.runtime,
|
|
197
195
|
})
|
|
198
196
|
})
|
|
199
197
|
})
|