solid-navigator 0.3.3 → 0.3.5

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.js CHANGED
@@ -1,8 +1,8 @@
1
+ import { createContext, children, createMemo, createSignal, onCleanup, batch, mergeProps, createEffect, on, useContext } from 'solid-js';
1
2
  import { delegateEvents, createComponent, spread, template } from 'solid-js/web';
2
- import { createContext, children, createMemo, createSignal, onCleanup, mergeProps, createEffect, on, useContext } from 'solid-js';
3
3
  import { createStore, reconcile } from 'solid-js/store';
4
4
 
5
- // src/Router.tsx
5
+ // src/navigator.ts
6
6
 
7
7
  // src/utils/matcher.ts
8
8
  function createMatcher(path, partial, matchFilters) {
@@ -152,8 +152,10 @@ function Router(props) {
152
152
  });
153
153
  const navigate = createNavigate(routes, pathname, setPathname, setHashAndSearch);
154
154
  const onPopState = (_event) => {
155
- setPathname(location.pathname);
156
- setHashAndSearch(getHashAndSearch());
155
+ batch(() => {
156
+ setPathname(location.pathname);
157
+ setHashAndSearch(getHashAndSearch());
158
+ });
157
159
  };
158
160
  const onClick = (event) => {
159
161
  if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
@@ -163,8 +165,10 @@ function Router(props) {
163
165
  return;
164
166
  if (!target.hasAttribute("sn-link"))
165
167
  return;
166
- event.preventDefault();
167
168
  const href = target.getAttribute("href") || "";
169
+ if (href.startsWith("http://") || href.startsWith("https://"))
170
+ return;
171
+ event.preventDefault();
168
172
  navigate(href, {
169
173
  replace: target.hasAttribute("replace")
170
174
  });
@@ -284,8 +288,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
284
288
  if (!isValidPath(routes, location.pathname)) {
285
289
  console.warn("Invalid path: " + path);
286
290
  }
287
- setPathname(location.pathname);
288
- setHashAndSearch(getHashAndSearch());
291
+ batch(() => {
292
+ setPathname(location.pathname);
293
+ setHashAndSearch(getHashAndSearch());
294
+ });
289
295
  };
290
296
  };
