@solidjs/web 2.0.0-experimental.14 → 2.0.0-experimental.16

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/web.cjs CHANGED
@@ -19,6 +19,9 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
19
19
  "webview",
20
20
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
21
21
 
22
+ const effect = (fn, effectFn, initial) => solidJs.createRenderEffect(fn, effectFn, initial, {
23
+ transparent: true
24
+ });
22
25
  const memo = fn => solidJs.createMemo(() => fn());
23
26
 
24
27
  function reconcileArrays(parentNode, a, b) {
@@ -94,12 +97,13 @@ function render(code, element, init, options = {}) {
94
97
  }
95
98
  function template(html, isImportNode, isSVG, isMathML) {
96
99
  let node;
97
- const create = () => {
100
+ const create = bypassGuard => {
98
101
  const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
99
102
  t.innerHTML = html;
100
103
  return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
101
104
  };
102
- return isImportNode ? () => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
105
+ const fn = isImportNode ? bypassGuard => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : bypassGuard => (node || (node = create())).cloneNode(true);
106
+ return fn;
103
107
  }
104
108
  function delegateEvents(eventNames, document = window.document) {
105
109
  const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
@@ -172,7 +176,7 @@ function addEventListener(node, name, handler, delegate) {
172
176
  }
173
177
  function style(node, value, prev) {
174
178
  if (!value) {
175
- prev ? setAttribute(node, "style") : value;
179
+ if (prev) setAttribute(node, "style");
176
180
  return;
177
181
  }
178
182
  const nodeStyle = node.style;
@@ -194,13 +198,16 @@ function setStyleProperty(node, name, value) {
194
198
  function spread(node, props = {}, isSVG, skipChildren) {
195
199
  const prevProps = {};
196
200
  if (!skipChildren) {
197
- solidJs.createRenderEffect(() => normalize(props.children, prevProps.children), value => {
201
+ effect(() => normalize(props.children, prevProps.children), value => {
198
202
  insertExpression(node, value, prevProps.children);
199
203
  prevProps.children = value;
200
204
  });
201
205
  }
202
- solidJs.createRenderEffect(() => typeof props.ref === "function" && use(props.ref, node), () => {});
203
- solidJs.createRenderEffect(() => {
206
+ effect(() => {
207
+ const r = props.ref;
208
+ (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
209
+ }, () => {});
210
+ effect(() => {
204
211
  const newProps = {};
205
212
  for (const prop in props) {
206
213
  if (prop === "children" || prop === "ref") continue;
@@ -220,17 +227,28 @@ function dynamicProperty(props, key) {
220
227
  });
221
228
  return props;
222
229
  }
223
- function use(fn, element, arg) {
224
- solidJs.untrack(() => fn(element, arg));
230
+ function applyRef(r, element) {
231
+ Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
232
+ }
233
+ function ref(fn, element) {
234
+ const resolved = solidJs.untrack(fn);
235
+ solidJs.runWithOwner(null, () => applyRef(resolved, element));
225
236
  }
226
237
  function insert(parent, accessor, marker, initial) {
227
238
  const multi = marker !== undefined;
228
239
  if (multi && !initial) initial = [];
240
+ if (isHydrating(parent) && Array.isArray(initial)) {
241
+ let j = 0;
242
+ for (let i = 0; i < initial.length; i++) {
243
+ if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
244
+ }
245
+ initial.length = j;
246
+ }
229
247
  if (typeof accessor !== "function") {
230
248
  accessor = normalize(accessor, initial, multi, true);
231
249
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
232
250
  }
233
- solidJs.createRenderEffect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
251
+ effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
234
252
  }
235
253
  function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
236
254
  props || (props = {});
@@ -252,11 +270,29 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
252
270
  function hydrate$1(code, element, options = {}) {
253
271
  if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
254
272
  options.renderId ||= "";
273
+ if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
274
+ if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
255
275
  solidJs.sharedConfig.completed = globalThis._$HY.completed;
256
276
  solidJs.sharedConfig.events = globalThis._$HY.events;
257
277
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
258
278
  solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
259
279
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
280
+ solidJs.sharedConfig.cleanupFragment = id => {
281
+ const tpl = document.getElementById("pl-" + id);
282
+ if (tpl) {
283
+ let node = tpl.nextSibling;
284
+ while (node) {
285
+ const next = node.nextSibling;
286
+ if (node.nodeType === 8 && node.nodeValue === "pl-" + id) {
287
+ node.remove();
288
+ break;
289
+ }
290
+ node.remove();
291
+ node = next;
292
+ }
293
+ tpl.remove();
294
+ }
295
+ };
260
296
  solidJs.sharedConfig.registry = new Map();
261
297
  solidJs.sharedConfig.hydrating = true;
262
298
  try {
@@ -271,7 +307,10 @@ function getNextElement(template) {
271
307
  key,
272
308
  hydrating = isHydrating();
273
309
  if (!hydrating || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
274
- return template();
310
+ if (!template) {
311
+ throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
312
+ }
313
+ return template(true);
275
314
  }
276
315
  if (solidJs.sharedConfig.completed) solidJs.sharedConfig.completed.add(node);
277
316
  solidJs.sharedConfig.registry.delete(key);
@@ -300,6 +339,14 @@ function getNextMarker(start) {
300
339
  }
301
340
  return [end, current];
302
341
  }
342
+ function getFirstChild(node, expectedTag) {
343
+ const child = node.firstChild;
344
+ return child;
345
+ }
346
+ function getNextSibling(node, expectedTag) {
347
+ const sibling = node.nextSibling;
348
+ return sibling;
349
+ }
303
350
  function runHydrationEvents() {
304
351
  if (solidJs.sharedConfig.events && !solidJs.sharedConfig.events.queued) {
305
352
  queueMicrotask(() => {
@@ -324,7 +371,7 @@ function runHydrationEvents() {
324
371
  }
325
372
  }
326
373
  function isHydrating(node) {
327
- return solidJs.sharedConfig.hydrating && !solidJs.sharedConfig.done && (!node || node.isConnected);
374
+ return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
328
375
  }
329
376
  function toggleClassKey(node, key, value) {
330
377
  const classNames = key.trim().split(/\s+/);
@@ -350,7 +397,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
350
397
  if (prop === "class") return className(node, value, isSVG, prev), value;
351
398
  if (value === prev) return prev;
352
399
  if (prop === "ref") {
353
- if (!skipRef) value(node);
400
+ if (!skipRef && value) ref(() => value, node);
354
401
  } else if (prop.slice(0, 3) === "on:") {
355
402
  const e = prop.slice(3);
356
403
  prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
@@ -406,7 +453,6 @@ function eventHandler(e) {
406
453
  return node || document;
407
454
  }
408
455
  });
409
- if (solidJs.sharedConfig.registry && !solidJs.sharedConfig.done) solidJs.sharedConfig.done = _$HY.done = true;
410
456
  if (e.composedPath) {
411
457
  const path = e.composedPath();
412
458
  retarget(path[0]);
@@ -630,10 +676,6 @@ Object.defineProperty(exports, "createComponent", {
630
676
  enumerable: true,
631
677
  get: function () { return solidJs.createComponent; }
632
678
  });
633
- Object.defineProperty(exports, "effect", {
634
- enumerable: true,
635
- get: function () { return solidJs.createRenderEffect; }
636
- });
637
679
  Object.defineProperty(exports, "getOwner", {
638
680
  enumerable: true,
639
681
  get: function () { return solidJs.getOwner; }
@@ -660,25 +702,30 @@ exports.RequestContext = RequestContext;
660
702
  exports.SVGElements = SVGElements;
661
703
  exports.SVGNamespace = SVGNamespace;
662
704
  exports.addEventListener = addEventListener;
705
+ exports.applyRef = applyRef;
663
706
  exports.assign = assign;
664
707
  exports.className = className;
665
708
  exports.clearDelegatedEvents = clearDelegatedEvents;
666
709
  exports.createDynamic = createDynamic;
667
710
  exports.delegateEvents = delegateEvents;
668
711
  exports.dynamicProperty = dynamicProperty;
712
+ exports.effect = effect;
669
713
  exports.escape = escape;
670
714
  exports.generateHydrationScript = voidFn;
671
715
  exports.getAssets = voidFn;
716
+ exports.getFirstChild = getFirstChild;
672
717
  exports.getHydrationKey = getHydrationKey;
673
718
  exports.getNextElement = getNextElement;
674
719
  exports.getNextMarker = getNextMarker;
675
720
  exports.getNextMatch = getNextMatch;
721
+ exports.getNextSibling = getNextSibling;
676
722
  exports.getRequestEvent = voidFn;
677
723
  exports.hydrate = hydrate;
678
724
  exports.insert = insert;
679
725
  exports.isDev = isDev;
680
726
  exports.isServer = isServer;
681
727
  exports.memo = memo;
728
+ exports.ref = ref;
682
729
  exports.render = render;
683
730
  exports.renderToStream = renderToStream;
684
731
  exports.renderToString = renderToString;
@@ -698,5 +745,4 @@ exports.ssrHydrationKey = ssrHydrationKey;
698
745
  exports.ssrStyle = ssrStyle;
699
746
  exports.style = style;
700
747
  exports.template = template;
701
- exports.use = use;
702
748
  exports.useAssets = voidFn;
package/dist/web.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createMemo, createRoot, flatten, untrack, createRenderEffect, sharedConfig, enableHydration, omit } from 'solid-js';
2
- export { Errored, For, Loading, Match, Show, Switch, createComponent, createRenderEffect as effect, getOwner, merge as mergeProps, untrack } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, createRoot, flatten, omit, enableHydration } from 'solid-js';
2
+ export { Errored, For, Loading, Match, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
3
 
4
4
  const Properties = /*#__PURE__*/new Set([
5
5
  "value", "checked", "selected", "muted"]);
@@ -18,6 +18,9 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
18
18
  "webview",
19
19
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
20
20
 
21
+ const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
22
+ transparent: true
23
+ });
21
24
  const memo = fn => createMemo(() => fn());
22
25
 
23
26
  function reconcileArrays(parentNode, a, b) {
@@ -93,12 +96,13 @@ function render(code, element, init, options = {}) {
93
96
  }
94
97
  function template(html, isImportNode, isSVG, isMathML) {
95
98
  let node;
96
- const create = () => {
99
+ const create = bypassGuard => {
97
100
  const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
98
101
  t.innerHTML = html;
99
102
  return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
100
103
  };
101
- return isImportNode ? () => untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
104
+ const fn = isImportNode ? bypassGuard => untrack(() => document.importNode(node || (node = create()), true)) : bypassGuard => (node || (node = create())).cloneNode(true);
105
+ return fn;
102
106
  }
103
107
  function delegateEvents(eventNames, document = window.document) {
104
108
  const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
@@ -171,7 +175,7 @@ function addEventListener(node, name, handler, delegate) {
171
175
  }
172
176
  function style(node, value, prev) {
173
177
  if (!value) {
174
- prev ? setAttribute(node, "style") : value;
178
+ if (prev) setAttribute(node, "style");
175
179
  return;
176
180
  }
177
181
  const nodeStyle = node.style;
@@ -193,13 +197,16 @@ function setStyleProperty(node, name, value) {
193
197
  function spread(node, props = {}, isSVG, skipChildren) {
194
198
  const prevProps = {};
195
199
  if (!skipChildren) {
196
- createRenderEffect(() => normalize(props.children, prevProps.children), value => {
200
+ effect(() => normalize(props.children, prevProps.children), value => {
197
201
  insertExpression(node, value, prevProps.children);
198
202
  prevProps.children = value;
199
203
  });
200
204
  }
201
- createRenderEffect(() => typeof props.ref === "function" && use(props.ref, node), () => {});
202
- createRenderEffect(() => {
205
+ effect(() => {
206
+ const r = props.ref;
207
+ (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
208
+ }, () => {});
209
+ effect(() => {
203
210
  const newProps = {};
204
211
  for (const prop in props) {
205
212
  if (prop === "children" || prop === "ref") continue;
@@ -219,17 +226,28 @@ function dynamicProperty(props, key) {
219
226
  });
220
227
  return props;
221
228
  }
222
- function use(fn, element, arg) {
223
- untrack(() => fn(element, arg));
229
+ function applyRef(r, element) {
230
+ Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
231
+ }
232
+ function ref(fn, element) {
233
+ const resolved = untrack(fn);
234
+ runWithOwner(null, () => applyRef(resolved, element));
224
235
  }
225
236
  function insert(parent, accessor, marker, initial) {
226
237
  const multi = marker !== undefined;
227
238
  if (multi && !initial) initial = [];
239
+ if (isHydrating(parent) && Array.isArray(initial)) {
240
+ let j = 0;
241
+ for (let i = 0; i < initial.length; i++) {
242
+ if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
243
+ }
244
+ initial.length = j;
245
+ }
228
246
  if (typeof accessor !== "function") {
229
247
  accessor = normalize(accessor, initial, multi, true);
230
248
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
231
249
  }
232
- createRenderEffect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
250
+ effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
233
251
  }
234
252
  function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
235
253
  props || (props = {});
@@ -251,11 +269,29 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
251
269
  function hydrate$1(code, element, options = {}) {
252
270
  if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
253
271
  options.renderId ||= "";
272
+ if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
273
+ if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
254
274
  sharedConfig.completed = globalThis._$HY.completed;
255
275
  sharedConfig.events = globalThis._$HY.events;
256
276
  sharedConfig.load = id => globalThis._$HY.r[id];
257
277
  sharedConfig.has = id => id in globalThis._$HY.r;
258
278
  sharedConfig.gather = root => gatherHydratable(element, root);
279
+ sharedConfig.cleanupFragment = id => {
280
+ const tpl = document.getElementById("pl-" + id);
281
+ if (tpl) {
282
+ let node = tpl.nextSibling;
283
+ while (node) {
284
+ const next = node.nextSibling;
285
+ if (node.nodeType === 8 && node.nodeValue === "pl-" + id) {
286
+ node.remove();
287
+ break;
288
+ }
289
+ node.remove();
290
+ node = next;
291
+ }
292
+ tpl.remove();
293
+ }
294
+ };
259
295
  sharedConfig.registry = new Map();
260
296
  sharedConfig.hydrating = true;
261
297
  try {
@@ -270,7 +306,10 @@ function getNextElement(template) {
270
306
  key,
271
307
  hydrating = isHydrating();
272
308
  if (!hydrating || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
273
- return template();
309
+ if (!template) {
310
+ throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
311
+ }
312
+ return template(true);
274
313
  }
275
314
  if (sharedConfig.completed) sharedConfig.completed.add(node);
276
315
  sharedConfig.registry.delete(key);
@@ -299,6 +338,14 @@ function getNextMarker(start) {
299
338
  }
300
339
  return [end, current];
301
340
  }
341
+ function getFirstChild(node, expectedTag) {
342
+ const child = node.firstChild;
343
+ return child;
344
+ }
345
+ function getNextSibling(node, expectedTag) {
346
+ const sibling = node.nextSibling;
347
+ return sibling;
348
+ }
302
349
  function runHydrationEvents() {
303
350
  if (sharedConfig.events && !sharedConfig.events.queued) {
304
351
  queueMicrotask(() => {
@@ -323,7 +370,7 @@ function runHydrationEvents() {
323
370
  }
324
371
  }
325
372
  function isHydrating(node) {
326
- return sharedConfig.hydrating && !sharedConfig.done && (!node || node.isConnected);
373
+ return sharedConfig.hydrating && (!node || node.isConnected);
327
374
  }
328
375
  function toggleClassKey(node, key, value) {
329
376
  const classNames = key.trim().split(/\s+/);
@@ -349,7 +396,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
349
396
  if (prop === "class") return className(node, value, isSVG, prev), value;
350
397
  if (value === prev) return prev;
351
398
  if (prop === "ref") {
352
- if (!skipRef) value(node);
399
+ if (!skipRef && value) ref(() => value, node);
353
400
  } else if (prop.slice(0, 3) === "on:") {
354
401
  const e = prop.slice(3);
355
402
  prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
@@ -405,7 +452,6 @@ function eventHandler(e) {
405
452
  return node || document;
406
453
  }
407
454
  });
408
- if (sharedConfig.registry && !sharedConfig.done) sharedConfig.done = _$HY.done = true;
409
455
  if (e.composedPath) {
410
456
  const path = e.composedPath();
411
457
  retarget(path[0]);
@@ -601,4 +647,4 @@ function Dynamic(props) {
601
647
  return createDynamic(() => props.component, others);
602
648
  }
603
649
 
604
- export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, addEventListener, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, use, voidFn as useAssets };
650
+ export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, addEventListener, applyRef, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solidjs/web",
3
3
  "description": "Solid's web runtime for the browser and the server",
4
- "version": "2.0.0-experimental.14",
4
+ "version": "2.0.0-experimental.16",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -75,10 +75,10 @@
75
75
  "seroval-plugins": "^1.1.0"
76
76
  },
77
77
  "peerDependencies": {
78
- "solid-js": "^2.0.0-experimental.14"
78
+ "solid-js": "^2.0.0-experimental.16"
79
79
  },
80
80
  "devDependencies": {
81
- "solid-js": "2.0.0-experimental.14"
81
+ "solid-js": "2.0.0-experimental.16"
82
82
  },
83
83
  "scripts": {
84
84
  "build": "npm-run-all -nl build:*",
@@ -90,7 +90,8 @@
90
90
  "types:web": "tsc --project ./tsconfig.build.json",
91
91
  "types:copy-web": "ncp ../../node_modules/dom-expressions/src/client.d.ts ./types/client.d.ts && ncp ../../node_modules/dom-expressions/src/server.d.ts ./types/server.d.ts",
92
92
  "types:web-storage": "tsc --project ./storage/tsconfig.build.json",
93
- "test": "vitest run",
93
+ "test": "vitest run && vitest run --config vite.config.server.mjs && vitest run --config vite.config.hydrate.mjs",
94
+ "test:server": "vitest run --config vite.config.server.mjs",
94
95
  "coverage": "vitest run --coverage",
95
96
  "test-types": "tsc --project tsconfig.test.json"
96
97
  }
@@ -0,0 +1 @@
1
+ export * from "dom-expressions/src/client.js";
@@ -0,0 +1,45 @@
1
+ import { hydrate as hydrateCore } from "./client.js";
2
+ import { JSX, ComponentProps, ValidComponent } from "solid-js";
3
+ export * from "./client.js";
4
+ export { For, Show, Switch, Match, Errored, Loading, merge as mergeProps } from "solid-js";
5
+ export * from "./server-mock.js";
6
+ export declare const isServer: boolean;
7
+ export declare const isDev: boolean;
8
+ export declare const hydrate: typeof hydrateCore;
9
+ /**
10
+ * Renders components somewhere else in the DOM
11
+ *
12
+ * Useful for inserting modals and tooltips outside of an cropping layout. If no mount point is given, the portal is inserted in document.body; it is wrapped in a `<div>` unless the target is document.head or `isSVG` is true. setting `useShadow` to true places the element in a shadow root to isolate styles.
13
+ *
14
+ * @description https://docs.solidjs.com/reference/components/portal
15
+ */
16
+ export declare function Portal<T extends boolean = false, S extends boolean = false>(props: {
17
+ mount?: Element;
18
+ children: JSX.Element;
19
+ }): Text;
20
+ export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
21
+ [K in keyof P]: P[K];
22
+ } & {
23
+ component: T | undefined;
24
+ };
25
+ /**
26
+ * Renders an arbitrary component or element with the given props
27
+ *
28
+ * This is a lower level version of the `Dynamic` component, useful for
29
+ * performance optimizations in libraries. Do not use this unless you know
30
+ * what you are doing.
31
+ * ```typescript
32
+ * const element = () => multiline() ? 'textarea' : 'input';
33
+ * createDynamic(element, { value: value() });
34
+ * ```
35
+ * @description https://docs.solidjs.com/reference/components/dynamic
36
+ */
37
+ export declare function createDynamic<T extends ValidComponent>(component: () => T | undefined, props: ComponentProps<T>): JSX.Element;
38
+ /**
39
+ * Renders an arbitrary custom or native component and passes the other props
40
+ * ```typescript
41
+ * <Dynamic component={multiline() ? 'textarea' : 'input'} value={value()} />
42
+ * ```
43
+ * @description https://docs.solidjs.com/reference/components/dynamic
44
+ */
45
+ export declare function Dynamic<T extends ValidComponent>(props: DynamicProps<T>): JSX.Element;
@@ -0,0 +1,72 @@
1
+ export declare function renderToString<T>(fn: () => T, options?: {
2
+ nonce?: string;
3
+ renderId?: string;
4
+ noScripts?: boolean;
5
+ plugins?: any[];
6
+ manifest?: Record<string, {
7
+ file: string;
8
+ css?: string[];
9
+ isEntry?: boolean;
10
+ isDynamicEntry?: boolean;
11
+ imports?: string[];
12
+ }>;
13
+ onError?: (err: any) => void;
14
+ }): string;
15
+ export declare function renderToStringAsync<T>(fn: () => T, options?: {
16
+ timeoutMs?: number;
17
+ nonce?: string;
18
+ renderId?: string;
19
+ noScripts?: boolean;
20
+ plugins?: any[];
21
+ manifest?: Record<string, {
22
+ file: string;
23
+ css?: string[];
24
+ isEntry?: boolean;
25
+ isDynamicEntry?: boolean;
26
+ imports?: string[];
27
+ }>;
28
+ onError?: (err: any) => void;
29
+ }): Promise<string>;
30
+ export declare function renderToStream<T>(fn: () => T, options?: {
31
+ nonce?: string;
32
+ renderId?: string;
33
+ noScripts?: boolean;
34
+ plugins?: any[];
35
+ manifest?: Record<string, {
36
+ file: string;
37
+ css?: string[];
38
+ isEntry?: boolean;
39
+ isDynamicEntry?: boolean;
40
+ imports?: string[];
41
+ }>;
42
+ onCompleteShell?: (info: {
43
+ write: (v: string) => void;
44
+ }) => void;
45
+ onCompleteAll?: (info: {
46
+ write: (v: string) => void;
47
+ }) => void;
48
+ onError?: (err: any) => void;
49
+ }): {
50
+ then: (fn: (html: string) => void) => void;
51
+ pipe: (writable: {
52
+ write: (v: string) => void;
53
+ end: () => void;
54
+ }) => void;
55
+ pipeTo: (writable: WritableStream) => Promise<void>;
56
+ };
57
+ export declare function ssr(template: string[] | string, ...nodes: any[]): {
58
+ t: string;
59
+ };
60
+ export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
61
+ t: string;
62
+ };
63
+ export declare function ssrClassList(value: {
64
+ [k: string]: boolean;
65
+ }): string;
66
+ export declare function ssrStyle(value: {
67
+ [k: string]: string;
68
+ }): string;
69
+ export declare function ssrAttribute(key: string, value: boolean): string;
70
+ export declare function ssrHydrationKey(): string;
71
+ export declare function resolveSSRNode(node: any): string;
72
+ export declare function escape(html: string): string;
@@ -0,0 +1,2 @@
1
+ import type { RequestEvent } from "@solidjs/web";
2
+ export declare function provideRequestEvent<T extends RequestEvent, U>(init: T, cb: () => U): U;
package/types/client.d.ts CHANGED
@@ -7,8 +7,13 @@ export const SVGElements: Set<string>;
7
7
  export const SVGNamespace: Record<string, string>;
8
8
 
9
9
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
10
- export function render(code: () => JSX.Element, element: MountableElement): () => void;
11
- export function template(html: string, isCE?: boolean, isSVG?: boolean): () => Element;
10
+ export function render(
11
+ code: () => JSX.Element,
12
+ element: MountableElement,
13
+ init?: JSX.Element,
14
+ options?: { owner?: unknown }
15
+ ): () => void;
16
+ export function template(html: string, isImportNode?: boolean, isSVG?: boolean, isMathML?: boolean): () => Element;
12
17
  export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void, init?: T): void;
13
18
  export function memo<T>(fn: () => T, equal: boolean): () => T;
14
19
  export function untrack<T>(fn: () => T): T;
@@ -27,7 +32,14 @@ export function spread<T>(
27
32
  isSVG?: Boolean,
28
33
  skipChildren?: Boolean
29
34
  ): void;
30
- export function assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
35
+ export function assign(
36
+ node: Element,
37
+ props: any,
38
+ isSVG?: Boolean,
39
+ skipChildren?: Boolean,
40
+ prevProps?: any,
41
+ skipRef?: Boolean
42
+ ): void;
31
43
  export function setAttribute(node: Element, name: string, value: string): void;
32
44
  export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
33
45
  type ClassList =
@@ -35,6 +47,7 @@ type ClassList =
35
47
  | Array<string | number | boolean | null | undefined | Record<string, boolean>>;
36
48
  export function className(node: Element, value: string | ClassList, isSvg?: boolean, prev?: string | ClassList): void;
37
49
  export function setProperty(node: Element, name: string, value: any): void;
50
+ export function setStyleProperty(node: Element, name: string, value: any): void;
38
51
  export function addEventListener(
39
52
  node: Element,
40
53
  name: string,
@@ -49,25 +62,28 @@ export function style(
49
62
  export function getOwner(): unknown;
50
63
  export function mergeProps(...sources: unknown[]): unknown;
51
64
  export function dynamicProperty(props: unknown, key: string): unknown;
65
+ export function applyRef(r: ((element: Element) => void) | ((element: Element) => void)[], element: Element): void;
66
+ export function ref(fn: () => ((element: Element) => void) | ((element: Element) => void)[], element: Element): void;
52
67
 
53
68
  export function hydrate(
54
69
  fn: () => JSX.Element,
55
70
  node: MountableElement,
56
71
  options?: { renderId?: string; owner?: unknown }
57
72
  ): () => void;
58
- export function getHydrationKey(): string;
59
- export function getNextElement(template?: HTMLTemplateElement): Element;
73
+ export function getHydrationKey(): string | undefined;
74
+ export function getNextElement(template?: () => Element): Element;
60
75
  export function getNextMatch(start: Node, elementName: string): Element;
61
76
  export function getNextMarker(start: Node): [Node, Array<Node>];
62
77
  export function useAssets(fn: () => JSX.Element): void;
63
78
  export function getAssets(): string;
64
- export function HydrationScript(): JSX.Element;
65
- export function generateHydrationScript(): string;
79
+ export function HydrationScript(props?: { nonce?: string; eventNames?: string[] }): JSX.Element;
80
+ export function generateHydrationScript(options?: { nonce?: string; eventNames?: string[] }): string;
66
81
  export function Assets(props: { children?: JSX.Element }): JSX.Element;
67
82
  export function Hydration(props: { children?: JSX.Element }): JSX.Element;
68
83
  export function NoHydration(props: { children?: JSX.Element }): JSX.Element;
69
84
  export interface RequestEvent {
70
85
  request: Request;
86
+ locals: Record<string | number | symbol, any>;
71
87
  }
72
88
  export declare const RequestContext: unique symbol;
73
89
  export function getRequestEvent(): RequestEvent | undefined;
package/types/core.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { getOwner, createComponent, createRoot as root, createRenderEffect as effect, sharedConfig, untrack, merge as mergeProps, flatten, ssrHandleError, ssrRunInScope } from "solid-js";
1
+ export { getOwner, runWithOwner, createComponent, createRoot as root, sharedConfig, untrack, merge as mergeProps, flatten, ssrHandleError, ssrRunInScope } from "solid-js";
2
+ export declare const effect: (fn: any, effectFn: any, initial: any) => void;
2
3
  export declare const memo: (fn: any) => import("solid-js").Accessor<any>;