@nemigo/svelte 0.2.2 → 0.3.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.
@@ -21,7 +21,7 @@ declare class StateCTX extends Queue<QueueItem> {
21
21
  /**
22
22
  * Безопасно от прокси добавляет новое состояние в историю браузера
23
23
  */
24
- private pushStateSafe;
24
+ pushStateSafe(url: string | URL, ctate?: App.PageState): void;
25
25
  /**
26
26
  * Безопасно от прокси заменяет текущее состояние в истории браузера
27
27
  */
package/dist/kit/state.js CHANGED
@@ -33,12 +33,14 @@ class StateCTX extends Queue {
33
33
  * Безопасно от прокси добавляет новое состояние в историю браузера
34
34
  */
35
35
  pushStateSafe(url, ctate = this.get()) {
36
+ // eslint-disable-next-line svelte/no-navigation-without-resolve
36
37
  pushState(url, parsify(ctate));
37
38
  }
38
39
  /**
39
40
  * Безопасно от прокси заменяет текущее состояние в истории браузера
40
41
  */
41
42
  replaceStateSafe(url, ctate = this.get()) {
43
+ // eslint-disable-next-line svelte/no-navigation-without-resolve
42
44
  replaceState(url, parsify(ctate));
43
45
  }
44
46
  //...
package/dist/loader.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type LoaderHook = ReturnType<LoaderStore["hook"]>;
2
2
  export declare class LoaderStore {
3
- store: import("./value.svelte.js").ValueStoreType<boolean>;
3
+ state: import("./value.svelte.js").ValueStateType<boolean>;
4
4
  private queue;
5
5
  private caller;
6
6
  _hydratable: boolean;
package/dist/loader.js CHANGED
@@ -1,15 +1,15 @@
1
- import { ValueStore } from "./value.svelte.js";
1
+ import { ValueState } from "./value.svelte.js";
2
2
  import { delay } from "@nemigo/helpers/async";
3
3
  import { isSSR } from "@nemigo/helpers/html";
4
4
  import { onMount } from "svelte";
5
5
  export class LoaderStore {
6
- store = ValueStore(false);
6
+ state = ValueState(false);
7
7
  queue = [];
8
8
  caller = 0;
9
9
  _hydratable;
10
10
  constructor(hydratable = false) {
11
11
  this._hydratable = hydratable;
12
- this.store.set(this._hydratable);
12
+ this.state.set(this._hydratable);
13
13
  }
14
14
  check(caller) {
15
15
  if (this.queue.length === 0)
@@ -21,13 +21,13 @@ export class LoaderStore {
21
21
  });
22
22
  }
23
23
  awaiter(caller) {
24
- this.store.set(true);
24
+ this.state.set(true);
25
25
  this.check(caller);
26
26
  }
27
27
  reset(caller) {
28
28
  if (this.caller !== caller)
29
29
  return;
30
- this.store.set(false);
30
+ this.state.set(false);
31
31
  this.caller = 0;
32
32
  this.queue = [];
33
33
  }
@@ -58,7 +58,7 @@ export class LoaderStore {
58
58
  hydrate() {
59
59
  if (this._hydratable) {
60
60
  onMount(() => {
61
- if (this.store.value)
61
+ if (this.state.value)
62
62
  this.check(this.caller);
63
63
  });
64
64
  }
@@ -1,6 +1,6 @@
1
1
  import type { Property } from "csstype";
2
2
  import { linear } from "svelte/easing";
3
- import type { SlideParams, TransitionConfig } from "svelte/transition";
3
+ import type { FlyParams, SlideParams, TransitionConfig } from "svelte/transition";
4
4
  export interface ClassNameTransitionParams {
5
5
  animationClassName: string;
6
6
  /**
@@ -23,6 +23,10 @@ export declare const classNameTransition: (node: HTMLElement, { animationClassNa
23
23
  export declare function slide(node: Element, { delay, duration, easing, axis, classic }?: SlideParams & {
24
24
  classic?: boolean;
25
25
  }): TransitionConfig;
26
+ /**
27
+ * Анимация всплытия (scale + fly)
28
+ */
29
+ export declare const bloop: (node: Element, { delay, duration, easing, x, y, opacity }?: FlyParams) => TransitionConfig;
26
30
  /**
27
31
  * Микс-анимация из scale и translate с добавлением лёгкого fade-эффекта
28
32
  */
@@ -101,6 +101,33 @@ export function slide(node, { delay = 0, duration = 325, easing, axis = "y", cla
101
101
  };
102
102
  }
103
103
  //...
104
+ const split_css_unit = (value) => {
105
+ const split = typeof value === "string" && value.match(/^\s*(-?[\d.]+)(\S*)\s*$/);
106
+ return split ? [parseFloat(split[1]), split[2] || "px"] : [Number(value), "px"];
107
+ };
108
+ /**
109
+ * Анимация всплытия (scale + fly)
110
+ */
111
+ export const bloop = (node, { delay = 0, duration = 325, easing = quadInOut, x = 0, y = 0, opacity = 0 } = {}) => {
112
+ const style = getComputedStyle(node);
113
+ const target_opacity = +style.opacity;
114
+ const transform = style.transform === "none" ? "" : style.transform;
115
+ const od = target_opacity * (1 - opacity);
116
+ const { 0: x_value, 1: x_unit } = split_css_unit(x);
117
+ const { 0: y_value, 1: y_unit } = split_css_unit(y);
118
+ return {
119
+ delay,
120
+ duration,
121
+ easing,
122
+ css: (t, u) => {
123
+ const boosted = css_boost(t, 2 / 5);
124
+ return `
125
+ transform: ${transform} translate(${(1 - t) * x_value}${x_unit}, ${(1 - t) * y_value}${y_unit}) scale(${boosted});
126
+ opacity: ${target_opacity - od * u}
127
+ `;
128
+ },
129
+ };
130
+ };
104
131
  /**
105
132
  * Микс-анимация из scale и translate с добавлением лёгкого fade-эффекта
106
133
  */
@@ -120,7 +147,6 @@ export const upper = (node, { delay = 0, duration = 400, x = 0, y = 0, opacity =
120
147
  },
121
148
  };
122
149
  };
123
- //...
124
150
  /**
125
151
  * Просто анимация изменения размера через font-size (0 ~ 1)
126
152
  */
@@ -1,4 +1,4 @@
1
- export interface ValueStoreType<T = boolean | undefined> {
1
+ export interface ValueStateType<T = boolean | undefined> {
2
2
  /**
3
3
  * @reactive
4
4
  */
@@ -7,6 +7,6 @@ export interface ValueStoreType<T = boolean | undefined> {
7
7
  set(state: T): void;
8
8
  untrack<R>(call: (state: T) => R): R;
9
9
  }
10
- declare function ValueStore<T = boolean>(): ValueStoreType<T | undefined>;
11
- declare function ValueStore<T = boolean>(initial: T): ValueStoreType<T>;
12
- export { ValueStore };
10
+ declare function ValueState<T = boolean>(): ValueStateType<T | undefined>;
11
+ declare function ValueState<T = boolean>(initial: T): ValueStateType<T>;
12
+ export { ValueState };
@@ -1,5 +1,5 @@
1
1
  import { untrack } from "svelte";
2
- function ValueStore(initial) {
2
+ function ValueState(initial) {
3
3
  let _value = $state(initial);
4
4
  return {
5
5
  get value() {
@@ -21,4 +21,4 @@ function ValueStore(initial) {
21
21
  },
22
22
  };
23
23
  }
24
- export { ValueStore };
24
+ export { ValueState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemigo/svelte",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "Vlad Logvin",
@@ -33,7 +33,7 @@
33
33
  }
34
34
  },
35
35
  "peerDependencies": {
36
- "@nemigo/helpers": "^0.3.0",
36
+ "@nemigo/helpers": ">0.3.0",
37
37
  "@sveltejs/kit": "^2.12.0",
38
38
  "svelte": "^5.0.0"
39
39
  },