@sigil-dev/runtime 0.8.5 → 0.9.0

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.
@@ -0,0 +1,30 @@
1
+ export function __asyncBoundary(
2
+ factory: () => Promise<any>,
3
+ Loading?: () => any,
4
+ Err?: (props: { error: unknown }) => any,
5
+ ): Node {
6
+ const container = document.createElement("div");
7
+ container.dataset.asyncBoundary = "1";
8
+
9
+ if (Loading) {
10
+ const node = Loading();
11
+ if (node) container.appendChild(node);
12
+ }
13
+
14
+ factory()
15
+ .then((node) => {
16
+ if (node) container.replaceChildren(node);
17
+ else container.replaceChildren();
18
+ })
19
+ .catch((err) => {
20
+ if (Err) {
21
+ const errNode = Err({ error: err });
22
+ if (errNode) container.replaceChildren(errNode);
23
+ } else {
24
+ console.error("[sigil] async component error:", err);
25
+ container.replaceChildren();
26
+ }
27
+ });
28
+
29
+ return container;
30
+ }
package/index.ts CHANGED
@@ -19,6 +19,7 @@ export {
19
19
  } from "./easing.ts";
20
20
  export { ReactiveMap } from "./reactivity/map.ts";
21
21
  export { ReactiveSet } from "./reactivity/set.ts";
22
+ export {__asyncBoundary} from "./async-boundary.ts"
22
23
 
23
24
  export const SIGIL_SAFE = Symbol.for("sigil.safe");
24
25
  export class SafeHtml {
@@ -354,7 +355,7 @@ export function createProfilerEffect(
354
355
  const start = performance.now();
355
356
  const cleanup = fn();
356
357
  const end = performance.now();
357
- console.log(`[Profiler] ${name}: ${(end - start).toFixed(2)}ms`);
358
+ // console.log(`[Profiler] ${name}: ${(end - start).toFixed(2)}ms`);
358
359
  return cleanup;
359
360
  });
360
361
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@sigil-dev/runtime",
3
3
  "module": "index.ts",
4
4
  "type": "module",
5
- "version": "0.8.5",
5
+ "version": "0.9.0",
6
6
  "description": "Runtime for the Sigil framework",
7
7
  "private": false,
8
8
  "devDependencies": {