mobx-solid 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
@@ -2,7 +2,28 @@
2
2
 
3
3
  MobX bindings for [SolidJS](https://www.solidjs.com/) — reactive state management with fine-grained UI updates.
4
4
 
5
- # [Read docs →](https://js2me.github.io/mobx-solid)
5
+ Bridge MobX observables with SolidJS's compile-time reactivity — no proxy hacks, no double tracking.
6
+
7
+ **~0.4 kB gzip** · Zero config · TypeScript-first · SSR-ready
8
+
9
+ ---
10
+
11
+ ## 📖 [Read docs →](https://js2me.github.io/mobx-solid)
12
+
13
+ ---
14
+
15
+ ## Why mobx-solid?
16
+
17
+ | Feature | What you get |
18
+ |---|---|
19
+ | Fine-grained reactivity | Only DOM nodes that depend on changed observables update |
20
+ | MobX ecosystem | `observable`, `action`, `computed`, `autorun` — the full toolbox |
21
+ | Zero boilerplate | No `observer()` HOC, no `useSyncExternalStore` — just write components |
22
+ | SSR support | Works with SolidJS server-side rendering out of the box |
23
+ | TypeScript-first | Full type safety with zero `any` escapes |
24
+ | Tiny footprint | ~0.4 kB gzip — minimal runtime overhead |
25
+
26
+ ---
6
27
 
7
28
  ## Installation
8
29
 
@@ -12,6 +33,8 @@ npm install mobx-solid mobx solid-js
12
33
  pnpm add mobx-solid mobx solid-js
13
34
  ```
14
35
 
36
+ ---
37
+
15
38
  ## Quick Start
16
39
 
17
40
  ```tsx
@@ -19,6 +42,7 @@ import { enableObservableTracking } from "mobx-solid";
19
42
  import { observable } from "mobx";
20
43
  import { render } from "solid-js/web";
21
44
 
45
+ // Enable MobX → SolidJS reactivity bridge (call once at app startup)
22
46
  enableObservableTracking();
23
47
 
24
48
  const store = observable({
@@ -45,6 +69,49 @@ function Counter() {
45
69
  render(() => <Counter />, document.getElementById("app")!);
46
70
  ```
47
71
 
72
+ > Call `enableObservableTracking()` once at your app's entry point — after that, MobX observables automatically integrate with SolidJS's reactivity system.
73
+
74
+ ---
75
+
76
+ ## How it works
77
+
78
+ mobx-solid hooks into MobX's internal reaction tracking and translates observable reads into SolidJS reactive primitives. When a MobX observable changes, only the exact SolidJS DOM nodes that read that value update — true fine-grained reactivity, not component-level re-rendering.
79
+
80
+ ---
81
+
82
+ ## API
83
+
84
+ | Function | Description |
85
+ |---|---|
86
+ | `enableObservableTracking()` | Enable the MobX → SolidJS reactivity bridge |
87
+ | `disableObservableTracking()` | Disable the bridge (useful for SSR cleanup) |
88
+ | `observable` | MobX observable — works with SolidJS components automatically |
89
+ | `computed` | MobX computed — auto-tracked by SolidJS |
90
+ | `action` | MobX action — batch mutations for optimal DOM updates |
91
+
92
+ ---
93
+
94
+ ## SSR Support
95
+
96
+ ```tsx
97
+ import { enableObservableTracking, disableObservableTracking } from "mobx-solid";
98
+
99
+ enableObservableTracking();
100
+ const html = renderToString(() => <App />);
101
+ disableObservableTracking(); // Clean up after rendering
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Compatibility
107
+
108
+ - MobX **6.x**
109
+ - SolidJS **1.6+**
110
+ - TypeScript **5.x**
111
+ - SSR / Hydration
112
+
113
+ ---
114
+
48
115
  ## License
49
116
 
50
- MIT
117
+ MIT © [Sergey Volkov](https://github.com/js2me)
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * [**Documentation**](https://js2me.github.io/mobx-solid/api/enable-observable-tracking)
5
5
  */
6
- export declare function enableObservableTracking(): void;
7
- /** @internal Whether `enableObservableTracking()` has already been called. */
8
- export declare function isObservableTrackingEnabled(): boolean;
6
+ export declare const enableObservableTracking: {
7
+ (): void;
8
+ _: boolean;
9
+ };
9
10
  //# sourceMappingURL=enable-observable-tracking.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enable-observable-tracking.d.ts","sourceRoot":"","sources":["../src/enable-observable-tracking.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAuB/C;AAED,8EAA8E;AAC9E,wBAAgB,2BAA2B,IAAI,OAAO,CAErD"}
1
+ {"version":3,"file":"enable-observable-tracking.d.ts","sourceRoot":"","sources":["../src/enable-observable-tracking.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;CAsBpC,CAAA"}
package/dist/index.js CHANGED
@@ -1,34 +1,34 @@
1
- import { Reaction as s, untracked as l, autorun as u } from "mobx";
2
- import { enableExternalSource as i, createSignal as c, onCleanup as b } from "solid-js";
3
- let a = !1;
4
- function p() {
5
- a || (a = !0, i(
6
- (e, t) => {
7
- const r = new s("mobx-solid", t);
1
+ import { Reaction as u, untracked as i, reaction as l } from "mobx";
2
+ import { enableExternalSource as f, createSignal as a, untrack as b, onCleanup as d } from "solid-js";
3
+ const p = "mobx-solid", s = () => {
4
+ s._ || (s._ = !0, f(
5
+ (e, n) => {
6
+ const t = new u(p, n);
8
7
  return {
9
- track: (n) => {
8
+ track: (r) => {
10
9
  let o;
11
- return r.track(() => {
12
- o = e(n);
10
+ return t.track(() => {
11
+ o = e(r);
13
12
  }), o;
14
13
  },
15
- dispose: () => {
16
- r.dispose();
17
- }
14
+ dispose: () => t.dispose()
18
15
  };
19
16
  },
20
- (e) => l(e)
17
+ i
21
18
  ));
19
+ };
20
+ s._ = !1;
21
+ const c = { equals: !1 }, m = { equals: () => !1 };
22
+ function S(e) {
23
+ const [n] = a(e(), c);
24
+ return n;
22
25
  }
23
- function k(e) {
24
- const [t, r] = c(void 0, {
25
- equals: !1
26
- }), n = u(() => {
27
- r(e);
28
- });
29
- return b(n), t;
26
+ function _(e) {
27
+ const [n, t] = a(b(e), c), r = l(e, (o) => t(() => o), m);
28
+ return d(r), n;
30
29
  }
30
+ const v = typeof window > "u" ? S : _;
31
31
  export {
32
- p as enableObservableTracking,
33
- k as obs
32
+ s as enableObservableTracking,
33
+ v as obs
34
34
  };
package/dist/obs.d.ts CHANGED
@@ -1,8 +1,3 @@
1
1
  import { Accessor } from 'solid-js';
2
- /**
3
- * Converts a MobX observable expression into a SolidJS signal accessor.
4
- *
5
- * [**Documentation**](https://js2me.github.io/mobx-solid/api/obs)
6
- */
7
- export declare function obs<T>(getter: () => T): Accessor<T>;
2
+ export declare const obs: <T>(getter: () => T) => Accessor<T>;
8
3
  //# sourceMappingURL=obs.d.ts.map
package/dist/obs.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"obs.d.ts","sourceRoot":"","sources":["../src/obs.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAYnD"}
1
+ {"version":3,"file":"obs.d.ts","sourceRoot":"","sources":["../src/obs.ts"],"names":[],"mappings":"AACA,OAAO,EAAoC,KAAK,QAAQ,EAAsB,MAAM,UAAU,CAAC;AA4B/F,eAAO,MAAM,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,QAAQ,CAAC,CAAC,CACA,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mobx-solid",
3
- "version": "0.0.1",
4
- "description": "MobX bindings for SolidJS — reactive state management with fine-grained UI updates",
3
+ "version": "0.0.3",
4
+ "description": "MobX bindings for SolidJS — reactive state management with fine-grained UI updates (~0.4 kB gzip)",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -17,6 +17,13 @@
17
17
  "dist"
18
18
  ],
19
19
  "sideEffects": false,
20
+ "size-limit": [
21
+ {
22
+ "path": "dist/index.js",
23
+ "gzip": true,
24
+ "limit": "0.45 kB"
25
+ }
26
+ ],
20
27
  "publishConfig": {
21
28
  "access": "public"
22
29
  },
@@ -27,12 +34,14 @@
27
34
  "devDependencies": {
28
35
  "@changesets/changelog-github": "^0.7.0",
29
36
  "@changesets/cli": "^2.31.1",
37
+ "@size-limit/file": "^13.0.1",
30
38
  "@solidjs/testing-library": "^0.8.10",
31
39
  "@testing-library/dom": "^10.4.1",
32
40
  "@testing-library/jest-dom": "^6.9.1",
33
41
  "docusite": "^0.1.6",
34
42
  "jsdom": "^26.1.0",
35
43
  "mobx": "^6.16.0",
44
+ "size-limit": "^13.0.1",
36
45
  "solid-js": "^1.9.0",
37
46
  "typescript": "^5.8.0",
38
47
  "vite": "^6.3.0",
@@ -47,7 +56,21 @@
47
56
  "reactive",
48
57
  "state-management",
49
58
  "observer",
50
- "fine-grained"
59
+ "fine-grained",
60
+ "observable",
61
+ "computed",
62
+ "action",
63
+ "mobx-solid",
64
+ "solid-js",
65
+ "bindings",
66
+ "bridge",
67
+ "ssr",
68
+ "typescript",
69
+ "store",
70
+ "state",
71
+ "reactivity",
72
+ "fine-grained-reactivity",
73
+ "no-vdom"
51
74
  ],
52
75
  "license": "MIT",
53
76
  "homepage": "https://js2me.github.io/mobx-solid",
@@ -69,6 +92,7 @@
69
92
  "docs:build": "docusite build",
70
93
  "docs:preview": "docusite preview",
71
94
  "changeset:version": "bash scripts/changeset-version.sh",
72
- "pub": "pnpm build && changeset publish"
95
+ "pub": "pnpm build && changeset publish",
96
+ "size-limit": "size-limit"
73
97
  }
74
98
  }