@solidjs/router 0.16.1 → 0.17.0-next.0

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.
@@ -1,4 +1,3 @@
1
- export { createAsync, createAsyncStore } from "./createAsync.js";
2
- export { action, useSubmission, useSubmissions, useAction } from "./action.js";
3
- export { query, revalidate, cache } from "./query.js";
1
+ export { action, useSubmissions, useAction } from "./action.js";
2
+ export { query, revalidate } from "./query.js";
4
3
  export { redirect, reload, json } from "./response.js";
@@ -2,7 +2,7 @@ import type { CacheEntry, NarrowResponse } from "../types.js";
2
2
  /**
3
3
  * Revalidates the given cache entry/entries.
4
4
  */
5
- export declare function revalidate(key?: string | string[] | void, force?: boolean): Promise<void>;
5
+ export declare function revalidate(key?: string | string[] | void, force?: boolean): void;
6
6
  export declare function cacheKeyOp(key: string | string[] | void, fn: (cacheEntry: CacheEntry) => void): void;
7
7
  export type CachedFunction<T extends (...args: any) => any> = T extends (...args: infer A) => infer R ? ([] extends {
8
8
  [K in keyof A]-?: A[K];
@@ -18,6 +18,4 @@ export declare namespace query {
18
18
  export var clear: () => void;
19
19
  export { _a as delete };
20
20
  }
21
- /** @deprecated use query instead */
22
- export declare const cache: typeof query;
23
21
  export declare function hashKey<T extends Array<any>>(args: T): string;
@@ -1,5 +1,5 @@
1
- import { createSignal, getListener, getOwner, onCleanup, sharedConfig, startTransition } from "solid-js";
2
- import { getRequestEvent, isServer } from "solid-js/web";
1
+ import { createSignal, getObserver, getOwner, onCleanup, sharedConfig } from "solid-js";
2
+ import { getRequestEvent, isServer } from "@solidjs/web";
3
3
  import { useNavigate, getIntent, getInPreloadFn } from "../routing.js";
4
4
  const LocationHeader = "Location";
5
5
  const PRELOAD_TIMEOUT = 5000;
@@ -28,12 +28,10 @@ function getCache() {
28
28
  * Revalidates the given cache entry/entries.
29
29
  */
30
30
  export function revalidate(key, force = true) {
31
- return startTransition(() => {
32
- const now = Date.now();
33
- cacheKeyOp(key, entry => {
34
- force && (entry[0] = 0); //force cache miss
35
- entry[4][1](now); // retrigger live signals
36
- });
31
+ const now = Date.now();
32
+ cacheKeyOp(key, entry => {
33
+ force && (entry[0] = 0); //force cache miss
34
+ entry[4][1](now); // retrigger live signals
37
35
  });
38
36
  }
39
37
  export function cacheKeyOp(key, fn) {
@@ -72,7 +70,7 @@ export function query(fn, name) {
72
70
  }
73
71
  }
74
72
  }
75
- if (getListener() && !isServer) {
73
+ if (getObserver() && !isServer) {
76
74
  tracking = true;
77
75
  onCleanup(() => cached[4].count--);
78
76
  }
@@ -95,7 +93,7 @@ export function query(fn, name) {
95
93
  "then" in cached[1]
96
94
  ? cached[1].then(handleResponse(false), handleResponse(true))
97
95
  : handleResponse(false)(cached[1]);
98
- !isServer && intent === "navigate" && startTransition(() => cached[4][1](cached[0])); // update version
96
+ !isServer && intent === "navigate" && cached[4][1](cached[0]); // update version
99
97
  }
100
98
  inPreloadFn && "then" in res && res.catch(() => { });
101
99
  return res;
@@ -112,7 +110,7 @@ export function query(fn, name) {
112
110
  cached[0] = now;
113
111
  cached[1] = res;
114
112
  cached[3] = intent;
115
- !isServer && intent === "navigate" && startTransition(() => cached[4][1](cached[0])); // update version
113
+ !isServer && intent === "navigate" && cached[4][1](cached[0]); // update version
116
114
  }
117
115
  else {
118
116
  cache.set(key, (cached = [now, res, , intent, createSignal(now)]));
@@ -159,9 +157,7 @@ export function query(fn, name) {
159
157
  if (url !== null) {
160
158
  // client + server relative redirect
161
159
  if (navigate && url.startsWith("/"))
162
- startTransition(() => {
163
- navigate(url, { replace: true });
164
- });
160
+ navigate(url, { replace: true });
165
161
  else if (!isServer)
166
162
  window.location.href = url;
167
163
  else if (e)
@@ -203,8 +199,6 @@ query.set = (key, value) => {
203
199
  };
204
200
  query.delete = (key) => getCache().delete(key);
205
201
  query.clear = () => getCache().clear();
206
- /** @deprecated use query instead */
207
- export const cache = query;
208
202
  function matchKey(key, keys) {
209
203
  for (let k of keys) {
210
204
  if (k && key.startsWith(k))
package/dist/index.d.ts CHANGED
@@ -4,4 +4,4 @@ export * from "./lifecycle.js";
4
4
  export { useHref, useIsRouting, useLocation, useMatch, useCurrentMatches, useNavigate, useParams, useResolvedPath, useSearchParams, useBeforeLeave, usePreloadRoute, RouterContextObj as RouterContext } from "./routing.js";
5
5
  export { mergeSearchString as _mergeSearchString } from "./utils.js";
6
6
  export * from "./data/index.js";
7
- export type { Location, LocationChange, SearchParams, MatchFilter, MatchFilters, NavigateOptions, Navigator, OutputMatch, Params, PathMatch, RouteSectionProps, RoutePreloadFunc, RoutePreloadFuncArgs, RouteDefinition, RouteDescription, RouteMatch, RouterIntegration, RouterUtils, SetParams, Submission, BeforeLeaveEventArgs, RouteLoadFunc, RouteLoadFuncArgs, RouterResponseInit, CustomResponse } from "./types.js";
7
+ export type { Location, LocationChange, SearchParams, MatchFilter, MatchFilters, NavigateOptions, Navigator, OutputMatch, Params, PathMatch, RouteSectionProps, RoutePreloadFunc, RoutePreloadFuncArgs, RouteDefinition, RouteDescription, RouteMatch, RouterIntegration, RouterUtils, SetParams, Submission, BeforeLeaveEventArgs, RouterResponseInit, CustomResponse } from "./types.js";