solid-js 1.4.5 → 1.4.8

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/dev.cjs CHANGED
@@ -809,10 +809,8 @@ function runUpdates(fn, init) {
809
809
  completeUpdates(wait);
810
810
  return res;
811
811
  } catch (err) {
812
+ if (!Updates) Effects = null;
812
813
  handleError(err);
813
- } finally {
814
- Updates = null;
815
- if (!wait) Effects = null;
816
814
  }
817
815
  }
818
816
  function completeUpdates(wait) {
@@ -1022,31 +1020,33 @@ function serializeChildren(root) {
1022
1020
  return result;
1023
1021
  }
1024
1022
 
1025
- function getSymbol() {
1026
- const SymbolCopy = Symbol;
1027
- return SymbolCopy.observable || "@@observable";
1028
- }
1029
1023
  function observable(input) {
1030
- const $$observable = getSymbol();
1031
1024
  return {
1032
1025
  subscribe(observer) {
1033
1026
  if (!(observer instanceof Object) || observer == null) {
1034
1027
  throw new TypeError("Expected the observer to be an object.");
1035
1028
  }
1036
- const handler = "next" in observer ? observer.next.bind(observer) : observer;
1037
- let complete = false;
1038
- createComputed(() => {
1039
- if (complete) return;
1040
- const v = input();
1041
- untrack(() => handler(v));
1029
+ const handler = typeof observer === 'function' ? observer : observer.next && observer.next.bind(observer);
1030
+ if (!handler) {
1031
+ return {
1032
+ unsubscribe() {}
1033
+ };
1034
+ }
1035
+ const dispose = createRoot(disposer => {
1036
+ createComputed(() => {
1037
+ const v = input();
1038
+ untrack(() => handler(v));
1039
+ });
1040
+ return disposer;
1042
1041
  });
1042
+ if (getOwner()) onCleanup(dispose);
1043
1043
  return {
1044
1044
  unsubscribe() {
1045
- complete = true;
1045
+ dispose();
1046
1046
  }
1047
1047
  };
1048
1048
  },
1049
- [$$observable]() {
1049
+ [Symbol.observable || "@@observable"]() {
1050
1050
  return this;
1051
1051
  }
1052
1052
  };
@@ -1552,7 +1552,7 @@ function Suspense(props) {
1552
1552
  set();
1553
1553
  setHydrateContext();
1554
1554
  });
1555
- }
1555
+ } else if (p === null) sharedConfig.gather(key);
1556
1556
  }
1557
1557
  const listContext = useContext(SuspenseListContext);
1558
1558
  if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
package/dist/dev.js CHANGED
@@ -805,10 +805,8 @@ function runUpdates(fn, init) {
805
805
  completeUpdates(wait);
806
806
  return res;
807
807
  } catch (err) {
808
+ if (!Updates) Effects = null;
808
809
  handleError(err);
809
- } finally {
810
- Updates = null;
811
- if (!wait) Effects = null;
812
810
  }
813
811
  }
