@sketch-hq/sketch-web-renderer 3.2.0 → 3.2.2
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 +19 -0
- package/dist/featureFlags.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/module-debug.wasm +0 -0
- package/dist/module-release.wasm +0 -0
- package/dist/static/js/web-renderer-8addc65e32c7f00a9bf5.chunk.js +1 -0
- package/dist/static/js/web-renderer-8cbabe889ae0a40da834.chunk.js +1 -0
- package/dist/static/js/web-renderer-dcd9a388dd98f28adced.chunk.js +1 -0
- package/dist/ts/Manager.d.ts +21 -11
- package/dist/ts/Manager.d.ts.map +1 -1
- package/dist/ts/SketchWeb.d.ts +25 -15
- package/dist/ts/SketchWeb.d.ts.map +1 -1
- package/dist/ts/react/SketchWebProvider.d.ts.map +1 -1
- package/dist/ts/react/contexts.d.ts +5 -1
- package/dist/ts/react/contexts.d.ts.map +1 -1
- package/dist/ts/react/hooks/actions.d.ts +4 -1
- package/dist/ts/react/hooks/actions.d.ts.map +1 -1
- package/dist/ts/react/hooks/state.d.ts +1 -1
- package/dist/ts/react/hooks/state.d.ts.map +1 -1
- package/dist/ts/react/hooks/useEvent.d.ts +1 -1
- package/dist/ts/react/hooks/useEvent.d.ts.map +1 -1
- package/dist/ts/react/reducer.d.ts.map +1 -1
- package/dist/ts/react/types.d.ts +4 -15
- package/dist/ts/react/types.d.ts.map +1 -1
- package/dist/ts/types/CSSCursor.d.ts +12 -0
- package/dist/ts/types/CSSCursor.d.ts.map +1 -0
- package/dist/ts/types/Events.d.ts +8 -4
- package/dist/ts/types/Events.d.ts.map +1 -1
- package/dist/ts/types/JSBridge.d.ts +8 -0
- package/dist/ts/types/JSBridge.d.ts.map +1 -1
- package/dist/ts/types/PointerInfo.d.ts +11 -0
- package/dist/ts/types/PointerInfo.d.ts.map +1 -0
- package/dist/ts/types/WASM.d.ts +74 -38
- package/dist/ts/types/WASM.d.ts.map +1 -1
- package/dist/ts/utils/GestureManager/GestureManager.d.ts +23 -43
- package/dist/ts/utils/GestureManager/GestureManager.d.ts.map +1 -1
- package/dist/ts/utils/misc.d.ts +0 -1
- package/dist/ts/utils/misc.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/static/js/web-renderer-17fd55cdb979ed59dbc9.chunk.js +0 -1
- package/dist/static/js/web-renderer-b584c7152f956c9cbea5.chunk.js +0 -1
- package/dist/static/js/web-renderer-e4d5f4f314c42815f663.chunk.js +0 -1
- package/dist/ts/utils/CameraMoveTracker/CameraMoveTracker.d.ts +0 -48
- package/dist/ts/utils/CameraMoveTracker/CameraMoveTracker.d.ts.map +0 -1
- package/dist/ts/utils/CameraMoveTracker/CameraMoveTracker.test.d.ts +0 -2
- package/dist/ts/utils/CameraMoveTracker/CameraMoveTracker.test.d.ts.map +0 -1
- package/dist/ts/utils/CameraMoveTracker/index.d.ts +0 -2
- package/dist/ts/utils/CameraMoveTracker/index.d.ts.map +0 -1
- package/dist/ts/utils/GestureManager/GestureManager.test.d.ts +0 -2
- package/dist/ts/utils/GestureManager/GestureManager.test.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(function(){return(()=>{"use strict";var e,t,n={},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var s=2&r&&n;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach((e=>a[e]=()=>n[e]));return a.default=()=>n,o.d(i,a),i},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,n)=>(o.f[n](e,t),t)),[])),o.u=e=>"static/js/web-renderer-"+{610:"17fd55cdb979ed59dbc9",706:"b584c7152f956c9cbea5"}[e]+".chunk.js",o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.p="/",(()=>{var e={667:1};o.f.i=(t,n)=>{e[t]||importScripts(o.p+o.u(t))};var t=self.webpackChunk_sketch_hq_sketch_web_renderer=self.webpackChunk_sketch_hq_sketch_web_renderer||[],n=t.push.bind(t);t.push=t=>{var[r,i,a]=t;for(var s in i)o.o(i,s)&&(o.m[s]=i[s]);for(a&&a(o);r.length;)e[r.pop()]=1;n(t)}})();const i={delayedDraw:!0,useNewTiledRenderer:!0,offscreenCanvas:!1,safariWebGL2:!1,pageBoundariesLimit:!1};var a=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/;function s(e,t){var n;function r(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];clearTimeout(n),n=setTimeout((function(){e.apply(void 0,r)}),t)}return r.cancel=function(){n&&clearTimeout(n)},r}function c(e){for(var t=e.size(),n=[],r=0;r<t;++r){var o=e.get(r);n.push(o)}return n}var u=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){var n,r;this.listeners[e]=null!==(n=this.listeners[e])&&void 0!==n?n:new Set,null===(r=this.listeners[e])||void 0===r||r.add(t)},e.prototype.off=function(e,t){var n;null===(n=this.listeners[e])||void 0===n||n.delete(t)},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=this.listeners[e];(null==r?void 0:r.size)&&r.forEach((function(e){Promise.resolve().then((function(){e.apply(void 0,t)}))}))},e}(),l=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)r[o]=i[a];return r};const d=new(function(){function e(){this.active=!0}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.debug.apply(console,l(["[SketchWeb] [Debug]"],e))},e.prototype.warning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.warn.apply(console,l(["[SketchWeb] [Warn]"],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,l(["[SketchWeb] [Error]"],e))},e}());var h,f,p=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now(),d.debug("[Performance] Start: "+this.label)}return e.prototype.measure=function(){return{duration:performance.now()-this.startTime,end:Date.now(),start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);d.debug("[Performance] End: "+this.label+" -> "+t+" ms")}else{var n=(e/1e3).toFixed(2);d.debug("[Performance] End: "+this.label+" -> "+n+" s")}},e}(),m=(h=function(e,t){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),g=function(e){function t(n,r,o){var i=this.constructor,a=e.call(this,"("+n+") "+r)||this;return a.code=n,a.cause=o,a.name=t.name,Object.setPrototypeOf(a,i.prototype),a}return m(t,e),t}(Error);function v(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}!function(e){e.debug="debug",e.release="release"}(f||(f={}));const b=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function y(e){return e.toLowerCase().replace(/^angle ?\((.+)\)*$/,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"")}const w="undefined"==typeof window,W=(()=>{if(w)return;const{userAgent:e,platform:t,maxTouchPoints:n}=window.navigator,r=/(iphone|ipod|ipad)/i.test(e),o="iPad"===t||"MacIntel"===t&&n>0&&!window.MSStream;return{isIpad:o,isMobile:/android/i.test(e)||r||o,isSafari12:/Version\/12.+Safari/.test(e)}})(),P=[],k=[];function x(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let r=e.length,o=t.length;for(;r>0&&e.charCodeAt(~-r)===t.charCodeAt(~-o);)r--,o--;let i,a=0;for(;a<r&&e.charCodeAt(a)===t.charCodeAt(a);)a++;if(r-=a,o-=a,0===r)return o;let s,c,u=0,l=0,d=0;for(;l<r;)k[l]=e.charCodeAt(a+l),P[l]=++l;for(;d<o;)for(i=t.charCodeAt(a+d),s=d++,u=d,l=0;l<r;l++)c=i===k[l]?s:s+1,s=P[l],u=P[l]=s>u?c>u?u+1:c:c>s?s+1:c;return u}function L(e){return null!=e}class E extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const S=({mobileTiers:e=[0,15,30,60],desktopTiers:t=[0,15,30,60],override:n={},glContext:r,failIfMajorPerformanceCaveat:o=!1,benchmarksURL:i="https://unpkg.com/detect-gpu@4.0.37/dist/benchmarks"}={})=>v(void 0,void 0,void 0,(function*(){const a={};if(w)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==W?void 0:W.isIpad),isMobile:c=!!(null==W?void 0:W.isMobile),screenSize:u=window.screen,loadBenchmarks:l=(e=>v(void 0,void 0,void 0,(function*(){const t=yield fetch(`${i}/${e}`).then((e=>e.json()));if(parseInt(t.shift().split(".")[0],10)<4)throw new E("Detect GPU benchmark data is out of date. Please update to version 4x");return t})))}=n;let{renderer:d}=n;const h=(e,t,n,r,o)=>({device:o,fps:r,gpu:n,isMobile:c,tier:e,type:t});let f,p="";if(d)d=y(d),f=[d];else{const e=r||function(e,t=!1){const n={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:t,powerPreference:"high-performance",stencil:!1};e&&delete n.powerPreference;const r=window.document.createElement("canvas"),o=r.getContext("webgl",n)||r.getContext("experimental-webgl",n);return null!=o?o:void 0}(null==W?void 0:W.isSafari12,o);if(!e)return h(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(t&&(d=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),!d)return h(1,"FALLBACK");p=d,d=y(d),f=function(e,t,n){return"apple gpu"===t?function(e,t,n){if(!n)return[t];const r=function(e){const t=e.createShader(35633),n=e.createShader(35632),r=e.createProgram();if(!(n&&t&&r))return;e.shaderSource(t,"\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n "),e.shaderSource(n,"\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n "),e.compileShader(t),e.compileShader(n),e.attachShader(r,t),e.attachShader(r,n),e.linkProgram(r),e.detachShader(r,t),e.detachShader(r,n),e.deleteShader(t),e.deleteShader(n),e.useProgram(r);const o=e.createBuffer();e.bindBuffer(34962,o),e.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const i=e.getAttribLocation(r,"aPosition");e.vertexAttribPointer(i,3,5126,!1,0,0),e.enableVertexAttribArray(i),e.clearColor(1,1,1,1),e.clear(16384),e.viewport(0,0,1,1),e.drawArrays(4,0,3);const a=new Uint8Array(4);return e.readPixels(0,0,1,1,6408,5121,a),e.deleteProgram(r),e.deleteBuffer(o),a.join("")}(e),o="801621810",i="8016218135",a="80162181161",s=(null==W?void 0:W.isIpad)?[["a7",a,12],["a8",i,15],["a8x",i,15],["a9",i,15],["a9x",i,15],["a10",i,15],["a10x",i,15],["a12",o,15],["a12x",o,15],["a12z",o,15],["a14",o,15],["m1",o,15]]:[["a7",a,12],["a8",i,12],["a9",i,15],["a10",i,15],["a11",o,15],["a12",o,15],["a13",o,15],["a14",o,15]];let c;return"80162181255"===r?c=s.filter((([,,e])=>e>=14)):(c=s.filter((([,e])=>e===r)),c.length||(c=s)),c.map((([e])=>`apple ${e} gpu`))}(e,t,n):[t]}(e,d,c)}const m=(yield Promise.all(f.map((function(e){var t;return v(this,void 0,void 0,(function*(){const n=(e=>{const t=c?["adreno","apple","mali-t","mali","nvidia","powervr"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const r=`${c?"m":"d"}-${n}${s?"-ipad":""}.json`,o=a[r]=null!==(t=a[r])&&void 0!==t?t:l(r);let i;try{i=yield o}catch(n){if(n instanceof E)throw n;return}const d=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let h=i.filter((([,e])=>e===d));h.length||(h=i.filter((([t])=>t.includes(e))));const f=h.length;if(0===f)return;let p,[m,,,g]=f>1?h.map((t=>[t,x(e,t[0])])).sort((([,e],[,t])=>e-t))[0][0]:h[0],v=Number.MAX_VALUE;const{devicePixelRatio:b}=window,y=u.width*b*u.height*b;for(const e of g){const[t,n]=e,r=t*n,o=Math.abs(y-r);o<v&&(v=o,p=e)}if(!p)return;const[,,w,W]=p;return[v,w,m,W]}))})))).filter(L).sort((([e=Number.MAX_VALUE,t],[n=Number.MAX_VALUE,r])=>e===n?t-r:e-n));if(!m.length){const e=b.find((e=>d.includes(e)));return e?h(0,"BLOCKLISTED",e):h(1,"FALLBACK",`${d} (${p})`)}const[,g,P,k]=m[0];if(-1===g)return h(0,"BLOCKLISTED",P,g,k);const S=c?e:t;let C=0;for(let e=0;e<S.length;e++)g>=S[e]&&(C=e);return h(C,"BENCHMARK",P,g,k)}));var C=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),R=function(){return(R=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},A=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))},D=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},I=(globalThis.indexedDB,function(e){function t(t){var n=t.canvas,r=t.locateFile,o=t.filePath,c=t.imagesURLFormat,u=t.imagesURLMap,l=t.backgroundColor,h=void 0===l?{r:1,g:1,b:1,a:1}:l,m=t.size,g=t.pixelRatio,v=t.mode,b=t.showTilesBorders,y=void 0!==b&&b,w=t.minimumZoomLevel,W=t.maximumZoomLevel,P=t.preserveDrawingBuffer,k=void 0!==P&&P,x=t.panBoundariesPadding,L=void 0===x?40:x,E=t.featureFlags,S=void 0===E?{}:E,C=e.call(this)||this;return C.status={type:"INIT"},C.isZooming=!1,C.handleWebGLContextLost=function(){C.setStatus({type:"WEBGL_CONTEXT_LOST"})},C.debouncedFullDraw=s((function(){return C.draw(!0)}),60),C.notifyZoomDidEndDebounced=s((function(){var e;C.isZooming&&(C.isZooming=!1,null===(e=C.sketchWebWasm)||void 0===e||e.setIsZooming(!1),C.delayedDraw())}),80),C.canvas=n,C.locateFile=r,C.filePath=o,C.imagesURLFormat=c,C.imagesURLMap=u,C.backgroundColor=h,C.size=m,C.pixelRatio=g,C.mode=v,C.showTilesBorders=y,C.currentWebGLVersion=function(e){if(void 0===e&&(e=window.navigator.userAgent),e.includes("Chrome/")||e.includes("Chromium/")||e.includes("Opera/")||e.includes("Firefox/"))return null;var t=e.match(a);if(!t)return null;var n=t[1];return"Macintosh"!==n&&"iPad"!==n&&"iPhone"!==n?null:{hardware:n,version:{major:parseInt(t[4])||0,minor:parseInt(t[5])||0,patch:parseInt(t[6])||0}}}()&&!i.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1,C.zoomLevels={min:w,max:W},C.preserveDrawingBuffer=k,C.panBoundariesPadding=L,C.featureFlags=R(R({},i),S),d.active=v===f.debug,C.traceFirstPaint=new p("FirstPaint"),C}return C(t,e),t.prototype.collectAndEmitDeviceInfo=function(){return A(this,void 0,void 0,(function(){var e;return D(this,(function(t){switch(t.label){case 0:return[4,S()];case 1:return e=t.sent(),this.deviceInfo=R(R({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.init=function(){return A(this,void 0,void 0,(function(){var e;return D(this,(function(t){switch(t.label){case 0:this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),t.label=1;case 1:return t.trys.push([1,5,,6]),[4,this.initSketchWebWasm()];case 2:return t.sent(),[4,this.setFile(this.filePath)];case 3:return t.sent(),[4,this.preloadImages()];case 4:return t.sent(),[3,6];case 5:return e=t.sent(),[2,this.fail(e instanceof g?e:new g("ERROR","Unexpected exception initializing the web renderer",e))];case 6:return[2]}}))}))},t.prototype.preloadImages=function(){var e=this;return new Promise((function(t){var n;null===(n=e.sketchWebWasm)||void 0===n||n.preloadImages((function(){t()}))}))},t.prototype.startRendering=function(){this.traceInitialRender=new p("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),this.draw(!0,!1),this.sketchWebWasm.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){d.debug("[C++] "+e)},logWarning:function(e){d.warning("[C++] "+e)},logError:function(e){d.error("[C++] "+e)},emitMetric:function(t,n,r,o){e.emit("metric",{id:t,start:n,end:r,duration:o})},resolveImageUrl:function(t){return e.imagesURLFormat?e.imagesURLFormat.replace(":imageId",t):e.imagesURLMap&&e.imagesURLMap[t]?e.imagesURLMap[t]:(d.warning("Not able to resolve the url for the image with UUID: "+t),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")}}},t.prototype.downloadImages=function(){var e=this;return new Promise((function(t){var n,r=new p("ImagesDownload");null===(n=e.sketchWebWasm)||void 0===n||n.downloadImages((function(){r.printMeasurement(),e.emit("metric",r.measure()),d.debug("Images downloaded"),t()}))}))},t.prototype.initSketchWebWasm=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i,a,s,c=this;return D(this,(function(u){switch(u.label){case 0:return e=new p("WasmModuleDownload"),this.mode!==f.debug?[3,2]:[4,o.e(706).then(o.t.bind(o,706,23))];case 1:return t=u.sent(),[3,4];case 2:return[4,o.e(610).then(o.t.bind(o,610,23))];case 3:t=u.sent(),u.label=4;case 4:n=t.default,u.label=5;case 5:return u.trys.push([5,7,,8]),r=this,[4,n({FeatureFlags:this.featureFlags,currentWebGLVersion:this.currentWebGLVersion,locateFile:function(e){return c.locateFile.replace("{file}",e)},bridge:this.createJSBridge()})];case 6:return r.wasmModule=u.sent(),[3,8];case 7:throw i=u.sent(),new g("WASM_ERROR","An error occurred while trying to create the wasm module.",i);case 8:if(e.printMeasurement(),this.emit("metric",e.measure()),a={majorVersion:this.currentWebGLVersion,antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:this.preserveDrawingBuffer},d.debug("Using WebGL "+a.majorVersion),!(s=this.wasmModule.GL.createContext(this.canvas,a)))throw new g("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");this.webglCtxHandle=s;try{this.sketchWebWasm=this.wasmModule.SketchWeb.MakeGL(this.webglCtxHandle,this.canvas.width,this.size.height,this.pixelRatio,{showTilesBorders:this.showTilesBorders})}catch(e){throw new g("WASM_ERROR","An error occurred while trying to create the SketchWebWasm object.",e)}return this.sketchWebWasm.setBackgroundColor(this.backgroundColor.r,this.backgroundColor.g,this.backgroundColor.b,this.backgroundColor.a),this.sketchWebWasm.setZoomLevels(this.zoomLevels.min,this.zoomLevels.max),this.sketchWebWasm.setPanBoundariesPadding(this.panBoundariesPadding),this.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost),[2]}}))}))},t.prototype.setBackgroundColor=function(e){var t;e.r===this.backgroundColor.r&&e.g===this.backgroundColor.g&&e.b===this.backgroundColor.b&&e.a===this.backgroundColor.a||(null===(t=this.sketchWebWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.backgroundColor=e,this.delayedDraw())},t.prototype.generateDocumentPNG=function(){return A(this,void 0,void 0,(function(){return D(this,(function(e){switch(e.label){case 0:return[4,this.downloadImages()];case 1:return e.sent(),[2,this.sketchWebWasm.generateDocumentPNG()]}}))}))},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.traceInitialRender.printMeasurement(),this.emit("metric",this.traceInitialRender.measure()),this.traceFirstPaint.printMeasurement(),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}),this.downloadImages())},t.prototype.looseWebGLContext=function(){var e=this.wasmModule.GL.getContext(this.webglCtxHandle);if(e){var t=e.GLctx.getExtension("WEBGL_lose_context");t?t.loseContext():console.warn("Unable to retrieve WEBGL_lose_context extension")}else console.warn("Unable to loose context. WebGL rendering context not found")},t.prototype.scaleDocumentToFit=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.scaleDocumentToFit(),this.delayedDraw()},t.prototype.setFile=function(e){return A(this,void 0,void 0,(function(){var t=this;return D(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,r){t.sketchWebWasm.setFile(e,(function(e,r,o,i){if(void 0===i&&(i=[]),i.length){d.debug("Parser warnings: "+i);var a=i.map((function(e){return{key:e}}));t.emit("warnings",a)}t.setStatus({type:"FILE_READY"}),t.emit("fileReady",t.getDocument(),e,r,o),n()}),(function(){return r(new g("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},t.prototype.delayedDraw=function(){if(!this.featureFlags.delayedDraw)return this.draw(!0);this.draw(),this.debouncedFullDraw()},t.prototype.draw=function(e,t){var n;void 0===e&&(e=!1),void 0===t&&(t=!1),null===(n=this.sketchWebWasm)||void 0===n||n.setNeedsUpdate(e,t)},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:e.toString()+(e.cause?"\nWrapped Error: "+e.cause.toString():"")}),d.error(e),e.cause&&d.error(e.cause)},t.prototype.setPixelRatio=function(e){this.pixelRatio=e,this.setSize(this.size.width*this.pixelRatio,this.size.height*this.pixelRatio,this.pixelRatio),this.delayedDraw()},t.prototype.setSize=function(e,t,n){var r;this.size.width=e*n,this.size.height=t*n,this.canvas.width=e*n,this.canvas.height=t*n,null===(r=this.sketchWebWasm)||void 0===r||r.resize(e,t,n)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(d.debug("Status transition "+this.status.type+" => "+e.type+"}"),this.status=e,this.emit("status",e))},t.prototype.getDocument=function(){if(!this.sketchWebWasm)return null;if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.filePath){var e=this.sketchWebWasm.getPRFile();this.cachedDocumentInfo={filePath:this.filePath,document:R(R({},e),{artboards:c(e.artboards)})}}return this.cachedDocumentInfo.document},t.prototype.getArtboardAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getArtboardAtPosition(e,t)},t.prototype.getPanAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getPanAtPosition(e,t)},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){var n,r;null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(r=this.sketchWebWasm)||void 0===r||r.setZoom(e),this.delayedDraw()},t.prototype.addZoom=function(e,t){var n,r;this.notifyZoomDidStart(),null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(r=this.sketchWebWasm)||void 0===r||r.addZoom(e),this.notifyZoomDidEndDebounced(),this.delayedDraw()},t.prototype.notifyZoomDidStart=function(){var e;this.isZooming||(this.isZooming=!0,null===(e=this.sketchWebWasm)||void 0===e||e.setIsZooming(!0))},t.prototype.setPan=function(e,t,n){var r;void 0===n&&(n=!1),null===(r=this.sketchWebWasm)||void 0===r||r.setPan(e,t,n),this.delayedDraw()},t.prototype.addPan=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.addPan(e,t),this.delayedDraw()},t.prototype.getPan=function(){if(this.sketchWebWasm)return this.sketchWebWasm.getPan()},t.prototype.getZoom=function(){var e;return null===(e=this.sketchWebWasm)||void 0===e?void 0:e.getZoom()},t.prototype.setMouse=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.setMouse(e,t)},t.prototype.setIsCameraMoving=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.setIsCameraMoving(e)},t.prototype.dispose=function(){var e,t;try{null===(e=this.sketchWebWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.sketchWebWasm)||void 0===t||t.delete(),this.looseWebGLContext(),this.sketchWebWasm=null,this.wasmModule=null}catch(e){this.fail(new g("ERROR","Unexpected exception while disposing the SketchWebWasm object",e))}},t}(u));const _=Symbol("Comlink.proxy"),M=Symbol("Comlink.endpoint"),O=Symbol("Comlink.releaseProxy"),j=Symbol("Comlink.thrown"),F=e=>"object"==typeof e&&null!==e||"function"==typeof e,T=new Map([["proxy",{canHandle:e=>F(e)&&e[_],serialize(e){const{port1:t,port2:n}=new MessageChannel;return G(e,t),[n,[n]]},deserialize:e=>(e.start(),N(e,[],undefined))}],["throw",{canHandle:e=>F(e)&&j in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function G(e,t=self){t.addEventListener("message",(function n(r){if(!r||!r.data)return;const{id:o,type:i,path:a}=Object.assign({path:[]},r.data),s=(r.data.argumentList||[]).map(V);let c;try{const t=a.slice(0,-1).reduce(((e,t)=>e[t]),e),n=a.reduce(((e,t)=>e[t]),e);switch(i){case"GET":c=n;break;case"SET":t[a.slice(-1)[0]]=V(r.data.value),c=!0;break;case"APPLY":c=n.apply(t,s);break;case"CONSTRUCT":c=function(e){return Object.assign(e,{[_]:!0})}(new n(...s));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;G(e,n),c=function(e,t){return Z.set(e,t),e}(t,[t])}break;case"RELEASE":c=void 0;break;default:return}}catch(e){c={value:e,[j]:0}}Promise.resolve(c).catch((e=>({value:e,[j]:0}))).then((e=>{const[r,a]=$(e);t.postMessage(Object.assign(Object.assign({},r),{id:o}),a),"RELEASE"===i&&(t.removeEventListener("message",n),B(t))}))})),t.start&&t.start()}function B(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function U(e){if(e)throw new Error("Proxy has been released and is not useable")}function N(e,t=[],n=function(){}){let r=!1;const o=new Proxy(n,{get(n,i){if(U(r),i===O)return()=>H(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{B(e),r=!0}));if("then"===i){if(0===t.length)return{then:()=>o};const n=H(e,{type:"GET",path:t.map((e=>e.toString()))}).then(V);return n.then.bind(n)}return N(e,[...t,i])},set(n,o,i){U(r);const[a,s]=$(i);return H(e,{type:"SET",path:[...t,o].map((e=>e.toString())),value:a},s).then(V)},apply(n,o,i){U(r);const a=t[t.length-1];if(a===M)return H(e,{type:"ENDPOINT"}).then(V);if("bind"===a)return N(e,t.slice(0,-1));const[s,c]=z(i);return H(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:s},c).then(V)},construct(n,o){U(r);const[i,a]=z(o);return H(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:i},a).then(V)}});return o}function z(e){const t=e.map($);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const Z=new WeakMap;function $(e){for(const[t,n]of T)if(n.canHandle(e)){const[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},Z.get(e)||[]]}function V(e){switch(e.type){case"HANDLER":return T.get(e.name).deserialize(e.value);case"RAW":return e.value}}function H(e,t,n){return new Promise((r=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===o&&(e.removeEventListener("message",t),r(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),n)}))}return G(I),{}})()}));
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Class to track if the camera should be considered as moving based on the pan/zoom
|
|
3
|
-
* events coming in. This information is then used by the web renderer to be able
|
|
4
|
-
* to know if a click/hover event on an artboard should be ignored because it happened
|
|
5
|
-
* while the user just wanted to move the camera.
|
|
6
|
-
*
|
|
7
|
-
* We need to track this because users clicks are sometimes not very precise and can
|
|
8
|
-
* involve a bit of mouse movement that could be interpreted as a macro pan/zoom movement.
|
|
9
|
-
* It is hard to be 100% sure what is the user intention (interact with artboard vs move camera)
|
|
10
|
-
* by looking at just one event. For that reason, we look at a short time frame
|
|
11
|
-
* to detect if a pan/zoom event is the start or the end of a camera move or if it
|
|
12
|
-
* should be ignored:
|
|
13
|
-
* - The first event we receive is the start of a new interaction but not necessarily of a camera move.
|
|
14
|
-
* The first 20ms following this first event are considered as "wait and see" time where the interaction
|
|
15
|
-
* could potentially be the start of a camera move but we are not sure yet. Other events could be received
|
|
16
|
-
* during those first 20ms but that does not confirm the camera move.
|
|
17
|
-
* - If we receive at least one event after those first 20ms but before the end of the interaction
|
|
18
|
-
* (100ms after last event), we can finally consider the interaction as a camera move and onCameraMoveStart()
|
|
19
|
-
* callback is called. Once we consider the camera moving, other events would not trigger other calls to
|
|
20
|
-
* onCameraMoveStart, and this until the interaction is ended and a new one can start.
|
|
21
|
-
* - We consider an interaction as ended when we haven't received any new events in the 100ms
|
|
22
|
-
* following the last received event. When ending the interaction, if onCameraMoveStart callback
|
|
23
|
-
* was called during that interaction, we also call the onCameraMoveEnd callback. Once ended,
|
|
24
|
-
* any new event received would start a new interaction and restart the process described here.
|
|
25
|
-
*/
|
|
26
|
-
export declare class CameraMoveTracker {
|
|
27
|
-
private onCameraMoveStart;
|
|
28
|
-
private onCameraMoveEnd;
|
|
29
|
-
private cameraMoveState;
|
|
30
|
-
constructor(onCameraMoveStart: () => void, onCameraMoveEnd: () => void);
|
|
31
|
-
/** Class destructor we need to manually call when disposing of everything */
|
|
32
|
-
dispose(): void;
|
|
33
|
-
/**
|
|
34
|
-
* For each camera events received (zoom or pan), check if this
|
|
35
|
-
* is the start of a camera move interaction and
|
|
36
|
-
* start or postpone the "end of interaction" by 100ms more.
|
|
37
|
-
*/
|
|
38
|
-
handleCameraMoveEvent(): void;
|
|
39
|
-
private setCameraMoveStatus;
|
|
40
|
-
/**
|
|
41
|
-
* Because the function is wrapped in debounce, this function
|
|
42
|
-
* is executed CAMERA_INACTIVE_DELAY ms after its last
|
|
43
|
-
* call, i.e. after the last camera move related event
|
|
44
|
-
* has been received.
|
|
45
|
-
*/
|
|
46
|
-
private endInteractionDebounced;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=CameraMoveTracker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CameraMoveTracker.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/CameraMoveTracker/CameraMoveTracker.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,iBAAiB,CAAY;IACrC,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,eAAe,CAA0C;gBAErD,iBAAiB,EAAE,MAAM,IAAI,EAAE,eAAe,EAAE,MAAM,IAAI;IAKtE,6EAA6E;IACtE,OAAO;IAOd;;;;OAIG;IACI,qBAAqB;IAoB5B,OAAO,CAAC,mBAAmB;IAe3B;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB,CAWN;CAC1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CameraMoveTracker.test.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/CameraMoveTracker/CameraMoveTracker.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/CameraMoveTracker/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GestureManager.test.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/GestureManager/GestureManager.test.ts"],"names":[],"mappings":""}
|