@nordcraft/runtime 1.0.37 → 1.0.39
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 +2 -2
- package/dist/custom-element.main.esm.js.map +4 -4
- package/dist/debug/panicScreen.js +3 -5
- package/dist/debug/panicScreen.js.map +1 -1
- package/dist/editor-preview.main.js +31 -18
- package/dist/editor-preview.main.js.map +1 -1
- package/dist/page.main.esm.js +2 -2
- package/dist/page.main.esm.js.map +4 -4
- package/dist/utils/nodes.d.ts +1 -1
- package/dist/utils/nodes.js +1 -1
- package/package.json +3 -3
- package/src/debug/panicScreen.ts +3 -5
- package/src/editor-preview.main.ts +35 -24
- package/src/utils/nodes.ts +1 -1
package/dist/utils/nodes.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface NodeAndAncestorLookup {
|
|
|
9
9
|
export declare const getNodeAndAncestors: (component: Component, root: NodeModel, id: unknown) => NodeAndAncestorLookup | undefined;
|
|
10
10
|
export declare const isNodeOrAncestorConditional: (nodeLookup?: NodeAndAncestorLookup) => nodeLookup is NodeAndAncestorLookup;
|
|
11
11
|
/**
|
|
12
|
-
* @returns The next
|
|
12
|
+
* @returns The next sibling element or null if this is the last element. A nc sibling is a sibling with a higher index or the same index but a higher repeat index.
|
|
13
13
|
*/
|
|
14
14
|
export declare const getNextSiblingElement: (path: string, parentElement: Element | ShadowRoot) => Element | null;
|
|
15
15
|
/**
|
package/dist/utils/nodes.js
CHANGED
|
@@ -35,7 +35,7 @@ export const getNodeAndAncestors = (component, root, id) => {
|
|
|
35
35
|
export const isNodeOrAncestorConditional = (nodeLookup) => nodeLookup?.node?.condition !== undefined ||
|
|
36
36
|
nodeLookup?.ancestors.some((a) => a.condition !== undefined) === true;
|
|
37
37
|
/**
|
|
38
|
-
* @returns The next
|
|
38
|
+
* @returns The next sibling element or null if this is the last element. A nc sibling is a sibling with a higher index or the same index but a higher repeat index.
|
|
39
39
|
*/
|
|
40
40
|
export const getNextSiblingElement = (path, parentElement) => {
|
|
41
41
|
const pathParts = path.split('.');
|
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.39",
|
|
8
|
+
"@nordcraft/std-lib": "1.0.39",
|
|
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.39"
|
|
25
25
|
}
|
package/src/debug/panicScreen.ts
CHANGED
|
@@ -21,9 +21,7 @@ export const createPanicScreen = ({
|
|
|
21
21
|
return document.createRange().createContextualFragment(`
|
|
22
22
|
<main style="background-color: blue; color: white; font-family: 'Courier New', monospace; font-weight: 100; display: flex; justify-content: flex-start; align-items: flex-start; margin: 0px; padding: 0px;">
|
|
23
23
|
<div style="display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; height: 100vh;">
|
|
24
|
-
<div style="display: flex; flex-direction: column; gap: 20px; padding: 80px; font-size: 22px;">
|
|
25
|
-
${content}
|
|
26
|
-
</div>
|
|
24
|
+
<div style="display: flex; flex-direction: column; gap: 20px; padding: 80px; font-size: 22px;">${content}</div>
|
|
27
25
|
</div>
|
|
28
26
|
<div style="position:fixed; pointer-events: none; width: 100vw; height: 100vh; background-image: linear-gradient(0deg, rgba(0,0,0,0) 25%, rgba(0,0,0,0.33) 25%, rgba(0,0,0,0.33) 50%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 75%, rgba(0,0,0,0.33) 75%, rgba(0,0,0,0.33) 100%); background-size: 4px 4px;"></div>
|
|
29
27
|
<div style="position:fixed; pointer-events: none; width: 100vw; height: 100vh; background-image: radial-gradient(ellipse at center, rgba(0,0,0,0) 50%, rgba(0,0,0,0.25) 100%);"></div>
|
|
@@ -32,6 +30,6 @@ export const createPanicScreen = ({
|
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
const getContent = (name: string, message: string, isPage?: boolean) => `
|
|
35
|
-
<h1 style="display: inline; font-size: 1em; background: white; color: blue; padding: 0.4em 0.8em;"
|
|
33
|
+
<h1 style="display: inline; font-size: 1em; background: white; color: blue; padding: 0.4em 0.8em;">Error: ${name}</h1>
|
|
36
34
|
<p style="font-size: 0.8em;">The ${isPage ? 'page' : 'component'} could not be rendered. Fix the issue and try again. Join our <a style="color:white" href="https://discord.gg/nordcraft" target="_blank">Discord</a> for help.</p>
|
|
37
|
-
<p style="font-size: 0.81em;
|
|
35
|
+
<p style="font-size: 0.81em; white-space: pre-wrap">${message}</p>`
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
/* eslint-disable no-case-declarations */
|
|
4
4
|
/* eslint-disable no-fallthrough */
|
|
5
5
|
import { isLegacyApi } from '@nordcraft/core/dist/api/api'
|
|
6
|
-
import { type ApiRequest } from '@nordcraft/core/dist/api/apiTypes'
|
|
7
6
|
import type {
|
|
8
7
|
AnimationKeyframe,
|
|
9
8
|
Component,
|
|
@@ -692,20 +691,16 @@ export const createRoot = (
|
|
|
692
691
|
const { apiKey } = message.data
|
|
693
692
|
const api = component?.apis[apiKey]
|
|
694
693
|
if (api && !isLegacyApi(api) && component) {
|
|
695
|
-
const Attributes = mapObject(
|
|
696
|
-
component.attributes,
|
|
697
|
-
([name, { testValue }]) => [name, testValue],
|
|
698
|
-
)
|
|
699
694
|
const formulaContext: FormulaContext = {
|
|
700
695
|
component,
|
|
701
|
-
data:
|
|
696
|
+
data: dataSignal.get(),
|
|
702
697
|
root: document,
|
|
703
698
|
package: ctx?.package,
|
|
704
699
|
toddle: window.toddle,
|
|
705
700
|
env,
|
|
706
701
|
}
|
|
707
702
|
const introspectionResult = await introspectApiRequest({
|
|
708
|
-
api
|
|
703
|
+
api,
|
|
709
704
|
componentName: component.name,
|
|
710
705
|
formulaContext,
|
|
711
706
|
})
|
|
@@ -975,13 +970,13 @@ export const createRoot = (
|
|
|
975
970
|
)
|
|
976
971
|
|
|
977
972
|
if (
|
|
978
|
-
nodeLookup?.node.type === 'element' ||
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
973
|
+
(nodeLookup?.node.type === 'element' ||
|
|
974
|
+
nodeLookup?.node.type === 'component') &&
|
|
975
|
+
nodeLookup.node.variants?.[
|
|
976
|
+
styleVariantSelection.styleVariantIndex
|
|
977
|
+
].pseudoElement
|
|
983
978
|
) {
|
|
984
|
-
pseudoElement = `::${nodeLookup.node.variants
|
|
979
|
+
pseudoElement = `::${nodeLookup.node.variants[styleVariantSelection.styleVariantIndex].pseudoElement}`
|
|
985
980
|
}
|
|
986
981
|
}
|
|
987
982
|
|
|
@@ -1433,13 +1428,25 @@ export const createRoot = (
|
|
|
1433
1428
|
panic = true
|
|
1434
1429
|
name = 'Infinite loop detected'
|
|
1435
1430
|
message =
|
|
1436
|
-
'RangeError (Maximum call stack size exceeded): Remove any circular dependencies or recursive calls. This is most likely caused by
|
|
1431
|
+
'RangeError (Maximum call stack size exceeded): Remove any circular dependencies or recursive calls (Try undoing your last change). This is most likely caused by a component, formula or action using itself.'
|
|
1437
1432
|
}
|
|
1438
1433
|
|
|
1439
|
-
//
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1434
|
+
// This can be triggered by setting "type" on a select etc.
|
|
1435
|
+
if (error instanceof TypeError) {
|
|
1436
|
+
panic = true
|
|
1437
|
+
name = 'TypeError'
|
|
1438
|
+
message = `Type errors are often caused by:
|
|
1439
|
+
|
|
1440
|
+
• Trying to set a read-only property (like "type" on a select element).
|
|
1441
|
+
|
|
1442
|
+
• Trying to set a property on an undefined or null value.
|
|
1443
|
+
|
|
1444
|
+
• Trying to access a property on an undefined or null value.
|
|
1445
|
+
|
|
1446
|
+
• Trying to call a method on an undefined or null value.`
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
console.error(name, message, error)
|
|
1443
1450
|
|
|
1444
1451
|
if (panic) {
|
|
1445
1452
|
// Show error overlay in the editor until next update
|
|
@@ -1453,8 +1460,12 @@ export const createRoot = (
|
|
|
1453
1460
|
// Replace the inner HTML of the editor preview with the panic screen
|
|
1454
1461
|
domNode.innerHTML = ''
|
|
1455
1462
|
domNode.appendChild(panicScreen)
|
|
1463
|
+
} else {
|
|
1464
|
+
// Otherwise send a toast to the editor with the error (unknown errors may be recoverable), if not please add the error-type to the above
|
|
1465
|
+
sendEditorToast(name, message, {
|
|
1466
|
+
type: 'critical',
|
|
1467
|
+
})
|
|
1456
1468
|
}
|
|
1457
|
-
console.error(name, message, error)
|
|
1458
1469
|
}
|
|
1459
1470
|
postMessageToEditor({
|
|
1460
1471
|
type: 'style',
|
|
@@ -1659,7 +1670,9 @@ function getRectData(selectedNode: Element | null | undefined) {
|
|
|
1659
1670
|
return null
|
|
1660
1671
|
}
|
|
1661
1672
|
|
|
1662
|
-
const
|
|
1673
|
+
const { borderRadius, rotate } = window.getComputedStyle(selectedNode)
|
|
1674
|
+
const rect: DOMRect = selectedNode.getBoundingClientRect()
|
|
1675
|
+
|
|
1663
1676
|
return {
|
|
1664
1677
|
left: rect.left,
|
|
1665
1678
|
right: rect.right,
|
|
@@ -1669,10 +1682,8 @@ function getRectData(selectedNode: Element | null | undefined) {
|
|
|
1669
1682
|
height: rect.height,
|
|
1670
1683
|
x: rect.x,
|
|
1671
1684
|
y: rect.y,
|
|
1672
|
-
borderRadius:
|
|
1673
|
-
|
|
1674
|
-
.borderRadius.split(' ')
|
|
1675
|
-
.map(parseFloat),
|
|
1685
|
+
borderRadius: borderRadius.split(' '),
|
|
1686
|
+
rotate,
|
|
1676
1687
|
}
|
|
1677
1688
|
}
|
|
1678
1689
|
|
package/src/utils/nodes.ts
CHANGED
|
@@ -56,7 +56,7 @@ export const isNodeOrAncestorConditional = (
|
|
|
56
56
|
nodeLookup?.ancestors.some((a) => a.condition !== undefined) === true
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* @returns The next
|
|
59
|
+
* @returns The next sibling element or null if this is the last element. A nc sibling is a sibling with a higher index or the same index but a higher repeat index.
|
|
60
60
|
*/
|
|
61
61
|
export const getNextSiblingElement = (
|
|
62
62
|
path: string,
|