tinybase 4.5.5 → 4.5.7

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.
@@ -1 +1 @@
1
- "use strict";const t=t=>typeof t,e=t(""),a="t",s=(t,e)=>t.startsWith(e),n=Promise,r=t=>null==t,i=(t,e,a)=>r(t)?a?.():e(t),o=(t,e,a)=>t.slice(e,a),c=t=>t.length,l=async t=>n.all(t),g=(t,e)=>t.map(e),h=(t,...e)=>t.push(...e),f=Object,u=(t=[])=>f.fromEntries(t),w=(t,e)=>g(f.entries(t),(([t,a])=>e(a,t))),y=(t,e,a)=>(((t,e)=>!r(((t,e)=>i(t,(t=>t[e])))(t,e)))(t,e)||(t[e]=a()),t[e]),p=t=>JSON.stringify(t,((t,e)=>e instanceof Map?f.fromEntries([...e]):e)),S=JSON.parse,d=(a,s,n)=>a+s+(t(n)==e?n:p(n)),x=(t,e,a)=>{const n=c(t);return s(e,t)?[e[n],(a?S:String)(o(e,n+1))]:void 0},P=(t,e)=>((t,e)=>t?.forEach(e))(t,((t,a)=>e(a,t))),m="hasStore",D=u(g(["Origin","Methods","Headers"],(t=>["Access-Control-Allow-"+t,"*"]))),b=async(t,e="")=>!!await t.get(e+m),R=async(t,e="")=>{const s={},n={};return P(await t.list(),((t,r)=>i(x(e,t),(([t,e])=>{if(t==a){const[t,a,n]=S("["+e+"]");y(y(s,t,u),a,u)[n]=r}else"v"==t&&(n[e]=r)})))),[s,n]},T=async(t,e,a)=>t.party.broadcast(d(t.config.messagePrefix,"s",e),a),C=async(t,e,n,i)=>{const o=t.party.storage,g=t.config.storagePrefix,f={[g+m]:1},u=[],y=[];await l(w(e[0],(async(e,s)=>r(e)?!n&&t.canDelTable(s,i)&&((t,...e)=>t.unshift(...e))(y,v(g,a,s)):t.canSetTable(s,n,i)&&await l(w(e,(async(e,c)=>r(e)?!n&&t.canDelRow(s,c,i)&&h(y,v(g,a,s,c)):t.canSetRow(s,c,n,i)&&await l(w(e,(async(e,l)=>{const w=[s,c,l],y=v(g,a,...w);r(e)?!n&&t.canDelCell(...w,i)&&h(u,y):t.canSetCell(...w,e,n,i,await o.get(y))&&(f[y]=e)}))))))))),await l(w(e[1],(async(e,a)=>{const s=g+"v"+a;r(e)?!n&&t.canDelValue(a,i)&&h(u,s):t.canSetValue(a,e,n,i,await o.get(s))&&(f[s]=e)}))),0!=c(y)&&P(await o.list(),(t=>y.every((e=>!s(t,e)||h(u,t)&&0)))),await o.delete(u),await o.put(f)},v=(t,e,...a)=>d(t,e,o(p(a),1,-1)),O=async(t,e,a=null)=>new Response(a,{status:e,headers:t.config.responseHeaders});exports.TinyBasePartyKitServer=class{constructor(t){this.party=t,this.config={},this.config.storePath??="/store",this.config.messagePrefix??="",this.config.storagePrefix??="",this.config.responseHeaders??=D}async onRequest(t){const{party:{storage:e},config:{storePath:a,storagePrefix:s}}=this;if(new URL(t.url).pathname.endsWith(a)){const a=await b(e,s),n=await t.text();return"PUT"==t.method?a?O(this,205):(await C(this,S(n),!0,t),O(this,201)):O(this,200,a?p(await R(e,s)):"")}return O(this,404)}async onMessage(t,e){const{config:{messagePrefix:a,storagePrefix:s}}=this;await i(x(a,t,1),(async([t,a])=>{"s"==t&&await b(this.party.storage,s)&&(await C(this,a,!1,e),T(this,a,[e.id]))}))}canSetTable(t,e,a){return!0}canDelTable(t,e){return!0}canSetRow(t,e,a,s){return!0}canDelRow(t,e,a){return!0}canSetCell(t,e,a,s,n,r,i){return!0}canDelCell(t,e,a,s){return!0}canSetValue(t,e,a,s,n){return!0}canDelValue(t,e){return!0}},exports.broadcastTransactionChanges=T,exports.hasStoreInStorage=b,exports.loadStoreFromStorage=R;
1
+ "use strict";const a=a=>typeof a,t=a(""),e="t",s=(a,t)=>a.startsWith(t),n=Promise,r=a=>null==a,i=(a,t,e)=>r(a)?e?.():t(a),c=(a,t,e)=>a.slice(t,e),o=a=>a.length,l=async a=>n.all(a),w=(a,t)=>a.map(t),g=(a,...t)=>a.push(...t),h=Object,y=(a=[])=>h.fromEntries(a),f=(a,t)=>w(h.entries(a),(([a,e])=>t(e,a))),u=(a,t,e)=>(((a,t)=>!r(((a,t)=>i(a,(a=>a[t])))(a,t)))(a,t)||(a[t]=e()),a[t]),p=a=>JSON.stringify(a,((a,t)=>t instanceof Map?h.fromEntries([...t]):t)),S=JSON.parse,d=(e,s,n)=>e+s+(a(n)==t?n:p(n)),x=(a,t,e)=>{const n=o(a);return s(t,a)?[t[n],(e?S:String)(c(t,n+1))]:void 0},P=(a,t)=>((a,t)=>a?.forEach(t))(a,((a,e)=>t(e,a))),m="hasStore",D=y(w(["Origin","Methods","Headers"],(a=>["Access-Control-Allow-"+a,"*"]))),b=async(a,t="")=>!!await a.get(t+m),R=async(a,t="")=>{const s={},n={};return P(await a.list(),((a,r)=>i(x(t,a),(([a,t])=>{if(a==e){const[a,e,n]=S("["+t+"]");u(u(s,a,y),e,y)[n]=r}else"v"==a&&(n[t]=r)})))),[s,n]},T=async(a,t,e)=>a.party.broadcast(d(a.config.messagePrefix,"s",t),e),C=async(a,t,n,i)=>{const c=a.party.storage,w=a.config.storagePrefix,h={[w+m]:1},y=[],u=[];await l(f(t[0],(async(t,s)=>r(t)?!n&&await a.canDelTable(s,i)&&((a,...t)=>a.unshift(...t))(u,v(w,e,s)):await a.canSetTable(s,n,i)&&await l(f(t,(async(t,o)=>r(t)?!n&&await a.canDelRow(s,o,i)&&g(u,v(w,e,s,o)):await a.canSetRow(s,o,n,i)&&await l(f(t,(async(t,l)=>{const f=[s,o,l],u=v(w,e,...f);r(t)?!n&&await a.canDelCell(...f,i)&&g(y,u):await a.canSetCell(...f,t,n,i,await c.get(u))&&(h[u]=t)}))))))))),await l(f(t[1],(async(t,e)=>{const s=w+"v"+e;r(t)?!n&&await a.canDelValue(e,i)&&g(y,s):await a.canSetValue(e,t,n,i,await c.get(s))&&(h[s]=t)}))),0!=o(u)&&P(await c.list(),(a=>u.every((t=>!s(a,t)||g(y,a)&&0)))),await c.delete(y),await c.put(h)},v=(a,t,...e)=>d(a,t,c(p(e),1,-1)),O=async(a,t,e=null)=>new Response(e,{status:t,headers:a.config.responseHeaders});exports.TinyBasePartyKitServer=class{constructor(a){this.party=a,this.config={},this.config.storePath??="/store",this.config.messagePrefix??="",this.config.storagePrefix??="",this.config.responseHeaders??=D}async onRequest(a){const{party:{storage:t},config:{storePath:e,storagePrefix:s}}=this;if(new URL(a.url).pathname.endsWith(e)){const e=await b(t,s),n=await a.text();return"PUT"==a.method?e?O(this,205):(await C(this,S(n),!0,a),O(this,201)):O(this,200,e?p(await R(t,s)):"")}return O(this,404)}async onMessage(a,t){const{config:{messagePrefix:e,storagePrefix:s}}=this;await i(x(e,a,1),(async([a,e])=>{"s"==a&&await b(this.party.storage,s)&&(await C(this,e,!1,t),T(this,e,[t.id]))}))}async canSetTable(a,t,e){return!0}async canDelTable(a,t){return!0}async canSetRow(a,t,e,s){return!0}async canDelRow(a,t,e){return!0}async canSetCell(a,t,e,s,n,r,i){return!0}async canDelCell(a,t,e,s){return!0}async canSetValue(a,t,e,s,n){return!0}async canDelValue(a,t){return!0}},exports.broadcastTransactionChanges=T,exports.hasStoreInStorage=b,exports.loadStoreFromStorage=R;
@@ -1 +1 @@
1
- "use strict";const e=e=>typeof e,t=e(""),n="t",r=(e,t)=>e.startsWith(t),s=Promise,i=e=>null==e,o=(e,t,n)=>i(e)?null==n?void 0:n():t(e),l=(e,t,n)=>e.slice(t,n),a=e=>e.length,c=e=>{return t=function*(){return s.all(e)},new Promise(((e,n)=>{var r=e=>{try{i(t.next(e))}catch(e){n(e)}},s=e=>{try{i(t.throw(e))}catch(e){n(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,s);i((t=t.apply(void 0,null)).next())}));var t},u=(e,t)=>e.map(t),d=(e,...t)=>e.push(...t),h=Object,f=(e=[])=>h.fromEntries(e),y=(e,t)=>u(h.entries(e),(([e,n])=>t(n,e))),g=(e,t,n)=>(((e,t)=>!i(((e,t)=>o(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),v=e=>JSON.stringify(e,((e,t)=>t instanceof Map?h.fromEntries([...t]):t)),p=JSON.parse,P=(n,r,s)=>n+r+(e(s)==t?s:v(s)),x=(e,t,n)=>{const s=a(e);return r(t,e)?[t[s],(n?p:String)(l(t,s+1))]:void 0},S=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var m=(e,t,n)=>new Promise(((r,s)=>{var i=e=>{try{l(n.next(e))}catch(e){s(e)}},o=e=>{try{l(n.throw(e))}catch(e){s(e)}},l=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,o);l((n=n.apply(e,t)).next())}));const w="hasStore",D=f(u(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),b=(e,...t)=>m(void 0,[e,...t],(function*(e,t=""){return!!(yield e.get(t+w))})),R=(e,...t)=>m(void 0,[e,...t],(function*(e,t=""){const r={},s={};return S(yield e.list(),((e,i)=>o(x(t,e),(([e,t])=>{if(e==n){const[e,n,s]=p("["+t+"]");g(g(r,e,f),n,f)[s]=i}else"v"==e&&(s[t]=i)})))),[r,s]})),T=(e,t,n)=>m(void 0,null,(function*(){return e.party.broadcast(P(e.config.messagePrefix,"s",t),n)})),C=(e,t,s,o)=>m(void 0,null,(function*(){const l=e.party.storage,u=e.config.storagePrefix,h={[u+w]:1},f=[],g=[];yield c(y(t[0],((t,r)=>m(void 0,null,(function*(){return i(t)?!s&&e.canDelTable(r,o)&&((e,...t)=>e.unshift(...t))(g,H(u,n,r)):e.canSetTable(r,s,o)&&(yield c(y(t,((t,a)=>m(void 0,null,(function*(){return i(t)?!s&&e.canDelRow(r,a,o)&&d(g,H(u,n,r,a)):e.canSetRow(r,a,s,o)&&(yield c(y(t,((t,c)=>m(void 0,null,(function*(){const y=[r,a,c],g=H(u,n,...y);i(t)?!s&&e.canDelCell(...y,o)&&d(f,g):e.canSetCell(...y,t,s,o,yield l.get(g))&&(h[g]=t)}))))))}))))))}))))),yield c(y(t[1],((t,n)=>m(void 0,null,(function*(){const r=u+"v"+n;i(t)?!s&&e.canDelValue(n,o)&&d(f,r):e.canSetValue(n,t,s,o,yield l.get(r))&&(h[r]=t)}))))),0!=a(g)&&S(yield l.list(),(e=>g.every((t=>!r(e,t)||d(f,e)&&0)))),yield l.delete(f),yield l.put(h)})),H=(e,t,...n)=>P(e,t,l(v(n),1,-1)),O=(e,t,n=null)=>m(void 0,null,(function*(){return new Response(n,{status:t,headers:e.config.responseHeaders})}));exports.TinyBasePartyKitServer=class{constructor(e){var t,n,r,s;this.party=e,this.config={},null!=(t=this.config).storePath||(t.storePath="/store"),null!=(n=this.config).messagePrefix||(n.messagePrefix=""),null!=(r=this.config).storagePrefix||(r.storagePrefix=""),null!=(s=this.config).responseHeaders||(s.responseHeaders=D)}onRequest(e){return m(this,null,(function*(){const{party:{storage:t},config:{storePath:n,storagePrefix:r}}=this;if(new URL(e.url).pathname.endsWith(n)){const n=yield b(t,r),s=yield e.text();return"PUT"==e.method?n?O(this,205):(yield C(this,p(s),!0,e),O(this,201)):O(this,200,n?v(yield R(t,r)):"")}return O(this,404)}))}onMessage(e,t){return m(this,null,(function*(){const{config:{messagePrefix:n,storagePrefix:r}}=this;yield o(x(n,e,1),(e=>m(this,[e],(function*([e,n]){"s"==e&&(yield b(this.party.storage,r))&&(yield C(this,n,!1,t),T(this,n,[t.id]))}))))}))}canSetTable(e,t,n){return!0}canDelTable(e,t){return!0}canSetRow(e,t,n,r){return!0}canDelRow(e,t,n){return!0}canSetCell(e,t,n,r,s,i,o){return!0}canDelCell(e,t,n,r){return!0}canSetValue(e,t,n,r,s){return!0}canDelValue(e,t){return!0}},exports.broadcastTransactionChanges=T,exports.hasStoreInStorage=b,exports.loadStoreFromStorage=R;
1
+ "use strict";const e=e=>typeof e,t=e(""),n="t",r=(e,t)=>e.startsWith(t),i=Promise,l=e=>null==e,s=(e,t,n)=>l(e)?null==n?void 0:n():t(e),o=(e,t,n)=>e.slice(t,n),u=e=>e.length,a=e=>{return t=function*(){return i.all(e)},new Promise(((e,n)=>{var r=e=>{try{l(t.next(e))}catch(e){n(e)}},i=e=>{try{l(t.throw(e))}catch(e){n(e)}},l=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,i);l((t=t.apply(void 0,null)).next())}));var t},c=(e,t)=>e.map(t),d=(e,...t)=>e.push(...t),h=Object,f=(e=[])=>h.fromEntries(e),y=(e,t)=>c(h.entries(e),(([e,n])=>t(n,e))),g=(e,t,n)=>(((e,t)=>!l(((e,t)=>s(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),v=e=>JSON.stringify(e,((e,t)=>t instanceof Map?h.fromEntries([...t]):t)),p=JSON.parse,P=(n,r,i)=>n+r+(e(i)==t?i:v(i)),x=(e,t,n)=>{const i=u(e);return r(t,e)?[t[i],(n?p:String)(o(t,i+1))]:void 0},S=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var m=(e,t,n)=>new Promise(((r,i)=>{var l=e=>{try{o(n.next(e))}catch(e){i(e)}},s=e=>{try{o(n.throw(e))}catch(e){i(e)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(l,s);o((n=n.apply(e,t)).next())}));const w="hasStore",D=f(c(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),b=(e,...t)=>m(void 0,[e,...t],(function*(e,t=""){return!!(yield e.get(t+w))})),R=(e,...t)=>m(void 0,[e,...t],(function*(e,t=""){const r={},i={};return S(yield e.list(),((e,l)=>s(x(t,e),(([e,t])=>{if(e==n){const[e,n,i]=p("["+t+"]");g(g(r,e,f),n,f)[i]=l}else"v"==e&&(i[t]=l)})))),[r,i]})),T=(e,t,n)=>m(void 0,null,(function*(){return e.party.broadcast(P(e.config.messagePrefix,"s",t),n)})),C=(e,t,i,s)=>m(void 0,null,(function*(){const o=e.party.storage,c=e.config.storagePrefix,h={[c+w]:1},f=[],g=[];yield a(y(t[0],((t,r)=>m(void 0,null,(function*(){return l(t)?!i&&(yield e.canDelTable(r,s))&&((e,...t)=>e.unshift(...t))(g,H(c,n,r)):(yield e.canSetTable(r,i,s))&&(yield a(y(t,((t,u)=>m(void 0,null,(function*(){return l(t)?!i&&(yield e.canDelRow(r,u,s))&&d(g,H(c,n,r,u)):(yield e.canSetRow(r,u,i,s))&&(yield a(y(t,((t,a)=>m(void 0,null,(function*(){const y=[r,u,a],g=H(c,n,...y);l(t)?!i&&(yield e.canDelCell(...y,s))&&d(f,g):(yield e.canSetCell(...y,t,i,s,yield o.get(g)))&&(h[g]=t)}))))))}))))))}))))),yield a(y(t[1],((t,n)=>m(void 0,null,(function*(){const r=c+"v"+n;l(t)?!i&&(yield e.canDelValue(n,s))&&d(f,r):(yield e.canSetValue(n,t,i,s,yield o.get(r)))&&(h[r]=t)}))))),0!=u(g)&&S(yield o.list(),(e=>g.every((t=>!r(e,t)||d(f,e)&&0)))),yield o.delete(f),yield o.put(h)})),H=(e,t,...n)=>P(e,t,o(v(n),1,-1)),O=(e,t,n=null)=>m(void 0,null,(function*(){return new Response(n,{status:t,headers:e.config.responseHeaders})}));exports.TinyBasePartyKitServer=class{constructor(e){var t,n,r,i;this.party=e,this.config={},null!=(t=this.config).storePath||(t.storePath="/store"),null!=(n=this.config).messagePrefix||(n.messagePrefix=""),null!=(r=this.config).storagePrefix||(r.storagePrefix=""),null!=(i=this.config).responseHeaders||(i.responseHeaders=D)}onRequest(e){return m(this,null,(function*(){const{party:{storage:t},config:{storePath:n,storagePrefix:r}}=this;if(new URL(e.url).pathname.endsWith(n)){const n=yield b(t,r),i=yield e.text();return"PUT"==e.method?n?O(this,205):(yield C(this,p(i),!0,e),O(this,201)):O(this,200,n?v(yield R(t,r)):"")}return O(this,404)}))}onMessage(e,t){return m(this,null,(function*(){const{config:{messagePrefix:n,storagePrefix:r}}=this;yield s(x(n,e,1),(e=>m(this,[e],(function*([e,n]){"s"==e&&(yield b(this.party.storage,r))&&(yield C(this,n,!1,t),T(this,n,[t.id]))}))))}))}canSetTable(e,t,n){return m(this,null,(function*(){return!0}))}canDelTable(e,t){return m(this,null,(function*(){return!0}))}canSetRow(e,t,n,r){return m(this,null,(function*(){return!0}))}canDelRow(e,t,n){return m(this,null,(function*(){return!0}))}canSetCell(e,t,n,r,i,l,s){return m(this,null,(function*(){return!0}))}canDelCell(e,t,n,r){return m(this,null,(function*(){return!0}))}canSetValue(e,t,n,r,i){return m(this,null,(function*(){return!0}))}canDelValue(e,t){return m(this,null,(function*(){return!0}))}},exports.broadcastTransactionChanges=T,exports.hasStoreInStorage=b,exports.loadStoreFromStorage=R;
@@ -111,42 +111,45 @@ const saveStore = async (
111
111
  objMap(transactionChanges[0], async (table, tableId) =>
112
112
  isUndefined(table)
113
113
  ? !initialSave &&
114
- that.canDelTable(tableId, requestOrConnection) &&
114
+ (await that.canDelTable(tableId, requestOrConnection)) &&
115
115
  arrayUnshift(
116
116
  keyPrefixesToDel,
117
117
  constructStorageKey(storagePrefix, T, tableId),
118
118
  )
119
- : that.canSetTable(tableId, initialSave, requestOrConnection) &&
119
+ : (await that.canSetTable(tableId, initialSave, requestOrConnection)) &&
120
120
  (await promiseAll(
121
121
  objMap(table, async (row, rowId) =>
122
122
  isUndefined(row)
123
123
  ? !initialSave &&
124
- that.canDelRow(tableId, rowId, requestOrConnection) &&
124
+ (await that.canDelRow(tableId, rowId, requestOrConnection)) &&
125
125
  arrayPush(
126
126
  keyPrefixesToDel,
127
127
  constructStorageKey(storagePrefix, T, tableId, rowId),
128
128
  )
129
- : that.canSetRow(
129
+ : (await that.canSetRow(
130
130
  tableId,
131
131
  rowId,
132
132
  initialSave,
133
133
  requestOrConnection,
134
- ) &&
134
+ )) &&
135
135
  (await promiseAll(
136
136
  objMap(row, async (cell, cellId) => {
137
137
  const ids = [tableId, rowId, cellId];
138
138
  const key = constructStorageKey(storagePrefix, T, ...ids);
139
139
  isUndefined(cell)
140
140
  ? !initialSave &&
141
- that.canDelCell(...ids, requestOrConnection) &&
141
+ (await that.canDelCell(
142
+ ...ids,
143
+ requestOrConnection,
144
+ )) &&
142
145
  arrayPush(keysToDel, key)
143
- : that.canSetCell(
146
+ : (await that.canSetCell(
144
147
  ...ids,
145
148
  cell,
146
149
  initialSave,
147
150
  requestOrConnection,
148
151
  await storage.get(key),
149
- ) && (keysToSet[key] = cell);
152
+ )) && (keysToSet[key] = cell);
150
153
  }),
151
154
  )),
152
155
  ),
@@ -158,15 +161,15 @@ const saveStore = async (
158
161
  const key = storagePrefix + V + valueId;
159
162
  isUndefined(value)
160
163
  ? !initialSave &&
161
- that.canDelValue(valueId, requestOrConnection) &&
164
+ (await that.canDelValue(valueId, requestOrConnection)) &&
162
165
  arrayPush(keysToDel, key)
163
- : that.canSetValue(
166
+ : (await that.canSetValue(
164
167
  valueId,
165
168
  value,
166
169
  initialSave,
167
170
  requestOrConnection,
168
171
  await storage.get(key),
169
- ) && (keysToSet[key] = value);
172
+ )) && (keysToSet[key] = value);
170
173
  }),
171
174
  );
172
175
  if (!arrayIsEmpty(keyPrefixesToDel)) {
@@ -240,19 +243,19 @@ class TinyBasePartyKitServer {
240
243
  },
241
244
  );
242
245
  }
243
- canSetTable(_tableId, _initialSave, _requestOrConnection) {
246
+ async canSetTable(_tableId, _initialSave, _requestOrConnection) {
244
247
  return true;
245
248
  }
246
- canDelTable(_tableId, _connection) {
249
+ async canDelTable(_tableId, _connection) {
247
250
  return true;
248
251
  }
249
- canSetRow(_tableId, _rowId, _initialSave, _requestOrConnection) {
252
+ async canSetRow(_tableId, _rowId, _initialSave, _requestOrConnection) {
250
253
  return true;
251
254
  }
252
- canDelRow(_tableId, _rowId, _connection) {
255
+ async canDelRow(_tableId, _rowId, _connection) {
253
256
  return true;
254
257
  }
255
- canSetCell(
258
+ async canSetCell(
256
259
  _tableId,
257
260
  _rowId,
258
261
  _cellId,
@@ -263,13 +266,19 @@ class TinyBasePartyKitServer {
263
266
  ) {
264
267
  return true;
265
268
  }
266
- canDelCell(_tableId, _rowId, _cellId, _connection) {
269
+ async canDelCell(_tableId, _rowId, _cellId, _connection) {
267
270
  return true;
268
271
  }
269
- canSetValue(_valueId, _value, _initialSave, _requestOrConnection, _oldValue) {
272
+ async canSetValue(
273
+ _valueId,
274
+ _value,
275
+ _initialSave,
276
+ _requestOrConnection,
277
+ _oldValue,
278
+ ) {
270
279
  return true;
271
280
  }
272
- canDelValue(_valueId, _connection) {
281
+ async canDelValue(_valueId, _connection) {
273
282
  return true;
274
283
  }
275
284
  }
@@ -1 +1 @@
1
- const e=e=>typeof e,t=e(""),n="t",r=(e,t)=>e.startsWith(t),i=Promise,s=e=>null==e,l=(e,t,n)=>s(e)?null==n?void 0:n():t(e),o=(e,t,n)=>e.slice(t,n),a=e=>e.length,c=e=>{return t=function*(){return i.all(e)},new Promise(((e,n)=>{var r=e=>{try{s(t.next(e))}catch(e){n(e)}},i=e=>{try{s(t.throw(e))}catch(e){n(e)}},s=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,i);s((t=t.apply(void 0,null)).next())}));var t},u=(e,t)=>e.map(t),d=(e,...t)=>e.push(...t),f=Object,h=(e=[])=>f.fromEntries(e),y=(e,t)=>u(f.entries(e),(([e,n])=>t(n,e))),g=(e,t,n)=>(((e,t)=>!s(((e,t)=>l(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),v=e=>JSON.stringify(e,((e,t)=>t instanceof Map?f.fromEntries([...t]):t)),p=JSON.parse,P=(n,r,i)=>n+r+(e(i)==t?i:v(i)),x=(e,t,n)=>{const i=a(e);return r(t,e)?[t[i],(n?p:String)(o(t,i+1))]:void 0},m=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var S=(e,t,n)=>new Promise(((r,i)=>{var s=e=>{try{o(n.next(e))}catch(e){i(e)}},l=e=>{try{o(n.throw(e))}catch(e){i(e)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,l);o((n=n.apply(e,t)).next())}));const w="hasStore",D=h(u(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),R=(e,...t)=>S(void 0,[e,...t],(function*(e,t=""){return!!(yield e.get(t+w))})),b=(e,...t)=>S(void 0,[e,...t],(function*(e,t=""){const r={},i={};return m(yield e.list(),((e,s)=>l(x(t,e),(([e,t])=>{if(e==n){const[e,n,i]=p("["+t+"]");g(g(r,e,h),n,h)[i]=s}else"v"==e&&(i[t]=s)})))),[r,i]})),C=(e,t,n)=>S(void 0,null,(function*(){return e.party.broadcast(P(e.config.messagePrefix,"s",t),n)})),T=(e,t,i,l)=>S(void 0,null,(function*(){const o=e.party.storage,u=e.config.storagePrefix,f={[u+w]:1},h=[],g=[];yield c(y(t[0],((t,r)=>S(void 0,null,(function*(){return s(t)?!i&&e.canDelTable(r,l)&&((e,...t)=>e.unshift(...t))(g,H(u,n,r)):e.canSetTable(r,i,l)&&(yield c(y(t,((t,a)=>S(void 0,null,(function*(){return s(t)?!i&&e.canDelRow(r,a,l)&&d(g,H(u,n,r,a)):e.canSetRow(r,a,i,l)&&(yield c(y(t,((t,c)=>S(void 0,null,(function*(){const y=[r,a,c],g=H(u,n,...y);s(t)?!i&&e.canDelCell(...y,l)&&d(h,g):e.canSetCell(...y,t,i,l,yield o.get(g))&&(f[g]=t)}))))))}))))))}))))),yield c(y(t[1],((t,n)=>S(void 0,null,(function*(){const r=u+"v"+n;s(t)?!i&&e.canDelValue(n,l)&&d(h,r):e.canSetValue(n,t,i,l,yield o.get(r))&&(f[r]=t)}))))),0!=a(g)&&m(yield o.list(),(e=>g.every((t=>!r(e,t)||d(h,e)&&0)))),yield o.delete(h),yield o.put(f)})),H=(e,t,...n)=>P(e,t,o(v(n),1,-1)),O=(e,t,n=null)=>S(void 0,null,(function*(){return new Response(n,{status:t,headers:e.config.responseHeaders})}));class V{constructor(e){var t,n,r,i;this.party=e,this.config={},null!=(t=this.config).storePath||(t.storePath="/store"),null!=(n=this.config).messagePrefix||(n.messagePrefix=""),null!=(r=this.config).storagePrefix||(r.storagePrefix=""),null!=(i=this.config).responseHeaders||(i.responseHeaders=D)}onRequest(e){return S(this,null,(function*(){const{party:{storage:t},config:{storePath:n,storagePrefix:r}}=this;if(new URL(e.url).pathname.endsWith(n)){const n=yield R(t,r),i=yield e.text();return"PUT"==e.method?n?O(this,205):(yield T(this,p(i),!0,e),O(this,201)):O(this,200,n?v(yield b(t,r)):"")}return O(this,404)}))}onMessage(e,t){return S(this,null,(function*(){const{config:{messagePrefix:n,storagePrefix:r}}=this;yield l(x(n,e,1),(e=>S(this,[e],(function*([e,n]){"s"==e&&(yield R(this.party.storage,r))&&(yield T(this,n,!1,t),C(this,n,[t.id]))}))))}))}canSetTable(e,t,n){return!0}canDelTable(e,t){return!0}canSetRow(e,t,n,r){return!0}canDelRow(e,t,n){return!0}canSetCell(e,t,n,r,i,s,l){return!0}canDelCell(e,t,n,r){return!0}canSetValue(e,t,n,r,i){return!0}canDelValue(e,t){return!0}}export{V as TinyBasePartyKitServer,C as broadcastTransactionChanges,R as hasStoreInStorage,b as loadStoreFromStorage};
1
+ const e=e=>typeof e,t=e(""),n="t",i=(e,t)=>e.startsWith(t),r=Promise,l=e=>null==e,s=(e,t,n)=>l(e)?null==n?void 0:n():t(e),o=(e,t,n)=>e.slice(t,n),u=e=>e.length,a=e=>{return t=function*(){return r.all(e)},new Promise(((e,n)=>{var i=e=>{try{l(t.next(e))}catch(e){n(e)}},r=e=>{try{l(t.throw(e))}catch(e){n(e)}},l=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,r);l((t=t.apply(void 0,null)).next())}));var t},c=(e,t)=>e.map(t),d=(e,...t)=>e.push(...t),f=Object,h=(e=[])=>f.fromEntries(e),y=(e,t)=>c(f.entries(e),(([e,n])=>t(n,e))),g=(e,t,n)=>(((e,t)=>!l(((e,t)=>s(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),v=e=>JSON.stringify(e,((e,t)=>t instanceof Map?f.fromEntries([...t]):t)),p=JSON.parse,P=(n,i,r)=>n+i+(e(r)==t?r:v(r)),x=(e,t,n)=>{const r=u(e);return i(t,e)?[t[r],(n?p:String)(o(t,r+1))]:void 0},m=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var S=(e,t,n)=>new Promise(((i,r)=>{var l=e=>{try{o(n.next(e))}catch(e){r(e)}},s=e=>{try{o(n.throw(e))}catch(e){r(e)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(l,s);o((n=n.apply(e,t)).next())}));const w="hasStore",D=h(c(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),R=(e,...t)=>S(void 0,[e,...t],(function*(e,t=""){return!!(yield e.get(t+w))})),b=(e,...t)=>S(void 0,[e,...t],(function*(e,t=""){const i={},r={};return m(yield e.list(),((e,l)=>s(x(t,e),(([e,t])=>{if(e==n){const[e,n,r]=p("["+t+"]");g(g(i,e,h),n,h)[r]=l}else"v"==e&&(r[t]=l)})))),[i,r]})),C=(e,t,n)=>S(void 0,null,(function*(){return e.party.broadcast(P(e.config.messagePrefix,"s",t),n)})),T=(e,t,r,s)=>S(void 0,null,(function*(){const o=e.party.storage,c=e.config.storagePrefix,f={[c+w]:1},h=[],g=[];yield a(y(t[0],((t,i)=>S(void 0,null,(function*(){return l(t)?!r&&(yield e.canDelTable(i,s))&&((e,...t)=>e.unshift(...t))(g,H(c,n,i)):(yield e.canSetTable(i,r,s))&&(yield a(y(t,((t,u)=>S(void 0,null,(function*(){return l(t)?!r&&(yield e.canDelRow(i,u,s))&&d(g,H(c,n,i,u)):(yield e.canSetRow(i,u,r,s))&&(yield a(y(t,((t,a)=>S(void 0,null,(function*(){const y=[i,u,a],g=H(c,n,...y);l(t)?!r&&(yield e.canDelCell(...y,s))&&d(h,g):(yield e.canSetCell(...y,t,r,s,yield o.get(g)))&&(f[g]=t)}))))))}))))))}))))),yield a(y(t[1],((t,n)=>S(void 0,null,(function*(){const i=c+"v"+n;l(t)?!r&&(yield e.canDelValue(n,s))&&d(h,i):(yield e.canSetValue(n,t,r,s,yield o.get(i)))&&(f[i]=t)}))))),0!=u(g)&&m(yield o.list(),(e=>g.every((t=>!i(e,t)||d(h,e)&&0)))),yield o.delete(h),yield o.put(f)})),H=(e,t,...n)=>P(e,t,o(v(n),1,-1)),O=(e,t,n=null)=>S(void 0,null,(function*(){return new Response(n,{status:t,headers:e.config.responseHeaders})}));class V{constructor(e){var t,n,i,r;this.party=e,this.config={},null!=(t=this.config).storePath||(t.storePath="/store"),null!=(n=this.config).messagePrefix||(n.messagePrefix=""),null!=(i=this.config).storagePrefix||(i.storagePrefix=""),null!=(r=this.config).responseHeaders||(r.responseHeaders=D)}onRequest(e){return S(this,null,(function*(){const{party:{storage:t},config:{storePath:n,storagePrefix:i}}=this;if(new URL(e.url).pathname.endsWith(n)){const n=yield R(t,i),r=yield e.text();return"PUT"==e.method?n?O(this,205):(yield T(this,p(r),!0,e),O(this,201)):O(this,200,n?v(yield b(t,i)):"")}return O(this,404)}))}onMessage(e,t){return S(this,null,(function*(){const{config:{messagePrefix:n,storagePrefix:i}}=this;yield s(x(n,e,1),(e=>S(this,[e],(function*([e,n]){"s"==e&&(yield R(this.party.storage,i))&&(yield T(this,n,!1,t),C(this,n,[t.id]))}))))}))}canSetTable(e,t,n){return S(this,null,(function*(){return!0}))}canDelTable(e,t){return S(this,null,(function*(){return!0}))}canSetRow(e,t,n,i){return S(this,null,(function*(){return!0}))}canDelRow(e,t,n){return S(this,null,(function*(){return!0}))}canSetCell(e,t,n,i,r,l,s){return S(this,null,(function*(){return!0}))}canDelCell(e,t,n,i){return S(this,null,(function*(){return!0}))}canSetValue(e,t,n,i,r){return S(this,null,(function*(){return!0}))}canDelValue(e,t){return S(this,null,(function*(){return!0}))}}export{V as TinyBasePartyKitServer,C as broadcastTransactionChanges,R as hasStoreInStorage,b as loadStoreFromStorage};
@@ -1 +1 @@
1
- const t=t=>typeof t,e=t(""),a="t",s=(t,e)=>t.startsWith(e),n=Promise,r=t=>null==t,i=(t,e,a)=>r(t)?a?.():e(t),c=(t,e,a)=>t.slice(e,a),o=t=>t.length,l=async t=>n.all(t),h=(t,e)=>t.map(e),g=(t,...e)=>t.push(...e),f=Object,u=(t=[])=>f.fromEntries(t),w=(t,e)=>h(f.entries(t),(([t,a])=>e(a,t))),y=(t,e,a)=>(((t,e)=>!r(((t,e)=>i(t,(t=>t[e])))(t,e)))(t,e)||(t[e]=a()),t[e]),p=t=>JSON.stringify(t,((t,e)=>e instanceof Map?f.fromEntries([...e]):e)),S=JSON.parse,d=(a,s,n)=>a+s+(t(n)==e?n:p(n)),P=(t,e,a)=>{const n=o(t);return s(e,t)?[e[n],(a?S:String)(c(e,n+1))]:void 0},m=(t,e)=>((t,e)=>t?.forEach(e))(t,((t,a)=>e(a,t))),x="hasStore",D=u(h(["Origin","Methods","Headers"],(t=>["Access-Control-Allow-"+t,"*"]))),R=async(t,e="")=>!!await t.get(e+x),b=async(t,e="")=>{const s={},n={};return m(await t.list(),((t,r)=>i(P(e,t),(([t,e])=>{if(t==a){const[t,a,n]=S("["+e+"]");y(y(s,t,u),a,u)[n]=r}else"v"==t&&(n[e]=r)})))),[s,n]},C=async(t,e,a)=>t.party.broadcast(d(t.config.messagePrefix,"s",e),a),T=async(t,e,n,i)=>{const c=t.party.storage,h=t.config.storagePrefix,f={[h+x]:1},u=[],y=[];await l(w(e[0],(async(e,s)=>r(e)?!n&&t.canDelTable(s,i)&&((t,...e)=>t.unshift(...e))(y,v(h,a,s)):t.canSetTable(s,n,i)&&await l(w(e,(async(e,o)=>r(e)?!n&&t.canDelRow(s,o,i)&&g(y,v(h,a,s,o)):t.canSetRow(s,o,n,i)&&await l(w(e,(async(e,l)=>{const w=[s,o,l],y=v(h,a,...w);r(e)?!n&&t.canDelCell(...w,i)&&g(u,y):t.canSetCell(...w,e,n,i,await c.get(y))&&(f[y]=e)}))))))))),await l(w(e[1],(async(e,a)=>{const s=h+"v"+a;r(e)?!n&&t.canDelValue(a,i)&&g(u,s):t.canSetValue(a,e,n,i,await c.get(s))&&(f[s]=e)}))),0!=o(y)&&m(await c.list(),(t=>y.every((e=>!s(t,e)||g(u,t)&&0)))),await c.delete(u),await c.put(f)},v=(t,e,...a)=>d(t,e,c(p(a),1,-1)),O=async(t,e,a=null)=>new Response(a,{status:e,headers:t.config.responseHeaders});class V{constructor(t){this.party=t,this.config={},this.config.storePath??="/store",this.config.messagePrefix??="",this.config.storagePrefix??="",this.config.responseHeaders??=D}async onRequest(t){const{party:{storage:e},config:{storePath:a,storagePrefix:s}}=this;if(new URL(t.url).pathname.endsWith(a)){const a=await R(e,s),n=await t.text();return"PUT"==t.method?a?O(this,205):(await T(this,S(n),!0,t),O(this,201)):O(this,200,a?p(await b(e,s)):"")}return O(this,404)}async onMessage(t,e){const{config:{messagePrefix:a,storagePrefix:s}}=this;await i(P(a,t,1),(async([t,a])=>{"s"==t&&await R(this.party.storage,s)&&(await T(this,a,!1,e),C(this,a,[e.id]))}))}canSetTable(t,e,a){return!0}canDelTable(t,e){return!0}canSetRow(t,e,a,s){return!0}canDelRow(t,e,a){return!0}canSetCell(t,e,a,s,n,r,i){return!0}canDelCell(t,e,a,s){return!0}canSetValue(t,e,a,s,n){return!0}canDelValue(t,e){return!0}}export{V as TinyBasePartyKitServer,C as broadcastTransactionChanges,R as hasStoreInStorage,b as loadStoreFromStorage};
1
+ const a=a=>typeof a,t=a(""),e="t",s=(a,t)=>a.startsWith(t),n=Promise,i=a=>null==a,r=(a,t,e)=>i(a)?e?.():t(a),c=(a,t,e)=>a.slice(t,e),o=a=>a.length,l=async a=>n.all(a),w=(a,t)=>a.map(t),h=(a,...t)=>a.push(...t),y=Object,g=(a=[])=>y.fromEntries(a),f=(a,t)=>w(y.entries(a),(([a,e])=>t(e,a))),u=(a,t,e)=>(((a,t)=>!i(((a,t)=>r(a,(a=>a[t])))(a,t)))(a,t)||(a[t]=e()),a[t]),p=a=>JSON.stringify(a,((a,t)=>t instanceof Map?y.fromEntries([...t]):t)),S=JSON.parse,d=(e,s,n)=>e+s+(a(n)==t?n:p(n)),P=(a,t,e)=>{const n=o(a);return s(t,a)?[t[n],(e?S:String)(c(t,n+1))]:void 0},m=(a,t)=>((a,t)=>a?.forEach(t))(a,((a,e)=>t(e,a))),x="hasStore",D=g(w(["Origin","Methods","Headers"],(a=>["Access-Control-Allow-"+a,"*"]))),R=async(a,t="")=>!!await a.get(t+x),b=async(a,t="")=>{const s={},n={};return m(await a.list(),((a,i)=>r(P(t,a),(([a,t])=>{if(a==e){const[a,e,n]=S("["+t+"]");u(u(s,a,g),e,g)[n]=i}else"v"==a&&(n[t]=i)})))),[s,n]},C=async(a,t,e)=>a.party.broadcast(d(a.config.messagePrefix,"s",t),e),T=async(a,t,n,r)=>{const c=a.party.storage,w=a.config.storagePrefix,y={[w+x]:1},g=[],u=[];await l(f(t[0],(async(t,s)=>i(t)?!n&&await a.canDelTable(s,r)&&((a,...t)=>a.unshift(...t))(u,v(w,e,s)):await a.canSetTable(s,n,r)&&await l(f(t,(async(t,o)=>i(t)?!n&&await a.canDelRow(s,o,r)&&h(u,v(w,e,s,o)):await a.canSetRow(s,o,n,r)&&await l(f(t,(async(t,l)=>{const f=[s,o,l],u=v(w,e,...f);i(t)?!n&&await a.canDelCell(...f,r)&&h(g,u):await a.canSetCell(...f,t,n,r,await c.get(u))&&(y[u]=t)}))))))))),await l(f(t[1],(async(t,e)=>{const s=w+"v"+e;i(t)?!n&&await a.canDelValue(e,r)&&h(g,s):await a.canSetValue(e,t,n,r,await c.get(s))&&(y[s]=t)}))),0!=o(u)&&m(await c.list(),(a=>u.every((t=>!s(a,t)||h(g,a)&&0)))),await c.delete(g),await c.put(y)},v=(a,t,...e)=>d(a,t,c(p(e),1,-1)),O=async(a,t,e=null)=>new Response(e,{status:t,headers:a.config.responseHeaders});class V{constructor(a){this.party=a,this.config={},this.config.storePath??="/store",this.config.messagePrefix??="",this.config.storagePrefix??="",this.config.responseHeaders??=D}async onRequest(a){const{party:{storage:t},config:{storePath:e,storagePrefix:s}}=this;if(new URL(a.url).pathname.endsWith(e)){const e=await R(t,s),n=await a.text();return"PUT"==a.method?e?O(this,205):(await T(this,S(n),!0,a),O(this,201)):O(this,200,e?p(await b(t,s)):"")}return O(this,404)}async onMessage(a,t){const{config:{messagePrefix:e,storagePrefix:s}}=this;await r(P(e,a,1),(async([a,e])=>{"s"==a&&await R(this.party.storage,s)&&(await T(this,e,!1,t),C(this,e,[t.id]))}))}async canSetTable(a,t,e){return!0}async canDelTable(a,t){return!0}async canSetRow(a,t,e,s){return!0}async canDelRow(a,t,e){return!0}async canSetCell(a,t,e,s,n,i,r){return!0}async canDelCell(a,t,e,s){return!0}async canSetValue(a,t,e,s,n){return!0}async canDelValue(a,t){return!0}}export{V as TinyBasePartyKitServer,C as broadcastTransactionChanges,R as hasStoreInStorage,b as loadStoreFromStorage};
@@ -249,7 +249,7 @@ export class TinyBasePartyKitServer implements Server {
249
249
  tableId: Id,
250
250
  initialSave: boolean,
251
251
  requestOrConnection: Request | Connection,
252
- ): boolean;
252
+ ): Promise<boolean>;
253
253
  /**
254
254
  * The canDelTable method lets you allow or disallow deletions of a Table
255
255
  * stored on the server, as sent from a client.
@@ -281,7 +281,7 @@ export class TinyBasePartyKitServer implements Server {
281
281
  * @category Sanitization
282
282
  * @since v4.3.12
283
283
  */
284
- canDelTable(tableId: Id, connection: Connection): boolean;
284
+ canDelTable(tableId: Id, connection: Connection): Promise<boolean>;
285
285
  /**
286
286
  * The canSetRow method lets you allow or disallow any changes to a Row stored
287
287
  * on the server, as sent from a client.
@@ -324,7 +324,7 @@ export class TinyBasePartyKitServer implements Server {
324
324
  rowId: Id,
325
325
  initialSave: boolean,
326
326
  requestOrConnection: Request | Connection,
327
- ): boolean;
327
+ ): Promise<boolean>;
328
328
  /**
329
329
  * The canDelRow method lets you allow or disallow deletions of a Row stored
330
330
  * on the server, as sent from a client.
@@ -357,7 +357,7 @@ export class TinyBasePartyKitServer implements Server {
357
357
  * @category Sanitization
358
358
  * @since v4.3.12
359
359
  */
360
- canDelRow(tableId: Id, rowId: Id, connection: Connection): boolean;
360
+ canDelRow(tableId: Id, rowId: Id, connection: Connection): Promise<boolean>;
361
361
  /**
362
362
  * The canSetCell method lets you allow or disallow any changes to a Cell
363
363
  * stored on the server, as sent from a client.
@@ -406,7 +406,7 @@ export class TinyBasePartyKitServer implements Server {
406
406
  initialSave: boolean,
407
407
  requestOrConnection: Request | Connection,
408
408
  oldCell: CellOrUndefined,
409
- ): boolean;
409
+ ): Promise<boolean>;
410
410
  /**
411
411
  * The canDelCell method lets you allow or disallow deletions of a Cell stored
412
412
  * on the server, as sent from a client.
@@ -444,7 +444,7 @@ export class TinyBasePartyKitServer implements Server {
444
444
  rowId: Id,
445
445
  cellId: Id,
446
446
  connection: Connection,
447
- ): boolean;
447
+ ): Promise<boolean>;
448
448
  /**
449
449
  * The canSetValue method lets you allow or disallow any changes to a Value
450
450
  * stored on the server, as sent from a client.
@@ -491,7 +491,7 @@ export class TinyBasePartyKitServer implements Server {
491
491
  initialSave: boolean,
492
492
  requestOrConnection: Request | Connection,
493
493
  oldValue: ValueOrUndefined,
494
- ): boolean;
494
+ ): Promise<boolean>;
495
495
  /**
496
496
  * The canDelValue method lets you allow or disallow deletions of a Value
497
497
  * stored on the server, as sent from a client.
@@ -523,7 +523,7 @@ export class TinyBasePartyKitServer implements Server {
523
523
  * @category Sanitization
524
524
  * @since v4.3.12
525
525
  */
526
- canDelValue(valueId: Id, connection: Connection): boolean;
526
+ canDelValue(valueId: Id, connection: Connection): Promise<boolean>;
527
527
  }
528
528
 
529
529
  /**
@@ -252,7 +252,7 @@ export class TinyBasePartyKitServer implements Server {
252
252
  tableId: Id,
253
253
  initialSave: boolean,
254
254
  requestOrConnection: Request | Connection,
255
- ): boolean;
255
+ ): Promise<boolean>;
256
256
  /**
257
257
  * The canDelTable method lets you allow or disallow deletions of a Table
258
258
  * stored on the server, as sent from a client.
@@ -284,7 +284,7 @@ export class TinyBasePartyKitServer implements Server {
284
284
  * @category Sanitization
285
285
  * @since v4.3.12
286
286
  */
287
- canDelTable(tableId: Id, connection: Connection): boolean;
287
+ canDelTable(tableId: Id, connection: Connection): Promise<boolean>;
288
288
  /**
289
289
  * The canSetRow method lets you allow or disallow any changes to a Row stored
290
290
  * on the server, as sent from a client.
@@ -327,7 +327,7 @@ export class TinyBasePartyKitServer implements Server {
327
327
  rowId: Id,
328
328
  initialSave: boolean,
329
329
  requestOrConnection: Request | Connection,
330
- ): boolean;
330
+ ): Promise<boolean>;
331
331
  /**
332
332
  * The canDelRow method lets you allow or disallow deletions of a Row stored
333
333
  * on the server, as sent from a client.
@@ -360,7 +360,7 @@ export class TinyBasePartyKitServer implements Server {
360
360
  * @category Sanitization
361
361
  * @since v4.3.12
362
362
  */
363
- canDelRow(tableId: Id, rowId: Id, connection: Connection): boolean;
363
+ canDelRow(tableId: Id, rowId: Id, connection: Connection): Promise<boolean>;
364
364
  /**
365
365
  * The canSetCell method lets you allow or disallow any changes to a Cell
366
366
  * stored on the server, as sent from a client.
@@ -376,7 +376,7 @@ export class TinyBasePartyKitServer implements Server {
376
376
  * initialSave: boolean,
377
377
  * requestOrConnection: Request | Connection,
378
378
  * oldCell: CellOrUndefined,
379
- * ): boolean;
379
+ * ): Promise<boolean>;
380
380
  * ```
381
381
  *
382
382
  * This is one of the functions use to sanitize the data that is being sent
@@ -423,7 +423,7 @@ export class TinyBasePartyKitServer implements Server {
423
423
  initialSave: boolean,
424
424
  requestOrConnection: Request | Connection,
425
425
  oldCell: CellOrUndefined<NoTablesSchema, Id, Id>,
426
- ): boolean;
426
+ ): Promise<boolean>;
427
427
  /**
428
428
  * The canDelCell method lets you allow or disallow deletions of a Cell stored
429
429
  * on the server, as sent from a client.
@@ -461,7 +461,7 @@ export class TinyBasePartyKitServer implements Server {
461
461
  rowId: Id,
462
462
  cellId: Id,
463
463
  connection: Connection,
464
- ): boolean;
464
+ ): Promise<boolean>;
465
465
  /**
466
466
  * The canSetValue method lets you allow or disallow any changes to a Value
467
467
  * stored on the server, as sent from a client.
@@ -475,7 +475,7 @@ export class TinyBasePartyKitServer implements Server {
475
475
  * initialSave: boolean,
476
476
  * requestOrConnection: Request | Connection,
477
477
  * oldValue: ValueOrUndefined,
478
- * ): boolean;
478
+ * ): Promise<boolean>;
479
479
  * ```
480
480
  *
481
481
  * This is one of the functions use to sanitize the data that is being sent
@@ -520,7 +520,7 @@ export class TinyBasePartyKitServer implements Server {
520
520
  initialSave: boolean,
521
521
  requestOrConnection: Request | Connection,
522
522
  oldValue: ValueOrUndefined<NoValuesSchema, Id>,
523
- ): boolean;
523
+ ): Promise<boolean>;
524
524
  /**
525
525
  * The canDelValue method lets you allow or disallow deletions of a Value
526
526
  * stored on the server, as sent from a client.
@@ -552,7 +552,7 @@ export class TinyBasePartyKitServer implements Server {
552
552
  * @category Sanitization
553
553
  * @since v4.3.12
554
554
  */
555
- canDelValue(valueId: Id, connection: Connection): boolean;
555
+ canDelValue(valueId: Id, connection: Connection): Promise<boolean>;
556
556
  }
557
557
 
558
558
  /**
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,a=t(""),s="t",n=(e,t)=>e.startsWith(t),r=Promise,i=e=>null==e,o=(e,t,a)=>i(e)?a?.():t(e),c=(e,t,a)=>e.slice(t,a),l=e=>e.length,f=async e=>r.all(e),h=(e,t)=>e.map(t),g=(e,...t)=>e.push(...t),u=Object,y=(e=[])=>u.fromEntries(e),w=(e,t)=>h(u.entries(e),(([e,a])=>t(a,e))),d=(e,t,a)=>(((e,t)=>!i(((e,t)=>o(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=a()),e[t]),p=e=>JSON.stringify(e,((e,t)=>t instanceof Map?u.fromEntries([...t]):t)),S=JSON.parse,P=(e,s,n)=>e+s+(t(n)==a?n:p(n)),m=(e,t,a)=>{const s=l(e);return n(t,e)?[t[s],(a?S:String)(c(t,s+1))]:void 0},x=(e,t)=>((e,t)=>e?.forEach(t))(e,((e,a)=>t(a,e))),b="hasStore",T=y(h(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),D=async(e,t="")=>!!await e.get(t+b),v=async(e,t="")=>{const a={},n={};return x(await e.list(),((e,r)=>o(m(t,e),(([e,t])=>{if(e==s){const[e,s,n]=S("["+t+"]");d(d(a,e,y),s,y)[n]=r}else"v"==e&&(n[t]=r)})))),[a,n]},R=async(e,t,a)=>e.party.broadcast(P(e.config.messagePrefix,"s",t),a),C=async(e,t,a,r)=>{const o=e.party.storage,c=e.config.storagePrefix,h={[c+b]:1},u=[],y=[];await f(w(t[0],(async(t,n)=>i(t)?!a&&e.canDelTable(n,r)&&((e,...t)=>e.unshift(...t))(y,O(c,s,n)):e.canSetTable(n,a,r)&&await f(w(t,(async(t,l)=>i(t)?!a&&e.canDelRow(n,l,r)&&g(y,O(c,s,n,l)):e.canSetRow(n,l,a,r)&&await f(w(t,(async(t,f)=>{const y=[n,l,f],w=O(c,s,...y);i(t)?!a&&e.canDelCell(...y,r)&&g(u,w):e.canSetCell(...y,t,a,r,await o.get(w))&&(h[w]=t)}))))))))),await f(w(t[1],(async(t,s)=>{const n=c+"v"+s;i(t)?!a&&e.canDelValue(s,r)&&g(u,n):e.canSetValue(s,t,a,r,await o.get(n))&&(h[n]=t)}))),0!=l(y)&&x(await o.list(),(e=>y.every((t=>!n(e,t)||g(u,e)&&0)))),await o.delete(u),await o.put(h)},O=(e,t,...a)=>P(e,t,c(p(a),1,-1)),V=async(e,t,a=null)=>new Response(a,{status:t,headers:e.config.responseHeaders});e.TinyBasePartyKitServer=class{constructor(e){this.party=e,this.config={},this.config.storePath??="/store",this.config.messagePrefix??="",this.config.storagePrefix??="",this.config.responseHeaders??=T}async onRequest(e){const{party:{storage:t},config:{storePath:a,storagePrefix:s}}=this;if(new URL(e.url).pathname.endsWith(a)){const a=await D(t,s),n=await e.text();return"PUT"==e.method?a?V(this,205):(await C(this,S(n),!0,e),V(this,201)):V(this,200,a?p(await v(t,s)):"")}return V(this,404)}async onMessage(e,t){const{config:{messagePrefix:a,storagePrefix:s}}=this;await o(m(a,e,1),(async([e,a])=>{"s"==e&&await D(this.party.storage,s)&&(await C(this,a,!1,t),R(this,a,[t.id]))}))}canSetTable(e,t,a){return!0}canDelTable(e,t){return!0}canSetRow(e,t,a,s){return!0}canDelRow(e,t,a){return!0}canSetCell(e,t,a,s,n,r,i){return!0}canDelCell(e,t,a,s){return!0}canSetValue(e,t,a,s,n){return!0}canDelValue(e,t){return!0}},e.broadcastTransactionChanges=R,e.hasStoreInStorage=D,e.loadStoreFromStorage=v},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
1
+ var a,t;a=this,t=function(a){"use strict";const t=a=>typeof a,e=t(""),s="t",n=(a,t)=>a.startsWith(t),i=Promise,r=a=>null==a,o=(a,t,e)=>r(a)?e?.():t(a),c=(a,t,e)=>a.slice(t,e),l=a=>a.length,f=async a=>i.all(a),y=(a,t)=>a.map(t),h=(a,...t)=>a.push(...t),g=Object,w=(a=[])=>g.fromEntries(a),u=(a,t)=>y(g.entries(a),(([a,e])=>t(e,a))),d=(a,t,e)=>(((a,t)=>!r(((a,t)=>o(a,(a=>a[t])))(a,t)))(a,t)||(a[t]=e()),a[t]),p=a=>JSON.stringify(a,((a,t)=>t instanceof Map?g.fromEntries([...t]):t)),S=JSON.parse,P=(a,s,n)=>a+s+(t(n)==e?n:p(n)),m=(a,t,e)=>{const s=l(a);return n(t,a)?[t[s],(e?S:String)(c(t,s+1))]:void 0},x=(a,t)=>((a,t)=>a?.forEach(t))(a,((a,e)=>t(e,a))),b="hasStore",T=w(y(["Origin","Methods","Headers"],(a=>["Access-Control-Allow-"+a,"*"]))),D=async(a,t="")=>!!await a.get(t+b),v=async(a,t="")=>{const e={},n={};return x(await a.list(),((a,i)=>o(m(t,a),(([a,t])=>{if(a==s){const[a,s,n]=S("["+t+"]");d(d(e,a,w),s,w)[n]=i}else"v"==a&&(n[t]=i)})))),[e,n]},R=async(a,t,e)=>a.party.broadcast(P(a.config.messagePrefix,"s",t),e),C=async(a,t,e,i)=>{const o=a.party.storage,c=a.config.storagePrefix,y={[c+b]:1},g=[],w=[];await f(u(t[0],(async(t,n)=>r(t)?!e&&await a.canDelTable(n,i)&&((a,...t)=>a.unshift(...t))(w,O(c,s,n)):await a.canSetTable(n,e,i)&&await f(u(t,(async(t,l)=>r(t)?!e&&await a.canDelRow(n,l,i)&&h(w,O(c,s,n,l)):await a.canSetRow(n,l,e,i)&&await f(u(t,(async(t,f)=>{const w=[n,l,f],u=O(c,s,...w);r(t)?!e&&await a.canDelCell(...w,i)&&h(g,u):await a.canSetCell(...w,t,e,i,await o.get(u))&&(y[u]=t)}))))))))),await f(u(t[1],(async(t,s)=>{const n=c+"v"+s;r(t)?!e&&await a.canDelValue(s,i)&&h(g,n):await a.canSetValue(s,t,e,i,await o.get(n))&&(y[n]=t)}))),0!=l(w)&&x(await o.list(),(a=>w.every((t=>!n(a,t)||h(g,a)&&0)))),await o.delete(g),await o.put(y)},O=(a,t,...e)=>P(a,t,c(p(e),1,-1)),V=async(a,t,e=null)=>new Response(e,{status:t,headers:a.config.responseHeaders});a.TinyBasePartyKitServer=class{constructor(a){this.party=a,this.config={},this.config.storePath??="/store",this.config.messagePrefix??="",this.config.storagePrefix??="",this.config.responseHeaders??=T}async onRequest(a){const{party:{storage:t},config:{storePath:e,storagePrefix:s}}=this;if(new URL(a.url).pathname.endsWith(e)){const e=await D(t,s),n=await a.text();return"PUT"==a.method?e?V(this,205):(await C(this,S(n),!0,a),V(this,201)):V(this,200,e?p(await v(t,s)):"")}return V(this,404)}async onMessage(a,t){const{config:{messagePrefix:e,storagePrefix:s}}=this;await o(m(e,a,1),(async([a,e])=>{"s"==a&&await D(this.party.storage,s)&&(await C(this,e,!1,t),R(this,e,[t.id]))}))}async canSetTable(a,t,e){return!0}async canDelTable(a,t){return!0}async canSetRow(a,t,e,s){return!0}async canDelRow(a,t,e){return!0}async canSetCell(a,t,e,s,n,i,r){return!0}async canDelCell(a,t,e,s){return!0}async canSetValue(a,t,e,s,n){return!0}async canDelValue(a,t){return!0}},a.broadcastTransactionChanges=R,a.hasStoreInStorage=D,a.loadStoreFromStorage=v},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((a="undefined"!=typeof globalThis?globalThis:a||self).TinyBasePersisterPartyKitServer={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n=t(""),r="t",i=(e,t)=>e.startsWith(t),s=Promise,o=e=>null==e,l=(e,t,n)=>o(e)?null==n?void 0:n():t(e),a=(e,t,n)=>e.slice(t,n),c=e=>e.length,u=e=>{return t=function*(){return s.all(e)},new Promise(((e,n)=>{var r=e=>{try{s(t.next(e))}catch(e){n(e)}},i=e=>{try{s(t.throw(e))}catch(e){n(e)}},s=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,i);s((t=t.apply(void 0,null)).next())}));var t},d=(e,t)=>e.map(t),f=(e,...t)=>e.push(...t),h=Object,y=(e=[])=>h.fromEntries(e),g=(e,t)=>d(h.entries(e),(([e,n])=>t(n,e))),v=(e,t,n)=>(((e,t)=>!o(((e,t)=>l(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),p=e=>JSON.stringify(e,((e,t)=>t instanceof Map?h.fromEntries([...t]):t)),P=JSON.parse,S=(e,r,i)=>e+r+(t(i)==n?i:p(i)),m=(e,t,n)=>{const r=c(e);return i(t,e)?[t[r],(n?P:String)(a(t,r+1))]:void 0},x=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var w=(e,t,n)=>new Promise(((r,i)=>{var s=e=>{try{l(n.next(e))}catch(e){i(e)}},o=e=>{try{l(n.throw(e))}catch(e){i(e)}},l=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,o);l((n=n.apply(e,t)).next())}));const b="hasStore",T=y(d(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),D=(e,...t)=>w(void 0,[e,...t],(function*(e,t=""){return!!(yield e.get(t+b))})),R=(e,...t)=>w(void 0,[e,...t],(function*(e,t=""){const n={},i={};return x(yield e.list(),((e,s)=>l(m(t,e),(([e,t])=>{if(e==r){const[e,r,i]=P("["+t+"]");v(v(n,e,y),r,y)[i]=s}else"v"==e&&(i[t]=s)})))),[n,i]})),C=(e,t,n)=>w(void 0,null,(function*(){return e.party.broadcast(S(e.config.messagePrefix,"s",t),n)})),H=(e,t,n,s)=>w(void 0,null,(function*(){const l=e.party.storage,a=e.config.storagePrefix,d={[a+b]:1},h=[],y=[];yield u(g(t[0],((t,i)=>w(void 0,null,(function*(){return o(t)?!n&&e.canDelTable(i,s)&&((e,...t)=>e.unshift(...t))(y,O(a,r,i)):e.canSetTable(i,n,s)&&(yield u(g(t,((t,c)=>w(void 0,null,(function*(){return o(t)?!n&&e.canDelRow(i,c,s)&&f(y,O(a,r,i,c)):e.canSetRow(i,c,n,s)&&(yield u(g(t,((t,u)=>w(void 0,null,(function*(){const y=[i,c,u],g=O(a,r,...y);o(t)?!n&&e.canDelCell(...y,s)&&f(h,g):e.canSetCell(...y,t,n,s,yield l.get(g))&&(d[g]=t)}))))))}))))))}))))),yield u(g(t[1],((t,r)=>w(void 0,null,(function*(){const i=a+"v"+r;o(t)?!n&&e.canDelValue(r,s)&&f(h,i):e.canSetValue(r,t,n,s,yield l.get(i))&&(d[i]=t)}))))),0!=c(y)&&x(yield l.list(),(e=>y.every((t=>!i(e,t)||f(h,e)&&0)))),yield l.delete(h),yield l.put(d)})),O=(e,t,...n)=>S(e,t,a(p(n),1,-1)),V=(e,t,n=null)=>w(void 0,null,(function*(){return new Response(n,{status:t,headers:e.config.responseHeaders})}));e.TinyBasePartyKitServer=class{constructor(e){var t,n,r,i;this.party=e,this.config={},null!=(t=this.config).storePath||(t.storePath="/store"),null!=(n=this.config).messagePrefix||(n.messagePrefix=""),null!=(r=this.config).storagePrefix||(r.storagePrefix=""),null!=(i=this.config).responseHeaders||(i.responseHeaders=T)}onRequest(e){return w(this,null,(function*(){const{party:{storage:t},config:{storePath:n,storagePrefix:r}}=this;if(new URL(e.url).pathname.endsWith(n)){const n=yield D(t,r),i=yield e.text();return"PUT"==e.method?n?V(this,205):(yield H(this,P(i),!0,e),V(this,201)):V(this,200,n?p(yield R(t,r)):"")}return V(this,404)}))}onMessage(e,t){return w(this,null,(function*(){const{config:{messagePrefix:n,storagePrefix:r}}=this;yield l(m(n,e,1),(e=>w(this,[e],(function*([e,n]){"s"==e&&(yield D(this.party.storage,r))&&(yield H(this,n,!1,t),C(this,n,[t.id]))}))))}))}canSetTable(e,t,n){return!0}canDelTable(e,t){return!0}canSetRow(e,t,n,r){return!0}canDelRow(e,t,n){return!0}canSetCell(e,t,n,r,i,s,o){return!0}canDelCell(e,t,n,r){return!0}canSetValue(e,t,n,r,i){return!0}canDelValue(e,t){return!0}},e.broadcastTransactionChanges=C,e.hasStoreInStorage=D,e.loadStoreFromStorage=R},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n=t(""),r="t",i=(e,t)=>e.startsWith(t),l=Promise,s=e=>null==e,o=(e,t,n)=>s(e)?null==n?void 0:n():t(e),u=(e,t,n)=>e.slice(t,n),a=e=>e.length,c=e=>{return t=function*(){return l.all(e)},new Promise(((e,n)=>{var r=e=>{try{l(t.next(e))}catch(e){n(e)}},i=e=>{try{l(t.throw(e))}catch(e){n(e)}},l=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,i);l((t=t.apply(void 0,null)).next())}));var t},d=(e,t)=>e.map(t),f=(e,...t)=>e.push(...t),h=Object,y=(e=[])=>h.fromEntries(e),g=(e,t)=>d(h.entries(e),(([e,n])=>t(n,e))),v=(e,t,n)=>(((e,t)=>!s(((e,t)=>o(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),p=e=>JSON.stringify(e,((e,t)=>t instanceof Map?h.fromEntries([...t]):t)),P=JSON.parse,S=(e,r,i)=>e+r+(t(i)==n?i:p(i)),m=(e,t,n)=>{const r=a(e);return i(t,e)?[t[r],(n?P:String)(u(t,r+1))]:void 0},x=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var w=(e,t,n)=>new Promise(((r,i)=>{var l=e=>{try{o(n.next(e))}catch(e){i(e)}},s=e=>{try{o(n.throw(e))}catch(e){i(e)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(l,s);o((n=n.apply(e,t)).next())}));const b="hasStore",T=y(d(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),D=(e,...t)=>w(void 0,[e,...t],(function*(e,t=""){return!!(yield e.get(t+b))})),R=(e,...t)=>w(void 0,[e,...t],(function*(e,t=""){const n={},i={};return x(yield e.list(),((e,l)=>o(m(t,e),(([e,t])=>{if(e==r){const[e,r,i]=P("["+t+"]");v(v(n,e,y),r,y)[i]=l}else"v"==e&&(i[t]=l)})))),[n,i]})),C=(e,t,n)=>w(void 0,null,(function*(){return e.party.broadcast(S(e.config.messagePrefix,"s",t),n)})),H=(e,t,n,l)=>w(void 0,null,(function*(){const o=e.party.storage,u=e.config.storagePrefix,d={[u+b]:1},h=[],y=[];yield c(g(t[0],((t,i)=>w(void 0,null,(function*(){return s(t)?!n&&(yield e.canDelTable(i,l))&&((e,...t)=>e.unshift(...t))(y,O(u,r,i)):(yield e.canSetTable(i,n,l))&&(yield c(g(t,((t,a)=>w(void 0,null,(function*(){return s(t)?!n&&(yield e.canDelRow(i,a,l))&&f(y,O(u,r,i,a)):(yield e.canSetRow(i,a,n,l))&&(yield c(g(t,((t,c)=>w(void 0,null,(function*(){const y=[i,a,c],g=O(u,r,...y);s(t)?!n&&(yield e.canDelCell(...y,l))&&f(h,g):(yield e.canSetCell(...y,t,n,l,yield o.get(g)))&&(d[g]=t)}))))))}))))))}))))),yield c(g(t[1],((t,r)=>w(void 0,null,(function*(){const i=u+"v"+r;s(t)?!n&&(yield e.canDelValue(r,l))&&f(h,i):(yield e.canSetValue(r,t,n,l,yield o.get(i)))&&(d[i]=t)}))))),0!=a(y)&&x(yield o.list(),(e=>y.every((t=>!i(e,t)||f(h,e)&&0)))),yield o.delete(h),yield o.put(d)})),O=(e,t,...n)=>S(e,t,u(p(n),1,-1)),V=(e,t,n=null)=>w(void 0,null,(function*(){return new Response(n,{status:t,headers:e.config.responseHeaders})}));e.TinyBasePartyKitServer=class{constructor(e){var t,n,r,i;this.party=e,this.config={},null!=(t=this.config).storePath||(t.storePath="/store"),null!=(n=this.config).messagePrefix||(n.messagePrefix=""),null!=(r=this.config).storagePrefix||(r.storagePrefix=""),null!=(i=this.config).responseHeaders||(i.responseHeaders=T)}onRequest(e){return w(this,null,(function*(){const{party:{storage:t},config:{storePath:n,storagePrefix:r}}=this;if(new URL(e.url).pathname.endsWith(n)){const n=yield D(t,r),i=yield e.text();return"PUT"==e.method?n?V(this,205):(yield H(this,P(i),!0,e),V(this,201)):V(this,200,n?p(yield R(t,r)):"")}return V(this,404)}))}onMessage(e,t){return w(this,null,(function*(){const{config:{messagePrefix:n,storagePrefix:r}}=this;yield o(m(n,e,1),(e=>w(this,[e],(function*([e,n]){"s"==e&&(yield D(this.party.storage,r))&&(yield H(this,n,!1,t),C(this,n,[t.id]))}))))}))}canSetTable(e,t,n){return w(this,null,(function*(){return!0}))}canDelTable(e,t){return w(this,null,(function*(){return!0}))}canSetRow(e,t,n,r){return w(this,null,(function*(){return!0}))}canDelRow(e,t,n){return w(this,null,(function*(){return!0}))}canSetCell(e,t,n,r,i,l,s){return w(this,null,(function*(){return!0}))}canDelCell(e,t,n,r){return w(this,null,(function*(){return!0}))}canSetValue(e,t,n,r,i){return w(this,null,(function*(){return!0}))}canDelValue(e,t){return w(this,null,(function*(){return!0}))}},e.broadcastTransactionChanges=C,e.hasStoreInStorage=D,e.loadStoreFromStorage=R},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "4.5.5",
3
+ "version": "4.5.7",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -22,6 +22,14 @@
22
22
  "tinybase": "./bin/cli.js"
23
23
  },
24
24
  "exports": {
25
+ ".": {
26
+ "types": "./lib/types/tinybase.d.ts",
27
+ "default": "./lib/tinybase.js"
28
+ },
29
+ "./*": {
30
+ "types": "./lib/types/*.d.ts",
31
+ "default": "./lib/*.js"
32
+ },
25
33
  "./package.json": "./package.json",
26
34
  "./cjs": "./lib/cjs/tinybase.cjs",
27
35
  "./cjs/with-schemas": "./lib/cjs/tinybase.cjs",
@@ -63,10 +71,6 @@
63
71
  "types": "./lib/types/*.d.ts",
64
72
  "default": "./lib/debug/*.js"
65
73
  },
66
- ".": {
67
- "types": "./lib/types/tinybase.d.ts",
68
- "default": "./lib/tinybase.js"
69
- },
70
74
  "./with-schemas": {
71
75
  "types": "./lib/types/with-schemas/tinybase.d.ts",
72
76
  "default": "./lib/tinybase.js"
@@ -74,10 +78,6 @@
74
78
  "./*/with-schemas": {
75
79
  "types": "./lib/types/with-schemas/*.d.ts",
76
80
  "default": "./lib/*.js"
77
- },
78
- "./*": {
79
- "types": "./lib/types/*.d.ts",
80
- "default": "./lib/*.js"
81
81
  }
82
82
  },
83
83
  "typesVersions": {
@@ -227,7 +227,7 @@
227
227
  "@types/asciichart": "^1.5.8",
228
228
  "@types/expect-puppeteer": "^5.0.6",
229
229
  "@types/http-server": "^0.12.4",
230
- "@types/jest": "^29.5.10",
230
+ "@types/jest": "^29.5.11",
231
231
  "@types/jest-environment-puppeteer": "^5.0.6",
232
232
  "@types/less": "^3.0.6",
233
233
  "@types/node": "^20.10.3",
@@ -248,7 +248,7 @@
248
248
  "babel-preset-minify": "^0.5.2",
249
249
  "buffer-replace": "^1.0.0",
250
250
  "country-flag-emoji-json": "^2.0.0",
251
- "cspell": "^8.1.2",
251
+ "cspell": "^8.1.3",
252
252
  "esbuild": "^0.19.8",
253
253
  "eslint": "^8.55.0",
254
254
  "eslint-config-prettier": "^9.1.0",
@@ -265,12 +265,12 @@
265
265
  "jest": "^29.7.0",
266
266
  "jest-environment-jsdom": "^29.7.0",
267
267
  "jest-fetch-mock": "^3.0.3",
268
- "jest-puppeteer": "^9.0.1",
268
+ "jest-puppeteer": "^9.0.2",
269
269
  "less": "^4.2.0",
270
270
  "partykit": "^0.0.39",
271
271
  "partysocket": "^0.0.16",
272
272
  "prettier": "^3.1.0",
273
- "puppeteer": "21.5.2",
273
+ "puppeteer": "21.6.0",
274
274
  "react": "^18.2.0",
275
275
  "react-dom": "^18.2.0",
276
276
  "react-test-renderer": "^18.2.0",
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-5"><em>NEW!</em> v4.5 release</a> <span id="one-with">&quot;The One With Expo SQLite Next&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app&#x27;s data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions &amp; ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>, and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.0kB - 9.4kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">Tinybase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/expo.svg">Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;label=Twitter&amp;labelColor=%23333&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.5.5" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
1
+ <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-5"><em>NEW!</em> v4.5 release</a> <span id="one-with">&quot;The One With Expo SQLite Next&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app&#x27;s data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions &amp; ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>, and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.0kB - 9.4kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">Tinybase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/expo.svg">Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;label=Twitter&amp;labelColor=%23333&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.5.7" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  const store = createStore()