@nil-/xit 0.2.3 → 0.2.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/assets/bundler.js +278 -0
- package/assets/index.js +2534 -0
- package/assets/svelte/animate.js +29 -0
- package/assets/svelte/easing.js +130 -0
- package/assets/svelte/events.js +4 -0
- package/assets/svelte/index.js +2215 -0
- package/assets/svelte/internal/client.js +2417 -0
- package/assets/svelte/internal/disclose-version.js +3 -0
- package/assets/svelte/motion.js +460 -0
- package/assets/svelte/store.js +173 -0
- package/assets/svelte/transition.js +142 -0
- package/package.json +4 -4
- package/test/Frame.svelte +78 -0
- package/test/Frame.svelte.d.ts +16 -0
- package/test.d.ts +0 -8
- package/test.js +0 -31
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
const M = (t) => t;
|
|
2
|
+
function m(t) {
|
|
3
|
+
const e = t - 1;
|
|
4
|
+
return e * e * e + 1;
|
|
5
|
+
}
|
|
6
|
+
function C(t) {
|
|
7
|
+
return t < 0.5 ? 4 * t * t * t : 0.5 * Math.pow(2 * t - 2, 3) + 1;
|
|
8
|
+
}
|
|
9
|
+
function w(t) {
|
|
10
|
+
const e = typeof t == "string" && t.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);
|
|
11
|
+
return e ? [parseFloat(e[1]), e[2] || "px"] : [
|
|
12
|
+
/** @type {number} */
|
|
13
|
+
t,
|
|
14
|
+
"px"
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
function W(t, { delay: e = 0, duration: a = 400, easing: r = C, amount: p = 5, opacity: n = 0 } = {}) {
|
|
18
|
+
const c = getComputedStyle(t), s = +c.opacity, d = c.filter === "none" ? "" : c.filter, i = s * (1 - n), [o, y] = w(p);
|
|
19
|
+
return {
|
|
20
|
+
delay: e,
|
|
21
|
+
duration: a,
|
|
22
|
+
easing: r,
|
|
23
|
+
css: (f, u) => `opacity: ${s - i * u}; filter: ${d} blur(${u * o}${y});`
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function q(t, { delay: e = 0, duration: a = 400, easing: r = M } = {}) {
|
|
27
|
+
const p = +getComputedStyle(t).opacity;
|
|
28
|
+
return {
|
|
29
|
+
delay: e,
|
|
30
|
+
duration: a,
|
|
31
|
+
easing: r,
|
|
32
|
+
css: (n) => `opacity: ${n * p}`
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function B(t, { delay: e = 0, duration: a = 400, easing: r = m, x: p = 0, y: n = 0, opacity: c = 0 } = {}) {
|
|
36
|
+
const s = getComputedStyle(t), d = +s.opacity, i = s.transform === "none" ? "" : s.transform, o = d * (1 - c), [y, f] = w(p), [u, _] = w(n);
|
|
37
|
+
return {
|
|
38
|
+
delay: e,
|
|
39
|
+
duration: a,
|
|
40
|
+
easing: r,
|
|
41
|
+
css: ($, h) => `
|
|
42
|
+
transform: ${i} translate(${(1 - $) * y}${f}, ${(1 - $) * u}${_});
|
|
43
|
+
opacity: ${d - o * h}`
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function L(t, { delay: e = 0, duration: a = 400, easing: r = m, axis: p = "y" } = {}) {
|
|
47
|
+
const n = getComputedStyle(t), c = +n.opacity, s = p === "y" ? "height" : "width", d = parseFloat(n[s]), i = p === "y" ? ["top", "bottom"] : ["left", "right"], o = i.map(
|
|
48
|
+
(l) => (
|
|
49
|
+
/** @type {'Left' | 'Right' | 'Top' | 'Bottom'} */
|
|
50
|
+
`${l[0].toUpperCase()}${l.slice(1)}`
|
|
51
|
+
)
|
|
52
|
+
), y = parseFloat(n[`padding${o[0]}`]), f = parseFloat(n[`padding${o[1]}`]), u = parseFloat(n[`margin${o[0]}`]), _ = parseFloat(n[`margin${o[1]}`]), $ = parseFloat(
|
|
53
|
+
n[`border${o[0]}Width`]
|
|
54
|
+
), h = parseFloat(
|
|
55
|
+
n[`border${o[1]}Width`]
|
|
56
|
+
);
|
|
57
|
+
return {
|
|
58
|
+
delay: e,
|
|
59
|
+
duration: a,
|
|
60
|
+
easing: r,
|
|
61
|
+
css: (l) => `overflow: hidden;opacity: ${Math.min(l * 20, 1) * c};${s}: ${l * d}px;padding-${i[0]}: ${l * y}px;padding-${i[1]}: ${l * f}px;margin-${i[0]}: ${l * u}px;margin-${i[1]}: ${l * _}px;border-${i[0]}-width: ${l * $}px;border-${i[1]}-width: ${l * h}px;min-${s}: 0`
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function R(t, { delay: e = 0, duration: a = 400, easing: r = m, start: p = 0, opacity: n = 0 } = {}) {
|
|
65
|
+
const c = getComputedStyle(t), s = +c.opacity, d = c.transform === "none" ? "" : c.transform, i = 1 - p, o = s * (1 - n);
|
|
66
|
+
return {
|
|
67
|
+
delay: e,
|
|
68
|
+
duration: a,
|
|
69
|
+
easing: r,
|
|
70
|
+
css: (y, f) => `
|
|
71
|
+
transform: ${d} scale(${1 - i * f});
|
|
72
|
+
opacity: ${s - o * f}
|
|
73
|
+
`
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function z(t, { delay: e = 0, speed: a, duration: r, easing: p = C } = {}) {
|
|
77
|
+
let n = t.getTotalLength();
|
|
78
|
+
const c = getComputedStyle(t);
|
|
79
|
+
return c.strokeLinecap !== "butt" && (n += parseInt(c.strokeWidth)), r === void 0 ? a === void 0 ? r = 800 : r = n / a : typeof r == "function" && (r = r(n)), {
|
|
80
|
+
delay: e,
|
|
81
|
+
duration: r,
|
|
82
|
+
easing: p,
|
|
83
|
+
css: (s, d) => `
|
|
84
|
+
stroke-dasharray: ${n};
|
|
85
|
+
stroke-dashoffset: ${d * n};
|
|
86
|
+
`
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function v(t, e) {
|
|
90
|
+
for (const a in e) t[a] = e[a];
|
|
91
|
+
return (
|
|
92
|
+
/** @type {T & S} */
|
|
93
|
+
t
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function I({ fallback: t, ...e }) {
|
|
97
|
+
const a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
98
|
+
function p(c, s, d) {
|
|
99
|
+
const {
|
|
100
|
+
delay: i = 0,
|
|
101
|
+
duration: o = (
|
|
102
|
+
/** @param {number} d */
|
|
103
|
+
(g) => Math.sqrt(g) * 30
|
|
104
|
+
),
|
|
105
|
+
easing: y = m
|
|
106
|
+
} = v(v({}, e), d), f = c.getBoundingClientRect(), u = s.getBoundingClientRect(), _ = f.left - u.left, $ = f.top - u.top, h = f.width / u.width, l = f.height / u.height, k = Math.sqrt(_ * _ + $ * $), x = getComputedStyle(s), F = x.transform === "none" ? "" : x.transform, S = +x.opacity;
|
|
107
|
+
return {
|
|
108
|
+
delay: i,
|
|
109
|
+
duration: typeof o == "function" ? o(k) : o,
|
|
110
|
+
easing: y,
|
|
111
|
+
css: (g, b) => `
|
|
112
|
+
opacity: ${g * S};
|
|
113
|
+
transform-origin: top left;
|
|
114
|
+
transform: ${F} translate(${b * _}px,${b * $}px) scale(${g + (1 - g) * h}, ${g + (1 - g) * l});
|
|
115
|
+
`
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function n(c, s, d) {
|
|
119
|
+
return (i, o) => (c.set(o.key, i), () => {
|
|
120
|
+
if (s.has(o.key)) {
|
|
121
|
+
const y = s.get(o.key);
|
|
122
|
+
return s.delete(o.key), p(
|
|
123
|
+
/** @type {Element} */
|
|
124
|
+
y,
|
|
125
|
+
i,
|
|
126
|
+
o
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
return c.delete(o.key), t && t(i, o, d);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return [n(r, a, !1), n(a, r, !0)];
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
W as blur,
|
|
136
|
+
I as crossfade,
|
|
137
|
+
z as draw,
|
|
138
|
+
q as fade,
|
|
139
|
+
B as fly,
|
|
140
|
+
R as scale,
|
|
141
|
+
L as slide
|
|
142
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nil-/xit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"svelte": "^5.7.1"
|
|
6
6
|
},
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"types": "./index.d.ts",
|
|
12
12
|
"default": "./index.js"
|
|
13
13
|
},
|
|
14
|
-
"./test": {
|
|
15
|
-
"types": "./test.d.ts",
|
|
16
|
-
"
|
|
14
|
+
"./test/Frame.svelte": {
|
|
15
|
+
"types": "./test/Frame.svelte.d.ts",
|
|
16
|
+
"svelte": "./test/Frame.svelte"
|
|
17
17
|
},
|
|
18
18
|
"./components/layouts/Container.svelte": {
|
|
19
19
|
"types": "./components/layouts/Container.svelte.d.ts",
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">import { xit } from "../index";
|
|
2
|
+
import { get } from "svelte/store";
|
|
3
|
+
let {
|
|
4
|
+
decoder,
|
|
5
|
+
selected = -1,
|
|
6
|
+
load
|
|
7
|
+
} = $props();
|
|
8
|
+
let { signals, values, frame, frame_ui } = xit();
|
|
9
|
+
const frame_info = async (tag, decoder2) => {
|
|
10
|
+
const { values: values2, unsub } = await frame("frame_info", tag);
|
|
11
|
+
const load2 = async (key) => {
|
|
12
|
+
const v = values2.json(key, [], {
|
|
13
|
+
decode: decoder2,
|
|
14
|
+
encode: () => {
|
|
15
|
+
return new Uint8Array();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return Promise.all(
|
|
19
|
+
get(v).map((v2) => {
|
|
20
|
+
const [frame_id, mark, g] = v2.split(":");
|
|
21
|
+
if (g !== "V") {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (mark === "T") {
|
|
25
|
+
return frame_ui(frame_id, tag);
|
|
26
|
+
} else if (mark === "U") {
|
|
27
|
+
return frame_ui(frame_id);
|
|
28
|
+
}
|
|
29
|
+
}).filter((v2) => v2 != null)
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
const [inputs, outputs] = await Promise.all([load2("inputs"), load2("outputs")]);
|
|
33
|
+
unsub();
|
|
34
|
+
return { inputs, outputs };
|
|
35
|
+
};
|
|
36
|
+
const tags = values.json("tags", [], {
|
|
37
|
+
decode: decoder,
|
|
38
|
+
encode: () => new Uint8Array()
|
|
39
|
+
});
|
|
40
|
+
const finalize = signals.string("finalize");
|
|
41
|
+
let a_inputs = $state(null);
|
|
42
|
+
let a_outputs = $state(null);
|
|
43
|
+
let title = $state("");
|
|
44
|
+
const update = (v) => {
|
|
45
|
+
a_inputs = null;
|
|
46
|
+
a_outputs = null;
|
|
47
|
+
const t = $tags;
|
|
48
|
+
if (0 <= v && v < t.length) {
|
|
49
|
+
frame_info(t[v], decoder).then(({ inputs, outputs }) => {
|
|
50
|
+
a_inputs = inputs;
|
|
51
|
+
a_outputs = outputs;
|
|
52
|
+
});
|
|
53
|
+
title = t[selected];
|
|
54
|
+
} else {
|
|
55
|
+
title = "";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
$effect(() => {
|
|
59
|
+
update(selected);
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<svelte:head>
|
|
64
|
+
<title>nil - xit {title}</title>
|
|
65
|
+
</svelte:head>
|
|
66
|
+
|
|
67
|
+
<svelte:window
|
|
68
|
+
onkeydown={(event) => {
|
|
69
|
+
if ((event.ctrlKey || event.metaKey) && event.key === "s") {
|
|
70
|
+
if (0 <= selected && selected < $tags.length) {
|
|
71
|
+
finalize($tags[selected]);
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
{@render load($tags.sort(), { inputs: a_inputs, outputs: a_outputs })}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { CoDec, Action } from "../index";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
decoder: CoDec<any>["decode"];
|
|
5
|
+
selected?: number;
|
|
6
|
+
load: Snippet<[
|
|
7
|
+
string[],
|
|
8
|
+
{
|
|
9
|
+
inputs: Action<HTMLElement>[] | null;
|
|
10
|
+
outputs: Action<HTMLElement>[] | null;
|
|
11
|
+
}
|
|
12
|
+
]>;
|
|
13
|
+
};
|
|
14
|
+
declare const Frame: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
15
|
+
type Frame = ReturnType<typeof Frame>;
|
|
16
|
+
export default Frame;
|
package/test.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CoDec } from "./index";
|
|
2
|
-
export declare const xit_test: () => {
|
|
3
|
-
xit: import("./index").Context;
|
|
4
|
-
frame_info: (tag: string, decoder: CoDec<any>["decode"]) => Promise<{
|
|
5
|
-
inputs: import("./index").Action<HTMLElement>[];
|
|
6
|
-
outputs: import("./index").Action<HTMLElement>[];
|
|
7
|
-
}>;
|
|
8
|
-
};
|
package/test.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { xit } from "./index";
|
|
2
|
-
import { get } from "svelte/store";
|
|
3
|
-
export const xit_test = () => {
|
|
4
|
-
const x = xit();
|
|
5
|
-
return {
|
|
6
|
-
xit: x,
|
|
7
|
-
frame_info: async (tag, decoder) => {
|
|
8
|
-
const { values, unsub } = await x.frame("frame_info", tag);
|
|
9
|
-
const load = async (key) => {
|
|
10
|
-
const v = values.json(key, [], { decode: decoder, encode: () => { return new Uint8Array(); } });
|
|
11
|
-
return Promise.all(get(v)
|
|
12
|
-
.map(v => {
|
|
13
|
-
const [frame_id, mark, g] = v.split(":");
|
|
14
|
-
if (g !== "V") {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (mark === "T") {
|
|
18
|
-
return x.frame_ui(frame_id, tag);
|
|
19
|
-
}
|
|
20
|
-
else if (mark === "U") {
|
|
21
|
-
return x.frame_ui(frame_id);
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
.filter(v => v != null));
|
|
25
|
-
};
|
|
26
|
-
const [inputs, outputs] = await Promise.all([load("inputs"), load("outputs")]);
|
|
27
|
-
unsub();
|
|
28
|
-
return { inputs, outputs };
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
};
|