814
812
  function completeUpdates(wait) {
@@ -1018,31 +1016,33 @@ function serializeChildren(root) {
1018
1016
  return result;
1019
1017
  }
1020
1018
 
1021
- function getSymbol() {
1022
- const SymbolCopy = Symbol;
1023
- return SymbolCopy.observable || "@@observable";
1024
- }
1025
1019
  function observable(input) {
1026
- const $$observable = getSymbol();
1027
1020
  return {
1028
1021
  subscribe(observer) {
1029
1022
  if (!(observer instanceof Object) || observer == null) {
1030
1023
  throw new TypeError("Expected the observer to be an object.");
1031
1024
  }
1032
- const handler = "next" in observer ? observer.next.bind(observer) : observer;
1033
- let complete = false;
1034
- createComputed(() => {
1035
- if (complete) return;
1036
- const v = input();
1037
- untrack(() => handler(v));
1025
+ const handler = typeof observer === 'function' ? observer : observer.next && observer.next.bind(observer);
1026
+ if (!handler) {
1027
+ return {
1028
+ unsubscribe() {}
1029
+ };
1030
+ }
1031
+ const dispose = createRoot(disposer => {
1032
+ createComputed(() => {
1033
+ const v = input();
1034
+ untrack(() => handler(v));
1035
+ });
1036
+ return disposer;
1038
1037
  });
1038
+ if (getOwner()) onCleanup(dispose);
1039
1039
  return {
1040
1040
  unsubscribe() {
1041
- complete = true;
1041
+ dispose();
1042
1042
  }
1043
1043
  };
1044
1044
  },
1045
- [$$observable]() {
1045
+ [Symbol.observable || "@@observable"]() {
1046
1046
  return this;
1047
1047
  }
1048
1048
  };
@@ -1548,7 +1548,7 @@ function Suspense(props) {
1548
1548
  set();
1549
1549
  setHydrateContext();
1550
1550
  });
1551
- }
1551
+ } else if (p === null) sharedConfig.gather(key);
1552
1552
  }
1553
1553
  const listContext = useContext(SuspenseListContext);
1554
1554
  if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
package/dist/server.cjs CHANGED
@@ -430,10 +430,17 @@ function createResource(source, fetcher, options = {}) {
430
430
  }
431
431
  function lazy(fn) {
432
432
  let resolved;
433
- const p = fn();
433
+ let p;
434
+ let load = () => {
435
+ if (!p) {
436
+ p = fn();
437
+ p.then(mod => resolved = mod.default);
438
+ }
439
+ return p;
440
+ };
434
441
  const contexts = new Set();
435
- p.then(mod => resolved = mod.default);
436
442
  const wrap = props => {
443
+ load();
437
444
  const id = sharedConfig.context.id.slice(0, -1);
438
445
  if (resolved) return resolved(props);
439
446
  const ctx = useContext(SuspenseContext);
@@ -451,7 +458,7 @@ function lazy(fn) {
451
458
  });
452
459
  return "";
453
460
  };
454
- wrap.preload = () => p;
461
+ wrap.preload = load;
455
462
  return wrap;
456
463
  }
457
464
  function suspenseComplete(c) {
package/dist/server.js CHANGED
@@ -426,10 +426,17 @@ function createResource(source, fetcher, options = {}) {
426
426
  }
427
427
  function lazy(fn) {
428
428
  let resolved;
429
- const p = fn();
429
+ let p;
430
+ let load = () => {
431
+ if (!p) {
432
+ p = fn();
433
+ p.then(mod => resolved = mod.default);
434
+ }
435
+ return p;
436
+ };
430
437
  const contexts = new Set();
431
- p.then(mod => resolved = mod.default);
432
438
  const wrap = props => {
439
+ load();
433
440
  const id = sharedConfig.context.id.slice(0, -1);
434
441
  if (resolved) return resolved(props);
435
442
  const ctx = useContext(SuspenseContext);
@@ -447,7 +454,7 @@ function lazy(fn) {
447
454
  });
448
455
  return "";
449
456
  };
450
- wrap.preload = () => p;
457
+ wrap.preload = load;
451
458
  return wrap;
452
459
  }
453
460
  function suspenseComplete(c) {
package/dist/solid.cjs CHANGED
@@ -747,10 +747,8 @@ function runUpdates(fn, init) {
747
747
  completeUpdates(wait);
748
748
  return res;
749
749
  } catch (err) {
750
+ if (!Updates) Effects = null;
750
751
  handleError(err);
751
- } finally {
752
- Updates = null;
753
- if (!wait) Effects = null;
754
752
  }
755
753
  }
756
754
  function completeUpdates(wait) {
@@ -935,31 +933,33 @@ function createProvider(id) {
935
933
  };
936
934
  }
937
935
 
938
- function getSymbol() {
939
- const SymbolCopy = Symbol;
940
- return SymbolCopy.observable || "@@observable";
941
- }
942
936
  function observable(input) {
943
- const $$observable = getSymbol();
944
937
  return {
945
938
  subscribe(observer) {
946
939
  if (!(observer instanceof Object) || observer == null) {
947
940
  throw new TypeError("Expected the observer to be an object.");
948
941
  }
949
- const handler = "next" in observer ? observer.next.bind(observer) : observer;
950
- let complete = false;
951
- createComputed(() => {
952
- if (complete) return;
953
- const v = input();
954
- untrack(() => handler(v));
942
+ const handler = typeof observer === 'function' ? observer : observer.next && observer.next.bind(observer);
943
+ if (!handler) {
944
+ return {
945
+ unsubscribe() {}
946
+ };
947
+ }
948
+ const dispose = createRoot(disposer => {
949
+ createComputed(() => {
950
+ const v = input();
951
+ untrack(() => handler(v));
952
+ });
953
+ return disposer;
955
954
  });
955
+ if (getOwner()) onCleanup(dispose);
956
956
  return {
957
957
  unsubscribe() {
958
- complete = true;
958
+ dispose();
959
959
  }
960
960
  };
961
961
  },
962
- [$$observable]() {
962
+ [Symbol.observable || "@@observable"]() {
963
963
  return this;
964
964
  }
965
965
  };
@@ -1461,7 +1461,7 @@ function Suspense(props) {
1461
1461
  set();
1462
1462
  setHydrateContext();
1463
1463
  });
1464
- }
1464
+ } else if (p === null) sharedConfig.gather(key);
1465
1465
  }
