@fairfox/polly 0.47.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +16 -14
  2. package/dist/src/background/index.d.ts +1 -0
  3. package/dist/src/background/index.js +65 -2
  4. package/dist/src/background/index.js.map +8 -7
  5. package/dist/src/background/message-router.js.map +4 -4
  6. package/dist/src/client/index.js.map +2 -2
  7. package/dist/src/elysia/index.js.map +1 -1
  8. package/dist/src/index.js.map +6 -6
  9. package/dist/src/mesh-node.js.map +3 -3
  10. package/dist/src/mesh.js +49 -17
  11. package/dist/src/mesh.js.map +13 -13
  12. package/dist/src/peer.js +16 -10
  13. package/dist/src/peer.js.map +7 -7
  14. package/dist/src/shared/adapters/index.js.map +3 -3
  15. package/dist/src/shared/lib/context-helpers.js.map +4 -4
  16. package/dist/src/shared/lib/mesh-client.d.ts +31 -9
  17. package/dist/src/shared/lib/mesh-network-adapter.d.ts +22 -5
  18. package/dist/src/shared/lib/mesh-webrtc-adapter.d.ts +24 -1
  19. package/dist/src/shared/lib/message-bus.js.map +4 -4
  20. package/dist/src/shared/lib/resource.js.map +3 -3
  21. package/dist/src/shared/lib/state.js.map +3 -3
  22. package/dist/src/shared/state/app-state.js.map +3 -3
  23. package/dist/tools/quality/src/cli.js +217 -74
  24. package/dist/tools/quality/src/cli.js.map +9 -8
  25. package/dist/tools/quality/src/index.js +217 -74
  26. package/dist/tools/quality/src/index.js.map +9 -8
  27. package/dist/tools/quality/src/plugins/cliche-checks.d.ts +16 -0
  28. package/dist/tools/quality/src/plugins/core.d.ts +1 -1
  29. package/dist/tools/test/src/browser/index.js.map +1 -1
  30. package/dist/tools/test/src/browser/run.js.map +1 -1
  31. package/dist/tools/verify/src/cli.js +2 -2
  32. package/dist/tools/verify/src/cli.js.map +8 -8
  33. package/dist/tools/verify/src/config.js.map +2 -2
  34. package/dist/tools/visualize/src/cli.js.map +3 -3
  35. package/package.json +2 -1
package/README.md CHANGED
@@ -99,7 +99,7 @@ The four primitives above keep state consistent inside a single deployment. But
99
99
  **`$peerState`** — every device holds a full [Automerge](https://automerge.org/) CRDT replica. The server holds one too, so cron and HTTP handlers can read and mutate documents. If the server loses its storage, any reconnecting client repopulates it through the normal sync protocol.
100
100
 
101
101
  ```typescript
102
- import { createPeerStateClient, configurePeerState, $peerState } from "@fairfox/polly";
102
+ import { createPeerStateClient, configurePeerState, $peerState } from "@fairfox/polly/peer";
103
103
 
104
104
  const client = createPeerStateClient({ url: "wss://yourapp.com/polly/peer" });
105
105
  configurePeerState(client.repo);
@@ -112,7 +112,7 @@ settings.value = { theme: "light" }; // syncs to every peer
112
112
  **`$meshState`** — peers exchange operations directly over WebRTC data channels, signed with Ed25519 and encrypted with XSalsa20-Poly1305. No server sees the data. A small stateless signalling server helps peers find each other; removing it does not affect running connections.
113
113
 
114
114
  ```typescript
115
- import { configureMeshState, $meshState, MeshNetworkAdapter, MeshWebRTCAdapter } from "@fairfox/polly";
115
+ import { configureMeshState, $meshState, MeshNetworkAdapter, MeshWebRTCAdapter } from "@fairfox/polly/mesh";
116
116
 
117
117
  const repo = new Repo({ network: [new MeshNetworkAdapter({ base: webrtcAdapter, keyring })] });
118
118
  configureMeshState(repo);
@@ -275,22 +275,24 @@ bun install && bun run dev
275
275
  | [full-featured](examples/full-featured) | Production Chrome extension with all framework features |
276
276
  | [elysia-todo-app](examples/elysia-todo-app) | Full-stack web app with Elysia + Bun, offline-first |
277
277
  | [webrtc-p2p-chat](examples/webrtc-p2p-chat) | Peer-to-peer chat over WebRTC data channels |
278
- | [team-task-manager](examples/team-task-manager) | Collaborative task management with end-to-end encryption |
278
+ | [team-task-manager](examples/team-task-manager) | Role-based collaborative tasks with `$constraints()` and verified urgent-task counts |
279
279
 
280
280
  ## CLI
281
281
 
282
282
  ```
283
- polly init [name] Scaffold a new project
284
- polly build [--prod] Build for development or production
285
- polly dev Build with watch mode
286
- polly check Run all checks (typecheck, lint, test, build)
287
- polly typecheck Type-check your code
288
- polly lint [--fix] Lint (and optionally auto-fix)
289
- polly format Format your code
290
- polly test Run tests
291
- polly verify Run formal verification
292
- polly visualize Generate architecture diagrams (Structurizr DSL)
293
- polly quality Run conformance checks (no-as-casting)
283
+ polly init [name] [--type=TYPE] Scaffold a new project (extension | pwa | websocket | generic)
284
+ polly build [--prod] Build for development or production
285
+ polly dev Build with watch mode
286
+ polly check Run all checks (typecheck, lint, test, build)
287
+ polly typecheck Type-check your code
288
+ polly lint [--fix] Lint (and optionally auto-fix)
289
+ polly format Format your code
290
+ polly test [args] Run unit tests (bun test)
291
+ polly test:browser [dir] Run *.browser.{ts,tsx} in Puppeteer
292
+ polly verify Run formal verification (TLA+/TLC)
293
+ polly visualize Generate architecture diagrams (Structurizr DSL)
294
+ polly quality [args] Run conformance checks (no-as-casting, boundaries, secrets,
295
+ server-imports, forbidden-deps, banners, marketing, ...)
294
296
  ```
295
297
 
296
298
  ## Quality tooling
@@ -36,4 +36,5 @@ import type { BaseMessage, ExtensionMessage } from "../shared/types/messages";
36
36
  */
37
37
  export declare function createBackground<TMessage extends BaseMessage = ExtensionMessage>(adapters?: ExtensionAdapters): MessageBus<TMessage>;
38
38
  export { getMessageBus } from "../shared/lib/message-bus";
39
+ export { LogStore, type LogStoreOptions } from "./log-store";
39
40
  export { MessageRouter } from "./message-router";
@@ -1826,6 +1826,68 @@ class MessageRouter {
1826
1826
  MessageRouter.instanceExists = false;
1827
1827
  }
1828
1828
  }
