rmapi-js 1.0.0 → 2.0.0
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/CHANGELOG.md +22 -0
- package/README.md +34 -9
- package/bundle/rmapi-js.cjs.min.js +4 -4
- package/bundle/rmapi-js.esm.min.js +4 -4
- package/bundle/rmapi-js.iife.min.js +4 -4
- package/dist/index.d.ts +143 -29
- package/dist/index.js +200 -73
- package/package.json +35 -32
- package/bundle/rmapi.cjs.min.js +0 -4
- package/bundle/rmapi.esm.min.js +0 -4
- package/bundle/rmapi.iife.min.js +0 -4
package/bundle/rmapi.esm.min.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var Ce=Object.create;var ue=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var q=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var $e=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of je(r))!Ne.call(e,n)&&n!==t&&ue(e,n,{get:()=>r[n],enumerable:!(i=Le(r,n))||i.enumerable});return e};var He=(e,r,t)=>(t=e!=null?Ce(De(e)):{},$e(r||!e||!e.__esModule?ue(t,"default",{value:e,enumerable:!0}):t,e));var oe=q(l=>{"use strict";var ye=l&&l.__rest||function(e,r){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&r.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)r.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(t[i[n]]=e[i[n]]);return t};Object.defineProperty(l,"__esModule",{value:!0});l.isSchema=l.isValidSchema=l.isDiscriminatorForm=l.isValuesForm=l.isPropertiesForm=l.isElementsForm=l.isEnumForm=l.isTypeForm=l.isRefForm=l.isEmptyForm=void 0;function rt(e){let{definitions:r,nullable:t,metadata:i}=e,n=ye(e,["definitions","nullable","metadata"]);return Object.keys(n).length===0}l.isEmptyForm=rt;function ve(e){return"ref"in e}l.isRefForm=ve;function nt(e){return"type"in e}l.isTypeForm=nt;function be(e){return"enum"in e}l.isEnumForm=be;function xe(e){return"elements"in e}l.isElementsForm=xe;function ie(e){return"properties"in e||"optionalProperties"in e}l.isPropertiesForm=ie;function we(e){return"values"in e}l.isValuesForm=we;function Te(e){return"discriminator"in e}l.isDiscriminatorForm=Te;function C(e,r){if(r===void 0&&(r=e),e.definitions!==void 0){if(r!==e)return!1;for(let t of Object.values(e.definitions))if(!C(t,r))return!1}if(ve(e)&&!(e.ref in(r.definitions||{}))||be(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(xe(e))return C(e.elements,r);if(ie(e)){for(let t of Object.values(e.properties||{}))if(!C(t,r))return!1;for(let t of Object.values(e.optionalProperties||{}))if(!C(t,r))return!1;for(let t of Object.keys(e.properties||{}))if(t in(e.optionalProperties||{}))return!1}if(we(e))return C(e.values,r);if(Te(e)){for(let t of Object.values(e.mapping))if(!C(t,r)||!ie(t)||t.nullable||e.discriminator in(t.properties||{})||e.discriminator in(t.optionalProperties||{}))return!1}return!0}l.isValidSchema=C;var it=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],ot=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function L(e){if(typeof e!="object"||Array.isArray(e)||e===null)return!1;let r=e,{definitions:t=void 0,nullable:i=void 0,metadata:n=void 0,ref:o=void 0,type:s=void 0,enum:f=void 0,elements:a=void 0,properties:d=void 0,optionalProperties:u=void 0,additionalProperties:E=void 0,values:T=void 0,discriminator:P=void 0,mapping:p=void 0}=r,S=ye(r,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),A=[o!==void 0,s!==void 0,f!==void 0,a!==void 0,d!==void 0,u!==void 0,E!==void 0,T!==void 0,P!==void 0,p!==void 0],k=!1;for(let c of it)k=k||c.every((U,O)=>U===A[O]);if(!k)return!1;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;for(let c of Object.values(t))if(!L(c))return!1}if(i!==void 0&&typeof i!="boolean"||n!==void 0&&(typeof n!="object"||Array.isArray(n)||n===null)||o!==void 0&&typeof o!="string"||s!==void 0&&(typeof s!="string"||!ot.includes(s))||f!==void 0&&(!Array.isArray(f)||!f.every(c=>typeof c=="string"))||a!==void 0&&!L(a))return!1;if(d!==void 0){if(typeof d!="object"||Array.isArray(d)||d===null)return!1;for(let c of Object.values(d))if(!L(c))return!1}if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let c of Object.values(u))if(!L(c))return!1}if(E!==void 0&&typeof E!="boolean"||T!==void 0&&!L(T)||P!==void 0&&typeof P!="string")return!1;if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let c of Object.values(p))if(!L(c))return!1}return Object.keys(S).length===0}l.isSchema=L});var Ee=q(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});var st=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function at(e){let r=e.match(st);if(r===null)return!1;let t=parseInt(r[1],10),i=parseInt(r[2],10),n=parseInt(r[3],10),o=parseInt(r[4],10),s=parseInt(r[5],10),f=parseInt(r[6],10);return!(i>12||n>ft(t,i)||o>23||s>59||f>60)}se.default=at;function ft(e,r){return r===2?lt(e)?29:28:ut[r]}function lt(e){return e%4===0&&(e%100!==0||e%400===0)}var ut=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Pe=q(F=>{"use strict";var dt=F&&F.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(F,"__esModule",{value:!0});F.validate=F.MaxDepthExceededError=void 0;var pt=dt(Ee()),j=oe(),X=class extends Error{};F.MaxDepthExceededError=X;var Q=class extends Error{};function ct(e,r,t){let i={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:t||{maxDepth:0,maxErrors:0}};try{$(i,e,r)}catch(n){if(!(n instanceof Q))throw n}return i.errors}F.validate=ct;function $(e,r,t,i){if(!(r.nullable&&t===null)){if(j.isRefForm(r)){if(e.schemaTokens.length===e.config.maxDepth)throw new X;e.schemaTokens.push(["definitions",r.ref]),$(e,e.root.definitions[r.ref],t),e.schemaTokens.pop()}else if(j.isTypeForm(r)){switch(b(e,"type"),r.type){case"boolean":typeof t!="boolean"&&x(e);break;case"float32":case"float64":typeof t!="number"&&x(e);break;case"int8":B(e,t,-128,127);break;case"uint8":B(e,t,0,255);break;case"int16":B(e,t,-32768,32767);break;case"uint16":B(e,t,0,65535);break;case"int32":B(e,t,-2147483648,2147483647);break;case"uint32":B(e,t,0,4294967295);break;case"string":typeof t!="string"&&x(e);break;case"timestamp":typeof t!="string"?x(e):pt.default(t)||x(e);break}w(e)}else if(j.isEnumForm(r))b(e,"enum"),(typeof t!="string"||!r.enum.includes(t))&&x(e),w(e);else if(j.isElementsForm(r)){if(b(e,"elements"),Array.isArray(t))for(let[n,o]of t.entries())D(e,n.toString()),$(e,r.elements,o),N(e);else x(e);w(e)}else if(j.isPropertiesForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t)){if(r.properties!==void 0){b(e,"properties");for(let[n,o]of Object.entries(r.properties))b(e,n),t.hasOwnProperty(n)?(D(e,n),$(e,o,t[n]),N(e)):x(e),w(e);w(e)}if(r.optionalProperties!==void 0){b(e,"optionalProperties");for(let[n,o]of Object.entries(r.optionalProperties))b(e,n),t.hasOwnProperty(n)&&(D(e,n),$(e,o,t[n]),N(e)),w(e);w(e)}if(r.additionalProperties!==!0)for(let n of Object.keys(t)){let o=r.properties&&n in r.properties,s=r.optionalProperties&&n in r.optionalProperties;!o&&!s&&n!==i&&(D(e,n),x(e),N(e))}}else r.properties!==void 0?b(e,"properties"):b(e,"optionalProperties"),x(e),w(e);else if(j.isValuesForm(r)){if(b(e,"values"),typeof t=="object"&&t!==null&&!Array.isArray(t))for(let[n,o]of Object.entries(t))D(e,n),$(e,r.values,o),N(e);else x(e);w(e)}else if(j.isDiscriminatorForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t))if(t.hasOwnProperty(r.discriminator)){let n=t[r.discriminator];typeof n=="string"?n in r.mapping?(b(e,"mapping"),b(e,n),$(e,r.mapping[n],t,r.discriminator),w(e),w(e)):(b(e,"mapping"),D(e,r.discriminator),x(e),N(e),w(e)):(b(e,"discriminator"),D(e,r.discriminator),x(e),N(e),w(e))}else b(e,"discriminator"),x(e),w(e);else b(e,"discriminator"),x(e),w(e)}}function B(e,r,t,i){(typeof r!="number"||!Number.isInteger(r)||r<t||r>i)&&x(e)}function D(e,r){e.instanceTokens.push(r)}function N(e){e.instanceTokens.pop()}function b(e,r){e.schemaTokens[e.schemaTokens.length-1].push(r)}function w(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function x(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new Q}});var ke=q(I=>{"use strict";var mt=I&&I.__createBinding||(Object.create?function(e,r,t,i){i===void 0&&(i=t),Object.defineProperty(e,i,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,i){i===void 0&&(i=t),e[i]=r[t]}),Ae=I&&I.__exportStar||function(e,r){for(var t in e)t!=="default"&&!r.hasOwnProperty(t)&&mt(r,e,t)};Object.defineProperty(I,"__esModule",{value:!0});Ae(oe(),I);Ae(Pe(),I)});var J,_e=new Uint8Array(16);function z(){if(!J&&(J=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!J))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return J(_e)}var de=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Be(e){return typeof e=="string"&&de.test(e)}var H=Be;var m=[];for(G=0;G<256;++G)m.push((G+256).toString(16).substr(1));var G;function Ve(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(m[e[r+0]]+m[e[r+1]]+m[e[r+2]]+m[e[r+3]]+"-"+m[e[r+4]]+m[e[r+5]]+"-"+m[e[r+6]]+m[e[r+7]]+"-"+m[e[r+8]]+m[e[r+9]]+"-"+m[e[r+10]]+m[e[r+11]]+m[e[r+12]]+m[e[r+13]]+m[e[r+14]]+m[e[r+15]]).toLowerCase();if(!H(t))throw TypeError("Stringified UUID is invalid");return t}var _=Ve;function qe(e){if(!H(e))throw TypeError("Invalid UUID");var r,t=new Uint8Array(16);return t[0]=(r=parseInt(e.slice(0,8),16))>>>24,t[1]=r>>>16&255,t[2]=r>>>8&255,t[3]=r&255,t[4]=(r=parseInt(e.slice(9,13),16))>>>8,t[5]=r&255,t[6]=(r=parseInt(e.slice(14,18),16))>>>8,t[7]=r&255,t[8]=(r=parseInt(e.slice(19,23),16))>>>8,t[9]=r&255,t[10]=(r=parseInt(e.slice(24,36),16))/1099511627776&255,t[11]=r/4294967296&255,t[12]=r>>>24&255,t[13]=r>>>16&255,t[14]=r>>>8&255,t[15]=r&255,t}var te=qe;function Je(e){e=unescape(encodeURIComponent(e));for(var r=[],t=0;t<e.length;++t)r.push(e.charCodeAt(t));return r}var ze="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Ge="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Y(e,r,t){function i(n,o,s,f){if(typeof n=="string"&&(n=Je(n)),typeof o=="string"&&(o=te(o)),o.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+n.length);if(a.set(o),a.set(n,o.length),a=t(a),a[6]=a[6]&15|r,a[8]=a[8]&63|128,s){f=f||0;for(var d=0;d<16;++d)s[f+d]=a[d];return s}return _(a)}try{i.name=e}catch{}return i.DNS=ze,i.URL=Ge,i}function Ye(e){if(typeof e=="string"){var r=unescape(encodeURIComponent(e));e=new Uint8Array(r.length);for(var t=0;t<r.length;++t)e[t]=r.charCodeAt(t)}return Ze(Ke(Xe(e),e.length*8))}function Ze(e){for(var r=[],t=e.length*32,i="0123456789abcdef",n=0;n<t;n+=8){var o=e[n>>5]>>>n%32&255,s=parseInt(i.charAt(o>>>4&15)+i.charAt(o&15),16);r.push(s)}return r}function pe(e){return(e+64>>>9<<4)+14+1}function Ke(e,r){e[r>>5]|=128<<r%32,e[pe(r)-1]=r;for(var t=1732584193,i=-271733879,n=-1732584194,o=271733878,s=0;s<e.length;s+=16){var f=t,a=i,d=n,u=o;t=g(t,i,n,o,e[s],7,-680876936),o=g(o,t,i,n,e[s+1],12,-389564586),n=g(n,o,t,i,e[s+2],17,606105819),i=g(i,n,o,t,e[s+3],22,-1044525330),t=g(t,i,n,o,e[s+4],7,-176418897),o=g(o,t,i,n,e[s+5],12,1200080426),n=g(n,o,t,i,e[s+6],17,-1473231341),i=g(i,n,o,t,e[s+7],22,-45705983),t=g(t,i,n,o,e[s+8],7,1770035416),o=g(o,t,i,n,e[s+9],12,-1958414417),n=g(n,o,t,i,e[s+10],17,-42063),i=g(i,n,o,t,e[s+11],22,-1990404162),t=g(t,i,n,o,e[s+12],7,1804603682),o=g(o,t,i,n,e[s+13],12,-40341101),n=g(n,o,t,i,e[s+14],17,-1502002290),i=g(i,n,o,t,e[s+15],22,1236535329),t=h(t,i,n,o,e[s+1],5,-165796510),o=h(o,t,i,n,e[s+6],9,-1069501632),n=h(n,o,t,i,e[s+11],14,643717713),i=h(i,n,o,t,e[s],20,-373897302),t=h(t,i,n,o,e[s+5],5,-701558691),o=h(o,t,i,n,e[s+10],9,38016083),n=h(n,o,t,i,e[s+15],14,-660478335),i=h(i,n,o,t,e[s+4],20,-405537848),t=h(t,i,n,o,e[s+9],5,568446438),o=h(o,t,i,n,e[s+14],9,-1019803690),n=h(n,o,t,i,e[s+3],14,-187363961),i=h(i,n,o,t,e[s+8],20,1163531501),t=h(t,i,n,o,e[s+13],5,-1444681467),o=h(o,t,i,n,e[s+2],9,-51403784),n=h(n,o,t,i,e[s+7],14,1735328473),i=h(i,n,o,t,e[s+12],20,-1926607734),t=y(t,i,n,o,e[s+5],4,-378558),o=y(o,t,i,n,e[s+8],11,-2022574463),n=y(n,o,t,i,e[s+11],16,1839030562),i=y(i,n,o,t,e[s+14],23,-35309556),t=y(t,i,n,o,e[s+1],4,-1530992060),o=y(o,t,i,n,e[s+4],11,1272893353),n=y(n,o,t,i,e[s+7],16,-155497632),i=y(i,n,o,t,e[s+10],23,-1094730640),t=y(t,i,n,o,e[s+13],4,681279174),o=y(o,t,i,n,e[s],11,-358537222),n=y(n,o,t,i,e[s+3],16,-722521979),i=y(i,n,o,t,e[s+6],23,76029189),t=y(t,i,n,o,e[s+9],4,-640364487),o=y(o,t,i,n,e[s+12],11,-421815835),n=y(n,o,t,i,e[s+15],16,530742520),i=y(i,n,o,t,e[s+2],23,-995338651),t=v(t,i,n,o,e[s],6,-198630844),o=v(o,t,i,n,e[s+7],10,1126891415),n=v(n,o,t,i,e[s+14],15,-1416354905),i=v(i,n,o,t,e[s+5],21,-57434055),t=v(t,i,n,o,e[s+12],6,1700485571),o=v(o,t,i,n,e[s+3],10,-1894986606),n=v(n,o,t,i,e[s+10],15,-1051523),i=v(i,n,o,t,e[s+1],21,-2054922799),t=v(t,i,n,o,e[s+8],6,1873313359),o=v(o,t,i,n,e[s+15],10,-30611744),n=v(n,o,t,i,e[s+6],15,-1560198380),i=v(i,n,o,t,e[s+13],21,1309151649),t=v(t,i,n,o,e[s+4],6,-145523070),o=v(o,t,i,n,e[s+11],10,-1120210379),n=v(n,o,t,i,e[s+2],15,718787259),i=v(i,n,o,t,e[s+9],21,-343485551),t=R(t,f),i=R(i,a),n=R(n,d),o=R(o,u)}return[t,i,n,o]}function Xe(e){if(e.length===0)return[];for(var r=e.length*8,t=new Uint32Array(pe(r)),i=0;i<r;i+=8)t[i>>5]|=(e[i/8]&255)<<i%32;return t}function R(e,r){var t=(e&65535)+(r&65535),i=(e>>16)+(r>>16)+(t>>16);return i<<16|t&65535}function Qe(e,r){return e<<r|e>>>32-r}function Z(e,r,t,i,n,o){return R(Qe(R(R(r,e),R(i,o)),n),t)}function g(e,r,t,i,n,o,s){return Z(r&t|~r&i,e,r,n,o,s)}function h(e,r,t,i,n,o,s){return Z(r&i|t&~i,e,r,n,o,s)}function y(e,r,t,i,n,o,s){return Z(r^t^i,e,r,n,o,s)}function v(e,r,t,i,n,o,s){return Z(t^(r|~i),e,r,n,o,s)}var ce=Ye;var Bt=Y("v3",48,ce);function We(e,r,t){e=e||{};var i=e.random||(e.rng||z)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r){t=t||0;for(var n=0;n<16;++n)r[t+n]=i[n];return r}return _(i)}var K=We;function et(e,r,t,i){switch(e){case 0:return r&t^~r&i;case 1:return r^t^i;case 2:return r&t^r&i^t&i;case 3:return r^t^i}}function re(e,r){return e<<r|e>>>32-r}function tt(e){var r=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var i=unescape(encodeURIComponent(e));e=[];for(var n=0;n<i.length;++n)e.push(i.charCodeAt(n))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=e.length/4+2,s=Math.ceil(o/16),f=new Array(s),a=0;a<s;++a){for(var d=new Uint32Array(16),u=0;u<16;++u)d[u]=e[a*64+u*4]<<24|e[a*64+u*4+1]<<16|e[a*64+u*4+2]<<8|e[a*64+u*4+3];f[a]=d}f[s-1][14]=(e.length-1)*8/Math.pow(2,32),f[s-1][14]=Math.floor(f[s-1][14]),f[s-1][15]=(e.length-1)*8&4294967295;for(var E=0;E<s;++E){for(var T=new Uint32Array(80),P=0;P<16;++P)T[P]=f[E][P];for(var p=16;p<80;++p)T[p]=re(T[p-3]^T[p-8]^T[p-14]^T[p-16],1);for(var S=t[0],A=t[1],k=t[2],c=t[3],U=t[4],O=0;O<80;++O){var M=Math.floor(O/20),ee=re(S,5)+et(M,A,k,c)+U+r[M]+T[O]>>>0;U=c,c=k,k=re(A,30)>>>0,A=S,S=ee}t[0]=t[0]+S>>>0,t[1]=t[1]+A>>>0,t[2]=t[2]+k>>>0,t[3]=t[3]+c>>>0,t[4]=t[4]+U>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var me=tt;var Kt=Y("v5",80,me);function ne(e){return[...new Uint8Array(e)].map(r=>r.toString(16).padStart(2,"0")).join("")}function ge(e){return new Uint8Array((e.match(/../g)??[]).map(r=>parseInt(r,16)))}function he(e){let r=0;for(let n of e)r+=n.length;let t=new Uint8Array(r),i=0;for(let n of e)t.set(n,i),i+=n.length;return t}var Se=He(ke());function ae(e,r){if((0,Se.validate)(e,r).length)throw new Error(`couldn't validate schema: ${JSON.stringify(r)} didn't match schema ${JSON.stringify(e)}`)}var Oe="3",Ue="https://webapp-production-dot-remarkable-production.appspot.com",gt="https://rm-blob-storage-prod.appspot.com",Re="x-goog-generation",ht="x-goog-if-generation-match",kr=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],Sr=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],yt={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},vt={sm:50,md:125,rr:180,lg:200},bt={df:-1,md:100,lg:150,xl:200},xt={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}}},Fe={visibleName:{type:"string"},parent:{type:"string"},lastModified:{type:"string"},version:{type:"int32"},synced:{type:"boolean"}},Ie={pinned:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"}},wt={discriminator:"type",mapping:{CollectionType:{properties:Fe,optionalProperties:Ie},DocumentType:{properties:Fe,optionalProperties:{...Ie,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},V=class extends Error{constructor(t,i,n){super(n);this.status=t,this.statusText=i}},W=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function Or(e,{deviceDesc:r="desktop-linux",uuid:t=K(),authUrl:i=Ue,fetch:n=globalThis.fetch}={}){if(e.length!==8)throw new Error(`code should be length 8, but was ${e.length}`);let o=await n(`${i}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:e,deviceDesc:r,deviceID:t})});if(o.ok)return await o.text();throw new V(o.status,o.statusText,"couldn't register api")}function Tt({hash:e,type:r,documentId:t,subfiles:i,size:n}){return`${e}:${r}:${t}:${i}:${n}
|
|
2
|
-
`}function Et(e){let[r,t,i,n,o]=e.split(":");if(r===void 0||t===void 0||i===void 0||n===void 0||o===void 0)throw new Error(`entries line didn't contain five fields: '${e}'`);if(t==="80000000"){if(o!=="0")throw new Error(`collection type entry had nonzero size: ${o}`);return{hash:r,type:t,documentId:i,subfiles:parseInt(n),size:0n}}else if(t==="0"){if(n!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${n}`);return{hash:r,type:t,documentId:i,subfiles:0,size:BigInt(o)}}else throw new Error(`entries line contained invalid type: ${t}`)}var fe=class{constructor(r,t,i,n,o){this.userToken=r;this.fetch=t;this.cache=i;this.subtle=n;this.blobUrl=o}async authedFetch(r,t,i="POST"){let n=await this.fetch(r,{method:i,headers:{Authorization:`Bearer ${this.userToken}`},body:t&&JSON.stringify(t)});if(n.ok)return n;throw new V(n.status,n.statusText,"failed reMarkable request")}async signedFetch({url:r,method:t},i,n){let o=await this.fetch(r,{method:t,body:i,headers:n});if(o.ok)return o;{let s=await o.text();throw new V(o.status,o.statusText,s)}}async getUrl(r,t){let i=t===void 0?"downloads":"uploads",n=t==null?void 0:`${t}`,s=await(await this.authedFetch(`${this.blobUrl}/api/v1/signed-urls/${i}`,{http_method:n===void 0?"GET":"PUT",relative_path:r,generation:n})).text(),f=JSON.parse(s);return ae(xt,f),f}async syncComplete(){await this.authedFetch(`${this.blobUrl}/api/v1/sync-complete`)}async getRootHash(){let r=await this.getUrl("root"),t=await this.signedFetch(r),i=t.headers.get(Re);if(!i)throw new Error("no generation header in root hash");return[await t.text(),BigInt(i)]}async putRootHash(r,t){let i=await this.getUrl("root",t),n;try{n=await this.signedFetch(i,r,{[ht]:`${t}`})}catch(s){throw s instanceof V&&s.status===412?new W:s}let o=n.headers.get(Re);if(!o)throw new Error("no generation header in root hash");return BigInt(o)}async getBuffer(r){let t=await this.getUrl(r);return await(await this.signedFetch(t)).arrayBuffer()}async getText(r){let t=this.cache&&await this.cache.get(r);if(t)return t;{let i=await this.getUrl(r),o=await(await this.signedFetch(i)).text();return this.cache&&await this.cache.set(r,o),o}}async getMetadata(r){let t=await this.getText(r),i=JSON.parse(t);return ae(wt,i),i}async getEntries(r){let t=await this.getText(r),[i,...n]=t.slice(0,-1).split(`
|
|
3
|
-
`);if(i!==Oe)throw new Error(`got unexpected schema version: ${i}`);return n.map(Et)}async putHash(r,t){let i=await this.getUrl(r,null);await this.signedFetch(i,t)}async putEntries(r,t){let i=new TextEncoder;t.sort((u,E)=>u.documentId.localeCompare(E.documentId));let n=he(t.map(u=>ge(u.hash))),o=await this.subtle.digest("SHA-256",n),s=ne(o),f=t.map(Tt).join(""),a=`${Oe}
|
|
4
|
-
${f}`,d=i.encode(a);return await this.putHash(s,d),this.cache&&await this.cache.set(s,a),{hash:s,type:"80000000",documentId:r,subfiles:t.length,size:0n}}async putBuffer(r,t){let i=await this.subtle.digest("SHA-256",t),n=ne(i);return await this.putHash(n,t),{hash:n,type:"0",documentId:r,subfiles:0,size:BigInt(t.length)}}async putText(r,t){let i=new TextEncoder,n=await this.putBuffer(r,i.encode(t));return this.cache&&await this.cache.set(n.hash,t),n}async putEpub(r,t,{parent:i="",margins:n=125,orientation:o,textAlignment:s,textScale:f=1,lineHeight:a=-1,fontName:d="",cover:u="visited",lastTool:E,notify:T=!0,retries:P=3}={}){let p=K(),S=`${new Date().valueOf()}`,A=[];A.push(this.putBuffer(`${p}.epub`,t));let k={type:"DocumentType",visibleName:r,version:0,parent:i,synced:!0,lastModified:S};A.push(this.putText(`${p}.metadata`,JSON.stringify(k)));let c={dummyDocument:!1,extraMetadata:{LastTool:E},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof a=="string"?bt[a]:a,margins:typeof n=="string"?vt[n]:n,textScale:typeof f=="string"?yt[f]:f,pages:[],coverPageNumber:u==="first"?0:-1,formatVersion:1,orientation:o,textAlignment:s,fontName:d};A.push(this.putText(`${p}.content`,JSON.stringify(c)));let U=await Promise.all(A),O=await this.putEntries(p,U);for(;;--P)try{let[M,ee]=await this.getRootHash(),le=await this.getEntries(M);le.push(O);let{hash:Me}=await this.putEntries("",le);await this.putRootHash(Me,ee);break}catch(M){if(P<=0||!(M instanceof W))throw M}T&&await this.syncComplete()}};async function Rr(e,{fetch:r=globalThis.fetch,cache:t,subtle:i=globalThis.crypto?.subtle,authUrl:n=Ue,blobUrl:o=gt}={}){let s=await r(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!s.ok)throw new Error(`couldn't fetch auth token: ${s.statusText}`);let f=await s.text();return new fe(f,r,t,i,o)}export{W as GenerationError,V as ResponseError,Sr as builtinFontNames,bt as builtinLineHeights,vt as builtinMargins,yt as builtinTextScales,kr as builtinTools,Or as register,Rr as remarkable};
|
package/bundle/rmapi.iife.min.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var rmapi=(()=>{var Ne=Object.create;var J=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var _e=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var z=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Ve=(e,r)=>{for(var t in r)J(e,t,{get:r[t],enumerable:!0})},de=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of He(r))!Be.call(e,n)&&n!==t&&J(e,n,{get:()=>r[n],enumerable:!(i=$e(r,n))||i.enumerable});return e};var qe=(e,r,t)=>(t=e!=null?Ne(_e(e)):{},de(r||!e||!e.__esModule?J(t,"default",{value:e,enumerable:!0}):t,e)),Je=e=>de(J({},"__esModule",{value:!0}),e);var se=z(l=>{"use strict";var ve=l&&l.__rest||function(e,r){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&r.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)r.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(t[i[n]]=e[i[n]]);return t};Object.defineProperty(l,"__esModule",{value:!0});l.isSchema=l.isValidSchema=l.isDiscriminatorForm=l.isValuesForm=l.isPropertiesForm=l.isElementsForm=l.isEnumForm=l.isTypeForm=l.isRefForm=l.isEmptyForm=void 0;function at(e){let{definitions:r,nullable:t,metadata:i}=e,n=ve(e,["definitions","nullable","metadata"]);return Object.keys(n).length===0}l.isEmptyForm=at;function be(e){return"ref"in e}l.isRefForm=be;function ft(e){return"type"in e}l.isTypeForm=ft;function xe(e){return"enum"in e}l.isEnumForm=xe;function we(e){return"elements"in e}l.isElementsForm=we;function oe(e){return"properties"in e||"optionalProperties"in e}l.isPropertiesForm=oe;function Te(e){return"values"in e}l.isValuesForm=Te;function Ee(e){return"discriminator"in e}l.isDiscriminatorForm=Ee;function C(e,r){if(r===void 0&&(r=e),e.definitions!==void 0){if(r!==e)return!1;for(let t of Object.values(e.definitions))if(!C(t,r))return!1}if(be(e)&&!(e.ref in(r.definitions||{}))||xe(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(we(e))return C(e.elements,r);if(oe(e)){for(let t of Object.values(e.properties||{}))if(!C(t,r))return!1;for(let t of Object.values(e.optionalProperties||{}))if(!C(t,r))return!1;for(let t of Object.keys(e.properties||{}))if(t in(e.optionalProperties||{}))return!1}if(Te(e))return C(e.values,r);if(Ee(e)){for(let t of Object.values(e.mapping))if(!C(t,r)||!oe(t)||t.nullable||e.discriminator in(t.properties||{})||e.discriminator in(t.optionalProperties||{}))return!1}return!0}l.isValidSchema=C;var lt=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],ut=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function L(e){if(typeof e!="object"||Array.isArray(e)||e===null)return!1;let r=e,{definitions:t=void 0,nullable:i=void 0,metadata:n=void 0,ref:o=void 0,type:s=void 0,enum:f=void 0,elements:a=void 0,properties:d=void 0,optionalProperties:u=void 0,additionalProperties:E=void 0,values:T=void 0,discriminator:P=void 0,mapping:p=void 0}=r,S=ve(r,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),A=[o!==void 0,s!==void 0,f!==void 0,a!==void 0,d!==void 0,u!==void 0,E!==void 0,T!==void 0,P!==void 0,p!==void 0],k=!1;for(let c of lt)k=k||c.every((U,O)=>U===A[O]);if(!k)return!1;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;for(let c of Object.values(t))if(!L(c))return!1}if(i!==void 0&&typeof i!="boolean"||n!==void 0&&(typeof n!="object"||Array.isArray(n)||n===null)||o!==void 0&&typeof o!="string"||s!==void 0&&(typeof s!="string"||!ut.includes(s))||f!==void 0&&(!Array.isArray(f)||!f.every(c=>typeof c=="string"))||a!==void 0&&!L(a))return!1;if(d!==void 0){if(typeof d!="object"||Array.isArray(d)||d===null)return!1;for(let c of Object.values(d))if(!L(c))return!1}if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let c of Object.values(u))if(!L(c))return!1}if(E!==void 0&&typeof E!="boolean"||T!==void 0&&!L(T)||P!==void 0&&typeof P!="string")return!1;if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let c of Object.values(p))if(!L(c))return!1}return Object.keys(S).length===0}l.isSchema=L});var Pe=z(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});var dt=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function pt(e){let r=e.match(dt);if(r===null)return!1;let t=parseInt(r[1],10),i=parseInt(r[2],10),n=parseInt(r[3],10),o=parseInt(r[4],10),s=parseInt(r[5],10),f=parseInt(r[6],10);return!(i>12||n>ct(t,i)||o>23||s>59||f>60)}ae.default=pt;function ct(e,r){return r===2?mt(e)?29:28:gt[r]}function mt(e){return e%4===0&&(e%100!==0||e%400===0)}var gt=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Ae=z(F=>{"use strict";var ht=F&&F.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(F,"__esModule",{value:!0});F.validate=F.MaxDepthExceededError=void 0;var yt=ht(Pe()),j=se(),W=class extends Error{};F.MaxDepthExceededError=W;var ee=class extends Error{};function vt(e,r,t){let i={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:t||{maxDepth:0,maxErrors:0}};try{$(i,e,r)}catch(n){if(!(n instanceof ee))throw n}return i.errors}F.validate=vt;function $(e,r,t,i){if(!(r.nullable&&t===null)){if(j.isRefForm(r)){if(e.schemaTokens.length===e.config.maxDepth)throw new W;e.schemaTokens.push(["definitions",r.ref]),$(e,e.root.definitions[r.ref],t),e.schemaTokens.pop()}else if(j.isTypeForm(r)){switch(b(e,"type"),r.type){case"boolean":typeof t!="boolean"&&x(e);break;case"float32":case"float64":typeof t!="number"&&x(e);break;case"int8":V(e,t,-128,127);break;case"uint8":V(e,t,0,255);break;case"int16":V(e,t,-32768,32767);break;case"uint16":V(e,t,0,65535);break;case"int32":V(e,t,-2147483648,2147483647);break;case"uint32":V(e,t,0,4294967295);break;case"string":typeof t!="string"&&x(e);break;case"timestamp":typeof t!="string"?x(e):yt.default(t)||x(e);break}w(e)}else if(j.isEnumForm(r))b(e,"enum"),(typeof t!="string"||!r.enum.includes(t))&&x(e),w(e);else if(j.isElementsForm(r)){if(b(e,"elements"),Array.isArray(t))for(let[n,o]of t.entries())D(e,n.toString()),$(e,r.elements,o),N(e);else x(e);w(e)}else if(j.isPropertiesForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t)){if(r.properties!==void 0){b(e,"properties");for(let[n,o]of Object.entries(r.properties))b(e,n),t.hasOwnProperty(n)?(D(e,n),$(e,o,t[n]),N(e)):x(e),w(e);w(e)}if(r.optionalProperties!==void 0){b(e,"optionalProperties");for(let[n,o]of Object.entries(r.optionalProperties))b(e,n),t.hasOwnProperty(n)&&(D(e,n),$(e,o,t[n]),N(e)),w(e);w(e)}if(r.additionalProperties!==!0)for(let n of Object.keys(t)){let o=r.properties&&n in r.properties,s=r.optionalProperties&&n in r.optionalProperties;!o&&!s&&n!==i&&(D(e,n),x(e),N(e))}}else r.properties!==void 0?b(e,"properties"):b(e,"optionalProperties"),x(e),w(e);else if(j.isValuesForm(r)){if(b(e,"values"),typeof t=="object"&&t!==null&&!Array.isArray(t))for(let[n,o]of Object.entries(t))D(e,n),$(e,r.values,o),N(e);else x(e);w(e)}else if(j.isDiscriminatorForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t))if(t.hasOwnProperty(r.discriminator)){let n=t[r.discriminator];typeof n=="string"?n in r.mapping?(b(e,"mapping"),b(e,n),$(e,r.mapping[n],t,r.discriminator),w(e),w(e)):(b(e,"mapping"),D(e,r.discriminator),x(e),N(e),w(e)):(b(e,"discriminator"),D(e,r.discriminator),x(e),N(e),w(e))}else b(e,"discriminator"),x(e),w(e);else b(e,"discriminator"),x(e),w(e)}}function V(e,r,t,i){(typeof r!="number"||!Number.isInteger(r)||r<t||r>i)&&x(e)}function D(e,r){e.instanceTokens.push(r)}function N(e){e.instanceTokens.pop()}function b(e,r){e.schemaTokens[e.schemaTokens.length-1].push(r)}function w(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function x(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new ee}});var Se=z(I=>{"use strict";var bt=I&&I.__createBinding||(Object.create?function(e,r,t,i){i===void 0&&(i=t),Object.defineProperty(e,i,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,i){i===void 0&&(i=t),e[i]=r[t]}),ke=I&&I.__exportStar||function(e,r){for(var t in e)t!=="default"&&!r.hasOwnProperty(t)&&bt(r,e,t)};Object.defineProperty(I,"__esModule",{value:!0});ke(se(),I);ke(Ae(),I)});var Ft={};Ve(Ft,{GenerationError:()=>q,ResponseError:()=>H,builtinFontNames:()=>Et,builtinLineHeights:()=>je,builtinMargins:()=>Le,builtinTextScales:()=>Ce,builtinTools:()=>Tt,register:()=>kt,remarkable:()=>Rt});var G,ze=new Uint8Array(16);function Y(){if(!G&&(G=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!G))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return G(ze)}var pe=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Ge(e){return typeof e=="string"&&pe.test(e)}var _=Ge;var m=[];for(Z=0;Z<256;++Z)m.push((Z+256).toString(16).substr(1));var Z;function Ye(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(m[e[r+0]]+m[e[r+1]]+m[e[r+2]]+m[e[r+3]]+"-"+m[e[r+4]]+m[e[r+5]]+"-"+m[e[r+6]]+m[e[r+7]]+"-"+m[e[r+8]]+m[e[r+9]]+"-"+m[e[r+10]]+m[e[r+11]]+m[e[r+12]]+m[e[r+13]]+m[e[r+14]]+m[e[r+15]]).toLowerCase();if(!_(t))throw TypeError("Stringified UUID is invalid");return t}var B=Ye;function Ze(e){if(!_(e))throw TypeError("Invalid UUID");var r,t=new Uint8Array(16);return t[0]=(r=parseInt(e.slice(0,8),16))>>>24,t[1]=r>>>16&255,t[2]=r>>>8&255,t[3]=r&255,t[4]=(r=parseInt(e.slice(9,13),16))>>>8,t[5]=r&255,t[6]=(r=parseInt(e.slice(14,18),16))>>>8,t[7]=r&255,t[8]=(r=parseInt(e.slice(19,23),16))>>>8,t[9]=r&255,t[10]=(r=parseInt(e.slice(24,36),16))/1099511627776&255,t[11]=r/4294967296&255,t[12]=r>>>24&255,t[13]=r>>>16&255,t[14]=r>>>8&255,t[15]=r&255,t}var re=Ze;function Ke(e){e=unescape(encodeURIComponent(e));for(var r=[],t=0;t<e.length;++t)r.push(e.charCodeAt(t));return r}var Xe="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Qe="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function K(e,r,t){function i(n,o,s,f){if(typeof n=="string"&&(n=Ke(n)),typeof o=="string"&&(o=re(o)),o.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+n.length);if(a.set(o),a.set(n,o.length),a=t(a),a[6]=a[6]&15|r,a[8]=a[8]&63|128,s){f=f||0;for(var d=0;d<16;++d)s[f+d]=a[d];return s}return B(a)}try{i.name=e}catch{}return i.DNS=Xe,i.URL=Qe,i}function We(e){if(typeof e=="string"){var r=unescape(encodeURIComponent(e));e=new Uint8Array(r.length);for(var t=0;t<r.length;++t)e[t]=r.charCodeAt(t)}return et(tt(rt(e),e.length*8))}function et(e){for(var r=[],t=e.length*32,i="0123456789abcdef",n=0;n<t;n+=8){var o=e[n>>5]>>>n%32&255,s=parseInt(i.charAt(o>>>4&15)+i.charAt(o&15),16);r.push(s)}return r}function ce(e){return(e+64>>>9<<4)+14+1}function tt(e,r){e[r>>5]|=128<<r%32,e[ce(r)-1]=r;for(var t=1732584193,i=-271733879,n=-1732584194,o=271733878,s=0;s<e.length;s+=16){var f=t,a=i,d=n,u=o;t=g(t,i,n,o,e[s],7,-680876936),o=g(o,t,i,n,e[s+1],12,-389564586),n=g(n,o,t,i,e[s+2],17,606105819),i=g(i,n,o,t,e[s+3],22,-1044525330),t=g(t,i,n,o,e[s+4],7,-176418897),o=g(o,t,i,n,e[s+5],12,1200080426),n=g(n,o,t,i,e[s+6],17,-1473231341),i=g(i,n,o,t,e[s+7],22,-45705983),t=g(t,i,n,o,e[s+8],7,1770035416),o=g(o,t,i,n,e[s+9],12,-1958414417),n=g(n,o,t,i,e[s+10],17,-42063),i=g(i,n,o,t,e[s+11],22,-1990404162),t=g(t,i,n,o,e[s+12],7,1804603682),o=g(o,t,i,n,e[s+13],12,-40341101),n=g(n,o,t,i,e[s+14],17,-1502002290),i=g(i,n,o,t,e[s+15],22,1236535329),t=h(t,i,n,o,e[s+1],5,-165796510),o=h(o,t,i,n,e[s+6],9,-1069501632),n=h(n,o,t,i,e[s+11],14,643717713),i=h(i,n,o,t,e[s],20,-373897302),t=h(t,i,n,o,e[s+5],5,-701558691),o=h(o,t,i,n,e[s+10],9,38016083),n=h(n,o,t,i,e[s+15],14,-660478335),i=h(i,n,o,t,e[s+4],20,-405537848),t=h(t,i,n,o,e[s+9],5,568446438),o=h(o,t,i,n,e[s+14],9,-1019803690),n=h(n,o,t,i,e[s+3],14,-187363961),i=h(i,n,o,t,e[s+8],20,1163531501),t=h(t,i,n,o,e[s+13],5,-1444681467),o=h(o,t,i,n,e[s+2],9,-51403784),n=h(n,o,t,i,e[s+7],14,1735328473),i=h(i,n,o,t,e[s+12],20,-1926607734),t=y(t,i,n,o,e[s+5],4,-378558),o=y(o,t,i,n,e[s+8],11,-2022574463),n=y(n,o,t,i,e[s+11],16,1839030562),i=y(i,n,o,t,e[s+14],23,-35309556),t=y(t,i,n,o,e[s+1],4,-1530992060),o=y(o,t,i,n,e[s+4],11,1272893353),n=y(n,o,t,i,e[s+7],16,-155497632),i=y(i,n,o,t,e[s+10],23,-1094730640),t=y(t,i,n,o,e[s+13],4,681279174),o=y(o,t,i,n,e[s],11,-358537222),n=y(n,o,t,i,e[s+3],16,-722521979),i=y(i,n,o,t,e[s+6],23,76029189),t=y(t,i,n,o,e[s+9],4,-640364487),o=y(o,t,i,n,e[s+12],11,-421815835),n=y(n,o,t,i,e[s+15],16,530742520),i=y(i,n,o,t,e[s+2],23,-995338651),t=v(t,i,n,o,e[s],6,-198630844),o=v(o,t,i,n,e[s+7],10,1126891415),n=v(n,o,t,i,e[s+14],15,-1416354905),i=v(i,n,o,t,e[s+5],21,-57434055),t=v(t,i,n,o,e[s+12],6,1700485571),o=v(o,t,i,n,e[s+3],10,-1894986606),n=v(n,o,t,i,e[s+10],15,-1051523),i=v(i,n,o,t,e[s+1],21,-2054922799),t=v(t,i,n,o,e[s+8],6,1873313359),o=v(o,t,i,n,e[s+15],10,-30611744),n=v(n,o,t,i,e[s+6],15,-1560198380),i=v(i,n,o,t,e[s+13],21,1309151649),t=v(t,i,n,o,e[s+4],6,-145523070),o=v(o,t,i,n,e[s+11],10,-1120210379),n=v(n,o,t,i,e[s+2],15,718787259),i=v(i,n,o,t,e[s+9],21,-343485551),t=R(t,f),i=R(i,a),n=R(n,d),o=R(o,u)}return[t,i,n,o]}function rt(e){if(e.length===0)return[];for(var r=e.length*8,t=new Uint32Array(ce(r)),i=0;i<r;i+=8)t[i>>5]|=(e[i/8]&255)<<i%32;return t}function R(e,r){var t=(e&65535)+(r&65535),i=(e>>16)+(r>>16)+(t>>16);return i<<16|t&65535}function nt(e,r){return e<<r|e>>>32-r}function X(e,r,t,i,n,o){return R(nt(R(R(r,e),R(i,o)),n),t)}function g(e,r,t,i,n,o,s){return X(r&t|~r&i,e,r,n,o,s)}function h(e,r,t,i,n,o,s){return X(r&i|t&~i,e,r,n,o,s)}function y(e,r,t,i,n,o,s){return X(r^t^i,e,r,n,o,s)}function v(e,r,t,i,n,o,s){return X(t^(r|~i),e,r,n,o,s)}var me=We;var Zt=K("v3",48,me);function it(e,r,t){e=e||{};var i=e.random||(e.rng||Y)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r){t=t||0;for(var n=0;n<16;++n)r[t+n]=i[n];return r}return B(i)}var Q=it;function ot(e,r,t,i){switch(e){case 0:return r&t^~r&i;case 1:return r^t^i;case 2:return r&t^r&i^t&i;case 3:return r^t^i}}function ne(e,r){return e<<r|e>>>32-r}function st(e){var r=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var i=unescape(encodeURIComponent(e));e=[];for(var n=0;n<i.length;++n)e.push(i.charCodeAt(n))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=e.length/4+2,s=Math.ceil(o/16),f=new Array(s),a=0;a<s;++a){for(var d=new Uint32Array(16),u=0;u<16;++u)d[u]=e[a*64+u*4]<<24|e[a*64+u*4+1]<<16|e[a*64+u*4+2]<<8|e[a*64+u*4+3];f[a]=d}f[s-1][14]=(e.length-1)*8/Math.pow(2,32),f[s-1][14]=Math.floor(f[s-1][14]),f[s-1][15]=(e.length-1)*8&4294967295;for(var E=0;E<s;++E){for(var T=new Uint32Array(80),P=0;P<16;++P)T[P]=f[E][P];for(var p=16;p<80;++p)T[p]=ne(T[p-3]^T[p-8]^T[p-14]^T[p-16],1);for(var S=t[0],A=t[1],k=t[2],c=t[3],U=t[4],O=0;O<80;++O){var M=Math.floor(O/20),te=ne(S,5)+ot(M,A,k,c)+U+r[M]+T[O]>>>0;U=c,c=k,k=ne(A,30)>>>0,A=S,S=te}t[0]=t[0]+S>>>0,t[1]=t[1]+A>>>0,t[2]=t[2]+k>>>0,t[3]=t[3]+c>>>0,t[4]=t[4]+U>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var ge=st;var nr=K("v5",80,ge);function ie(e){return[...new Uint8Array(e)].map(r=>r.toString(16).padStart(2,"0")).join("")}function he(e){return new Uint8Array((e.match(/../g)??[]).map(r=>parseInt(r,16)))}function ye(e){let r=0;for(let n of e)r+=n.length;let t=new Uint8Array(r),i=0;for(let n of e)t.set(n,i),i+=n.length;return t}var Oe=qe(Se());function fe(e,r){if((0,Oe.validate)(e,r).length)throw new Error(`couldn't validate schema: ${JSON.stringify(r)} didn't match schema ${JSON.stringify(e)}`)}var Re="3",Me="https://webapp-production-dot-remarkable-production.appspot.com",xt="https://rm-blob-storage-prod.appspot.com",Fe="x-goog-generation",wt="x-goog-if-generation-match",Tt=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],Et=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],Ce={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},Le={sm:50,md:125,rr:180,lg:200},je={df:-1,md:100,lg:150,xl:200},Pt={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}}},Ie={visibleName:{type:"string"},parent:{type:"string"},lastModified:{type:"string"},version:{type:"int32"},synced:{type:"boolean"}},Ue={pinned:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"}},At={discriminator:"type",mapping:{CollectionType:{properties:Ie,optionalProperties:Ue},DocumentType:{properties:Ie,optionalProperties:{...Ue,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},H=class extends Error{constructor(t,i,n){super(n);this.status=t,this.statusText=i}},q=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function kt(e,{deviceDesc:r="desktop-linux",uuid:t=Q(),authUrl:i=Me,fetch:n=globalThis.fetch}={}){if(e.length!==8)throw new Error(`code should be length 8, but was ${e.length}`);let o=await n(`${i}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:e,deviceDesc:r,deviceID:t})});if(o.ok)return await o.text();throw new H(o.status,o.statusText,"couldn't register api")}function St({hash:e,type:r,documentId:t,subfiles:i,size:n}){return`${e}:${r}:${t}:${i}:${n}
|
|
2
|
-
`}function Ot(e){let[r,t,i,n,o]=e.split(":");if(r===void 0||t===void 0||i===void 0||n===void 0||o===void 0)throw new Error(`entries line didn't contain five fields: '${e}'`);if(t==="80000000"){if(o!=="0")throw new Error(`collection type entry had nonzero size: ${o}`);return{hash:r,type:t,documentId:i,subfiles:parseInt(n),size:0n}}else if(t==="0"){if(n!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${n}`);return{hash:r,type:t,documentId:i,subfiles:0,size:BigInt(o)}}else throw new Error(`entries line contained invalid type: ${t}`)}var le=class{constructor(r,t,i,n,o){this.userToken=r;this.fetch=t;this.cache=i;this.subtle=n;this.blobUrl=o}async authedFetch(r,t,i="POST"){let n=await this.fetch(r,{method:i,headers:{Authorization:`Bearer ${this.userToken}`},body:t&&JSON.stringify(t)});if(n.ok)return n;throw new H(n.status,n.statusText,"failed reMarkable request")}async signedFetch({url:r,method:t},i,n){let o=await this.fetch(r,{method:t,body:i,headers:n});if(o.ok)return o;{let s=await o.text();throw new H(o.status,o.statusText,s)}}async getUrl(r,t){let i=t===void 0?"downloads":"uploads",n=t==null?void 0:`${t}`,s=await(await this.authedFetch(`${this.blobUrl}/api/v1/signed-urls/${i}`,{http_method:n===void 0?"GET":"PUT",relative_path:r,generation:n})).text(),f=JSON.parse(s);return fe(Pt,f),f}async syncComplete(){await this.authedFetch(`${this.blobUrl}/api/v1/sync-complete`)}async getRootHash(){let r=await this.getUrl("root"),t=await this.signedFetch(r),i=t.headers.get(Fe);if(!i)throw new Error("no generation header in root hash");return[await t.text(),BigInt(i)]}async putRootHash(r,t){let i=await this.getUrl("root",t),n;try{n=await this.signedFetch(i,r,{[wt]:`${t}`})}catch(s){throw s instanceof H&&s.status===412?new q:s}let o=n.headers.get(Fe);if(!o)throw new Error("no generation header in root hash");return BigInt(o)}async getBuffer(r){let t=await this.getUrl(r);return await(await this.signedFetch(t)).arrayBuffer()}async getText(r){let t=this.cache&&await this.cache.get(r);if(t)return t;{let i=await this.getUrl(r),o=await(await this.signedFetch(i)).text();return this.cache&&await this.cache.set(r,o),o}}async getMetadata(r){let t=await this.getText(r),i=JSON.parse(t);return fe(At,i),i}async getEntries(r){let t=await this.getText(r),[i,...n]=t.slice(0,-1).split(`
|
|
3
|
-
`);if(i!==Re)throw new Error(`got unexpected schema version: ${i}`);return n.map(Ot)}async putHash(r,t){let i=await this.getUrl(r,null);await this.signedFetch(i,t)}async putEntries(r,t){let i=new TextEncoder;t.sort((u,E)=>u.documentId.localeCompare(E.documentId));let n=ye(t.map(u=>he(u.hash))),o=await this.subtle.digest("SHA-256",n),s=ie(o),f=t.map(St).join(""),a=`${Re}
|
|
4
|
-
${f}`,d=i.encode(a);return await this.putHash(s,d),this.cache&&await this.cache.set(s,a),{hash:s,type:"80000000",documentId:r,subfiles:t.length,size:0n}}async putBuffer(r,t){let i=await this.subtle.digest("SHA-256",t),n=ie(i);return await this.putHash(n,t),{hash:n,type:"0",documentId:r,subfiles:0,size:BigInt(t.length)}}async putText(r,t){let i=new TextEncoder,n=await this.putBuffer(r,i.encode(t));return this.cache&&await this.cache.set(n.hash,t),n}async putEpub(r,t,{parent:i="",margins:n=125,orientation:o,textAlignment:s,textScale:f=1,lineHeight:a=-1,fontName:d="",cover:u="visited",lastTool:E,notify:T=!0,retries:P=3}={}){let p=Q(),S=`${new Date().valueOf()}`,A=[];A.push(this.putBuffer(`${p}.epub`,t));let k={type:"DocumentType",visibleName:r,version:0,parent:i,synced:!0,lastModified:S};A.push(this.putText(`${p}.metadata`,JSON.stringify(k)));let c={dummyDocument:!1,extraMetadata:{LastTool:E},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof a=="string"?je[a]:a,margins:typeof n=="string"?Le[n]:n,textScale:typeof f=="string"?Ce[f]:f,pages:[],coverPageNumber:u==="first"?0:-1,formatVersion:1,orientation:o,textAlignment:s,fontName:d};A.push(this.putText(`${p}.content`,JSON.stringify(c)));let U=await Promise.all(A),O=await this.putEntries(p,U);for(;;--P)try{let[M,te]=await this.getRootHash(),ue=await this.getEntries(M);ue.push(O);let{hash:De}=await this.putEntries("",ue);await this.putRootHash(De,te);break}catch(M){if(P<=0||!(M instanceof q))throw M}T&&await this.syncComplete()}};async function Rt(e,{fetch:r=globalThis.fetch,cache:t,subtle:i=globalThis.crypto?.subtle,authUrl:n=Me,blobUrl:o=xt}={}){let s=await r(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!s.ok)throw new Error(`couldn't fetch auth token: ${s.statusText}`);let f=await s.text();return new le(f,r,t,i,o)}return Je(Ft);})();
|