@nordcraft/runtime 1.0.37 → 1.0.38

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.
@@ -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 toddle sibling element or null if this is the last element. A toddle sibling is a sibling with a higher index or a the index, but a higher repeat index.
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
  /**
@@ -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 toddle sibling element or null if this is the last element. A toddle sibling is a sibling with a higher index or a the index, but a higher repeat index.
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.37",
8
- "@nordcraft/std-lib": "1.0.37",
7
+ "@nordcraft/core": "1.0.38",
8
+ "@nordcraft/std-lib": "1.0.38",
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.37"
24
+ "version": "1.0.38"
25
25
  }
@@ -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;">${name}</h1>
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;">Error Message: ${message}</p>`
35
+ <p style="font-size: 0.81em; white-space: pre-wrap">${message}</p>`
@@ -975,13 +975,13 @@ export const createRoot = (
975
975
  )
976
976
 
977
977
  if (
978
- nodeLookup?.node.type === 'element' ||
979
- (nodeLookup?.node.type === 'component' &&
980
- nodeLookup.node.variants?.[
981
- styleVariantSelection.styleVariantIndex
982
- ].pseudoElement)
978
+ (nodeLookup?.node.type === 'element' ||
979
+ nodeLookup?.node.type === 'component') &&
980
+ nodeLookup.node.variants?.[
981
+ styleVariantSelection.styleVariantIndex
982
+ ].pseudoElement
983
983
  ) {
984
- pseudoElement = `::${nodeLookup.node.variants?.[styleVariantSelection.styleVariantIndex].pseudoElement}`
984
+ pseudoElement = `::${nodeLookup.node.variants[styleVariantSelection.styleVariantIndex].pseudoElement}`
985
985
  }
986
986
  }
987
987
 
@@ -1433,13 +1433,25 @@ export const createRoot = (
1433
1433
  panic = true
1434
1434
  name = 'Infinite loop detected'
1435
1435
  message =
1436
- 'RangeError (Maximum call stack size exceeded): Remove any circular dependencies or recursive calls. This is most likely caused by components, formulas or actions using themselves without an exit case.'
1436
+ '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
1437
  }
1438
1438
 
1439
- // Send a toast to the editor with the error
1440
- sendEditorToast(name, message, {
1441
- type: 'critical',
1442
- })
1439
+ // This can be triggered by setting "type" on a select etc.
1440
+ if (error instanceof TypeError) {
1441
+ panic = true
1442
+ name = 'TypeError'
1443
+ message = `Type errors are often caused by:
1444
+
1445
+ • Trying to set a read-only property (like "type" on a select element).
1446
+
1447
+ • Trying to set a property on an undefined or null value.
1448
+
1449
+ • Trying to access a property on an undefined or null value.
1450
+
1451
+ • Trying to call a method on an undefined or null value.`
1452
+ }
1453
+
1454
+ console.error(name, message, error)
1443
1455
 
1444
1456
  if (panic) {
1445
1457
  // Show error overlay in the editor until next update
@@ -1453,8 +1465,12 @@ export const createRoot = (
1453
1465
  // Replace the inner HTML of the editor preview with the panic screen
1454
1466
  domNode.innerHTML = ''
1455
1467
  domNode.appendChild(panicScreen)
1468
+ } else {
1469
+ // 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
1470
+ sendEditorToast(name, message, {
1471
+ type: 'critical',
1472
+ })
1456
1473
  }
1457
- console.error(name, message, error)
1458
1474
  }
1459
1475
  postMessageToEditor({
1460
1476
  type: 'style',
@@ -1659,7 +1675,9 @@ function getRectData(selectedNode: Element | null | undefined) {
1659
1675
  return null
1660
1676
  }
1661
1677
 
1662
- const rect = selectedNode.getBoundingClientRect()
1678
+ const { borderRadius, rotate } = window.getComputedStyle(selectedNode)
1679
+ const rect: DOMRect = selectedNode.getBoundingClientRect()
1680
+
1663
1681
  return {
1664
1682
  left: rect.left,
1665
1683
  right: rect.right,
@@ -1669,10 +1687,8 @@ function getRectData(selectedNode: Element | null | undefined) {
1669
1687
  height: rect.height,
1670
1688
  x: rect.x,
1671
1689
  y: rect.y,
1672
- borderRadius: window
1673
- .getComputedStyle(selectedNode)
1674
- .borderRadius.split(' ')
1675
- .map(parseFloat),
1690
+ borderRadius: borderRadius.split(' '),
1691
+ rotate,
1676
1692
  }
1677
1693
  }
1678
1694
 
@@ -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 toddle sibling element or null if this is the last element. A toddle sibling is a sibling with a higher index or a the index, but a higher repeat index.
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,