@rivetkit/framework-base 2.0.28 → 2.0.29

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 (3) hide show
  1. package/dist/mod.cjs +1 -1
  2. package/dist/mod.js +139 -111
  3. package/package.json +2 -2
package/dist/mod.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=new WeakMap,v=new WeakMap,g={current:[]};let b=!1;const S=new Set,k=new Map;function C(i){const n=Array.from(i).sort((t,e)=>t instanceof f&&t.options.deps.includes(e)?1:e instanceof f&&e.options.deps.includes(t)?-1:0);for(const t of n){if(g.current.includes(t))continue;g.current.push(t),t.recompute();const e=v.get(t);if(e)for(const s of e){const o=p.get(s);o&&C(o)}}}function O(i){i.listeners.forEach(n=>n({prevVal:i.prevState,currentVal:i.state}))}function F(i){i.listeners.forEach(n=>n({prevVal:i.prevState,currentVal:i.state}))}function R(i){if(S.add(i),!b)try{for(b=!0;S.size>0;){const n=Array.from(S);S.clear();for(const t of n){const e=k.get(t)??t.prevState;t.prevState=e,O(t)}for(const t of n){const e=p.get(t);e&&(g.current.push(t),C(e))}for(const t of n){const e=p.get(t);if(e)for(const s of e)F(s)}}}finally{b=!1,g.current=[],k.clear()}}function G(i){return typeof i=="function"}class m{constructor(n,t){this.listeners=new Set,this.subscribe=e=>{var s,o;this.listeners.add(e);const h=(o=(s=this.options)==null?void 0:s.onSubscribe)==null?void 0:o.call(s,e,this);return()=>{this.listeners.delete(e),h==null||h()}},this.prevState=n,this.state=n,this.options=t}setState(n){var t,e,s;this.prevState=this.state,(t=this.options)!=null&&t.updateFn?this.state=this.options.updateFn(this.prevState)(n):G(n)?this.state=n(this.prevState):this.state=n,(s=(e=this.options)==null?void 0:e.onUpdate)==null||s.call(e),R(this)}}class f{constructor(n){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{const t=[],e=[];for(const s of this.options.deps)t.push(s.prevState),e.push(s.state);return this.lastSeenDepValues=e,{prevDepVals:t,currDepVals:e,prevVal:this.prevState??void 0}},this.recompute=()=>{var t,e;this.prevState=this.state;const{prevDepVals:s,currDepVals:o,prevVal:h}=this.getDepVals();this.state=this.options.fn({prevDepVals:s,currDepVals:o,prevVal:h}),(e=(t=this.options).onUpdate)==null||e.call(t)},this.checkIfRecalculationNeededDeeply=()=>{for(const o of this.options.deps)o instanceof f&&o.checkIfRecalculationNeededDeeply();let t=!1;const e=this.lastSeenDepValues,{currDepVals:s}=this.getDepVals();for(let o=0;o<s.length;o++)if(s[o]!==e[o]){t=!0;break}t&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(const t of this._subscriptions)t()}),this.subscribe=t=>{var e,s;this.listeners.add(t);const o=(s=(e=this.options).onSubscribe)==null?void 0:s.call(e,t,this);return()=>{this.listeners.delete(t),o==null||o()}},this.options=n,this.state=n.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(n=this.options.deps){for(const t of n)if(t instanceof f)t.registerOnGraph(),this.registerOnGraph(t.options.deps);else if(t instanceof m){let e=p.get(t);e||(e=new Set,p.set(t,e)),e.add(this);let s=v.get(this);s||(s=new Set,v.set(this,s)),s.add(t)}}unregisterFromGraph(n=this.options.deps){for(const t of n)if(t instanceof f)this.unregisterFromGraph(t.options.deps);else if(t instanceof m){const e=p.get(t);e&&e.delete(this);const s=v.get(this);s&&s.delete(t)}}}class I{constructor(n){const{eager:t,fn:e,...s}=n;this._derived=new f({...s,fn:()=>{},onUpdate(){e()}}),t&&e()}mount(){return this._derived.mount()}}function N(i,n={}){const t=new m({actors:{}}),e=n.hashFunction||T,s=new Map;function o(h){const r=e(h),_=s.get(r);if(_)return{..._,state:_.state};const d=new f({fn:({currDepVals:[a]})=>a.actors[r],deps:[t]});function V(){async function a(){const c=t.state.actors[r];try{const u=i.getOrCreate(c.opts.name,c.opts.key,{params:c.opts.params,createInRegion:c.opts.createInRegion,createWithInput:c.opts.createWithInput}),l=u.connect();await u.resolve(),t.setState(D=>({...D,actors:{...D.actors,[r]:{...D.actors[r],isConnected:!0,isConnecting:!1,handle:u,connection:l,isError:!1,error:null}}}))}catch(u){t.setState(l=>({...l,actors:{...l.actors,[r]:{...l.actors[r],isError:!0,isConnecting:!1,error:u}}}))}}t.setState(c=>(c.actors[r].isConnecting=!0,c.actors[r].isError=!1,c.actors[r].error=null,a(),c))}const E=new I({fn:()=>{const a=t.state.actors[r];JSON.stringify(t.prevState.actors[r].opts)===JSON.stringify(t.state.actors[r].opts)&&!a.isConnected&&!a.isConnecting&&!a.isError&&a.opts.enabled&&V()},deps:[d]});t.setState(a=>a.actors[r]?a:{...a,actors:{...a.actors,[r]:{hash:r,isConnected:!1,isConnecting:!1,connection:null,handle:null,isError:!1,error:null,opts:h}}});function y(a){t.setState(c=>{const u=c.actors[r];if(!u)throw new Error(`Actor with key "${r}" does not exist.`);let l;return typeof a=="function"?l=a(u):l=a,{...c,actors:{...c.actors,[r]:l}}})}const w=()=>{const a=d.mount(),c=E.mount();return()=>{a(),c()}};return s.set(r,{state:d,key:r,mount:w,setState:y,create:V}),{mount:w,setState:y,state:d,create:V,key:r}}return{getOrCreateActor:o,store:t}}function T({name:i,key:n,params:t}){return JSON.stringify({name:i,key:n,params:t})}exports.createRivetKit=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=new WeakMap,_=new WeakMap,V={current:[]};let m=!1;const v=new Set,k=new Map;function O(i){const n=Array.from(i).sort((t,e)=>t instanceof h&&t.options.deps.includes(e)?1:e instanceof h&&e.options.deps.includes(t)?-1:0);for(const t of n){if(V.current.includes(t))continue;V.current.push(t),t.recompute();const e=_.get(t);if(e)for(const s of e){const r=p.get(s);r&&O(r)}}}function F(i){i.listeners.forEach(n=>n({prevVal:i.prevState,currentVal:i.state}))}function R(i){i.listeners.forEach(n=>n({prevVal:i.prevState,currentVal:i.state}))}function G(i){if(v.add(i),!m)try{for(m=!0;v.size>0;){const n=Array.from(v);v.clear();for(const t of n){const e=k.get(t)??t.prevState;t.prevState=e,F(t)}for(const t of n){const e=p.get(t);e&&(V.current.push(t),O(e))}for(const t of n){const e=p.get(t);if(e)for(const s of e)R(s)}}}finally{m=!1,V.current=[],k.clear()}}function I(i){return typeof i=="function"}class y{constructor(n,t){this.listeners=new Set,this.subscribe=e=>{var s,r;this.listeners.add(e);const d=(r=(s=this.options)==null?void 0:s.onSubscribe)==null?void 0:r.call(s,e,this);return()=>{this.listeners.delete(e),d==null||d()}},this.prevState=n,this.state=n,this.options=t}setState(n){var t,e,s;this.prevState=this.state,(t=this.options)!=null&&t.updateFn?this.state=this.options.updateFn(this.prevState)(n):I(n)?this.state=n(this.prevState):this.state=n,(s=(e=this.options)==null?void 0:e.onUpdate)==null||s.call(e),G(this)}}class h{constructor(n){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{const t=[],e=[];for(const s of this.options.deps)t.push(s.prevState),e.push(s.state);return this.lastSeenDepValues=e,{prevDepVals:t,currDepVals:e,prevVal:this.prevState??void 0}},this.recompute=()=>{var t,e;this.prevState=this.state;const{prevDepVals:s,currDepVals:r,prevVal:d}=this.getDepVals();this.state=this.options.fn({prevDepVals:s,currDepVals:r,prevVal:d}),(e=(t=this.options).onUpdate)==null||e.call(t)},this.checkIfRecalculationNeededDeeply=()=>{for(const r of this.options.deps)r instanceof h&&r.checkIfRecalculationNeededDeeply();let t=!1;const e=this.lastSeenDepValues,{currDepVals:s}=this.getDepVals();for(let r=0;r<s.length;r++)if(s[r]!==e[r]){t=!0;break}t&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(const t of this._subscriptions)t()}),this.subscribe=t=>{var e,s;this.listeners.add(t);const r=(s=(e=this.options).onSubscribe)==null?void 0:s.call(e,t,this);return()=>{this.listeners.delete(t),r==null||r()}},this.options=n,this.state=n.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(n=this.options.deps){for(const t of n)if(t instanceof h)t.registerOnGraph(),this.registerOnGraph(t.options.deps);else if(t instanceof y){let e=p.get(t);e||(e=new Set,p.set(t,e)),e.add(this);let s=_.get(this);s||(s=new Set,_.set(this,s)),s.add(t)}}unregisterFromGraph(n=this.options.deps){for(const t of n)if(t instanceof h)this.unregisterFromGraph(t.options.deps);else if(t instanceof y){const e=p.get(t);e&&e.delete(this);const s=_.get(this);s&&s.delete(t)}}}class N{constructor(n){const{eager:t,fn:e,...s}=n;this._derived=new h({...s,fn:()=>{},onUpdate(){e()}}),t&&e()}mount(){return this._derived.mount()}}function T(i,n={}){const t=new y({actors:{}}),e=n.hashFunction||A,s=new Map;function r(d){const o=e(d),D=s.get(o);if(D)return{...D,state:D.state};const g=new h({fn:({currDepVals:[a]})=>a.actors[o],deps:[t]});function b(){async function a(){const c=t.state.actors[o];try{const f=i.getOrCreate(c.opts.name,c.opts.key,{params:c.opts.params,createInRegion:c.opts.createInRegion,createWithInput:c.opts.createWithInput}),u=f.connect();u.onOpen(()=>{t.setState(l=>{var S;return((S=l.actors[o])==null?void 0:S.connection)!==u?l:{...l,actors:{...l.actors,[o]:{...l.actors[o],isConnected:!0}}}})}),u.onClose(()=>{t.setState(l=>{var S;return((S=l.actors[o])==null?void 0:S.connection)!==u?l:{...l,actors:{...l.actors,[o]:{...l.actors[o],isConnected:!1}}}})}),await f.resolve(),t.setState(l=>({...l,actors:{...l.actors,[o]:{...l.actors[o],isConnected:u.isConnected,isConnecting:!1,handle:f,connection:u,isError:!1,error:null}}}))}catch(f){t.setState(u=>({...u,actors:{...u.actors,[o]:{...u.actors[o],isError:!0,isConnecting:!1,error:f}}}))}}t.setState(c=>(c.actors[o].isConnecting=!0,c.actors[o].isError=!1,c.actors[o].error=null,a(),c))}const E=new N({fn:()=>{const a=t.state.actors[o];JSON.stringify(t.prevState.actors[o].opts)===JSON.stringify(t.state.actors[o].opts)&&!a.isConnected&&!a.isConnecting&&!a.isError&&a.opts.enabled&&b()},deps:[g]});t.setState(a=>a.actors[o]?a:{...a,actors:{...a.actors,[o]:{hash:o,isConnected:!1,isConnecting:!1,connection:null,handle:null,isError:!1,error:null,opts:d}}});function w(a){t.setState(c=>{const f=c.actors[o];if(!f)throw new Error(`Actor with key "${o}" does not exist.`);let u;return typeof a=="function"?u=a(f):u=a,{...c,actors:{...c.actors,[o]:u}}})}const C=()=>{const a=g.mount(),c=E.mount();return()=>{a(),c()}};return s.set(o,{state:g,key:o,mount:C,setState:w,create:b}),{mount:C,setState:w,state:g,create:b,key:o}}return{getOrCreateActor:r,store:t}}function A({name:i,key:n,params:t}){return JSON.stringify({name:i,key:n,params:t})}exports.createRivetKit=T;
package/dist/mod.js CHANGED
@@ -1,19 +1,19 @@
1
- const p = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), g = {
1
+ const d = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), V = {
2
2
  current: []
3
3
  };