1466
1466
  const listContext = useContext(SuspenseListContext);
1467
1467
  if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
package/dist/solid.js CHANGED
@@ -743,10 +743,8 @@ function runUpdates(fn, init) {
743
743
  completeUpdates(wait);
744
744
  return res;
745
745
  } catch (err) {
746
+ if (!Updates) Effects = null;
746
747
  handleError(err);
747
- } finally {
748
- Updates = null;
749
- if (!wait) Effects = null;
750
748
  }
751
749
  }
752
750
  function completeUpdates(wait) {
@@ -931,31 +929,33 @@ function createProvider(id) {
931
929
  };
932
930
  }
933
931
 
934
- function getSymbol() {
935
- const SymbolCopy = Symbol;
936
- return SymbolCopy.observable || "@@observable";
937
- }
938
932
  function observable(input) {
939
- const $$observable = getSymbol();
940
933
  return {
941
934
  subscribe(observer) {
942
935
  if (!(observer instanceof Object) || observer == null) {
943
936
  throw new TypeError("Expected the observer to be an object.");
944
937
  }
945
- const handler = "next" in observer ? observer.next.bind(observer) : observer;
946
- let complete = false;
947
- createComputed(() => {
948
- if (complete) return;
949
- const v = input();
950
- untrack(() => handler(v));
938
+ const handler = typeof observer === 'function' ? observer : observer.next && observer.next.bind(observer);
939
+ if (!handler) {
940
+ return {
941
+ unsubscribe() {}
942
+ };
943
+ }
944
+ const dispose = createRoot(disposer => {
945
+ createComputed(() => {
946
+ const v = input();
947
+ untrack(() => handler(v));
948
+ });
949
+ return disposer;
951
950
  });
951
+ if (getOwner()) onCleanup(dispose);
952
952
  return {
953
953
  unsubscribe() {
954
- complete = true;
954
+ dispose();
955
955
  }
956
956
  };
957
957
  },
958
- [$$observable]() {
958
+ [Symbol.observable || "@@observable"]() {
959
959
  return this;
960
960
  }
961
961
  };
@@ -1457,7 +1457,7 @@ function Suspense(props) {
1457
1457
  set();
1458
1458
  setHydrateContext();
1459
1459
  });
1460
- }
1460
+ } else if (p === null) sharedConfig.gather(key);
1461
1461
  }
1462
1462
  const listContext = useContext(SuspenseListContext);
1463
1463
  if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
@@ -2,10 +2,9 @@
2
2
 
3
3
  var web = require('solid-js/web');
4
4
 
