@xlsft/grammy-reactive 0.7.34
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/LICENSE +7 -0
- package/dist/jsx/index.d.ts +3 -0
- package/dist/jsx/index.d.ts.map +1 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx/jsx-dev-runtime.js +2 -0
- package/dist/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx/jsx-runtime.d.ts +2 -0
- package/dist/jsx/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx/jsx-runtime.js +2 -0
- package/dist/jsx/jsx-runtime.js.map +1 -0
- package/dist/jsx/runtime/jsx.d.ts +10 -0
- package/dist/jsx/runtime/jsx.d.ts.map +1 -0
- package/dist/jsx/runtime/jsx.errors.d.ts +4 -0
- package/dist/jsx/runtime/jsx.errors.d.ts.map +1 -0
- package/dist/jsx/runtime/jsx.errors.js +7 -0
- package/dist/jsx/runtime/jsx.errors.js.map +1 -0
- package/dist/jsx/runtime/jsx.js +209 -0
- package/dist/jsx/runtime/jsx.js.map +1 -0
- package/dist/jsx/runtime/jsx.runtime.d.ts +18 -0
- package/dist/jsx/runtime/jsx.runtime.d.ts.map +1 -0
- package/dist/jsx/runtime/jsx.runtime.js +3 -0
- package/dist/jsx/runtime/jsx.runtime.js.map +1 -0
- package/dist/lib/helpers/context.helper.d.ts +3 -0
- package/dist/lib/helpers/context.helper.d.ts.map +1 -0
- package/dist/lib/helpers/index.d.ts +2 -0
- package/dist/lib/helpers/index.d.ts.map +1 -0
- package/dist/lib/index.d.ts +12 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +45 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/jsx-runtime.d.ts +2 -0
- package/dist/lib/jsx-runtime.d.ts.map +1 -0
- package/dist/lib/plugin/index.d.ts +4 -0
- package/dist/lib/plugin/index.d.ts.map +1 -0
- package/dist/lib/plugin/index.js +40 -0
- package/dist/lib/plugin/index.js.map +1 -0
- package/dist/lib/render/components/Error.d.ts +26 -0
- package/dist/lib/render/components/Error.d.ts.map +1 -0
- package/dist/lib/render/components/Error.js +25 -0
- package/dist/lib/render/components/Error.js.map +1 -0
- package/dist/lib/render/message.render.d.ts +40 -0
- package/dist/lib/render/message.render.d.ts.map +1 -0
- package/dist/lib/render/message.render.js +60 -0
- package/dist/lib/render/message.render.js.map +1 -0
- package/dist/lib/render/node/fragmemt.render.d.ts +34 -0
- package/dist/lib/render/node/fragmemt.render.d.ts.map +1 -0
- package/dist/lib/render/node/fragmemt.render.js +56 -0
- package/dist/lib/render/node/fragmemt.render.js.map +1 -0
- package/dist/lib/render/node/intrinsic.render.d.ts +37 -0
- package/dist/lib/render/node/intrinsic.render.d.ts.map +1 -0
- package/dist/lib/render/node/intrinsic.render.js +167 -0
- package/dist/lib/render/node/intrinsic.render.js.map +1 -0
- package/dist/lib/render/node/plain.render.d.ts +27 -0
- package/dist/lib/render/node/plain.render.d.ts.map +1 -0
- package/dist/lib/render/node/plain.render.js +32 -0
- package/dist/lib/render/node/plain.render.js.map +1 -0
- package/dist/lib/render/tag.render.d.ts +24 -0
- package/dist/lib/render/tag.render.d.ts.map +1 -0
- package/dist/lib/render/tag.render.js +27 -0
- package/dist/lib/render/tag.render.js.map +1 -0
- package/dist/lib/state/create.state.d.ts +8 -0
- package/dist/lib/state/create.state.d.ts.map +1 -0
- package/dist/lib/state/create.state.js +61 -0
- package/dist/lib/state/create.state.js.map +1 -0
- package/dist/lib/state/events/onclick.event.d.ts +21 -0
- package/dist/lib/state/events/onclick.event.d.ts.map +1 -0
- package/dist/lib/state/events/onclick.event.js +36 -0
- package/dist/lib/state/events/onclick.event.js.map +1 -0
- package/dist/lib/state/hooks/callback.hooks.d.ts +2 -0
- package/dist/lib/state/hooks/callback.hooks.d.ts.map +1 -0
- package/dist/lib/state/hooks/create.d.ts +7 -0
- package/dist/lib/state/hooks/create.d.ts.map +1 -0
- package/dist/lib/state/hooks/create.hooks.d.ts +29 -0
- package/dist/lib/state/hooks/create.hooks.d.ts.map +1 -0
- package/dist/lib/state/hooks/create.hooks.js +38 -0
- package/dist/lib/state/hooks/create.hooks.js.map +1 -0
- package/dist/lib/state/hooks/effect.hooks.d.ts +5 -0
- package/dist/lib/state/hooks/effect.hooks.d.ts.map +1 -0
- package/dist/lib/state/hooks/get.hooks.d.ts +25 -0
- package/dist/lib/state/hooks/get.hooks.d.ts.map +1 -0
- package/dist/lib/state/hooks/get.hooks.js +33 -0
- package/dist/lib/state/hooks/get.hooks.js.map +1 -0
- package/dist/lib/state/hooks/index.d.ts +7 -0
- package/dist/lib/state/hooks/index.d.ts.map +1 -0
- package/dist/lib/state/hooks/memo.hooks.d.ts +2 -0
- package/dist/lib/state/hooks/memo.hooks.d.ts.map +1 -0
- package/dist/lib/state/hooks/reducer.hooks.d.ts +3 -0
- package/dist/lib/state/hooks/reducer.hooks.d.ts.map +1 -0
- package/dist/lib/state/hooks/ref.hooks.d.ts +4 -0
- package/dist/lib/state/hooks/ref.hooks.d.ts.map +1 -0
- package/dist/lib/state/hooks/reset.hooks.d.ts +16 -0
- package/dist/lib/state/hooks/reset.hooks.d.ts.map +1 -0
- package/dist/lib/state/hooks/reset.hooks.js +19 -0
- package/dist/lib/state/hooks/reset.hooks.js.map +1 -0
- package/dist/lib/state/hooks/set.hooks.d.ts +23 -0
- package/dist/lib/state/hooks/set.hooks.d.ts.map +1 -0
- package/dist/lib/state/hooks/set.hooks.js +28 -0
- package/dist/lib/state/hooks/set.hooks.js.map +1 -0
- package/dist/lib/state/hooks/state.hooks.d.ts +50 -0
- package/dist/lib/state/hooks/state.hooks.d.ts.map +1 -0
- package/dist/lib/state/lifecycle/error.state.d.ts +7 -0
- package/dist/lib/state/lifecycle/error.state.d.ts.map +1 -0
- package/dist/lib/state/lifecycle/error.state.js +55 -0
- package/dist/lib/state/lifecycle/error.state.js.map +1 -0
- package/dist/lib/state/lifecycle/mount.state.d.ts +10 -0
- package/dist/lib/state/lifecycle/mount.state.d.ts.map +1 -0
- package/dist/lib/state/lifecycle/mount.state.js +84 -0
- package/dist/lib/state/lifecycle/mount.state.js.map +1 -0
- package/dist/lib/state/lifecycle/rerender.state.d.ts +10 -0
- package/dist/lib/state/lifecycle/rerender.state.d.ts.map +1 -0
- package/dist/lib/state/lifecycle/rerender.state.js +86 -0
- package/dist/lib/state/lifecycle/rerender.state.js.map +1 -0
- package/dist/lib/state/lifecycle/unmount.state.d.ts +9 -0
- package/dist/lib/state/lifecycle/unmount.state.d.ts.map +1 -0
- package/dist/lib/state/lifecycle/unmount.state.js +33 -0
- package/dist/lib/state/lifecycle/unmount.state.js.map +1 -0
- package/dist/types/grammy.types.d.ts +29 -0
- package/dist/types/grammy.types.d.ts.map +1 -0
- package/dist/types/grammy.types.js +3 -0
- package/dist/types/grammy.types.js.map +1 -0
- package/dist/types/hooks.types.d.ts +27 -0
- package/dist/types/hooks.types.d.ts.map +1 -0
- package/dist/types/jsx.types.d.ts +240 -0
- package/dist/types/jsx.types.d.ts.map +1 -0
- package/dist/types/jsx.types.js +29 -0
- package/dist/types/jsx.types.js.map +1 -0
- package/dist/types/lib.types.d.ts +80 -0
- package/dist/types/lib.types.d.ts.map +1 -0
- package/dist/types/lib.types.js +1 -0
- package/dist/types/lib.types.js.map +1 -0
- package/dist/types/plugin.types.d.ts +81 -0
- package/dist/types/plugin.types.d.ts.map +1 -0
- package/dist/types/plugin.types.js +1 -0
- package/dist/types/plugin.types.js.map +1 -0
- package/dist/utils/generateUniqueId.d.ts +29 -0
- package/dist/utils/generateUniqueId.d.ts.map +1 -0
- package/dist/utils/generateUniqueId.js +41 -0
- package/dist/utils/generateUniqueId.js.map +1 -0
- package/dist/utils/getEmoji.d.ts +26 -0
- package/dist/utils/getEmoji.d.ts.map +1 -0
- package/dist/utils/getEmoji.js +33 -0
- package/dist/utils/getEmoji.js.map +1 -0
- package/dist/utils/getPlainText.d.ts +23 -0
- package/dist/utils/getPlainText.d.ts.map +1 -0
- package/dist/utils/getPlainText.js +30 -0
- package/dist/utils/getPlainText.js.map +1 -0
- package/dist/utils/global.d.ts +13 -0
- package/dist/utils/global.d.ts.map +1 -0
- package/dist/utils/global.js +7 -0
- package/dist/utils/global.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/isAbortError.d.ts +2 -0
- package/dist/utils/isAbortError.d.ts.map +1 -0
- package/dist/utils/isEmoji.d.ts +25 -0
- package/dist/utils/isEmoji.d.ts.map +1 -0
- package/dist/utils/isEmoji.js +27 -0
- package/dist/utils/isEmoji.js.map +1 -0
- package/dist/utils/isEqual.d.ts +42 -0
- package/dist/utils/isEqual.d.ts.map +1 -0
- package/dist/utils/isEqual.js +142 -0
- package/dist/utils/isEqual.js.map +1 -0
- package/dist/utils/isIntrinsicElement.d.ts +23 -0
- package/dist/utils/isIntrinsicElement.d.ts.map +1 -0
- package/dist/utils/isIntrinsicElement.js +25 -0
- package/dist/utils/isIntrinsicElement.js.map +1 -0
- package/dist/utils/isMessageNotFount.d.ts +2 -0
- package/dist/utils/isMessageNotFount.d.ts.map +1 -0
- package/dist/utils/isUnixTime.d.ts +32 -0
- package/dist/utils/isUnixTime.d.ts.map +1 -0
- package/dist/utils/isUnixTime.js +38 -0
- package/dist/utils/isUnixTime.js.map +1 -0
- package/dist/utils/sanitizeHtmlString.d.ts +24 -0
- package/dist/utils/sanitizeHtmlString.d.ts.map +1 -0
- package/dist/utils/sanitizeHtmlString.js +29 -0
- package/dist/utils/sanitizeHtmlString.js.map +1 -0
- package/dist/utils/withComponentScope.d.ts +2 -0
- package/dist/utils/withComponentScope.d.ts.map +1 -0
- package/dist/utils/withRuntime.d.ts +4 -0
- package/dist/utils/withRuntime.d.ts.map +1 -0
- package/package.json +62 -0
- package/readme.md +373 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Context, Message, OtherContexted } from "./grammy.types";
|
|
2
|
+
import type { JSX } from "./jsx.types";
|
|
3
|
+
/**
|
|
4
|
+
* Excludes `undefined` from a union type.
|
|
5
|
+
*
|
|
6
|
+
* Commonly used to normalize optional generic parameters
|
|
7
|
+
* into a required variant for internal render pipelines.
|
|
8
|
+
*
|
|
9
|
+
* @template T
|
|
10
|
+
*/
|
|
11
|
+
export type RequiredUnion<T> = T extends undefined ? never : T;
|
|
12
|
+
/**
|
|
13
|
+
* Represents a value that can be provided either as a single item
|
|
14
|
+
* or as an array of items of the same type.
|
|
15
|
+
*
|
|
16
|
+
* Useful for APIs that accept both:
|
|
17
|
+
* - a single value
|
|
18
|
+
* - multiple values
|
|
19
|
+
*
|
|
20
|
+
* @template T
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* type Input = MaybeArray<string>;
|
|
24
|
+
* // string | string[]
|
|
25
|
+
*/
|
|
26
|
+
export type MaybeArray<T> = T | T[];
|
|
27
|
+
/**
|
|
28
|
+
* Configuration options for the reactive plugin runtime.
|
|
29
|
+
*
|
|
30
|
+
* Used to provide the target options for
|
|
31
|
+
* middleware registration
|
|
32
|
+
*
|
|
33
|
+
* @template C
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const options: PluginOptions<MyContext> = {
|
|
37
|
+
*
|
|
38
|
+
* };
|
|
39
|
+
*/
|
|
40
|
+
export type PluginOptions<C extends Context> = {} | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Augments a Grammy context type with reactive runtime capabilities.
|
|
43
|
+
*
|
|
44
|
+
* This utility flavor composes the base Grammy `Context` with
|
|
45
|
+
* {@link ReactiveContextExtension}, making all reactive helpers
|
|
46
|
+
* available on the resulting context type.
|
|
47
|
+
*
|
|
48
|
+
* Useful for strongly typed middleware pipelines, plugins, and
|
|
49
|
+
* custom bot context definitions.
|
|
50
|
+
*
|
|
51
|
+
* @template {Context} C
|
|
52
|
+
*/
|
|
53
|
+
export type ReactiveContextFlavor<C extends Context> = C & ReactiveContextExtension;
|
|
54
|
+
/**
|
|
55
|
+
* A minimal reactive Grammy context type based on the standard `Context`.
|
|
56
|
+
*
|
|
57
|
+
* This is a convenience alias for:
|
|
58
|
+
* `ReactiveContextFlavor<Context>`.
|
|
59
|
+
*
|
|
60
|
+
* Useful when no custom context extensions are required.
|
|
61
|
+
*/
|
|
62
|
+
export type ReactiveContext = ReactiveContextFlavor<Context>;
|
|
63
|
+
/**
|
|
64
|
+
* Extends the Grammy context with JSX-based messaging helpers.
|
|
65
|
+
*
|
|
66
|
+
* These methods render JSX trees into Telegram-compatible HTML messages
|
|
67
|
+
* and forward the result to the corresponding context or raw API method.
|
|
68
|
+
*/
|
|
69
|
+
export interface ReactiveContextExtension {
|
|
70
|
+
/**
|
|
71
|
+
* Context-aware alias for api.sendMessage with JSX support. Use this method to send text messages with JSX markup.
|
|
72
|
+
* On success, the sent Message is returned.
|
|
73
|
+
*
|
|
74
|
+
* @param jsx — JSX of the message to be sent, 1-4096 characters after entities parsing and render
|
|
75
|
+
* @param other — Optional remaining parameters, confer the official reference below
|
|
76
|
+
* @param signal
|
|
77
|
+
* Optional AbortSignal to cancel the request
|
|
78
|
+
*/
|
|
79
|
+
reply(jsx: MaybeArray<JSX.Element>, other?: OtherContexted<"sendMessage", "text" | "chat_id" | "parse_mode">, signal?: AbortSignal): Promise<Message.TextMessage>;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=plugin.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.types.d.ts","sourceRoot":"","sources":["../../src/types/plugin.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAO,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAIvC;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;AAInC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,OAAO,IAAI,EAE9C,GAAG,SAAS,CAAC;AAId;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,GAAG,wBAAwB,CAAC;AAEpF;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACrC;;;;;;;;OAQG;IACH,KAAK,CACD,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAC5B,KAAK,CAAC,EAAE,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,CAAC,EACxE,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=plugin.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.types.js","sourceRoot":"","sources":["../../src/types/plugin.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a cryptographically strong unique identifier string.
|
|
3
|
+
*
|
|
4
|
+
* The identifier is built from 16 cryptographically secure random bytes
|
|
5
|
+
* using `crypto.getRandomValues()` and encoded as a fixed-length base36
|
|
6
|
+
* string.
|
|
7
|
+
*
|
|
8
|
+
* To guarantee uniqueness within the current runtime instance, generated
|
|
9
|
+
* identifiers are checked against a global in-memory registry and regenerated
|
|
10
|
+
* until a non-colliding value is produced.
|
|
11
|
+
*
|
|
12
|
+
* This makes the function suitable for stable runtime IDs such as:
|
|
13
|
+
* - reactive node identifiers
|
|
14
|
+
* - subscription keys
|
|
15
|
+
* - render instance tracking
|
|
16
|
+
* - component lifecycle registries
|
|
17
|
+
*
|
|
18
|
+
* @returns {string} A unique 16-character base36 identifier.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Uniqueness is guaranteed only within the current process lifetime
|
|
22
|
+
* while `globalIdSet` is preserved.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const id = generateUniqueId();
|
|
26
|
+
* // "a8k2x4p1m9z0q7rs"
|
|
27
|
+
*/
|
|
28
|
+
export declare function generateUniqueId(): string;
|
|
29
|
+
//# sourceMappingURL=generateUniqueId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateUniqueId.d.ts","sourceRoot":"","sources":["../../src/utils/generateUniqueId.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CASzC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { globalIdSet } from "./global";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a cryptographically strong unique identifier string.
|
|
4
|
+
*
|
|
5
|
+
* The identifier is built from 16 cryptographically secure random bytes
|
|
6
|
+
* using `crypto.getRandomValues()` and encoded as a fixed-length base36
|
|
7
|
+
* string.
|
|
8
|
+
*
|
|
9
|
+
* To guarantee uniqueness within the current runtime instance, generated
|
|
10
|
+
* identifiers are checked against a global in-memory registry and regenerated
|
|
11
|
+
* until a non-colliding value is produced.
|
|
12
|
+
*
|
|
13
|
+
* This makes the function suitable for stable runtime IDs such as:
|
|
14
|
+
* - reactive node identifiers
|
|
15
|
+
* - subscription keys
|
|
16
|
+
* - render instance tracking
|
|
17
|
+
* - component lifecycle registries
|
|
18
|
+
*
|
|
19
|
+
* @returns {string} A unique 16-character base36 identifier.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Uniqueness is guaranteed only within the current process lifetime
|
|
23
|
+
* while `globalIdSet` is preserved.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const id = generateUniqueId();
|
|
27
|
+
* // "a8k2x4p1m9z0q7rs"
|
|
28
|
+
*/
|
|
29
|
+
export function generateUniqueId() {
|
|
30
|
+
const generate = () => {
|
|
31
|
+
const bytes = new Uint8Array(16);
|
|
32
|
+
crypto.getRandomValues(bytes);
|
|
33
|
+
return Array.from(bytes, byte => (byte % 36).toString(36)).join("");
|
|
34
|
+
};
|
|
35
|
+
let id = generate();
|
|
36
|
+
while (globalIdSet.has(id))
|
|
37
|
+
id = generate();
|
|
38
|
+
globalIdSet.add(id);
|
|
39
|
+
return id;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=generateUniqueId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateUniqueId.js","sourceRoot":"","sources":["../../src/utils/generateUniqueId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,gBAAgB;IAC5B,MAAM,QAAQ,GAAG,GAAG,EAAE;QAClB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;QAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAChE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC,CAAA;IACD,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;IACpB,OAAO,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QAAE,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC3C,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACnB,OAAO,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IntrinsicElement, IntrinsicElements } from "~/types/jsx.types";
|
|
2
|
+
/**
|
|
3
|
+
* Finds the first direct emoji intrinsic child entity within an element.
|
|
4
|
+
*
|
|
5
|
+
* This utility performs a shallow scan over the element's immediate
|
|
6
|
+
* `children` collection and returns the first child whose intrinsic
|
|
7
|
+
* entity type is `"emoji"`.
|
|
8
|
+
*
|
|
9
|
+
* Only direct children are inspected. Nested descendants inside child
|
|
10
|
+
* branches are not traversed.
|
|
11
|
+
*
|
|
12
|
+
* Useful for extracting decorative or semantic emoji metadata from
|
|
13
|
+
* JSX-generated intrinsic trees.
|
|
14
|
+
*
|
|
15
|
+
* @param {IntrinsicElement} element - The intrinsic element whose direct children should be scanned.
|
|
16
|
+
* @returns {IntrinsicElements["emoji"] | undefined}
|
|
17
|
+
* The first matching emoji entity, or `undefined` if none is found.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const emoji = getEmoji(element);
|
|
21
|
+
* if (emoji) {
|
|
22
|
+
* console.log(emoji.id);
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
export declare function getEmoji(element: IntrinsicElement): IntrinsicElements["emoji"] | undefined;
|
|
26
|
+
//# sourceMappingURL=getEmoji.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEmoji.d.ts","sourceRoot":"","sources":["../../src/utils/getEmoji.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,SAAS,CAS1F"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the first direct emoji intrinsic child entity within an element.
|
|
3
|
+
*
|
|
4
|
+
* This utility performs a shallow scan over the element's immediate
|
|
5
|
+
* `children` collection and returns the first child whose intrinsic
|
|
6
|
+
* entity type is `"emoji"`.
|
|
7
|
+
*
|
|
8
|
+
* Only direct children are inspected. Nested descendants inside child
|
|
9
|
+
* branches are not traversed.
|
|
10
|
+
*
|
|
11
|
+
* Useful for extracting decorative or semantic emoji metadata from
|
|
12
|
+
* JSX-generated intrinsic trees.
|
|
13
|
+
*
|
|
14
|
+
* @param {IntrinsicElement} element - The intrinsic element whose direct children should be scanned.
|
|
15
|
+
* @returns {IntrinsicElements["emoji"] | undefined}
|
|
16
|
+
* The first matching emoji entity, or `undefined` if none is found.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const emoji = getEmoji(element);
|
|
20
|
+
* if (emoji) {
|
|
21
|
+
* console.log(emoji.id);
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
export function getEmoji(element) {
|
|
25
|
+
const children = element.children;
|
|
26
|
+
for (let i = 0; i < children.length; i++) {
|
|
27
|
+
const child = children[i];
|
|
28
|
+
if (child.type === "intrinsic" && child.entity.type === "emoji") {
|
|
29
|
+
return child.entity;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=getEmoji.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEmoji.js","sourceRoot":"","sources":["../../src/utils/getEmoji.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAyB;IAC9C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC9D,OAAO,KAAK,CAAC,MAAoC,CAAC;QACtD,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IntrinsicElement } from "~/types/jsx.types";
|
|
2
|
+
/**
|
|
3
|
+
* Finds the first direct plain-text child value within an intrinsic element.
|
|
4
|
+
*
|
|
5
|
+
* This utility performs a shallow scan over the element's immediate
|
|
6
|
+
* `children` collection and returns the value of the first child whose
|
|
7
|
+
* node type is `"plain"`.
|
|
8
|
+
*
|
|
9
|
+
* Only direct children are inspected. Nested descendants are not traversed.
|
|
10
|
+
*
|
|
11
|
+
* Useful for extracting raw textual labels, captions, button titles,
|
|
12
|
+
* or other first-level plain text content from JSX-generated trees.
|
|
13
|
+
*
|
|
14
|
+
* @param {IntrinsicElement} element - The intrinsic element whose direct children should be scanned.
|
|
15
|
+
* @returns {string | undefined}
|
|
16
|
+
* The first plain-text child value, or `undefined` if no direct plain node exists.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const text = getPlainText(buttonElement);
|
|
20
|
+
* // "Click me"
|
|
21
|
+
*/
|
|
22
|
+
export declare function getPlainText(element: IntrinsicElement): string | undefined;
|
|
23
|
+
//# sourceMappingURL=getPlainText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPlainText.d.ts","sourceRoot":"","sources":["../../src/utils/getPlainText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAgB,MAAM,mBAAmB,CAAC;AAExE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAU1E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the first direct plain-text child value within an intrinsic element.
|
|
3
|
+
*
|
|
4
|
+
* This utility performs a shallow scan over the element's immediate
|
|
5
|
+
* `children` collection and returns the value of the first child whose
|
|
6
|
+
* node type is `"plain"`.
|
|
7
|
+
*
|
|
8
|
+
* Only direct children are inspected. Nested descendants are not traversed.
|
|
9
|
+
*
|
|
10
|
+
* Useful for extracting raw textual labels, captions, button titles,
|
|
11
|
+
* or other first-level plain text content from JSX-generated trees.
|
|
12
|
+
*
|
|
13
|
+
* @param {IntrinsicElement} element - The intrinsic element whose direct children should be scanned.
|
|
14
|
+
* @returns {string | undefined}
|
|
15
|
+
* The first plain-text child value, or `undefined` if no direct plain node exists.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const text = getPlainText(buttonElement);
|
|
19
|
+
* // "Click me"
|
|
20
|
+
*/
|
|
21
|
+
export function getPlainText(element) {
|
|
22
|
+
const children = element.children;
|
|
23
|
+
for (let i = 0; i < children.length; i++) {
|
|
24
|
+
const child = children[i];
|
|
25
|
+
if (child.type === "plain") {
|
|
26
|
+
return child.value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=getPlainText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPlainText.js","sourceRoot":"","sources":["../../src/utils/getPlainText.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,YAAY,CAAC,OAAyB;IAClD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAElC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAE,CAAC;QAE3B,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,KAA2B,CAAC;QAC7C,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import type { Message } from "~/types/grammy.types";
|
|
3
|
+
import type { HookRuntime } from "~/types/hooks.types";
|
|
4
|
+
import type { BotHandlerLifecycleInstance } from "~/types/lib.types";
|
|
5
|
+
import type { ReactiveContext } from "~/types/plugin.types";
|
|
6
|
+
export declare const globalButtonCallbacks: Record<string, (ctx: ReactiveContext) => Promise<void> | void>;
|
|
7
|
+
export declare const globalPreviousState: Record<string, Message>;
|
|
8
|
+
export declare const globalCurrentState: Record<string, Message>;
|
|
9
|
+
export declare const globalIdSet: Set<string>;
|
|
10
|
+
export declare const globalAbortControllers: Map<string, AbortController>;
|
|
11
|
+
export declare const globalHookRuntimeAsyncStorage: AsyncLocalStorage<HookRuntime>;
|
|
12
|
+
export declare const globalStates: Map<string, BotHandlerLifecycleInstance<ReactiveContext>>;
|
|
13
|
+
//# sourceMappingURL=global.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../src/utils/global.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAM,CAAA;AACvG,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAA;AAC9D,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAA;AAC7D,eAAO,MAAM,WAAW,EAAE,GAAG,CAAC,MAAM,CAAa,CAAC;AAClD,eAAO,MAAM,sBAAsB,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAa,CAAC;AAC9E,eAAO,MAAM,6BAA6B,gCAAuC,CAAC;AAClF,eAAO,MAAM,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,2BAA2B,CAAC,eAAe,CAAC,CAAa,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const globalButtonCallbacks = {};
|
|
2
|
+
export const globalHooks = {};
|
|
3
|
+
export const globalPreviousState = {};
|
|
4
|
+
export const globalCurrentState = {};
|
|
5
|
+
export const globalIdSet = new Set();
|
|
6
|
+
export const globalAbortControllers = new Map();
|
|
7
|
+
//# sourceMappingURL=global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/utils/global.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,qBAAqB,GAAmE,EAAE,CAAA;AACvG,MAAM,CAAC,MAAM,WAAW,GAA0B,EAAE,CAAA;AACpD,MAAM,CAAC,MAAM,mBAAmB,GAA4B,EAAE,CAAA;AAC9D,MAAM,CAAC,MAAM,kBAAkB,GAA4B,EAAE,CAAA;AAC7D,MAAM,CAAC,MAAM,WAAW,GAAgB,IAAI,GAAG,EAAE,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAiC,IAAI,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { generateUniqueId } from "./generateUniqueId";
|
|
2
|
+
export { isEmoji } from "./isEmoji";
|
|
3
|
+
export { isUnixTime } from "./isUnixTime";
|
|
4
|
+
export { sanitizeHtmlString } from "./sanitizeHtmlString";
|
|
5
|
+
export { isIntrinsicElement } from "./isIntrinsicElement";
|
|
6
|
+
export { getEmoji } from "./getEmoji";
|
|
7
|
+
export { getPlainText } from "./getPlainText";
|
|
8
|
+
export * from "./global";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { generateUniqueId } from "./generateUniqueId";
|
|
2
|
+
export { isEmoji } from "./isEmoji";
|
|
3
|
+
export { isUnixTime } from "./isUnixTime";
|
|
4
|
+
export { sanitizeHtmlString } from "./sanitizeHtmlString";
|
|
5
|
+
export { isIntrinsicElement } from "./isIntrinsicElement";
|
|
6
|
+
export { getEmoji } from "./getEmoji";
|
|
7
|
+
export { getPlainText } from "./getPlainText";
|
|
8
|
+
export { isEqual } from "./isEqual";
|
|
9
|
+
export * from "./global";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isAbortError.d.ts","sourceRoot":"","sources":["../../src/utils/isAbortError.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKpD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether a string is exactly one emoji symbol.
|
|
3
|
+
*
|
|
4
|
+
* The check validates that the entire string consists of a single
|
|
5
|
+
* Unicode RGI emoji grapheme, including complex emoji sequences such as:
|
|
6
|
+
* - skin tone modifiers
|
|
7
|
+
* - ZWJ sequences
|
|
8
|
+
* - flags
|
|
9
|
+
* - family emojis
|
|
10
|
+
* - keycap emojis
|
|
11
|
+
*
|
|
12
|
+
* Requires JavaScript support for the `v` regular expression flag.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} str - The string to validate.
|
|
15
|
+
* @returns {boolean} `true` if the string is exactly one emoji symbol.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* isEmoji("🔥"); // true
|
|
19
|
+
* isEmoji("👨👩👧👦"); // true
|
|
20
|
+
* isEmoji("🇱🇻"); // true
|
|
21
|
+
* isEmoji("🔥🔥"); // false
|
|
22
|
+
* isEmoji("🔥 hi"); // false
|
|
23
|
+
*/
|
|
24
|
+
export declare function isEmoji(str: string): boolean;
|
|
25
|
+
//# sourceMappingURL=isEmoji.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEmoji.d.ts","sourceRoot":"","sources":["../../src/utils/isEmoji.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE5C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether a string is exactly one emoji symbol.
|
|
3
|
+
*
|
|
4
|
+
* The check validates that the entire string consists of a single
|
|
5
|
+
* Unicode RGI emoji grapheme, including complex emoji sequences such as:
|
|
6
|
+
* - skin tone modifiers
|
|
7
|
+
* - ZWJ sequences
|
|
8
|
+
* - flags
|
|
9
|
+
* - family emojis
|
|
10
|
+
* - keycap emojis
|
|
11
|
+
*
|
|
12
|
+
* Requires JavaScript support for the `v` regular expression flag.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} str - The string to validate.
|
|
15
|
+
* @returns {boolean} `true` if the string is exactly one emoji symbol.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* isEmoji("🔥"); // true
|
|
19
|
+
* isEmoji("👨👩👧👦"); // true
|
|
20
|
+
* isEmoji("🇱🇻"); // true
|
|
21
|
+
* isEmoji("🔥🔥"); // false
|
|
22
|
+
* isEmoji("🔥 hi"); // false
|
|
23
|
+
*/
|
|
24
|
+
export function isEmoji(str) {
|
|
25
|
+
return /^\p{RGI_Emoji}$/v.test(str);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=isEmoji.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEmoji.js","sourceRoot":"","sources":["../../src/utils/isEmoji.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW;IAC/B,OAAO,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs a deep structural equality comparison between two values.
|
|
3
|
+
*
|
|
4
|
+
* This utility recursively compares primitives, arrays, plain objects,
|
|
5
|
+
* typed arrays, buffers, maps, sets, dates, regexes, symbols,
|
|
6
|
+
* array buffers, data views, and cyclic object graphs.
|
|
7
|
+
*
|
|
8
|
+
* Supported comparison features:
|
|
9
|
+
* - deep recursive object comparison
|
|
10
|
+
* - cyclic reference detection
|
|
11
|
+
* - `NaN` equality support
|
|
12
|
+
* - symbol key comparison
|
|
13
|
+
* - `Map` and `Set` structural equality
|
|
14
|
+
* - `ArrayBuffer`, `DataView`, and typed array byte comparison
|
|
15
|
+
* - `Buffer` support in Node.js
|
|
16
|
+
* - constructor equality validation
|
|
17
|
+
*
|
|
18
|
+
* `Set` values are compared by deep value equivalence rather than insertion
|
|
19
|
+
* identity, and `Map` values are compared through their entry pairs.
|
|
20
|
+
*
|
|
21
|
+
* @param {unknown} a - The first value to compare.
|
|
22
|
+
* @param {unknown} b - The second value to compare.
|
|
23
|
+
* @returns {boolean} `true` if both values are deeply equal, otherwise `false`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* isEqual({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] });
|
|
27
|
+
* // true
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* isEqual(new Set([1, 2]), new Set([2, 1]));
|
|
31
|
+
* // true
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const a: any = {};
|
|
35
|
+
* a.self = a;
|
|
36
|
+
* const b: any = {};
|
|
37
|
+
* b.self = b;
|
|
38
|
+
* isEqual(a, b);
|
|
39
|
+
* // true
|
|
40
|
+
*/
|
|
41
|
+
export declare function isEqual(a: unknown, b: unknown): boolean;
|
|
42
|
+
//# sourceMappingURL=isEqual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEqual.d.ts","sourceRoot":"","sources":["../../src/utils/isEqual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAsFvD"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs a deep structural equality comparison between two values.
|
|
3
|
+
*
|
|
4
|
+
* This utility recursively compares primitives, arrays, plain objects,
|
|
5
|
+
* typed arrays, buffers, maps, sets, dates, regexes, symbols,
|
|
6
|
+
* array buffers, data views, and cyclic object graphs.
|
|
7
|
+
*
|
|
8
|
+
* Supported comparison features:
|
|
9
|
+
* - deep recursive object comparison
|
|
10
|
+
* - cyclic reference detection
|
|
11
|
+
* - `NaN` equality support
|
|
12
|
+
* - symbol key comparison
|
|
13
|
+
* - `Map` and `Set` structural equality
|
|
14
|
+
* - `ArrayBuffer`, `DataView`, and typed array byte comparison
|
|
15
|
+
* - `Buffer` support in Node.js
|
|
16
|
+
* - constructor equality validation
|
|
17
|
+
*
|
|
18
|
+
* `Set` values are compared by deep value equivalence rather than insertion
|
|
19
|
+
* identity, and `Map` values are compared through their entry pairs.
|
|
20
|
+
*
|
|
21
|
+
* @param {unknown} a - The first value to compare.
|
|
22
|
+
* @param {unknown} b - The second value to compare.
|
|
23
|
+
* @returns {boolean} `true` if both values are deeply equal, otherwise `false`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* isEqual({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] });
|
|
27
|
+
* // true
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* isEqual(new Set([1, 2]), new Set([2, 1]));
|
|
31
|
+
* // true
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const a: any = {};
|
|
35
|
+
* a.self = a;
|
|
36
|
+
* const b: any = {};
|
|
37
|
+
* b.self = b;
|
|
38
|
+
* isEqual(a, b);
|
|
39
|
+
* // true
|
|
40
|
+
*/
|
|
41
|
+
export function isEqual(a, b) {
|
|
42
|
+
const toString = Object.prototype.toString;
|
|
43
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
44
|
+
const propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
45
|
+
const eq = (x, y) => x === y || (x !== x && y !== y);
|
|
46
|
+
const isObjectLike = (v) => v !== null && typeof v === "object";
|
|
47
|
+
const isTypedArray = (v) => ArrayBuffer.isView(v) && !(v instanceof DataView);
|
|
48
|
+
const getTag = (v) => toString.call(v);
|
|
49
|
+
const getSymbols = (obj) => Object.getOwnPropertySymbols(obj).filter((s) => propertyIsEnumerable.call(obj, s));
|
|
50
|
+
const getAllKeys = (obj) => [...Object.keys(obj), ...getSymbols(obj)];
|
|
51
|
+
const compare = (x, y, stack = new WeakMap()) => {
|
|
52
|
+
if (eq(x, y))
|
|
53
|
+
return true;
|
|
54
|
+
if (!isObjectLike(x) || !isObjectLike(y))
|
|
55
|
+
return eq(x, y);
|
|
56
|
+
if (stack.get(x) === y)
|
|
57
|
+
return true;
|
|
58
|
+
stack.set(x, y);
|
|
59
|
+
const tagX = getTag(x), tagY = getTag(y);
|
|
60
|
+
if (tagX !== tagY)
|
|
61
|
+
return false;
|
|
62
|
+
if (Array.isArray(x)) {
|
|
63
|
+
if (x.length !== y.length)
|
|
64
|
+
return false;
|
|
65
|
+
for (let i = 0; i < x.length; i++)
|
|
66
|
+
if (!compare(x[i], y[i], stack))
|
|
67
|
+
return false;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
if (tagX === "[object Date]" || tagX === "[object Boolean]" || tagX === "[object Number]")
|
|
71
|
+
return eq(+x, +y);
|
|
72
|
+
if (tagX === "[object String]" || tagX === "[object RegExp]")
|
|
73
|
+
return String(x) === String(y);
|
|
74
|
+
if (tagX === "[object Error]")
|
|
75
|
+
return x.name === y.name && x.message === y.message;
|
|
76
|
+
if (tagX === "[object Symbol]")
|
|
77
|
+
return Symbol.prototype.valueOf.call(x) === Symbol.prototype.valueOf.call(y);
|
|
78
|
+
if (tagX === "[object ArrayBuffer]") {
|
|
79
|
+
if (x.byteLength !== y.byteLength)
|
|
80
|
+
return false;
|
|
81
|
+
return compare(new Uint8Array(x), new Uint8Array(y), stack);
|
|
82
|
+
}
|
|
83
|
+
if (tagX === "[object DataView]") {
|
|
84
|
+
if (x.byteLength !== y.byteLength || x.byteOffset !== y.byteOffset)
|
|
85
|
+
return false;
|
|
86
|
+
return compare(new Uint8Array(x.buffer), new Uint8Array(y.buffer), stack);
|
|
87
|
+
}
|
|
88
|
+
if (isTypedArray(x)) {
|
|
89
|
+
if (x.length !== y.length)
|
|
90
|
+
return false;
|
|
91
|
+
for (let i = 0; i < x.length; i++)
|
|
92
|
+
if (!eq(x[i], y[i]))
|
|
93
|
+
return false;
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if (tagX === "[object Set]") {
|
|
97
|
+
if (x.size !== y.size)
|
|
98
|
+
return false;
|
|
99
|
+
const used = new Set(), arrY = [...y];
|
|
100
|
+
outer: for (const xv of x) {
|
|
101
|
+
for (let i = 0; i < arrY.length; i++) {
|
|
102
|
+
if (used.has(i))
|
|
103
|
+
continue;
|
|
104
|
+
if (compare(xv, arrY[i], stack)) {
|
|
105
|
+
used.add(i);
|
|
106
|
+
continue outer;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (tagX === "[object Map]") {
|
|
114
|
+
if (x.size !== y.size)
|
|
115
|
+
return false;
|
|
116
|
+
return compare([...x.entries()], [...y.entries()], stack);
|
|
117
|
+
}
|
|
118
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(x)) {
|
|
119
|
+
if (!Buffer.isBuffer(y) || x.length !== y.length)
|
|
120
|
+
return false;
|
|
121
|
+
for (let i = 0; i < x.length; i++)
|
|
122
|
+
if (x[i] !== y[i])
|
|
123
|
+
return false;
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
const keysX = getAllKeys(x);
|
|
127
|
+
const keysY = getAllKeys(y);
|
|
128
|
+
if (keysX.length !== keysY.length)
|
|
129
|
+
return false;
|
|
130
|
+
for (const key of keysX) {
|
|
131
|
+
if (!hasOwn.call(y, key))
|
|
132
|
+
return false;
|
|
133
|
+
if (!compare(x[key], y[key], stack))
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
const ctorX = x.constructor;
|
|
137
|
+
const ctorY = y.constructor;
|
|
138
|
+
return ctorX === ctorY;
|
|
139
|
+
};
|
|
140
|
+
return compare(a, b);
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=isEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEqual.js","sourceRoot":"","sources":["../../src/utils/isEqual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,OAAO,CAAC,CAAU,EAAE,CAAU;IAC1C,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;IAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;IAC/C,MAAM,oBAAoB,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;IAEnE,MAAM,EAAE,GAAG,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,CAAC,CAAM,EAAe,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,OAAO,CA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