This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * TODO: clean this module up massively. | |
| * | |
| * - Use class instead of func impl (...?) | |
| * | |
| */ | |
| import type { Item, Nullable } from "$lib/types"; | |
| import { Logger, addToQueue, getSrc, notify, seededShuffle, type ResponseBody } from "$lib/utils"; | |
| import { Mutex } from "$lib/utils/sync"; | |
| import { splice } from "$lib/utils/collections/array"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let intersectionObserver: IntersectionObserver; | |
| const observerCallback = (entries: IntersectionObserverEntry[], ob) => { | |
| for (let idx = 0; idx < entries.length; idx++) { | |
| const entry = entries[idx]; | |
| const target = entry.target as HTMLImageElement; | |
| if (entry.isIntersecting) { | |
| target.decode().finally(() => { | |
| target.src = target.dataset.src; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function buildCron() { | |
| const { update, subscribe, set } = writable<Cron>({ | |
| seconds: 0, | |
| minutes: 0, | |
| hours: "*", | |
| month: "*", | |
| dayOfMonth: "*", | |
| days: "*", | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable @typescript-eslint/no-inferrable-types */ | |
| import { browser } from "$app/environment"; | |
| import { cubicOut } from "svelte/easing"; | |
| import { tweened } from "svelte/motion"; | |
| import type { Unsubscriber } from "svelte/store"; | |
| import { get } from "svelte/store"; | |
| import SessionListService, { type ISessionListProvider } from "./stores/list"; | |
| import { groupSession, type ConnectionState } from "./stores/sessions"; | |
| import { currentTitle } from "./stores/stores"; | |
| import type { Nullable } from "./types"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { writable } from "svelte/store"; | |
| export type CronValue = "*" | `${"*" | number | string}/${number | string}` | `${string}/${string}` | string | number; | |
| export type Cron = { | |
| seconds: CronValue; | |
| minutes: CronValue; | |
| hours: CronValue; | |
| month: CronValue; | |
| dayOfMonth: CronValue; | |
| days: (number | string)[] | "*"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let textDecoder: TextDecoder; | |
| let textEncoder: TextEncoder = new TextEncoder(); | |
| type BufferEncoding = | |
| | "ascii" | |
| | "utf8" | |
| | "utf-8" | |
| | "utf16le" | |
| | "ucs2" | |
| | "ucs-2" | |
| | "base64" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const _onEvent: onEventStore = (storeFn: (events: EventOrProfile[]) => Promise<void>) => { | |
| let cursorIdx = 0; | |
| let currentBatch: EventOrProfile[] = [] | |
| let isTaking = false; | |
| const pool = new Map<number, EventOrProfile[]>([]); | |
| let allEventIds: Set<string> = new Set([]) | |
| let size = 0; | |
| function add(event: IEvent) { | |
| if (event.id && allEventIds.has(event.id)) return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class LazyIterator<T extends any[] = any[]> { | |
| #_: T[] = [] as T | |
| #_iterator: IterableIterator<T> | Generator<T> | |
| // #fnQueue: ((...args: T[number]) => T[number] | boolean)[] = [] | |
| constructor(...entries: readonly [...T[]]) | |
| constructor(entries: readonly T[]) | |
| constructor(entries: T) { | |
| this.#elements = entries; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { browser } from "./internals/utils"; | |
| import { Worker as NodeWorker } from "./internals/NodeWorker.js"; | |
| import { BroadcastChannel } from "./threads/channel"; | |
| import { StatusCode } from "./models"; | |
| import type { | |
| GetReturnType, | |
| IThreadSpawner, | |
| } from "./models/thread"; | |
| const TEMPLATE_NODE = `const { parentPort } = require('worker_threads'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // import { relayPool } from 'nostr-tools'; | |
| // import { validateEvent } from 'nostr-tools'; | |
| import { relayPool, type RelayPool } from './lib/nostr-tools'; | |
| import { validateEvent } from './lib/nostr-tools'; | |
| import { db } from './db'; | |
| import type { IProfile, IEvent } from './db'; | |
| import { snooze, setImmediate, yieldMicrotask } from './utils'; | |
| export class $Data { | |
| public pool!: RelayPool; | |
| private allEventIds!: Set<string> |