claude-mux 0.7.0 → 0.7.1
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/README.md +4 -2
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/web/client/_app/immutable/chunks/{DU91Ml7U.js → BGcEgn7w.js} +1 -1
- package/{web/.svelte-kit/output/client/_app/immutable/chunks/DmdO6ygw.js → dist/web/client/_app/immutable/chunks/By6CYjmE.js} +1 -1
- package/dist/web/client/_app/immutable/chunks/{HKNo9LID.js → CR5jMWGV.js} +1 -1
- package/{web/.svelte-kit/output/client/_app/immutable/entry/app.CGIBnoln.js → dist/web/client/_app/immutable/entry/app.DmtnygN7.js} +2 -2
- package/dist/web/client/_app/immutable/entry/start.fYmelGlC.js +1 -0
- package/dist/web/client/_app/immutable/nodes/{0.CqlJ9a31.js → 0.DGDAdwT5.js} +1 -1
- package/dist/web/client/_app/immutable/nodes/{1.BQUZh2-w.js → 1.Cg8dWgUN.js} +1 -1
- package/dist/web/client/_app/immutable/nodes/{2.CCV1YdgF.js → 2.DItUEo3e.js} +1 -1
- package/dist/web/client/_app/immutable/nodes/{3.D9tDCdq8.js → 3.dHui0twF.js} +1 -1
- package/dist/web/client/_app/immutable/nodes/{4.BqPyNkFA.js → 4.CiEHP0cr.js} +1 -1
- package/dist/web/client/_app/version.json +1 -1
- package/dist/web/server/chunks/{0-BHWsmCJv.js → 0-BmRg-l2z.js} +5 -5
- package/dist/web/server/chunks/{0-BHWsmCJv.js.map → 0-BmRg-l2z.js.map} +1 -1
- package/dist/web/server/chunks/{1-YRx6A8Tm.js → 1-CPgO8U7d.js} +3 -3
- package/dist/web/server/chunks/{1-YRx6A8Tm.js.map → 1-CPgO8U7d.js.map} +1 -1
- package/dist/web/server/chunks/{2-eC6JuGAo.js → 2--ZO5fZp_.js} +5 -5
- package/dist/web/server/chunks/{2-eC6JuGAo.js.map → 2--ZO5fZp_.js.map} +1 -1
- package/dist/web/server/chunks/{3-Bk-wV20p.js → 3-7HqSep9c.js} +3 -3
- package/dist/web/server/chunks/{3-Bk-wV20p.js.map → 3-7HqSep9c.js.map} +1 -1
- package/dist/web/server/chunks/{4-nteBgDrW.js → 4-C1PCdmY0.js} +4 -4
- package/dist/web/server/chunks/{4-nteBgDrW.js.map → 4-C1PCdmY0.js.map} +1 -1
- package/dist/web/server/index.js +1 -1
- package/dist/web/server/index.js.map +1 -1
- package/dist/web/server/manifest.js +10 -10
- package/dist/web/server/manifest.js.map +1 -1
- package/docs/release-checklist.md +8 -34
- package/docs/removing-hooks.md +14 -14
- package/package.json +1 -1
- package/src/cli.ts +1 -1
- package/src/utils/version.ts +1 -1
- package/web/.svelte-kit/adapter-bun/chunks/internal.js +1 -1
- package/web/.svelte-kit/adapter-bun/manifest-full.js +1 -1
- package/web/.svelte-kit/adapter-bun/manifest.js +1 -1
- package/web/.svelte-kit/adapter-bun/nodes/0.js +1 -1
- package/web/.svelte-kit/adapter-bun/nodes/1.js +1 -1
- package/web/.svelte-kit/adapter-bun/nodes/2.js +1 -1
- package/web/.svelte-kit/adapter-bun/nodes/3.js +1 -1
- package/web/.svelte-kit/adapter-bun/nodes/4.js +1 -1
- package/web/.svelte-kit/adapter-node/.vite/manifest.json +200 -15
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/AllSessionsPanel.BKhqOrbV.css +1 -0
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_layout.WptSHSUl.css +1 -0
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_page.DldLgTc-.css +1 -0
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_page.DoNWy7tW.css +1 -0
- package/web/.svelte-kit/adapter-node/chunks/AllSessionsPanel.svelte_svelte_type_style_lang.js +49 -0
- package/web/.svelte-kit/adapter-node/chunks/alert-dialog-description.js +2670 -0
- package/web/.svelte-kit/adapter-node/chunks/auth.js +59 -0
- package/web/.svelte-kit/adapter-node/chunks/button.js +82 -0
- package/web/.svelte-kit/adapter-node/chunks/client.js +29 -0
- package/web/.svelte-kit/adapter-node/chunks/context.js +28 -16
- package/web/.svelte-kit/adapter-node/chunks/events.js +121 -0
- package/web/.svelte-kit/adapter-node/chunks/index.js +1 -1
- package/web/.svelte-kit/adapter-node/chunks/index2.js +186 -68
- package/web/.svelte-kit/adapter-node/chunks/internal.js +5 -90
- package/web/.svelte-kit/adapter-node/chunks/pane.js +82 -0
- package/web/.svelte-kit/adapter-node/chunks/sessions-json.js +16 -1
- package/web/.svelte-kit/adapter-node/chunks/sessions.svelte.js +174 -12
- package/web/.svelte-kit/adapter-node/chunks/ws-handlers.js +782 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/auth/login/_server.ts.js +22 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/auth/logout/_server.ts.js +9 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/beads/_server.ts.js +22 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/chrome/_server.ts.js +30 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/files/image/_server.ts.js +53 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/kill/_server.ts.js +12 -6
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/restart/_server.ts.js +40 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/screenshots/_server.ts.js +28 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/send/_server.ts.js +11 -4
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_server.ts.js +1 -78
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_target_/output/_server.ts.js +2 -2
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/tmux/panes/_server.ts.js +21 -0
- package/web/.svelte-kit/adapter-node/entries/fallbacks/error.svelte.js +1 -18
- package/web/.svelte-kit/adapter-node/entries/hooks.server.js +105 -0
- package/web/.svelte-kit/adapter-node/entries/pages/_layout.svelte.js +493 -6
- package/web/.svelte-kit/adapter-node/entries/pages/_page.svelte.js +3024 -54
- package/web/.svelte-kit/adapter-node/entries/pages/login/_page.server.ts.js +15 -0
- package/web/.svelte-kit/adapter-node/entries/pages/login/_page.svelte.js +37 -0
- package/web/.svelte-kit/adapter-node/entries/pages/session/_target_/_page.svelte.js +623 -46
- package/web/.svelte-kit/adapter-node/manifest-full.js +67 -3
- package/web/.svelte-kit/adapter-node/manifest.js +67 -3
- package/web/.svelte-kit/adapter-node/nodes/0.js +2 -2
- package/web/.svelte-kit/adapter-node/nodes/1.js +1 -1
- package/web/.svelte-kit/adapter-node/nodes/2.js +2 -2
- package/web/.svelte-kit/adapter-node/nodes/3.js +6 -4
- package/web/.svelte-kit/adapter-node/nodes/4.js +8 -0
- package/web/.svelte-kit/ambient.d.ts +28 -2
- package/web/.svelte-kit/generated/server/internal.js +1 -1
- package/web/.svelte-kit/output/client/.vite/manifest.json +44 -44
- package/web/.svelte-kit/output/client/_app/immutable/chunks/{DU91Ml7U.js → BGcEgn7w.js} +1 -1
- package/{dist/web/client/_app/immutable/chunks/DmdO6ygw.js → web/.svelte-kit/output/client/_app/immutable/chunks/By6CYjmE.js} +1 -1
- package/web/.svelte-kit/output/client/_app/immutable/chunks/{HKNo9LID.js → CR5jMWGV.js} +1 -1
- package/{dist/web/client/_app/immutable/entry/app.CGIBnoln.js → web/.svelte-kit/output/client/_app/immutable/entry/app.DmtnygN7.js} +2 -2
- package/web/.svelte-kit/output/client/_app/immutable/entry/start.fYmelGlC.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/{0.CqlJ9a31.js → 0.DGDAdwT5.js} +1 -1
- package/web/.svelte-kit/output/client/_app/immutable/nodes/{1.BQUZh2-w.js → 1.Cg8dWgUN.js} +1 -1
- package/web/.svelte-kit/output/client/_app/immutable/nodes/{2.CCV1YdgF.js → 2.DItUEo3e.js} +1 -1
- package/web/.svelte-kit/output/client/_app/immutable/nodes/{3.D9tDCdq8.js → 3.dHui0twF.js} +1 -1
- package/web/.svelte-kit/output/client/_app/immutable/nodes/{4.BqPyNkFA.js → 4.CiEHP0cr.js} +1 -1
- package/web/.svelte-kit/output/client/_app/version.json +1 -1
- package/web/.svelte-kit/output/server/chunks/internal.js +1 -1
- package/web/.svelte-kit/output/server/manifest-full.js +1 -1
- package/web/.svelte-kit/output/server/manifest.js +1 -1
- package/web/.svelte-kit/output/server/nodes/0.js +1 -1
- package/web/.svelte-kit/output/server/nodes/1.js +1 -1
- package/web/.svelte-kit/output/server/nodes/2.js +1 -1
- package/web/.svelte-kit/output/server/nodes/3.js +1 -1
- package/web/.svelte-kit/output/server/nodes/4.js +1 -1
- package/dist/web/client/_app/immutable/entry/start.CJk8zB1j.js +0 -1
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_layout.4NiX29PU.css +0 -1
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_page.BEMzYUGV.css +0 -1
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_page.DOJn7TG7.css +0 -1
- package/web/.svelte-kit/output/client/_app/immutable/entry/start.CJk8zB1j.js +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createHmac } from "crypto";
|
|
2
|
+
const COOKIE_NAME = "claude-mux-session";
|
|
3
|
+
const MAX_AGE = 60 * 60 * 24 * 7;
|
|
4
|
+
function isAuthEnabled() {
|
|
5
|
+
return !!process.env.CLAUDE_WATCH_PASSWORD;
|
|
6
|
+
}
|
|
7
|
+
function getPassword() {
|
|
8
|
+
return process.env.CLAUDE_WATCH_PASSWORD || "";
|
|
9
|
+
}
|
|
10
|
+
function validatePassword(password) {
|
|
11
|
+
const expected = getPassword();
|
|
12
|
+
if (!expected) return false;
|
|
13
|
+
if (password.length !== expected.length) return false;
|
|
14
|
+
let result = 0;
|
|
15
|
+
for (let i = 0; i < password.length; i++) {
|
|
16
|
+
result |= password.charCodeAt(i) ^ expected.charCodeAt(i);
|
|
17
|
+
}
|
|
18
|
+
return result === 0;
|
|
19
|
+
}
|
|
20
|
+
function createAuthToken() {
|
|
21
|
+
const timestamp = Date.now().toString();
|
|
22
|
+
const signature = createHmac("sha256", getPassword()).update(timestamp).digest("hex");
|
|
23
|
+
return `${timestamp}:${signature}`;
|
|
24
|
+
}
|
|
25
|
+
function validateAuthToken(token) {
|
|
26
|
+
if (!token || !isAuthEnabled()) return false;
|
|
27
|
+
const parts = token.split(":");
|
|
28
|
+
if (parts.length !== 2) return false;
|
|
29
|
+
const [timestamp, signature] = parts;
|
|
30
|
+
const tokenAge = Date.now() - parseInt(timestamp, 10);
|
|
31
|
+
if (isNaN(tokenAge) || tokenAge > MAX_AGE * 1e3 || tokenAge < 0) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const expectedSignature = createHmac("sha256", getPassword()).update(timestamp).digest("hex");
|
|
35
|
+
if (signature.length !== expectedSignature.length) return false;
|
|
36
|
+
let result = 0;
|
|
37
|
+
for (let i = 0; i < signature.length; i++) {
|
|
38
|
+
result |= signature.charCodeAt(i) ^ expectedSignature.charCodeAt(i);
|
|
39
|
+
}
|
|
40
|
+
return result === 0;
|
|
41
|
+
}
|
|
42
|
+
const AUTH_COOKIE = {
|
|
43
|
+
name: COOKIE_NAME,
|
|
44
|
+
maxAge: MAX_AGE,
|
|
45
|
+
options: (isSecure) => ({
|
|
46
|
+
httpOnly: true,
|
|
47
|
+
sameSite: "lax",
|
|
48
|
+
path: "/",
|
|
49
|
+
maxAge: MAX_AGE,
|
|
50
|
+
secure: isSecure
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
AUTH_COOKIE as A,
|
|
55
|
+
validateAuthToken as a,
|
|
56
|
+
createAuthToken as c,
|
|
57
|
+
isAuthEnabled as i,
|
|
58
|
+
validatePassword as v
|
|
59
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { a6 as attributes, aa as clsx$1, a7 as bind_props } from "./index2.js";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
import { tv } from "tailwind-variants";
|
|
5
|
+
function cn(...inputs) {
|
|
6
|
+
return twMerge(clsx(inputs));
|
|
7
|
+
}
|
|
8
|
+
const buttonVariants = tv({
|
|
9
|
+
base: "cursor-pointer focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90 shadow-xs",
|
|
13
|
+
destructive: "bg-destructive hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60 text-white shadow-xs",
|
|
14
|
+
outline: "bg-background hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border shadow-xs",
|
|
15
|
+
secondary: "bg-[#222] text-stone-100 hover:bg-[#333] shadow-xs",
|
|
16
|
+
ghost: "text-stone-400 hover:bg-[#222] hover:text-stone-100",
|
|
17
|
+
"ghost-destructive": "bg-red-900 text-red-300 hover:bg-red-800 hover:text-white",
|
|
18
|
+
warning: "bg-amber-700 text-amber-100 hover:bg-amber-600 shadow-xs",
|
|
19
|
+
success: "bg-emerald-600 text-white hover:bg-emerald-500 active:bg-emerald-700 shadow-xs",
|
|
20
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
24
|
+
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
|
|
25
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
26
|
+
icon: "size-9",
|
|
27
|
+
"icon-sm": "size-8",
|
|
28
|
+
"icon-lg": "size-10",
|
|
29
|
+
toolbar: "flex-col gap-0.5 px-2 py-1.5 min-w-11 h-auto [&_svg]:size-[18px] text-[9px] uppercase tracking-wide"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: { variant: "default", size: "default" }
|
|
33
|
+
});
|
|
34
|
+
function Button($$renderer, $$props) {
|
|
35
|
+
$$renderer.component(($$renderer2) => {
|
|
36
|
+
let {
|
|
37
|
+
class: className,
|
|
38
|
+
variant = "default",
|
|
39
|
+
size = "default",
|
|
40
|
+
ref = null,
|
|
41
|
+
href = void 0,
|
|
42
|
+
type = "button",
|
|
43
|
+
disabled,
|
|
44
|
+
children,
|
|
45
|
+
$$slots,
|
|
46
|
+
$$events,
|
|
47
|
+
...restProps
|
|
48
|
+
} = $$props;
|
|
49
|
+
if (href) {
|
|
50
|
+
$$renderer2.push("<!--[-->");
|
|
51
|
+
$$renderer2.push(`<a${attributes({
|
|
52
|
+
"data-slot": "button",
|
|
53
|
+
class: clsx$1(cn(buttonVariants({ variant, size }), className)),
|
|
54
|
+
href: disabled ? void 0 : href,
|
|
55
|
+
"aria-disabled": disabled,
|
|
56
|
+
role: disabled ? "link" : void 0,
|
|
57
|
+
tabindex: disabled ? -1 : void 0,
|
|
58
|
+
...restProps
|
|
59
|
+
})}>`);
|
|
60
|
+
children?.($$renderer2);
|
|
61
|
+
$$renderer2.push(`<!----></a>`);
|
|
62
|
+
} else {
|
|
63
|
+
$$renderer2.push("<!--[!-->");
|
|
64
|
+
$$renderer2.push(`<button${attributes({
|
|
65
|
+
"data-slot": "button",
|
|
66
|
+
class: clsx$1(cn(buttonVariants({ variant, size }), className)),
|
|
67
|
+
type,
|
|
68
|
+
disabled,
|
|
69
|
+
...restProps
|
|
70
|
+
})}>`);
|
|
71
|
+
children?.($$renderer2);
|
|
72
|
+
$$renderer2.push(`<!----></button>`);
|
|
73
|
+
}
|
|
74
|
+
$$renderer2.push(`<!--]-->`);
|
|
75
|
+
bind_props($$props, { ref });
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
Button as B,
|
|
80
|
+
buttonVariants as b,
|
|
81
|
+
cn as c
|
|
82
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "clsx";
|
|
2
|
+
import "@sveltejs/kit/internal";
|
|
3
|
+
import "./exports.js";
|
|
4
|
+
import "./utils.js";
|
|
5
|
+
import { w as writable } from "./index.js";
|
|
6
|
+
import "@sveltejs/kit/internal/server";
|
|
7
|
+
import "./state.svelte.js";
|
|
8
|
+
function create_updated_store() {
|
|
9
|
+
const { set, subscribe } = writable(false);
|
|
10
|
+
{
|
|
11
|
+
return {
|
|
12
|
+
subscribe,
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
14
|
+
check: async () => false
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const stores = {
|
|
19
|
+
updated: /* @__PURE__ */ create_updated_store()
|
|
20
|
+
};
|
|
21
|
+
function goto(url, opts = {}) {
|
|
22
|
+
{
|
|
23
|
+
throw new Error("Cannot call goto(...) on the server");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
goto as g,
|
|
28
|
+
stores as s
|
|
29
|
+
};
|
|
@@ -10,6 +10,9 @@ var get_prototype_of = Object.getPrototypeOf;
|
|
|
10
10
|
var is_extensible = Object.isExtensible;
|
|
11
11
|
const noop = () => {
|
|
12
12
|
};
|
|
13
|
+
function run(fn) {
|
|
14
|
+
return fn();
|
|
15
|
+
}
|
|
13
16
|
function run_all(arr) {
|
|
14
17
|
for (var i = 0; i < arr.length; i++) {
|
|
15
18
|
arr[i]();
|
|
@@ -70,6 +73,12 @@ function setContext(key, context) {
|
|
|
70
73
|
get_or_init_context_map().set(key, context);
|
|
71
74
|
return context;
|
|
72
75
|
}
|
|
76
|
+
function hasContext(key) {
|
|
77
|
+
return get_or_init_context_map().has(key);
|
|
78
|
+
}
|
|
79
|
+
function getAllContexts() {
|
|
80
|
+
return get_or_init_context_map();
|
|
81
|
+
}
|
|
73
82
|
function get_or_init_context_map(name) {
|
|
74
83
|
if (ssr_context === null) {
|
|
75
84
|
lifecycle_outside_component();
|
|
@@ -96,26 +105,29 @@ function get_parent_context(ssr_context2) {
|
|
|
96
105
|
}
|
|
97
106
|
export {
|
|
98
107
|
array_from as a,
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
get_prototype_of as b,
|
|
109
|
+
getAllContexts as c,
|
|
101
110
|
define_property as d,
|
|
102
111
|
escape_html as e,
|
|
103
|
-
|
|
112
|
+
ssr_context as f,
|
|
104
113
|
getContext as g,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
hasContext as h,
|
|
115
|
+
is_array as i,
|
|
116
|
+
safe_not_equal as j,
|
|
117
|
+
run_all as k,
|
|
118
|
+
deferred as l,
|
|
119
|
+
includes as m,
|
|
111
120
|
noop as n,
|
|
112
121
|
object_prototype as o,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
safe_equals as p,
|
|
123
|
+
equals as q,
|
|
124
|
+
run as r,
|
|
116
125
|
setContext as s,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
126
|
+
array_prototype as t,
|
|
127
|
+
get_descriptor as u,
|
|
128
|
+
is_extensible as v,
|
|
129
|
+
index_of as w,
|
|
130
|
+
set_ssr_context as x,
|
|
131
|
+
push as y,
|
|
132
|
+
pop as z
|
|
121
133
|
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { n as set_active_reaction, m as set_active_effect, f as active_effect, v as active_reaction, q as queue_micro_task, ad as without_reactive_context } from "./index2.js";
|
|
2
|
+
import { d as define_property } from "./context.js";
|
|
3
|
+
const all_registered_events = /* @__PURE__ */ new Set();
|
|
4
|
+
const root_event_handles = /* @__PURE__ */ new Set();
|
|
5
|
+
function create_event(event_name, dom, handler, options = {}) {
|
|
6
|
+
function target_handler(event) {
|
|
7
|
+
if (!options.capture) {
|
|
8
|
+
handle_event_propagation.call(dom, event);
|
|
9
|
+
}
|
|
10
|
+
if (!event.cancelBubble) {
|
|
11
|
+
return without_reactive_context(() => {
|
|
12
|
+
return handler?.call(this, event);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (event_name.startsWith("pointer") || event_name.startsWith("touch") || event_name === "wheel") {
|
|
17
|
+
queue_micro_task(() => {
|
|
18
|
+
dom.addEventListener(event_name, target_handler, options);
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
dom.addEventListener(event_name, target_handler, options);
|
|
22
|
+
}
|
|
23
|
+
return target_handler;
|
|
24
|
+
}
|
|
25
|
+
function on(element, type, handler, options = {}) {
|
|
26
|
+
var target_handler = create_event(type, element, handler, options);
|
|
27
|
+
return () => {
|
|
28
|
+
element.removeEventListener(type, target_handler, options);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
let last_propagated_event = null;
|
|
32
|
+
function handle_event_propagation(event) {
|
|
33
|
+
var handler_element = this;
|
|
34
|
+
var owner_document = (
|
|
35
|
+
/** @type {Node} */
|
|
36
|
+
handler_element.ownerDocument
|
|
37
|
+
);
|
|
38
|
+
var event_name = event.type;
|
|
39
|
+
var path = event.composedPath?.() || [];
|
|
40
|
+
var current_target = (
|
|
41
|
+
/** @type {null | Element} */
|
|
42
|
+
path[0] || event.target
|
|
43
|
+
);
|
|
44
|
+
last_propagated_event = event;
|
|
45
|
+
var path_idx = 0;
|
|
46
|
+
var handled_at = last_propagated_event === event && event.__root;
|
|
47
|
+
if (handled_at) {
|
|
48
|
+
var at_idx = path.indexOf(handled_at);
|
|
49
|
+
if (at_idx !== -1 && (handler_element === document || handler_element === /** @type {any} */
|
|
50
|
+
window)) {
|
|
51
|
+
event.__root = handler_element;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
var handler_idx = path.indexOf(handler_element);
|
|
55
|
+
if (handler_idx === -1) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (at_idx <= handler_idx) {
|
|
59
|
+
path_idx = at_idx;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
current_target = /** @type {Element} */
|
|
63
|
+
path[path_idx] || event.target;
|
|
64
|
+
if (current_target === handler_element) return;
|
|
65
|
+
define_property(event, "currentTarget", {
|
|
66
|
+
configurable: true,
|
|
67
|
+
get() {
|
|
68
|
+
return current_target || owner_document;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
var previous_reaction = active_reaction;
|
|
72
|
+
var previous_effect = active_effect;
|
|
73
|
+
set_active_reaction(null);
|
|
74
|
+
set_active_effect(null);
|
|
75
|
+
try {
|
|
76
|
+
var throw_error;
|
|
77
|
+
var other_errors = [];
|
|
78
|
+
while (current_target !== null) {
|
|
79
|
+
var parent_element = current_target.assignedSlot || current_target.parentNode || /** @type {any} */
|
|
80
|
+
current_target.host || null;
|
|
81
|
+
try {
|
|
82
|
+
var delegated = current_target["__" + event_name];
|
|
83
|
+
if (delegated != null && (!/** @type {any} */
|
|
84
|
+
current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
|
|
85
|
+
// -> the target could not have been disabled because it emits the event in the first place
|
|
86
|
+
event.target === current_target)) {
|
|
87
|
+
delegated.call(current_target, event);
|
|
88
|
+
}
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (throw_error) {
|
|
91
|
+
other_errors.push(error);
|
|
92
|
+
} else {
|
|
93
|
+
throw_error = error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (event.cancelBubble || parent_element === handler_element || parent_element === null) {
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
current_target = parent_element;
|
|
100
|
+
}
|
|
101
|
+
if (throw_error) {
|
|
102
|
+
for (let error of other_errors) {
|
|
103
|
+
queueMicrotask(() => {
|
|
104
|
+
throw error;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
throw throw_error;
|
|
108
|
+
}
|
|
109
|
+
} finally {
|
|
110
|
+
event.__root = handler_element;
|
|
111
|
+
delete event.currentTarget;
|
|
112
|
+
set_active_reaction(previous_reaction);
|
|
113
|
+
set_active_effect(previous_effect);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
all_registered_events as a,
|
|
118
|
+
handle_event_propagation as h,
|
|
119
|
+
on as o,
|
|
120
|
+
root_event_handles as r
|
|
121
|
+
};
|