@nil-/xit 0.1.8 → 0.1.9

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/assets/index.js CHANGED
@@ -2800,14 +2800,16 @@ const protobufjs = /* @__PURE__ */ getDefaultExportFromCjs(light), proto_data =
2800
2800
  json: (a, f, u) => {
2801
2801
  const t = i.value_buffer.get(a);
2802
2802
  if (t != null) {
2803
- let s = u.decode(get(t));
2803
+ let s = get(t), o = u.decode(s);
2804
2804
  return {
2805
- set: (o) => {
2806
- s = o, t.set(u.encode(s));
2805
+ set: (r) => {
2806
+ o = r, s = u.encode(o), t.set(s);
2807
2807
  },
2808
- subscribe: (o) => t.subscribe((r) => o(s)),
2809
- update: (o) => {
2810
- t.update((r) => (s = o(s), u.encode(s)));
2808
+ subscribe: (r) => t.subscribe((l) => {
2809
+ l !== s && (s = l, o = u.decode(s)), r(o);
2810
+ }),
2811
+ update: (r) => {
2812
+ t.update((l) => (o = r(o), s = u.encode(o), s));
2811
2813
  }
2812
2814
  };
2813
2815
  }
package/index.d.ts CHANGED
@@ -25,7 +25,7 @@ export type Xit = {
25
25
  number: (t: string, v: number) => Writable<number>;
26
26
  string: (t: string, v: string) => Writable<string>;
27
27
  buffer: (t: string, v: Uint8Array) => Writable<Uint8Array>;
28
- json: <T>(t: string, v: object, codec: CoDec) => Writable<Record<string, any>>;
28
+ json: (t: string, v: object, codec: CoDec) => Writable<Record<string, any>>;
29
29
  };
30
30
  signals: {
31
31
  none: (t: string) => () => void;
@@ -34,7 +34,7 @@ export type Xit = {
34
34
  number: (t: string) => (v: number) => void;
35
35
  string: (t: string) => (v: string) => void;
36
36
  buffer: (t: string) => (v: Uint8Array) => void;
37
- json: <T>(t: string, encoder: CoDec["encode"]) => (v: Record<string, any>) => void;
37
+ json: (t: string, encoder: CoDec["encode"]) => (v: Record<string, any>) => void;
38
38
  };
39
39
  loader: Loader;
40
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nil-/xit",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",