@fairfox/polly 0.40.0 → 0.49.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.
- package/README.md +16 -14
- package/dist/src/background/index.d.ts +1 -0
- package/dist/src/background/index.js +65 -2
- package/dist/src/background/index.js.map +8 -7
- package/dist/src/background/message-router.js.map +4 -4
- package/dist/src/client/index.js.map +2 -2
- package/dist/src/elysia/index.js.map +1 -1
- package/dist/src/index.js.map +6 -6
- package/dist/src/mesh-node.js.map +3 -3
- package/dist/src/mesh.js +25 -4
- package/dist/src/mesh.js.map +12 -12
- package/dist/src/peer.js.map +4 -4
- package/dist/src/polly-ui/registry.d.ts +16 -0
- package/dist/src/polly-ui/registry.generated.d.ts +20 -0
- package/dist/src/shared/adapters/index.js.map +3 -3
- package/dist/src/shared/lib/context-helpers.js.map +4 -4
- package/dist/src/shared/lib/mesh-webrtc-adapter.d.ts +24 -1
- package/dist/src/shared/lib/message-bus.js.map +4 -4
- package/dist/src/shared/lib/resource.js.map +3 -3
- package/dist/src/shared/lib/state.js.map +3 -3
- package/dist/src/shared/state/app-state.js.map +3 -3
- package/dist/tools/quality/src/attest.d.ts +55 -0
- package/dist/tools/quality/src/cache.d.ts +34 -0
- package/dist/tools/quality/src/cli.js +1881 -2
- package/dist/tools/quality/src/cli.js.map +14 -4
- package/dist/tools/quality/src/config.d.ts +18 -0
- package/dist/tools/quality/src/host.d.ts +46 -0
- package/dist/tools/quality/src/index.d.ts +7 -0
- package/dist/tools/quality/src/index.js +1780 -1
- package/dist/tools/quality/src/index.js.map +14 -4
- package/dist/tools/quality/src/plugins/cliche-checks.d.ts +16 -0
- package/dist/tools/quality/src/plugins/core-checks.d.ts +20 -0
- package/dist/tools/quality/src/plugins/core.d.ts +18 -0
- package/dist/tools/quality/src/plugins/extra-checks.d.ts +14 -0
- package/dist/tools/quality/src/plugins/import-checks.d.ts +16 -0
- package/dist/tools/quality/src/plugins/polly-ui.d.ts +31 -0
- package/dist/tools/quality/src/types.d.ts +104 -0
- package/dist/tools/test/src/browser/index.js.map +1 -1
- package/dist/tools/test/src/browser/run.js.map +1 -1
- package/dist/tools/verify/src/cli.js +325 -227
- package/dist/tools/verify/src/cli.js.map +10 -9
- package/dist/tools/verify/src/config.js.map +2 -2
- package/dist/tools/visualize/src/cli.js.map +3 -3
- package/package.json +9 -2
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) |
|
|
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]
|
|
284
|
-
polly build [--prod]
|
|
285
|
-
polly dev
|
|
286
|
-
polly check
|
|
287
|
-
polly typecheck
|
|
288
|
-
polly lint [--fix]
|
|
289
|
-
polly format
|
|
290
|
-
polly test
|
|
291
|
-
polly
|
|
292
|
-
polly
|
|
293
|
-
polly
|
|
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=
|
|
1905
|
+
//# debugId=4914221959EE755064756E2164756E21
|