solid-js 1.4.6 → 1.5.0-beta.1

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.
Files changed (45) hide show
  1. package/dist/dev.cjs +112 -113
  2. package/dist/dev.js +112 -113
  3. package/dist/server.cjs +65 -31
  4. package/dist/server.js +65 -31
  5. package/dist/solid.cjs +112 -111
  6. package/dist/solid.js +112 -111
  7. package/h/jsx-runtime/types/jsx.d.ts +6 -1401
  8. package/h/types/hyperscript.d.ts +17 -0
  9. package/html/dist/html.cjs +34 -59
  10. package/html/dist/html.js +34 -59
  11. package/html/types/lit.d.ts +37 -0
  12. package/package.json +23 -21
  13. package/store/dist/dev.cjs +40 -22
  14. package/store/dist/dev.js +41 -23
  15. package/store/dist/store.cjs +40 -22
  16. package/store/dist/store.js +40 -22
  17. package/store/types/store.d.ts +1 -1
  18. package/types/jsx.d.ts +194 -1580
  19. package/types/reactive/observable.d.ts +7 -2
  20. package/types/reactive/signal.d.ts +42 -13
  21. package/types/render/component.d.ts +21 -6
  22. package/types/server/reactive.d.ts +6 -1
  23. package/types/server/rendering.d.ts +3 -2
  24. package/universal/types/universal.d.ts +3 -3
  25. package/web/dist/dev.cjs +3 -3
  26. package/web/dist/dev.js +3 -3
  27. package/web/dist/server.cjs +35 -69
  28. package/web/dist/server.js +35 -69
  29. package/web/dist/web.cjs +3 -3
  30. package/web/dist/web.js +3 -3
  31. package/web/types/core.d.ts +2 -2
  32. package/web/types/index.d.ts +5 -6
  33. package/web/types/server-mock.d.ts +4 -2
  34. package/web/types/server.d.ts +70 -0
  35. package/h/README.md +0 -99
  36. package/h/jsx-runtime/package.json +0 -8
  37. package/h/package.json +0 -8
  38. package/html/README.md +0 -84
  39. package/html/package.json +0 -8
  40. package/store/README.md +0 -23
  41. package/store/package.json +0 -35
  42. package/universal/README.md +0 -102
  43. package/universal/package.json +0 -18
  44. package/web/README.md +0 -7
  45. package/web/package.json +0 -35
@@ -4,6 +4,7 @@ export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch,
4
4
  const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
5
5
  const BooleanAttributes = /*#__PURE__*/new Set(booleans);
6
6
  /*#__PURE__*/new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
