1var __create = Object.create; 2var __defProp = Object.defineProperty; 3var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 4var __getOwnPropNames = Object.getOwnPropertyNames; 5var __getProtoOf = Object.getPrototypeOf; 6var __hasOwnProp = Object.prototype.hasOwnProperty; 7var __esm = (fn, res) => function __init() { 8 return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; 9}; 10var __commonJS = (cb, mod) => function __require() { 11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 12}; 13var __export = (target, all) => { 14 for (var name in all) 15 __defProp(target, name, { get: all[name], enumerable: true }); 16}; 17var __copyProps = (to, from, except, desc) => { 18 if (from && typeof from === "object" || typeof from === "function") { 19 for (let key of __getOwnPropNames(from)) 20 if (!__hasOwnProp.call(to, key) && key !== except) 21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 22 } 23 return to; 24}; 25var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 26 // If the importer is in node compatibility mode or this is not an ESM 27 // file that has been converted to a CommonJS file using a Babel- 28 // compatible transform (i.e. "__esModule" has not been set), then set 29 // "default" to the CommonJS "module.exports" for node compatibility. 30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 31 mod 32)); 33 34// <define:_LANGS_> 35var init_define_LANGS = __esm({ 36 "<define:_LANGS_>"() { 37 } 38}); 39
vendor: 6,348 bytes, lines 40-202
40// ../../node_modules/.pnpm/[email protected]/node_modules/eventemitter3/index.js 41var require_eventemitter3 = __commonJS({ 42 "../../node_modules/.pnpm/[email protected]/node_modules/eventemitter3/index.js"(exports, module) { 43 "use strict"; 44 init_define_LANGS(); 45 var has = Object.prototype.hasOwnProperty; 46 var prefix = "~"; 47 function Events() { 48 } 49 if (Object.create) { 50 Events.prototype = /* @__PURE__ */ Object.create(null); 51 if (!new Events().__proto__) prefix = false; 52 } 53 function EE(fn, context, once) { 54 this.fn = fn; 55 this.context = context; 56 this.once = once || false; 57 } 58 function addListener(emitter, event, fn, context, once) { 59 if (typeof fn !== "function") { 60 throw new TypeError("The listener must be a function"); 61 } 62 var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event; 63 if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; 64 else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); 65 else emitter._events[evt] = [emitter._events[evt], listener]; 66 return emitter; 67 } 68 function clearEvent(emitter, evt) { 69 if (--emitter._eventsCount === 0) emitter._events = new Events(); 70 else delete emitter._events[evt]; 71 } 72 function EventEmitter2() { 73 this._events = new Events(); 74 this._eventsCount = 0; 75 } 76 EventEmitter2.prototype.eventNames = function eventNames() { 77 var names = [], events, name; 78 if (this._eventsCount === 0) return names; 79 for (name in events = this._events) { 80 if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); 81 } 82 if (Object.getOwnPropertySymbols) { 83 return names.concat(Object.getOwnPropertySymbols(events)); 84 } 85 return names; 86 }; 87 EventEmitter2.prototype.listeners = function listeners(event) { 88 var evt = prefix ? prefix + event : event, handlers = this._events[evt]; 89 if (!handlers) return []; 90 if (handlers.fn) return [handlers.fn]; 91 for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { 92 ee[i] = handlers[i].fn; 93 } 94 return ee; 95 }; 96 EventEmitter2.prototype.listenerCount = function listenerCount(event) { 97 var evt = prefix ? prefix + event : event, listeners = this._events[evt]; 98 if (!listeners) return 0; 99 if (listeners.fn) return 1; 100 return listeners.length; 101 }; 102 EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { 103 var evt = prefix ? prefix + event : event; 104 if (!this._events[evt]) return false; 105 var listeners = this._events[evt], len = arguments.length, args, i; 106 if (listeners.fn) { 107 if (listeners.once) this.removeListener(event, listeners.fn, void 0, true); 108 switch (len) { 109 case 1: 110 return listeners.fn.call(listeners.context), true; 111 case 2: 112 return listeners.fn.call(listeners.context, a1), true; 113 case 3: 114 return listeners.fn.call(listeners.context, a1, a2), true; 115 case 4: 116 return listeners.fn.call(listeners.context, a1, a2, a3), true; 117 case 5: 118 return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; 119 case 6: 120 return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; 121 } 122 for (i = 1, args = new Array(len - 1); i < len; i++) { 123 args[i - 1] = arguments[i]; 124 } 125 listeners.fn.apply(listeners.context, args); 126 } else { 127 var length = listeners.length, j; 128 for (i = 0; i < length; i++) { 129 if (listeners[i].once) this.removeListener(event, listeners[i].fn, void 0, true); 130 switch (len) { 131 case 1: 132 listeners[i].fn.call(listeners[i].context); 133 break; 134 case 2: 135 listeners[i].fn.call(listeners[i].context, a1); 136 break; 137 case 3: 138 listeners[i].fn.call(listeners[i].context, a1, a2); 139 break; 140 case 4: 141 listeners[i].fn.call(listeners[i].context, a1, a2, a3); 142 break; 143 default: 144 if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) { 145 args[j - 1] = arguments[j]; 146 } 147 listeners[i].fn.apply(listeners[i].context, args); 148 } 149 } 150 } 151 return true; 152 }; 153 EventEmitter2.prototype.on = function on(event, fn, context) { 154 return addListener(this, event, fn, context, false); 155 }; 156 EventEmitter2.prototype.once = function once(event, fn, context) { 157 return addListener(this, event, fn, context, true); 158 }; 159 EventEmitter2.prototype.removeListener = function removeListener(event, fn, context, once) { 160 var evt = prefix ? prefix + event : event; 161 if (!this._events[evt]) return this; 162 if (!fn) { 163 clearEvent(this, evt); 164 return this; 165 } 166 var listeners = this._events[evt]; 167 if (listeners.fn) { 168 if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) { 169 clearEvent(this, evt); 170 } 171 } else { 172 for (var i = 0, events = [], length = listeners.length; i < length; i++) { 173 if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) { 174 events.push(listeners[i]); 175 } 176 } 177 if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; 178 else clearEvent(this, evt); 179 } 180 return this; 181 }; 182 EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) { 183 var evt; 184 if (event) { 185 evt = prefix ? prefix + event : event; 186 if (this._events[evt]) clearEvent(this, evt); 187 } else { 188 this._events = new Events(); 189 this._eventsCount = 0; 190 } 191 return this; 192 }; 193 EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener; 194 EventEmitter2.prototype.addListener = EventEmitter2.prototype.on; 195 EventEmitter2.prefixed = prefix; 196 EventEmitter2.EventEmitter = EventEmitter2; 197 if ("undefined" !== typeof module) { 198 module.exports = EventEmitter2; 199 } 200 } 201}); 202
203// src/sw.ts 204init_define_LANGS(); 205
vendor: 1,171 bytes, lines 206-236
206// ../../node_modules/.pnpm/[email protected]/node_modules/idb-keyval/dist/index.js 207init_define_LANGS(); 208function promisifyRequest(request) { 209 return new Promise((resolve, reject) => { 210 request.oncomplete = request.onsuccess = () => resolve(request.result); 211 request.onabort = request.onerror = () => reject(request.error); 212 }); 213} 214function createStore(dbName, storeName) { 215 const request = indexedDB.open(dbName); 216 request.onupgradeneeded = () => request.result.createObjectStore(storeName); 217 const dbp = promisifyRequest(request); 218 return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName))); 219} 220var defaultGetStoreFunc; 221function defaultGetStore() { 222 if (!defaultGetStoreFunc) { 223 defaultGetStoreFunc = createStore("keyval-store", "keyval"); 224 } 225 return defaultGetStoreFunc; 226} 227function get(key, customStore = defaultGetStore()) { 228 return customStore("readonly", (store) => promisifyRequest(store.get(key))); 229} 230function set(key, value, customStore = defaultGetStore()) { 231 return customStore("readwrite", (store) => { 232 store.put(value, key); 233 return promisifyRequest(store.transaction); 234 }); 235} 236
237// ../misskey-js/built/index.js 238init_define_LANGS(); 239
240// ../misskey-js/built/streaming.js 241init_define_LANGS(); 242
vendor: 163 bytes, lines 243-246
243// ../../node_modules/.pnpm/[email protected]/node_modules/eventemitter3/index.mjs 244init_define_LANGS(); 245var import_index = __toESM(require_eventemitter3(), 1); 246
vendor: 17,874 bytes, lines 247-796
247// ../../node_modules/.pnpm/[email protected]/node_modules/reconnecting-websocket/dist/reconnecting-websocket-mjs.js 248init_define_LANGS(); 249var extendStatics = function(d, b) { 250 extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { 251 d2.__proto__ = b2; 252 } || function(d2, b2) { 253 for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p]; 254 }; 255 return extendStatics(d, b); 256}; 257function __extends(d, b) { 258 extendStatics(d, b); 259 function __() { 260 this.constructor = d; 261 } 262 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 263} 264function __values(o) { 265 var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; 266 if (m) return m.call(o); 267 return { 268 next: function() { 269 if (o && i >= o.length) o = void 0; 270 return { value: o && o[i++], done: !o }; 271 } 272 }; 273} 274function __read(o, n) { 275 var m = typeof Symbol === "function" && o[Symbol.iterator]; 276 if (!m) return o; 277 var i = m.call(o), r, ar = [], e; 278 try { 279 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); 280 } catch (error) { 281 e = { error }; 282 } finally { 283 try { 284 if (r && !r.done && (m = i["return"])) m.call(i); 285 } finally { 286 if (e) throw e.error; 287 } 288 } 289 return ar; 290} 291function __spread() { 292 for (var ar = [], i = 0; i < arguments.length; i++) 293 ar = ar.concat(__read(arguments[i])); 294 return ar; 295} 296var Event = ( 297 /** @class */ 298 /* @__PURE__ */ function() { 299 function Event2(type, target) { 300 this.target = target; 301 this.type = type; 302 } 303 return Event2; 304 }() 305); 306var ErrorEvent = ( 307 /** @class */ 308 function(_super) { 309 __extends(ErrorEvent2, _super); 310 function ErrorEvent2(error, target) { 311 var _this = _super.call(this, "error", target) || this; 312 _this.message = error.message; 313 _this.error = error; 314 return _this; 315 } 316 return ErrorEvent2; 317 }(Event) 318); 319var CloseEvent = ( 320 /** @class */ 321 function(_super) { 322 __extends(CloseEvent2, _super); 323 function CloseEvent2(code, reason, target) { 324 if (code === void 0) { 325 code = 1e3; 326 } 327 if (reason === void 0) { 328 reason = ""; 329 } 330 var _this = _super.call(this, "close", target) || this; 331 _this.wasClean = true; 332 _this.code = code; 333 _this.reason = reason; 334 return _this; 335 } 336 return CloseEvent2; 337 }(Event) 338); 339var getGlobalWebSocket = function() { 340 if (typeof WebSocket !== "undefined") { 341 return WebSocket; 342 } 343}; 344var isWebSocket = function(w) { 345 return typeof w !== "undefined" && !!w && w.CLOSING === 2; 346}; 347var DEFAULT = { 348 maxReconnectionDelay: 1e4, 349 minReconnectionDelay: 1e3 + Math.random() * 4e3, 350 minUptime: 5e3, 351 reconnectionDelayGrowFactor: 1.3, 352 connectionTimeout: 4e3, 353 maxRetries: Infinity, 354 maxEnqueuedMessages: Infinity, 355 startClosed: false, 356 debug: false 357}; 358var ReconnectingWebSocket = ( 359 /** @class */ 360 function() { 361 function ReconnectingWebSocket2(url, protocols, options) { 362 var _this = this; 363 if (options === void 0) { 364 options = {}; 365 } 366 this._listeners = { 367 error: [], 368 message: [], 369 open: [], 370 close: [] 371 }; 372 this._retryCount = -1; 373 this._shouldReconnect = true; 374 this._connectLock = false; 375 this._binaryType = "blob"; 376 this._closeCalled = false; 377 this._messageQueue = []; 378 this.onclose = null; 379 this.onerror = null; 380 this.onmessage = null; 381 this.onopen = null; 382 this._handleOpen = function(event) { 383 _this._debug("open event"); 384 var _a = _this._options.minUptime, minUptime = _a === void 0 ? DEFAULT.minUptime : _a; 385 clearTimeout(_this._connectTimeout); 386 _this._uptimeTimeout = setTimeout(function() { 387 return _this._acceptOpen(); 388 }, minUptime); 389 _this._ws.binaryType = _this._binaryType; 390 _this._messageQueue.forEach(function(message) { 391 return _this._ws.send(message); 392 }); 393 _this._messageQueue = []; 394 if (_this.onopen) { 395 _this.onopen(event); 396 } 397 _this._listeners.open.forEach(function(listener) { 398 return _this._callEventListener(event, listener); 399 }); 400 }; 401 this._handleMessage = function(event) { 402 _this._debug("message event"); 403 if (_this.onmessage) { 404 _this.onmessage(event); 405 } 406 _this._listeners.message.forEach(function(listener) { 407 return _this._callEventListener(event, listener); 408 }); 409 }; 410 this._handleError = function(event) { 411 _this._debug("error event", event.message); 412 _this._disconnect(void 0, event.message === "TIMEOUT" ? "timeout" : void 0); 413 if (_this.onerror) { 414 _this.onerror(event); 415 } 416 _this._debug("exec error listeners"); 417 _this._listeners.error.forEach(function(listener) { 418 return _this._callEventListener(event, listener); 419 }); 420 _this._connect(); 421 }; 422 this._handleClose = function(event) { 423 _this._debug("close event"); 424 _this._clearTimeouts(); 425 if (_this._shouldReconnect) { 426 _this._connect(); 427 } 428 if (_this.onclose) { 429 _this.onclose(event); 430 } 431 _this._listeners.close.forEach(function(listener) { 432 return _this._callEventListener(event, listener); 433 }); 434 }; 435 this._url = url; 436 this._protocols = protocols; 437 this._options = options; 438 if (this._options.startClosed) { 439 this._shouldReconnect = false; 440 } 441 this._connect(); 442 } 443 Object.defineProperty(ReconnectingWebSocket2, "CONNECTING", { 444 get: function() { 445 return 0; 446 }, 447 enumerable: true, 448 configurable: true 449 }); 450 Object.defineProperty(ReconnectingWebSocket2, "OPEN", { 451 get: function() { 452 return 1; 453 }, 454 enumerable: true, 455 configurable: true 456 }); 457 Object.defineProperty(ReconnectingWebSocket2, "CLOSING", { 458 get: function() { 459 return 2; 460 }, 461 enumerable: true, 462 configurable: true 463 }); 464 Object.defineProperty(ReconnectingWebSocket2, "CLOSED", { 465 get: function() { 466 return 3; 467 }, 468 enumerable: true, 469 configurable: true 470 }); 471 Object.defineProperty(ReconnectingWebSocket2.prototype, "CONNECTING", { 472 get: function() { 473 return ReconnectingWebSocket2.CONNECTING; 474 }, 475 enumerable: true, 476 configurable: true 477 }); 478 Object.defineProperty(ReconnectingWebSocket2.prototype, "OPEN", { 479 get: function() { 480 return ReconnectingWebSocket2.OPEN; 481 }, 482 enumerable: true, 483 configurable: true 484 }); 485 Object.defineProperty(ReconnectingWebSocket2.prototype, "CLOSING", { 486 get: function() { 487 return ReconnectingWebSocket2.CLOSING; 488 }, 489 enumerable: true, 490 configurable: true 491 }); 492 Object.defineProperty(ReconnectingWebSocket2.prototype, "CLOSED", { 493 get: function() { 494 return ReconnectingWebSocket2.CLOSED; 495 }, 496 enumerable: true, 497 configurable: true 498 }); 499 Object.defineProperty(ReconnectingWebSocket2.prototype, "binaryType", { 500 get: function() { 501 return this._ws ? this._ws.binaryType : this._binaryType; 502 }, 503 set: function(value) { 504 this._binaryType = value; 505 if (this._ws) { 506 this._ws.binaryType = value; 507 } 508 }, 509 enumerable: true, 510 configurable: true 511 }); 512 Object.defineProperty(ReconnectingWebSocket2.prototype, "retryCount", { 513 /** 514 * Returns the number or connection retries 515 */ 516 get: function() { 517 return Math.max(this._retryCount, 0); 518 }, 519 enumerable: true, 520 configurable: true 521 }); 522 Object.defineProperty(ReconnectingWebSocket2.prototype, "bufferedAmount", { 523 /** 524 * The number of bytes of data that have been queued using calls to send() but not yet 525 * transmitted to the network. This value resets to zero once all queued data has been sent. 526 * This value does not reset to zero when the connection is closed; if you keep calling send(), 527 * this will continue to climb. Read only 528 */ 529 get: function() { 530 var bytes = this._messageQueue.reduce(function(acc, message) { 531 if (typeof message === "string") { 532 acc += message.length; 533 } else if (message instanceof Blob) { 534 acc += message.size; 535 } else { 536 acc += message.byteLength; 537 } 538 return acc; 539 }, 0); 540 return bytes + (this._ws ? this._ws.bufferedAmount : 0); 541 }, 542 enumerable: true, 543 configurable: true 544 }); 545 Object.defineProperty(ReconnectingWebSocket2.prototype, "extensions", { 546 /** 547 * The extensions selected by the server. This is currently only the empty string or a list of 548 * extensions as negotiated by the connection 549 */ 550 get: function() { 551 return this._ws ? this._ws.extensions : ""; 552 }, 553 enumerable: true, 554 configurable: true 555 }); 556 Object.defineProperty(ReconnectingWebSocket2.prototype, "protocol", { 557 /** 558 * A string indicating the name of the sub-protocol the server selected; 559 * this will be one of the strings specified in the protocols parameter when creating the 560 * WebSocket object 561 */ 562 get: function() { 563 return this._ws ? this._ws.protocol : ""; 564 }, 565 enumerable: true, 566 configurable: true 567 }); 568 Object.defineProperty(ReconnectingWebSocket2.prototype, "readyState", { 569 /** 570 * The current state of the connection; this is one of the Ready state constants 571 */ 572 get: function() { 573 if (this._ws) { 574 return this._ws.readyState; 575 } 576 return this._options.startClosed ? ReconnectingWebSocket2.CLOSED : ReconnectingWebSocket2.CONNECTING; 577 }, 578 enumerable: true, 579 configurable: true 580 }); 581 Object.defineProperty(ReconnectingWebSocket2.prototype, "url", { 582 /** 583 * The URL as resolved by the constructor 584 */ 585 get: function() { 586 return this._ws ? this._ws.url : ""; 587 }, 588 enumerable: true, 589 configurable: true 590 }); 591 ReconnectingWebSocket2.prototype.close = function(code, reason) { 592 if (code === void 0) { 593 code = 1e3; 594 } 595 this._closeCalled = true; 596 this._shouldReconnect = false; 597 this._clearTimeouts(); 598 if (!this._ws) { 599 this._debug("close enqueued: no ws instance"); 600 return; 601 } 602 if (this._ws.readyState === this.CLOSED) { 603 this._debug("close: already closed"); 604 return; 605 } 606 this._ws.close(code, reason); 607 }; 608 ReconnectingWebSocket2.prototype.reconnect = function(code, reason) { 609 this._shouldReconnect = true; 610 this._closeCalled = false; 611 this._retryCount = -1; 612 if (!this._ws || this._ws.readyState === this.CLOSED) { 613 this._connect(); 614 } else { 615 this._disconnect(code, reason); 616 this._connect(); 617 } 618 }; 619 ReconnectingWebSocket2.prototype.send = function(data) { 620 if (this._ws && this._ws.readyState === this.OPEN) { 621 this._debug("send", data); 622 this._ws.send(data); 623 } else { 624 var _a = this._options.maxEnqueuedMessages, maxEnqueuedMessages = _a === void 0 ? DEFAULT.maxEnqueuedMessages : _a; 625 if (this._messageQueue.length < maxEnqueuedMessages) { 626 this._debug("enqueue", data); 627 this._messageQueue.push(data); 628 } 629 } 630 }; 631 ReconnectingWebSocket2.prototype.addEventListener = function(type, listener) { 632 if (this._listeners[type]) { 633 this._listeners[type].push(listener); 634 } 635 }; 636 ReconnectingWebSocket2.prototype.dispatchEvent = function(event) { 637 var e_1, _a; 638 var listeners = this._listeners[event.type]; 639 if (listeners) { 640 try { 641 for (var listeners_1 = __values(listeners), listeners_1_1 = listeners_1.next(); !listeners_1_1.done; listeners_1_1 = listeners_1.next()) { 642 var listener = listeners_1_1.value; 643 this._callEventListener(event, listener); 644 } 645 } catch (e_1_1) { 646 e_1 = { error: e_1_1 }; 647 } finally { 648 try { 649 if (listeners_1_1 && !listeners_1_1.done && (_a = listeners_1.return)) _a.call(listeners_1); 650 } finally { 651 if (e_1) throw e_1.error; 652 } 653 } 654 } 655 return true; 656 }; 657 ReconnectingWebSocket2.prototype.removeEventListener = function(type, listener) { 658 if (this._listeners[type]) { 659 this._listeners[type] = this._listeners[type].filter(function(l) { 660 return l !== listener; 661 }); 662 } 663 }; 664 ReconnectingWebSocket2.prototype._debug = function() { 665 var args = []; 666 for (var _i = 0; _i < arguments.length; _i++) { 667 args[_i] = arguments[_i]; 668 } 669 if (this._options.debug) { 670 console.log.apply(console, __spread(["RWS>"], args)); 671 } 672 }; 673 ReconnectingWebSocket2.prototype._getNextDelay = function() { 674 var _a = this._options, _b = _a.reconnectionDelayGrowFactor, reconnectionDelayGrowFactor = _b === void 0 ? DEFAULT.reconnectionDelayGrowFactor : _b, _c = _a.minReconnectionDelay, minReconnectionDelay = _c === void 0 ? DEFAULT.minReconnectionDelay : _c, _d = _a.maxReconnectionDelay, maxReconnectionDelay = _d === void 0 ? DEFAULT.maxReconnectionDelay : _d; 675 var delay = 0; 676 if (this._retryCount > 0) { 677 delay = minReconnectionDelay * Math.pow(reconnectionDelayGrowFactor, this._retryCount - 1); 678 if (delay > maxReconnectionDelay) { 679 delay = maxReconnectionDelay; 680 } 681 } 682 this._debug("next delay", delay); 683 return delay; 684 }; 685 ReconnectingWebSocket2.prototype._wait = function() { 686 var _this = this; 687 return new Promise(function(resolve) { 688 setTimeout(resolve, _this._getNextDelay()); 689 }); 690 }; 691 ReconnectingWebSocket2.prototype._getNextUrl = function(urlProvider) { 692 if (typeof urlProvider === "string") { 693 return Promise.resolve(urlProvider); 694 } 695 if (typeof urlProvider === "function") { 696 var url = urlProvider(); 697 if (typeof url === "string") { 698 return Promise.resolve(url); 699 } 700 if (!!url.then) { 701 return url; 702 } 703 } 704 throw Error("Invalid URL"); 705 }; 706 ReconnectingWebSocket2.prototype._connect = function() { 707 var _this = this; 708 if (this._connectLock || !this._shouldReconnect) { 709 return; 710 } 711 this._connectLock = true; 712 var _a = this._options, _b = _a.maxRetries, maxRetries = _b === void 0 ? DEFAULT.maxRetries : _b, _c = _a.connectionTimeout, connectionTimeout = _c === void 0 ? DEFAULT.connectionTimeout : _c, _d = _a.WebSocket, WebSocket2 = _d === void 0 ? getGlobalWebSocket() : _d; 713 if (this._retryCount >= maxRetries) { 714 this._debug("max retries reached", this._retryCount, ">=", maxRetries); 715 return; 716 } 717 this._retryCount++; 718 this._debug("connect", this._retryCount); 719 this._removeListeners(); 720 if (!isWebSocket(WebSocket2)) { 721 throw Error("No valid WebSocket class provided"); 722 } 723 this._wait().then(function() { 724 return _this._getNextUrl(_this._url); 725 }).then(function(url) { 726 if (_this._closeCalled) { 727 return; 728 } 729 _this._debug("connect", { url, protocols: _this._protocols }); 730 _this._ws = _this._protocols ? new WebSocket2(url, _this._protocols) : new WebSocket2(url); 731 _this._ws.binaryType = _this._binaryType; 732 _this._connectLock = false; 733 _this._addListeners(); 734 _this._connectTimeout = setTimeout(function() { 735 return _this._handleTimeout(); 736 }, connectionTimeout); 737 }); 738 }; 739 ReconnectingWebSocket2.prototype._handleTimeout = function() { 740 this._debug("timeout event"); 741 this._handleError(new ErrorEvent(Error("TIMEOUT"), this)); 742 }; 743 ReconnectingWebSocket2.prototype._disconnect = function(code, reason) { 744 if (code === void 0) { 745 code = 1e3; 746 } 747 this._clearTimeouts(); 748 if (!this._ws) { 749 return; 750 } 751 this._removeListeners(); 752 try { 753 this._ws.close(code, reason); 754 this._handleClose(new CloseEvent(code, reason, this)); 755 } catch (error) { 756 } 757 }; 758 ReconnectingWebSocket2.prototype._acceptOpen = function() { 759 this._debug("accept open"); 760 this._retryCount = 0; 761 }; 762 ReconnectingWebSocket2.prototype._callEventListener = function(event, listener) { 763 if ("handleEvent" in listener) { 764 listener.handleEvent(event); 765 } else { 766 listener(event); 767 } 768 }; 769 ReconnectingWebSocket2.prototype._removeListeners = function() { 770 if (!this._ws) { 771 return; 772 } 773 this._debug("removeListeners"); 774 this._ws.removeEventListener("open", this._handleOpen); 775 this._ws.removeEventListener("close", this._handleClose); 776 this._ws.removeEventListener("message", this._handleMessage); 777 this._ws.removeEventListener("error", this._handleError); 778 }; 779 ReconnectingWebSocket2.prototype._addListeners = function() { 780 if (!this._ws) { 781 return; 782 } 783 this._debug("addListeners"); 784 this._ws.addEventListener("open", this._handleOpen); 785 this._ws.addEventListener("close", this._handleClose); 786 this._ws.addEventListener("message", this._handleMessage); 787 this._ws.addEventListener("error", this._handleError); 788 }; 789 ReconnectingWebSocket2.prototype._clearTimeouts = function() { 790 clearTimeout(this._connectTimeout); 791 clearTimeout(this._uptimeTimeout); 792 }; 793 return ReconnectingWebSocket2; 794 }() 795); 796
797// ../misskey-js/built/consts.js 798init_define_LANGS(); 799
800// ../misskey-js/built/api.js 801var api_exports = {}; 802__export(api_exports, { 803 APIClient: () => APIClient, 804 isAPIError: () => isAPIError 805}); 806init_define_LANGS(); 807
808// ../misskey-js/built/autogen/apiClientJSDoc.js 809init_define_LANGS(); 810
811// ../misskey-js/built/autogen/endpoint.js 812init_define_LANGS(); 813var endpointReqTypes = { 814 "drive/files/create": "multipart/form-data" 815}; 816
817// ../misskey-js/built/api.js 818var MK_API_ERROR = Symbol(); 819function isAPIError(reason) { 820 return reason[MK_API_ERROR] === true; 821} 822var APIClient = class { 823 origin; 824 credential; 825 fetch; 826 constructor(opts) { 827 this.origin = opts.origin.replace(/\/$/, ""); 828 this.credential = opts.credential; 829 this.fetch = opts.fetch ?? ((...args) => fetch(...args)); 830 } 831 // eslint-disable-next-line @typescript-eslint/no-explicit-any 832 assertIsRecord(obj) { 833 return obj !== null && typeof obj === "object" && !Array.isArray(obj); 834 } 835 assertSpecialEpReqType(ep) { 836 return ep in endpointReqTypes; 837 } 838 request(endpoint, params = {}, credential) { 839 return new Promise((resolve, reject) => { 840 let mediaType = "application/json"; 841 if (this.assertSpecialEpReqType(endpoint) && endpointReqTypes[endpoint] != null) { 842 mediaType = endpointReqTypes[endpoint]; 843 } 844 let payload = "{}"; 845 if (mediaType === "application/json") { 846 payload = JSON.stringify({ 847 ...params, 848 i: credential !== void 0 ? credential : this.credential 849 }); 850 } else if (mediaType === "multipart/form-data") { 851 payload = new FormData(); 852 const i = credential !== void 0 ? credential : this.credential; 853 if (i != null) { 854 payload.append("i", i); 855 } 856 if (this.assertIsRecord(params)) { 857 for (const key in params) { 858 const value = params[key]; 859 if (value == null) continue; 860 if (value instanceof File || value instanceof Blob) { 861 payload.append(key, value); 862 } else if (typeof value === "object") { 863 payload.append(key, JSON.stringify(value)); 864 } else { 865 payload.append(key, value); 866 } 867 } 868 } 869 } 870 this.fetch(`${this.origin}/api/${endpoint}`, { 871 method: "POST", 872 body: payload, 873 headers: { 874 "Content-Type": mediaType 875 }, 876 credentials: "omit", 877 cache: "no-cache" 878 }).then(async (res) => { 879 const body = res.status === 204 ? null : await res.json(); 880 if (res.status === 200 || res.status === 204) { 881 resolve(body); 882 } else { 883 reject({ 884 [MK_API_ERROR]: true, 885 ...body.error 886 }); 887 } 888 }).catch(reject); 889 }); 890 } 891}; 892
893// ../misskey-js/built/entities.js 894init_define_LANGS(); 895
896// ../misskey-js/built/autogen/entities.js 897init_define_LANGS(); 898
899// ../misskey-js/built/autogen/models.js 900init_define_LANGS(); 901
902// ../misskey-js/built/acct.js 903var acct_exports = {}; 904__export(acct_exports, { 905 parse: () => parse, 906 toString: () => toString 907}); 908init_define_LANGS(); 909function parse(_acct) { 910 let acct = _acct; 911 if (acct.startsWith("@")) acct = acct.substring(1); 912 const split = acct.split("@", 2); 913 return { username: split[0], host: split[1] || null }; 914} 915function toString(acct) { 916 return acct.host == null ? acct.username : `${acct.username}@${acct.host}`; 917} 918
919// ../misskey-js/built/note.js 920init_define_LANGS(); 921
922// ../misskey-js/built/nyaize.js 923init_define_LANGS(); 924
925// src/scripts/create-notification.ts 926init_define_LANGS(); 927
928// src/scripts/twemoji-base.ts 929init_define_LANGS(); 930function char2fileName(char) { 931 let codes = Array.from(char).map((x) => x.codePointAt(0)?.toString(16)).filter((x) => x !== void 0); 932 if (!codes.includes("200d")) codes = codes.filter((x) => x !== "fe0f"); 933 codes = codes.filter((x) => x.length !== 0); 934 return codes.join("-"); 935} 936
937// src/scripts/operations.ts 938init_define_LANGS(); 939
940// src/scripts/get-account-from-id.ts 941init_define_LANGS(); 942async function getAccountFromId(id) { 943 const accounts = await get("accounts"); 944 if (!accounts) { 945 console.log("Accounts are not recorded"); 946 return; 947 } 948 return accounts.find((e) => e.id === id); 949} 950
951// src/scripts/login-id.ts 952init_define_LANGS(); 953function getUrlWithLoginId(url, loginId) { 954 const u = new URL(url, origin); 955 u.searchParams.set("loginId", loginId); 956 return u.toString(); 957} 958
959// src/scripts/operations.ts 960var cli = new api_exports.APIClient({ origin, fetch: (...args) => fetch(...args) }); 961async function api(endpoint, userId, params) { 962 let account; 963 if (userId) { 964 account = await getAccountFromId(userId); 965 if (!account) return; 966 } 967 return cli.request(endpoint, params, account?.token); 968} 969var readBlockingStatus = /* @__PURE__ */ new Map(); 970function sendMarkAllAsRead(userId) { 971 if (readBlockingStatus.get(userId)) return Promise.resolve(); 972 readBlockingStatus.set(userId, true); 973 return new Promise((resolve) => { 974 setTimeout(() => { 975 readBlockingStatus.set(userId, false); 976 api("notifications/mark-all-as-read", userId).then(resolve, resolve); 977 }, 1e3); 978 }); 979} 980function openUser(acct, loginId) { 981 return openClient("push", `/@${acct}`, loginId, { acct }); 982} 983function openNote(noteId, loginId) { 984 return openClient("push", `/notes/${noteId}`, loginId, { noteId }); 985} 986function openAntenna(antennaId, loginId) { 987 return openClient("push", `/timeline/antenna/${antennaId}`, loginId, { antennaId }); 988} 989function openChat(body, loginId) { 990 if (body.toRoomId != null) { 991 return openClient("push", `/chat/room/${body.toRoomId}`, loginId, { body }); 992 } else { 993 return openClient("push", `/chat/user/${body.toUserId}`, loginId, { body }); 994 } 995} 996async function openPost(options, loginId) { 997 const url = "/share"; 998 const query = new URLSearchParams(); 999 if (options.initialText) query.set("text", options.initialText); 1000 if (options.reply) query.set("replyId", options.reply.id); 1001 if (options.renote) query.set("renoteId", options.renote.id); 1002 return openClient("post", `${url}?${query}`, loginId, { options }); 1003} 1004async function openClient(order, url, loginId, query = {}) { 1005 const client = await findClient(); 1006 if (client) { 1007 client.postMessage({ type: "order", ...query, order, loginId, url }); 1008 return client; 1009 } 1010 return globalThis.clients.openWindow(loginId ? getUrlWithLoginId(url, loginId) : url); 1011} 1012async function findClient() { 1013 const clients = await globalThis.clients.matchAll({ 1014 type: "window" 1015 }); 1016 return clients.find((c) => !new URL(c.url).searchParams.has("zen")) ?? null; 1017} 1018
1019// src/scripts/lang.ts 1020init_define_LANGS(); 1021
1022// ../frontend-shared/js/i18n.ts 1023init_define_LANGS(); 1024var I18n = class { 1025 constructor(locale, devMode = false) { 1026 this.locale = locale; 1027 this.devMode = devMode; 1028 this.t = this.t.bind(this); 1029 } 1030 tsxCache; 1031 devMode; 1032 get ts() { 1033 if (this.devMode) { 1034 class Handler { 1035 get(target, p) { 1036 const value = target[p]; 1037 if (typeof value === "object") { 1038 return new Proxy(value, new Handler()); 1039 } 1040 if (typeof value === "string") { 1041 const parameters = Array.from(value.matchAll(/\{(\w+)\}/g), ([, parameter]) => parameter); 1042 if (parameters.length) { 1043 console.error(`Missing locale parameters: ${parameters.join(", ")} at ${String(p)}`); 1044 } 1045 return value; 1046 } 1047 console.error(`Unexpected locale key: ${String(p)}`); 1048 return p; 1049 } 1050 } 1051 return new Proxy(this.locale, new Handler()); 1052 } 1053 return this.locale; 1054 } 1055 get tsx() { 1056 if (this.devMode) { 1057 if (this.tsxCache) { 1058 return this.tsxCache; 1059 } 1060 class Handler { 1061 get(target, p) { 1062 const value = target[p]; 1063 if (typeof value === "object") { 1064 return new Proxy(value, new Handler()); 1065 } 1066 if (typeof value === "string") { 1067 const quasis = []; 1068 const expressions = []; 1069 let cursor = 0; 1070 while (~cursor) { 1071 const start = value.indexOf("{", cursor); 1072 if (!~start) { 1073 quasis.push(value.slice(cursor)); 1074 break; 1075 } 1076 quasis.push(value.slice(cursor, start)); 1077 const end = value.indexOf("}", start); 1078 expressions.push(value.slice(start + 1, end)); 1079 cursor = end + 1; 1080 } 1081 if (!expressions.length) { 1082 console.error(`Unexpected locale key: ${String(p)}`); 1083 return () => value; 1084 } 1085 return (arg) => { 1086 let str = quasis[0]; 1087 for (let i = 0; i < expressions.length; i++) { 1088 if (!Object.hasOwn(arg, expressions[i])) { 1089 console.error(`Missing locale parameters: ${expressions[i]} at ${String(p)}`); 1090 } 1091 str += arg[expressions[i]] + quasis[i + 1]; 1092 } 1093 return str; 1094 }; 1095 } 1096 console.error(`Unexpected locale key: ${String(p)}`); 1097 return p; 1098 } 1099 } 1100 return this.tsxCache = new Proxy(this.locale, new Handler()); 1101 } 1102 if (this.tsxCache) { 1103 return this.tsxCache; 1104 } 1105 function build(target) { 1106 const result = {}; 1107 for (const k in target) { 1108 if (!Object.hasOwn(target, k)) { 1109 continue; 1110 } 1111 const value = target[k]; 1112 if (typeof value === "object") { 1113 result[k] = build(value); 1114 } else if (typeof value === "string") { 1115 const quasis = []; 1116 const expressions = []; 1117 let cursor = 0; 1118 while (~cursor) { 1119 const start = value.indexOf("{", cursor); 1120 if (!~start) { 1121 quasis.push(value.slice(cursor)); 1122 break; 1123 } 1124 quasis.push(value.slice(cursor, start)); 1125 const end = value.indexOf("}", start); 1126 expressions.push(value.slice(start + 1, end)); 1127 cursor = end + 1; 1128 } 1129 if (!expressions.length) { 1130 continue; 1131 } 1132 result[k] = (arg) => { 1133 let str = quasis[0]; 1134 for (let i = 0; i < expressions.length; i++) { 1135 str += arg[expressions[i]] + quasis[i + 1]; 1136 } 1137 return str; 1138 }; 1139 } 1140 } 1141 return result; 1142 } 1143 return this.tsxCache = build(this.locale); 1144 } 1145 t(key, args) { 1146 let str = this.locale; 1147 for (const k of key.split(".")) { 1148 str = str[k]; 1149 if (this.devMode) { 1150 if (typeof str === "undefined") { 1151 console.error(`Unexpected locale key: ${key}`); 1152 return key; 1153 } 1154 } 1155 } 1156 if (args) { 1157 if (this.devMode) { 1158 const missing = Array.from(str.matchAll(/\{(\w+)\}/g), ([, parameter]) => parameter).filter((parameter) => !Object.hasOwn(args, parameter)); 1159 if (missing.length) { 1160 console.error(`Missing locale parameters: ${missing.join(", ")} at ${key}`); 1161 } 1162 } 1163 for (const [k, v] of Object.entries(args)) { 1164 const search = `{${k}}`; 1165 if (this.devMode) { 1166 if (!str.includes(search)) { 1167 console.error(`Unexpected locale parameter: ${k} at ${key}`); 1168 } 1169 } 1170 str = str.replace(search, v.toString()); 1171 } 1172 } 1173 return str; 1174 } 1175}; 1176
1177// src/scripts/lang.ts 1178var SwLang = class { 1179 cacheName = `mk-cache-${"V9fwaXwYOVSzKIK3ff6eTQ"}`; 1180 lang = get("lang").then(async (prelang) => { 1181 if (!prelang) return "en-US"; 1182 return prelang; 1183 }); 1184 setLang(newLang) { 1185 this.lang = Promise.resolve(newLang); 1186 set("lang", newLang); 1187 return this.fetchLocale(); 1188 } 1189 i18n = null; 1190 fetchLocale() { 1191 return this.i18n = this._fetch(); 1192 } 1193 async _fetch() { 1194 const localeUrl = `/assets/locales/${await this.lang}.${"V9fwaXwYOVSzKIK3ff6eTQ"}.json`; 1195 let localeRes = await caches.match(localeUrl); 1196 if (!localeRes || true) { 1197 localeRes = await fetch(localeUrl); 1198 const clone = localeRes.clone(); 1199 if (!clone.clone().ok) throw new Error("locale fetching error"); 1200 caches.open(this.cacheName).then((cache) => cache.put(localeUrl, clone)); 1201 } 1202 return new I18n(await localeRes.json()); 1203 } 1204}; 1205var swLang = new SwLang(); 1206
1207// src/scripts/get-user-name.ts 1208init_define_LANGS(); 1209function getUserName(user) { 1210 return user.name === "" ? user.username : user.name ?? user.username; 1211} 1212
1213// src/scripts/create-notification.ts 1214var closeNotificationsByTags = async (tags) => { 1215 for (const n of (await Promise.all(tags.map((tag) => globalThis.registration.getNotifications({ tag })))).flat()) { 1216 n.close(); 1217 } 1218}; 1219var iconUrl = (name) => `/static-assets/tabler-badges/${name}.png`; 1220async function createNotification(data) { 1221 const n = await composeNotification(data); 1222 if (n) { 1223 return globalThis.registration.showNotification(...n); 1224 } else { 1225 console.error("Could not compose notification", data); 1226 return createEmptyNotification(); 1227 } 1228} 1229async function composeNotification(data) { 1230 const i18n = await (swLang.i18n ?? swLang.fetchLocale()); 1231 switch (data.type) { 1232 /* 1233 case 'driveFileCreated': // TODO (Server Side) 1234 return [i18n.ts._notification.fileUploaded, { 1235 body: body.name, 1236 icon: body.url, 1237 data 1238 }]; 1239 */ 1240 case "notification": 1241 switch (data.body.type) { 1242 case "follow": { 1243 const account = await getAccountFromId(data.userId); 1244 if (!account) return null; 1245 const userDetail = await cli.request("users/show", { userId: data.body.userId }, account.token); 1246 return [i18n.ts._notification.youWereFollowed, { 1247 body: getUserName(data.body.user), 1248 icon: data.body.user.avatarUrl ?? void 0, 1249 badge: iconUrl("user-plus"), 1250 data, 1251 actions: userDetail.isFollowing ? [] : [ 1252 { 1253 action: "follow", 1254 title: i18n.ts._notification._actions.followBack 1255 } 1256 ] 1257 }]; 1258 } 1259 case "mention": 1260 return [i18n.tsx._notification.youGotMention({ name: getUserName(data.body.user) }), { 1261 body: data.body.note.text ?? "", 1262 icon: data.body.user.avatarUrl ?? void 0, 1263 badge: iconUrl("at"), 1264 data, 1265 actions: [ 1266 { 1267 action: "reply", 1268 title: i18n.ts._notification._actions.reply 1269 } 1270 ] 1271 }]; 1272 case "reply": 1273 return [i18n.tsx._notification.youGotReply({ name: getUserName(data.body.user) }), { 1274 body: data.body.note.text ?? "", 1275 icon: data.body.user.avatarUrl ?? void 0, 1276 badge: iconUrl("arrow-back-up"), 1277 data, 1278 actions: [ 1279 { 1280 action: "reply", 1281 title: i18n.ts._notification._actions.reply 1282 } 1283 ] 1284 }]; 1285 case "renote": 1286 return [i18n.tsx._notification.youRenoted({ name: getUserName(data.body.user) }), { 1287 body: data.body.note.text ?? "", 1288 icon: data.body.user.avatarUrl ?? void 0, 1289 badge: iconUrl("repeat"), 1290 data, 1291 actions: [ 1292 { 1293 action: "showUser", 1294 title: getUserName(data.body.user) 1295 } 1296 ] 1297 }]; 1298 case "quote": 1299 return [i18n.tsx._notification.youGotQuote({ name: getUserName(data.body.user) }), { 1300 body: data.body.note.text ?? "", 1301 icon: data.body.user.avatarUrl ?? void 0, 1302 badge: iconUrl("quote"), 1303 data, 1304 actions: [ 1305 { 1306 action: "reply", 1307 title: i18n.ts._notification._actions.reply 1308 }, 1309 ...data.body.note.visibility === "public" || data.body.note.visibility === "home" ? [ 1310 { 1311 action: "renote", 1312 title: i18n.ts._notification._actions.renote 1313 } 1314 ] : [] 1315 ] 1316 }]; 1317 case "note": 1318 return [i18n.ts._notification.newNote + ": " + getUserName(data.body.user), { 1319 body: data.body.note.text ?? "", 1320 icon: data.body.user.avatarUrl ?? void 0, 1321 data 1322 }]; 1323 case "reaction": { 1324 let reaction = data.body.reaction; 1325 let badge; 1326 if (reaction.startsWith(":")) { 1327 const name = reaction.substring(1, reaction.length - 1); 1328 const badgeUrl = new URL(`/emoji/${name}.webp`, origin); 1329 badgeUrl.searchParams.set("badge", "1"); 1330 badge = badgeUrl.href; 1331 reaction = name.split("@")[0]; 1332 } else { 1333 badge = `/twemoji-badge/${char2fileName(reaction)}.png`; 1334 } 1335 if (await fetch(badge).then((res) => res.status !== 200).catch(() => true)) { 1336 badge = iconUrl("plus"); 1337 } 1338 const tag = `reaction:${data.body.note.id}`; 1339 return [`${reaction} ${getUserName(data.body.user)}`, { 1340 body: data.body.note.text ?? "", 1341 icon: data.body.user.avatarUrl ?? void 0, 1342 tag, 1343 badge, 1344 data, 1345 actions: [ 1346 { 1347 action: "showUser", 1348 title: getUserName(data.body.user) 1349 } 1350 ] 1351 }]; 1352 } 1353 case "receiveFollowRequest": 1354 return [i18n.ts._notification.youReceivedFollowRequest, { 1355 body: getUserName(data.body.user), 1356 icon: data.body.user.avatarUrl ?? void 0, 1357 badge: iconUrl("user-plus"), 1358 data, 1359 actions: [ 1360 { 1361 action: "accept", 1362 title: i18n.ts.accept 1363 }, 1364 { 1365 action: "reject", 1366 title: i18n.ts.reject 1367 } 1368 ] 1369 }]; 1370 case "followRequestAccepted": 1371 return [i18n.ts._notification.yourFollowRequestAccepted, { 1372 body: getUserName(data.body.user), 1373 icon: data.body.user.avatarUrl ?? void 0, 1374 badge: iconUrl("circle-check"), 1375 data 1376 }]; 1377 case "achievementEarned": 1378 return [i18n.ts._notification.achievementEarned, {
1379 body: i18n.ts._achievements._types[`_${data.body.achievement}`].title, 1380 badge: iconUrl("medal"), 1381 data, 1382 tag: `achievement:${data.body.achievement}` 1383 }]; 1384 case "login": 1385 return [i18n.ts._notification.login, { 1386 badge: iconUrl("login-2"), 1387 data 1388 }]; 1389 case "exportCompleted": { 1390 const entityName = { 1391 antenna: i18n.ts.antennas, 1392 blocking: i18n.ts.blockedUsers, 1393 clip: i18n.ts.clips, 1394 customEmoji: i18n.ts.customEmojis, 1395 favorite: i18n.ts.favorites, 1396 following: i18n.ts.following, 1397 muting: i18n.ts.mutedUsers, 1398 note: i18n.ts.notes, 1399 userList: i18n.ts.lists 1400 }; 1401 return [i18n.tsx._notification.exportOfXCompleted({ x: entityName[data.body.exportedEntity] }), { 1402 badge: iconUrl("circle-check"), 1403 data 1404 }]; 1405 } 1406 case "pollEnded": 1407 return [i18n.ts._notification.pollEnded, { 1408 body: data.body.note.text ?? "", 1409 badge: iconUrl("chart-arrows"), 1410 data 1411 }]; 1412 case "app": 1413 return [data.body.header ?? data.body.body, { 1414 body: data.body.header ? data.body.body : "", 1415 icon: data.body.icon ?? void 0, 1416 data 1417 }]; 1418 case "test": 1419 return [i18n.ts._notification.testNotification, { 1420 body: i18n.ts._notification.notificationWillBeDisplayedLikeThis, 1421 badge: iconUrl("bell"), 1422 data 1423 }]; 1424 case "edited": 1425 return [i18n.ts._notification.edited, { 1426 body: data.body.note.text ?? "", 1427 icon: data.body.user.avatarUrl ?? void 0, 1428 badge: iconUrl("messages"), 1429 data 1430 }]; 1431 case "scheduledNoteFailed": 1432 return [i18n.ts._notification.scheduledNoteFailed, { 1433 body: data.body.reason, 1434 badge: iconUrl("bell"), 1435 data 1436 }]; 1437 case "scheduledNotePosted": 1438 return [i18n.ts._notification.scheduledNotePosted, { 1439 body: data.body.note.text ?? "", 1440 icon: data.body.user.avatarUrl ?? void 0, 1441 badge: iconUrl("bell"), 1442 data 1443 }]; 1444 default: 1445 return null; 1446 } 1447 case "unreadAntennaNote": 1448 return [i18n.tsx._notification.unreadAntennaNote({ name: data.body.antenna.name }), { 1449 body: `${getUserName(data.body.note.user)}: ${data.body.note.text ?? ""}`, 1450 icon: data.body.note.user.avatarUrl ?? void 0, 1451 badge: iconUrl("antenna"), 1452 tag: `antenna:${data.body.antenna.id}`, 1453 data, 1454 renotify: true 1455 }]; 1456 case "newChatMessage": 1457 if (data.body.toRoom != null) { 1458 return [`${data.body.toRoom.name}: ${getUserName(data.body.fromUser)}: ${data.body.text}`, { 1459 icon: data.body.fromUser.avatarUrl ?? void 0, 1460 badge: iconUrl("messages"), 1461 tag: `chat:room:${data.body.toRoomId}`, 1462 data, 1463 renotify: true 1464 }]; 1465 } else { 1466 return [`${getUserName(data.body.fromUser)}: ${data.body.text}`, { 1467 icon: data.body.fromUser.avatarUrl ?? void 0, 1468 badge: iconUrl("messages"), 1469 tag: `chat:user:${data.body.fromUserId}`, 1470 data, 1471 renotify: true 1472 }]; 1473 } 1474 default: 1475 return null; 1476 } 1477} 1478async function createEmptyNotification() { 1479 return new Promise(async (res) => { 1480 const i18n = await (swLang.i18n ?? swLang.fetchLocale()); 1481 await globalThis.registration.showNotification( 1482 new URL(origin).host, 1483 { 1484 body: `Sharkey v${"2025.4.7"}`, 1485 silent: true, 1486 badge: iconUrl("null"), 1487 tag: "read_notification", 1488 actions: [ 1489 { 1490 action: "markAllAsRead", 1491 title: i18n.ts.markAllAsRead 1492 }, 1493 { 1494 action: "settings", 1495 title: i18n.ts.notificationSettings 1496 } 1497 ], 1498 data: {} 1499 } 1500 ); 1501 setTimeout(async () => {
1502 try { 1503 await closeNotificationsByTags(["user_visible_auto_notification"]); 1504 } finally { 1505 res(); 1506 } 1507 }, 1e3); 1508 }); 1509} 1510
1511// src/sw.ts 1512globalThis.addEventListener("install", () => { 1513}); 1514globalThis.addEventListener("activate", (ev) => { 1515 ev.waitUntil( 1516 caches.keys().then((cacheNames) => Promise.all( 1517 cacheNames.filter((v) => v !== swLang.cacheName).map((name) => caches.delete(name)) 1518 )).then(() => globalThis.clients.claim()) 1519 ); 1520}); 1521async function offlineContentHTML() { 1522 const i18n = await (swLang.i18n ?? swLang.fetchLocale()); 1523 const messages = { 1524 title: i18n.ts?._offlineScreen.title ?? "Offline - Could not connect to server", 1525 header: i18n.ts?._offlineScreen.header ?? "Could not connect to server", 1526 reload: i18n.ts?.reload ?? "Reload" 1527 }; 1528 return `<!DOCTYPE html><html lang="ja"><head><meta charset="UTF-8"><meta content="width=device-width,initial-scale=1"name="viewport"><title>${messages.title}</title><style>body{background-color:#0c1210;color:#dee7e4;font-family:Hiragino Maru Gothic Pro,BIZ UDGothic,Roboto,HelveticaNeue,Arial,sans-serif;line-height:1.35;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100vh;margin:0;padding:24px;box-sizing:border-box}.icon{max-width:120px;width:100%;height:auto;margin-bottom:20px;}.message{text-align:center;font-size:20px;font-weight:700;margin-bottom:20px}.version{text-align:center;font-size:90%;margin-bottom:20px}button{padding:7px 14px;min-width:100px;font-weight:700;font-family:Hiragino Maru Gothic Pro,BIZ UDGothic,Roboto,HelveticaNeue,Arial,sans-serif;line-height:1.35;border-radius:99rem;background-color:#b4e900;color:#192320;border:none;cursor:pointer;-webkit-tap-highlight-color:transparent}button:hover{background-color:#c6ff03}</style></head><body><svg class="icon"fill="none"height="24"stroke="currentColor"stroke-linecap="round"stroke-linejoin="round"stroke-width="2"viewBox="0 0 24 24"width="24"xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z"fill="none"stroke="none"/><path d="M9.58 5.548c.24 -.11 .492 -.207 .752 -.286c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 .957 -.383 1.824 -1.003 2.454m-2.997 1.033h-11.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.13 -.582 .37 -1.128 .7 -1.62"/><path d="M3 3l18 18"/></svg><div class="message">${messages.header}</div><div class="version">v${"2025.4.7"}</div><button onclick="reloadPage()">${messages.reload}</button><script>function reloadPage(){location.reload(!0)}<\/script></body></html>`; 1529} 1530globalThis.addEventListener("fetch", (ev) => { 1531 let isHTMLRequest = false; 1532 if (ev.request.headers.get("sec-fetch-dest") === "document") { 1533 isHTMLRequest = true; 1534 } else if (ev.request.headers.get("accept")?.includes("/html")) { 1535 isHTMLRequest = true; 1536 } else if (ev.request.url.endsWith("/")) { 1537 isHTMLRequest = true; 1538 } 1539 if (!isHTMLRequest) return; 1540 ev.respondWith( 1541 fetch(ev.request).catch(async () => { 1542 const html = await offlineContentHTML(); 1543 return new Response(html, { 1544 status: 200, 1545 headers: { 1546 "content-type": "text/html" 1547 } 1548 }); 1549 }) 1550 ); 1551}); 1552globalThis.addEventListener("push", (ev) => { 1553 ev.waitUntil(globalThis.clients.matchAll({ 1554 includeUncontrolled: true, 1555 type: "window" 1556 }).then(async () => { 1557 const data = ev.data?.json(); 1558 switch (data.type) { 1559 // case 'driveFileCreated': 1560 case "notification": 1561 case "unreadAntennaNote": 1562 case "newChatMessage": 1563 if (Date.now() - data.dateTime > 1e3 * 60 * 60 * 24) break; 1564 return createNotification(data); 1565 case "readAllNotifications": 1566 await globalThis.registration.getNotifications().then((notifications) => notifications.forEach((n) => n.tag !== "read_notification" && n.close())); 1567 break; 1568 } 1569 await createEmptyNotification(); 1570 return; 1571 })); 1572}); 1573globalThis.addEventListener("notificationclick", (ev) => { 1574 ev.waitUntil((async () => { 1575 if (true) { 1576 console.log("notificationclick", ev.action, ev.notification.data); 1577 } 1578 const { action, notification } = ev; 1579 const data = notification.data ?? {}; 1580 const { userId: loginId } = data;
1581 let client = null; 1582 switch (data.type) { 1583 case "notification": 1584 switch (action) { 1585 case "follow": 1586 if ("userId" in data.body) await api("following/create", loginId, { userId: data.body.userId }); 1587 break; 1588 case "showUser": 1589 if ("user" in data.body) client = await openUser(acct_exports.toString(data.body.user), loginId); 1590 break; 1591 case "reply": 1592 if ("note" in data.body) client = await openPost({ reply: data.body.note }, loginId); 1593 break; 1594 case "renote": 1595 if ("note" in data.body) await api("notes/create", loginId, { renoteId: data.body.note.id }); 1596 break; 1597 case "accept": 1598 switch (data.body.type) { 1599 case "receiveFollowRequest": 1600 await api("following/requests/accept", loginId, { userId: data.body.userId }); 1601 break; 1602 } 1603 break; 1604 case "reject": 1605 switch (data.body.type) { 1606 case "receiveFollowRequest": 1607 await api("following/requests/reject", loginId, { userId: data.body.userId }); 1608 break; 1609 } 1610 break; 1611 case "showFollowRequests": 1612 client = await openClient("push", "/my/follow-requests", loginId); 1613 break; 1614 case "edited": 1615 if ("note" in data.body) client = await openPost({ reply: data.body.note }, loginId); 1616 break; 1617 default: 1618 switch (data.body.type) { 1619 case "receiveFollowRequest": 1620 client = await openClient("push", "/my/follow-requests", loginId); 1621 break; 1622 case "reaction": 1623 client = await openNote(data.body.note.id, loginId); 1624 break; 1625 default: 1626 if ("note" in data.body) { 1627 client = await openNote(data.body.note.id, loginId); 1628 } else if ("user" in data.body) { 1629 client = await openUser(acct_exports.toString(data.body.user), loginId); 1630 } 1631 break; 1632 } 1633 } 1634 break; 1635 case "unreadAntennaNote": 1636 client = await openAntenna(data.body.antenna.id, loginId); 1637 break; 1638 case "newChatMessage": 1639 client = await openChat(data.body, loginId); 1640 break; 1641 default: 1642 switch (action) { 1643 case "markAllAsRead": 1644 await globalThis.registration.getNotifications().then((notifications) => notifications.forEach((n) => n.tag !== "read_notification" && n.close())); 1645 await get("accounts").then((accounts) => { 1646 return Promise.all((accounts ?? []).map(async (account) => { 1647 await sendMarkAllAsRead(account.id); 1648 })); 1649 }); 1650 break; 1651 case "settings": 1652 client = await openClient("push", "/settings/notifications", loginId); 1653 break; 1654 } 1655 } 1656 if (client) { 1657 client.focus(); 1658 } 1659 if (data.type === "notification") { 1660 await sendMarkAllAsRead(loginId); 1661 } 1662 notification.close(); 1663 })()); 1664}); 1665globalThis.addEventListener("notificationclose", (ev) => { 1666 const data = ev.notification.data; 1667 ev.waitUntil((async () => { 1668 if (data.type === "notification") { 1669 await sendMarkAllAsRead(data.userId); 1670 } 1671 return; 1672 })()); 1673}); 1674globalThis.addEventListener("message", (ev) => { 1675 ev.waitUntil((async () => { 1676 switch (ev.data) { 1677 case "clear": 1678 await caches.keys().then((cacheNames) => Promise.all( 1679 cacheNames.map((name) => caches.delete(name)) 1680 )); 1681 return; 1682 } 1683 if (typeof ev.data === "object") { 1684 const otype = Object.prototype.toString.call(ev.data).slice(8, -1).toLowerCase(); 1685 if (otype === "object") { 1686 if (ev.data.msg === "initialize") { 1687 swLang.setLang(ev.data.lang); 1688 } 1689 } 1690 } 1691 })()); 1692}); 1693/*! Bundled license information: 1694 1695reconnecting-websocket/dist/reconnecting-websocket-mjs.js: 1696 (*! ***************************************************************************** 1697 Copyright (c) Microsoft Corporation. All rights reserved. 1698 Licensed under the Apache License, Version 2.0 (the "License");
1698 you may not use 1699 this file except in compliance with the License. You may obtain a copy of the 1700 License at http://www.apache.org/licenses/LICENSE-2.0 1701 1702 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1703 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 1704 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 1705 MERCHANTABLITY OR NON-INFRINGEMENT. 1706 1707 See the Apache Version 2.0 License for specific language governing permissions 1708 and limitations under the License. 1709 ***************************************************************************** *) 1710 (*! 1711 * Reconnecting WebSocket 1712 * by Pedro Ladaria <[email protected]> 1713 * https://github.com/pladaria/reconnecting-websocket 1714 * License MIT 1715 *) 1716*/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.