@solidjs/router 0.17.0-next.6 → 1.0.0-next.10

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 (50) hide show
  1. package/README.md +526 -716
  2. package/dist/claims.d.ts +21 -0
  3. package/dist/claims.js +115 -0
  4. package/dist/data/action.d.ts +15 -0
  5. package/dist/data/action.js +165 -25
  6. package/dist/data/events.d.ts +8 -0
  7. package/dist/data/events.js +23 -22
  8. package/dist/data/flash.d.ts +1 -5
  9. package/dist/data/flash.js +10 -18
  10. package/dist/data/flashCookie.d.ts +7 -0
  11. package/dist/data/flashCookie.js +20 -0
  12. package/dist/data/serverForms.d.ts +1 -0
  13. package/dist/data/serverForms.js +5 -0
  14. package/dist/index.d.ts +5 -3
  15. package/dist/index.js +1896 -1156
  16. package/dist/index.jsx +2 -2
  17. package/dist/lifecycle.d.ts +29 -4
  18. package/dist/lifecycle.js +40 -37
  19. package/dist/paths.d.ts +117 -0
  20. package/dist/paths.js +41 -0
  21. package/dist/routers/components.d.ts +10 -21
  22. package/dist/routers/components.jsx +29 -51
  23. package/dist/routers/factory.d.ts +66 -0
  24. package/dist/routers/factory.jsx +151 -0
  25. package/dist/routers/history.d.ts +26 -0
  26. package/dist/routers/history.js +180 -0
  27. package/dist/routers/index.d.ts +4 -11
  28. package/dist/routers/index.js +2 -6
  29. package/dist/routers/scrollRestoration.d.ts +33 -0
  30. package/dist/routers/scrollRestoration.js +135 -0
  31. package/dist/routing.d.ts +79 -52
  32. package/dist/routing.js +304 -128
  33. package/dist/server.d.ts +31 -17
  34. package/dist/server.js +68 -12
  35. package/dist/types.d.ts +74 -5
  36. package/dist/utils.d.ts +2 -0
  37. package/dist/utils.js +2 -0
  38. package/package.json +6 -6
  39. package/dist/components.d.ts +0 -31
  40. package/dist/components.jsx +0 -46
  41. package/dist/routers/HashRouter.d.ts +0 -9
  42. package/dist/routers/HashRouter.js +0 -41
  43. package/dist/routers/MemoryRouter.d.ts +0 -24
  44. package/dist/routers/MemoryRouter.js +0 -57
  45. package/dist/routers/Router.d.ts +0 -9
  46. package/dist/routers/Router.js +0 -45
  47. package/dist/routers/StaticRouter.d.ts +0 -6
  48. package/dist/routers/StaticRouter.js +0 -15
  49. package/dist/routers/createRouter.d.ts +0 -10
  50. package/dist/routers/createRouter.js +0 -40
@@ -1,40 +0,0 @@
1
- import { createSignal, onCleanup, sharedConfig } from "solid-js";
2
- import { createRouterComponent } from "./components.jsx";
3
- export function createRouter(config) {
4
- let ignore = false;
5
- const wrap = (value) => (typeof value === "string" ? { value } : value);
6
- const [read, write] = createSignal(wrap(config.get()), {
7
- equals: (a, b) => a.value === b.value && a.state === b.state,
8
- ownedWrite: true
9
- });
10
- const signal = [read, (next) => {
11
- !ignore && config.set(next);
12
- if (sharedConfig.registry && !sharedConfig.done)
13
- sharedConfig.done = true;
14
- write(next);
15
- }];
16
- config.init &&
17
- onCleanup(config.init((value = config.get()) => {
18
- ignore = true;
19
- signal[1](wrap(value));
20
- ignore = false;
21
- }));
22
- return createRouterComponent({
23
- signal,
24
- create: config.create,
25
- utils: config.utils
26
- });
27
- }
28
- export function bindEvent(target, type, handler) {
29
- target.addEventListener(type, handler);
30
- return () => target.removeEventListener(type, handler);
31
- }
32
- export function scrollToHash(hash, fallbackTop) {
33
- const el = hash && document.getElementById(hash);
34
- if (el) {
35
- el.scrollIntoView();
36
- }
37
- else if (fallbackTop) {
38
- window.scrollTo(0, 0);
39
- }
40
- }