7
+ const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
7
8
  const Aliases = {
8
9
  className: "class",
9
10
  htmlFor: "for"
@@ -229,8 +230,7 @@ function stringifyString(str) {
229
230
  return result;
230
231
  }
231
232
 
232
- const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t||null)}`;
233
- const FRAGMENT_REPLACE = /<!\[([\d-]+)\]>/;
233
+ const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t||"$$$")}`;
234
234
  function renderToString(code, options = {}) {
235
235
  let scripts = "";
236
236
  sharedConfig.context = {
@@ -249,69 +249,20 @@ function renderToString(code, options = {}) {
249
249
  return html;
250
250
  }
251
251
  function renderToStringAsync(code, options = {}) {
252
- let scripts = "";
253
252
  const {
254
- nonce,
255
- renderId,
256
253
  timeoutMs = 30000
257
254
  } = options;
258
- const dedupe = new WeakMap();
259
- const context = sharedConfig.context = {
260
- id: renderId || "",
261
- count: 0,
262
- resources: {},
263
- suspense: {},
264
- assets: [],
265
- async: true,
266
- nonce,
267
- writeResource(id, p, error) {
268
- if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
269
- if (!p || typeof p !== "object" || !("then" in p)) return scripts += serializeSet(dedupe, id, p) + ";";
270
- p.then(d => scripts += serializeSet(dedupe, id, d) + ";").catch(() => scripts += `_$HY.set("${id}", {});`);
271
- }
272
- };
273
255
  let timeoutHandle;
274
256
  const timeout = new Promise((_, reject) => {
275
257
  timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
276
258
  });
277
- function asyncWrap(fn) {
278
- return new Promise(resolve => {
279
- const registry = new Set();
280
- const cache = Object.create(null);
281
- sharedConfig.context.registerFragment = register;
282
- const rendered = fn();
283
- if (!registry.size) resolve(rendered);
284
- function register(key) {
285
- registry.add(key);
286
- return (value = "", error) => {
287
- if (!registry.has(key)) return;
288
- cache[key] = value;
289
- registry.delete(key);
290
- if (error) scripts += `_$HY.set("${key}", Promise.resolve(${serializeError(error)}));`;else scripts += `_$HY.set("${key}", null);`;
291
- if (!registry.size) Promise.resolve().then(() => {
292
- let source = resolveSSRNode(rendered);
293
- let final = "";
294
- let match;
295
- while (match = source.match(FRAGMENT_REPLACE)) {
296
- final += source.substring(0, match.index);
297
- source = cache[match[1]] + source.substring(match.index + match[0].length);
298
- }
299
- resolve(final + source);
300
- });
301
- return true;
302
- };
303
- }
304
- });
305
- }
306
- return Promise.race([asyncWrap(() => escape(code())), timeout]).then(res => {
259
+ return Promise.race([renderToStream(code, options), timeout]).then(html => {
307
260
  clearTimeout(timeoutHandle);
308
- let html = injectAssets(context.assets, resolveSSRNode(res));
309
- if (scripts.length) html = injectScripts(html, scripts, nonce);
310
261
  return html;
311
262
  });
312
263
  }
313
264
  function renderToStream(code, options = {}) {
314
- const {
265
+ let {
315
266
  nonce,
316
267
  onCompleteShell,
317
268
  onCompleteAll,
@@ -336,13 +287,13 @@ function renderToStream(code, options = {}) {
336
287
  };
337
288
  const pushTask = task => {
338
289
  tasks.push(task);
339
- if (!scheduled) {
290
+ if (!scheduled && firstFlushed) {
340
291
  Promise.resolve().then(writeTasks);
341
292
  scheduled = true;
342
293
  }
343
294
  };
344
295
  const writeTasks = () => {
345
- if (tasks.length && !completed) {
296
+ if (tasks.length && !completed && firstFlushed) {
346
297
  buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.join(";")}</script>`);
347
298
  tasks.length = 0;
348
299
  }
@@ -362,7 +313,6 @@ function renderToStream(code, options = {}) {
362
313
  id: renderId || "",
363
314
  count: 0,
364
315
  async: true,
365
- streaming: true,
366
316
  resources: {},
367
317
  suspense: {},
368
318
  assets: [],
@@ -390,15 +340,15 @@ function renderToStream(code, options = {}) {
390
340
  if ((value !== undefined || error) && !completed) {
391
341
  if (!firstFlushed) {
392
342
  Promise.resolve().then(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
393
- pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}");`) : ""}_$HY.set("${key}",${error ? serializeError(error) : "null"})`);
343
+ pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}");`) : ""}_$HY.set("${key}",${error ? serializeError(error) : '"$$$"'})`);
394
344
  } else {
395
345
  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 : ""}`);
346
+ pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," + serializeError(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
397
347
  scriptFlushed = true;
398
348
  }
399
349
  }
400
350
  }
401
- if (firstFlushed) checkEnd();
351
+ Promise.resolve().then(checkEnd);
402
352
  return true;
403
353
  };
404
354
  }
@@ -417,6 +367,22 @@ function renderToStream(code, options = {}) {
417
367
  });
418
368
  }
