@vpmedia/simplify 1.67.0 → 1.68.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [1.68.0] - 2026-02-04
2
+
3
+ ### 🚜 Refactor
4
+
5
+ - Use event emitter custom internally
6
+
7
+ ### ⚙️ Miscellaneous Tasks
8
+
9
+ - Release
10
+ - *(release)* V1.68.0
1
11
  ## [1.67.0] - 2026-02-04
2
12
 
3
13
  ### 🚀 Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpmedia/simplify",
3
- "version": "1.67.0",
3
+ "version": "1.68.0",
4
4
  "description": "@vpmedia/simplify",
5
5
  "author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
6
6
  "license": "MIT",
@@ -18,9 +18,6 @@
18
18
  "main": "./src/index.js",
19
19
  "types": "./types/index.d.ts",
20
20
  "type": "module",
21
- "dependencies": {
22
- "eventemitter3": "^5.0.4"
23
- },
24
21
  "optionalDependencies": {
25
22
  "@sentry/browser": "^10.38.0"
26
23
  },
@@ -31,12 +28,12 @@
31
28
  "@types/node": "^25.2.0",
32
29
  "@vitest/coverage-v8": "^4.0.18",
33
30
  "eslint": "^9.39.2",
34
- "eslint-plugin-jsdoc": "^62.5.0",
31
+ "eslint-plugin-jsdoc": "^62.5.1",
35
32
  "eslint-plugin-oxlint": "^1.43.0",
36
33
  "eslint-plugin-unicorn": "^62.0.0",
37
34
  "globals": "^17.3.0",
38
35
  "jsdom": "^28.0.0",
39
- "msw": "^2.12.7",
36
+ "msw": "^2.12.8",
40
37
  "oxlint": "^1.43.0",
41
38
  "oxlint-tsgolint": "^0.11.4",
42
39
  "prettier": "^3.8.1",
package/src/index.js CHANGED
@@ -21,7 +21,7 @@ export { TypeCheckError } from './typecheck/TypeCheckError.js';
21
21
  export { typeCheck, typeCheckArray, typeCheckEnum } from './typecheck/util.js';
22
22
  export { delayPromise, loadJSON } from './util/async.js';
23
23
  export { getErrorDetails, getTypedError } from './util/error.js';
24
- export { EventEmitter3 } from './util/event_emitter.js';
24
+ export { EventEmitter as EventEmitter3 } from './util/event_emitter.js';
25
25
  export { FetchError, fetchRetry, HTTP_0_ANY } from './util/fetch.js';