1829
+ // src/background/log-store.ts
1830
+ class LogStore {
1831
+ bus;
1832
+ logs = [];
1833
+ maxLogs;
1834
+ constructor(bus, options) {
1835
+ this.bus = bus || getMessageBus("background");
1836
+ this.maxLogs = options?.maxLogs || 1000;
1837
+ this.setupHandlers();
1838
+ }
1839
+ setupHandlers() {
1840
+ this.bus.on("LOG", async (payload) => {
1841
+ const entry = {
1842
+ id: crypto.randomUUID(),
1843
+ level: payload.level,
1844
+ message: payload.message,
1845
+ ...payload.context && { context: payload.context },
1846
+ ...payload.error && { error: payload.error },
1847
+ ...payload.stack && { stack: payload.stack },
1848
+ source: payload.source,
1849
+ timestamp: payload.timestamp
1850
+ };
1851
+ this.logs.push(entry);
1852
+ if (this.logs.length > this.maxLogs) {
1853
+ this.logs.shift();
1854
+ }
1855
+ return { success: true };
1856
+ });
1857
+ this.bus.on("LOGS_GET", async (payload) => {
1858
+ let filtered = this.logs;
1859
+ if (payload.filters?.level) {
1860
+ filtered = filtered.filter((log) => log.level === payload.filters?.level);
1861
+ }
1862
+ if (payload.filters?.source) {
1863
+ filtered = filtered.filter((log) => log.source === payload.filters?.source);
1864
+ }
1865
+ if (payload.filters?.since !== undefined) {
1866
+ const since = payload.filters.since;
1867
+ filtered = filtered.filter((log) => log.timestamp >= since);
1868
+ }
1869
+ if (payload.filters?.limit) {
1870
+ filtered = filtered.slice(-payload.filters.limit);
1871
+ }
1872
+ return { logs: filtered };
1873
+ });
1874
+ this.bus.on("LOGS_CLEAR", async () => {
1875
+ const count = this.logs.length;
1876
+ this.logs = [];
1877
+ return { success: true, count };
1878
+ });
1879
+ this.bus.on("LOGS_EXPORT", async () => {
1880
+ const json = JSON.stringify(this.logs, null, 2);
1881
+ return { json, count: this.logs.length };
1882
+ });
1883
+ }
1884
+ getCount() {
1885
+ return this.logs.length;
1886
+ }
1887
+ getAllLogs() {
1888
+ return [...this.logs];
1889
+ }
1890
+ }
1829
1891
 
1830
1892
  // src/background/index.ts
1831
1893
  function createBackground(adapters) {
@@ -1836,7 +1898,8 @@ function createBackground(adapters) {
1836
1898
  export {
1837
1899
  getMessageBus,
1838
1900
  createBackground,
1839
- MessageRouter
1901
+ MessageRouter,
1902
+ LogStore
1840
1903
  };
1841
1904
 
1842
- //# debugId=B8B01C48D6E4EE6364756E2164756E21
1905
+ //# debugId=4914221959EE755064756E2164756E21