@hyphen/react-sdk 1.1.0 → 1.1.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.
Files changed (3) hide show
  1. package/dist/index.cjs +701 -12
  2. package/dist/index.js +701 -10
  3. package/package.json +12 -13
package/dist/index.js CHANGED
@@ -1,9 +1,695 @@
1
- // node_modules/.pnpm/@hyphen+browser-sdk@1.1.0/node_modules/@hyphen/browser-sdk/dist/index.js
2
- import { Hookified } from "hookified";
3
1
  var __defProp = Object.defineProperty;
4
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // node_modules/.pnpm/hookified@1.15.1/node_modules/hookified/dist/node/index.js
6
+ var Eventified = class {
7
+ constructor(options) {
8
+ __publicField(this, "_eventListeners");
9
+ __publicField(this, "_maxListeners");
10
+ __publicField(this, "_logger");
11
+ __publicField(this, "_throwOnEmitError", false);
12
+ __publicField(this, "_throwOnEmptyListeners", false);
13
+ __publicField(this, "_errorEvent", "error");
14
+ this._eventListeners = /* @__PURE__ */ new Map();
15
+ this._maxListeners = 100;
16
+ this._logger = options?.logger;
17
+ if (options?.throwOnEmitError !== void 0) {
18
+ this._throwOnEmitError = options.throwOnEmitError;
19
+ }
20
+ if (options?.throwOnEmptyListeners !== void 0) {
21
+ this._throwOnEmptyListeners = options.throwOnEmptyListeners;
22
+ }
23
+ }
24
+ /**
25
+ * Gets the logger
26
+ * @returns {Logger}
27
+ */
28
+ get logger() {
29
+ return this._logger;
30
+ }
31
+ /**
32
+ * Sets the logger
33
+ * @param {Logger} logger
34
+ */
35
+ set logger(logger) {
36
+ this._logger = logger;
37
+ }
38
+ /**
39
+ * Gets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.
40
+ * @returns {boolean}
41
+ */
42
+ get throwOnEmitError() {
43
+ return this._throwOnEmitError;
44
+ }
45
+ /**
46
+ * Sets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.
47
+ * @param {boolean} value
48
+ */
49
+ set throwOnEmitError(value) {
50
+ this._throwOnEmitError = value;
51
+ }
52
+ /**
53
+ * Gets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
54
+ * @returns {boolean}
55
+ */
56
+ get throwOnEmptyListeners() {
57
+ return this._throwOnEmptyListeners;
58
+ }
59
+ /**
60
+ * Sets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
61
+ * @param {boolean} value
62
+ */
63
+ set throwOnEmptyListeners(value) {
64
+ this._throwOnEmptyListeners = value;
65
+ }
66
+ /**
67
+ * Adds a handler function for a specific event that will run only once
68
+ * @param {string | symbol} eventName
69
+ * @param {EventListener} listener
70
+ * @returns {IEventEmitter} returns the instance of the class for chaining
71
+ */
72
+ once(eventName, listener) {
73
+ const onceListener = (...arguments_) => {
74
+ this.off(eventName, onceListener);
75
+ listener(...arguments_);
76
+ };
77
+ this.on(eventName, onceListener);
78
+ return this;
79
+ }
80
+ /**
81
+ * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners
82
+ * @param {string} eventName The event name. Not required
83
+ * @returns {number} The number of listeners
84
+ */
85
+ listenerCount(eventName) {
86
+ if (eventName === void 0) {
87
+ return this.getAllListeners().length;
88
+ }
89
+ const listeners = this._eventListeners.get(eventName);
90
+ return listeners ? listeners.length : 0;
91
+ }
92
+ /**
93
+ * Gets an array of event names
94
+ * @returns {Array<string | symbol>} An array of event names
95
+ */
96
+ eventNames() {
97
+ return [...this._eventListeners.keys()];
98
+ }
99
+ /**
100
+ * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners
101
+ * @param {string} [event] (Optional) The event name
102
+ * @returns {EventListener[]} An array of listeners
103
+ */
104
+ rawListeners(event) {
105
+ if (event === void 0) {
106
+ return this.getAllListeners();
107
+ }
108
+ return this._eventListeners.get(event) ?? [];
109
+ }
110
+ /**
111
+ * Prepends a listener to the beginning of the listeners array for the specified event
112
+ * @param {string | symbol} eventName
113
+ * @param {EventListener} listener
114
+ * @returns {IEventEmitter} returns the instance of the class for chaining
115
+ */
116
+ prependListener(eventName, listener) {
117
+ const listeners = this._eventListeners.get(eventName) ?? [];
118
+ listeners.unshift(listener);
119
+ this._eventListeners.set(eventName, listeners);
120
+ return this;
121
+ }
122
+ /**
123
+ * Prepends a one-time listener to the beginning of the listeners array for the specified event
124
+ * @param {string | symbol} eventName
125
+ * @param {EventListener} listener
126
+ * @returns {IEventEmitter} returns the instance of the class for chaining
127
+ */
128
+ prependOnceListener(eventName, listener) {
129
+ const onceListener = (...arguments_) => {
130
+ this.off(eventName, onceListener);
131
+ listener(...arguments_);
132
+ };
133
+ this.prependListener(eventName, onceListener);
134
+ return this;
135
+ }
136
+ /**
137
+ * Gets the maximum number of listeners that can be added for a single event
138
+ * @returns {number} The maximum number of listeners
139
+ */
140
+ maxListeners() {
141
+ return this._maxListeners;
142
+ }
143
+ /**
144
+ * Adds a listener for a specific event. It is an alias for the on() method
145
+ * @param {string | symbol} event
146
+ * @param {EventListener} listener
147
+ * @returns {IEventEmitter} returns the instance of the class for chaining
148
+ */
149
+ addListener(event, listener) {
150
+ this.on(event, listener);
151
+ return this;
152
+ }
153
+ /**
154
+ * Adds a listener for a specific event
155
+ * @param {string | symbol} event
156
+ * @param {EventListener} listener
157
+ * @returns {IEventEmitter} returns the instance of the class for chaining
158
+ */
159
+ on(event, listener) {
160
+ if (!this._eventListeners.has(event)) {
161
+ this._eventListeners.set(event, []);
162
+ }
163
+ const listeners = this._eventListeners.get(event);
164
+ if (listeners) {
165
+ if (listeners.length >= this._maxListeners) {
166
+ console.warn(
167
+ `MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event} listeners added. Use setMaxListeners() to increase limit.`
168
+ );
169
+ }
170
+ listeners.push(listener);
171
+ }
172
+ return this;
173
+ }
174
+ /**
175
+ * Removes a listener for a specific event. It is an alias for the off() method
176
+ * @param {string | symbol} event
177
+ * @param {EventListener} listener
178
+ * @returns {IEventEmitter} returns the instance of the class for chaining
179
+ */
180
+ removeListener(event, listener) {
181
+ this.off(event, listener);
182
+ return this;
183
+ }
184
+ /**
185
+ * Removes a listener for a specific event
186
+ * @param {string | symbol} event
187
+ * @param {EventListener} listener
188
+ * @returns {IEventEmitter} returns the instance of the class for chaining
189
+ */
190
+ off(event, listener) {
191
+ const listeners = this._eventListeners.get(event) ?? [];
192
+ const index = listeners.indexOf(listener);
193
+ if (index !== -1) {
194
+ listeners.splice(index, 1);
195
+ }
196
+ if (listeners.length === 0) {
197
+ this._eventListeners.delete(event);
198
+ }
199
+ return this;
200
+ }
201
+ /**
202
+ * Calls all listeners for a specific event
203
+ * @param {string | symbol} event
204
+ * @param arguments_ The arguments to pass to the listeners
205
+ * @returns {boolean} Returns true if the event had listeners, false otherwise
206
+ */
207
+ emit(event, ...arguments_) {
208
+ let result = false;
209
+ const listeners = this._eventListeners.get(event);
210
+ if (listeners && listeners.length > 0) {
211
+ for (const listener of listeners) {
212
+ listener(...arguments_);
213
+ result = true;
214
+ }
215
+ }
216
+ if (event === this._errorEvent) {
217
+ const error = arguments_[0] instanceof Error ? arguments_[0] : new Error(`${arguments_[0]}`);
218
+ if (this._throwOnEmitError && !result) {
219
+ throw error;
220
+ } else {
221
+ if (this.listeners(this._errorEvent).length === 0 && this._throwOnEmptyListeners === true) {
222
+ throw error;
223
+ }
224
+ }
225
+ }
226
+ this.sendLog(event, arguments_);
227
+ return result;
228
+ }
229
+ /**
230
+ * Gets all listeners for a specific event. If no event is provided, it returns all listeners
231
+ * @param {string} [event] (Optional) The event name
232
+ * @returns {EventListener[]} An array of listeners
233
+ */
234
+ listeners(event) {
235
+ return this._eventListeners.get(event) ?? [];
236
+ }
237
+ /**
238
+ * Removes all listeners for a specific event. If no event is provided, it removes all listeners
239
+ * @param {string} [event] (Optional) The event name
240
+ * @returns {IEventEmitter} returns the instance of the class for chaining
241
+ */
242
+ removeAllListeners(event) {
243
+ if (event !== void 0) {
244
+ this._eventListeners.delete(event);
245
+ } else {
246
+ this._eventListeners.clear();
247
+ }
248
+ return this;
249
+ }
250
+ /**
251
+ * Sets the maximum number of listeners that can be added for a single event
252
+ * @param {number} n The maximum number of listeners
253
+ * @returns {void}
254
+ */
255
+ setMaxListeners(n) {
256
+ this._maxListeners = n;
257
+ for (const listeners of this._eventListeners.values()) {
258
+ if (listeners.length > n) {
259
+ listeners.splice(n);
260
+ }
261
+ }
262
+ }
263
+ /**
264
+ * Gets all listeners
265
+ * @returns {EventListener[]} An array of listeners
266
+ */
267
+ getAllListeners() {
268
+ let result = [];
269
+ for (const listeners of this._eventListeners.values()) {
270
+ result = [...result, ...listeners];
271
+ }
272
+ return result;
273
+ }
274
+ /**
275
+ * Sends a log message using the configured logger based on the event name
276
+ * @param {string | symbol} eventName - The event name that determines the log level
277
+ * @param {unknown} data - The data to log
278
+ */
279
+ sendLog(eventName, data) {
280
+ if (!this._logger) {
281
+ return;
282
+ }
283
+ let message;
284
+ if (typeof data === "string") {
285
+ message = data;
286
+ } else if (Array.isArray(data) && data.length > 0 && data[0] instanceof Error) {
287
+ message = data[0].message;
288
+ } else if (data instanceof Error) {
289
+ message = data.message;
290
+ } else if (Array.isArray(data) && data.length > 0 && typeof data[0]?.message === "string") {
291
+ message = data[0].message;
292
+ } else {
293
+ message = JSON.stringify(data);
294
+ }
295
+ switch (eventName) {
296
+ case "error": {
297
+ this._logger.error?.(message, { event: eventName, data });
298
+ break;
299
+ }
300
+ case "warn": {
301
+ this._logger.warn?.(message, { event: eventName, data });
302
+ break;
303
+ }
304
+ case "trace": {
305
+ this._logger.trace?.(message, { event: eventName, data });
306
+ break;
307
+ }
308
+ case "debug": {
309
+ this._logger.debug?.(message, { event: eventName, data });
310
+ break;
311
+ }
312
+ case "fatal": {
313
+ this._logger.fatal?.(message, { event: eventName, data });
314
+ break;
315
+ }
316
+ default: {
317
+ this._logger.info?.(message, { event: eventName, data });
318
+ break;
319
+ }
320
+ }
321
+ }
322
+ };
323
+ var Hookified = class extends Eventified {
324
+ constructor(options) {
325
+ super({
326
+ logger: options?.logger,
327
+ throwOnEmitError: options?.throwOnEmitError,
328
+ throwOnEmptyListeners: options?.throwOnEmptyListeners
329
+ });
330
+ __publicField(this, "_hooks");
331
+ __publicField(this, "_throwOnHookError", false);
332
+ __publicField(this, "_enforceBeforeAfter", false);
333
+ __publicField(this, "_deprecatedHooks");
334
+ __publicField(this, "_allowDeprecated", true);
335
+ this._hooks = /* @__PURE__ */ new Map();
336
+ this._deprecatedHooks = options?.deprecatedHooks ? new Map(options.deprecatedHooks) : /* @__PURE__ */ new Map();
337
+ if (options?.throwOnHookError !== void 0) {
338
+ this._throwOnHookError = options.throwOnHookError;
339
+ } else if (options?.throwHookErrors !== void 0) {
340
+ this._throwOnHookError = options.throwHookErrors;
341
+ }
342
+ if (options?.enforceBeforeAfter !== void 0) {
343
+ this._enforceBeforeAfter = options.enforceBeforeAfter;
344
+ }
345
+ if (options?.allowDeprecated !== void 0) {
346
+ this._allowDeprecated = options.allowDeprecated;
347
+ }
348
+ }
349
+ /**
350
+ * Gets all hooks
351
+ * @returns {Map<string, Hook[]>}
352
+ */
353
+ get hooks() {
354
+ return this._hooks;
355
+ }
356
+ /**
357
+ * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
358
+ * @returns {boolean}
359
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
360
+ */
361
+ get throwHookErrors() {
362
+ return this._throwOnHookError;
363
+ }
364
+ /**
365
+ * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
366
+ * @param {boolean} value
367
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
368
+ */
369
+ set throwHookErrors(value) {
370
+ this._throwOnHookError = value;
371
+ }
372
+ /**
373
+ * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
374
+ * @returns {boolean}
375
+ */
376
+ get throwOnHookError() {
377
+ return this._throwOnHookError;
378
+ }
379
+ /**
380
+ * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
381
+ * @param {boolean} value
382
+ */
383
+ set throwOnHookError(value) {
384
+ this._throwOnHookError = value;
385
+ }
386
+ /**
387
+ * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.
388
+ * @returns {boolean}
389
+ * @default false
390
+ */
391
+ get enforceBeforeAfter() {
392
+ return this._enforceBeforeAfter;
393
+ }
394
+ /**
395
+ * Sets whether to enforce that all hook names start with 'before' or 'after'. Default is false.
396
+ * @param {boolean} value
397
+ */
398
+ set enforceBeforeAfter(value) {
399
+ this._enforceBeforeAfter = value;
400
+ }
401
+ /**
402
+ * Gets the map of deprecated hook names to deprecation messages.
403
+ * @returns {Map<string, string>}
404
+ */
405
+ get deprecatedHooks() {
406
+ return this._deprecatedHooks;
407
+ }
408
+ /**
409
+ * Sets the map of deprecated hook names to deprecation messages.
410
+ * @param {Map<string, string>} value
411
+ */
412
+ set deprecatedHooks(value) {
413
+ this._deprecatedHooks = value;
414
+ }
415
+ /**
416
+ * Gets whether deprecated hooks are allowed to be registered and executed. Default is true.
417
+ * @returns {boolean}
418
+ */
419
+ get allowDeprecated() {
420
+ return this._allowDeprecated;
421
+ }
422
+ /**
423
+ * Sets whether deprecated hooks are allowed to be registered and executed. Default is true.
424
+ * @param {boolean} value
425
+ */
426
+ set allowDeprecated(value) {
427
+ this._allowDeprecated = value;
428
+ }
429
+ /**
430
+ * Validates hook event name if enforceBeforeAfter is enabled
431
+ * @param {string} event - The event name to validate
432
+ * @throws {Error} If enforceBeforeAfter is true and event doesn't start with 'before' or 'after'
433
+ */
434
+ validateHookName(event) {
435
+ if (this._enforceBeforeAfter) {
436
+ const eventValue = event.trim().toLocaleLowerCase();
437
+ if (!eventValue.startsWith("before") && !eventValue.startsWith("after")) {
438
+ throw new Error(
439
+ `Hook event "${event}" must start with "before" or "after" when enforceBeforeAfter is enabled`
440
+ );
441
+ }
442
+ }
443
+ }
444
+ /**
445
+ * Checks if a hook is deprecated and emits a warning if it is
446
+ * @param {string} event - The event name to check
447
+ * @returns {boolean} - Returns true if the hook should proceed, false if it should be blocked
448
+ */
449
+ checkDeprecatedHook(event) {
450
+ if (this._deprecatedHooks.has(event)) {
451
+ const message = this._deprecatedHooks.get(event);
452
+ const warningMessage = `Hook "${event}" is deprecated${message ? `: ${message}` : ""}`;
453
+ this.emit("warn", { hook: event, message: warningMessage });
454
+ return this._allowDeprecated;
455
+ }
456
+ return true;
457
+ }
458
+ /**
459
+ * Adds a handler function for a specific event
460
+ * @param {string} event
461
+ * @param {Hook} handler - this can be async or sync
462
+ * @returns {void}
463
+ */
464
+ onHook(event, handler) {
465
+ this.onHookEntry({ event, handler });
466
+ }
467
+ /**
468
+ * Adds a handler function for a specific event
469
+ * @param {HookEntry} hookEntry
470
+ * @returns {void}
471
+ */
472
+ onHookEntry(hookEntry) {
473
+ this.validateHookName(hookEntry.event);
474
+ if (!this.checkDeprecatedHook(hookEntry.event)) {
475
+ return;
476
+ }
477
+ const eventHandlers = this._hooks.get(hookEntry.event);
478
+ if (eventHandlers) {
479
+ eventHandlers.push(hookEntry.handler);
480
+ } else {
481
+ this._hooks.set(hookEntry.event, [hookEntry.handler]);
482
+ }
483
+ }
484
+ /**
485
+ * Alias for onHook. This is provided for compatibility with other libraries that use the `addHook` method.
486
+ * @param {string} event
487
+ * @param {Hook} handler - this can be async or sync
488
+ * @returns {void}
489
+ */
490
+ addHook(event, handler) {
491
+ this.onHookEntry({ event, handler });
492
+ }
493
+ /**
494
+ * Adds a handler function for a specific event
495
+ * @param {Array<HookEntry>} hooks
496
+ * @returns {void}
497
+ */
498
+ onHooks(hooks) {
499
+ for (const hook of hooks) {
500
+ this.onHook(hook.event, hook.handler);
501
+ }
502
+ }
503
+ /**
504
+ * Adds a handler function for a specific event that runs before all other handlers
505
+ * @param {string} event
506
+ * @param {Hook} handler - this can be async or sync
507
+ * @returns {void}
508
+ */
509
+ prependHook(event, handler) {
510
+ this.validateHookName(event);
511
+ if (!this.checkDeprecatedHook(event)) {
512
+ return;
513
+ }
514
+ const eventHandlers = this._hooks.get(event);
515
+ if (eventHandlers) {
516
+ eventHandlers.unshift(handler);
517
+ } else {
518
+ this._hooks.set(event, [handler]);
519
+ }
520
+ }
521
+ /**
522
+ * Adds a handler that only executes once for a specific event before all other handlers
523
+ * @param event
524
+ * @param handler
525
+ */
526
+ prependOnceHook(event, handler) {
527
+ this.validateHookName(event);
528
+ if (!this.checkDeprecatedHook(event)) {
529
+ return;
530
+ }
531
+ const hook = async (...arguments_) => {
532
+ this.removeHook(event, hook);
533
+ return handler(...arguments_);
534
+ };
535
+ this.prependHook(event, hook);
536
+ }
537
+ /**
538
+ * Adds a handler that only executes once for a specific event
539
+ * @param event
540
+ * @param handler
541
+ */
542
+ onceHook(event, handler) {
543
+ this.validateHookName(event);
544
+ if (!this.checkDeprecatedHook(event)) {
545
+ return;
546
+ }
547
+ const hook = async (...arguments_) => {
548
+ this.removeHook(event, hook);
549
+ return handler(...arguments_);
550
+ };
551
+ this.onHook(event, hook);
552
+ }
553
+ /**
554
+ * Removes a handler function for a specific event
555
+ * @param {string} event
556
+ * @param {Hook} handler
557
+ * @returns {void}
558
+ */
559
+ removeHook(event, handler) {
560
+ this.validateHookName(event);
561
+ if (!this.checkDeprecatedHook(event)) {
562
+ return;
563
+ }
564
+ const eventHandlers = this._hooks.get(event);
565
+ if (eventHandlers) {
566
+ const index = eventHandlers.indexOf(handler);
567
+ if (index !== -1) {
568
+ eventHandlers.splice(index, 1);
569
+ }
570
+ }
571
+ }
572
+ /**
573
+ * Removes all handlers for a specific event
574
+ * @param {Array<HookEntry>} hooks
575
+ * @returns {void}
576
+ */
577
+ removeHooks(hooks) {
578
+ for (const hook of hooks) {
579
+ this.removeHook(hook.event, hook.handler);
580
+ }
581
+ }
582
+ /**
583
+ * Calls all handlers for a specific event
584
+ * @param {string} event
585
+ * @param {T[]} arguments_
586
+ * @returns {Promise<void>}
587
+ */
588
+ async hook(event, ...arguments_) {
589
+ this.validateHookName(event);
590
+ if (!this.checkDeprecatedHook(event)) {
591
+ return;
592
+ }
593
+ const eventHandlers = this._hooks.get(event);
594
+ if (eventHandlers) {
595
+ for (const handler of eventHandlers) {
596
+ try {
597
+ await handler(...arguments_);
598
+ } catch (error) {
599
+ const message = `${event}: ${error.message}`;
600
+ this.emit("error", new Error(message));
601
+ if (this._throwOnHookError) {
602
+ throw new Error(message);
603
+ }
604
+ }
605
+ }
606
+ }
607
+ }
608
+ /**
609
+ * Calls all synchronous handlers for a specific event.
610
+ * Async handlers (declared with `async` keyword) are silently skipped.
611
+ *
612
+ * Note: The `hook` method is preferred as it executes both sync and async functions.
613
+ * Use `hookSync` only when you specifically need synchronous execution.
614
+ * @param {string} event
615
+ * @param {T[]} arguments_
616
+ * @returns {void}
617
+ */
618
+ hookSync(event, ...arguments_) {
619
+ this.validateHookName(event);
620
+ if (!this.checkDeprecatedHook(event)) {
621
+ return;
622
+ }
623
+ const eventHandlers = this._hooks.get(event);
624
+ if (eventHandlers) {
625
+ for (const handler of eventHandlers) {
626
+ if (handler.constructor.name === "AsyncFunction") {
627
+ continue;
628
+ }
629
+ try {
630
+ handler(...arguments_);
631
+ } catch (error) {
632
+ const message = `${event}: ${error.message}`;
633
+ this.emit("error", new Error(message));
634
+ if (this._throwOnHookError) {
635
+ throw new Error(message);
636
+ }
637
+ }
638
+ }
639
+ }
640
+ }
641
+ /**
642
+ * Prepends the word `before` to your hook. Example is event is `test`, the before hook is `before:test`.
643
+ * @param {string} event - The event name
644
+ * @param {T[]} arguments_ - The arguments to pass to the hook
645
+ */
646
+ async beforeHook(event, ...arguments_) {
647
+ await this.hook(`before:${event}`, ...arguments_);
648
+ }
649
+ /**
650
+ * Prepends the word `after` to your hook. Example is event is `test`, the after hook is `after:test`.
651
+ * @param {string} event - The event name
652
+ * @param {T[]} arguments_ - The arguments to pass to the hook
653
+ */
654
+ async afterHook(event, ...arguments_) {
655
+ await this.hook(`after:${event}`, ...arguments_);
656
+ }
657
+ /**
658
+ * Calls all handlers for a specific event. This is an alias for `hook` and is provided for
659
+ * compatibility with other libraries that use the `callHook` method.
660
+ * @param {string} event
661
+ * @param {T[]} arguments_
662
+ * @returns {Promise<void>}
663
+ */
664
+ async callHook(event, ...arguments_) {
665
+ await this.hook(event, ...arguments_);
666
+ }
667
+ /**
668
+ * Gets all hooks for a specific event
669
+ * @param {string} event
670
+ * @returns {Hook[]}
671
+ */
672
+ getHooks(event) {
673
+ this.validateHookName(event);
674
+ if (!this.checkDeprecatedHook(event)) {
675
+ return void 0;
676
+ }
677
+ return this._hooks.get(event);
678
+ }
679
+ /**
680
+ * Removes all hooks
681
+ * @returns {void}
682
+ */
683
+ clearHooks() {
684
+ this._hooks.clear();
685
+ }
686
+ };
687
+
688
+ // node_modules/.pnpm/@hyphen+browser-sdk@1.1.1/node_modules/@hyphen/browser-sdk/dist/index.js
689
+ var __defProp2 = Object.defineProperty;
690
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
691
+ var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
692
+ var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
7
693
  var ToggleEvents = /* @__PURE__ */ (function(ToggleEvents2) {
8
694
  ToggleEvents2["Error"] = "error";
9
695
  return ToggleEvents2;
@@ -11,13 +697,13 @@ var ToggleEvents = /* @__PURE__ */ (function(ToggleEvents2) {
11
697
  var _Toggle = class _Toggle2 extends Hookified {
12
698
  constructor(options) {
13
699
  super();
14
- __publicField(this, "_publicApiKey");
15
- __publicField(this, "_organizationId");
16
- __publicField(this, "_applicationId");
17
- __publicField(this, "_environment");
18
- __publicField(this, "_horizonUrls", []);
19
- __publicField(this, "_defaultContext");
20
- __publicField(this, "_defaultTargetingKey", `${Math.random().toString(36).substring(7)}`);
700
+ __publicField2(this, "_publicApiKey");
701
+ __publicField2(this, "_organizationId");
702
+ __publicField2(this, "_applicationId");
703
+ __publicField2(this, "_environment");
704
+ __publicField2(this, "_horizonUrls", []);
705
+ __publicField2(this, "_defaultContext");
706
+ __publicField2(this, "_defaultTargetingKey", `${Math.random().toString(36).substring(7)}`);
21
707
  if (options == null ? void 0 : options.applicationId) {
22
708
  this._applicationId = options.applicationId;
23
709
  }
@@ -568,3 +1254,8 @@ export {
568
1254
  withToggleProvider
569
1255
  };
570
1256
  /* v8 ignore next -- @preserve */
1257
+ /*! Bundled license information:
1258
+
1259
+ hookified/dist/node/index.js:
1260
+ (* v8 ignore next -- @preserve *)
1261
+ */