419
369
  return {
370
+ then(fn) {
371
+ function complete() {
372
+ doShell();
373
+ let mapped = "";
374
+ for (let i = 0, len = tmp.length; i < len; i++) mapped += tmp[i];
375
+ fn(mapped);
376
+ }
377
+ if (onCompleteAll) {
378
+ ogComplete = onCompleteAll;
379
+ onCompleteAll = options => {
380
+ ogComplete(options);
381
+ complete();
382
+ };
383
+ } else onCompleteAll = complete;
384
+ checkEnd();
385
+ },
420
386
  pipe(w) {
421
387
  Promise.allSettled(blockingResources).then(() => {
422
388
  doShell();
@@ -513,16 +479,15 @@ function ssrStyle(value) {
513
479
  }
514
480
  return result;
515
481
  }
516
- function ssrSpread(props, isSVG, skipChildren) {
517
- let result = "";
518
- if (props == null) return results;
482
+ function ssrElement(tag, props, children, needsId) {
483
+ let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
519
484
  if (typeof props === "function") props = props();
520
485
  const keys = Object.keys(props);
521
486
  let classResolved;
522
487
  for (let i = 0; i < keys.length; i++) {
523
488
  const prop = keys[i];
524
- if (prop === "children") {
525
- !skipChildren && console.warn(`SSR currently does not support spread children.`);
489
+ if (ChildProperties.has(prop) && children === undefined) {
490
+ children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
526
491
  continue;
527
492
  }
528
493
  const value = props[prop];
@@ -542,7 +507,9 @@ function ssrSpread(props, isSVG, skipChildren) {
542
507
  }
543
508
  if (i !== keys.length - 1) result += " ";
544
509
  }
545
- return result;
510
+ return {
511
+ t: result + `>${resolveSSRNode(children)}</${tag}>`
512
+ };
546
513
  }
547
514
  function ssrAttribute(key, value, isBoolean) {
548
515
  return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
@@ -614,7 +581,7 @@ function generateHydrationScript({
614
581
  eventNames = ["click", "input"],
615
582
  nonce
616
583
  } = {}) {
617
- return `<script${nonce ? ` nonce="${nonce}"` : ""}>var e,t;e=window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}}),t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let s=o.composedPath&&o.composedPath()[0]||o.target,a=t(s);a&&!e.completed.has(a)&&e.events.push([a,o])})))),e.init=(t,o)=>{e.r[t]=[new Promise(((e,t)=>o=e)),o]},e.set=(t,o,s)=>{(s=e.r[t])&&s[1](o),e.r[t]=[o]},e.unset=t=>{delete e.r[t]},e.load=(t,o)=>{if(o=e.r[t])return o[0]};</script><!--xs-->`;
584
+ return `<script${nonce ? ` nonce="${nonce}"` : ""}>var e,t;e=window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}}),t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let s=o.composedPath&&o.composedPath()[0]||o.target,a=t(s);a&&!e.completed.has(a)&&e.events.push([a,o])})))),e.init=(t,o)=>{e.r[t]=[new Promise(((e,t)=>o=e)),o]},e.set=(t,o,s)=>{(s=e.r[t])&&s[1](o),e.r[t]=[o]},e.unset=t=>{delete e.r[t]},e.load=t=>e.r[t];</script><!--xs-->`;
618
585
  }
619
586
  function injectAssets(assets, html) {
620
587
  for (let i = 0; i < assets.length; i++) {
@@ -718,8 +685,7 @@ function Dynamic(props) {
718
685
  t = typeof comp;
719
686
  if (comp) {
720
687
  if (t === "function") return comp(others);else if (t === "string") {
721
- const [local, sOthers] = splitProps(others, ["children"]);
722
- return ssr([`<${comp}`, ' ', ">", `</${comp}>`], ssrHydrationKey(), ssrSpread(sOthers), escape(local.children || ""));
688
+ return ssrElement(comp, others, undefined, true);
723
689
  }
724
690
  }
725
691
  }
@@ -727,4 +693,4 @@ function Portal(props) {
727
693
  return "";
728
694
  }
729
695
 
730
- export { Assets, Dynamic, HydrationScript, NoHydration, Portal, escape, generateHydrationScript, getHydrationKey, isServer, pipeToNodeWritable, pipeToWritable, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrAttribute, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle };
696
+ export { Assets, Dynamic, HydrationScript, NoHydration, Portal, escape, generateHydrationScript, getHydrationKey, isServer, pipeToNodeWritable, pipeToWritable, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle };
package/web/dist/web.cjs CHANGED
@@ -518,12 +518,12 @@ function renderToStream(fn, options) {
518
518
  throwInBrowser(renderToStream);
519
519
  }
520
520
  function ssr(template, ...nodes) {}
521
- function resolveSSRNode(node) {}
521
+ function ssrElement(name, props, children, needsId) {}
522
522
  function ssrClassList(value) {}
523
523
  function ssrStyle(value) {}
524
- function ssrSpread(accessor) {}
525
524
  function ssrAttribute(key, value) {}
526
525
  function ssrHydrationKey() {}
526
+ function resolveSSRNode(node) {}
527
527
  function escape(html) {}
528
528
  function generateHydrationScript() {}
529
529
 
@@ -681,8 +681,8 @@ exports.spread = spread;
681
681
  exports.ssr = ssr;
682
682
  exports.ssrAttribute = ssrAttribute;
683
683
  exports.ssrClassList = ssrClassList;
684
+ exports.ssrElement = ssrElement;
684
685
  exports.ssrHydrationKey = ssrHydrationKey;
685
- exports.ssrSpread = ssrSpread;
686
686
  exports.ssrStyle = ssrStyle;
687
687
  exports.style = style;
688
688
  exports.template = template;
package/web/dist/web.js CHANGED
@@ -515,12 +515,12 @@ function renderToStream(fn, options) {
515
515
  throwInBrowser(renderToStream);
516
516
  }
517
517
  function ssr(template, ...nodes) {}
518
- function resolveSSRNode(node) {}
518
+ function ssrElement(name, props, children, needsId) {}
519
519
  function ssrClassList(value) {}
520
520
  function ssrStyle(value) {}
521
- function ssrSpread(accessor) {}
522
521
  function ssrAttribute(key, value) {}
523
522
  function ssrHydrationKey() {}
523
+ function resolveSSRNode(node) {}
524
524
  function escape(html) {}
525
525
  function generateHydrationScript() {}
526
526
 
@@ -587,4 +587,4 @@ function Dynamic(props) {
587
587
  });
588
588
  }
589
589
 
590
- export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
590
+ export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template };
@@ -1,3 +1,3 @@
1
- import { createRoot, createRenderEffect, createComponent, getOwner, sharedConfig } from "../..";
2
- declare function memo<T>(fn: () => T, equals: boolean): import("../..").Accessor<T>;
1
+ import { createRoot, createRenderEffect, createComponent, getOwner, sharedConfig } from "solid-js";
2
+ declare function memo<T>(fn: () => T, equals: boolean): import("solid-js").Accessor<T>;
3
3
  export { getOwner, createComponent, createRoot as root, createRenderEffect as effect, memo, sharedConfig };
@@ -1,7 +1,7 @@
1
1
  import { hydrate as hydrateCore } from "./client";
2
- import { Component, JSX, Accessor } from "../..";
2
+ import { JSX, Accessor, ComponentProps, ValidComponent } from "solid-js";
3
3
  export * from "./client";
4
- export { For, Show, Suspense, SuspenseList, Switch, Match, Index, ErrorBoundary, mergeProps } from "../..";
4
+ export { For, Show, Suspense, SuspenseList, Switch, Match, Index, ErrorBoundary, mergeProps } from "solid-js";
5
5
  export * from "./server-mock";
6
6
  export declare const isServer = false;
7
7
  export declare const hydrate: typeof hydrateCore;
@@ -21,9 +21,8 @@ export declare function Portal<T extends boolean = false, S extends boolean = fa
21
21
  } : {}) & (S extends true ? SVGGElement : HTMLDivElement)) => void);
22
22
  children: JSX.Element;
23
23
  }): Text;