291
297
  var useNavigate = () => {
package/dist/dev.jsx CHANGED
@@ -1,5 +1,9 @@
1
+ // src/navigator.ts
2
+ import { batch as batch2 } from "solid-js";
3
+
1
4
  // src/Router.tsx
2
5
  import {
6
+ batch,
3
7
  children,
4
8
  createContext,
5
9
  createMemo as createMemo2,
@@ -159,8 +163,10 @@ function Router(props) {
159
163
  });
160
164
  const navigate = createNavigate(routes, pathname, setPathname, setHashAndSearch);
161
165
  const onPopState = (_event) => {
162
- setPathname(location.pathname);
163
- setHashAndSearch(getHashAndSearch());
166
+ batch(() => {
167
+ setPathname(location.pathname);
168
+ setHashAndSearch(getHashAndSearch());
169
+ });
164
170
  };
165
171
  const onClick = (event) => {
166
172
  if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
@@ -170,8 +176,10 @@ function Router(props) {
170
176
  return;
171
177
  if (!target.hasAttribute("sn-link"))
172
178
  return;
173
- event.preventDefault();
174
179
  const href = target.getAttribute("href") || "";
180
+ if (href.startsWith("http://") || href.startsWith("https://"))
181
+ return;
182
+ event.preventDefault();
175
183
  navigate(href, {
176
184
  replace: target.hasAttribute("replace")
177
185
  });
@@ -286,8 +294,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
286
294
  if (!isValidPath(routes, location.pathname)) {
287
295
  console.warn("Invalid path: " + path);
288
296
  }
289
- setPathname(location.pathname);
290
- setHashAndSearch(getHashAndSearch());
297
+ batch2(() => {
298
+ setPathname(location.pathname);
299
+ setHashAndSearch(getHashAndSearch());
300
+ });
291
301
  };
292
302
  };
293
303
  var useNavigate = () => {
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
+ import { createContext, children, createMemo, createSignal, onCleanup, batch, mergeProps, createEffect, on, useContext } from 'solid-js';
1
2
  import { delegateEvents, createComponent, spread, template } from 'solid-js/web';
2
- import { createContext, children, createMemo, createSignal, onCleanup, mergeProps, createEffect, on, useContext } from 'solid-js';
3
3
  import { createStore, reconcile } from 'solid-js/store';
4
4
 
5
- // src/Router.tsx
5
+ // src/navigator.ts
6
6
 
7
7
  // src/utils/matcher.ts
8
8
  function createMatcher(path, partial, matchFilters) {
@@ -152,8 +152,10 @@ function Router(props) {
152
152
  });
153
153
  const navigate = createNavigate(routes, pathname, setPathname, setHashAndSearch);
154
154
  const onPopState = (_event) => {
155
- setPathname(location.pathname);
156
- setHashAndSearch(getHashAndSearch());
155
+ batch(() => {
156
+ setPathname(location.pathname);
157
+ setHashAndSearch(getHashAndSearch());
158
+ });
157
159
  };
158
160
  const onClick = (event) => {
159
161
  if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
@@ -163,8 +165,10 @@ function Router(props) {
163
165
  return;
164
166
  if (!target.hasAttribute("sn-link"))
165
167
  return;
166
- event.preventDefault();
167
168
  const href = target.getAttribute("href") || "";
169
+ if (href.startsWith("http://") || href.startsWith("https://"))
170
+ return;
171
+ event.preventDefault();
168
172
  navigate(href, {
169
173
  replace: target.hasAttribute("replace")
170
174
  });
@@ -282,8 +286,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
282
286
  history.pushState({}, "", newPath);
283
287
  }
284
288
  if (!isValidPath(routes, location.pathname)) ;
285
- setPathname(location.pathname);
286
- setHashAndSearch(getHashAndSearch());
289
+ batch(() => {
290
+ setPathname(location.pathname);
291
+ setHashAndSearch(getHashAndSearch());
292
+ });
287
293
  };
288
294
  };
289
295
  var useNavigate = () => {
package/dist/index.jsx CHANGED
@@ -1,5 +1,9 @@
1
+ // src/navigator.ts
2
+ import { batch as batch2 } from "solid-js";
3
+
1
4
  // src/Router.tsx
2
5
  import {
6
+ batch,
3
7
  children,
4
8
  createContext,
5
9
  createMemo as createMemo2,
@@ -159,8 +163,10 @@ function Router(props) {
159
163
  });
160
164
  const navigate = createNavigate(routes, pathname, setPathname, setHashAndSearch);
161
165
  const onPopState = (_event) => {
162
- setPathname(location.pathname);
163
- setHashAndSearch(getHashAndSearch());
166
+ batch(() => {
167
+ setPathname(location.pathname);
168
+ setHashAndSearch(getHashAndSearch());
169
+ });
164
170
  };
165
171
  const onClick = (event) => {
166
172
  if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
@@ -170,8 +176,10 @@ function Router(props) {
170
176
  return;
171
177
  if (!target.hasAttribute("sn-link"))
172
178
  return;
173
- event.preventDefault();
174
179
  const href = target.getAttribute("href") || "";
180
+ if (href.startsWith("http://") || href.startsWith("https://"))
181
+ return;
182
+ event.preventDefault();
175
183
  navigate(href, {
176
184
  replace: target.hasAttribute("replace")
177
185
  });
@@ -285,8 +293,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
285
293
  }
286
294
  if (!isValidPath(routes, location.pathname)) {
287
295
  }
288
- setPathname(location.pathname);
289
- setHashAndSearch(getHashAndSearch());
296
+ batch2(() => {
297
+ setPathname(location.pathname);
298
+ setHashAndSearch(getHashAndSearch());
299
+ });
290
300
  };
291
301
  };
292
302
  var useNavigate = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-navigator",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Solid Navigator is a library that is inspired by vue router and solid router.",
5
5
  "license": "MIT",
6
6
  "author": "SupertigerDev",