@nemigo/svelte 1.5.0 → 2.1.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.
- package/dist/kit/navigation.d.ts +13 -0
- package/dist/kit/navigation.js +32 -0
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +1 -1
- package/package.json +15 -11
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IState } from "@nemigo/helpers/types";
|
|
2
|
+
import type { ISvelteState } from "@nemigo/svelte";
|
|
3
|
+
export interface NavigationHandler {
|
|
4
|
+
ignore?: (from: URL, to: URL) => boolean;
|
|
5
|
+
equal?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class Navigation<State extends IState<boolean> = ISvelteState<boolean>> {
|
|
8
|
+
state: State;
|
|
9
|
+
__handler: NavigationHandler;
|
|
10
|
+
static default(handler?: NavigationHandler): Navigation;
|
|
11
|
+
constructor(state: State, handler?: NavigationHandler);
|
|
12
|
+
hydrate(): this;
|
|
13
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createSvelteState } from "@nemigo/svelte";
|
|
2
|
+
import { afterNavigate, beforeNavigate } from "$app/navigation";
|
|
3
|
+
import { page } from "$app/state";
|
|
4
|
+
export class Navigation {
|
|
5
|
+
state;
|
|
6
|
+
__handler;
|
|
7
|
+
static default(handler) {
|
|
8
|
+
return new Navigation(createSvelteState(false), handler);
|
|
9
|
+
}
|
|
10
|
+
constructor(state, handler = {}) {
|
|
11
|
+
this.state = state;
|
|
12
|
+
this.__handler = handler;
|
|
13
|
+
}
|
|
14
|
+
hydrate() {
|
|
15
|
+
afterNavigate(() => this.state.set(false));
|
|
16
|
+
beforeNavigate((navigation) => {
|
|
17
|
+
if (!navigation.to)
|
|
18
|
+
return;
|
|
19
|
+
const form_url = page.url;
|
|
20
|
+
const to_url = navigation.to.url;
|
|
21
|
+
if (!this.__handler.equal && form_url.toString() === to_url.toString())
|
|
22
|
+
return;
|
|
23
|
+
if (this.__handler.ignore?.(form_url, to_url))
|
|
24
|
+
return;
|
|
25
|
+
if (this.state.get())
|
|
26
|
+
navigation.cancel();
|
|
27
|
+
else
|
|
28
|
+
this.state.set(true);
|
|
29
|
+
});
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
}
|
package/dist/loader.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ISvelteState } from "./state.svelte.js";
|
|
2
1
|
import { Loader } from "@nemigo/helpers/async/loader";
|
|
3
2
|
import type { IState } from "@nemigo/helpers/types";
|
|
3
|
+
import type { ISvelteState } from "./state.svelte.js";
|
|
4
4
|
export type { LoaderHook } from "@nemigo/helpers/async/loader";
|
|
5
5
|
/**
|
|
6
6
|
* Менеджер состояния выполнения для асинхронных операций.
|
package/dist/loader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createSvelteState } from "./state.svelte.js";
|
|
2
1
|
import { Loader } from "@nemigo/helpers/async/loader";
|
|
3
2
|
import { onMount } from "svelte";
|
|
3
|
+
import { createSvelteState } from "./state.svelte.js";
|
|
4
4
|
/**
|
|
5
5
|
* Менеджер состояния выполнения для асинхронных операций.
|
|
6
6
|
* Поддерживает гидратацию true-значения после SSR
|
package/package.json
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nemigo/svelte",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Vlad Logvin",
|
|
7
7
|
"email": "vlad.logvin84@gmail.com"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
|
-
"engines": {
|
|
11
|
-
"node": ">=22",
|
|
12
|
-
"pnpm": ">=10.9.0"
|
|
13
|
-
},
|
|
14
10
|
"scripts": {
|
|
15
11
|
"build": "svelte-package && rimraf .svelte-kit",
|
|
16
|
-
"check": "tsc --noemit",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
12
|
+
"check": "bunx --bun tsc --noemit",
|
|
13
|
+
"eslint": "bunx --bun eslint ./",
|
|
14
|
+
"eslint:fix": "bunx --bun eslint --fix ./",
|
|
15
|
+
"lint": "biome lint",
|
|
16
|
+
"lint:fix": "biome lint --fix --unsafe",
|
|
17
|
+
"lint:fix:unsafe": "biome lint --fix --unsafe",
|
|
18
|
+
"format": "biome check --write --linter-enabled=false"
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
22
|
"types": "./dist/state.svelte.d.ts",
|
|
23
23
|
"svelte": "./dist/state.svelte.js"
|
|
24
24
|
},
|
|
25
|
+
"./kit/navigation": {
|
|
26
|
+
"types": "./dist/kit/navigation.d.ts",
|
|
27
|
+
"svelte": "./dist/kit/navigation.js"
|
|
28
|
+
},
|
|
25
29
|
"./loader": {
|
|
26
30
|
"types": "./dist/loader.d.ts",
|
|
27
31
|
"svelte": "./dist/loader.js"
|
|
@@ -32,7 +36,7 @@
|
|
|
32
36
|
}
|
|
33
37
|
},
|
|
34
38
|
"peerDependencies": {
|
|
35
|
-
"@nemigo/helpers": ">=
|
|
39
|
+
"@nemigo/helpers": ">=2.0.0",
|
|
36
40
|
"@sveltejs/kit": ">=2.12.0",
|
|
37
41
|
"svelte": ">=5.0.0"
|
|
38
42
|
},
|
|
@@ -45,7 +49,7 @@
|
|
|
45
49
|
"csstype": ">=3.0.0"
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {
|
|
48
|
-
"@nemigo/configs": "
|
|
49
|
-
"@nemigo/helpers": "
|
|
52
|
+
"@nemigo/configs": "2.1.0",
|
|
53
|
+
"@nemigo/helpers": "2.0.0"
|
|
50
54
|
}
|
|
51
55
|
}
|