5
- var attrRE, lookup, parseTag, pushCommentNode, pushTextNode, tagRE;
6
- tagRE = /(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g;
7
- attrRE = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
8
- lookup = {
5
+ const tagRE = /(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g;
6
+ const attrRE = /(?:\s(?<boolean>[^/\s><=]+?)(?=[\s/>]))|(?:(?<name>\S+?)(?:\s*=\s*(?:(['"])(?<quotedValue>[\s\S]*?)\3|(?<unquotedValue>[^\s>]+))))/g;
7
+ const lookup = {
9
8
  area: true,
10
9
  base: true,
11
10
  br: true,
@@ -23,9 +22,9 @@ lookup = {
23
22
  track: true,
24
23
  wbr: true
25
24
  };
26
- parseTag = function (tag) {
27
- var res;
28
- res = {
25
+ function parseTag(
26
+ tag) {
27
+ const res = {
29
28
  type: 'tag',
30
29
  name: '',
31
30
  voidElement: false,
@@ -47,64 +46,42 @@ parseTag = function (tag) {
47
46
  }
48
47
  }
49
48
  const reg = new RegExp(attrRE);
50
- let result = null;
51
- for (;;) {
52
- result = reg.exec(tag);
53
- if (result === null) {
54
- break;
55
- }
56
- if (!result[0].trim()) {
57
- continue;
58
- }
59
- if (result[1]) {
60
- const attr = result[1].trim();
61
- let arr = [attr, ''];
62
- if (attr.indexOf('=') > -1) {
63
- arr = attr.split('=');
64
- }
65
- res.attrs[arr[0]] = arr[1];
66
- reg.lastIndex--;
67
- } else if (result[2]) {
68
- res.attrs[result[2]] = result[3].trim().substring(1, result[3].length - 1);
69
- }
49
+ for (const match of tag.matchAll(reg)) {
50
+ res.attrs[match[1] || match[2]] = match[4] || match[5] || '';
70
51
  }
71
52
  return res;
72
- };
73
- pushTextNode = function (list, html, start) {
74
- var content, end;
75
- end = html.indexOf('<', start);
76
- content = html.slice(start, end === -1 ? void 0 : end);
53
+ }
54
+ function pushTextNode(list, html, start) {
55
+ const end = html.indexOf('<', start);
56
+ const content = html.slice(start, end === -1 ? void 0 : end);
77
57
  if (!/^\s*$/.test(content)) {
78
58
  list.push({
79
59
  type: 'text',
80
60
  content: content
81
61
  });
82
62
  }
83
- };
84
- pushCommentNode = function (list, tag) {
85
- var content;
86
- content = tag.replace('<!--', '').replace('-->', '');
63
+ }
64
+ function pushCommentNode(list, tag) {
65
+ const content = tag.replace('<!--', '').replace('-->', '');
87
66
  if (!/^\s*$/.test(content)) {
88
67
  list.push({
89
68
  type: 'comment',
90
69
  content: content
91
70
  });
92
71
  }
93
- };
72
+ }
94
73
  function parse(html) {
95
- var arr, byTag, current, level, result;
96
- result = [];
97
- current = void 0;
98
- level = -1;
99
- arr = [];
100
- byTag = {};
101
- html.replace(tagRE, function (tag, index) {
102
- var isComment, isOpen, nextChar, parent, start;
103
- isOpen = tag.charAt(1) !== '/';
104
- isComment = tag.slice(0, 4) === '<!--';
105
- start = index + tag.length;
106
- nextChar = html.charAt(start);
107
- parent = void 0;
74
+ const result = [];
75
+ let current = void 0;
76
+ let level = -1;
77
+ const arr = [];
78
+ const byTag = {};
79
+ html.replace(tagRE, (tag, index) => {
80
+ const isOpen = tag.charAt(1) !== '/';
81
+ const isComment = tag.slice(0, 4) === '<!--';
82
+ const start = index + tag.length;
83
+ const nextChar = html.charAt(start);
84
+ let parent = void 0;
108
85
  if (isOpen && !isComment) {
109
86
  level++;
110
87
  current = parseTag(tag);
@@ -140,19 +117,17 @@ function parse(html) {
140
117
  });
141
118
  return result;
142
119
  }
143
- var attrString, stringifier;
144
- attrString = function (attrs) {
145
- var buff, key;
146
- buff = [];
147
- for (key in attrs) {
148
- buff.push(key + '="' + attrs[key] + '"');
120
+ function attrString(attrs) {
121
+ const buff = [];
122
+ for (const key in attrs) {
123
+ buff.push(key + '="' + attrs[key].replace(/"/g, '&quot;') + '"');
149
124
  }
150
125
  if (!buff.length) {
151
126
  return '';
152
127
  }
153
128
  return ' ' + buff.join(' ');
154
- };
155
- stringifier = function (buff, doc) {
129
+ }
130
+ function stringifier(buff, doc) {
156
131
  switch (doc.type) {
157
132
  case 'text':
158
133
  return buff + doc.content;
@@ -165,7 +140,7 @@ stringifier = function (buff, doc) {
165
140
  case 'comment':
166
141
  return buff += '<!--' + doc.content + '-->';
167
142
  }
168
- };
143
+ }
169
144
  function stringify(doc) {
170
145
  return doc.reduce(function (token, rootEl) {
171
146
  return token + stringifier('', rootEl);
package/html/dist/html.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { effect, style, insert, spread, createComponent, delegateEvents, classList, mergeProps, dynamicProperty, setAttribute, setAttributeNS, addEventListener, Aliases, PropAliases, Properties, ChildProperties, DelegatedEvents, SVGElements, SVGNamespace } from 'solid-js/web';
2
2
 
3
- var attrRE, lookup, parseTag, pushCommentNode, pushTextNode, tagRE;
4
- tagRE = /(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g;
5
- attrRE = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
6
- lookup = {
3
+ const tagRE = /(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g;
4
+ const attrRE = /(?:\s(?<boolean>[^/\s><=]+?)(?=[\s/>]))|(?:(?<name>\S+?)(?:\s*=\s*(?:(['"])(?<quotedValue>[\s\S]*?)\3|(?<unquotedValue>[^\s>]+))))/g;
5
+ const lookup = {
7
6
  area: true,
8
7
  base: true,
9
8
  br: true,
@@ -21,9 +20,9 @@ lookup = {
21
20
  track: true,
22
21
  wbr: true
23
22
  };
24
- parseTag = function (tag) {
25
- var res;
26
- res = {
23
+ function parseTag(
24
+ tag) {
25
+ const res = {
27
26
  type: 'tag',
28
27
  name: '',
29
28
  voidElement: false,
@@ -45,64 +44,42 @@ parseTag = function (tag) {
45
44
  }
46
45
  }
47
46
  const reg = new RegExp(attrRE);
48
- let result = null;
49
- for (;;) {
50
- result = reg.exec(tag);
51
- if (result === null) {
52
- break;
53
- }
54
- if (!result[0].trim()) {
55
- continue;
56
- }
57
- if (result[1]) {
58
- const attr = result[1].trim();
59
- let arr = [attr, ''];
60
- if (attr.indexOf('=') > -1) {
61
- arr = attr.split('=');
62
- }
63
- res.attrs[arr[0]] = arr[1];
64
- reg.lastIndex--;
65
- } else if (result[2]) {
66
- res.attrs[result[2]] = result[3].trim().substring(1, result[3].length - 1);
67
- }
47
+ for (const match of tag.matchAll(reg)) {
48
+ res.attrs[match[1] || match[2]] = match[4] || match[5] || '';
68
49
  }
69
50
  return res;
70
- };
71
- pushTextNode = function (list, html, start) {
72
- var content, end;
73
- end = html.indexOf('<', start);
74
- content = html.slice(start, end === -1 ? void 0 : end);
51
+ }
52
+ function pushTextNode(list, html, start) {
53
+ const end = html.indexOf('<', start);
54
+ const content = html.slice(start, end === -1 ? void 0 : end);
75
55
  if (!/^\s*$/.test(content)) {
76
56
  list.push({
77
57
  type: 'text',
78
58
  content: content
79
59
  });
80
60
  }
81
- };
82
- pushCommentNode = function (list, tag) {
83
- var content;
84
- content = tag.replace('<!--', '').replace('-->', '');
61
+ }
62
+ function pushCommentNode(list, tag) {
63
+ const content = tag.replace('<!--', '').replace('-->', '');
85
64
  if (!/^\s*$/.test(content)) {
86
65
  list.push({
87
66
  type: 'comment',
88
67
  content: content
89
68
  });
90
69
  }
91
- };
70
+ }
92
71
  function parse(html) {
93
- var arr, byTag, current, level, result;
94
- result = [];
95
- current = void 0;
96
- level = -1;
97
- arr = [];
98
- byTag = {};
99
- html.replace(tagRE, function (tag, index) {
100
- var isComment, isOpen, nextChar, parent, start;
101
- isOpen = tag.charAt(1) !== '/';
102
- isComment = tag.slice(0, 4) === '<!--';
103
- start = index + tag.length;
104
- nextChar = html.charAt(start);
105
- parent = void 0;
72
+ const result = [];
73
+ let current = void 0;
74
+ let level = -1;
75
+ const arr = [];
76
+ const byTag = {};
77
+ html.replace(tagRE, (tag, index) => {
78
+ const isOpen = tag.charAt(1) !== '/';
79
+ const isComment = tag.slice(0, 4) === '<!--';
80
+ const start = index + tag.length;
81
+ const nextChar = html.charAt(start);
82
+ let parent = void 0;
106
83
  if (isOpen && !isComment) {
107
84
  level++;
108
85
  current = parseTag(tag);
@@ -138,19 +115,17 @@ function parse(html) {
138
115
  });
139
116
  return result;
140
117
  }
141
- var attrString, stringifier;
142
- attrString = function (attrs) {
143
- var buff, key;
144
- buff = [];
145
- for (key in attrs) {
146
- buff.push(key + '="' + attrs[key] + '"');
118
+ function attrString(attrs) {
119
+ const buff = [];
120
+ for (const key in attrs) {
121
+ buff.push(key + '="' + attrs[key].replace(/"/g, '&quot;') + '"');
147
122
  }
148
123
  if (!buff.length) {
149
124
  return '';
150
125
  }
151
126
  return ' ' + buff.join(' ');
152
- };
153
- stringifier = function (buff, doc) {
127
+ }
128
+ function stringifier(buff, doc) {
154
129
  switch (doc.type) {
155
130
  case 'text':
156
131
  return buff + doc.content;
@@ -163,7 +138,7 @@ stringifier = function (buff, doc) {
163
138
  case 'comment':
164
139
  return buff += '<!--' + doc.content + '-->';
165
140
  }
166
- };
141
+ }
167
142
  function stringify(doc) {
168
143
  return doc.reduce(function (token, rootEl) {
169
144
  return token + stringifier('', rootEl);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "1.4.5",
4
+ "version": "1.4.8",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -151,5 +151,5 @@
151
151
  "compiler",
152
152
  "performance"
153
153
  ],
154
- "gitHead": "2c2252d6e4bd0d59f9164da32d6b6afc65dd4220"
154
+ "gitHead": "e7f60ab9ac33e0666d966b4ba50371f2a683a574"
155
155
  }
@@ -238,11 +238,11 @@ const proxyTraps = {
238
238
  return isWrappable(value) ? wrap(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
239
239
  },
240
240
  set(target, property, value) {
241
- setProperty(target, property, unwrap(value));
241
+ solidJs.batch(() => setProperty(target, property, unwrap(value)));
242
242
  return true;
243
243
  },
244
244
  deleteProperty(target, property) {
245
- setProperty(target, property, undefined);
245
+ solidJs.batch(() => setProperty(target, property, undefined));
246
246
  return true;
247
247
  },
248
248
  ownKeys: ownKeys,
package/store/dist/dev.js CHANGED
@@ -234,11 +234,11 @@ const proxyTraps = {
234
234
  return isWrappable(value) ? wrap(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
235
235
  },
236
236
  set(target, property, value) {
237
- setProperty(target, property, unwrap(value));
237
+ batch(() => setProperty(target, property, unwrap(value)));
238
238
  return true;
239
239
  },
240
240
  deleteProperty(target, property) {
241
- setProperty(target, property, undefined);
241
+ batch(() => setProperty(target, property, undefined));
242
242
  return true;
243
243
  },
244
244
  ownKeys: ownKeys,
@@ -226,11 +226,11 @@ const proxyTraps = {
226
226
  return isWrappable(value) ? wrap(value) : value;
227
227
  },
228
228
  set(target, property, value) {
229
- setProperty(target, property, unwrap(value));
229
+ solidJs.batch(() => setProperty(target, property, unwrap(value)));
230
230
  return true;
231
231
  },
232
232
  deleteProperty(target, property) {
233
- setProperty(target, property, undefined);
233
+ solidJs.batch(() => setProperty(target, property, undefined));
234
234
  return true;
235
235
  },
236
236
  ownKeys: ownKeys,
@@ -222,11 +222,11 @@ const proxyTraps = {
222
222
  return isWrappable(value) ? wrap(value) : value;
223
223
  },
224
224
  set(target, property, value) {
225
- setProperty(target, property, unwrap(value));
225
+ batch(() => setProperty(target, property, unwrap(value)));
226
226
  return true;
227
227
  },
228
228
  deleteProperty(target, property) {
229
- setProperty(target, property, undefined);
229
+ batch(() => setProperty(target, property, undefined));
230
230
  return true;
231
231
  },
232
232
  ownKeys: ownKeys,
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createReaction, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $DEVCOMP, $PROXY, $TRACK } from "./reactive/signal";
2
- export type { Accessor, Setter, Signal, Resource, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, Context, ReturnTypes } from "./reactive/signal";
2
+ export type { Accessor, Setter, Signal, Resource, ResourceOptions, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, Context, ReturnTypes, Owner } from "./reactive/signal";
3
3
  export * from "./reactive/observable";
4
4
  export * from "./reactive/scheduler";
5
5
  export * from "./reactive/array";
@@ -1,6 +1,11 @@
1
1
  import { Accessor, Setter } from "./signal";
2
+ declare global {
3
+ interface SymbolConstructor {
4
+ readonly observable: symbol;
5
+ }
6
+ }
2
7
  export declare type ObservableObserver<T> = ((v: T) => void) | {
3
- next: (v: T) => void;
8
+ next?: (v: T) => void;
4
9
  error?: (v: any) => void;
5
10
  complete?: (v: boolean) => void;
6
11
  };
@@ -15,10 +20,10 @@ export declare type ObservableObserver<T> = ((v: T) => void) | {
15
20
  * description https://www.solidjs.com/docs/latest/api#observable
16
21
  */
17
22
  export declare function observable<T>(input: Accessor<T>): {
18
- [x: number]: () => any;
19
23
  subscribe(observer: ObservableObserver<T>): {
20
24
  unsubscribe(): void;
21
25
  };
26
+ [Symbol.observable](): any;
22
27
  };
23
28
  export declare function from<T>(producer: ((setter: Setter<T>) => () => void) | {
24
29
  subscribe: (fn: (v: T) => void) => (() => void) | {
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -6,9 +6,9 @@ export interface RendererOptions<NodeType> {
6
6
  setProperty<T>(node: NodeType, name: string, value: T, prev?: T): void;
7
7
  insertNode(parent: NodeType, node: NodeType, anchor?: NodeType): void;
8
8
  removeNode(parent: NodeType, node: NodeType): void;
9
- getParentNode(node: NodeType): NodeType;
10
- getFirstChild(node: NodeType): NodeType;
11
- getNextSibling(node: NodeType): NodeType;
9
+ getParentNode(node: NodeType): NodeType | undefined;
10
+ getFirstChild(node: NodeType): NodeType | undefined;
11
+ getNextSibling(node: NodeType): NodeType | undefined;
12
12
  }
13
13
 
14
14
  export interface Renderer<NodeType> {
package/web/dist/dev.cjs CHANGED
@@ -446,13 +446,12 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
446
446
  let dynamic = false;
447
447
  for (let i = 0, len = array.length; i < len; i++) {
448
448
  let item = array[i],
449
- prev = current && current[i],
450
- t;
449
+ prev = current && current[i];
451
450
  if (item instanceof Node) {
452
451
  normalized.push(item);
453
452
  } else if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
454
453
  dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
455
- } else if ((t = typeof item) === "function") {
454
+ } else if ((typeof item) === "function") {
456
455
  if (unwrap) {
457
456
  while (typeof item === "function") item = item();
458
457
  dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item], prev) || dynamic;
@@ -461,7 +460,7 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
461
460
  dynamic = true;
462
461
  }
463
462
  } else {
464
- const value = t === "string" ? item : item.string();
463
+ const value = String(item);
465
464
  if (prev && prev.nodeType === 3 && prev.data === value) {
466
465
  normalized.push(prev);
467
466
  } else normalized.push(document.createTextNode(value));
package/web/dist/dev.js CHANGED
@@ -443,13 +443,12 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
443
443
  let dynamic = false;
444
444
  for (let i = 0, len = array.length; i < len; i++) {
445
445
  let item = array[i],
446
- prev = current && current[i],
447
- t;
446
+ prev = current && current[i];
448
447
  if (item instanceof Node) {
449
448
  normalized.push(item);
450
449
  } else if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
451
450
  dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
452
- } else if ((t = typeof item) === "function") {
451
+ } else if ((typeof item) === "function") {
453
452
  if (unwrap) {
454
453
  while (typeof item === "function") item = item();
455
454
  dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item], prev) || dynamic;
@@ -458,7 +457,7 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
458
457
  dynamic = true;
459
458
  }
460
459
  } else {
461
- const value = t === "string" ? item : item.string();
460
+ const value = String(item);
462
461
  if (prev && prev.nodeType === 3 && prev.data === value) {
463
462
  normalized.push(prev);
464
463
  } else normalized.push(document.createTextNode(value));
@@ -279,17 +279,18 @@ function renderToStringAsync(code, options = {}) {
279
279
  });
280
280
  function asyncWrap(fn) {
281
281
  return new Promise(resolve => {
282
- const registry = new Set();
282
+ const registry = new Map();
283
283
  const cache = Object.create(null);
284
284
  solidJs.sharedConfig.context.registerFragment = register;
285
285
  const rendered = fn();
286
286
  if (!registry.size) resolve(rendered);
287
287
  function register(key) {
288
- registry.add(key);
288
+ if (!registry.has(key)) registry.set(key, []);
289
289
  return (value = "", error) => {
290
290
  if (!registry.has(key)) return;
291
291
  cache[key] = value;
292
292
  registry.delete(key);
293
+ if (waitForFragments(registry, key)) return;
293
294
  if (error) scripts += `_$HY.set("${key}", Promise.resolve(${serializeError(error)}));`;else scripts += `_$HY.set("${key}", null);`;
294
295
  if (!registry.size) Promise.resolve().then(() => {
295
296
  let source = resolveSSRNode(rendered);
@@ -396,7 +397,7 @@ function renderToStream(code, options = {}) {
396
397
  pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}");`) : ""}_$HY.set("${key}",${error ? serializeError(error) : "null"})`);
397
398
  } else {
398
399
  buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div>`);
399
- pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") : ""}$df("${key}"${error ? "," + serializeError(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
400
+ pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," + serializeError(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
400
401
  scriptFlushed = true;
401
402
  }
402
403
  }
@@ -276,17 +276,18 @@ function renderToStringAsync(code, options = {}) {
276
276
  });
277
277
  function asyncWrap(fn) {
278
278
  return new Promise(resolve => {
279
- const registry = new Set();
279
+ const registry = new Map();
280
280
  const cache = Object.create(null);
281
281
  sharedConfig.context.registerFragment = register;
282
282
  const rendered = fn();
283
283
  if (!registry.size) resolve(rendered);
284
284
  function register(key) {
285
- registry.add(key);
285
+ if (!registry.has(key)) registry.set(key, []);
286
286
  return (value = "", error) => {
287
287
  if (!registry.has(key)) return;
288
288
  cache[key] = value;
289
289
  registry.delete(key);
290
+ if (waitForFragments(registry, key)) return;
290
291
  if (error) scripts += `_$HY.set("${key}", Promise.resolve(${serializeError(error)}));`;else scripts += `_$HY.set("${key}", null);`;
291
292
  if (!registry.size) Promise.resolve().then(() => {
292
293
  let source = resolveSSRNode(rendered);
@@ -393,7 +394,7 @@ function renderToStream(code, options = {}) {
393
394
  pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}");`) : ""}_$HY.set("${key}",${error ? serializeError(error) : "null"})`);
394
395
  } else {
395
396
  buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div>`);
396
- pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") : ""}$df("${key}"${error ? "," + serializeError(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
397
+ pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," + serializeError(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
397
398
  scriptFlushed = true;
398
399
  }
399
400
  }
package/web/dist/web.cjs CHANGED
@@ -445,13 +445,12 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
445
445
  let dynamic = false;
446
446
  for (let i = 0, len = array.length; i < len; i++) {
447
447
  let item = array[i],
448
- prev = current && current[i],
449
- t;
448
+ prev = current && current[i];
450
449
  if (item instanceof Node) {
451
450
  normalized.push(item);
452
451
  } else if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
453
452
  dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
454
- } else if ((t = typeof item) === "function") {
453
+ } else if ((typeof item) === "function") {
455
454
  if (unwrap) {
456
455
  while (typeof item === "function") item = item();
457
456
  dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item], prev) || dynamic;
@@ -460,7 +459,7 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
460
459
  dynamic = true;
461
460
  }
462
461
  } else {
463
- const value = t === "string" ? item : item.string();
462
+ const value = String(item);
464
463
  if (prev && prev.nodeType === 3 && prev.data === value) {
465
464
  normalized.push(prev);
466
465
  } else normalized.push(document.createTextNode(value));
package/web/dist/web.js CHANGED
@@ -442,13 +442,12 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
442
442
  let dynamic = false;
443
443
  for (let i = 0, len = array.length; i < len; i++) {
444
444
  let item = array[i],
445
- prev = current && current[i],
446
- t;
445
+ prev = current && current[i];
447
446
  if (item instanceof Node) {
448
447
  normalized.push(item);
449
448
  } else if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
450
449
  dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
451
- } else if ((t = typeof item) === "function") {
450
+ } else if ((typeof item) === "function") {
452
451
  if (unwrap) {
453
452
  while (typeof item === "function") item = item();
454
453
  dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item], prev) || dynamic;
@@ -457,7 +456,7 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
457
456
  dynamic = true;
458
457
  }
459
458
  } else {
460
- const value = t === "string" ? item : item.string();
459
+ const value = String(item);
461
460
  if (prev && prev.nodeType === 3 && prev.data === value) {
462
461
  normalized.push(prev);
463
462
  } else normalized.push(document.createTextNode(value));