solid-js 1.4.7 → 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
@@ -1020,31 +1020,33 @@ function serializeChildren(root) {
1020
1020
  return result;
1021
1021
  }
1022
1022
 
1023
- function getSymbol() {
1024
- const SymbolCopy = Symbol;
1025
- return SymbolCopy.observable || "@@observable";
1026
- }
1027
1023
  function observable(input) {
1028
- const $$observable = getSymbol();
1029
1024
  return {
1030
1025
  subscribe(observer) {
1031
1026
  if (!(observer instanceof Object) || observer == null) {
1032
1027
  throw new TypeError("Expected the observer to be an object.");
1033
1028
  }
1034
- const handler = "next" in observer ? observer.next.bind(observer) : observer;
1035
- let complete = false;
1036
- createComputed(() => {
1037
- if (complete) return;
1038
- const v = input();
1039
- 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;
1040
1041
  });
1042
+ if (getOwner()) onCleanup(dispose);
1041
1043
  return {
1042
1044
  unsubscribe() {
1043
- complete = true;
1045
+ dispose();
1044
1046
  }
1045
1047
  };
1046
1048
  },
1047
- [$$observable]() {
1049
+ [Symbol.observable || "@@observable"]() {
1048
1050
  return this;
1049
1051
  }
1050
1052
  };
package/dist/dev.js CHANGED
@@ -1016,31 +1016,33 @@ function serializeChildren(root) {
1016
1016
  return result;
1017
1017
  }
1018
1018
 
1019
- function getSymbol() {
1020
- const SymbolCopy = Symbol;
1021
- return SymbolCopy.observable || "@@observable";
1022
- }
1023
1019
  function observable(input) {
1024
- const $$observable = getSymbol();
1025
1020
  return {
1026
1021
  subscribe(observer) {
1027
1022
  if (!(observer instanceof Object) || observer == null) {
1028
1023
  throw new TypeError("Expected the observer to be an object.");
1029
1024
  }
1030
- const handler = "next" in observer ? observer.next.bind(observer) : observer;
1031
- let complete = false;
1032
- createComputed(() => {
1033
- if (complete) return;
1034
- const v = input();
1035
- 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;
1036
1037
  });
1038
+ if (getOwner()) onCleanup(dispose);
1037
1039
  return {
1038
1040
  unsubscribe() {
1039
- complete = true;
1041
+ dispose();
1040
1042
  }
1041
1043
  };
1042
1044
  },
1043
- [$$observable]() {
1045
+ [Symbol.observable || "@@observable"]() {
1044
1046
  return this;
1045
1047
  }
1046
1048
  };
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
@@ -933,31 +933,33 @@ function createProvider(id) {
933
933
  };
934
934
  }
935
935
 
936
- function getSymbol() {
937
- const SymbolCopy = Symbol;
938
- return SymbolCopy.observable || "@@observable";
939
- }
940
936
  function observable(input) {
941
- const $$observable = getSymbol();
942
937
  return {
943
938
  subscribe(observer) {
944
939
  if (!(observer instanceof Object) || observer == null) {
945
940
  throw new TypeError("Expected the observer to be an object.");
946
941
  }
947
- const handler = "next" in observer ? observer.next.bind(observer) : observer;
948
- let complete = false;
949
- createComputed(() => {
950
- if (complete) return;
951
- const v = input();
952
- 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;
953
954
  });
955
+ if (getOwner()) onCleanup(dispose);
954
956
  return {
955
957
  unsubscribe() {
956
- complete = true;
958
+ dispose();
957
959
  }
958
960
  };
959
961
  },
960
- [$$observable]() {
962
+ [Symbol.observable || "@@observable"]() {
961
963
  return this;
962
964
  }
963
965
  };
package/dist/solid.js CHANGED
@@ -929,31 +929,33 @@ function createProvider(id) {
929
929
  };
930
930
  }
931
931
 
932
- function getSymbol() {
933
- const SymbolCopy = Symbol;
934
- return SymbolCopy.observable || "@@observable";
935
- }
936
932
  function observable(input) {
937
- const $$observable = getSymbol();
938
933
  return {
939
934
  subscribe(observer) {
940
935
  if (!(observer instanceof Object) || observer == null) {
941
936
  throw new TypeError("Expected the observer to be an object.");
942
937
  }
943
- const handler = "next" in observer ? observer.next.bind(observer) : observer;
944
- let complete = false;
945
- createComputed(() => {
946
- if (complete) return;
947
- const v = input();
948
- 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;
949
950
  });
951
+ if (getOwner()) onCleanup(dispose);
950
952
  return {
951
953
  unsubscribe() {
952
- complete = true;
954
+ dispose();
953
955
  }
954
956
  };
955
957
  },
956
- [$$observable]() {
958
+ [Symbol.observable || "@@observable"]() {
957
959
  return this;
958
960
  }
959
961
  };
@@ -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.7",
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": "b2873ffbbb73ef76214d32db86a8f676722fb1c2"
154
+ "gitHead": "e7f60ab9ac33e0666d966b4ba50371f2a683a574"
155
155
  }
@@ -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> {