4
- let b = !1;
5
- const S = /* @__PURE__ */ new Set(), k = /* @__PURE__ */ new Map();
6
- function C(i) {
7
- const n = Array.from(i).sort((t, e) => t instanceof f && t.options.deps.includes(e) ? 1 : e instanceof f && e.options.deps.includes(t) ? -1 : 0);
4
+ let m = !1;
5
+ const v = /* @__PURE__ */ new Set(), k = /* @__PURE__ */ new Map();
6
+ function E(i) {
7
+ const n = Array.from(i).sort((t, e) => t instanceof h && t.options.deps.includes(e) ? 1 : e instanceof h && e.options.deps.includes(t) ? -1 : 0);
8
8
  for (const t of n) {
9
- if (g.current.includes(t))
9
+ if (V.current.includes(t))
10
10
  continue;
11
- g.current.push(t), t.recompute();
12
- const e = v.get(t);
11
+ V.current.push(t), t.recompute();
12
+ const e = _.get(t);
13
13
  if (e)
14
14
  for (const s of e) {
15
- const o = p.get(s);
16
- o && C(o);
15
+ const r = d.get(s);
16
+ r && E(r);
17
17
  }
18
18
  }
19
19
  }
@@ -25,7 +25,7 @@ function F(i) {
25
25
  })
