@lukekaalim/act-web 3.0.0 → 3.2.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # @lukekaalim/act-web
2
+
3
+ ## 3.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4381035: Added error boundaries
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [4381035]
12
+ - @lukekaalim/act-backstage@1.2.0
13
+ - @lukekaalim/act-recon@1.1.0
14
+ - @lukekaalim/act@3.1.0
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@lukekaalim/act-web",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "type": "module",
5
5
  "main": "mod.ts",
6
6
  "dependencies": {
7
- "@lukekaalim/act": "^3.0.0",
8
- "@lukekaalim/act-recon": "^1.0.0",
9
- "@lukekaalim/act-backstage": "^1.0.0"
7
+ "@lukekaalim/act": "^3.1.0",
8
+ "@lukekaalim/act-recon": "^1.1.0",
9
+ "@lukekaalim/act-backstage": "^1.2.0"
10
10
  }
11
- }
11
+ }
package/render.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { createWebSpace } from "./space";
2
- import { createRenderFunction, Scheduler } from "@lukekaalim/act-backstage";
1
+ import { h } from "@lukekaalim/act";
2
+ import { createWebSpace, HTML } from "./space";
3
+ import { createRenderFunction, RenderFunction, Scheduler } from "@lukekaalim/act-backstage";
3
4
 
4
5
  const intervalScheduler: Scheduler<NodeJS.Timeout> = {
5
6
  duration: 10,
@@ -7,4 +8,5 @@ const intervalScheduler: Scheduler<NodeJS.Timeout> = {
7
8
  cancel: id => clearInterval(id),
8
9
  }
9
10
 
10
- export const render = createRenderFunction(intervalScheduler, createWebSpace);
11
+ export const render: RenderFunction<HTMLElement> = (node, root) =>
12
+ createRenderFunction(intervalScheduler, createWebSpace)(h(HTML, {}, node), root);
package/space.ts CHANGED
@@ -5,8 +5,8 @@ import { createSimpleRenderSpace } from '@lukekaalim/act-backstage/mod.ts';
5
5
 
6
6
  import { setProps } from './props.ts';
7
7
 
8
- export const HTML: act.Component = ({ children }) => act.h(act.primitiveNodeTypes.render, { type: 'web:html' }, children);
9
- export const SVG: act.Component = ({ children }) => act.h(act.primitiveNodeTypes.render, { type: 'web:svg' }, children);
8
+ export const HTML: act.Component = ({ children }) => act.h(act.renderNodeType, { type: 'web:html' }, children);
9
+ export const SVG: act.Component = ({ children }) => act.h(act.renderNodeType, { type: 'web:svg' }, children);
10
10
 
11
11
  export const createWebSpace = (tree: recon.CommitTree, root: HTMLElement, document: Document = window.document) => {
12
12
  return createSimpleRenderSpace(tree, {
@@ -18,6 +18,7 @@ export const createWebSpace = (tree: recon.CommitTree, root: HTMLElement, docume
18
18
  case 'symbol': {
19
19
  switch (tag) {
20
20
  case act.primitiveNodeTypes.string:
21
+ case act.primitiveNodeTypes.number:
21
22
  return document.createTextNode("");
22
23
  default:
23
24
  return null;
@@ -39,8 +40,13 @@ export const createWebSpace = (tree: recon.CommitTree, root: HTMLElement, docume
39
40
  setProps(el, next, prev);
40
41
  },
41
42
  link(el, parent) {
43
+ console.log('attaching', el, 'to', (parent || root));
42
44
  (parent || root).appendChild(el);
43
45
  },
46
+ unlink(el, parent) {
47
+ console.log('detaching', el, 'to', (parent || root));
48
+ (parent || root).removeChild(el);
49
+ },
44
50
  sort(el, newChildren) {
45
51
  if (el instanceof Text)
46
52
  return;