@digipair/skill-sse 0.114.1 → 0.114.3

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/index.cjs.js CHANGED
@@ -1,1237 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var http = require('http');
4
- var crypto = require('crypto');
5
- var events = require('events');
3
+ var betterSse = require('better-sse');
6
4
  var engine = require('@digipair/engine');
7
5
 
8
- // src/Session.ts
9
- function _array_like_to_array(arr, len) {
10
- if (len == null || len > arr.length) len = arr.length;
11
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
12
- return arr2;
13
- }
14
- function _array_with_holes(arr) {
15
- if (Array.isArray(arr)) return arr;
16
- }
17
- function _array_without_holes(arr) {
18
- if (Array.isArray(arr)) return _array_like_to_array(arr);
19
- }
20
- function _assert_this_initialized(self) {
21
- if (self === void 0) {
22
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
23
- }
24
- return self;
25
- }
26
- function _async_iterator(iterable) {
27
- var method, async, sync, retry = 2;
28
- for("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;){
29
- if (async && null != (method = iterable[async])) return method.call(iterable);
30
- if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
31
- async = "@@asyncIterator", sync = "@@iterator";
32
- }
33
- throw new TypeError("Object is not async iterable");
34
- }
35
- function AsyncFromSyncIterator(s) {
36
- function AsyncFromSyncIteratorContinuation(r) {
37
- if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
38
- var done = r.done;
39
- return Promise.resolve(r.value).then(function(value) {
40
- return {
41
- value: value,
42
- done: done
43
- };
44
- });
45
- }
46
- return AsyncFromSyncIterator = function(s) {
47
- this.s = s, this.n = s.next;
48
- }, AsyncFromSyncIterator.prototype = {
49
- s: null,
50
- n: null,
51
- next: function() {
52
- return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
53
- },
54
- return: function(value) {
55
- var ret = this.s.return;
56
- return void 0 === ret ? Promise.resolve({
57
- value: value,
58
- done: true
59
- }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
60
- },
61
- throw: function(value) {
62
- var thr = this.s.return;
63
- return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
64
- }
65
- }, new AsyncFromSyncIterator(s);
66
- }
67
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
68
- try {
69
- var info = gen[key](arg);
70
- var value = info.value;
71
- } catch (error) {
72
- reject(error);
73
- return;
74
- }
75
- if (info.done) {
76
- resolve(value);
77
- } else {
78
- Promise.resolve(value).then(_next, _throw);
79
- }
80
- }
81
- function _async_to_generator(fn) {
82
- return function() {
83
- var self = this, args = arguments;
84
- return new Promise(function(resolve, reject) {
85
- var gen = fn.apply(self, args);
86
- function _next(value) {
87
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
88
- }
89
- function _throw(err) {
90
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
91
- }
92
- _next(undefined);
93
- });
94
- };
95
- }
96
- function _class_call_check(instance, Constructor) {
97
- if (!(instance instanceof Constructor)) {
98
- throw new TypeError("Cannot call a class as a function");
99
- }
100
- }
101
- function _construct(Parent, args, Class) {
102
- if (_is_native_reflect_construct()) {
103
- _construct = Reflect.construct;
104
- } else {
105
- _construct = function construct(Parent, args, Class) {
106
- var a = [
107
- null
108
- ];
109
- a.push.apply(a, args);
110
- var Constructor = Function.bind.apply(Parent, a);
111
- var instance = new Constructor();
112
- if (Class) _set_prototype_of(instance, Class.prototype);
113
- return instance;
114
- };
115
- }
116
- return _construct.apply(null, arguments);
117
- }
118
- function _defineProperties(target, props) {
119
- for(var i = 0; i < props.length; i++){
120
- var descriptor = props[i];
121
- descriptor.enumerable = descriptor.enumerable || false;
122
- descriptor.configurable = true;
123
- if ("value" in descriptor) descriptor.writable = true;
124
- Object.defineProperty(target, descriptor.key, descriptor);
125
- }
126
- }
127
- function _create_class(Constructor, protoProps, staticProps) {
128
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
129
- return Constructor;
130
- }
131
- function _define_property(obj, key, value) {
132
- if (key in obj) {
133
- Object.defineProperty(obj, key, {
134
- value: value,
135
- enumerable: true,
136
- configurable: true,
137
- writable: true
138
- });
139
- } else {
140
- obj[key] = value;
141
- }
142
- return obj;
143
- }
144
- function _get(target, property, receiver) {
145
- if (typeof Reflect !== "undefined" && Reflect.get) {
146
- _get = Reflect.get;
147
- } else {
148
- _get = function get(target, property, receiver) {
149
- var base = _super_prop_base(target, property);
150
- if (!base) return;
151
- var desc = Object.getOwnPropertyDescriptor(base, property);
152
- if (desc.get) {
153
- return desc.get.call(receiver || target);
154
- }
155
- return desc.value;
156
- };
157
- }
158
- return _get(target, property, receiver || target);
159
- }
160
- function _get_prototype_of(o) {
161
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
162
- return o.__proto__ || Object.getPrototypeOf(o);
163
- };
164
- return _get_prototype_of(o);
165
- }
166
- function _inherits(subClass, superClass) {
167
- if (typeof superClass !== "function" && superClass !== null) {
168
- throw new TypeError("Super expression must either be null or a function");
169
- }
170
- subClass.prototype = Object.create(superClass && superClass.prototype, {
171
- constructor: {
172
- value: subClass,
173
- writable: true,
174
- configurable: true
175
- }
176
- });
177
- if (superClass) _set_prototype_of(subClass, superClass);
178
- }
179
- function _instanceof(left, right) {
180
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
181
- return !!right[Symbol.hasInstance](left);
182
- } else {
183
- return left instanceof right;
184
- }
185
- }
186
- function _is_native_function(fn) {
187
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
188
- }
189
- function _iterable_to_array(iter) {
190
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
191
- }
192
- function _iterable_to_array_limit(arr, i) {
193
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
194
- if (_i == null) return;
195
- var _arr = [];
196
- var _n = true;
197
- var _d = false;
198
- var _s, _e;
199
- try {
200
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
201
- _arr.push(_s.value);
202
- if (i && _arr.length === i) break;
203
- }
204
- } catch (err) {
205
- _d = true;
206
- _e = err;
207
- } finally{
208
- try {
209
- if (!_n && _i["return"] != null) _i["return"]();
210
- } finally{
211
- if (_d) throw _e;
212
- }
213
- }
214
- return _arr;
215
- }
216
- function _non_iterable_rest() {
217
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
218
- }
219
- function _non_iterable_spread() {
220
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
221
- }
222
- function _possible_constructor_return(self, call) {
223
- if (call && (_type_of(call) === "object" || typeof call === "function")) {
224
- return call;
225
- }
226
- return _assert_this_initialized(self);
227
- }
228
- function _set_prototype_of(o, p) {
229
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
230
- o.__proto__ = p;
231
- return o;
232
- };
233
- return _set_prototype_of(o, p);
234
- }
235
- function _sliced_to_array(arr, i) {
236
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
237
- }
238
- function _super_prop_base(object, property) {
239
- while(!Object.prototype.hasOwnProperty.call(object, property)){
240
- object = _get_prototype_of(object);
241
- if (object === null) break;
242
- }
243
- return object;
244
- }
245
- function _to_consumable_array(arr) {
246
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
247
- }
248
- function _type_of(obj) {
249
- "@swc/helpers - typeof";
250
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
251
- }
252
- function _unsupported_iterable_to_array(o, minLen) {
253
- if (!o) return;
254
- if (typeof o === "string") return _array_like_to_array(o, minLen);
255
- var n = Object.prototype.toString.call(o).slice(8, -1);
256
- if (n === "Object" && o.constructor) n = o.constructor.name;
257
- if (n === "Map" || n === "Set") return Array.from(n);
258
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
259
- }
260
- function _wrap_native_super(Class) {
261
- var _cache = typeof Map === "function" ? new Map() : undefined;
262
- _wrap_native_super = function wrapNativeSuper(Class) {
263
- if (Class === null || !_is_native_function(Class)) return Class;
264
- if (typeof Class !== "function") {
265
- throw new TypeError("Super expression must either be null or a function");
266
- }
267
- if (typeof _cache !== "undefined") {
268
- if (_cache.has(Class)) return _cache.get(Class);
269
- _cache.set(Class, Wrapper);
270
- }
271
- function Wrapper() {
272
- return _construct(Class, arguments, _get_prototype_of(this).constructor);
273
- }
274
- Wrapper.prototype = Object.create(Class.prototype, {
275
- constructor: {
276
- value: Wrapper,
277
- enumerable: false,
278
- writable: true,
279
- configurable: true
280
- }
281
- });
282
- return _set_prototype_of(Wrapper, Class);
283
- };
284
- return _wrap_native_super(Class);
285
- }
286
- function _is_native_reflect_construct() {
287
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
288
- if (Reflect.construct.sham) return false;
289
- if (typeof Proxy === "function") return true;
290
- try {
291
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
292
- return true;
293
- } catch (e) {
294
- return false;
295
- }
296
- }
297
- function _create_super(Derived) {
298
- var hasNativeReflectConstruct = _is_native_reflect_construct();
299
- return function _createSuperInternal() {
300
- var Super = _get_prototype_of(Derived), result;
301
- if (hasNativeReflectConstruct) {
302
- var NewTarget = _get_prototype_of(this).constructor;
303
- result = Reflect.construct(Super, arguments, NewTarget);
304
- } else {
305
- result = Super.apply(this, arguments);
306
- }
307
- return _possible_constructor_return(this, result);
308
- };
309
- }
310
- function _ts_generator(thisArg, body) {
311
- var f, y, t, g, _ = {
312
- label: 0,
313
- sent: function() {
314
- if (t[0] & 1) throw t[1];
315
- return t[1];
316
- },
317
- trys: [],
318
- ops: []
319
- };
320
- return g = {
321
- next: verb(0),
322
- "throw": verb(1),
323
- "return": verb(2)
324
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
325
- return this;
326
- }), g;
327
- function verb(n) {
328
- return function(v) {
329
- return step([
330
- n,
331
- v
332
- ]);
333
- };
334
- }
335
- function step(op) {
336
- if (f) throw new TypeError("Generator is already executing.");
337
- while(_)try {
338
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
339
- if (y = 0, t) op = [
340
- op[0] & 2,
341
- t.value
342
- ];
343
- switch(op[0]){
344
- case 0:
345
- case 1:
346
- t = op;
347
- break;
348
- case 4:
349
- _.label++;
350
- return {
351
- value: op[1],
352
- done: false
353
- };
354
- case 5:
355
- _.label++;
356
- y = op[1];
357
- op = [
358
- 0
359
- ];
360
- continue;
361
- case 7:
362
- op = _.ops.pop();
363
- _.trys.pop();
364
- continue;
365
- default:
366
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
367
- _ = 0;
368
- continue;
369
- }
370
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
371
- _.label = op[1];
372
- break;
373
- }
374
- if (op[0] === 6 && _.label < t[1]) {
375
- _.label = t[1];
376
- t = op;
377
- break;
378
- }
379
- if (t && _.label < t[2]) {
380
- _.label = t[2];
381
- _.ops.push(op);
382
- break;
383
- }
384
- if (t[2]) _.ops.pop();
385
- _.trys.pop();
386
- continue;
387
- }
388
- op = body.call(thisArg, _);
389
- } catch (e) {
390
- op = [
391
- 6,
392
- e
393
- ];
394
- y = 0;
395
- } finally{
396
- f = t = 0;
397
- }
398
- if (op[0] & 5) throw op[1];
399
- return {
400
- value: op[0] ? op[1] : void 0,
401
- done: true
402
- };
403
- }
404
- }
405
- // src/lib/serialize.ts
406
- var serialize = function(data) {
407
- return JSON.stringify(data);
408
- };
409
- // src/lib/sanitize.ts
410
- var newlineVariantsRegex = /(\r\n|\r|\n)/g;
411
- var newlineTrailingRegex = /\n+$/g;
412
- var sanitize = function(text) {
413
- var sanitized = text;
414
- sanitized = sanitized.replace(newlineVariantsRegex, "\n");
415
- sanitized = sanitized.replace(newlineTrailingRegex, "");
416
- return sanitized;
417
- };
418
- var generateId;
419
- if (crypto.randomUUID) {
420
- generateId = function() {
421
- return crypto.randomUUID();
422
- };
423
- } else {
424
- generateId = function() {
425
- return crypto.randomBytes(4).toString("hex");
426
- };
427
- }
428
- // src/lib/createPushFromStream.ts
429
- var createPushFromStream = function(push) {
430
- return function() {
431
- var _ref = _async_to_generator(function(stream) {
432
- var options, _options_eventName, eventName;
433
- var _arguments = arguments;
434
- return _ts_generator(this, function(_state) {
435
- switch(_state.label){
436
- case 0:
437
- options = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
438
- _options_eventName = options.eventName, eventName = _options_eventName === void 0 ? "stream" : _options_eventName;
439
- return [
440
- 4,
441
- new Promise(function(resolve, reject) {
442
- stream.on("data", function(chunk) {
443
- var data;
444
- if (Buffer.isBuffer(chunk)) {
445
- data = chunk.toString();
446
- } else {
447
- data = chunk;
448
- }
449
- push(data, eventName);
450
- });
451
- stream.once("end", function() {
452
- return resolve(true);
453
- });
454
- stream.once("close", function() {
455
- return resolve(true);
456
- });
457
- stream.once("error", function(err) {
458
- return reject(err);
459
- });
460
- })
461
- ];
462
- case 1:
463
- return [
464
- 2,
465
- _state.sent()
466
- ];
467
- }
468
- });
469
- });
470
- return function(stream) {
471
- return _ref.apply(this, arguments);
472
- };
473
- }();
474
- };
475
- // src/lib/createPushFromIterable.ts
476
- var createPushFromIterable = function(push) {
477
- return function() {
478
- var _ref = _async_to_generator(function(iterable) {
479
- var options, _options_eventName, eventName, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, data, err;
480
- var _arguments = arguments;
481
- return _ts_generator(this, function(_state) {
482
- switch(_state.label){
483
- case 0:
484
- options = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
485
- _options_eventName = options.eventName, eventName = _options_eventName === void 0 ? "iteration" : _options_eventName;
486
- _iteratorAbruptCompletion = false, _didIteratorError = false;
487
- _state.label = 1;
488
- case 1:
489
- _state.trys.push([
490
- 1,
491
- 6,
492
- 7,
493
- 12
494
- ]);
495
- _iterator = _async_iterator(iterable);
496
- _state.label = 2;
497
- case 2:
498
- return [
499
- 4,
500
- _iterator.next()
501
- ];
502
- case 3:
503
- if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [
504
- 3,
505
- 5
506
- ];
507
- _value = _step.value;
508
- data = _value;
509
- push(data, eventName);
510
- _state.label = 4;
511
- case 4:
512
- _iteratorAbruptCompletion = false;
513
- return [
514
- 3,
515
- 2
516
- ];
517
- case 5:
518
- return [
519
- 3,
520
- 12
521
- ];
522
- case 6:
523
- err = _state.sent();
524
- _didIteratorError = true;
525
- _iteratorError = err;
526
- return [
527
- 3,
528
- 12
529
- ];
530
- case 7:
531
- _state.trys.push([
532
- 7,
533
- ,
534
- 10,
535
- 11
536
- ]);
537
- if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [
538
- 3,
539
- 9
540
- ];
541
- return [
542
- 4,
543
- _iterator.return()
544
- ];
545
- case 8:
546
- _state.sent();
547
- _state.label = 9;
548
- case 9:
549
- return [
550
- 3,
551
- 11
552
- ];
553
- case 10:
554
- if (_didIteratorError) {
555
- throw _iteratorError;
556
- }
557
- return [
558
- 7
559
- ];
560
- case 11:
561
- return [
562
- 7
563
- ];
564
- case 12:
565
- return [
566
- 2
567
- ];
568
- }
569
- });
570
- });
571
- return function(iterable) {
572
- return _ref.apply(this, arguments);
573
- };
574
- }();
575
- };
576
- // src/EventBuffer.ts
577
- var EventBuffer = /*#__PURE__*/ function() {
578
- function EventBuffer() {
579
- var _this = this;
580
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
581
- var _this1 = this;
582
- _class_call_check(this, EventBuffer);
583
- _define_property(this, "buffer", "");
584
- _define_property(this, "serialize", void 0);
585
- _define_property(this, "sanitize", void 0);
586
- /**
587
- * Write a line with a field key and value appended with a newline character.
588
- */ _define_property(this, "writeField", function(name, value) {
589
- var sanitized = _this.sanitize(value);
590
- _this.buffer += name + ":" + sanitized + "\n";
591
- return _this;
592
- });
593
- /**
594
- * Write arbitrary data into a data field.
595
- *
596
- * Data is serialized to a string using the given `serializer` function option or JSON stringification by default.
597
- *
598
- * @param data - Data to serialize and write.
599
- */ _define_property(this, "data", function(data) {
600
- var serialized = _this.serialize(data);
601
- _this.writeField("data", serialized);
602
- return _this;
603
- });
604
- /**
605
- * Write an event ID field.
606
- *
607
- * Defaults to an empty string if no argument is given.
608
- *
609
- * @param id - Identification string to write.
610
- */ _define_property(this, "id", function() {
611
- var id = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
612
- _this1.writeField("id", id);
613
- return _this1;
614
- });
615
- /**
616
- * Write a retry field that suggests a reconnection time with the given milliseconds.
617
- *
618
- * @param time - Time in milliseconds to retry.
619
- */ _define_property(this, "retry", function(time) {
620
- var stringifed = time.toString();
621
- _this.writeField("retry", stringifed);
622
- return _this;
623
- });
624
- /**
625
- * Write a comment (an ignored field).
626
- *
627
- * This will not fire an event but is often used to keep the connection alive.
628
- *
629
- * @param text - Text of the comment. Otherwise writes an empty field value.
630
- */ _define_property(this, "comment", function() {
631
- var text = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
632
- _this1.writeField("", text);
633
- return _this1;
634
- });
635
- /**
636
- * Indicate that the event has finished being created by writing an additional newline character.
637
- */ _define_property(this, "dispatch", function() {
638
- _this.buffer += "\n";
639
- return _this;
640
- });
641
- /**
642
- * Create, write and dispatch an event with the given data all at once.
643
- *
644
- * This is equivalent to calling the methods `event`, `id`, `data` and `dispatch` in that order.
645
- *
646
- * If no event name is given, the event name is set to `"message"`.
647
- *
648
- * If no event ID is given, the event ID is set to a unique string generated using a cryptographic pseudorandom number generator.
649
- *
650
- * @param data - Data to write.
651
- * @param eventName - Event name to write.
652
- * @param eventId - Event ID to write.
653
- */ _define_property(this, "push", function(data) {
654
- var eventName = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "message", eventId = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : generateId();
655
- _this1.event(eventName).id(eventId).data(data).dispatch();
656
- return _this1;
657
- });
658
- /**
659
- * Pipe readable stream data as a series of events into the buffer.
660
- *
661
- * This uses the `push` method under the hood.
662
- *
663
- * If no event name is given in the `options` object, the event name is set to `"stream"`.
664
- *
665
- * @param stream - Readable stream to consume data from.
666
- * @param options - Event name to use for each event created.
667
- *
668
- * @returns A promise that resolves or rejects based on the success of the stream write finishing.
669
- */ _define_property(this, "stream", createPushFromStream(this.push));
670
- /**
671
- * Iterate over an iterable and write yielded values as events into the buffer.
672
- *
673
- * This uses the `push` method under the hood.
674
- *
675
- * If no event name is given in the `options` object, the event name is set to `"iteration"`.
676
- *
677
- * @param iterable - Iterable to consume data from.
678
- *
679
- * @returns A promise that resolves once all data has been successfully yielded from the iterable.
680
- */ _define_property(this, "iterate", createPushFromIterable(this.push));
681
- /**
682
- * Clear the contents of the buffer.
683
- */ _define_property(this, "clear", function() {
684
- _this.buffer = "";
685
- return _this;
686
- });
687
- /**
688
- * Get a copy of the buffer contents.
689
- */ _define_property(this, "read", function() {
690
- return _this.buffer;
691
- });
692
- var _options_serializer;
693
- this.serialize = (_options_serializer = options.serializer) !== null && _options_serializer !== void 0 ? _options_serializer : serialize;
694
- var _options_sanitizer;
695
- this.sanitize = (_options_sanitizer = options.sanitizer) !== null && _options_sanitizer !== void 0 ? _options_sanitizer : sanitize;
696
- }
697
- _create_class(EventBuffer, [
698
- {
699
- /**
700
- * Write an event name field (also referred to as the event "type" in the specification).
701
- *
702
- * @param type - Event name/type.
703
- */ key: "event",
704
- value: function event(type) {
705
- this.writeField("event", type);
706
- return this;
707
- }
708
- }
709
- ]);
710
- return EventBuffer;
711
- }();
712
- var TypedEmitter = /*#__PURE__*/ function(EventEmitter) {
713
- _inherits(TypedEmitter, EventEmitter);
714
- var _super = _create_super(TypedEmitter);
715
- function TypedEmitter() {
716
- _class_call_check(this, TypedEmitter);
717
- return _super.apply(this, arguments);
718
- }
719
- _create_class(TypedEmitter, [
720
- {
721
- key: "addListener",
722
- value: function addListener(event, listener) {
723
- return _get(_get_prototype_of(TypedEmitter.prototype), "addListener", this).call(this, event, listener);
724
- }
725
- },
726
- {
727
- key: "prependListener",
728
- value: function prependListener(event, listener) {
729
- return _get(_get_prototype_of(TypedEmitter.prototype), "prependListener", this).call(this, event, listener);
730
- }
731
- },
732
- {
733
- key: "prependOnceListener",
734
- value: function prependOnceListener(event, listener) {
735
- return _get(_get_prototype_of(TypedEmitter.prototype), "prependOnceListener", this).call(this, event, listener);
736
- }
737
- },
738
- {
739
- key: "on",
740
- value: function on(event, listener) {
741
- return _get(_get_prototype_of(TypedEmitter.prototype), "on", this).call(this, event, listener);
742
- }
743
- },
744
- {
745
- key: "once",
746
- value: function once(event, listener) {
747
- return _get(_get_prototype_of(TypedEmitter.prototype), "once", this).call(this, event, listener);
748
- }
749
- },
750
- {
751
- key: "emit",
752
- value: function emit(event) {
753
- for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
754
- args[_key - 1] = arguments[_key];
755
- }
756
- var _$_get;
757
- return (_$_get = _get(_get_prototype_of(TypedEmitter.prototype), "emit", this)).call.apply(_$_get, [
758
- this,
759
- event
760
- ].concat(_to_consumable_array(args)));
761
- }
762
- },
763
- {
764
- key: "off",
765
- value: function off(event, listener) {
766
- return _get(_get_prototype_of(TypedEmitter.prototype), "off", this).call(this, event, listener);
767
- }
768
- },
769
- {
770
- key: "removeListener",
771
- value: function removeListener(event, listener) {
772
- return _get(_get_prototype_of(TypedEmitter.prototype), "removeListener", this).call(this, event, listener);
773
- }
774
- }
775
- ]);
776
- return TypedEmitter;
777
- }(events.EventEmitter);
778
- // src/lib/SseError.ts
779
- var SseError = /*#__PURE__*/ function(Error1) {
780
- _inherits(SseError, Error1);
781
- var _super = _create_super(SseError);
782
- function SseError(message) {
783
- _class_call_check(this, SseError);
784
- var _this;
785
- _this = _super.call(this, message);
786
- _this.message = "better-sse: ".concat(message);
787
- return _this;
788
- }
789
- return SseError;
790
- }(_wrap_native_super(Error));
791
- // src/Session.ts
792
- var Session = /*#__PURE__*/ function(TypedEmitter) {
793
- _inherits(Session, TypedEmitter);
794
- var _super = _create_super(Session);
795
- function Session(req, res) {
796
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
797
- _class_call_check(this, Session);
798
- var _this;
799
- _this = _super.call(this);
800
- /**
801
- * The last event ID sent to the client.
802
- *
803
- * This is initialized to the last event ID given by the user, and otherwise is equal to the last number given to the `.id` method.
804
- *
805
- * For security reasons, keep in mind that the client can provide *any* initial ID here. Use the `trustClientEventId` constructor option to ignore the client-given initial ID.
806
- *
807
- * @readonly
808
- */ _define_property(_assert_this_initialized(_this), "lastId", "");
809
- /**
810
- * Indicates whether the session and underlying connection is open or not.
811
- *
812
- * @readonly
813
- */ _define_property(_assert_this_initialized(_this), "isConnected", false);
814
- /**
815
- * Custom state for this session.
816
- *
817
- * Use this object to safely store information related to the session and user.
818
- *
819
- * Use [module augmentation and declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation)
820
- * to safely add new properties to the `DefaultSessionState` interface.
821
- */ _define_property(_assert_this_initialized(_this), "state", void 0);
822
- _define_property(_assert_this_initialized(_this), "buffer", void 0);
823
- /**
824
- * Raw HTTP request.
825
- */ _define_property(_assert_this_initialized(_this), "req", void 0);
826
- /**
827
- * Raw HTTP response that is the minimal interface needed and forms the
828
- * intersection between the HTTP/1.1 and HTTP/2 server response interfaces.
829
- */ _define_property(_assert_this_initialized(_this), "res", void 0);
830
- _define_property(_assert_this_initialized(_this), "serialize", void 0);
831
- _define_property(_assert_this_initialized(_this), "sanitize", void 0);
832
- _define_property(_assert_this_initialized(_this), "trustClientEventId", void 0);
833
- _define_property(_assert_this_initialized(_this), "initialRetry", void 0);
834
- _define_property(_assert_this_initialized(_this), "keepAliveInterval", void 0);
835
- _define_property(_assert_this_initialized(_this), "keepAliveTimer", void 0);
836
- _define_property(_assert_this_initialized(_this), "statusCode", void 0);
837
- _define_property(_assert_this_initialized(_this), "headers", void 0);
838
- _define_property(_assert_this_initialized(_this), "initialize", function() {
839
- var url = "http://".concat(_this.req.headers.host).concat(_this.req.url);
840
- var params = new URL(url).searchParams;
841
- if (_this.trustClientEventId) {
842
- var _this_req_headers_lasteventid, _ref, _ref1;
843
- var givenLastEventId = (_ref1 = (_ref = (_this_req_headers_lasteventid = _this.req.headers["last-event-id"]) !== null && _this_req_headers_lasteventid !== void 0 ? _this_req_headers_lasteventid : params.get("lastEventId")) !== null && _ref !== void 0 ? _ref : params.get("evs_last_event_id")) !== null && _ref1 !== void 0 ? _ref1 : "";
844
- _this.lastId = givenLastEventId;
845
- }
846
- var headers = {};
847
- if (_instanceof(_this.res, http.ServerResponse)) {
848
- headers["Content-Type"] = "text/event-stream";
849
- headers["Cache-Control"] = "private, no-cache, no-store, no-transform, must-revalidate, max-age=0";
850
- headers["Connection"] = "keep-alive";
851
- headers["Pragma"] = "no-cache";
852
- headers["X-Accel-Buffering"] = "no";
853
- } else {
854
- headers["content-type"] = "text/event-stream";
855
- headers["cache-control"] = "private, no-cache, no-store, no-transform, must-revalidate, max-age=0";
856
- headers["pragma"] = "no-cache";
857
- headers["x-accel-buffering"] = "no";
858
- }
859
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
860
- try {
861
- for(var _iterator = Object.entries(_this.headers)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
862
- var _step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], value = _step_value[1];
863
- headers[name] = value !== null && value !== void 0 ? value : "";
864
- }
865
- } catch (err) {
866
- _didIteratorError = true;
867
- _iteratorError = err;
868
- } finally{
869
- try {
870
- if (!_iteratorNormalCompletion && _iterator.return != null) {
871
- _iterator.return();
872
- }
873
- } finally{
874
- if (_didIteratorError) {
875
- throw _iteratorError;
876
- }
877
- }
878
- }
879
- _this.res.writeHead(_this.statusCode, headers);
880
- if (params.has("padding")) {
881
- _this.buffer.comment(" ".repeat(2049)).dispatch();
882
- }
883
- if (params.has("evs_preamble")) {
884
- _this.buffer.comment(" ".repeat(2056)).dispatch();
885
- }
886
- if (_this.initialRetry !== null) {
887
- _this.buffer.retry(_this.initialRetry).dispatch();
888
- }
889
- _this.flush();
890
- if (_this.keepAliveInterval !== null) {
891
- _this.keepAliveTimer = setInterval(_this.keepAlive, _this.keepAliveInterval);
892
- }
893
- _this.isConnected = true;
894
- _this.emit("connected");
895
- });
896
- _define_property(_assert_this_initialized(_this), "onDisconnected", function() {
897
- _this.req.removeListener("close", _this.onDisconnected);
898
- _this.res.removeListener("close", _this.onDisconnected);
899
- if (_this.keepAliveTimer) {
900
- clearInterval(_this.keepAliveTimer);
901
- }
902
- _this.isConnected = false;
903
- _this.emit("disconnected");
904
- });
905
- _define_property(_assert_this_initialized(_this), "keepAlive", function() {
906
- _this.buffer.comment().dispatch();
907
- _this.flush();
908
- });
909
- /**
910
- * @deprecated see https://github.com/MatthewWid/better-sse/issues/52
911
- */ _define_property(_assert_this_initialized(_this), "data", function(data) {
912
- _this.buffer.data(data);
913
- return _assert_this_initialized(_this);
914
- });
915
- /**
916
- * @deprecated see https://github.com/MatthewWid/better-sse/issues/52
917
- */ _define_property(_assert_this_initialized(_this), "id", function() {
918
- var id = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
919
- _this.buffer.id(id);
920
- _this.lastId = id;
921
- return _assert_this_initialized(_this);
922
- });
923
- /**
924
- * @deprecated see https://github.com/MatthewWid/better-sse/issues/52
925
- */ _define_property(_assert_this_initialized(_this), "retry", function(time) {
926
- _this.buffer.retry(time);
927
- return _assert_this_initialized(_this);
928
- });
929
- /**
930
- * @deprecated see https://github.com/MatthewWid/better-sse/issues/52
931
- */ _define_property(_assert_this_initialized(_this), "comment", function(text) {
932
- _this.buffer.comment(text);
933
- return _assert_this_initialized(_this);
934
- });
935
- /**
936
- * @deprecated see https://github.com/MatthewWid/better-sse/issues/52
937
- */ _define_property(_assert_this_initialized(_this), "dispatch", function() {
938
- _this.buffer.dispatch();
939
- return _assert_this_initialized(_this);
940
- });
941
- /**
942
- * Flush the contents of the internal buffer to the client and clear the buffer.
943
- *
944
- * @deprecated see https://github.com/MatthewWid/better-sse/issues/52
945
- */ _define_property(_assert_this_initialized(_this), "flush", function() {
946
- _this.res.write(_this.buffer.read());
947
- _this.buffer.clear();
948
- return _assert_this_initialized(_this);
949
- });
950
- /**
951
- * Push an event to the client.
952
- *
953
- * If no event name is given, the event name is set to `"message"`.
954
- *
955
- * If no event ID is given, the event ID (and thus the `lastId` property) is set to a unique string generated using a cryptographic pseudorandom number generator.
956
- *
957
- * Emits the `push` event with the given data, event name and event ID in that order.
958
- *
959
- * @param data - Data to write.
960
- * @param eventName - Event name to write.
961
- * @param eventId - Event ID to write.
962
- */ _define_property(_assert_this_initialized(_this), "push", function(data) {
963
- var eventName = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "message", eventId = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : generateId();
964
- if (!_this.isConnected) {
965
- throw new SseError("Cannot push data to a non-active session.");
966
- }
967
- _this.buffer.push(data, eventName, eventId);
968
- _this.flush();
969
- _this.lastId = eventId;
970
- _this.emit("push", data, eventName, eventId);
971
- return _assert_this_initialized(_this);
972
- });
973
- /**
974
- * Pipe readable stream data as a series of events to the client.
975
- *
976
- * This uses the `push` method under the hood.
977
- *
978
- * If no event name is given in the `options` object, the event name is set to `"stream"`.
979
- *
980
- * @param stream - Readable stream to consume data from.
981
- * @param options - Options to alter how the stream is flushed to the client.
982
- *
983
- * @returns A promise that resolves or rejects based on the success of the stream write finishing.
984
- */ _define_property(_assert_this_initialized(_this), "stream", createPushFromStream(_this.push));
985
- /**
986
- * Iterate over an iterable and send yielded values as events to the client.
987
- *
988
- * This uses the `push` method under the hood.
989
- *
990
- * If no event name is given in the `options` object, the event name is set to `"iteration"`.
991
- *
992
- * @param iterable - Iterable to consume data from.
993
- *
994
- * @returns A promise that resolves once all data has been successfully yielded from the iterable.
995
- */ _define_property(_assert_this_initialized(_this), "iterate", createPushFromIterable(_this.push));
996
- var _this1 = _assert_this_initialized(_this);
997
- /**
998
- * Batch and send multiple events at once.
999
- *
1000
- * If given an `EventBuffer` instance, its contents will be sent to the client.
1001
- *
1002
- * If given a callback, it will be passed an instance of `EventBuffer` which uses the same serializer and sanitizer as the session.
1003
- * Once its execution completes - or once it resolves if it returns a promise - the contents of the passed `EventBuffer` will be sent to the client.
1004
- *
1005
- * @param batcher - Event buffer to get contents from, or callback that takes an event buffer to write to.
1006
- *
1007
- * @returns A promise that resolves once all data from the event buffer has been successfully sent to the client.
1008
- *
1009
- * @see EventBuffer
1010
- */ _define_property(_assert_this_initialized(_this), "batch", function() {
1011
- var _ref = _async_to_generator(function(batcher) {
1012
- var buffer;
1013
- return _ts_generator(this, function(_state) {
1014
- switch(_state.label){
1015
- case 0:
1016
- if (!_instanceof(batcher, EventBuffer)) return [
1017
- 3,
1018
- 1
1019
- ];
1020
- _this1.res.write(batcher.read());
1021
- return [
1022
- 3,
1023
- 3
1024
- ];
1025
- case 1:
1026
- buffer = new EventBuffer({
1027
- serializer: _this1.serialize,
1028
- sanitizer: _this1.sanitize
1029
- });
1030
- return [
1031
- 4,
1032
- batcher(buffer)
1033
- ];
1034
- case 2:
1035
- _state.sent();
1036
- _this1.res.write(buffer.read());
1037
- _state.label = 3;
1038
- case 3:
1039
- return [
1040
- 2
1041
- ];
1042
- }
1043
- });
1044
- });
1045
- return function(batcher) {
1046
- return _ref.apply(this, arguments);
1047
- };
1048
- }());
1049
- _this.req = req;
1050
- _this.res = res;
1051
- var _options_serializer;
1052
- var serializer = (_options_serializer = options.serializer) !== null && _options_serializer !== void 0 ? _options_serializer : serialize;
1053
- var _options_sanitizer;
1054
- var sanitizer = (_options_sanitizer = options.sanitizer) !== null && _options_sanitizer !== void 0 ? _options_sanitizer : sanitize;
1055
- _this.serialize = serializer;
1056
- _this.sanitize = sanitizer;
1057
- _this.buffer = new EventBuffer({
1058
- serializer: serializer,
1059
- sanitizer: sanitizer
1060
- });
1061
- var _options_trustClientEventId;
1062
- _this.trustClientEventId = (_options_trustClientEventId = options.trustClientEventId) !== null && _options_trustClientEventId !== void 0 ? _options_trustClientEventId : true;
1063
- var _options_retry;
1064
- _this.initialRetry = options.retry === null ? null : (_options_retry = options.retry) !== null && _options_retry !== void 0 ? _options_retry : 2e3;
1065
- var _options_keepAlive;
1066
- _this.keepAliveInterval = options.keepAlive === null ? null : (_options_keepAlive = options.keepAlive) !== null && _options_keepAlive !== void 0 ? _options_keepAlive : 1e4;
1067
- var _options_statusCode;
1068
- _this.statusCode = (_options_statusCode = options.statusCode) !== null && _options_statusCode !== void 0 ? _options_statusCode : 200;
1069
- var _options_headers;
1070
- _this.headers = (_options_headers = options.headers) !== null && _options_headers !== void 0 ? _options_headers : {};
1071
- var _options_state;
1072
- _this.state = (_options_state = options.state) !== null && _options_state !== void 0 ? _options_state : {};
1073
- _this.req.once("close", _this.onDisconnected);
1074
- _this.res.once("close", _this.onDisconnected);
1075
- setImmediate(_this.initialize);
1076
- return _this;
1077
- }
1078
- _create_class(Session, [
1079
- {
1080
- /**
1081
- * @deprecated see https://github.com/MatthewWid/better-sse/issues/52
1082
- */ key: "event",
1083
- value: function event(type) {
1084
- this.buffer.event(type);
1085
- return this;
1086
- }
1087
- }
1088
- ]);
1089
- return Session;
1090
- }(TypedEmitter);
1091
- // src/createSession.ts
1092
- var createSession = function() {
1093
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
1094
- args[_key] = arguments[_key];
1095
- }
1096
- return new Promise(function(resolve) {
1097
- var session = _construct(Session, _to_consumable_array(args));
1098
- session.once("connected", function() {
1099
- resolve(session);
1100
- });
1101
- });
1102
- };
1103
- // src/Channel.ts
1104
- var Channel = /*#__PURE__*/ function(TypedEmitter) {
1105
- _inherits(Channel, TypedEmitter);
1106
- var _super = _create_super(Channel);
1107
- function Channel() {
1108
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1109
- _class_call_check(this, Channel);
1110
- var _this;
1111
- _this = _super.call(this);
1112
- /**
1113
- * Custom state for this channel.
1114
- *
1115
- * Use this object to safely store information related to the channel.
1116
- */ _define_property(_assert_this_initialized(_this), "state", void 0);
1117
- _define_property(_assert_this_initialized(_this), "sessions", /* @__PURE__ */ new Set());
1118
- /**
1119
- * Broadcast an event to every active session registered with this channel.
1120
- *
1121
- * Under the hood this calls the `push` method on every active session.
1122
- *
1123
- * If no event name is given, the event name is set to `"message"`.
1124
- *
1125
- * Note that the broadcasted event will have the same ID across all receiving sessions instead of generating a unique ID for each.
1126
- *
1127
- * @param data - Data to write.
1128
- * @param eventName - Event name to write.
1129
- */ _define_property(_assert_this_initialized(_this), "broadcast", function(data) {
1130
- var eventName = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "message", options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1131
- var _options_eventId;
1132
- var eventId = (_options_eventId = options.eventId) !== null && _options_eventId !== void 0 ? _options_eventId : generateId();
1133
- var sessions = options.filter ? _this.activeSessions.filter(options.filter) : _this.sessions;
1134
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1135
- try {
1136
- for(var _iterator = sessions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1137
- var session = _step.value;
1138
- session.push(data, eventName, eventId);
1139
- }
1140
- } catch (err) {
1141
- _didIteratorError = true;
1142
- _iteratorError = err;
1143
- } finally{
1144
- try {
1145
- if (!_iteratorNormalCompletion && _iterator.return != null) {
1146
- _iterator.return();
1147
- }
1148
- } finally{
1149
- if (_didIteratorError) {
1150
- throw _iteratorError;
1151
- }
1152
- }
1153
- }
1154
- _this.emit("broadcast", data, eventName, eventId);
1155
- return _assert_this_initialized(_this);
1156
- });
1157
- var _options_state;
1158
- _this.state = (_options_state = options.state) !== null && _options_state !== void 0 ? _options_state : {};
1159
- return _this;
1160
- }
1161
- _create_class(Channel, [
1162
- {
1163
- key: "activeSessions",
1164
- get: /**
1165
- * List of the currently active sessions subscribed to this channel.
1166
- */ function get() {
1167
- return Array.from(this.sessions);
1168
- }
1169
- },
1170
- {
1171
- key: "sessionCount",
1172
- get: /**
1173
- * Number of sessions subscribed to this channel.
1174
- */ function get() {
1175
- return this.sessions.size;
1176
- }
1177
- },
1178
- {
1179
- /**
1180
- * Register a session so that it can start receiving events from this channel.
1181
- *
1182
- * If the session was already registered to begin with this method does nothing.
1183
- *
1184
- * @param session - Session to register.
1185
- */ key: "register",
1186
- value: function register(session) {
1187
- var _this = this;
1188
- if (this.sessions.has(session)) {
1189
- return this;
1190
- }
1191
- if (!session.isConnected) {
1192
- throw new SseError("Cannot register a non-active session.");
1193
- }
1194
- session.once("disconnected", function() {
1195
- _this.emit("session-disconnected", session);
1196
- _this.deregister(session);
1197
- });
1198
- this.sessions.add(session);
1199
- this.emit("session-registered", session);
1200
- return this;
1201
- }
1202
- },
1203
- {
1204
- /**
1205
- * Deregister a session so that it no longer receives events from this channel.
1206
- *
1207
- * If the session was not registered to begin with this method does nothing.
1208
- *
1209
- * @param session - Session to deregister.
1210
- */ key: "deregister",
1211
- value: function deregister(session) {
1212
- if (!this.sessions.has(session)) {
1213
- return this;
1214
- }
1215
- this.sessions.delete(session);
1216
- this.emit("session-deregistered", session);
1217
- return this;
1218
- }
1219
- }
1220
- ]);
1221
- return Channel;
1222
- }(TypedEmitter);
1223
- // src/createChannel.ts
1224
- var createChannel = function() {
1225
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
1226
- args[_key] = arguments[_key];
1227
- }
1228
- return _construct(Channel, _to_consumable_array(args));
1229
- };
1230
-
1231
6
  let SSEService = class SSEService {
1232
7
  async registerSession(params, _pinsSettingsList, context) {
1233
8
  const { id, disconnected = [] } = params;
1234
- const session = await createSession(context.protected.req, context.protected.res);
9
+ const session = await betterSse.createSession(context.protected.req, context.protected.res);
1235
10
  if (id) {
1236
11
  const start = context.privates.SSE_SESSION_START || '';
1237
12
  const name = `${start}__${context.request.digipair}_${context.request.reasoning}__${id}`;
@@ -1251,7 +26,7 @@ let SSEService = class SSEService {
1251
26
  const name = `${start}__${context.request.digipair}_${context.request.reasoning}__${id}`;
1252
27
  let channel = this.channels.get(name);
1253
28
  if (!channel) {
1254
- channel = createChannel(session);
29
+ channel = betterSse.createChannel(session);
1255
30
  this.channels.set(name, channel);
1256
31
  }
1257
32
  const channelSession = session ?? await this.registerSession({
package/dist/index.esm.js CHANGED
@@ -24065,14 +24065,14 @@ function indent(str, spaces) {
24065
24065
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
24066
24066
  // match is required
24067
24067
  if (!match) {
24068
- return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
24068
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
24069
24069
  v: nextMatch1
24070
24070
  };
24071
24071
  }
24072
24072
  var token = match.token, offset = match.offset;
24073
24073
  i1 += offset;
24074
24074
  if (token === ' ') {
24075
- return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
24075
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
24076
24076
  }
24077
24077
  tokens1 = _to_consumable_array$4(tokens1).concat([
24078
24078
  token
@@ -24091,7 +24091,7 @@ function indent(str, spaces) {
24091
24091
  if (contextKeys.some(function(el) {
24092
24092
  return el.startsWith(name);
24093
24093
  })) {
24094
- return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
24094
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
24095
24095
  }
24096
24096
  if (dateTimeIdentifiers.some(function(el) {
24097
24097
  return el === name;
@@ -24110,9 +24110,9 @@ function indent(str, spaces) {
24110
24110
  if (dateTimeIdentifiers.some(function(el) {
24111
24111
  return el.startsWith(name);
24112
24112
  })) {
24113
- return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
24113
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
24114
24114
  }
24115
- return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
24115
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
24116
24116
  v: nextMatch1
24117
24117
  };
24118
24118
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-sse",
3
- "version": "0.114.1",
3
+ "version": "0.114.3",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -29,5 +29,7 @@
29
29
  "nx": {
30
30
  "name": "skill-sse"
31
31
  },
32
- "dependencies": {}
32
+ "dependencies": {
33
+ "better-sse": "^0.14.0"
34
+ }
33
35
  }