26
26
  );
27
27
  }
28
- function O(i) {
28
+ function G(i) {
29
29
  i.listeners.forEach(
30
30
  (n) => n({
31
31
  prevVal: i.prevState,
@@ -33,51 +33,51 @@ function O(i) {
33
33
  })
34
34
  );
35
35
  }
36
- function G(i) {
37
- if (S.add(i), !b)
36
+ function I(i) {
37
+ if (v.add(i), !m)
38
38
  try {
39
- for (b = !0; S.size > 0; ) {
40
- const n = Array.from(S);
41
- S.clear();
39
+ for (m = !0; v.size > 0; ) {
40
+ const n = Array.from(v);
41
+ v.clear();
42
42
  for (const t of n) {
43
43
  const e = k.get(t) ?? t.prevState;
44
44
  t.prevState = e, F(t);
45
45
  }
46
46
  for (const t of n) {
47
- const e = p.get(t);
48
- e && (g.current.push(t), C(e));
47
+ const e = d.get(t);
48
+ e && (V.current.push(t), E(e));
49
49
  }
50
50
  for (const t of n) {
51
- const e = p.get(t);
51
+ const e = d.get(t);
52
52
  if (e)
53
53
  for (const s of e)
54
- O(s);
54
+ G(s);
55
55
  }
56
56
  }
57
57
  } finally {
58
- b = !1, g.current = [], k.clear();
58
+ m = !1, V.current = [], k.clear();
59
59
  }
60
60
  }
61
- function I(i) {
61
+ function R(i) {
62
62
  return typeof i == "function";
63
63
  }
64
- class m {
64
+ class w {
65
65
  constructor(n, t) {
66
66
  this.listeners = /* @__PURE__ */ new Set(), this.subscribe = (e) => {
67
- var s, o;
67
+ var s, r;
68
68
  this.listeners.add(e);
69
- const h = (o = (s = this.options) == null ? void 0 : s.onSubscribe) == null ? void 0 : o.call(s, e, this);
69
+ const p = (r = (s = this.options) == null ? void 0 : s.onSubscribe) == null ? void 0 : r.call(s, e, this);
70
70
  return () => {
71
- this.listeners.delete(e), h == null || h();
71
+ this.listeners.delete(e), p == null || p();
72
72
  };
73
73
  }, this.prevState = n, this.state = n, this.options = t;
74
74
  }
75
75
  setState(n) {
76
76
  var t, e, s;
77
- this.prevState = this.state, (t = this.options) != null && t.updateFn ? this.state = this.options.updateFn(this.prevState)(n) : I(n) ? this.state = n(this.prevState) : this.state = n, (s = (e = this.options) == null ? void 0 : e.onUpdate) == null || s.call(e), G(this);
77
+ this.prevState = this.state, (t = this.options) != null && t.updateFn ? this.state = this.options.updateFn(this.prevState)(n) : R(n) ? this.state = n(this.prevState) : this.state = n, (s = (e = this.options) == null ? void 0 : e.onUpdate) == null || s.call(e), I(this);
78
78
  }
79
79
  }
80
- class f {
80
+ class h {
81
81
  constructor(n) {
82
82
  this.listeners = /* @__PURE__ */ new Set(), this._subscriptions = [], this.lastSeenDepValues = [], this.getDepVals = () => {
83
83
  const t = [], e = [];
@@ -91,19 +91,19 @@ class f {
91
91
  }, this.recompute = () => {
92
92
  var t, e;
93
93
  this.prevState = this.state;
94
- const { prevDepVals: s, currDepVals: o, prevVal: h } = this.getDepVals();
94
+ const { prevDepVals: s, currDepVals: r, prevVal: p } = this.getDepVals();
95
95
  this.state = this.options.fn({
96
96
  prevDepVals: s,
97
- currDepVals: o,
98
- prevVal: h
97
+ currDepVals: r,
98
+ prevVal: p
99
99
  }), (e = (t = this.options).onUpdate) == null || e.call(t);
100
100
  }, this.checkIfRecalculationNeededDeeply = () => {
101
- for (const o of this.options.deps)
102
- o instanceof f && o.checkIfRecalculationNeededDeeply();
101
+ for (const r of this.options.deps)
102
+ r instanceof h && r.checkIfRecalculationNeededDeeply();
103
103
  let t = !1;
104
104
  const e = this.lastSeenDepValues, { currDepVals: s } = this.getDepVals();
105
- for (let o = 0; o < s.length; o++)
106
- if (s[o] !== e[o]) {
105
+ for (let r = 0; r < s.length; r++)
106
+ if (s[r] !== e[r]) {
107
107
  t = !0;
108
108
  break;
109
109
  }
@@ -115,9 +115,9 @@ class f {
115
115
  }), this.subscribe = (t) => {
116
116
  var e, s;
117
117
  this.listeners.add(t);
118
- const o = (s = (e = this.options).onSubscribe) == null ? void 0 : s.call(e, t, this);
118
+ const r = (s = (e = this.options).onSubscribe) == null ? void 0 : s.call(e, t, this);
119
119
  return () => {
120
- this.listeners.delete(t), o == null || o();
120
+ this.listeners.delete(t), r == null || r();
121
121
  };
122
122
  }, this.options = n, this.state = n.fn({
123
123
  prevDepVals: void 0,
@@ -127,31 +127,31 @@ class f {
127
127
  }
128
128
  registerOnGraph(n = this.options.deps) {
129
129
  for (const t of n)
130
- if (t instanceof f)
130
+ if (t instanceof h)
131
131
  t.registerOnGraph(), this.registerOnGraph(t.options.deps);
132
- else if (t instanceof m) {
133
- let e = p.get(t);
134
- e || (e = /* @__PURE__ */ new Set(), p.set(t, e)), e.add(this);
135
- let s = v.get(this);
136
- s || (s = /* @__PURE__ */ new Set(), v.set(this, s)), s.add(t);
132
+ else if (t instanceof w) {
133
+ let e = d.get(t);
134
+ e || (e = /* @__PURE__ */ new Set(), d.set(t, e)), e.add(this);
135
+ let s = _.get(this);
136
+ s || (s = /* @__PURE__ */ new Set(), _.set(this, s)), s.add(t);
137
137
  }
138
138
  }
139
139
  unregisterFromGraph(n = this.options.deps) {
140
140
  for (const t of n)
141
- if (t instanceof f)
141
+ if (t instanceof h)
142
142
  this.unregisterFromGraph(t.options.deps);
143
- else if (t instanceof m) {
144
- const e = p.get(t);
143
+ else if (t instanceof w) {
144
+ const e = d.get(t);
145
145
  e && e.delete(this);
146
- const s = v.get(this);
146
+ const s = _.get(this);
147
147
  s && s.delete(t);
148
148
  }
149
149
  }
150
150
  }
151
- class R {
151
+ class N {
152
152
  constructor(n) {
153
153
  const { eager: t, fn: e, ...s } = n;
154
- this._derived = new f({
154
+ this._derived = new h({
155
155
  ...s,
156
156
  fn: () => {
157
157
  },
@@ -164,26 +164,26 @@ class R {
164
164
  return this._derived.mount();
165
165
  }
166
166
  }
167
- function A(i, n = {}) {
168
- const t = new m({
167
+ function L(i, n = {}) {
168
+ const t = new w({
169
169
  actors: {}
170
- }), e = n.hashFunction || N, s = /* @__PURE__ */ new Map();
171
- function o(h) {
172
- const r = e(h), _ = s.get(r);
173
- if (_)
170
+ }), e = n.hashFunction || A, s = /* @__PURE__ */ new Map();
171
+ function r(p) {
172
+ const o = e(p), D = s.get(o);
173
+ if (D)
174
174
  return {
175
- ..._,
176
- state: _.state
175
+ ...D,
176
+ state: D.state
177
177
  };
178
- const d = new f({
179
- fn: ({ currDepVals: [a] }) => a.actors[r],
178
+ const g = new h({
179
+ fn: ({ currDepVals: [a] }) => a.actors[o],
180
180
  deps: [t]
181
181
  });
182
- function V() {
182
+ function b() {
183
183
  async function a() {
184
- const c = t.state.actors[r];
184
+ const c = t.state.actors[o];
185
185
  try {
186
- const u = i.getOrCreate(
186
+ const f = i.getOrCreate(
187
187
  c.opts.name,
188
188
  c.opts.key,
189
189
  {
@@ -191,107 +191,135 @@ function A(i, n = {}) {
191
191
  createInRegion: c.opts.createInRegion,
192
192
  createWithInput: c.opts.createWithInput
193
193
  }
194
- ), l = u.connect();
195
- await u.resolve(
194
+ ), u = f.connect();
195
+ u.onOpen(() => {
196
+ t.setState((l) => {
197
+ var S;
198
+ return ((S = l.actors[o]) == null ? void 0 : S.connection) !== u ? l : {
199
+ ...l,
200
+ actors: {
201
+ ...l.actors,
202
+ [o]: {
203
+ ...l.actors[o],
204
+ isConnected: !0
205
+ }
206
+ }
207
+ };
208
+ });
209
+ }), u.onClose(() => {
210
+ t.setState((l) => {
211
+ var S;
212
+ return ((S = l.actors[o]) == null ? void 0 : S.connection) !== u ? l : {
213
+ ...l,
214
+ actors: {
215
+ ...l.actors,
216
+ [o]: {
217
+ ...l.actors[o],
218
+ isConnected: !1
219
+ }
220
+ }
221
+ };
222
+ });
223
+ }), await f.resolve(
196
224
  /*{ signal: AbortSignal.timeout(0) }*/
197
- ), t.setState((D) => ({
198
- ...D,
225
+ ), t.setState((l) => ({
226
+ ...l,
199
227
  actors: {
200
- ...D.actors,
201
- [r]: {
202
- ...D.actors[r],
203
- isConnected: !0,
228
+ ...l.actors,
229
+ [o]: {
230
+ ...l.actors[o],
231
+ isConnected: u.isConnected,
204
232
  isConnecting: !1,
205
- handle: u,
206
- connection: l,
233
+ handle: f,
234
+ connection: u,
207
235
  isError: !1,
208
236
  error: null
209
237
  }
210
238
  }
211
239
  }));
212
- } catch (u) {
213
- t.setState((l) => ({
214
- ...l,
240
+ } catch (f) {
241
+ t.setState((u) => ({
242
+ ...u,
215
243
  actors: {
216
- ...l.actors,
217
- [r]: {
218
- ...l.actors[r],
244
+ ...u.actors,
245
+ [o]: {
246
+ ...u.actors[o],
219
247
  isError: !0,
220
248
  isConnecting: !1,
221
- error: u
249
+ error: f
222
250
  }
223
251
  }
224
252
  }));
225
253
  }
226
254
  }
227
- t.setState((c) => (c.actors[r].isConnecting = !0, c.actors[r].isError = !1, c.actors[r].error = null, a(), c));
255
+ t.setState((c) => (c.actors[o].isConnecting = !0, c.actors[o].isError = !1, c.actors[o].error = null, a(), c));
228
256
  }
229
- const E = new R({
257
+ const O = new N({
230
258
  fn: () => {
231
- const a = t.state.actors[r];
232
- JSON.stringify(t.prevState.actors[r].opts) === JSON.stringify(t.state.actors[r].opts) && !a.isConnected && !a.isConnecting && !a.isError && a.opts.enabled && V();
259
+ const a = t.state.actors[o];
260
+ JSON.stringify(t.prevState.actors[o].opts) === JSON.stringify(t.state.actors[o].opts) && !a.isConnected && !a.isConnecting && !a.isError && a.opts.enabled && b();
233
261
  },
234
- deps: [d]
262
+ deps: [g]
235
263
  });
236
- t.setState((a) => a.actors[r] ? a : {
264
+ t.setState((a) => a.actors[o] ? a : {
237
265
  ...a,
238
266
  actors: {
239
267
  ...a.actors,
240
- [r]: {
241
- hash: r,
268
+ [o]: {
269
+ hash: o,
242
270
  isConnected: !1,
243
271
  isConnecting: !1,
244
272
  connection: null,
245
273
  handle: null,
246
274
  isError: !1,
247
275
  error: null,
248
- opts: h
276
+ opts: p
249
277
  }
250
278
  }
251
279
  });
252
- function w(a) {
280
+ function y(a) {
253
281
  t.setState((c) => {
254
- const u = c.actors[r];
255
- if (!u)
256
- throw new Error(`Actor with key "${r}" does not exist.`);
257
- let l;
258
- return typeof a == "function" ? l = a(u) : l = a, {
282
+ const f = c.actors[o];
283
+ if (!f)
284
+ throw new Error(`Actor with key "${o}" does not exist.`);
285
+ let u;
286
+ return typeof a == "function" ? u = a(f) : u = a, {
259
287
  ...c,
260
288
  actors: {
261
289
  ...c.actors,
262
- [r]: l
290
+ [o]: u
263
291
  }
264
292
  };
265
293
  });
266
294
  }
267
- const y = () => {
268
- const a = d.mount(), c = E.mount();
295
+ const C = () => {
296
+ const a = g.mount(), c = O.mount();
269
297
  return () => {
270
298
  a(), c();
271
299
  };
272
300
  };
273
- return s.set(r, {
274
- state: d,
275
- key: r,
276
- mount: y,
277
- setState: w,
278
- create: V
301
+ return s.set(o, {
302
+ state: g,
303
+ key: o,
304
+ mount: C,
305
+ setState: y,
306
+ create: b
279
307
  }), {
280
- mount: y,
281
- setState: w,
282
- state: d,
283
- create: V,
284
- key: r
308
+ mount: C,
309
+ setState: y,
310
+ state: g,
311
+ create: b,
312
+ key: o
285
313
  };
286
314
  }
287
315
  return {
288
- getOrCreateActor: o,
316
+ getOrCreateActor: r,
289
317
  store: t
290
318
  };
291
319
  }
292
- function N({ name: i, key: n, params: t }) {
320
+ function A({ name: i, key: n, params: t }) {
293
321
  return JSON.stringify({ name: i, key: n, params: t });
294
322
  }
295
323
  export {
296
- A as createRivetKit
324
+ L as createRivetKit
297
325
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivetkit/framework-base",
3
- "version": "2.0.28",
3
+ "version": "2.0.29",
4
4
  "description": "Base framework utilities for RivetKit client integrations",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -37,7 +37,7 @@
37
37
  "stableVersion": "0.8.0",
38
38
  "dependencies": {
39
39
  "@tanstack/store": "^0.7.1",
40
- "rivetkit": "2.0.28"
40
+ "rivetkit": "2.0.29"
41
41
  },
42
42
  "scripts": {
43
43
  "dev": "vite build --watch",