@interncom/diplomatic 0.0.1 → 0.0.3

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 CHANGED
@@ -5,7 +5,7 @@ Secure sync layer for web apps.
5
5
  ## Usage
6
6
 
7
7
  ```tsx
8
- import { useClient, StateManager, useStateWatcher } from '@interncom/diplomatic'
8
+ import { StateManager, useStateWatcher, localStorageStore, DiplomaticClient } from '@interncom/diplomatic'
9
9
 
10
10
  const appState = { count: 0 };
11
11
  const stateMgr = new StateManager(async (op) => {
@@ -14,21 +14,27 @@ const stateMgr = new StateManager(async (op) => {
14
14
  }
15
15
  })
16
16
 
17
+ const client = new DiplomaticClient({
18
+ seed: "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
19
+ hostURL: "https://diplomatic-cloudflare-host.root-a00.workers.dev",
20
+ stateManager: stateMgr,
21
+ store: localStorageStore,
22
+ });
23
+
17
24
  export default function App() {
18
- const [client] = useClient({
19
- seed: "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
20
- hostURL: "https://diplomatic-cloudflare-host.root-a00.workers.dev",
21
- stateManager: stateMgr,
22
- })
23
25
  const count = useStateWatcher(stateMgr, "count", () => appState.count)
24
26
  const inc = () => client.upsert("count", count + 1)
25
27
 
26
28
  return (
27
- <>
29
+ <div style={{ width: "100vw", textAlign: "center" }}>
28
30
  <h1>COUNT</h1>
29
31
  <h2>{count}</h2>
30
- <button type="button" onClick={inc}>+1</button>
31
- </>
32
+ <button onClick={inc}>+1</button>
33
+ </div>
32
34
  )
33
35
  }
34
36
  ```
37
+
38
+ ## Development
39
+
40
+ To deploy npm package: `npm publish --public`.
@@ -8329,6 +8329,7 @@ var DiplomaticClient = class {
8329
8329
  };
8330
8330
  this.websocket.onclose = (e) => {
8331
8331
  console.log("DISCONNECTED");
8332
+ this.connect(hostURL);
8332
8333
  };
8333
8334
  this.websocket.onmessage = (e) => {
8334
8335
  console.log(`RECEIVED: ${e.data}`);
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@interncom/diplomatic",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "description": "Secure sync layer",
6
- "main": "dist/index.js",
6
+ "main": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "files": [
9
9
  "dist"
package/dist/ops.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { type IOp } from './shared/types';
2
- export declare function genUpsertOp<T>(type: string, body: T, version?: number): IOp;