@alwith/module-chat 0.1.2 → 0.1.4

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.
@@ -0,0 +1,10 @@
1
+ export declare class ChatUpdateScheduler<Snapshot> {
2
+ private readonly publish;
3
+ private readonly pending;
4
+ private timer;
5
+ constructor(publish: (snapshots: Readonly<Record<string, Snapshot>>) => void);
6
+ enqueue(sessionId: string, snapshot: Snapshot): void;
7
+ flush(): void;
8
+ remove(sessionId: string): void;
9
+ cancel(): void;
10
+ }
@@ -0,0 +1 @@
1
+ class t{publish;pending=new Map;timer=null;constructor(i){this.publish=i}enqueue(i,e){this.pending.set(i,e),this.timer??=setTimeout(()=>this.flush(),16)}flush(){if(this.timer!==null)clearTimeout(this.timer);if(this.timer=null,this.pending.size===0)return;let i=Object.fromEntries(this.pending);this.pending.clear(),this.publish(i)}remove(i){if(this.pending.delete(i),this.pending.size===0)this.cancel()}cancel(){if(this.timer!==null)clearTimeout(this.timer);this.timer=null,this.pending.clear()}}export{t as ChatUpdateScheduler};
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@alwith/module-chat",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
7
+ "./update-scheduler": {
8
+ "types": "./dist/lib/update-scheduler.d.ts",
9
+ "import": "./dist/lib/update-scheduler.js",
10
+ "default": "./dist/lib/update-scheduler.js"
11
+ },
7
12
  "./markdown-parser.worker": {
8
13
  "types": "./dist/lib/markdown-parser.worker.d.ts",
9
14
  "import": "./dist/lib/markdown-parser.worker.js",
@@ -275,11 +280,14 @@
275
280
  "THIRD_PARTY_NOTICES.md",
276
281
  "licenses"
277
282
  ],
283
+ "alwithBuild": {
284
+ "bundledEntries": ["src/lib/code-highlighter.worker.ts"]
285
+ },
278
286
  "scripts": {
279
287
  "test": "bun test src",
280
288
  "typecheck": "tsc --noEmit",
281
289
  "build": "bun ../../scripts/build-npm.ts",
282
- "prepack": "bun run build"
290
+ "prepack": "bun run build && bun test ../../scripts/__tests__/chat-worker-distribution.test.ts"
283
291
  },
284
292
  "devDependencies": {
285
293
  "@happy-dom/global-registrator": "^20.14.3",