@nil-/xit 0.1.16 → 0.1.18
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/assets/bundler.js +79 -78
- package/assets/index.js +754 -730
- package/assets/svelte/index.js +817 -770
- package/assets/svelte/internal/client.js +1033 -1080
- package/assets/svelte/motion.js +22 -19
- package/assets/svelte/store.js +44 -43
- package/index.d.ts +22 -24
- package/package.json +1 -1
package/assets/svelte/motion.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { w as P } from "./store.js";
|
|
2
2
|
import { linear as z } from "./easing.js";
|
|
3
|
-
const C =
|
|
3
|
+
const C = () => performance.now(), p = {
|
|
4
|
+
// don't access requestAnimationFrame eagerly outside method
|
|
5
|
+
// this allows basic testing of user code without JSDOM
|
|
6
|
+
// bunder will eval and remove ternary when the user's app is built
|
|
4
7
|
tick: (
|
|
5
8
|
/** @param {any} _ */
|
|
6
|
-
(t) =>
|
|
9
|
+
(t) => requestAnimationFrame(t)
|
|
7
10
|
),
|
|
8
|
-
now: () =>
|
|
11
|
+
now: () => C(),
|
|
9
12
|
tasks: /* @__PURE__ */ new Set()
|
|
10
13
|
};
|
|
11
14
|
function O(t) {
|
|
@@ -48,19 +51,19 @@ function j(t, r, e, i) {
|
|
|
48
51
|
throw new Error(`Cannot spring ${typeof e} values`);
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
|
-
function
|
|
54
|
+
function D(t, r = {}) {
|
|
52
55
|
const e = P(t), { stiffness: i = 0.15, damping: n = 0.8, precision: s = 0.01 } = r;
|
|
53
56
|
let o, f, c, l = (
|
|
54
57
|
/** @type {T} */
|
|
55
58
|
t
|
|
56
|
-
),
|
|
59
|
+
), u = (
|
|
57
60
|
/** @type {T | undefined} */
|
|
58
61
|
t
|
|
59
62
|
), a = 1, w = 0, b = !1;
|
|
60
|
-
function k(
|
|
61
|
-
|
|
63
|
+
function k(y, m = {}) {
|
|
64
|
+
u = y;
|
|
62
65
|
const S = c = {};
|
|
63
|
-
return t == null || m.hard || d.stiffness >= 1 && d.damping >= 1 ? (b = !0, o = p.now(), l =
|
|
66
|
+
return t == null || m.hard || d.stiffness >= 1 && d.damping >= 1 ? (b = !0, o = p.now(), l = y, e.set(t = u), Promise.resolve()) : (m.soft && (w = 1 / ((m.soft === !0 ? 0.5 : +m.soft) * 60), a = 0), f || (o = p.now(), b = !1, f = M((g) => {
|
|
64
67
|
if (b)
|
|
65
68
|
return b = !1, f = null, !1;
|
|
66
69
|
a = Math.min(a + w, 1);
|
|
@@ -69,7 +72,7 @@ function q(t, r = {}) {
|
|
|
69
72
|
opts: d,
|
|
70
73
|
settled: !0,
|
|
71
74
|
dt: (g - o) * 60 / 1e3
|
|
72
|
-
}, T = j(A, l, t,
|
|
75
|
+
}, T = j(A, l, t, u);
|
|
73
76
|
return o = g, l = /** @type {T} */
|
|
74
77
|
t, e.set(t = /** @type {T} */
|
|
75
78
|
T), A.settled && (f = null), !A.settled;
|
|
@@ -81,9 +84,9 @@ function q(t, r = {}) {
|
|
|
81
84
|
}
|
|
82
85
|
const d = {
|
|
83
86
|
set: k,
|
|
84
|
-
update: (
|
|
87
|
+
update: (y, m) => k(y(
|
|
85
88
|
/** @type {T} */
|
|
86
|
-
|
|
89
|
+
u,
|
|
87
90
|
/** @type {T} */
|
|
88
91
|
t
|
|
89
92
|
), m),
|
|
@@ -137,24 +140,24 @@ function E(t, r) {
|
|
|
137
140
|
}
|
|
138
141
|
throw new Error(`Cannot interpolate ${e} values`);
|
|
139
142
|
}
|
|
140
|
-
function
|
|
143
|
+
function $(t, r = {}) {
|
|
141
144
|
const e = P(t);
|
|
142
145
|
let i, n = t;
|
|
143
146
|
function s(o, f) {
|
|
144
147
|
if (n = o, t == null)
|
|
145
148
|
return e.set(t = o), Promise.resolve();
|
|
146
149
|
let c = i, l = !1, {
|
|
147
|
-
delay:
|
|
150
|
+
delay: u = 0,
|
|
148
151
|
duration: a = 400,
|
|
149
152
|
easing: w = z,
|
|
150
153
|
interpolate: b = E
|
|
151
154
|
} = { ...r, ...f };
|
|
152
155
|
if (a === 0)
|
|
153
156
|
return c && (c.abort(), c = null), e.set(t = n), Promise.resolve();
|
|
154
|
-
const k = p.now() +
|
|
157
|
+
const k = p.now() + u;
|
|
155
158
|
let d;
|
|
156
|
-
return i = M((
|
|
157
|
-
if (
|
|
159
|
+
return i = M((y) => {
|
|
160
|
+
if (y < k) return !0;
|
|
158
161
|
l || (d = b(
|
|
159
162
|
/** @type {any} */
|
|
160
163
|
t,
|
|
@@ -164,7 +167,7 @@ function _(t, r = {}) {
|
|
|
164
167
|
t,
|
|
165
168
|
o
|
|
166
169
|
)), l = !0), c && (c.abort(), c = null);
|
|
167
|
-
const m =
|
|
170
|
+
const m = y - k;
|
|
168
171
|
return m > /** @type {number} */
|
|
169
172
|
a ? (e.set(t = o), !1) : (e.set(t = d(w(m / a))), !0);
|
|
170
173
|
}), i.promise;
|
|
@@ -182,8 +185,8 @@ function _(t, r = {}) {
|
|
|
182
185
|
}
|
|
183
186
|
const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
184
187
|
__proto__: null,
|
|
185
|
-
spring:
|
|
186
|
-
tweened:
|
|
188
|
+
spring: D,
|
|
189
|
+
tweened: $
|
|
187
190
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
188
191
|
export {
|
|
189
192
|
B as i,
|
package/assets/svelte/store.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as q, n as b, u as x,
|
|
1
|
+
import { s as q, n as b, u as x, a as z, r as j, e as A, b as h, c as O, g as B, t as C, d as E } from "./index.js";
|
|
2
2
|
import "./internal/client.js";
|
|
3
3
|
function M(e) {
|
|
4
4
|
q(e, e.v + 1);
|
|
@@ -16,16 +16,16 @@ function m(e, t, n) {
|
|
|
16
16
|
return r.unsubscribe ? () => r.unsubscribe() : r;
|
|
17
17
|
}
|
|
18
18
|
const l = [];
|
|
19
|
-
function
|
|
19
|
+
function v(e, t) {
|
|
20
20
|
return {
|
|
21
|
-
subscribe:
|
|
21
|
+
subscribe: g(e, t).subscribe
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function g(e, t = b) {
|
|
25
25
|
let n = null;
|
|
26
26
|
const r = /* @__PURE__ */ new Set();
|
|
27
|
-
function u(
|
|
28
|
-
if (
|
|
27
|
+
function u(i) {
|
|
28
|
+
if (z(e, i) && (e = i, n)) {
|
|
29
29
|
const f = !l.length;
|
|
30
30
|
for (const s of r)
|
|
31
31
|
s[1](), l.push(s, e);
|
|
@@ -36,29 +36,29 @@ function _(e, t = b) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function o(
|
|
40
|
-
u(
|
|
39
|
+
function o(i) {
|
|
40
|
+
u(i(
|
|
41
41
|
/** @type {T} */
|
|
42
42
|
e
|
|
43
43
|
));
|
|
44
44
|
}
|
|
45
|
-
function i
|
|
46
|
-
const s = [
|
|
47
|
-
return r.add(s), r.size === 1 && (n = t(u, o) || b),
|
|
45
|
+
function c(i, f = b) {
|
|
46
|
+
const s = [i, f];
|
|
47
|
+
return r.add(s), r.size === 1 && (n = t(u, o) || b), i(
|
|
48
48
|
/** @type {T} */
|
|
49
49
|
e
|
|
50
50
|
), () => {
|
|
51
51
|
r.delete(s), r.size === 0 && n && (n(), n = null);
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
return { set: u, update: o, subscribe:
|
|
54
|
+
return { set: u, update: o, subscribe: c };
|
|
55
55
|
}
|
|
56
56
|
function P(e, t, n) {
|
|
57
57
|
const r = !Array.isArray(e), u = r ? [e] : e;
|
|
58
58
|
if (!u.every(Boolean))
|
|
59
59
|
throw new Error("derived() expects stores as input, got a falsy value");
|
|
60
60
|
const o = t.length < 2;
|
|
61
|
-
return
|
|
61
|
+
return v(n, (c, i) => {
|
|
62
62
|
let f = !1;
|
|
63
63
|
const s = [];
|
|
64
64
|
let d = 0, p = b;
|
|
@@ -66,21 +66,21 @@ function P(e, t, n) {
|
|
|
66
66
|
if (d)
|
|
67
67
|
return;
|
|
68
68
|
p();
|
|
69
|
-
const a = t(r ? s[0] : s,
|
|
70
|
-
o ?
|
|
71
|
-
},
|
|
72
|
-
(a,
|
|
69
|
+
const a = t(r ? s[0] : s, c, i);
|
|
70
|
+
o ? c(a) : p = typeof a == "function" ? a : b;
|
|
71
|
+
}, S = u.map(
|
|
72
|
+
(a, _) => m(
|
|
73
73
|
a,
|
|
74
74
|
(k) => {
|
|
75
|
-
s[
|
|
75
|
+
s[_] = k, d &= ~(1 << _), f && y();
|
|
76
76
|
},
|
|
77
77
|
() => {
|
|
78
|
-
d |= 1 <<
|
|
78
|
+
d |= 1 << _;
|
|
79
79
|
}
|
|
80
80
|
)
|
|
81
81
|
);
|
|
82
82
|
return f = !0, y(), function() {
|
|
83
|
-
|
|
83
|
+
j(S), p(), f = !1;
|
|
84
84
|
};
|
|
85
85
|
});
|
|
86
86
|
}
|
|
@@ -90,27 +90,28 @@ function T(e) {
|
|
|
90
90
|
subscribe: e.subscribe.bind(e)
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function w(e) {
|
|
94
94
|
let t;
|
|
95
95
|
return m(e, (n) => t = n)(), t;
|
|
96
96
|
}
|
|
97
97
|
function $(e, t) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
let n = e();
|
|
99
|
+
const r = g(n, (u) => {
|
|
100
|
+
let o = n !== e();
|
|
101
|
+
const c = A(() => {
|
|
101
102
|
h(() => {
|
|
102
103
|
const i = e();
|
|
103
|
-
|
|
104
|
+
o && u(i);
|
|
104
105
|
});
|
|
105
106
|
});
|
|
106
|
-
return
|
|
107
|
+
return o = !0, c;
|
|
107
108
|
});
|
|
108
109
|
return t ? {
|
|
109
110
|
set: t,
|
|
110
|
-
update: (
|
|
111
|
-
subscribe:
|
|
111
|
+
update: (u) => t(u(e())),
|
|
112
|
+
subscribe: r.subscribe
|
|
112
113
|
} : {
|
|
113
|
-
subscribe:
|
|
114
|
+
subscribe: r.subscribe
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
117
|
function D(e) {
|
|
@@ -118,24 +119,24 @@ function D(e) {
|
|
|
118
119
|
function o() {
|
|
119
120
|
return O() ? (B(n), h(() => {
|
|
120
121
|
if (r === 0) {
|
|
121
|
-
let
|
|
122
|
-
u = e.subscribe((
|
|
123
|
-
t =
|
|
124
|
-
}),
|
|
122
|
+
let c = !1;
|
|
123
|
+
u = e.subscribe((i) => {
|
|
124
|
+
t = i, c && M(n);
|
|
125
|
+
}), c = !0;
|
|
125
126
|
}
|
|
126
127
|
return r += 1, () => {
|
|
127
|
-
|
|
128
|
-
r === 0 && u();
|
|
128
|
+
C().then(() => {
|
|
129
|
+
r -= 1, r === 0 && u();
|
|
129
130
|
});
|
|
130
131
|
};
|
|
131
|
-
}), t) :
|
|
132
|
+
}), t) : w(e);
|
|
132
133
|
}
|
|
133
134
|
return "set" in e ? {
|
|
134
135
|
get current() {
|
|
135
136
|
return o();
|
|
136
137
|
},
|
|
137
|
-
set current(
|
|
138
|
-
e.set(
|
|
138
|
+
set current(c) {
|
|
139
|
+
e.set(c);
|
|
139
140
|
}
|
|
140
141
|
} : {
|
|
141
142
|
get current() {
|
|
@@ -147,15 +148,15 @@ const H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
147
148
|
__proto__: null,
|
|
148
149
|
derived: P,
|
|
149
150
|
fromStore: D,
|
|
150
|
-
get:
|
|
151
|
-
readable:
|
|
151
|
+
get: w,
|
|
152
|
+
readable: v,
|
|
152
153
|
readonly: T,
|
|
153
154
|
toStore: $,
|
|
154
|
-
writable:
|
|
155
|
+
writable: g
|
|
155
156
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
156
157
|
export {
|
|
157
|
-
|
|
158
|
+
w as g,
|
|
158
159
|
H as i,
|
|
159
160
|
m as s,
|
|
160
|
-
|
|
161
|
+
g as w
|
|
161
162
|
};
|
package/index.d.ts
CHANGED
|
@@ -10,33 +10,31 @@ export type CoDec = {
|
|
|
10
10
|
encode: (o: Record<string, any>) => Uint8Array;
|
|
11
11
|
decode: (a: Uint8Array) => Record<string, any>;
|
|
12
12
|
};
|
|
13
|
-
export type
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export type Values = {
|
|
14
|
+
boolean: (t: string, v: boolean) => Writable<boolean>;
|
|
15
|
+
double: (t: string, v: number) => Writable<number>;
|
|
16
|
+
number: (t: string, v: number) => Writable<number>;
|
|
17
|
+
string: (t: string, v: string) => Writable<string>;
|
|
18
|
+
buffer: (t: string, v: Uint8Array) => Writable<Uint8Array>;
|
|
19
|
+
json: (t: string, v: object, codec: CoDec) => Writable<any>;
|
|
16
20
|
};
|
|
17
|
-
export type
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
export type Signals = {
|
|
22
|
+
none: (t: string) => () => void;
|
|
23
|
+
boolean: (t: string) => (v: boolean) => void;
|
|
24
|
+
double: (t: string) => (v: number) => void;
|
|
25
|
+
number: (t: string) => (v: number) => void;
|
|
26
|
+
string: (t: string) => (v: string) => void;
|
|
27
|
+
buffer: (t: string) => (v: Uint8Array) => void;
|
|
28
|
+
json: (t: string, encoder: CoDec["encode"]) => (v: any) => void;
|
|
20
29
|
};
|
|
21
30
|
export type Xit = {
|
|
22
|
-
values:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
signals: {
|
|
31
|
-
none: (t: string) => () => void;
|
|
32
|
-
boolean: (t: string) => (v: boolean) => void;
|
|
33
|
-
double: (t: string) => (v: number) => void;
|
|
34
|
-
number: (t: string) => (v: number) => void;
|
|
35
|
-
string: (t: string) => (v: string) => void;
|
|
36
|
-
buffer: (t: string) => (v: Uint8Array) => void;
|
|
37
|
-
json: (t: string, encoder: CoDec["encode"]) => (v: any) => void;
|
|
38
|
-
};
|
|
39
|
-
loader: Loader;
|
|
31
|
+
values: Values;
|
|
32
|
+
signals: Signals;
|
|
33
|
+
frame_ui: (f: string, tag?: string) => Promise<Action<HTMLDivElement>>;
|
|
34
|
+
frame: (f: string, tag?: string) => Promise<{
|
|
35
|
+
values: Values;
|
|
36
|
+
signals: Signals;
|
|
37
|
+
}>;
|
|
40
38
|
};
|
|
41
39
|
export declare const json_string: CoDec;
|
|
42
40
|
export declare const xit: () => Xit;
|