@instantdb/platform 0.22.117-experimental.drewh-cia-errors.21490640196.1 → 0.22.117
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.117
|
|
2
|
+
> @instantdb/platform@0.22.117 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.117
|
|
8
|
+
> @instantdb/platform@0.22.117 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.117
|
|
14
|
+
> @instantdb/platform@0.22.117 build:standalone
|
|
15
15
|
> vite build
|
|
16
16
|
|
|
17
17
|
[36mvite v5.4.14 [32mbuilding for production...[36m[39m
|
|
@@ -19,17 +19,17 @@ transforming...
|
|
|
19
19
|
[32m✓[39m 78 modules transformed.
|
|
20
20
|
rendering chunks...
|
|
21
21
|
computing gzip size...
|
|
22
|
-
[2mdist/standalone/[22m[36mindex.umd.cjs [39m[1m[2m350.
|
|
23
|
-
[2mdist/standalone/[22m[36mindex.js [39m[1m[2m457.
|
|
24
|
-
[32m✓ built in 2.
|
|
22
|
+
[2mdist/standalone/[22m[36mindex.umd.cjs [39m[1m[2m350.92 kB[22m[1m[22m[2m │ gzip: 95.30 kB[22m
|
|
23
|
+
[2mdist/standalone/[22m[36mindex.js [39m[1m[2m457.63 kB[22m[1m[22m[2m │ gzip: 107.29 kB[22m
|
|
24
|
+
[32m✓ built in 2.49s[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.117
|
|
28
|
+
> @instantdb/platform@0.22.117 check-exports
|
|
29
29
|
> attw --pack .
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
@instantdb/platform v0.22.117
|
|
32
|
+
@instantdb/platform v0.22.117
|
|
33
33
|
|
|
34
34
|
Build tools:
|
|
35
35
|
- @arethetypeswrong/cli@^0.17.4
|
package/dist/standalone/index.js
CHANGED
|
@@ -838,7 +838,7 @@ class $e extends Ut {
|
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
840
|
typeof window < "u" && typeof window.localStorage < "u" && (window.localStorage.getItem("devBackend"), window.localStorage.getItem("__instantLogging"), window.localStorage.getItem("__devtoolLocalDash"));
|
|
841
|
-
const je = "v0.22.117
|
|
841
|
+
const je = "v0.22.117";
|
|
842
842
|
class Q {
|
|
843
843
|
constructor(t, s, e, i = { indexed: !1, unique: !1 }) {
|
|
844
844
|
m(this, "valueType");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(S,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(S=typeof globalThis<"u"?globalThis:S||self,v(S.instant={}))})(this,function(S){"use strict";var Rn=Object.defineProperty;var xi=S=>{throw TypeError(S)};var jn=(S,v,N)=>v in S?Rn(S,v,{enumerable:!0,configurable:!0,writable:!0,value:N}):S[v]=N;var m=(S,v,N)=>jn(S,typeof v!="symbol"?v+"":v,N),Pi=(S,v,N)=>v.has(S)||xi("Cannot "+N);var w=(S,v,N)=>(Pi(S,v,"read from private field"),N?N.call(S):v.get(S)),xe=(S,v,N)=>v.has(S)?xi("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(S):v.set(S,N),Pe=(S,v,N,Le)=>(Pi(S,v,"write to private field"),Le?Le.call(S,N):v.set(S,N),N);var se,Y,dt,mt,yt,F,j;class v extends Error{constructor(s){super(s.message);m(this,"error");m(this,"errorDescription");const e=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,v),this.name="InstantOAuthError",this.error=s.error,this.errorDescription=s.errorDescription}get[Symbol.toStringTag](){return"InstantAPIError"}}const N={Remove:"remove",Replace:"replace",Add:"add"},Le=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),We=Symbol.iterator,Z={mutable:"mutable",immutable:"immutable"},Pt={};function Me(r,t){return r instanceof Map?r.has(t):Object.prototype.hasOwnProperty.call(r,t)}function as(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 ns(r){return Object.getPrototypeOf(r)===Set.prototype}function os(r){return Object.getPrototypeOf(r)===Map.prototype}function G(r){var t;return(t=r.copy)!==null&&t!==void 0?t:r.original}function gt(r){return!!L(r)}function L(r){return typeof r!="object"?null:r==null?void 0:r[Le]}function bt(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,Z))===Z.immutable||typeof s=="function")}function cs(r,t=[]){if(Object.hasOwnProperty.call(r,"key")){const s=r.parent.copy,e=L(he(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||Me(s,a)))return null;t.push(a)}if(r.parent)return cs(r.parent,t);t.reverse();try{gi(r.copy,t)}catch{return null}return t}function Fe(r){return Array.isArray(r)?1:r instanceof Map?2:r instanceof Set?3:0}function he(r,t){return Fe(r)===2?r.get(t):r[t]}function Tt(r,t,s){Fe(r)===2?r.set(t,s):r[t]=s}function wt(r,t){const s=L(r);return(s?G(s):r)[t]}function be(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 gi(r,t){for(let s=0;s<t.length-1;s+=1){const e=t[s];if(r=he(Fe(r)===3?Array.from(r):r,e),typeof r!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return r}function bi(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 Ti=Object.prototype.propertyIsEnumerable;function wi(r,t){let s;if(Array.isArray(r))return Array.prototype.concat.call(r);if(r instanceof Set){if(!ns(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(!os(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,Z),s!==void 0)&&s!==Z.mutable){if(s===Z.immutable)return bi(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=>{Ti.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 H(r){r.copy||(r.copy=wi(r.original,r.options))}function Be(r){if(!ge(r))return bt(r);if(Array.isArray(r))return r.map(Be);if(r instanceof Map){const s=Array.from(r.entries()).map(([e,i])=>[e,Be(i)]);if(!os(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(Be);if(!ns(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]=Be(r[s]);return t}function Xe(r){return gt(r)?Be(r):r}function ie(r){var t;r.assignedMap=(t=r.assignedMap)!==null&&t!==void 0?t:new Map,r.operated||(r.operated=!0,r.parent&&ie(r.parent))}function Ai(r,t){const s=Fe(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 hs(r,t,s){if(gt(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),Ai(r,(a,n)=>{var o;if(gt(n)){const c=L(n);H(c);const h=!((o=c.assignedMap)===null||o===void 0)&&o.size||c.operated?c.copy:c.original;Tt(e?i:r,a,h)}else hs(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 Si(r,t){const s=r.type===3?r.setMap:r.copy;r.finalities.revoke.length>1&&r.assignedMap.get(t)&&s&&hs(he(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(bt(t))}))}function St(r,t,s,e){if(r.operated&&r.assignedMap&&r.assignedMap.size>0&&!r.finalized){if(s&&e){const a=cs(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(be(he(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)),Tt(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;be(he(a,t),s)&&Si(r,t)})}function Ii(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]),p=Te(l,i);s.push({op:N.Replace,path:p,value:Xe(c[h])}),e.push({op:N.Replace,path:p,value:Xe(a[h])})}for(let h=a.length;h<c.length;h+=1){const l=t.concat([h]),p=Te(l,i);s.push({op:N.Add,path:p,value:Xe(c[h])})}if(a.length<c.length){const{arrayLengthAssignment:h=!0}=o.enablePatches;if(h){const l=t.concat(["length"]),p=Te(l,i);e.push({op:N.Replace,path:p,value:a.length})}else for(let l=c.length;a.length<l;l-=1){const p=t.concat([l-1]),d=Te(p,i);e.push({op:N.Remove,path:d})}}}function Ei({original:r,copy:t,assignedMap:s},e,i,a,n){s.forEach((o,c)=>{const h=he(r,c),l=Xe(he(t,c)),p=o?Me(r,c)?N.Replace:N.Add:N.Remove;if(be(h,l)&&p===N.Replace)return;const d=e.concat(c),f=Te(d,n);i.push(p===N.Remove?{op:p,path:f}:{op:p,path:f,value:l}),a.push(p===N.Add?{op:N.Remove,path:f}:p===N.Remove?{op:N.Add,path:f,value:h}:{op:N.Replace,path:f,value:h})})}function Ci({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 Ei(r,t,s,e,i);case 1:return Ii(r,t,s,e,i);case 3:return Ci(r,t,s,e,i)}}const Ge=(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 G(L(this)).size},has(r){return G(L(this)).has(r)},set(r,t){const s=L(this),e=G(s);return(!e.has(r)||!be(e.get(r),t))&&(H(s),ie(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 H(t),ie(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){H(r),ie(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);G(s).forEach((e,i)=>{r.call(t,this.get(i),i,this)})},get(r){var t,s;const e=L(this),i=G(e).get(r),a=((s=(t=e.options).mark)===null||s===void 0?void 0:s.call(t,i,Z))===Z.mutable;if(e.options.strict&&Ge(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 H(e),e.copy.set(r,n),n},keys(){return G(L(this)).keys()},values(){const r=this.keys();return{[We]:()=>this.values(),next:()=>{const t=r.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const r=this.keys();return{[We]:()=>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]}}}},[We](){return this.entries()}},Ni=Reflect.ownKeys(Et),ls=(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,Z))===Z.mutable;if(r.options.strict&&Ge(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]}},Ye={get size(){return L(this).setMap.size},has(r){const t=L(this);if(t.setMap.has(r))return!0;H(t);const s=L(r);return!!(s&&t.setMap.has(s.original))},add(r){const t=L(this);return this.has(r)||(H(t),ie(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);H(t),ie(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);H(r),ie(r);for(const t of r.original)r.assignedMap.set(t,!1);r.setMap.clear()},values(){const r=L(this);H(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:ls(r,t,{isValuesIterator:!0})}},entries(){const r=L(this);H(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:ls(r,t,{isValuesIterator:!1})}},keys(){return this.values()},[We](){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(Ye,{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 ki=Reflect.ownKeys(Ye),us=new WeakSet,ps={get(r,t,s){var e,i;const a=(e=r.copy)===null||e===void 0?void 0:e[t];if(a&&us.has(a))return a;if(t===Le)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,Z),n===Z.mutable)return r.options.strict&&Ge(h,r.options,!0),h}const o=G(r);if(o instanceof Map&&Ni.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&&ki.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Ye,"size").get.call(r.proxy);const h=Ye[t];if(h)return h.bind(r.proxy)}if(!Me(o,t)){const h=as(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&&Ge(c,r.options),r.finalized||!ge(c,r.options))return c;if(c===wt(r.original,t)){if(H(r),r.copy[t]=fs({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 H(h),ie(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=as(G(r),t);if(a!=null&&a.set)return a.set.call(r.proxy,s),!0;const n=wt(G(r),t),o=L(n);return o&&be(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):(be(s,n)&&(s!==void 0||Me(r.original,t))||(H(r),ie(r),Me(r.original,t)&&be(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 G(r)},ownKeys(r){return Reflect.ownKeys(G(r))},getOwnPropertyDescriptor(r,t){const s=G(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?ps.set.call(this,r,t,void 0,r.proxy):(wt(r.original,t)!==void 0||t in r.original?(H(r),ie(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 fs(r){const{original:t,parentDraft:s,key:e,finalities:i,options:a}=r,n=Fe(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,ps);if(i.revoke.push(h),us.add(c),o.proxy=c,s){const l=s;l.finalities.draft.push((p,d)=>{var f,x;const A=L(c);let _=l.type===3?l.setMap:l.copy;const C=he(_,e),O=L(C);if(O){let U=O.original;O.operated&&(U=bt(C)),At(O),St(O,Re,p,d),l.options.enableAutoFreeze&&(l.options.updatedValues=(f=l.options.updatedValues)!==null&&f!==void 0?f:new WeakMap,l.options.updatedValues.set(U,O.original)),Tt(_,e,U)}(x=A.callbacks)===null||x===void 0||x.forEach(U=>{U(p,d)})})}else{const l=L(c);l.finalities.draft.push((p,d)=>{At(l),St(l,Re,p,d)})}return c}Pt.createDraft=fs,Object.prototype.constructor.toString();const z=[];for(let r=0;r<256;++r)z.push((r+256).toString(16).slice(1));function vi(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 Di=new Uint8Array(16);function Oi(){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(Di)}const ds={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Li(r,t,s){var i;if(ds.randomUUID&&!r)return ds.randomUUID();r=r||{};const e=r.random??((i=r.rng)==null?void 0:i.call(r))??Oi();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,vi(e)}function ms(){return Li()}function Mi(r,t){return r.localeCompare(t)}function Fi(){let r=Mi;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{r=Intl.Collator("en-US").compare}catch{}return r}Fi();function Bi(){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 Ri=Bi();function Qe(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(Ri.has(a))return(n,o)=>Qe(r,t,[...s,o?[a,r,t,n,o]:[a,r,t,n]])}})}function ji(r,t){return`lookup__${r}__${JSON.stringify(t)}`}function _i(r){return r.startsWith("lookup__")}function ys(r){const[t,s,...e]=r.split("__");return[s,JSON.parse(e.join("__"))]}function Ui(r){return new Proxy({__etype:r},{get(t,s){if(s==="lookup")return(i,a)=>Qe(r,ys(ji(i,a)),[]);if(s==="__etype")return r;const e=s;return _i(e)?Qe(r,ys(e),[]):Qe(r,e,[])}})}function $i(){return new Proxy({},{get(r,t){return Ui(t)}})}$i();class Nt extends Error{constructor(s,e){super(s);m(this,"hint");this.hint=e;const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,Nt),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class je extends Nt{constructor(s){var a;const e=((a=s.body)==null?void 0:a.message)||`API Error (${s.status})`;super(e,s.body.hint);m(this,"body");m(this,"status");const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,je),this.name="InstantAPIError",this.status=s.status,this.body=s.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 Ee="v0.22.117-experimental.drewh-cia-errors.21490640196.1";class ee{constructor(t,s,e,i={indexed:!1,unique:!1}){m(this,"valueType");m(this,"required");m(this,"isIndexed");m(this,"config");m(this,"metadata",{});this.valueType=t,this.required=s,this.isIndexed=e,this.config=i}clientRequired(){return new ee(this.valueType,!1,this.isIndexed,this.config)}optional(){return new ee(this.valueType,!1,this.isIndexed,this.config)}unique(){return new ee(this.valueType,this.required,this.isIndexed,{...this.config,unique:!0})}indexed(){return new ee(this.valueType,this.required,!0,{...this.config,indexed:!0})}}class Ze{constructor(t,s){m(this,"attrs");m(this,"links");this.attrs=t,this.links=s}asType(){return new Ze(this.attrs,this.links)}}class et{constructor(t,s,e){m(this,"entities");m(this,"links");m(this,"rooms");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 qi(r,t){return new et(Ps(r,t),t,void 0)}function zi(r){return new Ze(r,{})}function Vi(){return new ee("string",!0,!1)}function Hi(){return new ee("number",!0,!1)}function Ki(){return new ee("boolean",!0,!1)}function Ji(){return new ee("date",!0,!1)}function Wi(){return new ee("json",!0,!1)}function Xi(){return new ee("json",!0,!1)}function Ps(r,t){var i,a,n,o;const s={fwd:{},rev:{}};for(const c of Object.values(t))(i=s.fwd)[a=c.forward.on]||(i[a]={}),(n=s.rev)[o=c.reverse.on]||(n[o]={}),s.fwd[c.forward.on][c.forward.label]={entityName:c.reverse.on,cardinality:c.forward.has},s.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,{...s.fwd[c],...s.rev[c]})]))}function Gi({entities:r,links:t,rooms:s}){const e=t??{},i=s??{};return new et(Ps(r,e),e,i)}const V={graph:qi,schema:Gi,entity:zi,string:Vi,number:Hi,boolean:Ki,date:Ji,json:Wi,any:Xi};function Yi(){return globalThis.__instantDbSchemaHashStore=globalThis.__instantDbSchemaHashStore??new WeakMap,globalThis.__instantDbSchemaHashStore}function Qi(){return globalThis.__instantDbStore=globalThis.__instantDbStore??{},globalThis.__instantDbStore}Qi(),Yi();function Zi(){const r="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._~";let t="";for(const s of crypto.getRandomValues(new Uint8Array(64)))t=t+r[s%r.length];return t}function er(r){return crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(r))}function tr(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function sr(r){return er(r).then(t=>tr(btoa(String.fromCharCode(...Array.from(new Uint8Array(t))))))}function ir(){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 gs=null;function rr({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 ar({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":Ee,"Instant-Core-Version":Ee},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 nr(){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 or({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=gs;i&&i.close();const a=crypto.randomUUID(),n=Zi(),o=new BroadcastChannel(a),c=new Promise((l,p)=>{o.addEventListener("message",async d=>{if(d.data.type!=="oauth-redirect")return;const{state:f,error:x,code:A,errorDescription:_}=d.data;if(!(!f||f!==a)){if(A)try{const C=await ar({clientId:r,code:A,verifier:n,apiURI:t,redirectUri:s});l(C)}catch(C){C instanceof v&&p(C),p(new v({error:"server_error",message:"OAuth error exchanging code for token"}))}else p(typeof x=="string"?new v({error:x,errorDescription:_,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(".",""),ir());return h?(gs=h,sr(n).then(l=>{const p=rr({clientId:r,state:a,codeChallenge:l,apiURI:t,redirectUri:s,scopes:e});h.location.href=p}),c.finally(()=>o.close())):Promise.reject({error:"Could not open Auth window"})}class cr{constructor(t){m(this,"redirectUri");m(this,"clientId");m(this,"apiURI");this.redirectUri=t.redirectUri,this.apiURI=t.apiURI??"https://api.instantdb.com",this.clientId=t.clientId}startClientOnlyFlow(t){return or({clientId:this.clientId,apiURI:this.apiURI,redirectUri:this.redirectUri,scopes:t})}handleClientRedirect(){return nr()}}function hr(r,t){const s=r&&Object.keys(r).length?JSON.stringify(r,null,2):`{
|
|
1
|
+
(function(S,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(S=typeof globalThis<"u"?globalThis:S||self,v(S.instant={}))})(this,function(S){"use strict";var Rn=Object.defineProperty;var xi=S=>{throw TypeError(S)};var jn=(S,v,N)=>v in S?Rn(S,v,{enumerable:!0,configurable:!0,writable:!0,value:N}):S[v]=N;var m=(S,v,N)=>jn(S,typeof v!="symbol"?v+"":v,N),Pi=(S,v,N)=>v.has(S)||xi("Cannot "+N);var w=(S,v,N)=>(Pi(S,v,"read from private field"),N?N.call(S):v.get(S)),xe=(S,v,N)=>v.has(S)?xi("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(S):v.set(S,N),Pe=(S,v,N,Le)=>(Pi(S,v,"write to private field"),Le?Le.call(S,N):v.set(S,N),N);var se,Y,dt,mt,yt,F,j;class v extends Error{constructor(s){super(s.message);m(this,"error");m(this,"errorDescription");const e=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,v),this.name="InstantOAuthError",this.error=s.error,this.errorDescription=s.errorDescription}get[Symbol.toStringTag](){return"InstantAPIError"}}const N={Remove:"remove",Replace:"replace",Add:"add"},Le=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),We=Symbol.iterator,Z={mutable:"mutable",immutable:"immutable"},Pt={};function Me(r,t){return r instanceof Map?r.has(t):Object.prototype.hasOwnProperty.call(r,t)}function as(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 ns(r){return Object.getPrototypeOf(r)===Set.prototype}function os(r){return Object.getPrototypeOf(r)===Map.prototype}function G(r){var t;return(t=r.copy)!==null&&t!==void 0?t:r.original}function gt(r){return!!L(r)}function L(r){return typeof r!="object"?null:r==null?void 0:r[Le]}function bt(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,Z))===Z.immutable||typeof s=="function")}function cs(r,t=[]){if(Object.hasOwnProperty.call(r,"key")){const s=r.parent.copy,e=L(he(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||Me(s,a)))return null;t.push(a)}if(r.parent)return cs(r.parent,t);t.reverse();try{gi(r.copy,t)}catch{return null}return t}function Fe(r){return Array.isArray(r)?1:r instanceof Map?2:r instanceof Set?3:0}function he(r,t){return Fe(r)===2?r.get(t):r[t]}function Tt(r,t,s){Fe(r)===2?r.set(t,s):r[t]=s}function wt(r,t){const s=L(r);return(s?G(s):r)[t]}function be(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 gi(r,t){for(let s=0;s<t.length-1;s+=1){const e=t[s];if(r=he(Fe(r)===3?Array.from(r):r,e),typeof r!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return r}function bi(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 Ti=Object.prototype.propertyIsEnumerable;function wi(r,t){let s;if(Array.isArray(r))return Array.prototype.concat.call(r);if(r instanceof Set){if(!ns(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(!os(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,Z),s!==void 0)&&s!==Z.mutable){if(s===Z.immutable)return bi(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=>{Ti.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 H(r){r.copy||(r.copy=wi(r.original,r.options))}function Be(r){if(!ge(r))return bt(r);if(Array.isArray(r))return r.map(Be);if(r instanceof Map){const s=Array.from(r.entries()).map(([e,i])=>[e,Be(i)]);if(!os(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(Be);if(!ns(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]=Be(r[s]);return t}function Xe(r){return gt(r)?Be(r):r}function ie(r){var t;r.assignedMap=(t=r.assignedMap)!==null&&t!==void 0?t:new Map,r.operated||(r.operated=!0,r.parent&&ie(r.parent))}function Ai(r,t){const s=Fe(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 hs(r,t,s){if(gt(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),Ai(r,(a,n)=>{var o;if(gt(n)){const c=L(n);H(c);const h=!((o=c.assignedMap)===null||o===void 0)&&o.size||c.operated?c.copy:c.original;Tt(e?i:r,a,h)}else hs(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 Si(r,t){const s=r.type===3?r.setMap:r.copy;r.finalities.revoke.length>1&&r.assignedMap.get(t)&&s&&hs(he(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(bt(t))}))}function St(r,t,s,e){if(r.operated&&r.assignedMap&&r.assignedMap.size>0&&!r.finalized){if(s&&e){const a=cs(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(be(he(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)),Tt(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;be(he(a,t),s)&&Si(r,t)})}function Ii(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]),p=Te(l,i);s.push({op:N.Replace,path:p,value:Xe(c[h])}),e.push({op:N.Replace,path:p,value:Xe(a[h])})}for(let h=a.length;h<c.length;h+=1){const l=t.concat([h]),p=Te(l,i);s.push({op:N.Add,path:p,value:Xe(c[h])})}if(a.length<c.length){const{arrayLengthAssignment:h=!0}=o.enablePatches;if(h){const l=t.concat(["length"]),p=Te(l,i);e.push({op:N.Replace,path:p,value:a.length})}else for(let l=c.length;a.length<l;l-=1){const p=t.concat([l-1]),d=Te(p,i);e.push({op:N.Remove,path:d})}}}function Ei({original:r,copy:t,assignedMap:s},e,i,a,n){s.forEach((o,c)=>{const h=he(r,c),l=Xe(he(t,c)),p=o?Me(r,c)?N.Replace:N.Add:N.Remove;if(be(h,l)&&p===N.Replace)return;const d=e.concat(c),f=Te(d,n);i.push(p===N.Remove?{op:p,path:f}:{op:p,path:f,value:l}),a.push(p===N.Add?{op:N.Remove,path:f}:p===N.Remove?{op:N.Add,path:f,value:h}:{op:N.Replace,path:f,value:h})})}function Ci({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 Ei(r,t,s,e,i);case 1:return Ii(r,t,s,e,i);case 3:return Ci(r,t,s,e,i)}}const Ge=(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 G(L(this)).size},has(r){return G(L(this)).has(r)},set(r,t){const s=L(this),e=G(s);return(!e.has(r)||!be(e.get(r),t))&&(H(s),ie(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 H(t),ie(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){H(r),ie(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);G(s).forEach((e,i)=>{r.call(t,this.get(i),i,this)})},get(r){var t,s;const e=L(this),i=G(e).get(r),a=((s=(t=e.options).mark)===null||s===void 0?void 0:s.call(t,i,Z))===Z.mutable;if(e.options.strict&&Ge(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 H(e),e.copy.set(r,n),n},keys(){return G(L(this)).keys()},values(){const r=this.keys();return{[We]:()=>this.values(),next:()=>{const t=r.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const r=this.keys();return{[We]:()=>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]}}}},[We](){return this.entries()}},Ni=Reflect.ownKeys(Et),ls=(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,Z))===Z.mutable;if(r.options.strict&&Ge(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]}},Ye={get size(){return L(this).setMap.size},has(r){const t=L(this);if(t.setMap.has(r))return!0;H(t);const s=L(r);return!!(s&&t.setMap.has(s.original))},add(r){const t=L(this);return this.has(r)||(H(t),ie(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);H(t),ie(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);H(r),ie(r);for(const t of r.original)r.assignedMap.set(t,!1);r.setMap.clear()},values(){const r=L(this);H(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:ls(r,t,{isValuesIterator:!0})}},entries(){const r=L(this);H(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:ls(r,t,{isValuesIterator:!1})}},keys(){return this.values()},[We](){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(Ye,{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 ki=Reflect.ownKeys(Ye),us=new WeakSet,ps={get(r,t,s){var e,i;const a=(e=r.copy)===null||e===void 0?void 0:e[t];if(a&&us.has(a))return a;if(t===Le)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,Z),n===Z.mutable)return r.options.strict&&Ge(h,r.options,!0),h}const o=G(r);if(o instanceof Map&&Ni.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&&ki.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Ye,"size").get.call(r.proxy);const h=Ye[t];if(h)return h.bind(r.proxy)}if(!Me(o,t)){const h=as(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&&Ge(c,r.options),r.finalized||!ge(c,r.options))return c;if(c===wt(r.original,t)){if(H(r),r.copy[t]=fs({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 H(h),ie(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=as(G(r),t);if(a!=null&&a.set)return a.set.call(r.proxy,s),!0;const n=wt(G(r),t),o=L(n);return o&&be(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):(be(s,n)&&(s!==void 0||Me(r.original,t))||(H(r),ie(r),Me(r.original,t)&&be(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 G(r)},ownKeys(r){return Reflect.ownKeys(G(r))},getOwnPropertyDescriptor(r,t){const s=G(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?ps.set.call(this,r,t,void 0,r.proxy):(wt(r.original,t)!==void 0||t in r.original?(H(r),ie(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 fs(r){const{original:t,parentDraft:s,key:e,finalities:i,options:a}=r,n=Fe(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,ps);if(i.revoke.push(h),us.add(c),o.proxy=c,s){const l=s;l.finalities.draft.push((p,d)=>{var f,x;const A=L(c);let _=l.type===3?l.setMap:l.copy;const C=he(_,e),O=L(C);if(O){let U=O.original;O.operated&&(U=bt(C)),At(O),St(O,Re,p,d),l.options.enableAutoFreeze&&(l.options.updatedValues=(f=l.options.updatedValues)!==null&&f!==void 0?f:new WeakMap,l.options.updatedValues.set(U,O.original)),Tt(_,e,U)}(x=A.callbacks)===null||x===void 0||x.forEach(U=>{U(p,d)})})}else{const l=L(c);l.finalities.draft.push((p,d)=>{At(l),St(l,Re,p,d)})}return c}Pt.createDraft=fs,Object.prototype.constructor.toString();const z=[];for(let r=0;r<256;++r)z.push((r+256).toString(16).slice(1));function vi(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 Di=new Uint8Array(16);function Oi(){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(Di)}const ds={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Li(r,t,s){var i;if(ds.randomUUID&&!r)return ds.randomUUID();r=r||{};const e=r.random??((i=r.rng)==null?void 0:i.call(r))??Oi();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,vi(e)}function ms(){return Li()}function Mi(r,t){return r.localeCompare(t)}function Fi(){let r=Mi;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{r=Intl.Collator("en-US").compare}catch{}return r}Fi();function Bi(){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 Ri=Bi();function Qe(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(Ri.has(a))return(n,o)=>Qe(r,t,[...s,o?[a,r,t,n,o]:[a,r,t,n]])}})}function ji(r,t){return`lookup__${r}__${JSON.stringify(t)}`}function _i(r){return r.startsWith("lookup__")}function ys(r){const[t,s,...e]=r.split("__");return[s,JSON.parse(e.join("__"))]}function Ui(r){return new Proxy({__etype:r},{get(t,s){if(s==="lookup")return(i,a)=>Qe(r,ys(ji(i,a)),[]);if(s==="__etype")return r;const e=s;return _i(e)?Qe(r,ys(e),[]):Qe(r,e,[])}})}function $i(){return new Proxy({},{get(r,t){return Ui(t)}})}$i();class Nt extends Error{constructor(s,e){super(s);m(this,"hint");this.hint=e;const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,Nt),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class je extends Nt{constructor(s){var a;const e=((a=s.body)==null?void 0:a.message)||`API Error (${s.status})`;super(e,s.body.hint);m(this,"body");m(this,"status");const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,je),this.name="InstantAPIError",this.status=s.status,this.body=s.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 Ee="v0.22.117";class ee{constructor(t,s,e,i={indexed:!1,unique:!1}){m(this,"valueType");m(this,"required");m(this,"isIndexed");m(this,"config");m(this,"metadata",{});this.valueType=t,this.required=s,this.isIndexed=e,this.config=i}clientRequired(){return new ee(this.valueType,!1,this.isIndexed,this.config)}optional(){return new ee(this.valueType,!1,this.isIndexed,this.config)}unique(){return new ee(this.valueType,this.required,this.isIndexed,{...this.config,unique:!0})}indexed(){return new ee(this.valueType,this.required,!0,{...this.config,indexed:!0})}}class Ze{constructor(t,s){m(this,"attrs");m(this,"links");this.attrs=t,this.links=s}asType(){return new Ze(this.attrs,this.links)}}class et{constructor(t,s,e){m(this,"entities");m(this,"links");m(this,"rooms");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 qi(r,t){return new et(Ps(r,t),t,void 0)}function zi(r){return new Ze(r,{})}function Vi(){return new ee("string",!0,!1)}function Hi(){return new ee("number",!0,!1)}function Ki(){return new ee("boolean",!0,!1)}function Ji(){return new ee("date",!0,!1)}function Wi(){return new ee("json",!0,!1)}function Xi(){return new ee("json",!0,!1)}function Ps(r,t){var i,a,n,o;const s={fwd:{},rev:{}};for(const c of Object.values(t))(i=s.fwd)[a=c.forward.on]||(i[a]={}),(n=s.rev)[o=c.reverse.on]||(n[o]={}),s.fwd[c.forward.on][c.forward.label]={entityName:c.reverse.on,cardinality:c.forward.has},s.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,{...s.fwd[c],...s.rev[c]})]))}function Gi({entities:r,links:t,rooms:s}){const e=t??{},i=s??{};return new et(Ps(r,e),e,i)}const V={graph:qi,schema:Gi,entity:zi,string:Vi,number:Hi,boolean:Ki,date:Ji,json:Wi,any:Xi};function Yi(){return globalThis.__instantDbSchemaHashStore=globalThis.__instantDbSchemaHashStore??new WeakMap,globalThis.__instantDbSchemaHashStore}function Qi(){return globalThis.__instantDbStore=globalThis.__instantDbStore??{},globalThis.__instantDbStore}Qi(),Yi();function Zi(){const r="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._~";let t="";for(const s of crypto.getRandomValues(new Uint8Array(64)))t=t+r[s%r.length];return t}function er(r){return crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(r))}function tr(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function sr(r){return er(r).then(t=>tr(btoa(String.fromCharCode(...Array.from(new Uint8Array(t))))))}function ir(){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 gs=null;function rr({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 ar({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":Ee,"Instant-Core-Version":Ee},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 nr(){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 or({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=gs;i&&i.close();const a=crypto.randomUUID(),n=Zi(),o=new BroadcastChannel(a),c=new Promise((l,p)=>{o.addEventListener("message",async d=>{if(d.data.type!=="oauth-redirect")return;const{state:f,error:x,code:A,errorDescription:_}=d.data;if(!(!f||f!==a)){if(A)try{const C=await ar({clientId:r,code:A,verifier:n,apiURI:t,redirectUri:s});l(C)}catch(C){C instanceof v&&p(C),p(new v({error:"server_error",message:"OAuth error exchanging code for token"}))}else p(typeof x=="string"?new v({error:x,errorDescription:_,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(".",""),ir());return h?(gs=h,sr(n).then(l=>{const p=rr({clientId:r,state:a,codeChallenge:l,apiURI:t,redirectUri:s,scopes:e});h.location.href=p}),c.finally(()=>o.close())):Promise.reject({error:"Could not open Auth window"})}class cr{constructor(t){m(this,"redirectUri");m(this,"clientId");m(this,"apiURI");this.redirectUri=t.redirectUri,this.apiURI=t.apiURI??"https://api.instantdb.com",this.clientId=t.clientId}startClientOnlyFlow(t){return or({clientId:this.clientId,apiURI:this.apiURI,redirectUri:this.redirectUri,scopes:t})}handleClientRedirect(){return nr()}}function hr(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.117
|
|
3
|
+
"version": "0.22.117",
|
|
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.117
|
|
58
|
-
"@instantdb/version": "0.22.117
|
|
57
|
+
"@instantdb/core": "0.22.117",
|
|
58
|
+
"@instantdb/version": "0.22.117"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"test": "vitest",
|