solid-js 1.8.3 → 1.8.4

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
@@ -1664,7 +1664,7 @@ function Suspense(props) {
1664
1664
  if (sharedConfig.context && sharedConfig.load) {
1665
1665
  const key = sharedConfig.context.id + sharedConfig.context.count;
1666
1666
  let ref = sharedConfig.load(key);
1667
- if (ref && (typeof ref !== "object" || ref.status !== 'success')) p = ref;
1667
+ if (ref && (typeof ref !== "object" || ref.status !== "success")) p = ref;
1668
1668
  if (p && p !== "$$f") {
1669
1669
  const [s, set] = createSignal(undefined, {
1670
1670
  equals: false
package/dist/solid.cjs CHANGED
@@ -1602,7 +1602,7 @@ function Suspense(props) {
1602
1602
  if (sharedConfig.context && sharedConfig.load) {
1603
1603
  const key = sharedConfig.context.id + sharedConfig.context.count;
1604
1604
  let ref = sharedConfig.load(key);
1605
- if (ref && (typeof ref !== "object" || ref.status !== 'success')) p = ref;
1605
+ if (ref && (typeof ref !== "object" || ref.status !== "success")) p = ref;
1606
1606
  if (p && p !== "$$f") {
1607
1607
  const [s, set] = createSignal(undefined, {
1608
1608
  equals: false
@@ -15,7 +15,9 @@ interface Runtime {
15
15
  prev?: {
16
16
  [k: string]: boolean;
17
17
  }
18
- ): void;
18
+ ): {
19
+ [k: string]: boolean;
20
+ };
19
21
  style(
20
22
  node: Element,
21
23
  value: {
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.8.3",
4
+ "version": "1.8.4",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -159,6 +159,10 @@
159
159
  "import": "./web/dist/web.js",
160
160
  "require": "./web/dist/web.cjs"
161
161
  },
162
+ "./web/storage": {
163
+ "import": "./web/dist/storage.js",
164
+ "require": "./web/dist/storage.cjs"
165
+ },
162
166
  "./web/dist/*": "./web/dist/*",
163
167
  "./universal": {
164
168
  "development": {
@@ -206,7 +210,7 @@
206
210
  ],
207
211
  "dependencies": {
208
212
  "csstype": "^3.1.0",
209
- "seroval": "^0.11.6"
213
+ "seroval": "^0.12.0"
210
214
  },
211
215
  "scripts": {
212
216
  "build": "npm-run-all -nl build:*",
@@ -217,7 +221,7 @@
217
221
  "types:copy": "ncp ../../node_modules/dom-expressions/src/jsx.d.ts ./src/jsx.d.ts && ncp ../../node_modules/dom-expressions/src/jsx-h.d.ts ./h/jsx-runtime/src/jsx.d.ts",
218
222
  "types:src": "tsc --project ./tsconfig.build.json && ncp ../../node_modules/dom-expressions/src/jsx.d.ts ./types/jsx.d.ts",
219
223
  "types:web": "tsc --project ./web/tsconfig.build.json",
220
- "types:copy-web": "ncp ../../node_modules/dom-expressions/src/client.d.ts ./web/types/client.d.ts && ncp ../../node_modules/dom-expressions/src/server.d.ts ./web/types/server.d.ts",
224
+ "types:copy-web": "ncp ../../node_modules/dom-expressions/src/client.d.ts ./web/types/client.d.ts && ncp ../../node_modules/dom-expressions/src/server.d.ts ./web/types/server.d.ts && ncp ./web/storage/storage.d.ts ./web/types/storage.d.ts",
221
225
  "types:store": "tsc --project ./store/tsconfig.build.json",
222
226
  "types:html": "tsc --project ./html/tsconfig.json && ncp ../../node_modules/lit-dom-expressions/types/index.d.ts ./html/types/lit.d.ts",
223
227
  "types:h": "tsc --project ./h/tsconfig.json && ncp ../../node_modules/hyper-dom-expressions/types/index.d.ts ./h/types/hyperscript.d.ts",
package/web/dist/dev.cjs CHANGED
@@ -537,6 +537,7 @@ function Hydration(props) {
537
537
  return props.children;
538
538
  }
539
539
  function voidFn() {}
540
+ const RequestContext = Symbol();
540
541
  function innerHTML(parent, content) {
541
542
  !solidJs.sharedConfig.context && (parent.innerHTML = content);
542
543
  }
@@ -700,6 +701,7 @@ exports.HydrationScript = voidFn;
700
701
  exports.NoHydration = NoHydration;
701
702
  exports.Portal = Portal;
702
703
  exports.Properties = Properties;
704
+ exports.RequestContext = RequestContext;
703
705
  exports.SVGElements = SVGElements;
704
706
  exports.SVGNamespace = SVGNamespace;
705
707
  exports.addEventListener = addEventListener;
@@ -717,6 +719,7 @@ exports.getNextElement = getNextElement;
717
719
  exports.getNextMarker = getNextMarker;
718
720
  exports.getNextMatch = getNextMatch;
719
721
  exports.getPropAlias = getPropAlias;
722
+ exports.getRequestEvent = voidFn;
720
723
  exports.hydrate = hydrate;
721
724
  exports.innerHTML = innerHTML;
722
725
  exports.insert = insert;
package/web/dist/dev.js CHANGED
@@ -1012,6 +1012,7 @@ function Hydration(props) {
1012
1012
  return props.children;
1013
1013
  }
1014
1014
  function voidFn() {}
1015
+ const RequestContext = Symbol();
1015
1016
  function innerHTML(parent, content) {
1016
1017
  !sharedConfig.context && (parent.innerHTML = content);
1017
1018
  }
@@ -1125,6 +1126,7 @@ export {
1125
1126
  NoHydration,
1126
1127
  Portal,
1127
1128
  Properties,
1129
+ RequestContext,
1128
1130
  SVGElements,
1129
1131
  SVGNamespace,
1130
1132
  addEventListener,
@@ -1142,6 +1144,7 @@ export {
1142
1144
  getNextMarker,
1143
1145
  getNextMatch,
1144
1146
  getPropAlias,
1147
+ voidFn as getRequestEvent,
1145
1148
  hydrate,
1146
1149
  innerHTML,
1147
1150
  insert,
@@ -18,14 +18,16 @@ const GLOBAL_IDENTIFIER = '_$HY.r';
18
18
  function createSerializer({
19
19
  onData,
20
20
  onDone,
21
- scopeId
21
+ scopeId,
22
+ onError
22
23
  }) {
23
24
  return new seroval.Serializer({
24
25
  scopeId,
25
26
  globalIdentifier: GLOBAL_IDENTIFIER,
26
27
  disabledFeatures: ES2017FLAG,
27
28
  onData,
28
- onDone
29
+ onDone,
30
+ onError
29
31
  });
30
32
  }
31
33
  function getGlobalHeaderScript() {
@@ -49,7 +51,8 @@ function renderToString(code, options = {}) {
49
51
  scripts = getLocalHeaderScript(renderId);
50
52
  }
51
53
  scripts += script;
52
- }
54
+ },
55
+ onError: options.onError
53
56
  });
54
57
  solidJs.sharedConfig.context = {
55
58
  id: renderId || "",
@@ -90,11 +93,13 @@ function renderToStream(code, options = {}) {
90
93
  nonce,
91
94
  onCompleteShell,
92
95
  onCompleteAll,
93
- renderId
96
+ renderId,
97
+ noScripts
94
98
  } = options;
95
99
  let dispose;
96
100
  const blockingPromises = [];
97
101
  const pushTask = task => {
102
+ if (noScripts) return;
98
103
  if (!tasks && !firstFlushed) {
99
104
  tasks = getLocalHeaderScript(renderId);
100
105
  }
@@ -119,7 +124,8 @@ function renderToStream(code, options = {}) {
119
124
  const serializer = createSerializer({
120
125
  scopeId: options.renderId,
121
126
  onData: pushTask,
122
- onDone: checkEnd
127
+ onDone: checkEnd,
128
+ onError: options.onError
123
129
  });
124
130
  const flushEnd = () => {
125
131
  if (!registry.size) {
@@ -507,6 +513,10 @@ function replacePlaceholder(html, key, value) {
507
513
  const last = html.indexOf(close, first + marker.length);
508
514
  return html.slice(0, first) + value + html.slice(last + close.length);
509
515
  }
516
+ const RequestContext = Symbol();
517
+ function getRequestEvent() {
518
+ return globalThis[RequestContext] ? globalThis[RequestContext].getStore() : undefined;
519
+ }
510
520
  function Assets(props) {
511
521
  useAssets(() => props.children);
512
522
  }
@@ -643,12 +653,14 @@ exports.Hydration = Hydration;
643
653
  exports.HydrationScript = HydrationScript;
644
654
  exports.NoHydration = NoHydration;
645
655
  exports.Portal = Portal;
656
+ exports.RequestContext = RequestContext;
646
657
  exports.addEventListener = addEventListener;
647
658
  exports.delegateEvents = delegateEvents;
648
659
  exports.escape = escape;
649
660
  exports.generateHydrationScript = generateHydrationScript;
650
661
  exports.getAssets = getAssets;
651
662
  exports.getHydrationKey = getHydrationKey;
663
+ exports.getRequestEvent = getRequestEvent;
652
664
  exports.hydrate = hydrate;
653
665
  exports.insert = insert;
654
666
  exports.isDev = isDev;
@@ -53,13 +53,14 @@ const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
53
53
 
54
54
  const ES2017FLAG = Feature.AggregateError | Feature.BigInt | Feature.BigIntTypedArray;
55
55
  const GLOBAL_IDENTIFIER = "_$HY.r";
56
- function createSerializer({ onData, onDone, scopeId }) {
56
+ function createSerializer({ onData, onDone, scopeId, onError }) {
57
57
  return new Serializer({
58
58
  scopeId,
59
59
  globalIdentifier: GLOBAL_IDENTIFIER,
60
60
  disabledFeatures: ES2017FLAG,
61
61
  onData,
62
- onDone
62
+ onDone,
63
+ onError
63
64
  });
64
65
  }
65
66
  function getGlobalHeaderScript() {
@@ -82,7 +83,8 @@ function renderToString(code, options = {}) {
82
83
  scripts = getLocalHeaderScript(renderId);
83
84
  }
84
85
  scripts += script;
85
- }
86
+ },
87
+ onError: options.onError
86
88
  });
87
89
  sharedConfig.context = {
88
90
  id: renderId || "",
@@ -117,10 +119,11 @@ function renderToStringAsync(code, options = {}) {
117
119
  });
118
120
  }
119
121
  function renderToStream(code, options = {}) {
120
- let { nonce, onCompleteShell, onCompleteAll, renderId } = options;
122
+ let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
121
123
  let dispose;
122
124
  const blockingPromises = [];
123
125
  const pushTask = task => {
126
+ if (noScripts) return;
124
127
  if (!tasks && !firstFlushed) {
125
128
  tasks = getLocalHeaderScript(renderId);
126
129
  }
@@ -146,7 +149,8 @@ function renderToStream(code, options = {}) {
146
149
  const serializer = createSerializer({
147
150
  scopeId: options.renderId,
148
151
  onData: pushTask,
149
- onDone: checkEnd
152
+ onDone: checkEnd,
153
+ onError: options.onError
150
154
  });
151
155
  const flushEnd = () => {
152
156
  if (!registry.size) {
@@ -551,6 +555,10 @@ function replacePlaceholder(html, key, value) {
551
555
  const last = html.indexOf(close, first + marker.length);
552
556
  return html.slice(0, first) + value + html.slice(last + close.length);
553
557
  }
558
+ const RequestContext = Symbol();
559
+ function getRequestEvent() {
560
+ return globalThis[RequestContext] ? globalThis[RequestContext].getStore() : undefined;
561
+ }
554
562
  function Assets(props) {
555
563
  useAssets(() => props.children);
556
564
  }
@@ -653,12 +661,14 @@ export {
653
661
  HydrationScript,
654
662
  NoHydration,
655
663
  Portal,
664
+ RequestContext,
656
665
  addEventListener,
657
666
  delegateEvents,
658
667
  escape,
659
668
  generateHydrationScript,
660
669
  getAssets,
661
670
  getHydrationKey,
671
+ getRequestEvent,
662
672
  hydrate,
663
673
  insert,
664
674
  isDev,
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var node_async_hooks = require('node:async_hooks');
4
+ var web = require('solid-js/web');
5
+
6
+ function provideRequestEvent(init, cb) {
7
+ if (!web.isServer) throw new Error("Attempting to use server context in non-server build");
8
+ const ctx = globalThis[web.RequestContext] = globalThis[web.RequestContext] || new node_async_hooks.AsyncLocalStorage();
9
+ return ctx.run(init, cb);
10
+ }
11
+
12
+ exports.provideRequestEvent = provideRequestEvent;
@@ -0,0 +1,10 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { isServer, RequestContext } from "solid-js/web";
3
+
4
+ function provideRequestEvent(init, cb) {
5
+ if (!isServer) throw new Error("Attempting to use server context in non-server build");
6
+ const ctx = (globalThis[RequestContext] = globalThis[RequestContext] || new AsyncLocalStorage());
7
+ return ctx.run(init, cb);
8
+ }
9
+
10
+ export { provideRequestEvent };
package/web/dist/web.cjs CHANGED
@@ -535,6 +535,7 @@ function Hydration(props) {
535
535
  return props.children;
536
536
  }
537
537
  function voidFn() {}
538
+ const RequestContext = Symbol();
538
539
  function innerHTML(parent, content) {
539
540
  !solidJs.sharedConfig.context && (parent.innerHTML = content);
540
541
  }
@@ -695,6 +696,7 @@ exports.HydrationScript = voidFn;
695
696
  exports.NoHydration = NoHydration;
696
697
  exports.Portal = Portal;
697
698
  exports.Properties = Properties;
699
+ exports.RequestContext = RequestContext;
698
700
  exports.SVGElements = SVGElements;
699
701
  exports.SVGNamespace = SVGNamespace;
700
702
  exports.addEventListener = addEventListener;
@@ -712,6 +714,7 @@ exports.getNextElement = getNextElement;
712
714
  exports.getNextMarker = getNextMarker;
713
715
  exports.getNextMatch = getNextMatch;
714
716
  exports.getPropAlias = getPropAlias;
717
+ exports.getRequestEvent = voidFn;
715
718
  exports.hydrate = hydrate;
716
719
  exports.innerHTML = innerHTML;
717
720
  exports.insert = insert;
package/web/dist/web.js CHANGED
@@ -1005,6 +1005,7 @@ function Hydration(props) {
1005
1005
  return props.children;
1006
1006
  }
1007
1007
  function voidFn() {}
1008
+ const RequestContext = Symbol();
1008
1009
  function innerHTML(parent, content) {
1009
1010
  !sharedConfig.context && (parent.innerHTML = content);
1010
1011
  }
@@ -1115,6 +1116,7 @@ export {
1115
1116
  NoHydration,
1116
1117
  Portal,
1117
1118
  Properties,
1119
+ RequestContext,
1118
1120
  SVGElements,
1119
1121
  SVGNamespace,
1120
1122
  addEventListener,
@@ -1132,6 +1134,7 @@ export {
1132
1134
  getNextMarker,
1133
1135
  getNextMatch,
1134
1136
  getPropAlias,
1137
+ voidFn as getRequestEvent,
1135
1138
  hydrate,
1136
1139
  innerHTML,
1137
1140
  insert,
@@ -44,7 +44,7 @@ export function classList(
44
44
  node: Element,
45
45
  value: { [k: string]: boolean },
46
46
  prev?: { [k: string]: boolean }
47
- ): void;
47
+ ): { [k: string]: boolean };
48
48
  export function style(
49
49
  node: Element,
50
50
  value: { [k: string]: string },
@@ -70,3 +70,8 @@ export function generateHydrationScript(): string;
70
70
  export function Assets(props: { children?: JSX.Element }): JSX.Element;
71
71
  export function Hydration(props: { children?: JSX.Element }): JSX.Element;
72
72
  export function NoHydration(props: { children?: JSX.Element }): JSX.Element;
73
+ export interface RequestEvent {
74
+ request: Request;
75
+ }
76
+ export declare const RequestContext: unique symbol;
77
+ export function getRequestEvent(): RequestEvent | undefined;
@@ -3,6 +3,7 @@ export function renderToString<T>(
3
3
  options?: {
4
4
  nonce?: string;
5
5
  renderId?: string;
6
+ onError?: (err: any) => void;
6
7
  }
7
8
  ): string;
8
9
  export function renderToStringAsync<T>(
@@ -11,6 +12,8 @@ export function renderToStringAsync<T>(
11
12
  timeoutMs?: number;
12
13
  nonce?: string;
13
14
  renderId?: string;
15
+ noScripts?: boolean;
16
+ onError?: (err: any) => void;
14
17
  }
15
18
  ): Promise<string>;
16
19
  export function renderToStream<T>(
@@ -20,6 +23,7 @@ export function renderToStream<T>(
20
23
  renderId?: string;
21
24
  onCompleteShell?: (info: { write: (v: string) => void }) => void;
22
25
  onCompleteAll?: (info: { write: (v: string) => void }) => void;
26
+ onError?: (err: any) => void;
23
27
  }
24
28
  ): {
25
29
  pipe: (writable: { write: (v: string) => void }) => void;
@@ -49,7 +53,12 @@ export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): J
49
53
  export function mergeProps(...sources: unknown[]): unknown;
50
54
  export function getOwner(): unknown;
51
55
  export function generateHydrationScript(options: { nonce?: string; eventNames?: string[] }): string;
52
- export function stringify(root: unknown): string;
56
+ export declare const RequestContext: unique symbol;
57
+ export interface RequestEvent {
58
+ request: Request;
59
+ locals: Record<string | number | symbol, any>;
60
+ }
61
+ export function getRequestEvent(): RequestEvent | undefined;
53
62
 
54
63
  export function Hydration(props: { children?: JSX.Element }): JSX.Element;
55
64
  export function NoHydration(props: { children?: JSX.Element }): JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { RequestEvent } from "solid-js/web";
2
+ export function provideRequestEvent<T extends RequestEvent, U>(init: T, cb: () => U): U;