24
- declare type DynamicProps<T> = T & {
25
- children?: any;
26
- component?: Component<T> | string | keyof JSX.IntrinsicElements;
24
+ declare type DynamicProps<T extends ValidComponent> = ComponentProps<T> & {
25
+ component: T | undefined;
27
26
  };
28
27
  /**
29
28
  * renders an arbitrary custom or native component and passes the other props
@@ -32,4 +31,4 @@ declare type DynamicProps<T> = T & {
32
31
  * ```
33
32
  * @description https://www.solidjs.com/docs/latest/api#%3Cdynamic%3E
34
33
  */
35
- export declare function Dynamic<T>(props: DynamicProps<T>): Accessor<JSX.Element>;
34
+ export declare function Dynamic<T extends ValidComponent>(props: DynamicProps<T>): Accessor<JSX.Element>;
@@ -25,16 +25,18 @@ export declare function renderToStream<T>(fn: () => T, options?: {
25
25
  export declare function ssr(template: string[] | string, ...nodes: any[]): {
26
26
  t: string;
27
27
  };
28
- export declare function resolveSSRNode(node: any): string;
28
+ export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
29
+ t: string;
30
+ };
29
31
  export declare function ssrClassList(value: {
30
32
  [k: string]: boolean;
31
33
  }): string;
32
34
  export declare function ssrStyle(value: {
33
35
  [k: string]: string;
34
36
  }): string;
35
- export declare function ssrSpread(accessor: any): () => string;
36
37
  export declare function ssrAttribute(key: string, value: boolean): string;
37
38
  export declare function ssrHydrationKey(): string;
39
+ export declare function resolveSSRNode(node: any): string;
38
40
  export declare function escape(html: string): string;
39
41
  export declare function generateHydrationScript(): string;
40
42
  export declare type LegacyResults = {
@@ -0,0 +1,70 @@
1
+ export function renderToString<T>(
2
+ fn: () => T,
3
+ options?: {
4
+ nonce?: string;
5
+ renderId?: string;
6
+ }
7
+ ): string;
8
+ export function renderToStringAsync<T>(
9
+ fn: () => T,
10
+ options?: {
11
+ timeoutMs?: number;
12
+ nonce?: string;
13
+ renderId?: string;
14
+ }
15
+ ): Promise<string>;
16
+ export function renderToStream<T>(
17
+ fn: () => T,
18
+ options?: {
19
+ nonce?: string;
20
+ renderId?: string;
21
+ onCompleteShell?: (info: { write: (v: string) => void }) => void;
22
+ onCompleteAll?: (info: { write: (v: string) => void }) => void;
23
+ }
24
+ ): {
25
+ pipe: (writable: { write: (v: string) => void }) => void;
26
+ pipeTo: (writable: WritableStream) => void;
27
+ };
28
+
29
+ export function Assets(props: { children?: JSX.Element }): JSX.Element;
30
+ export function HydrationScript(props: { nonce?: string; eventNames?: string[] }): JSX.Element;
31
+ export function NoHydration(props: { children?: JSX.Element }): JSX.Element;
32
+ export function ssr(template: string[] | string, ...nodes: any[]): { t: string };
33
+ export function ssrElement(name: string, props: any, children: any, needsId: boolean): { t: string };
34
+ export function ssrClassList(value: { [k: string]: boolean }): string;
35
+ export function ssrStyle(value: { [k: string]: string }): string;
36
+ export function ssrAttribute(key: string, value: any, isBoolean: boolean): string;
37
+ export function ssrHydrationKey(): string;
38
+ export function resolveSSRNode(node: any): string;
39
+ export function escape(html: string): string;
40
+ export function getHydrationKey(): string;
41
+ export function effect<T>(fn: (prev?: T) => T, init?: T): void;
42
+ export function memo<T>(fn: () => T, equal: boolean): () => T;
43
+ export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
44
+ export function mergeProps(...sources: unknown[]): unknown;
45
+ export function getOwner(): unknown;
46
+ export function generateHydrationScript(options: { nonce?: string; eventNames?: string[] }): string;
47
+
48
+ // deprecated
49
+ export type LegacyResults = {
50
+ write: (text: string) => void;
51
+ startWriting: () => void;
52
+ };
53
+ export function pipeToWritable<T>(
54
+ fn: () => T,
55
+ writable: WritableStream,
56
+ options?: {
57
+ nonce?: string;
58
+ onReady?: (res: LegacyResults) => void;
59
+ onCompleteAll?: () => void;
60
+ }
61
+ ): void;
62
+ export function pipeToNodeWritable<T>(
63
+ fn: () => T,
64
+ writable: { write: (v: string) => void },
65
+ options?: {
66
+ nonce?: string;
67
+ onReady?: (res: LegacyResults) => void;
68
+ onCompleteAll?: () => void;
69
+ }
70
+ ): void;
package/h/README.md DELETED
@@ -1,99 +0,0 @@
1
- # Solid HyperScript
2
-
3
- This sub module provides a HyperScript method for Solid. This is useful to use Solid in non-compiled environments or in some environments where you can only use a standard JSX transform. This method can be used as the JSX factory function.
4
-
5
- HyperScript function takes a few forms. The 2nd props argument is optional. Children may be passed as either an array to the 2nd/3rd argument or as every argument past the 2nd.
6
-
7
- ```js
8
- // create an element with a title attribute
9
- h("button", { title: "My button" }, "Click Me")
10
-
11
- // create a component with a title prop
12
- h(Button, { title: "My button" }, "Click Me")
13
-
14
- // create an element with many children
15
- h("div", { title: "My button" }, h("span", "1"), h("span", "2"), h("span", "3"))
16
- ```
17
-
18
- This is the least efficient way to use Solid as it requires a slightly larger runtime that isn't treeshakebable, and cannot leverage anything in the way of analysis, so it requires manual wrapping of expressions and has a few other caveats (see below).
19
-
20
- ## Example
21
-
22
- ```js
23
- import { render } from "solid-js/web";
24
- import h from "solid-js/h";
25
- import { createSignal } from "solid-js";
26
-
27
- function Button(props) {
28
- return h("button.btn-primary", props)
29
- }
30
-
31
- function Counter() {
32
- const [count, setCount] = createSignal(0);
33
- const increment = (e) => setCount(c => c + 1);
34
-
35
- return h(Button, { type: "button", onClick: increment }, count);
36
- }
37
-
38
- render(Counter, document.getElementById("app"));
39
- ```
40
-
41
- ## Differences from JSX
42
-
43
- There are a few differences from Solid's JSX that are important to note. And also apply when attempting use any transformation that would compile to HyperScript.
44
-
45
- 1. Reactive expression must be manually wrapped in functions to be reactive.
46
-
47
- ```js
48
- // jsx
49
- <div id={props.id}>{firstName() + lastName()}</div>
50
-
51
- // hyperscript
52
- h("div", { id: () => props.id }, () => firstName() + lastName())
53
- ```
54
-
55
- 2. Merging spreads requires using the merge props helper to keep reactivity
56
-
57
- ```js
58
- // jsx
59
- <div class={selectedClass()} {...props} />
60
-
61
- // hyperscript
62
- import { mergeProps } from "solid-js"
63
-
64
- h("div", mergeProps({ class: selectedClass }, props))
65
- ```
66
-
67
- 3. Events on components require explicit event in the arguments
68
-
69
- Solid's HyperScript automatically wraps functions passed to props of components with no arguments in getters so you need to provide one to prevent this. The same applies to render props like in the `<For>` component.
70
-
71
- ```js
72
- // good
73
- h(Button, { onClick: (e) => console.log("Hi")});
74
-
75
- // bad
76
- h(Button, { onClick: () => console.log("Hi")})
77
- ```
78
-
79
- 4. All refs are callback form
80
-
81
- We can't do the compiled assigment trick so only the callback form is supported.
82
-
83
- ```js
84
- let myEl;
85
-
86
- h(div, { ref: (el) => myEl = el });
87
- ```
88
-
89
- 5. There is a shorthand for static id and classes
90
-
91
- ```js
92
- h("div#some-id.my-class")
93
- ```
94
-
95
- 6. Fragments are just arrays
96
-
97
- ```js
98
- [h("span", "1"), h("span", "2")]
99
- ```
@@ -1,8 +0,0 @@
1
- {
2
- "name": "solid-js/h/jsx-runtime",
3
- "main": "./dist/jsx.cjs",
4
- "module": "./dist/jsx.js",
5
- "types": "./types/index.d.ts",
6
- "type": "module",
7
- "sideEffects": false
8
- }
package/h/package.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "name": "solid-js/h",
3
- "main": "./dist/h.cjs",
4
- "module": "./dist/h.js",
5
- "types": "./types/index.d.ts",
6
- "type": "module",
7
- "sideEffects": false
8
- }
package/html/README.md DELETED
@@ -1,84 +0,0 @@
1
- # Solid Tagged Template Literals
2
-
3
- This sub module provides a Tagged Template Literal `html` method for Solid. This is useful to use Solid in non-compiled environments. This method can be used as replacement for JSX.
4
-
5
- `html` uses `${}` to escape into JavaScript expressions. Components are closed with `<//>`
6
-
7
- ```js
8
- // create an element with a title attribute
9
- html`<button title="My button">Click Me</button>`
10
-
11
- // create a component with a title prop
12
- html`<${Button} title="My button">Click me<//>`
13
-
14
- // create an element with dynamic attribute and spread
15
- html`<div title=${() => selectedClass()} ...${props} />`
16
- ```
17
-
18
- Using `html` is slightly less efficient than JSX(but more than HyperScript), requires a larger runtime that isn't treeshakebable, and cannot leverage expression analysis, so it requires manual wrapping of expressions and has a few other caveats (see below).
19
-
20
- ## Example
21
-
22
- ```js
23
- import { render } from "solid-js/web";
24
- import html from "solid-js/html";
25
- import { createSignal } from "solid-js";
26
-
27
- function Button(props) {
28
- return html`<button class="btn-primary" ...${props} />`;
29
- }
30
-
31
- function Counter() {
32
- const [count, setCount] = createSignal(0);
33
- const increment = (e) => setCount((c) => c + 1);
34
-
35
- return html`<${Button} type="button" onClick=${increment}>${count}<//>`;
36
- }
37
-
38
- render(Counter, document.getElementById("app"));
39
- ```
40
-
41
- ## Differences from JSX
42
-
43
- There are a few differences from Solid's JSX that are important to note.
44
-
45
- 1. Reactive expression must be manually wrapped in functions to be reactive.
46
-
47
- ```js
48
- // jsx
49
- <div id={props.id}>{firstName() + lastName()}</div>
50
-
51
- // hyperscript
52
- html`<div id=${() => props.id}>${() => firstName() + lastName()}</div>`
53
- ```
54
-
55
- 2. Events on components require explicit event in the arguments
56
-
57
- Solid's Tagged Template Literals automatically wraps functions passed to props of components with no arguments in getters so you need to provide one to prevent this. The same applies to render props like in the `<For>` component.
58
-
59
- ```js
60
- // good
61
- html`<${Button} onClick=${(e) => console.log("Hi")} />`;
62
-
63
- // bad
64
- html`<${Button} onClick=${() => console.log("Hi")} />`;
65
- ```
66
-
67
- 4. All refs are callback form
68
-
69
- We can't do the compiled assigment trick so only the callback form is supported.
70
-
71
- ```js
72
- let myEl;
73
- html`<div ref=${(el) => myEl = el} />`;
74
- ```
75
-
76
- 5. There can be multiple top level elements
77
-
78
- No need for fragments just:
79
- ```js
80
- html`
81
- <div>1</div>
82
- <div>2</div>
83
- `
84
- ```
package/html/package.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "name": "solid-js/html",
3
- "main": "./dist/html.cjs",
4
- "module": "./dist/html.js",
5
- "types": "./types/index.d.ts",
6
- "type": "module",
7
- "sideEffects": false
8
- }
package/store/README.md DELETED
@@ -1,23 +0,0 @@
1
- # Solid Store
2
-
3
- This submodules contains the means for handling deeps nested reactivity. It provides 2 main primitives `createStore` and `createMutable` which leverage proxies to create dynamic nested reactive structures.
4
-
5
- This also contains helper methods `produce` and `reconcile` which augment the behavior of the store setter method to allow for localized mutation and data diffing.
6
-
7
- For full documentation, check out the [website](https://www.solidjs.com/docs/latest/api).
8
-
9
- ## Example
10
-
11
- ```js
12
- import { createStore } from "solid-js/store";
13
-
14
- const [store, setStore] = createStore({
15
- user: {
16
- firstName: "John",
17
- lastName: "Smith"
18
- }
19
- });
20
-
21
- // update store.user.firstName
22
- setStore("user", "firstName", "Will");
23
- ```
@@ -1,35 +0,0 @@
1
- {
2
- "name": "solid-js/store",
3
- "main": "./dist/server.cjs",
4
- "module": "./dist/server.js",
5
- "browser": {
6
- "./dist/server.cjs": "./dist/store.cjs",
7
- "./dist/server.js": "./dist/store.js"
8
- },
9
- "unpkg": "./dist/store.cjs",
10
- "types": "./types/index.d.ts",
11
- "type": "module",
12
- "sideEffects": false,
13
- "exports": {
14
- ".": {
15
- "browser": {
16
- "development": {
17
- "import": "./dist/dev.js",
18
- "require": "./dist/dev.cjs"
19
- },
20
- "import": "./dist/store.js",
21
- "require": "./dist/store.cjs"
22
- },
23
- "node": {
24
- "import": "./dist/server.js",
25
- "require": "./dist/server.cjs"
26
- },
27
- "development": {
28
- "import": "./dist/dev.js",
29
- "require": "./dist/dev.cjs"
30
- },
31
- "import": "./dist/store.js",
32
- "require": "./dist/store.cjs"
33
- }
34
- }
35
- }