@instantdb/platform 0.22.95-experimental.surgical.20386736818.1 → 0.22.95-experimental.surgical.20386947966.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @instantdb/platform@0.22.95-experimental.surgical.
|
|
2
|
+
> @instantdb/platform@0.22.95-experimental.surgical.20386947966.1 build /home/runner/work/instant/instant/client/packages/platform
|
|
3
3
|
> rm -rf dist; npm run build:tshy && npm run build:standalone && npm run check-exports
|
|
4
4
|
|
|
5
5
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm.
|
|
6
6
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm.
|
|
7
7
|
|
|
8
|
-
> @instantdb/platform@0.22.95-experimental.surgical.
|
|
8
|
+
> @instantdb/platform@0.22.95-experimental.surgical.20386947966.1 build:tshy
|
|
9
9
|
> tshy
|
|
10
10
|
|
|
11
11
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm.
|
|
12
12
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm.
|
|
13
13
|
|
|
14
|
-
> @instantdb/platform@0.22.95-experimental.surgical.
|
|
14
|
+
> @instantdb/platform@0.22.95-experimental.surgical.20386947966.1 build:standalone
|
|
15
15
|
> vite build
|
|
16
16
|
|
|
17
17
|
[36mvite v5.4.14 [32mbuilding for production...[36m[39m
|
|
@@ -21,15 +21,15 @@ rendering chunks...
|
|
|
21
21
|
computing gzip size...
|
|
22
22
|
[2mdist/standalone/[22m[36mindex.umd.cjs [39m[1m[2m352.64 kB[22m[1m[22m[2m │ gzip: 95.88 kB[22m
|
|
23
23
|
[2mdist/standalone/[22m[36mindex.js [39m[1m[2m459.57 kB[22m[1m[22m[2m │ gzip: 107.83 kB[22m
|
|
24
|
-
[32m✓ built in 2.
|
|
24
|
+
[32m✓ built in 2.09s[39m
|
|
25
25
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm.
|
|
26
26
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm.
|
|
27
27
|
|
|
28
|
-
> @instantdb/platform@0.22.95-experimental.surgical.
|
|
28
|
+
> @instantdb/platform@0.22.95-experimental.surgical.20386947966.1 check-exports
|
|
29
29
|
> attw --pack .
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
@instantdb/platform v0.22.95-experimental.surgical.
|
|
32
|
+
@instantdb/platform v0.22.95-experimental.surgical.20386947966.1
|
|
33
33
|
|
|
34
34
|
Build tools:
|
|
35
35
|
- @arethetypeswrong/cli@^0.17.4
|
package/dist/standalone/index.js
CHANGED
|
@@ -829,7 +829,7 @@ class ze extends Ut {
|
|
|
829
829
|
}
|
|
830
830
|
}
|
|
831
831
|
typeof window < "u" && typeof window.localStorage < "u" && (window.localStorage.getItem("devBackend"), window.localStorage.getItem("__instantLogging"), window.localStorage.getItem("__devtoolLocalDash"));
|
|
832
|
-
const nt = "v0.22.95-experimental.surgical.
|
|
832
|
+
const nt = "v0.22.95-experimental.surgical.20386947966.1";
|
|
833
833
|
class Z {
|
|
834
834
|
constructor(t, s, e, i = { indexed: !1, unique: !1 }) {
|
|
835
835
|
this.valueType = t, this.required = s, this.isIndexed = e, this.config = i, this.metadata = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(A,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(A=typeof globalThis<"u"?globalThis:A||self,v(A.instant={}))})(this,function(A){"use strict";var zn=Object.defineProperty;var Ai=A=>{throw TypeError(A)};var Vn=(A,v,N)=>v in A?zn(A,v,{enumerable:!0,configurable:!0,writable:!0,value:N}):A[v]=N;var m=(A,v,N)=>Vn(A,typeof v!="symbol"?v+"":v,N),Si=(A,v,N)=>v.has(A)||Ai("Cannot "+N);var T=(A,v,N)=>(Si(A,v,"read from private field"),N?N.call(A):v.get(A)),Pe=(A,v,N)=>v.has(A)?Ai("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(A):v.set(A,N),be=(A,v,N,Fe)=>(Si(A,v,"write to private field"),Fe?Fe.call(A,N):v.set(A,N),N);var ie,Q,dt,mt,yt,F,_;class v extends Error{constructor(t){super(t.message);const s=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,s),Error.captureStackTrace&&Error.captureStackTrace(this,v),this.name="InstantOAuthError",this.error=t.error,this.errorDescription=t.errorDescription}get[Symbol.toStringTag](){return"InstantAPIError"}}const N={Remove:"remove",Replace:"replace",Add:"add"},Fe=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),Xe=Symbol.iterator,ee={mutable:"mutable",immutable:"immutable"},Pt={};function Be(r,t){return r instanceof Map?r.has(t):Object.prototype.hasOwnProperty.call(r,t)}function ns(r,t){if(t in r){let s=Reflect.getPrototypeOf(r);for(;s;){const e=Reflect.getOwnPropertyDescriptor(s,t);if(e)return e;s=Reflect.getPrototypeOf(s)}}}function os(r){return Object.getPrototypeOf(r)===Set.prototype}function cs(r){return Object.getPrototypeOf(r)===Map.prototype}function Y(r){var t;return(t=r.copy)!==null&&t!==void 0?t:r.original}function bt(r){return!!L(r)}function L(r){return typeof r!="object"?null:r==null?void 0:r[Fe]}function gt(r){var t;const s=L(r);return s?(t=s.copy)!==null&&t!==void 0?t:s.original:r}function ge(r,t){if(!r||typeof r!="object")return!1;let s;return Object.getPrototypeOf(r)===Object.prototype||Array.isArray(r)||r instanceof Map||r instanceof Set||!!(t!=null&&t.mark)&&((s=t.mark(r,ee))===ee.immutable||typeof s=="function")}function hs(r,t=[]){if(Object.hasOwnProperty.call(r,"key")){const s=r.parent.copy,e=L(le(s,r.key));if(e!==null&&(e==null?void 0:e.original)!==r.original)return null;const i=r.parent.type===3,a=i?Array.from(r.parent.setMap.keys()).indexOf(r.key):r.key;if(!(i&&s.size>a||Be(s,a)))return null;t.push(a)}if(r.parent)return hs(r.parent,t);t.reverse();try{Ii(r.copy,t)}catch{return null}return t}function je(r){return Array.isArray(r)?1:r instanceof Map?2:r instanceof Set?3:0}function le(r,t){return je(r)===2?r.get(t):r[t]}function wt(r,t,s){je(r)===2?r.set(t,s):r[t]=s}function Tt(r,t){const s=L(r);return(s?Y(s):r)[t]}function we(r,t){return r===t?r!==0||1/r===1/t:r!==r&&t!==t}function Te(r,t){return t?r:[""].concat(r).map(s=>{const e=`${s}`;return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function Ii(r,t){for(let s=0;s<t.length-1;s+=1){const e=t[s];if(r=le(je(r)===3?Array.from(r):r,e),typeof r!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return r}function Ei(r){const t=Object.create(Object.getPrototypeOf(r));return Reflect.ownKeys(r).forEach(s=>{let e=Reflect.getOwnPropertyDescriptor(r,s);if(e.enumerable&&e.configurable&&e.writable){t[s]=r[s];return}e.writable||(e.writable=!0,e.configurable=!0),(e.get||e.set)&&(e={configurable:!0,writable:!0,enumerable:e.enumerable,value:r[s]}),Reflect.defineProperty(t,s,e)}),t}const Ci=Object.prototype.propertyIsEnumerable;function Ni(r,t){let s;if(Array.isArray(r))return Array.prototype.concat.call(r);if(r instanceof Set){if(!os(r)){const e=Object.getPrototypeOf(r).constructor;return new e(r.values())}return Set.prototype.difference?Set.prototype.difference.call(r,new Set):new Set(r.values())}else if(r instanceof Map){if(!cs(r)){const e=Object.getPrototypeOf(r).constructor;return new e(r)}return new Map(r)}else if(t!=null&&t.mark&&(s=t.mark(r,ee),s!==void 0)&&s!==ee.mutable){if(s===ee.immutable)return Ei(r);if(typeof s=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return s()}throw new Error(`Unsupported mark result: ${s}`)}else if(typeof r=="object"&&Object.getPrototypeOf(r)===Object.prototype){const e={};return Object.keys(r).forEach(i=>{e[i]=r[i]}),Object.getOwnPropertySymbols(r).forEach(i=>{Ci.call(r,i)&&(e[i]=r[i])}),e}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function K(r){r.copy||(r.copy=Ni(r.original,r.options))}function _e(r){if(!ge(r))return gt(r);if(Array.isArray(r))return r.map(_e);if(r instanceof Map){const s=Array.from(r.entries()).map(([e,i])=>[e,_e(i)]);if(!cs(r)){const e=Object.getPrototypeOf(r).constructor;return new e(s)}return new Map(s)}if(r instanceof Set){const s=Array.from(r).map(_e);if(!os(r)){const e=Object.getPrototypeOf(r).constructor;return new e(s)}return new Set(s)}const t=Object.create(Object.getPrototypeOf(r));for(const s in r)t[s]=_e(r[s]);return t}function Ge(r){return bt(r)?_e(r):r}function re(r){var t;r.assignedMap=(t=r.assignedMap)!==null&&t!==void 0?t:new Map,r.operated||(r.operated=!0,r.parent&&re(r.parent))}function ki(r,t){const s=je(r);if(s===0)Reflect.ownKeys(r).forEach(e=>{t(e,r[e],r)});else if(s===1){let e=0;for(const i of r)t(e,i,r),e+=1}else r.forEach((e,i)=>t(i,e,r))}function ls(r,t,s){if(bt(r)||!ge(r,s)||t.has(r)||Object.isFrozen(r))return;const e=r instanceof Set,i=e?new Map:void 0;if(t.add(r),ki(r,(a,n)=>{var o;if(bt(n)){const c=L(n);K(c);const h=!((o=c.assignedMap)===null||o===void 0)&&o.size||c.operated?c.copy:c.original;wt(e?i:r,a,h)}else ls(n,t,s)}),i){const a=r,n=Array.from(a);a.clear(),n.forEach(o=>{a.add(i.has(o)?i.get(o):o)})}}function vi(r,t){const s=r.type===3?r.setMap:r.copy;r.finalities.revoke.length>1&&r.assignedMap.get(t)&&s&&ls(le(s,t),r.finalities.handledSet,r.options)}function At(r){r.type===3&&r.copy&&(r.copy.clear(),r.setMap.forEach(t=>{r.copy.add(gt(t))}))}function St(r,t,s,e){if(r.operated&&r.assignedMap&&r.assignedMap.size>0&&!r.finalized){if(s&&e){const a=hs(r);a&&t(r,a,s,e)}r.finalized=!0}}function It(r,t,s,e){const i=L(s);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((a,n)=>{var o;const c=r.type===3?r.setMap:r.copy;if(we(le(c,t),s)){let h=i.original;i.copy&&(h=i.copy),At(r),St(r,e,a,n),r.options.enableAutoFreeze&&(r.options.updatedValues=(o=r.options.updatedValues)!==null&&o!==void 0?o:new WeakMap,r.options.updatedValues.set(h,i.original)),wt(c,t,h)}}),r.options.enableAutoFreeze&&i.finalities!==r.finalities&&(r.options.enableAutoFreeze=!1)),ge(s,r.options)&&r.finalities.draft.push(()=>{const a=r.type===3?r.setMap:r.copy;we(le(a,t),s)&&vi(r,t)})}function Oi(r,t,s,e,i){let{original:a,assignedMap:n,options:o}=r,c=r.copy;c.length<a.length&&([a,c]=[c,a],[s,e]=[e,s]);for(let h=0;h<a.length;h+=1)if(n.get(h.toString())&&c[h]!==a[h]){const l=t.concat([h]),u=Te(l,i);s.push({op:N.Replace,path:u,value:Ge(c[h])}),e.push({op:N.Replace,path:u,value:Ge(a[h])})}for(let h=a.length;h<c.length;h+=1){const l=t.concat([h]),u=Te(l,i);s.push({op:N.Add,path:u,value:Ge(c[h])})}if(a.length<c.length){const{arrayLengthAssignment:h=!0}=o.enablePatches;if(h){const l=t.concat(["length"]),u=Te(l,i);e.push({op:N.Replace,path:u,value:a.length})}else for(let l=c.length;a.length<l;l-=1){const u=t.concat([l-1]),d=Te(u,i);e.push({op:N.Remove,path:d})}}}function Di({original:r,copy:t,assignedMap:s},e,i,a,n){s.forEach((o,c)=>{const h=le(r,c),l=Ge(le(t,c)),u=o?Be(r,c)?N.Replace:N.Add:N.Remove;if(we(h,l)&&u===N.Replace)return;const d=e.concat(c),f=Te(d,n);i.push(u===N.Remove?{op:u,path:f}:{op:u,path:f,value:l}),a.push(u===N.Add?{op:N.Remove,path:f}:u===N.Remove?{op:N.Add,path:f,value:h}:{op:N.Replace,path:f,value:h})})}function Li({original:r,copy:t},s,e,i,a){let n=0;r.forEach(o=>{if(!t.has(o)){const c=s.concat([n]),h=Te(c,a);e.push({op:N.Remove,path:h,value:o}),i.unshift({op:N.Add,path:h,value:o})}n+=1}),n=0,t.forEach(o=>{if(!r.has(o)){const c=s.concat([n]),h=Te(c,a);e.push({op:N.Add,path:h,value:o}),i.unshift({op:N.Remove,path:h,value:o})}n+=1})}function Re(r,t,s,e){const{pathAsArray:i=!0}=r.options.enablePatches;switch(r.type){case 0:case 2:return Di(r,t,s,e,i);case 1:return Oi(r,t,s,e,i);case 3:return Li(r,t,s,e,i)}}const Ye=(r,t,s=!1)=>{if(typeof r=="object"&&r!==null&&(!ge(r,t)||s))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},Et={get size(){return Y(L(this)).size},has(r){return Y(L(this)).has(r)},set(r,t){const s=L(this),e=Y(s);return(!e.has(r)||!we(e.get(r),t))&&(K(s),re(s),s.assignedMap.set(r,!0),s.copy.set(r,t),It(s,r,t,Re)),this},delete(r){if(!this.has(r))return!1;const t=L(this);return K(t),re(t),t.original.has(r)?t.assignedMap.set(r,!1):t.assignedMap.delete(r),t.copy.delete(r),!0},clear(){const r=L(this);if(this.size){K(r),re(r),r.assignedMap=new Map;for(const[t]of r.original)r.assignedMap.set(t,!1);r.copy.clear()}},forEach(r,t){const s=L(this);Y(s).forEach((e,i)=>{r.call(t,this.get(i),i,this)})},get(r){var t,s;const e=L(this),i=Y(e).get(r),a=((s=(t=e.options).mark)===null||s===void 0?void 0:s.call(t,i,ee))===ee.mutable;if(e.options.strict&&Ye(i,e.options,a),a||e.finalized||!ge(i,e.options)||i!==e.original.get(r))return i;const n=Pt.createDraft({original:i,parentDraft:e,key:r,finalities:e.finalities,options:e.options});return K(e),e.copy.set(r,n),n},keys(){return Y(L(this)).keys()},values(){const r=this.keys();return{[Xe]:()=>this.values(),next:()=>{const t=r.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const r=this.keys();return{[Xe]:()=>this.entries(),next:()=>{const t=r.next();if(t.done)return t;const s=this.get(t.value);return{done:!1,value:[t.value,s]}}}},[Xe](){return this.entries()}},Mi=Reflect.ownKeys(Et),us=(r,t,{isValuesIterator:s})=>()=>{var e,i;const a=t.next();if(a.done)return a;const n=a.value;let o=r.setMap.get(n);const c=L(o),h=((i=(e=r.options).mark)===null||i===void 0?void 0:i.call(e,o,ee))===ee.mutable;if(r.options.strict&&Ye(n,r.options,h),!h&&!c&&ge(n,r.options)&&!r.finalized&&r.original.has(n)){const l=Pt.createDraft({original:n,parentDraft:r,key:n,finalities:r.finalities,options:r.options});r.setMap.set(n,l),o=l}else c&&(o=c.proxy);return{done:!1,value:s?o:[o,o]}},Qe={get size(){return L(this).setMap.size},has(r){const t=L(this);if(t.setMap.has(r))return!0;K(t);const s=L(r);return!!(s&&t.setMap.has(s.original))},add(r){const t=L(this);return this.has(r)||(K(t),re(t),t.assignedMap.set(r,!0),t.setMap.set(r,r),It(t,r,r,Re)),this},delete(r){if(!this.has(r))return!1;const t=L(this);K(t),re(t);const s=L(r);return s&&t.setMap.has(s.original)?(t.assignedMap.set(s.original,!1),t.setMap.delete(s.original)):(!s&&t.setMap.has(r)?t.assignedMap.set(r,!1):t.assignedMap.delete(r),t.setMap.delete(r))},clear(){if(!this.size)return;const r=L(this);K(r),re(r);for(const t of r.original)r.assignedMap.set(t,!1);r.setMap.clear()},values(){const r=L(this);K(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:us(r,t,{isValuesIterator:!0})}},entries(){const r=L(this);K(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:us(r,t,{isValuesIterator:!1})}},keys(){return this.values()},[Xe](){return this.values()},forEach(r,t){const s=this.values();let e=s.next();for(;!e.done;)r.call(t,e.value,e.value,this),e=s.next()}};Set.prototype.difference&&Object.assign(Qe,{intersection(r){return Set.prototype.intersection.call(new Set(this.values()),r)},union(r){return Set.prototype.union.call(new Set(this.values()),r)},difference(r){return Set.prototype.difference.call(new Set(this.values()),r)},symmetricDifference(r){return Set.prototype.symmetricDifference.call(new Set(this.values()),r)},isSubsetOf(r){return Set.prototype.isSubsetOf.call(new Set(this.values()),r)},isSupersetOf(r){return Set.prototype.isSupersetOf.call(new Set(this.values()),r)},isDisjointFrom(r){return Set.prototype.isDisjointFrom.call(new Set(this.values()),r)}});const Fi=Reflect.ownKeys(Qe),ps=new WeakSet,fs={get(r,t,s){var e,i;const a=(e=r.copy)===null||e===void 0?void 0:e[t];if(a&&ps.has(a))return a;if(t===Fe)return r;let n;if(r.options.mark){const h=t==="size"&&(r.original instanceof Map||r.original instanceof Set)?Reflect.get(r.original,t):Reflect.get(r.original,t,s);if(n=r.options.mark(h,ee),n===ee.mutable)return r.options.strict&&Ye(h,r.options,!0),h}const o=Y(r);if(o instanceof Map&&Mi.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Et,"size").get.call(r.proxy);const h=Et[t];if(h)return h.bind(r.proxy)}if(o instanceof Set&&Fi.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Qe,"size").get.call(r.proxy);const h=Qe[t];if(h)return h.bind(r.proxy)}if(!Be(o,t)){const h=ns(o,t);return h?"value"in h?h.value:(i=h.get)===null||i===void 0?void 0:i.call(r.proxy):void 0}const c=o[t];if(r.options.strict&&Ye(c,r.options),r.finalized||!ge(c,r.options))return c;if(c===Tt(r.original,t)){if(K(r),r.copy[t]=ds({original:r.original[t],parentDraft:r,key:r.type===1?Number(t):t,finalities:r.finalities,options:r.options}),typeof n=="function"){const h=L(r.copy[t]);return K(h),re(h),h.copy}return r.copy[t]}return c},set(r,t,s){var e;if(r.type===3||r.type===2)throw new Error("Map/Set draft does not support any property assignment.");let i;if(r.type===1&&t!=="length"&&!(Number.isInteger(i=Number(t))&&i>=0&&(t===0||i===0||String(i)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");const a=ns(Y(r),t);if(a!=null&&a.set)return a.set.call(r.proxy,s),!0;const n=Tt(Y(r),t),o=L(n);return o&&we(o.original,s)?(r.copy[t]=s,r.assignedMap=(e=r.assignedMap)!==null&&e!==void 0?e:new Map,r.assignedMap.set(t,!1),!0):(we(s,n)&&(s!==void 0||Be(r.original,t))||(K(r),re(r),Be(r.original,t)&&we(s,r.original[t])?r.assignedMap.delete(t):r.assignedMap.set(t,!0),r.copy[t]=s,It(r,t,s,Re)),!0)},has(r,t){return t in Y(r)},ownKeys(r){return Reflect.ownKeys(Y(r))},getOwnPropertyDescriptor(r,t){const s=Y(r),e=Reflect.getOwnPropertyDescriptor(s,t);return e&&{writable:!0,configurable:r.type!==1||t!=="length",enumerable:e.enumerable,value:s[t]}},getPrototypeOf(r){return Reflect.getPrototypeOf(r.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(r,t){var s;return r.type===1?fs.set.call(this,r,t,void 0,r.proxy):(Tt(r.original,t)!==void 0||t in r.original?(K(r),re(r),r.assignedMap.set(t,!1)):(r.assignedMap=(s=r.assignedMap)!==null&&s!==void 0?s:new Map,r.assignedMap.delete(t)),r.copy&&delete r.copy[t],!0)}};function ds(r){const{original:t,parentDraft:s,key:e,finalities:i,options:a}=r,n=je(t),o={type:n,finalized:!1,parent:s,original:t,copy:null,proxy:null,finalities:i,options:a,setMap:n===3?new Map(t.entries()):void 0};(e||"key"in r)&&(o.key=e);const{proxy:c,revoke:h}=Proxy.revocable(n===1?Object.assign([],o):o,fs);if(i.revoke.push(h),ps.add(c),o.proxy=c,s){const l=s;l.finalities.draft.push((u,d)=>{var f,x;const S=L(c);let R=l.type===3?l.setMap:l.copy;const C=le(R,e),D=L(C);if(D){let $=D.original;D.operated&&($=gt(C)),At(D),St(D,Re,u,d),l.options.enableAutoFreeze&&(l.options.updatedValues=(f=l.options.updatedValues)!==null&&f!==void 0?f:new WeakMap,l.options.updatedValues.set($,D.original)),wt(R,e,$)}(x=S.callbacks)===null||x===void 0||x.forEach($=>{$(u,d)})})}else{const l=L(c);l.finalities.draft.push((u,d)=>{At(l),St(l,Re,u,d)})}return c}Pt.createDraft=ds,Object.prototype.constructor.toString();const z=[];for(let r=0;r<256;++r)z.push((r+256).toString(16).slice(1));function Bi(r,t=0){return(z[r[t+0]]+z[r[t+1]]+z[r[t+2]]+z[r[t+3]]+"-"+z[r[t+4]]+z[r[t+5]]+"-"+z[r[t+6]]+z[r[t+7]]+"-"+z[r[t+8]]+z[r[t+9]]+"-"+z[r[t+10]]+z[r[t+11]]+z[r[t+12]]+z[r[t+13]]+z[r[t+14]]+z[r[t+15]]).toLowerCase()}let Ct;const ji=new Uint8Array(16);function _i(){if(!Ct){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ct=crypto.getRandomValues.bind(crypto)}return Ct(ji)}const ms={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ri(r,t,s){var i;if(ms.randomUUID&&!r)return ms.randomUUID();r=r||{};const e=r.random??((i=r.rng)==null?void 0:i.call(r))??_i();if(e.length<16)throw new Error("Random bytes length must be >= 16");return e[6]=e[6]&15|64,e[8]=e[8]&63|128,Bi(e)}function ys(){return Ri()}function $i(r,t){return r.localeCompare(t)}function Ui(){let r=$i;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{r=Intl.Collator("en-US").compare}catch{}return r}Ui();function qi(){const t={__etype:1,__ops:1,create:1,update:1,link:1,unlink:1,delete:1,merge:1,ruleParams:1};return new Set(Object.keys(t))}const zi=qi();function Nt(r,t,s){const e={__etype:r,__ops:s};return new Proxy(e,{get:(i,a)=>{if(a==="__ops")return s;if(a==="__etype")return r;if(zi.has(a))return(n,o)=>Nt(r,t,[...s,o?[a,r,t,n,o]:[a,r,t,n]])}})}function Vi(r){return r.startsWith("lookup__")}function Hi(r){const[t,s,...e]=r.split("__");return[s,JSON.parse(e.join("__"))]}function Ki(r){return new Proxy({__etype:r},{get(t,s){if(s==="__etype")return r;const e=s;return Vi(e)?Nt(r,Hi(e),[]):Nt(r,e,[])}})}function Ji(){return new Proxy({},{get(r,t){return Ki(t)}})}Ji(),Object.assign(Object.assign({},{"unique?":!0,"index?":!0}),{cardinality:"one"});class kt extends Error{constructor(t,s){super(t),this.hint=s;const e=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,kt),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class $e extends kt{constructor(t){var s;const e=((s=t.body)===null||s===void 0?void 0:s.message)||`API Error (${t.status})`;super(e,t.body.hint);const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,$e),this.name="InstantAPIError",this.status=t.status,this.body=t.body}get[Symbol.toStringTag](){return"InstantAPIError"}}typeof window<"u"&&typeof window.localStorage<"u"&&(window.localStorage.getItem("devBackend"),window.localStorage.getItem("__instantLogging"),window.localStorage.getItem("__devtoolLocalDash"));const Ue="v0.22.95-experimental.surgical.20386736818.1";class te{constructor(t,s,e,i={indexed:!1,unique:!1}){this.valueType=t,this.required=s,this.isIndexed=e,this.config=i,this.metadata={}}clientRequired(){return new te(this.valueType,!1,this.isIndexed,this.config)}optional(){return new te(this.valueType,!1,this.isIndexed,this.config)}unique(){return new te(this.valueType,this.required,this.isIndexed,Object.assign(Object.assign({},this.config),{unique:!0}))}indexed(){return new te(this.valueType,this.required,!0,Object.assign(Object.assign({},this.config),{indexed:!0}))}}class Ze{constructor(t,s){this.attrs=t,this.links=s}asType(){return new Ze(this.attrs,this.links)}}class et{constructor(t,s,e){this.entities=t,this.links=s,this.rooms=e}withRoomSchema(){return new et(this.entities,this.links,{})}}var xs;(function(r){r.InitialSyncBatch="InitialSyncBatch",r.InitialSyncComplete="InitialSyncComplete",r.LoadFromStorage="LoadFromStorage",r.SyncTransaction="SyncTransaction",r.Error="Error"})(xs||(xs={}));function Wi(r,t){return new et(Ps(r,t),t,void 0)}function Xi(r){return new Ze(r,{})}function Gi(){return new te("string",!0,!1)}function Yi(){return new te("number",!0,!1)}function Qi(){return new te("boolean",!0,!1)}function Zi(){return new te("date",!0,!1)}function er(){return new te("json",!0,!1)}function tr(){return new te("json",!0,!1)}function Ps(r,t){var s,e,i,a;const n={fwd:{},rev:{}};for(const c of Object.values(t))(s=n.fwd)[e=c.forward.on]||(s[e]={}),(i=n.rev)[a=c.reverse.on]||(i[a]={}),n.fwd[c.forward.on][c.forward.label]={entityName:c.reverse.on,cardinality:c.forward.has},n.rev[c.reverse.on][c.reverse.label]={entityName:c.forward.on,cardinality:c.reverse.has};return Object.fromEntries(Object.entries(r).map(([c,h])=>[c,new Ze(h.attrs,Object.assign(Object.assign({},n.fwd[c]),n.rev[c]))]))}function sr({entities:r,links:t,rooms:s}){const e=t??{},i=s??{};return new et(Ps(r,e),e,i)}const V={graph:Wi,schema:sr,entity:Xi,string:Gi,number:Yi,boolean:Qi,date:Zi,json:er,any:tr};function ir(){var r;return globalThis.__instantDbSchemaHashStore=(r=globalThis.__instantDbSchemaHashStore)!==null&&r!==void 0?r:new WeakMap,globalThis.__instantDbSchemaHashStore}function rr(){var r;return globalThis.__instantDbStore=(r=globalThis.__instantDbStore)!==null&&r!==void 0?r:{},globalThis.__instantDbStore}rr(),ir();function ar(){const r="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._~";let t="";for(const s of crypto.getRandomValues(new Uint8Array(64)))t=t+r[s%r.length];return t}function nr(r){return crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(r))}function or(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function cr(r){return nr(r).then(t=>or(btoa(String.fromCharCode(...Array.from(new Uint8Array(t))))))}function hr(){const r=Math.min(800,Math.floor(window.outerWidth*.8)),t=Math.min(630,Math.floor(window.outerHeight*.5)),s={width:r,height:t,left:Math.round(window.screenX+(window.outerWidth-r)/2),top:Math.round(window.screenY+(window.outerHeight-t)/8)},e={width:s.width,height:s.height,left:s.left,top:s.top,toolbar:0,scrollbars:1,status:1,resizable:1,menuBar:0,rel:"opener"};return Object.keys(e).map(i=>`${i}=${e[i]}`).join(",")}let bs=null;function lr({clientId:r,state:t,codeChallenge:s,apiURI:e,redirectUri:i,scopes:a}){const n=new URL(`${e}/platform/oauth/start`);return n.searchParams.set("client_id",r),n.searchParams.set("redirect_uri",i),n.searchParams.set("scope",a.join(" ")),n.searchParams.set("state",t),n.searchParams.set("response_type","code"),n.searchParams.set("code_challenge",s),n.searchParams.set("code_challenge_method","S256"),n.toString()}async function ur({code:r,clientId:t,verifier:s,apiURI:e,redirectUri:i}){const a=await fetch(`${e}/platform/oauth/token`,{method:"POST",headers:{"Content-type":"application/json","Instant-Platform-Version":Ue,"Instant-Core-Version":Ue},body:JSON.stringify({grant_type:"authorization_code",code:r,redirect_uri:i,client_id:t,code_verifier:s})});if(!a.ok){const o=await a.text();let c;try{const h=JSON.parse(o);c={error:h.error,errorDescription:h.error_description,message:`OAuth error: ${h.error||"server_error"}`}}catch{c={error:"server_error",message:"OAuth error: server_error"}}throw new v(c)}const n=await a.json();return{token:n.access_token,expiresAt:new Date(Date.now()+(n.expires_in-30)*1e3)}}function pr(){if(typeof window>"u")throw new Error("This function may only be used in a browser context.");const r=new URL(window.location.href).searchParams,t=r.get("state"),s=r.get("error"),e=r.get("error_description"),i=r.get("code");if(!t)throw new Error("Invalid redirect. The state param is missing.");const a=new BroadcastChannel(t);return a.addEventListener("message",n=>{n.data.type==="oauth-redirect-window-done"&&window.close()}),a.postMessage({type:"oauth-redirect",state:t,error:s,errorDescription:e,code:i}),()=>{a.close()}}function fr({clientId:r,apiURI:t,redirectUri:s,scopes:e}){if(typeof window>"u")throw new Error("OAuth flow can only be started on the client.");const i=bs;i&&i.close();const a=crypto.randomUUID(),n=ar(),o=new BroadcastChannel(a),c=new Promise((l,u)=>{o.addEventListener("message",async d=>{if(d.data.type!=="oauth-redirect")return;const{state:f,error:x,code:S,errorDescription:R}=d.data;if(!(!f||f!==a)){if(S)try{const C=await ur({clientId:r,code:S,verifier:n,apiURI:t,redirectUri:s});l(C)}catch(C){C instanceof v&&u(C),u(new v({error:"server_error",message:"OAuth error exchanging code for token"}))}else u(typeof x=="string"?new v({error:x,errorDescription:R,message:`OAuth error: ${x}`}):new v({error:"server_error",message:"OAuth error: server_error"}));o.postMessage({type:"oauth-redirect-window-done"})}})}),h=window.open("",`instantdb_oauth_${Math.random()}`.replace(".",""),hr());return h?(bs=h,cr(n).then(l=>{const u=lr({clientId:r,state:a,codeChallenge:l,apiURI:t,redirectUri:s,scopes:e});h.location.href=u}),c.finally(()=>o.close())):Promise.reject({error:"Could not open Auth window"})}class dr{constructor(t){this.redirectUri=t.redirectUri,this.apiURI=t.apiURI??"https://api.instantdb.com",this.clientId=t.clientId}startClientOnlyFlow(t){return fr({clientId:this.clientId,apiURI:this.apiURI,redirectUri:this.redirectUri,scopes:t})}handleClientRedirect(){return pr()}}function mr(r,t){const s=r&&Object.keys(r).length?JSON.stringify(r,null,2):`{
|
|
1
|
+
(function(A,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(A=typeof globalThis<"u"?globalThis:A||self,v(A.instant={}))})(this,function(A){"use strict";var zn=Object.defineProperty;var Ai=A=>{throw TypeError(A)};var Vn=(A,v,N)=>v in A?zn(A,v,{enumerable:!0,configurable:!0,writable:!0,value:N}):A[v]=N;var m=(A,v,N)=>Vn(A,typeof v!="symbol"?v+"":v,N),Si=(A,v,N)=>v.has(A)||Ai("Cannot "+N);var T=(A,v,N)=>(Si(A,v,"read from private field"),N?N.call(A):v.get(A)),Pe=(A,v,N)=>v.has(A)?Ai("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(A):v.set(A,N),be=(A,v,N,Fe)=>(Si(A,v,"write to private field"),Fe?Fe.call(A,N):v.set(A,N),N);var ie,Q,dt,mt,yt,F,_;class v extends Error{constructor(t){super(t.message);const s=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,s),Error.captureStackTrace&&Error.captureStackTrace(this,v),this.name="InstantOAuthError",this.error=t.error,this.errorDescription=t.errorDescription}get[Symbol.toStringTag](){return"InstantAPIError"}}const N={Remove:"remove",Replace:"replace",Add:"add"},Fe=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),Xe=Symbol.iterator,ee={mutable:"mutable",immutable:"immutable"},Pt={};function Be(r,t){return r instanceof Map?r.has(t):Object.prototype.hasOwnProperty.call(r,t)}function ns(r,t){if(t in r){let s=Reflect.getPrototypeOf(r);for(;s;){const e=Reflect.getOwnPropertyDescriptor(s,t);if(e)return e;s=Reflect.getPrototypeOf(s)}}}function os(r){return Object.getPrototypeOf(r)===Set.prototype}function cs(r){return Object.getPrototypeOf(r)===Map.prototype}function Y(r){var t;return(t=r.copy)!==null&&t!==void 0?t:r.original}function bt(r){return!!L(r)}function L(r){return typeof r!="object"?null:r==null?void 0:r[Fe]}function gt(r){var t;const s=L(r);return s?(t=s.copy)!==null&&t!==void 0?t:s.original:r}function ge(r,t){if(!r||typeof r!="object")return!1;let s;return Object.getPrototypeOf(r)===Object.prototype||Array.isArray(r)||r instanceof Map||r instanceof Set||!!(t!=null&&t.mark)&&((s=t.mark(r,ee))===ee.immutable||typeof s=="function")}function hs(r,t=[]){if(Object.hasOwnProperty.call(r,"key")){const s=r.parent.copy,e=L(le(s,r.key));if(e!==null&&(e==null?void 0:e.original)!==r.original)return null;const i=r.parent.type===3,a=i?Array.from(r.parent.setMap.keys()).indexOf(r.key):r.key;if(!(i&&s.size>a||Be(s,a)))return null;t.push(a)}if(r.parent)return hs(r.parent,t);t.reverse();try{Ii(r.copy,t)}catch{return null}return t}function je(r){return Array.isArray(r)?1:r instanceof Map?2:r instanceof Set?3:0}function le(r,t){return je(r)===2?r.get(t):r[t]}function wt(r,t,s){je(r)===2?r.set(t,s):r[t]=s}function Tt(r,t){const s=L(r);return(s?Y(s):r)[t]}function we(r,t){return r===t?r!==0||1/r===1/t:r!==r&&t!==t}function Te(r,t){return t?r:[""].concat(r).map(s=>{const e=`${s}`;return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function Ii(r,t){for(let s=0;s<t.length-1;s+=1){const e=t[s];if(r=le(je(r)===3?Array.from(r):r,e),typeof r!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return r}function Ei(r){const t=Object.create(Object.getPrototypeOf(r));return Reflect.ownKeys(r).forEach(s=>{let e=Reflect.getOwnPropertyDescriptor(r,s);if(e.enumerable&&e.configurable&&e.writable){t[s]=r[s];return}e.writable||(e.writable=!0,e.configurable=!0),(e.get||e.set)&&(e={configurable:!0,writable:!0,enumerable:e.enumerable,value:r[s]}),Reflect.defineProperty(t,s,e)}),t}const Ci=Object.prototype.propertyIsEnumerable;function Ni(r,t){let s;if(Array.isArray(r))return Array.prototype.concat.call(r);if(r instanceof Set){if(!os(r)){const e=Object.getPrototypeOf(r).constructor;return new e(r.values())}return Set.prototype.difference?Set.prototype.difference.call(r,new Set):new Set(r.values())}else if(r instanceof Map){if(!cs(r)){const e=Object.getPrototypeOf(r).constructor;return new e(r)}return new Map(r)}else if(t!=null&&t.mark&&(s=t.mark(r,ee),s!==void 0)&&s!==ee.mutable){if(s===ee.immutable)return Ei(r);if(typeof s=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return s()}throw new Error(`Unsupported mark result: ${s}`)}else if(typeof r=="object"&&Object.getPrototypeOf(r)===Object.prototype){const e={};return Object.keys(r).forEach(i=>{e[i]=r[i]}),Object.getOwnPropertySymbols(r).forEach(i=>{Ci.call(r,i)&&(e[i]=r[i])}),e}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function K(r){r.copy||(r.copy=Ni(r.original,r.options))}function _e(r){if(!ge(r))return gt(r);if(Array.isArray(r))return r.map(_e);if(r instanceof Map){const s=Array.from(r.entries()).map(([e,i])=>[e,_e(i)]);if(!cs(r)){const e=Object.getPrototypeOf(r).constructor;return new e(s)}return new Map(s)}if(r instanceof Set){const s=Array.from(r).map(_e);if(!os(r)){const e=Object.getPrototypeOf(r).constructor;return new e(s)}return new Set(s)}const t=Object.create(Object.getPrototypeOf(r));for(const s in r)t[s]=_e(r[s]);return t}function Ge(r){return bt(r)?_e(r):r}function re(r){var t;r.assignedMap=(t=r.assignedMap)!==null&&t!==void 0?t:new Map,r.operated||(r.operated=!0,r.parent&&re(r.parent))}function ki(r,t){const s=je(r);if(s===0)Reflect.ownKeys(r).forEach(e=>{t(e,r[e],r)});else if(s===1){let e=0;for(const i of r)t(e,i,r),e+=1}else r.forEach((e,i)=>t(i,e,r))}function ls(r,t,s){if(bt(r)||!ge(r,s)||t.has(r)||Object.isFrozen(r))return;const e=r instanceof Set,i=e?new Map:void 0;if(t.add(r),ki(r,(a,n)=>{var o;if(bt(n)){const c=L(n);K(c);const h=!((o=c.assignedMap)===null||o===void 0)&&o.size||c.operated?c.copy:c.original;wt(e?i:r,a,h)}else ls(n,t,s)}),i){const a=r,n=Array.from(a);a.clear(),n.forEach(o=>{a.add(i.has(o)?i.get(o):o)})}}function vi(r,t){const s=r.type===3?r.setMap:r.copy;r.finalities.revoke.length>1&&r.assignedMap.get(t)&&s&&ls(le(s,t),r.finalities.handledSet,r.options)}function At(r){r.type===3&&r.copy&&(r.copy.clear(),r.setMap.forEach(t=>{r.copy.add(gt(t))}))}function St(r,t,s,e){if(r.operated&&r.assignedMap&&r.assignedMap.size>0&&!r.finalized){if(s&&e){const a=hs(r);a&&t(r,a,s,e)}r.finalized=!0}}function It(r,t,s,e){const i=L(s);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((a,n)=>{var o;const c=r.type===3?r.setMap:r.copy;if(we(le(c,t),s)){let h=i.original;i.copy&&(h=i.copy),At(r),St(r,e,a,n),r.options.enableAutoFreeze&&(r.options.updatedValues=(o=r.options.updatedValues)!==null&&o!==void 0?o:new WeakMap,r.options.updatedValues.set(h,i.original)),wt(c,t,h)}}),r.options.enableAutoFreeze&&i.finalities!==r.finalities&&(r.options.enableAutoFreeze=!1)),ge(s,r.options)&&r.finalities.draft.push(()=>{const a=r.type===3?r.setMap:r.copy;we(le(a,t),s)&&vi(r,t)})}function Oi(r,t,s,e,i){let{original:a,assignedMap:n,options:o}=r,c=r.copy;c.length<a.length&&([a,c]=[c,a],[s,e]=[e,s]);for(let h=0;h<a.length;h+=1)if(n.get(h.toString())&&c[h]!==a[h]){const l=t.concat([h]),u=Te(l,i);s.push({op:N.Replace,path:u,value:Ge(c[h])}),e.push({op:N.Replace,path:u,value:Ge(a[h])})}for(let h=a.length;h<c.length;h+=1){const l=t.concat([h]),u=Te(l,i);s.push({op:N.Add,path:u,value:Ge(c[h])})}if(a.length<c.length){const{arrayLengthAssignment:h=!0}=o.enablePatches;if(h){const l=t.concat(["length"]),u=Te(l,i);e.push({op:N.Replace,path:u,value:a.length})}else for(let l=c.length;a.length<l;l-=1){const u=t.concat([l-1]),d=Te(u,i);e.push({op:N.Remove,path:d})}}}function Di({original:r,copy:t,assignedMap:s},e,i,a,n){s.forEach((o,c)=>{const h=le(r,c),l=Ge(le(t,c)),u=o?Be(r,c)?N.Replace:N.Add:N.Remove;if(we(h,l)&&u===N.Replace)return;const d=e.concat(c),f=Te(d,n);i.push(u===N.Remove?{op:u,path:f}:{op:u,path:f,value:l}),a.push(u===N.Add?{op:N.Remove,path:f}:u===N.Remove?{op:N.Add,path:f,value:h}:{op:N.Replace,path:f,value:h})})}function Li({original:r,copy:t},s,e,i,a){let n=0;r.forEach(o=>{if(!t.has(o)){const c=s.concat([n]),h=Te(c,a);e.push({op:N.Remove,path:h,value:o}),i.unshift({op:N.Add,path:h,value:o})}n+=1}),n=0,t.forEach(o=>{if(!r.has(o)){const c=s.concat([n]),h=Te(c,a);e.push({op:N.Add,path:h,value:o}),i.unshift({op:N.Remove,path:h,value:o})}n+=1})}function Re(r,t,s,e){const{pathAsArray:i=!0}=r.options.enablePatches;switch(r.type){case 0:case 2:return Di(r,t,s,e,i);case 1:return Oi(r,t,s,e,i);case 3:return Li(r,t,s,e,i)}}const Ye=(r,t,s=!1)=>{if(typeof r=="object"&&r!==null&&(!ge(r,t)||s))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},Et={get size(){return Y(L(this)).size},has(r){return Y(L(this)).has(r)},set(r,t){const s=L(this),e=Y(s);return(!e.has(r)||!we(e.get(r),t))&&(K(s),re(s),s.assignedMap.set(r,!0),s.copy.set(r,t),It(s,r,t,Re)),this},delete(r){if(!this.has(r))return!1;const t=L(this);return K(t),re(t),t.original.has(r)?t.assignedMap.set(r,!1):t.assignedMap.delete(r),t.copy.delete(r),!0},clear(){const r=L(this);if(this.size){K(r),re(r),r.assignedMap=new Map;for(const[t]of r.original)r.assignedMap.set(t,!1);r.copy.clear()}},forEach(r,t){const s=L(this);Y(s).forEach((e,i)=>{r.call(t,this.get(i),i,this)})},get(r){var t,s;const e=L(this),i=Y(e).get(r),a=((s=(t=e.options).mark)===null||s===void 0?void 0:s.call(t,i,ee))===ee.mutable;if(e.options.strict&&Ye(i,e.options,a),a||e.finalized||!ge(i,e.options)||i!==e.original.get(r))return i;const n=Pt.createDraft({original:i,parentDraft:e,key:r,finalities:e.finalities,options:e.options});return K(e),e.copy.set(r,n),n},keys(){return Y(L(this)).keys()},values(){const r=this.keys();return{[Xe]:()=>this.values(),next:()=>{const t=r.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const r=this.keys();return{[Xe]:()=>this.entries(),next:()=>{const t=r.next();if(t.done)return t;const s=this.get(t.value);return{done:!1,value:[t.value,s]}}}},[Xe](){return this.entries()}},Mi=Reflect.ownKeys(Et),us=(r,t,{isValuesIterator:s})=>()=>{var e,i;const a=t.next();if(a.done)return a;const n=a.value;let o=r.setMap.get(n);const c=L(o),h=((i=(e=r.options).mark)===null||i===void 0?void 0:i.call(e,o,ee))===ee.mutable;if(r.options.strict&&Ye(n,r.options,h),!h&&!c&&ge(n,r.options)&&!r.finalized&&r.original.has(n)){const l=Pt.createDraft({original:n,parentDraft:r,key:n,finalities:r.finalities,options:r.options});r.setMap.set(n,l),o=l}else c&&(o=c.proxy);return{done:!1,value:s?o:[o,o]}},Qe={get size(){return L(this).setMap.size},has(r){const t=L(this);if(t.setMap.has(r))return!0;K(t);const s=L(r);return!!(s&&t.setMap.has(s.original))},add(r){const t=L(this);return this.has(r)||(K(t),re(t),t.assignedMap.set(r,!0),t.setMap.set(r,r),It(t,r,r,Re)),this},delete(r){if(!this.has(r))return!1;const t=L(this);K(t),re(t);const s=L(r);return s&&t.setMap.has(s.original)?(t.assignedMap.set(s.original,!1),t.setMap.delete(s.original)):(!s&&t.setMap.has(r)?t.assignedMap.set(r,!1):t.assignedMap.delete(r),t.setMap.delete(r))},clear(){if(!this.size)return;const r=L(this);K(r),re(r);for(const t of r.original)r.assignedMap.set(t,!1);r.setMap.clear()},values(){const r=L(this);K(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:us(r,t,{isValuesIterator:!0})}},entries(){const r=L(this);K(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:us(r,t,{isValuesIterator:!1})}},keys(){return this.values()},[Xe](){return this.values()},forEach(r,t){const s=this.values();let e=s.next();for(;!e.done;)r.call(t,e.value,e.value,this),e=s.next()}};Set.prototype.difference&&Object.assign(Qe,{intersection(r){return Set.prototype.intersection.call(new Set(this.values()),r)},union(r){return Set.prototype.union.call(new Set(this.values()),r)},difference(r){return Set.prototype.difference.call(new Set(this.values()),r)},symmetricDifference(r){return Set.prototype.symmetricDifference.call(new Set(this.values()),r)},isSubsetOf(r){return Set.prototype.isSubsetOf.call(new Set(this.values()),r)},isSupersetOf(r){return Set.prototype.isSupersetOf.call(new Set(this.values()),r)},isDisjointFrom(r){return Set.prototype.isDisjointFrom.call(new Set(this.values()),r)}});const Fi=Reflect.ownKeys(Qe),ps=new WeakSet,fs={get(r,t,s){var e,i;const a=(e=r.copy)===null||e===void 0?void 0:e[t];if(a&&ps.has(a))return a;if(t===Fe)return r;let n;if(r.options.mark){const h=t==="size"&&(r.original instanceof Map||r.original instanceof Set)?Reflect.get(r.original,t):Reflect.get(r.original,t,s);if(n=r.options.mark(h,ee),n===ee.mutable)return r.options.strict&&Ye(h,r.options,!0),h}const o=Y(r);if(o instanceof Map&&Mi.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Et,"size").get.call(r.proxy);const h=Et[t];if(h)return h.bind(r.proxy)}if(o instanceof Set&&Fi.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Qe,"size").get.call(r.proxy);const h=Qe[t];if(h)return h.bind(r.proxy)}if(!Be(o,t)){const h=ns(o,t);return h?"value"in h?h.value:(i=h.get)===null||i===void 0?void 0:i.call(r.proxy):void 0}const c=o[t];if(r.options.strict&&Ye(c,r.options),r.finalized||!ge(c,r.options))return c;if(c===Tt(r.original,t)){if(K(r),r.copy[t]=ds({original:r.original[t],parentDraft:r,key:r.type===1?Number(t):t,finalities:r.finalities,options:r.options}),typeof n=="function"){const h=L(r.copy[t]);return K(h),re(h),h.copy}return r.copy[t]}return c},set(r,t,s){var e;if(r.type===3||r.type===2)throw new Error("Map/Set draft does not support any property assignment.");let i;if(r.type===1&&t!=="length"&&!(Number.isInteger(i=Number(t))&&i>=0&&(t===0||i===0||String(i)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");const a=ns(Y(r),t);if(a!=null&&a.set)return a.set.call(r.proxy,s),!0;const n=Tt(Y(r),t),o=L(n);return o&&we(o.original,s)?(r.copy[t]=s,r.assignedMap=(e=r.assignedMap)!==null&&e!==void 0?e:new Map,r.assignedMap.set(t,!1),!0):(we(s,n)&&(s!==void 0||Be(r.original,t))||(K(r),re(r),Be(r.original,t)&&we(s,r.original[t])?r.assignedMap.delete(t):r.assignedMap.set(t,!0),r.copy[t]=s,It(r,t,s,Re)),!0)},has(r,t){return t in Y(r)},ownKeys(r){return Reflect.ownKeys(Y(r))},getOwnPropertyDescriptor(r,t){const s=Y(r),e=Reflect.getOwnPropertyDescriptor(s,t);return e&&{writable:!0,configurable:r.type!==1||t!=="length",enumerable:e.enumerable,value:s[t]}},getPrototypeOf(r){return Reflect.getPrototypeOf(r.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(r,t){var s;return r.type===1?fs.set.call(this,r,t,void 0,r.proxy):(Tt(r.original,t)!==void 0||t in r.original?(K(r),re(r),r.assignedMap.set(t,!1)):(r.assignedMap=(s=r.assignedMap)!==null&&s!==void 0?s:new Map,r.assignedMap.delete(t)),r.copy&&delete r.copy[t],!0)}};function ds(r){const{original:t,parentDraft:s,key:e,finalities:i,options:a}=r,n=je(t),o={type:n,finalized:!1,parent:s,original:t,copy:null,proxy:null,finalities:i,options:a,setMap:n===3?new Map(t.entries()):void 0};(e||"key"in r)&&(o.key=e);const{proxy:c,revoke:h}=Proxy.revocable(n===1?Object.assign([],o):o,fs);if(i.revoke.push(h),ps.add(c),o.proxy=c,s){const l=s;l.finalities.draft.push((u,d)=>{var f,x;const S=L(c);let R=l.type===3?l.setMap:l.copy;const C=le(R,e),D=L(C);if(D){let $=D.original;D.operated&&($=gt(C)),At(D),St(D,Re,u,d),l.options.enableAutoFreeze&&(l.options.updatedValues=(f=l.options.updatedValues)!==null&&f!==void 0?f:new WeakMap,l.options.updatedValues.set($,D.original)),wt(R,e,$)}(x=S.callbacks)===null||x===void 0||x.forEach($=>{$(u,d)})})}else{const l=L(c);l.finalities.draft.push((u,d)=>{At(l),St(l,Re,u,d)})}return c}Pt.createDraft=ds,Object.prototype.constructor.toString();const z=[];for(let r=0;r<256;++r)z.push((r+256).toString(16).slice(1));function Bi(r,t=0){return(z[r[t+0]]+z[r[t+1]]+z[r[t+2]]+z[r[t+3]]+"-"+z[r[t+4]]+z[r[t+5]]+"-"+z[r[t+6]]+z[r[t+7]]+"-"+z[r[t+8]]+z[r[t+9]]+"-"+z[r[t+10]]+z[r[t+11]]+z[r[t+12]]+z[r[t+13]]+z[r[t+14]]+z[r[t+15]]).toLowerCase()}let Ct;const ji=new Uint8Array(16);function _i(){if(!Ct){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ct=crypto.getRandomValues.bind(crypto)}return Ct(ji)}const ms={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ri(r,t,s){var i;if(ms.randomUUID&&!r)return ms.randomUUID();r=r||{};const e=r.random??((i=r.rng)==null?void 0:i.call(r))??_i();if(e.length<16)throw new Error("Random bytes length must be >= 16");return e[6]=e[6]&15|64,e[8]=e[8]&63|128,Bi(e)}function ys(){return Ri()}function $i(r,t){return r.localeCompare(t)}function Ui(){let r=$i;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{r=Intl.Collator("en-US").compare}catch{}return r}Ui();function qi(){const t={__etype:1,__ops:1,create:1,update:1,link:1,unlink:1,delete:1,merge:1,ruleParams:1};return new Set(Object.keys(t))}const zi=qi();function Nt(r,t,s){const e={__etype:r,__ops:s};return new Proxy(e,{get:(i,a)=>{if(a==="__ops")return s;if(a==="__etype")return r;if(zi.has(a))return(n,o)=>Nt(r,t,[...s,o?[a,r,t,n,o]:[a,r,t,n]])}})}function Vi(r){return r.startsWith("lookup__")}function Hi(r){const[t,s,...e]=r.split("__");return[s,JSON.parse(e.join("__"))]}function Ki(r){return new Proxy({__etype:r},{get(t,s){if(s==="__etype")return r;const e=s;return Vi(e)?Nt(r,Hi(e),[]):Nt(r,e,[])}})}function Ji(){return new Proxy({},{get(r,t){return Ki(t)}})}Ji(),Object.assign(Object.assign({},{"unique?":!0,"index?":!0}),{cardinality:"one"});class kt extends Error{constructor(t,s){super(t),this.hint=s;const e=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,kt),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class $e extends kt{constructor(t){var s;const e=((s=t.body)===null||s===void 0?void 0:s.message)||`API Error (${t.status})`;super(e,t.body.hint);const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,$e),this.name="InstantAPIError",this.status=t.status,this.body=t.body}get[Symbol.toStringTag](){return"InstantAPIError"}}typeof window<"u"&&typeof window.localStorage<"u"&&(window.localStorage.getItem("devBackend"),window.localStorage.getItem("__instantLogging"),window.localStorage.getItem("__devtoolLocalDash"));const Ue="v0.22.95-experimental.surgical.20386947966.1";class te{constructor(t,s,e,i={indexed:!1,unique:!1}){this.valueType=t,this.required=s,this.isIndexed=e,this.config=i,this.metadata={}}clientRequired(){return new te(this.valueType,!1,this.isIndexed,this.config)}optional(){return new te(this.valueType,!1,this.isIndexed,this.config)}unique(){return new te(this.valueType,this.required,this.isIndexed,Object.assign(Object.assign({},this.config),{unique:!0}))}indexed(){return new te(this.valueType,this.required,!0,Object.assign(Object.assign({},this.config),{indexed:!0}))}}class Ze{constructor(t,s){this.attrs=t,this.links=s}asType(){return new Ze(this.attrs,this.links)}}class et{constructor(t,s,e){this.entities=t,this.links=s,this.rooms=e}withRoomSchema(){return new et(this.entities,this.links,{})}}var xs;(function(r){r.InitialSyncBatch="InitialSyncBatch",r.InitialSyncComplete="InitialSyncComplete",r.LoadFromStorage="LoadFromStorage",r.SyncTransaction="SyncTransaction",r.Error="Error"})(xs||(xs={}));function Wi(r,t){return new et(Ps(r,t),t,void 0)}function Xi(r){return new Ze(r,{})}function Gi(){return new te("string",!0,!1)}function Yi(){return new te("number",!0,!1)}function Qi(){return new te("boolean",!0,!1)}function Zi(){return new te("date",!0,!1)}function er(){return new te("json",!0,!1)}function tr(){return new te("json",!0,!1)}function Ps(r,t){var s,e,i,a;const n={fwd:{},rev:{}};for(const c of Object.values(t))(s=n.fwd)[e=c.forward.on]||(s[e]={}),(i=n.rev)[a=c.reverse.on]||(i[a]={}),n.fwd[c.forward.on][c.forward.label]={entityName:c.reverse.on,cardinality:c.forward.has},n.rev[c.reverse.on][c.reverse.label]={entityName:c.forward.on,cardinality:c.reverse.has};return Object.fromEntries(Object.entries(r).map(([c,h])=>[c,new Ze(h.attrs,Object.assign(Object.assign({},n.fwd[c]),n.rev[c]))]))}function sr({entities:r,links:t,rooms:s}){const e=t??{},i=s??{};return new et(Ps(r,e),e,i)}const V={graph:Wi,schema:sr,entity:Xi,string:Gi,number:Yi,boolean:Qi,date:Zi,json:er,any:tr};function ir(){var r;return globalThis.__instantDbSchemaHashStore=(r=globalThis.__instantDbSchemaHashStore)!==null&&r!==void 0?r:new WeakMap,globalThis.__instantDbSchemaHashStore}function rr(){var r;return globalThis.__instantDbStore=(r=globalThis.__instantDbStore)!==null&&r!==void 0?r:{},globalThis.__instantDbStore}rr(),ir();function ar(){const r="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._~";let t="";for(const s of crypto.getRandomValues(new Uint8Array(64)))t=t+r[s%r.length];return t}function nr(r){return crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(r))}function or(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function cr(r){return nr(r).then(t=>or(btoa(String.fromCharCode(...Array.from(new Uint8Array(t))))))}function hr(){const r=Math.min(800,Math.floor(window.outerWidth*.8)),t=Math.min(630,Math.floor(window.outerHeight*.5)),s={width:r,height:t,left:Math.round(window.screenX+(window.outerWidth-r)/2),top:Math.round(window.screenY+(window.outerHeight-t)/8)},e={width:s.width,height:s.height,left:s.left,top:s.top,toolbar:0,scrollbars:1,status:1,resizable:1,menuBar:0,rel:"opener"};return Object.keys(e).map(i=>`${i}=${e[i]}`).join(",")}let bs=null;function lr({clientId:r,state:t,codeChallenge:s,apiURI:e,redirectUri:i,scopes:a}){const n=new URL(`${e}/platform/oauth/start`);return n.searchParams.set("client_id",r),n.searchParams.set("redirect_uri",i),n.searchParams.set("scope",a.join(" ")),n.searchParams.set("state",t),n.searchParams.set("response_type","code"),n.searchParams.set("code_challenge",s),n.searchParams.set("code_challenge_method","S256"),n.toString()}async function ur({code:r,clientId:t,verifier:s,apiURI:e,redirectUri:i}){const a=await fetch(`${e}/platform/oauth/token`,{method:"POST",headers:{"Content-type":"application/json","Instant-Platform-Version":Ue,"Instant-Core-Version":Ue},body:JSON.stringify({grant_type:"authorization_code",code:r,redirect_uri:i,client_id:t,code_verifier:s})});if(!a.ok){const o=await a.text();let c;try{const h=JSON.parse(o);c={error:h.error,errorDescription:h.error_description,message:`OAuth error: ${h.error||"server_error"}`}}catch{c={error:"server_error",message:"OAuth error: server_error"}}throw new v(c)}const n=await a.json();return{token:n.access_token,expiresAt:new Date(Date.now()+(n.expires_in-30)*1e3)}}function pr(){if(typeof window>"u")throw new Error("This function may only be used in a browser context.");const r=new URL(window.location.href).searchParams,t=r.get("state"),s=r.get("error"),e=r.get("error_description"),i=r.get("code");if(!t)throw new Error("Invalid redirect. The state param is missing.");const a=new BroadcastChannel(t);return a.addEventListener("message",n=>{n.data.type==="oauth-redirect-window-done"&&window.close()}),a.postMessage({type:"oauth-redirect",state:t,error:s,errorDescription:e,code:i}),()=>{a.close()}}function fr({clientId:r,apiURI:t,redirectUri:s,scopes:e}){if(typeof window>"u")throw new Error("OAuth flow can only be started on the client.");const i=bs;i&&i.close();const a=crypto.randomUUID(),n=ar(),o=new BroadcastChannel(a),c=new Promise((l,u)=>{o.addEventListener("message",async d=>{if(d.data.type!=="oauth-redirect")return;const{state:f,error:x,code:S,errorDescription:R}=d.data;if(!(!f||f!==a)){if(S)try{const C=await ur({clientId:r,code:S,verifier:n,apiURI:t,redirectUri:s});l(C)}catch(C){C instanceof v&&u(C),u(new v({error:"server_error",message:"OAuth error exchanging code for token"}))}else u(typeof x=="string"?new v({error:x,errorDescription:R,message:`OAuth error: ${x}`}):new v({error:"server_error",message:"OAuth error: server_error"}));o.postMessage({type:"oauth-redirect-window-done"})}})}),h=window.open("",`instantdb_oauth_${Math.random()}`.replace(".",""),hr());return h?(bs=h,cr(n).then(l=>{const u=lr({clientId:r,state:a,codeChallenge:l,apiURI:t,redirectUri:s,scopes:e});h.location.href=u}),c.finally(()=>o.close())):Promise.reject({error:"Could not open Auth window"})}class dr{constructor(t){this.redirectUri=t.redirectUri,this.apiURI=t.apiURI??"https://api.instantdb.com",this.clientId=t.clientId}startClientOnlyFlow(t){return fr({clientId:this.clientId,apiURI:this.apiURI,redirectUri:this.redirectUri,scopes:t})}handleClientRedirect(){return pr()}}function mr(r,t){const s=r&&Object.keys(r).length?JSON.stringify(r,null,2):`{
|
|
2
2
|
/**
|
|
3
3
|
* Welcome to Instant's permission system!
|
|
4
4
|
* Right now your rules are empty. To start filling them in, check out the docs:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instantdb/platform",
|
|
3
|
-
"version": "0.22.95-experimental.surgical.
|
|
3
|
+
"version": "0.22.95-experimental.surgical.20386947966.1",
|
|
4
4
|
"description": "Instant's platform package for managing Instant apps.",
|
|
5
5
|
"homepage": "https://github.com/instantdb/instant/tree/main/client/packages/platform",
|
|
6
6
|
"repository": {
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/parser": "^8.0.0-beta.0",
|
|
56
56
|
"@babel/types": "^8.0.0-beta.0",
|
|
57
|
-
"@instantdb/core": "0.22.95-experimental.surgical.
|
|
58
|
-
"@instantdb/version": "0.22.95-experimental.surgical.
|
|
57
|
+
"@instantdb/core": "0.22.95-experimental.surgical.20386947966.1",
|
|
58
|
+
"@instantdb/version": "0.22.95-experimental.surgical.20386947966.1"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"test": "vitest",
|