26
26
  export {
27
27
  deg2rad,
@@ -1,12 +1,13 @@
1
1
  /* oxlint-disable prefer-await-to-callbacks */
2
+ /* eslint-disable unicorn/prefer-event-target */
2
3
 
3
4
  /**
4
5
  * Page lifecycle helper.
5
6
  * @see https://developer.chrome.com/docs/web-platform/page-lifecycle-api
6
7
  */
7
8
 
8
- import { EventEmitter } from 'eventemitter3';
9
9
  import { Logger } from '../logging/Logger.js';
10
+ import { EventEmitter } from '../util/event_emitter.js';
10
11
  import {
11
12
  DOCUMENT_STATE_CHANGE_EVENT,
12
13
  DOCUMENT_STATE_DOM_LOADED,
@@ -32,7 +32,7 @@ class Listener {
32
32
  * Event emitter implementation inspired by Node.js/EventEmitter3.
33
33
  * Allows registering, emitting, and removing event listeners.
34
34
  */
35
- export class EventEmitter3 {
35
+ export class EventEmitter {
36
36
  #events;
37
37
 
38
38
  constructor() {
@@ -102,7 +102,7 @@ export class EventEmitter3 {
102
102
  * @param {EventListener} fn - Listener callback.
103
103
  * @param {any} context - Execution context for the callback.
104
104
  * @param {boolean} once - Whether the listener is one-time.
105
- * @returns {EventEmitter3} The emitter instance.
105
+ * @returns {EventEmitter} The emitter instance.
106
106
  */
107
107
  #addListener(event, fn, context, once) {
108
108
  if (typeof fn !== 'function') {
@@ -126,7 +126,7 @@ export class EventEmitter3 {
126
126
  * @param {string | symbol} event - Event name.
127
127
  * @param {EventListener} fn - Listener callback.
128
128
  * @param {any} [context] - Optional execution context.
129
- * @returns {EventEmitter3} The emitter instance.
129
+ * @returns {EventEmitter} The emitter instance.
130
130
  */
131
131
  on(event, fn, context) {
132
132
  return this.#addListener(event, fn, context, false);
@@ -138,7 +138,7 @@ export class EventEmitter3 {
138
138
  * @param {string | symbol} event - Event name.
139
139
  * @param {EventListener} fn - Listener callback.
140
140
  * @param {any} [context] - Optional execution context.
141
- * @returns {EventEmitter3} The emitter instance.
141
+ * @returns {EventEmitter} The emitter instance.
142
142
  */
143
143
  once(event, fn, context) {
144
144
  return this.#addListener(event, fn, context, true);
@@ -149,7 +149,7 @@ export class EventEmitter3 {
149
149
  * @param {string | symbol} event - Event name.
150
150
  * @param {EventListener} [fn] - Listener callback to remove.
151
151
  * @param {any} [context] - Context to match when removing.
152
- * @returns {EventEmitter3} The emitter instance.
152
+ * @returns {EventEmitter} The emitter instance.
153
153
  */
154
154
  off(event, fn, context) {
155
155
  if (!this.#events.has(event)) {
@@ -184,7 +184,7 @@ export class EventEmitter3 {
184
184
  * Remove all listeners from the emitter,
185
185
  * or all listeners for a specific event.
186
186
  * @param {string | symbol} [event] - Optional event name.
187
- * @returns {EventEmitter3} The emitter instance.
187
+ * @returns {EventEmitter} The emitter instance.
188
188
  */
189
189
  removeAllListeners(event) {
190
190
  if (event === undefined) {
@@ -1,37 +1,37 @@
1
- /* eslint-disable no-empty-function, no-invalid-this, func-names, func-style, unicorn/consistent-function-scoping */
1
+ /* eslint-disable unicorn/prefer-event-target, no-empty-function, no-invalid-this, func-names, func-style, unicorn/consistent-function-scoping */
2
2
 
3
3
  import { describe, it, expect } from 'vitest';
4
- import { EventEmitter3 } from './event_emitter.js';
4
+ import { EventEmitter } from './event_emitter.js';
5
5
 
6
6
  describe('EventEmitter3 basics', () => {
7
7
  it('can be instantiated', () => {
8
- const e = new EventEmitter3();
9
- expect(e).toBeInstanceOf(EventEmitter3);
8
+ const e = new EventEmitter();
9
+ expect(e).toBeInstanceOf(EventEmitter);
10
10
  });
11
11
 
12
12
  it('supports subclassing', () => {
13
- class Beast extends EventEmitter3 {}
13
+ class Beast extends EventEmitter {}
14
14
  const beast = new Beast();
15
15
 
16
16
  expect(beast).toBeInstanceOf(Beast);
17
- expect(beast).toBeInstanceOf(EventEmitter3);
17
+ expect(beast).toBeInstanceOf(EventEmitter);
18
18
  });
19
19
  });
20
20
 
21
21
  describe('emit()', () => {
22
22
  it('returns false when no listeners exist', () => {
23
- const e = new EventEmitter3();
23
+ const e = new EventEmitter();
24
24
  expect(e.emit('foo')).toBe(false);
25
25
  });
26
26
 
27
27
  it('returns true when listeners exist', () => {
28
- const e = new EventEmitter3();
28
+ const e = new EventEmitter();
29
29
  e.on('foo', () => {});
30
30
  expect(e.emit('foo')).toBe(true);
31
31
  });
32
32
 
33
33
  it('invokes listeners with provided arguments', async () => {
34
- const e = new EventEmitter3();
34
+ const e = new EventEmitter();
35
35
 
36
36
  await new Promise((resolve) => {
37
37
  e.on('foo', (a, b) => {
@@ -45,7 +45,7 @@ describe('emit()', () => {
45
45
  });
46
46
 
47
47
  it('binds the correct context', async () => {
48
- const e = new EventEmitter3();
48
+ const e = new EventEmitter();
49
49
  const ctx = { value: 42 };
50
50
 
51
51
  await new Promise((resolve) => {
@@ -64,7 +64,7 @@ describe('emit()', () => {
64
64
  });
65
65
 
66
66
  it('supports many listeners for the same event', () => {
67
- const e = new EventEmitter3();
67
+ const e = new EventEmitter();
68
68
  const calls = [];
69
69
 
70
70
  e.on('foo', () => calls.push(1));
@@ -78,7 +78,7 @@ describe('emit()', () => {
78
78
 
79
79
  describe('once()', () => {
80
80
  it('fires the listener only once', () => {
81
- const e = new EventEmitter3();
81
+ const e = new EventEmitter();
82
82
  let calls = 0;
83
83
 
84
84
  e.once('foo', () => {
@@ -93,7 +93,7 @@ describe('once()', () => {
93
93
  });
94
94
 
95
95
  it('passes arguments correctly', async () => {
96
- const e = new EventEmitter3();
96
+ const e = new EventEmitter();
97
97
 
98
98
  await new Promise((resolve) => {
99
99
  e.once('foo', (...args) => {
@@ -108,13 +108,13 @@ describe('once()', () => {
108
108
 
109
109
  describe('listeners() and listenerCount()', () => {
110
110
  it('returns an empty array when no listeners exist', () => {
111
- const e = new EventEmitter3();
111
+ const e = new EventEmitter();
112
112
  expect(e.listeners('foo')).toEqual([]);
113
113
  expect(e.listenerCount('foo')).toBe(0);
114
114
  });
115
115
 
116
116
  it('returns only listener functions (not internals)', () => {
117
- const e = new EventEmitter3();
117
+ const e = new EventEmitter();
118
118
  function fn() {}
119
119
 
120
120
  e.on('foo', fn);
@@ -123,7 +123,7 @@ describe('listeners() and listenerCount()', () => {
123
123
  });
124
124
 
125
125
  it('does not expose internal listener storage', () => {
126
- const e = new EventEmitter3();
126
+ const e = new EventEmitter();
127
127
  function fn() {}
128
128
 
129
129
  e.on('foo', fn);
@@ -136,7 +136,7 @@ describe('listeners() and listenerCount()', () => {
136
136
 
137
137
  describe('off()', () => {
138
138
  it('removes all listeners for an event when fn is omitted', () => {
139
- const e = new EventEmitter3();
139
+ const e = new EventEmitter();
140
140
 
141
141
  e.on('foo', () => {});
142
142
  e.on('foo', () => {});
@@ -147,7 +147,7 @@ describe('off()', () => {
147
147
  });
148
148
 
149
149
  it('removes a specific listener', () => {
150
- const e = new EventEmitter3();
150
+ const e = new EventEmitter();
151
151
  function fn() {}
152
152
 
153
153
  e.on('foo', fn);
@@ -157,7 +157,7 @@ describe('off()', () => {
157
157
  });
158
158
 
159
159
  it('removes listeners matching both function and context', () => {
160
- const e = new EventEmitter3();
160
+ const e = new EventEmitter();
161
161
  const ctx1 = {};
162
162
  const ctx2 = {};
163
163
  function fn() {}
@@ -173,7 +173,7 @@ describe('off()', () => {
173
173
 
174
174
  describe('removeAllListeners()', () => {
175
175
  it('removes listeners for a single event', () => {
176
- const e = new EventEmitter3();
176
+ const e = new EventEmitter();
177
177
 
178
178
  e.on('foo', () => {});
179
179
  e.on('bar', () => {});
@@ -185,7 +185,7 @@ describe('removeAllListeners()', () => {
185
185
  });
186
186
 
187
187
  it('removes all listeners when no event is specified', () => {
188
- const e = new EventEmitter3();
188
+ const e = new EventEmitter();
189
189
 
190
190
  e.on('foo', () => {});
191
191
  e.on('bar', () => {});
@@ -198,12 +198,12 @@ describe('removeAllListeners()', () => {
198
198
 
199
199
  describe('eventNames()', () => {
200
200
  it('returns an empty array when no events exist', () => {
201
- const e = new EventEmitter3();
201
+ const e = new EventEmitter();
202
202
  expect(e.eventNames()).toEqual([]);
203
203
  });
204
204
 
205
205
  it('returns all registered event names', () => {
206
- const e = new EventEmitter3();
206
+ const e = new EventEmitter();
207
207
 
208
208
  e.on('foo', () => {});
209
209
  e.on('bar', () => {});
@@ -213,7 +213,7 @@ describe('eventNames()', () => {
213
213
  });
214
214
 
215
215
  it('supports symbol event names', () => {
216
- const e = new EventEmitter3();
216
+ const e = new EventEmitter();
217
217
  const sym = Symbol('test');
218
218
 
219
219
  e.on(sym, () => {});
@@ -221,8 +221,8 @@ describe('eventNames()', () => {
221
221
  });
222
222
 
223
223
  it('events map is instance field', () => {
224
- const e1 = new EventEmitter3();
225
- const e2 = new EventEmitter3();
224
+ const e1 = new EventEmitter();
225
+ const e2 = new EventEmitter();
226
226
  e1.on('event', () => {});
227
227
  expect(e1.listenerCount('event')).toBe(1);
228
228
  expect(e1.listenerCount('no-event')).toBe(0);
package/types/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { OpenTelemetryLogHandler } from "./logging/OpenTelemetryLogHandler.js";
10
10
  export { SentryLogHandler } from "./logging/SentryLogHandler.js";
11
11
  export { typeChecker } from "./typecheck/TypeChecker.js";
12
12
  export { TypeCheckError } from "./typecheck/TypeCheckError.js";
13
- export { EventEmitter3 } from "./util/event_emitter.js";
13
+ export { EventEmitter as EventEmitter3 } from "./util/event_emitter.js";
14
14
  export { serverDataToState } from "./util/state.js";
15
15
  export { formatLogMessage, getLogLevelName } from "./logging/util.js";
16
16
  export { addPageLifecycleCallback, getDocumentState, getPageLifecycleEventEmitter, getPageLifecycleState, initPageLifecycle, isPageLifecycleInitialized } from "./pagelifecycle/util.js";
@@ -4,5 +4,5 @@ export function getDocumentState(): import("./typedef.js").DocumentState | null
4
4
  export function getPageLifecycleEventEmitter(): EventEmitter;
5
5
  export function isPageLifecycleInitialized(): boolean;
6
6
  export function addPageLifecycleCallback(state: import("./typedef.js").DocumentState | import("./typedef.js").PageLifecycleState, callback: () => void): void;
7
- import { EventEmitter } from 'eventemitter3';
7
+ import { EventEmitter } from '../util/event_emitter.js';
8
8
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/pagelifecycle/util.js"],"names":[],"mappings":"AAkGO,0CAyBN;AAMM,yCAFM,MAAM,GAAG,IAAI,GAAG,SAAS,CAE8B;AAM7D,oCAFM,OAAO,cAAc,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,CAEV;AAMnD,gDAFM,YAAY,CAOxB;AAMM,8CAFM,OAAO,CAEyC;AAOtD,gDAHI,OAAO,cAAc,EAAE,aAAa,GAAG,OAAO,cAAc,EAAE,kBAAkB,YAChF,MAAM,IAAI,QAMpB;6BA5J4B,eAAe"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/pagelifecycle/util.js"],"names":[],"mappings":"AAmGO,0CAyBN;AAMM,yCAFM,MAAM,GAAG,IAAI,GAAG,SAAS,CAE8B;AAM7D,oCAFM,OAAO,cAAc,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,CAEV;AAMnD,gDAFM,YAAY,CAOxB;AAMM,8CAFM,OAAO,CAEyC;AAOtD,gDAHI,OAAO,cAAc,EAAE,aAAa,GAAG,OAAO,cAAc,EAAE,kBAAkB,YAChF,MAAM,IAAI,QAMpB;6BA3J4B,0BAA0B"}
@@ -2,7 +2,7 @@
2
2
  * Event emitter implementation inspired by Node.js/EventEmitter3.
3
3
  * Allows registering, emitting, and removing event listeners.
4
4
  */
5
- export class EventEmitter3 {
5
+ export class EventEmitter {
6
6
  /**
7
7
  * Get all registered event names.
8
8
  * @returns {(string | symbol)[]} Array of event identifiers.
@@ -33,33 +33,33 @@ export class EventEmitter3 {
33
33
  * @param {string | symbol} event - Event name.
34
34
  * @param {EventListener} fn - Listener callback.
35
35
  * @param {any} [context] - Optional execution context.
36
- * @returns {EventEmitter3} The emitter instance.
36
+ * @returns {EventEmitter} The emitter instance.
37
37
  */
38
- on(event: string | symbol, fn: EventListener, context?: any): EventEmitter3;
38
+ on(event: string | symbol, fn: EventListener, context?: any): EventEmitter;
39
39
  /**
40
40
  * Register a one-time listener for an event.
41
41
  * The listener is removed after its first invocation.
42
42
  * @param {string | symbol} event - Event name.
43
43
  * @param {EventListener} fn - Listener callback.
44
44
  * @param {any} [context] - Optional execution context.
45
- * @returns {EventEmitter3} The emitter instance.
45
+ * @returns {EventEmitter} The emitter instance.
46
46
  */
47
- once(event: string | symbol, fn: EventListener, context?: any): EventEmitter3;
47
+ once(event: string | symbol, fn: EventListener, context?: any): EventEmitter;
48
48
  /**
49
49
  * Remove a specific listener, or all listeners for an event.
50
50
  * @param {string | symbol} event - Event name.
51
51
  * @param {EventListener} [fn] - Listener callback to remove.
52
52
  * @param {any} [context] - Context to match when removing.
53
- * @returns {EventEmitter3} The emitter instance.
53
+ * @returns {EventEmitter} The emitter instance.
54
54
  */
55
- off(event: string | symbol, fn?: EventListener, context?: any): EventEmitter3;
55
+ off(event: string | symbol, fn?: EventListener, context?: any): EventEmitter;
56
56
  /**
57
57
  * Remove all listeners from the emitter,
58
58
  * or all listeners for a specific event.
59
59
  * @param {string | symbol} [event] - Optional event name.
60
- * @returns {EventEmitter3} The emitter instance.
60
+ * @returns {EventEmitter} The emitter instance.
61
61
  */
62
- removeAllListeners(event?: string | symbol): EventEmitter3;
62
+ removeAllListeners(event?: string | symbol): EventEmitter;
63
63
  #private;
64
64
  }
65
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"event_emitter.d.ts","sourceRoot":"","sources":["../../src/util/event_emitter.js"],"names":[],"mappings":"AA8BA;;;GAGG;AACH;IAWE;;;OAGG;IACH,cAFa,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAI/B;IAED;;;;OAIG;IACH,iBAHW,MAAM,GAAG,MAAM,GACb,aAAa,EAAE,CAK3B;IAED;;;;OAIG;IACH,qBAHW,MAAM,GAAG,MAAM,GACb,MAAM,CAKlB;IAED;;;;;;OAMG;IACH,YAJW,MAAM,GAAG,MAAM,WACZ,GAAG,EAAA,GACJ,OAAO,CAkBnB;IA2BD;;;;;;OAMG;IACH,UALW,MAAM,GAAG,MAAM,MACf,aAAa,YACb,GAAG,GACD,aAAa,CAIzB;IAED;;;;;;;OAOG;IACH,YALW,MAAM,GAAG,MAAM,MACf,aAAa,YACb,GAAG,GACD,aAAa,CAIzB;IAED;;;;;;OAMG;IACH,WALW,MAAM,GAAG,MAAM,OACf,aAAa,YACb,GAAG,GACD,aAAa,CA6BzB;IAED;;;;;OAKG;IACH,2BAHW,MAAM,GAAG,MAAM,GACb,aAAa,CAUzB;;CACF;;;;sCAlMa,GAAG,EAAA,KACJ,IAAI"}
1
+ {"version":3,"file":"event_emitter.d.ts","sourceRoot":"","sources":["../../src/util/event_emitter.js"],"names":[],"mappings":"AA8BA;;;GAGG;AACH;IAWE;;;OAGG;IACH,cAFa,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAI/B;IAED;;;;OAIG;IACH,iBAHW,MAAM,GAAG,MAAM,GACb,aAAa,EAAE,CAK3B;IAED;;;;OAIG;IACH,qBAHW,MAAM,GAAG,MAAM,GACb,MAAM,CAKlB;IAED;;;;;;OAMG;IACH,YAJW,MAAM,GAAG,MAAM,WACZ,GAAG,EAAA,GACJ,OAAO,CAkBnB;IA2BD;;;;;;OAMG;IACH,UALW,MAAM,GAAG,MAAM,MACf,aAAa,YACb,GAAG,GACD,YAAY,CAIxB;IAED;;;;;;;OAOG;IACH,YALW,MAAM,GAAG,MAAM,MACf,aAAa,YACb,GAAG,GACD,YAAY,CAIxB;IAED;;;;;;OAMG;IACH,WALW,MAAM,GAAG,MAAM,OACf,aAAa,YACb,GAAG,GACD,YAAY,CA6BxB;IAED;;;;;OAKG;IACH,2BAHW,MAAM,GAAG,MAAM,GACb,YAAY,CAUxB;;CACF;;;;sCAlMa,GAAG,EAAA,KACJ,IAAI"}