@civet/events 4.1.3 → 4.1.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/dist/main.d.ts +1 -0
- package/dist/main.js +131 -155
- package/package.json +15 -16
package/dist/main.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export { default as eventPlugin } from './eventPlugin';
|
|
|
6
6
|
export { default as EventReceiver, isEventReceiver } from './EventReceiver';
|
|
7
7
|
export type { EventReceiverImplementation, GenericEventReceiver, InferEvent, InferOptions, InferResource, } from './EventReceiver';
|
|
8
8
|
export { default as useEventHandler } from './useEventHandler';
|
|
9
|
+
export type { EventProps } from './useEventHandler';
|
|
9
10
|
export { ConfigConsumer, useConfigContext };
|
package/dist/main.js
CHANGED
|
@@ -1,159 +1,135 @@
|
|
|
1
|
-
import { createContext as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { createContext as e, useContext as t, useEffect as n, useMemo as r, useState as i } from "react";
|
|
2
|
+
import { Notifier as a, createPlugin as o, useResourceContext as s } from "@civet/core";
|
|
3
|
+
import { Fragment as c, jsx as l } from "react/jsx-runtime";
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
5
|
+
var u = Object.create, d = Object.defineProperty, f = Object.getOwnPropertyDescriptor, p = Object.getOwnPropertyNames, m = Object.getPrototypeOf, h = Object.prototype.hasOwnProperty, g = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), _ = (e, t, n, r) => {
|
|
6
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = p(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !h.call(e, s) && s !== n && d(e, s, {
|
|
7
|
+
get: ((e) => t[e]).bind(null, s),
|
|
8
|
+
enumerable: !(r = f(t, s)) || r.enumerable
|
|
9
|
+
});
|
|
10
|
+
return e;
|
|
11
|
+
}, v = (e, t, n) => (n = e == null ? {} : u(m(e)), _(t || !e || !e.__esModule ? d(n, "default", {
|
|
12
|
+
value: e,
|
|
13
|
+
enumerable: !0
|
|
14
|
+
}) : n, e)), y = e({});
|
|
15
|
+
y.displayName = "Events.ConfigContext";
|
|
16
|
+
var b = y.Consumer, x = () => t(y);
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region lib/composeHandlers.ts
|
|
19
|
+
function S(...e) {
|
|
20
|
+
return (...t) => e.reduce((e, n) => e || (typeof n == "function" ? n(...t) : !1), !1);
|
|
12
21
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region lib/EventReceiver.ts
|
|
24
|
+
var C = class {
|
|
25
|
+
_inferEvent;
|
|
26
|
+
_inferResource;
|
|
27
|
+
_inferOptions;
|
|
28
|
+
subscribe(e, t, n) {
|
|
29
|
+
if (typeof n != "function") throw Error("Handler must be a function");
|
|
30
|
+
let r = e instanceof a ? e : new a(), i = this.handleSubscribe(r, t, n);
|
|
31
|
+
return e instanceof a || r.trigger(e), typeof i != "function" && console.warn("EventReceiver.handleSubscribe should return a callback to cancel the subscription. Ignoring this warning may result in the execution of obsolete handlers and potential memory leaks."), i;
|
|
32
|
+
}
|
|
33
|
+
}, w = (e) => e instanceof C;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region lib/ConfigProvider.tsx
|
|
36
|
+
function T({ eventReceiver: e, children: t }) {
|
|
37
|
+
let n = r(() => ({ eventReceiver: e }), [e]);
|
|
38
|
+
return /* @__PURE__ */ l(y.Provider, {
|
|
39
|
+
value: n,
|
|
40
|
+
children: t
|
|
41
|
+
});
|
|
29
42
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region lib/useEventHandler.ts
|
|
45
|
+
var E = /* @__PURE__ */ v((/* @__PURE__ */ g(((e, t) => {
|
|
46
|
+
t.exports = function e(t, n) {
|
|
47
|
+
if (t === n) return !0;
|
|
48
|
+
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
49
|
+
if (t.constructor !== n.constructor) return !1;
|
|
50
|
+
var r, i, a;
|
|
51
|
+
if (Array.isArray(t)) {
|
|
52
|
+
if (r = t.length, r != n.length) return !1;
|
|
53
|
+
for (i = r; i-- !== 0;) if (!e(t[i], n[i])) return !1;
|
|
54
|
+
return !0;
|
|
55
|
+
}
|
|
56
|
+
if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
|
|
57
|
+
if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
|
|
58
|
+
if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
|
|
59
|
+
if (a = Object.keys(t), r = a.length, r !== Object.keys(n).length) return !1;
|
|
60
|
+
for (i = r; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(n, a[i])) return !1;
|
|
61
|
+
for (i = r; i-- !== 0;) {
|
|
62
|
+
var o = a[i];
|
|
63
|
+
if (!e(t[o], n[o])) return !1;
|
|
64
|
+
}
|
|
65
|
+
return !0;
|
|
66
|
+
}
|
|
67
|
+
return t !== t && n !== n;
|
|
68
|
+
};
|
|
69
|
+
})))(), 1);
|
|
70
|
+
function D({ eventReceiver: e, resource: t, disabled: r, options: o, onEvent: c, onNotify: l }) {
|
|
71
|
+
let u = x(), d = e || u.eventReceiver, f = s(), p = t === null ? void 0 : t || f, [m, h] = i(p);
|
|
72
|
+
p?.request !== m?.request && h(p);
|
|
73
|
+
let [g, _] = i(o);
|
|
74
|
+
(0, E.default)(g, o) || _(o);
|
|
75
|
+
let v = !!(r || p?.isDisabled), [[y, b, S] = [], C] = i();
|
|
76
|
+
n(() => {
|
|
77
|
+
if (d == null || v) {
|
|
78
|
+
C(void 0);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let e = new a(), t = d.subscribe(e, g, (e) => {
|
|
82
|
+
if ((e?.length || 0) === 0) return;
|
|
83
|
+
let t;
|
|
84
|
+
if (t = typeof c == "function" ? e.filter((e) => !c(e)) : e, t.length === 0 || typeof m?.notify != "function") return;
|
|
85
|
+
let n = m.notify();
|
|
86
|
+
typeof l == "function" && n.then((e) => l(e, t));
|
|
87
|
+
});
|
|
88
|
+
return e.trigger(m), C([
|
|
89
|
+
m?.request,
|
|
90
|
+
m?.revision,
|
|
91
|
+
e
|
|
92
|
+
]), t;
|
|
93
|
+
}, [
|
|
94
|
+
d,
|
|
95
|
+
v,
|
|
96
|
+
m,
|
|
97
|
+
g,
|
|
98
|
+
c,
|
|
99
|
+
l
|
|
100
|
+
]), n(() => {
|
|
101
|
+
S == null || p?.request !== y || p?.revision === b || S.trigger(p);
|
|
102
|
+
}, [
|
|
103
|
+
S,
|
|
104
|
+
p,
|
|
105
|
+
y,
|
|
106
|
+
b
|
|
107
|
+
]);
|
|
37
108
|
}
|
|
38
|
-
|
|
39
|
-
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region lib/EventHandler.tsx
|
|
111
|
+
function O({ eventReceiver: e, resource: t, disabled: n, options: r, onEvent: i, onNotify: a, children: o }) {
|
|
112
|
+
return D({
|
|
113
|
+
eventReceiver: e,
|
|
114
|
+
resource: t,
|
|
115
|
+
disabled: n,
|
|
116
|
+
options: r,
|
|
117
|
+
onEvent: i,
|
|
118
|
+
onNotify: a
|
|
119
|
+
}), /* @__PURE__ */ l(c, { children: o });
|
|
40
120
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
|
|
57
|
-
if (s = Object.keys(e), r = s.length, r !== Object.keys(t).length) return !1;
|
|
58
|
-
for (n = r; n-- !== 0; )
|
|
59
|
-
if (!Object.prototype.hasOwnProperty.call(t, s[n])) return !1;
|
|
60
|
-
for (n = r; n-- !== 0; ) {
|
|
61
|
-
var c = s[n];
|
|
62
|
-
if (!o(e[c], t[c])) return !1;
|
|
63
|
-
}
|
|
64
|
-
return !0;
|
|
65
|
-
}
|
|
66
|
-
return e !== e && t !== t;
|
|
67
|
-
}), C;
|
|
68
|
-
}
|
|
69
|
-
var K = J();
|
|
70
|
-
const L = /* @__PURE__ */ G(K);
|
|
71
|
-
function w({
|
|
72
|
-
eventReceiver: o,
|
|
73
|
-
resource: e,
|
|
74
|
-
disabled: t,
|
|
75
|
-
options: r,
|
|
76
|
-
onEvent: n,
|
|
77
|
-
onNotify: s
|
|
78
|
-
}) {
|
|
79
|
-
const c = k(), p = o || c.eventReceiver, D = B(), u = e === null ? void 0 : e || D, [i, S] = E(
|
|
80
|
-
u
|
|
81
|
-
);
|
|
82
|
-
u?.request !== i?.request && S(u);
|
|
83
|
-
const [v, _] = E(r);
|
|
84
|
-
L(v, r) || _(r);
|
|
85
|
-
const R = !!(t || u?.isDisabled), [
|
|
86
|
-
[b, O, d] = [],
|
|
87
|
-
q
|
|
88
|
-
] = E();
|
|
89
|
-
h(() => {
|
|
90
|
-
if (p == null || R) {
|
|
91
|
-
q(void 0);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const g = new l(), F = p.subscribe(
|
|
95
|
-
g,
|
|
96
|
-
v,
|
|
97
|
-
(m) => {
|
|
98
|
-
if ((m?.length || 0) === 0) return;
|
|
99
|
-
let f;
|
|
100
|
-
if (typeof n == "function" ? f = m.filter((y) => !n(y)) : f = m, f.length === 0 || typeof i?.notify != "function")
|
|
101
|
-
return;
|
|
102
|
-
const H = i.notify();
|
|
103
|
-
typeof s == "function" && H.then((y) => s(y, f));
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
return g.trigger(i), q([
|
|
107
|
-
i?.request,
|
|
108
|
-
i?.revision,
|
|
109
|
-
g
|
|
110
|
-
]), F;
|
|
111
|
-
}, [p, R, i, v, n, s]), h(() => {
|
|
112
|
-
d == null || u?.request !== b || u?.revision === O || d.trigger(u);
|
|
113
|
-
}, [
|
|
114
|
-
d,
|
|
115
|
-
u,
|
|
116
|
-
b,
|
|
117
|
-
O
|
|
118
|
-
]);
|
|
119
|
-
}
|
|
120
|
-
function Z({
|
|
121
|
-
eventReceiver: o,
|
|
122
|
-
resource: e,
|
|
123
|
-
disabled: t,
|
|
124
|
-
options: r,
|
|
125
|
-
onEvent: n,
|
|
126
|
-
onNotify: s,
|
|
127
|
-
children: c
|
|
128
|
-
}) {
|
|
129
|
-
return w({
|
|
130
|
-
eventReceiver: o,
|
|
131
|
-
resource: e,
|
|
132
|
-
disabled: t,
|
|
133
|
-
options: r,
|
|
134
|
-
onEvent: n,
|
|
135
|
-
onNotify: s
|
|
136
|
-
}), /* @__PURE__ */ j(M, { children: c });
|
|
137
|
-
}
|
|
138
|
-
const $ = I(
|
|
139
|
-
(o) => class extends o {
|
|
140
|
-
extend(t) {
|
|
141
|
-
super.extend(t), t.context(
|
|
142
|
-
(r, { events: n = !1 }) => (w(
|
|
143
|
-
typeof n == "boolean" ? { disabled: !n, resource: r } : { ...n, resource: r }
|
|
144
|
-
), r)
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
export {
|
|
150
|
-
V as ConfigConsumer,
|
|
151
|
-
Y as ConfigProvider,
|
|
152
|
-
Z as EventHandler,
|
|
153
|
-
z as EventReceiver,
|
|
154
|
-
W as composeHandlers,
|
|
155
|
-
$ as eventPlugin,
|
|
156
|
-
X as isEventReceiver,
|
|
157
|
-
k as useConfigContext,
|
|
158
|
-
w as useEventHandler
|
|
159
|
-
};
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region lib/eventPlugin.ts
|
|
123
|
+
var k = o((e) => class extends e {
|
|
124
|
+
extend(e) {
|
|
125
|
+
super.extend(e), e.context((e, { events: t = !1 }) => (D(typeof t == "boolean" ? {
|
|
126
|
+
disabled: !t,
|
|
127
|
+
resource: e
|
|
128
|
+
} : {
|
|
129
|
+
...t,
|
|
130
|
+
resource: e
|
|
131
|
+
}), e));
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
//#endregion
|
|
135
|
+
export { b as ConfigConsumer, T as ConfigProvider, O as EventHandler, C as EventReceiver, S as composeHandlers, k as eventPlugin, w as isEventReceiver, x as useConfigContext, D as useEventHandler };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@civet/events",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.5",
|
|
4
4
|
"description": "Civet",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aaron Burmeister"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"fast-deep-equal": "^3.1.3",
|
|
49
49
|
"object-hash": "^3.0.0",
|
|
50
|
-
"uuid": "^
|
|
50
|
+
"uuid": "^14.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@civet/core": ">=6.0",
|
|
@@ -55,28 +55,27 @@
|
|
|
55
55
|
"react-dom": ">=18.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@civet/core": "^6.2.
|
|
59
|
-
"@eslint/js": "^9.39.
|
|
58
|
+
"@civet/core": "^6.2.6",
|
|
59
|
+
"@eslint/js": "^9.39.4",
|
|
60
60
|
"@types/react": "^19.1.12",
|
|
61
61
|
"@types/react-dom": "^19.1.9",
|
|
62
|
-
"@vitejs/plugin-react": "^
|
|
63
|
-
"eslint": "^9.39.
|
|
62
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
63
|
+
"eslint": "^9.39.4",
|
|
64
64
|
"eslint-config-prettier": "^10.1.8",
|
|
65
65
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
66
66
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
67
67
|
"eslint-plugin-import": "^2.32.0",
|
|
68
68
|
"eslint-plugin-prettier": "^5.5.4",
|
|
69
|
-
"eslint-plugin-react-hooks": "^7.
|
|
69
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
70
70
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
71
71
|
"eslint-plugin-unused-imports": "^4.2.0",
|
|
72
|
-
"globals": "^17.
|
|
73
|
-
"prettier": "^3.
|
|
74
|
-
"react": "^19.
|
|
75
|
-
"react-dom": "^19.
|
|
76
|
-
"typescript": "^
|
|
77
|
-
"typescript-eslint": "^8.
|
|
78
|
-
"vite": "^
|
|
79
|
-
"vite-plugin-dts": "^4.5.4"
|
|
80
|
-
"vite-tsconfig-paths": "^6.1.1"
|
|
72
|
+
"globals": "^17.5.0",
|
|
73
|
+
"prettier": "^3.8.3",
|
|
74
|
+
"react": "^19.2.5",
|
|
75
|
+
"react-dom": "^19.2.5",
|
|
76
|
+
"typescript": "^6.0.3",
|
|
77
|
+
"typescript-eslint": "^8.59.0",
|
|
78
|
+
"vite": "^8.0.9",
|
|
79
|
+
"vite-plugin-dts": "^4.5.4"
|
|
81
80
|
}
|
|
82
81
|
}
|