@reactunity/scripts 0.6.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- function createUnityInstance(e,r,t){function n(e,t){if(!n.aborted&&r.showBanner)return"error"==t&&(n.aborted=!0),r.showBanner(e,t);switch(t){case"error":console.error(e);break;case"warning":console.warn(e);break;default:console.log(e)}}function o(e){var r=e.reason||e.error,t=r?r.toString():e.message||e.reason||"",n=r&&r.stack?r.stack.toString():"";if(n.startsWith(t)&&(n=n.substring(t.length)),t+="\n"+n.trim(),t&&c.stackTraceRegExp&&c.stackTraceRegExp.test(t)){var o=e.filename||r&&(r.fileName||r.sourceURL)||"",a=e.lineno||r&&(r.lineNumber||r.line)||0;s(t,o,a)}}function a(e){e.preventDefault()}function s(e,r,t){if(e.indexOf("fullscreen error")==-1){if(c.startupErrorHandler)return void c.startupErrorHandler(e,r,t);if(!(c.errorHandler&&c.errorHandler(e,r,t)||(console.log("Invoking error handler due to\n"+e),"function"==typeof dump&&dump("Invoking error handler due to\n"+e),s.didShowErrorMessage))){var e="An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:\n"+e;e.indexOf("DISABLE_EXCEPTION_CATCHING")!=-1?e="An exception has occurred, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project WebGL player settings to be able to catch the exception or see the stack trace.":e.indexOf("Cannot enlarge memory arrays")!=-1?e="Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings.":e.indexOf("Invalid array buffer length")==-1&&e.indexOf("Invalid typed array length")==-1&&e.indexOf("out of memory")==-1&&e.indexOf("could not allocate memory")==-1||(e="The browser could not allocate enough memory for the WebGL content. If you are the developer of this content, try allocating less memory to your WebGL build in the WebGL player settings."),alert(e),s.didShowErrorMessage=!0}}}function i(e,r){if("symbolsUrl"!=e){var n=c.downloadProgress[e];n||(n=c.downloadProgress[e]={started:!1,finished:!1,lengthComputable:!1,total:0,loaded:0}),"object"!=typeof r||"progress"!=r.type&&"load"!=r.type||(n.started||(n.started=!0,n.lengthComputable=r.lengthComputable,n.total=r.total),n.loaded=r.loaded,"load"==r.type&&(n.finished=!0));var o=0,a=0,s=0,i=0,d=0;for(var e in c.downloadProgress){var n=c.downloadProgress[e];if(!n.started)return 0;s++,n.lengthComputable?(o+=n.loaded,a+=n.total,i++):n.finished||d++}var l=s?(s-d-(a?i*(a-o)/a:0))/s:0;t(.9*l)}}function d(e){return new Promise(function(r,t){i(e);var o=c.companyName&&c.productName?new c.XMLHttpRequest({companyName:c.companyName,productName:c.productName,cacheControl:c.cacheControl(c[e])}):new XMLHttpRequest;o.open("GET",c[e]),o.responseType="arraybuffer",o.addEventListener("progress",function(r){i(e,r)}),o.addEventListener("load",function(t){i(e,t),r(new Uint8Array(o.response))}),o.addEventListener("error",function(r){var t="Failed to download file "+c[e];"file:"==location.protocol?n(t+". Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.","error"):console.error(t)}),o.send()})}function l(){return new Promise(function(e,r){var t=document.createElement("script");t.src=c.frameworkUrl,t.onload=function(){if("undefined"==typeof unityFramework||!unityFramework){var r=[["br","br"],["gz","gzip"]];for(var o in r){var a=r[o];if(c.frameworkUrl.endsWith("."+a[0])){var s="Unable to parse "+c.frameworkUrl+"!";if("file:"==location.protocol)return void n(s+" Loading pre-compressed (brotli or gzip) content via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host compressed Unity content, or use the Unity Build and Run option.","error");if(s+=' This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: '+a[1]+'" present. Check browser Console and Devtools Network tab to debug.',"br"==a[0]&&"http:"==location.protocol){var i=["localhost","127.0.0.1"].indexOf(location.hostname)!=-1?"":"Migrate your server to use HTTPS.";s=/Firefox/.test(navigator.userAgent)?"Unable to parse "+c.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported in Firefox over HTTP connections. '+i+' See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1670675">https://bugzilla.mozilla.org/show_bug.cgi?id=1670675</a> for more information.':"Unable to parse "+c.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate your server to use HTTPS.'}return void n(s,"error")}}n("Unable to parse "+c.frameworkUrl+"! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)","error")}var d=unityFramework;unityFramework=null,t.onload=null,e(d)},t.onerror=function(e){n("Unable to load file "+c.frameworkUrl+"! Check that the file exists on the remote server. (also check browser Console and Devtools Network tab to debug)","error")},document.body.appendChild(t),c.deinitializers.push(function(){document.body.removeChild(t)})})}function u(){l().then(function(e){e(c)});var e=d("dataUrl");c.preRun.push(function(){c.addRunDependency("dataUrl"),e.then(function(e){var r=new DataView(e.buffer,e.byteOffset,e.byteLength),t=0,n="UnityWebData1.0\0";if(!String.fromCharCode.apply(null,e.subarray(t,t+n.length))==n)throw"unknown data format";t+=n.length;var o=r.getUint32(t,!0);for(t+=4;t<o;){var a=r.getUint32(t,!0);t+=4;var s=r.getUint32(t,!0);t+=4;var i=r.getUint32(t,!0);t+=4;var d=String.fromCharCode.apply(null,e.subarray(t,t+i));t+=i;for(var l=0,u=d.indexOf("/",l)+1;u>0;l=u,u=d.indexOf("/",l)+1)c.FS_createPath(d.substring(0,l),d.substring(l,u-1),!0,!0);c.FS_createDataFile(d,null,e.subarray(a,a+s),!0,!0,!0)}c.removeRunDependency("dataUrl")})})}t=t||function(){};var c={canvas:e,webglContextAttributes:{preserveDrawingBuffer:!1},cacheControl:function(e){return e==c.dataUrl?"must-revalidate":"no-store"},streamingAssetsUrl:"StreamingAssets",downloadProgress:{},deinitializers:[],intervals:{},setInterval:function(e,r){var t=window.setInterval(e,r);return this.intervals[t]=!0,t},clearInterval:function(e){delete this.intervals[e],window.clearInterval(e)},preRun:[],postRun:[],print:function(e){console.log(e)},printErr:function(e){console.error(e),"string"==typeof e&&e.indexOf("wasm streaming compile failed")!=-1&&(e.toLowerCase().indexOf("mime")!=-1?n('HTTP Response Header "Content-Type" configured incorrectly on the server for file '+c.codeUrl+' , should be "application/wasm". Startup time performance will suffer.',"warning"):n('WebAssembly streaming compilation failed! This can happen for example if "Content-Encoding" HTTP header is incorrectly enabled on the server for file '+c.codeUrl+", but the file is not pre-compressed on disk (or vice versa). Check the Network tab in browser Devtools to debug server header configuration.","warning"))},locateFile:function(e){return"build.wasm"==e?this.codeUrl:e},disabledCanvasEvents:["contextmenu","dragstart"]};for(var f in r)c[f]=r[f];c.streamingAssetsUrl=new URL(c.streamingAssetsUrl,document.URL).href;var p=c.disabledCanvasEvents.slice();p.forEach(function(r){e.addEventListener(r,a)}),window.addEventListener("error",o),window.addEventListener("unhandledrejection",o);var h={Module:c,SetFullscreen:function(){return c.SetFullscreen?c.SetFullscreen.apply(c,arguments):void c.print("Failed to set Fullscreen mode: Player not loaded yet.")},SendMessage:function(){return c.SendMessage?c.SendMessage.apply(c,arguments):void c.print("Failed to execute SendMessage: Player not loaded yet.")},Quit:function(){return new Promise(function(r,t){c.shouldQuit=!0,c.onQuit=r,p.forEach(function(r){e.removeEventListener(r,a)}),window.removeEventListener("error",o),window.removeEventListener("unhandledrejection",o)})}};return c.SystemInfo=function(){function e(e,r,t){return e=RegExp(e,"i").exec(r),e&&e[t]}for(var r,t,n,o,a,s,i=navigator.userAgent+" ",d=[["Firefox","Firefox"],["OPR","Opera"],["Edg","Edge"],["SamsungBrowser","Samsung Browser"],["Trident","Internet Explorer"],["MSIE","Internet Explorer"],["Chrome","Chrome"],["CriOS","Chrome on iOS Safari"],["FxiOS","Firefox on iOS Safari"],["Safari","Safari"]],l=0;l<d.length;++l)if(t=e(d[l][0]+"[/ ](.*?)[ \\)]",i,1)){r=d[l][1];break}"Safari"==r&&(t=e("Version/(.*?) ",i,1)),"Internet Explorer"==r&&(t=e("rv:(.*?)\\)? ",i,1)||t);for(var u=[["Windows (.*?)[;)]","Windows"],["Android ([0-9_.]+)","Android"],["iPhone OS ([0-9_.]+)","iPhoneOS"],["iPad.*? OS ([0-9_.]+)","iPadOS"],["FreeBSD( )","FreeBSD"],["OpenBSD( )","OpenBSD"],["Linux|X11()","Linux"],["Mac OS X ([0-9_.]+)","macOS"],["bot|google|baidu|bing|msn|teoma|slurp|yandex","Search Bot"]],c=0;c<u.length;++c)if(o=e(u[c][0],i,1)){n=u[c][1],o=o.replace(/_/g,".");break}var f={"NT 5.0":"2000","NT 5.1":"XP","NT 5.2":"Server 2003","NT 6.0":"Vista","NT 6.1":"7","NT 6.2":"8","NT 6.3":"8.1","NT 10.0":"10"};o=f[o]||o,a=document.createElement("canvas"),a&&(gl=a.getContext("webgl2"),glVersion=gl?2:0,gl||(gl=a&&a.getContext("webgl"))&&(glVersion=1),gl&&(s=gl.getExtension("WEBGL_debug_renderer_info")&&gl.getParameter(37446)||gl.getParameter(7937)));var p="undefined"!=typeof SharedArrayBuffer,h="object"==typeof WebAssembly&&"function"==typeof WebAssembly.compile;return{width:screen.width,height:screen.height,userAgent:i.trim(),browser:r||"Unknown browser",browserVersion:t||"Unknown version",mobile:/Mobile|Android|iP(ad|hone)/.test(navigator.appVersion),os:n||"Unknown OS",osVersion:o||"Unknown OS Version",gpu:s||"Unknown GPU",language:navigator.userLanguage||navigator.language,hasWebGL:glVersion,hasCursorLock:!!document.body.requestPointerLock,hasFullscreen:!!document.body.requestFullscreen||!!document.body.webkitRequestFullscreen,hasThreads:p,hasWasm:h,hasWasmThreads:function(){var e=h&&p&&new WebAssembly.Memory({initial:1,maximum:1,shared:!0});return e&&e.buffer instanceof SharedArrayBuffer}()}}(),c.abortHandler=function(e){return s(e,"",0),!0},Error.stackTraceLimit=Math.max(Error.stackTraceLimit||0,50),c.XMLHttpRequest=function(){function e(e){console.log("[UnityCache] "+e)}function r(e){return r.link=r.link||document.createElement("a"),r.link.href=e,r.link.href}function t(e){var r=window.location.href.match(/^[a-z]+:\/\/[^\/]+/);return!r||e.lastIndexOf(r[0],0)}function n(){function r(r){if("undefined"==typeof n.database)for(n.database=r,n.database||e("indexedDB database could not be opened");n.queue.length;){var t=n.queue.shift();n.database?n.execute.apply(n,t):"function"==typeof t.onerror&&t.onerror(new Error("operation cancelled"))}}function t(){var e=o.open(s.name,s.version);e.onupgradeneeded=function(e){var r=e.target.result;r.objectStoreNames.contains(d.name)||r.createObjectStore(d.name)},e.onsuccess=function(e){r(e.target.result)},e.onerror=function(){r(null)}}var n=this;n.queue=[];try{var o=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,a=o.open(s.name);a.onupgradeneeded=function(e){var r=e.target.result.createObjectStore(i.name,{keyPath:"url"});["version","company","product","updated","revalidated","accessed"].forEach(function(e){r.createIndex(e,e)})},a.onsuccess=function(e){var n=e.target.result;n.version<s.version?(n.close(),t()):r(n)},a.onerror=function(){r(null)}}catch(e){r(null)}}function o(e,r,t,n,o){var a={url:e,version:i.version,company:r,product:t,updated:n,revalidated:n,accessed:n,responseHeaders:{},xhr:{}};return o&&(["Last-Modified","ETag"].forEach(function(e){a.responseHeaders[e]=o.getResponseHeader(e)}),["responseURL","status","statusText","response"].forEach(function(e){a.xhr[e]=o[e]})),a}function a(r){this.cache={enabled:!1},r&&(this.cache.control=r.cacheControl,this.cache.company=r.companyName,this.cache.product=r.productName),this.xhr=new XMLHttpRequest(r),this.xhr.addEventListener("load",function(){var r=this.xhr,t=this.cache;t.enabled&&!t.revalidated&&(304==r.status?(t.result.revalidated=t.result.accessed,t.revalidated=!0,l.execute(i.name,"put",[t.result]),e("'"+t.result.url+"' successfully revalidated and served from the indexedDB cache")):200==r.status?(t.result=o(t.result.url,t.company,t.product,t.result.accessed,r),t.revalidated=!0,l.execute(i.name,"put",[t.result],function(r){e("'"+t.result.url+"' successfully downloaded and stored in the indexedDB cache")},function(r){e("'"+t.result.url+"' successfully downloaded but not stored in the indexedDB cache due to the error: "+r)})):e("'"+t.result.url+"' request failed with status: "+r.status+" "+r.statusText))}.bind(this))}var s={name:"UnityCache",version:2},i={name:"XMLHttpRequest",version:1},d={name:"WebAssembly",version:1};n.prototype.execute=function(e,r,t,n,o){if(this.database)try{var a=this.database.transaction([e],["put","delete","clear"].indexOf(r)!=-1?"readwrite":"readonly").objectStore(e);"openKeyCursor"==r&&(a=a.index(t[0]),t=t.slice(1));var s=a[r].apply(a,t);"function"==typeof n&&(s.onsuccess=function(e){n(e.target.result)}),s.onerror=o}catch(e){"function"==typeof o&&o(e)}else"undefined"==typeof this.database?this.queue.push(arguments):"function"==typeof o&&o(new Error("indexedDB access denied"))};var l=new n;a.prototype.send=function(r){var n=this.xhr,o=this.cache,a=arguments;return o.enabled=o.enabled&&"arraybuffer"==n.responseType&&!r,o.enabled?void l.execute(i.name,"get",[o.result.url],function(r){if(!r||r.version!=i.version)return void n.send.apply(n,a);if(o.result=r,o.result.accessed=Date.now(),"immutable"==o.control)o.revalidated=!0,l.execute(i.name,"put",[o.result]),n.dispatchEvent(new Event("load")),e("'"+o.result.url+"' served from the indexedDB cache without revalidation");else if(t(o.result.url)&&(o.result.responseHeaders["Last-Modified"]||o.result.responseHeaders.ETag)){var s=new XMLHttpRequest;s.open("HEAD",o.result.url),s.onload=function(){o.revalidated=["Last-Modified","ETag"].every(function(e){return!o.result.responseHeaders[e]||o.result.responseHeaders[e]==s.getResponseHeader(e)}),o.revalidated?(o.result.revalidated=o.result.accessed,l.execute(i.name,"put",[o.result]),n.dispatchEvent(new Event("load")),e("'"+o.result.url+"' successfully revalidated and served from the indexedDB cache")):n.send.apply(n,a)},s.onerror=function(){n.send.apply(n,a)},s.send()}else o.result.responseHeaders["Last-Modified"]?(n.setRequestHeader("If-Modified-Since",o.result.responseHeaders["Last-Modified"]),n.setRequestHeader("Cache-Control","no-cache")):o.result.responseHeaders.ETag&&(n.setRequestHeader("If-None-Match",o.result.responseHeaders.ETag),n.setRequestHeader("Cache-Control","no-cache")),n.send.apply(n,a)},function(e){n.send.apply(n,a)}):n.send.apply(n,a)},a.prototype.open=function(e,t,n,a,s){return this.cache.result=o(r(t),this.cache.company,this.cache.product,Date.now()),this.cache.enabled=["must-revalidate","immutable"].indexOf(this.cache.control)!=-1&&"GET"==e&&this.cache.result.url.match("^https?://")&&("undefined"==typeof n||n)&&"undefined"==typeof a&&"undefined"==typeof s,this.cache.revalidated=!1,this.xhr.open.apply(this.xhr,arguments)},a.prototype.setRequestHeader=function(e,r){return this.cache.enabled=!1,this.xhr.setRequestHeader.apply(this.xhr,arguments)};var u=new XMLHttpRequest;for(var c in u)a.prototype.hasOwnProperty(c)||!function(e){Object.defineProperty(a.prototype,e,"function"==typeof u[e]?{value:function(){return this.xhr[e].apply(this.xhr,arguments)}}:{get:function(){return this.cache.revalidated&&this.cache.result.xhr.hasOwnProperty(e)?this.cache.result.xhr[e]:this.xhr[e]},set:function(r){this.xhr[e]=r}})}(c);return a}(),new Promise(function(e,r){c.SystemInfo.hasWebGL?c.SystemInfo.hasWasm?(1==c.SystemInfo.hasWebGL&&c.print('Warning: Your browser does not support "WebGL 2" Graphics API, switching to "WebGL 1"'),c.startupErrorHandler=r,t(0),c.postRun.push(function(){t(1),delete c.startupErrorHandler,e(h)}),u()):r("Your browser does not support WebAssembly."):r("Your browser does not support WebGL.")})}
1
+ function createUnityInstance(e,r,t){function n(e,t){if(!n.aborted&&r.showBanner)return"error"==t&&(n.aborted=!0),r.showBanner(e,t);switch(t){case"error":console.error(e);break;case"warning":console.warn(e);break;default:console.log(e)}}function o(e){var r=e.reason||e.error,t=r?r.toString():e.message||e.reason||"",n=r&&r.stack?r.stack.toString():"";if(n.startsWith(t)&&(n=n.substring(t.length)),t+="\n"+n.trim(),t&&c.stackTraceRegExp&&c.stackTraceRegExp.test(t)){var o=e.filename||r&&(r.fileName||r.sourceURL)||"",a=e.lineno||r&&(r.lineNumber||r.line)||0;s(t,o,a)}}function a(e){e.preventDefault()}function s(e,r,t){if(e.indexOf("fullscreen error")==-1){if(c.startupErrorHandler)return void c.startupErrorHandler(e,r,t);if(!(c.errorHandler&&c.errorHandler(e,r,t)||(console.log("Invoking error handler due to\n"+e),"function"==typeof dump&&dump("Invoking error handler due to\n"+e),s.didShowErrorMessage))){var e="An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:\n"+e;e.indexOf("DISABLE_EXCEPTION_CATCHING")!=-1?e="An exception has occurred, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project WebGL player settings to be able to catch the exception or see the stack trace.":e.indexOf("Cannot enlarge memory arrays")!=-1?e="Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings.":e.indexOf("Invalid array buffer length")==-1&&e.indexOf("Invalid typed array length")==-1&&e.indexOf("out of memory")==-1&&e.indexOf("could not allocate memory")==-1||(e="The browser could not allocate enough memory for the WebGL content. If you are the developer of this content, try allocating less memory to your WebGL build in the WebGL player settings."),alert(e),s.didShowErrorMessage=!0}}}function i(e,r){if("symbolsUrl"!=e){var n=c.downloadProgress[e];n||(n=c.downloadProgress[e]={started:!1,finished:!1,lengthComputable:!1,total:0,loaded:0}),"object"!=typeof r||"progress"!=r.type&&"load"!=r.type||(n.started||(n.started=!0,n.lengthComputable=r.lengthComputable,n.total=r.total),n.loaded=r.loaded,"load"==r.type&&(n.finished=!0));var o=0,a=0,s=0,i=0,d=0;for(var e in c.downloadProgress){var n=c.downloadProgress[e];if(!n.started)return 0;s++,n.lengthComputable?(o+=n.loaded,a+=n.total,i++):n.finished||d++}var l=s?(s-d-(a?i*(a-o)/a:0))/s:0;t(.9*l)}}function d(e){return new Promise(function(r,t){i(e);var o=c.companyName&&c.productName?new c.XMLHttpRequest({companyName:c.companyName,productName:c.productName,cacheControl:c.cacheControl(c[e])}):new XMLHttpRequest;o.open("GET",c[e]),o.responseType="arraybuffer",o.addEventListener("progress",function(r){i(e,r)}),o.addEventListener("load",function(t){i(e,t),r(new Uint8Array(o.response))}),o.addEventListener("error",function(r){var t="Failed to download file "+c[e];"file:"==location.protocol?n(t+". Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.","error"):console.error(t)}),o.send()})}function l(){return new Promise(function(e,r){var t=document.createElement("script");t.src=c.frameworkUrl,t.onload=function(){if("undefined"==typeof unityFramework||!unityFramework){var r=[["br","br"],["gz","gzip"]];for(var o in r){var a=r[o];if(c.frameworkUrl.endsWith("."+a[0])){var s="Unable to parse "+c.frameworkUrl+"!";if("file:"==location.protocol)return void n(s+" Loading pre-compressed (brotli or gzip) content via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host compressed Unity content, or use the Unity Build and Run option.","error");if(s+=' This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: '+a[1]+'" present. Check browser Console and Devtools Network tab to debug.',"br"==a[0]&&"http:"==location.protocol){var i=["localhost","127.0.0.1"].indexOf(location.hostname)!=-1?"":"Migrate your server to use HTTPS.";s=/Firefox/.test(navigator.userAgent)?"Unable to parse "+c.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported in Firefox over HTTP connections. '+i+' See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1670675">https://bugzilla.mozilla.org/show_bug.cgi?id=1670675</a> for more information.':"Unable to parse "+c.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate your server to use HTTPS.'}return void n(s,"error")}}n("Unable to parse "+c.frameworkUrl+"! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)","error")}var d=unityFramework;unityFramework=null,t.onload=null,e(d)},t.onerror=function(e){n("Unable to load file "+c.frameworkUrl+"! Check that the file exists on the remote server. (also check browser Console and Devtools Network tab to debug)","error")},document.body.appendChild(t),c.deinitializers.push(function(){document.body.removeChild(t)})})}function u(){l().then(function(e){e(c)});var e=d("dataUrl");c.preRun.push(function(){c.addRunDependency("dataUrl"),e.then(function(e){var r=new DataView(e.buffer,e.byteOffset,e.byteLength),t=0,n="UnityWebData1.0\0";if(!String.fromCharCode.apply(null,e.subarray(t,t+n.length))==n)throw"unknown data format";t+=n.length;var o=r.getUint32(t,!0);for(t+=4;t<o;){var a=r.getUint32(t,!0);t+=4;var s=r.getUint32(t,!0);t+=4;var i=r.getUint32(t,!0);t+=4;var d=String.fromCharCode.apply(null,e.subarray(t,t+i));t+=i;for(var l=0,u=d.indexOf("/",l)+1;u>0;l=u,u=d.indexOf("/",l)+1)c.FS_createPath(d.substring(0,l),d.substring(l,u-1),!0,!0);c.FS_createDataFile(d,null,e.subarray(a,a+s),!0,!0,!0)}c.removeRunDependency("dataUrl")})})}t=t||function(){};var c={canvas:e,webglContextAttributes:{preserveDrawingBuffer:!1},cacheControl:function(e){return e==c.dataUrl?"must-revalidate":"no-store"},streamingAssetsUrl:"StreamingAssets",downloadProgress:{},deinitializers:[],intervals:{},setInterval:function(e,r){var t=window.setInterval(e,r);return this.intervals[t]=!0,t},clearInterval:function(e){delete this.intervals[e],window.clearInterval(e)},preRun:[],postRun:[],print:function(e){console.log(e)},printErr:function(e){console.error(e),"string"==typeof e&&e.indexOf("wasm streaming compile failed")!=-1&&(e.toLowerCase().indexOf("mime")!=-1?n('HTTP Response Header "Content-Type" configured incorrectly on the server for file '+c.codeUrl+' , should be "application/wasm". Startup time performance will suffer.',"warning"):n('WebAssembly streaming compilation failed! This can happen for example if "Content-Encoding" HTTP header is incorrectly enabled on the server for file '+c.codeUrl+", but the file is not pre-compressed on disk (or vice versa). Check the Network tab in browser Devtools to debug server header configuration.","warning"))},locateFile:function(e){return"build.wasm"==e?this.codeUrl:e},disabledCanvasEvents:["contextmenu","dragstart"]};for(var f in r)c[f]=r[f];c.streamingAssetsUrl=new URL(c.streamingAssetsUrl,document.URL).href;var p=c.disabledCanvasEvents.slice();p.forEach(function(r){e.addEventListener(r,a)}),window.addEventListener("error",o),window.addEventListener("unhandledrejection",o);var h={Module:c,SetFullscreen:function(){return c.SetFullscreen?c.SetFullscreen.apply(c,arguments):void c.print("Failed to set Fullscreen mode: Player not loaded yet.")},SendMessage:function(){return c.SendMessage?c.SendMessage.apply(c,arguments):void c.print("Failed to execute SendMessage: Player not loaded yet.")},Quit:function(){return new Promise(function(r,t){c.shouldQuit=!0,c.onQuit=r,p.forEach(function(r){e.removeEventListener(r,a)}),window.removeEventListener("error",o),window.removeEventListener("unhandledrejection",o)})}};return c.SystemInfo=function(){function e(e,r,t){return e=RegExp(e,"i").exec(r),e&&e[t]}for(var r,t,n,o,a,s,i=navigator.userAgent+" ",d=[["Firefox","Firefox"],["OPR","Opera"],["Edg","Edge"],["SamsungBrowser","Samsung Browser"],["Trident","Internet Explorer"],["MSIE","Internet Explorer"],["Chrome","Chrome"],["CriOS","Chrome on iOS Safari"],["FxiOS","Firefox on iOS Safari"],["Safari","Safari"]],l=0;l<d.length;++l)if(t=e(d[l][0]+"[/ ](.*?)[ \\)]",i,1)){r=d[l][1];break}"Safari"==r&&(t=e("Version/(.*?) ",i,1)),"Internet Explorer"==r&&(t=e("rv:(.*?)\\)? ",i,1)||t);for(var u=[["Windows (.*?)[;)]","Windows"],["Android ([0-9_.]+)","Android"],["iPhone OS ([0-9_.]+)","iPhoneOS"],["iPad.*? OS ([0-9_.]+)","iPadOS"],["FreeBSD( )","FreeBSD"],["OpenBSD( )","OpenBSD"],["Linux|X11()","Linux"],["Mac OS X ([0-9_.]+)","macOS"],["bot|google|baidu|bing|msn|teoma|slurp|yandex","Search Bot"]],c=0;c<u.length;++c)if(o=e(u[c][0],i,1)){n=u[c][1],o=o.replace(/_/g,".");break}var f={"NT 5.0":"2000","NT 5.1":"XP","NT 5.2":"Server 2003","NT 6.0":"Vista","NT 6.1":"7","NT 6.2":"8","NT 6.3":"8.1","NT 10.0":"10"};o=f[o]||o,a=document.createElement("canvas"),a&&(gl=a.getContext("webgl2"),glVersion=gl?2:0,gl||(gl=a&&a.getContext("webgl"))&&(glVersion=1),gl&&(s=gl.getExtension("WEBGL_debug_renderer_info")&&gl.getParameter(37446)||gl.getParameter(7937)));var p="undefined"!=typeof SharedArrayBuffer,h="object"==typeof WebAssembly&&"function"==typeof WebAssembly.compile;return{width:screen.width,height:screen.height,userAgent:i.trim(),browser:r||"Unknown browser",browserVersion:t||"Unknown version",mobile:/Mobile|Android|iP(ad|hone)/.test(navigator.appVersion),os:n||"Unknown OS",osVersion:o||"Unknown OS Version",gpu:s||"Unknown GPU",language:navigator.userLanguage||navigator.language,hasWebGL:glVersion,hasCursorLock:!!document.body.requestPointerLock,hasFullscreen:!!document.body.requestFullscreen||!!document.body.webkitRequestFullscreen,hasThreads:p,hasWasm:h,hasWasmThreads:!1}}(),c.abortHandler=function(e){return s(e,"",0),!0},Error.stackTraceLimit=Math.max(Error.stackTraceLimit||0,50),c.XMLHttpRequest=function(){function e(e){console.log("[UnityCache] "+e)}function r(e){return r.link=r.link||document.createElement("a"),r.link.href=e,r.link.href}function t(e){var r=window.location.href.match(/^[a-z]+:\/\/[^\/]+/);return!r||e.lastIndexOf(r[0],0)}function n(){function r(r){if("undefined"==typeof n.database)for(n.database=r,n.database||e("indexedDB database could not be opened");n.queue.length;){var t=n.queue.shift();n.database?n.execute.apply(n,t.arguments):"function"==typeof t.onerror&&t.onerror(new Error("operation cancelled"))}}function t(){var e=o.open(s.name,s.version);e.onupgradeneeded=function(e){var r=e.target.result;r.objectStoreNames.contains(d.name)||r.createObjectStore(d.name)},e.onsuccess=function(e){r(e.target.result)},e.onerror=function(){r(null)}}var n=this;n.queue=[];try{var o=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,a=setTimeout(function(){"undefined"==typeof n.database&&r(null)},2e3),l=o.open(s.name);l.onupgradeneeded=function(e){var r=e.target.result.createObjectStore(i.name,{keyPath:"url"});["version","company","product","updated","revalidated","accessed"].forEach(function(e){r.createIndex(e,e)})},l.onsuccess=function(e){clearTimeout(a);var n=e.target.result;n.version<s.version?(n.close(),t()):r(n)},l.onerror=function(){clearTimeout(a),r(null)}}catch(e){clearTimeout(a),r(null)}}function o(e,r,t,n,o){var a={url:e,version:i.version,company:r,product:t,updated:n,revalidated:n,accessed:n,responseHeaders:{},xhr:{}};return o&&(["Last-Modified","ETag"].forEach(function(e){a.responseHeaders[e]=o.getResponseHeader(e)}),["responseURL","status","statusText","response"].forEach(function(e){a.xhr[e]=o[e]})),a}function a(r){this.cache={enabled:!1},r&&(this.cache.control=r.cacheControl,this.cache.company=r.companyName,this.cache.product=r.productName),this.xhr=new XMLHttpRequest(r),this.xhr.addEventListener("load",function(){var r=this.xhr,t=this.cache;t.enabled&&!t.revalidated&&(304==r.status?(t.result.revalidated=t.result.accessed,t.revalidated=!0,l.execute(i.name,"put",[t.result]),e("'"+t.result.url+"' successfully revalidated and served from the indexedDB cache")):200==r.status?(t.result=o(t.result.url,t.company,t.product,t.result.accessed,r),t.revalidated=!0,l.execute(i.name,"put",[t.result],function(r){e("'"+t.result.url+"' successfully downloaded and stored in the indexedDB cache")},function(r){e("'"+t.result.url+"' successfully downloaded but not stored in the indexedDB cache due to the error: "+r)})):e("'"+t.result.url+"' request failed with status: "+r.status+" "+r.statusText))}.bind(this))}var s={name:"UnityCache",version:2},i={name:"XMLHttpRequest",version:1},d={name:"WebAssembly",version:1};n.prototype.execute=function(e,r,t,n,o){if(this.database)try{var a=this.database.transaction([e],["put","delete","clear"].indexOf(r)!=-1?"readwrite":"readonly").objectStore(e);"openKeyCursor"==r&&(a=a.index(t[0]),t=t.slice(1));var s=a[r].apply(a,t);"function"==typeof n&&(s.onsuccess=function(e){n(e.target.result)}),s.onerror=o}catch(e){"function"==typeof o&&o(e)}else"undefined"==typeof this.database?this.queue.push({arguments:arguments,onerror:o}):"function"==typeof o&&o(new Error("indexedDB access denied"))};var l=new n;a.prototype.send=function(r){var n=this.xhr,o=this.cache,a=arguments;return o.enabled=o.enabled&&"arraybuffer"==n.responseType&&!r,o.enabled?void l.execute(i.name,"get",[o.result.url],function(r){if(!r||r.version!=i.version)return void n.send.apply(n,a);if(o.result=r,o.result.accessed=Date.now(),"immutable"==o.control)o.revalidated=!0,l.execute(i.name,"put",[o.result]),n.dispatchEvent(new Event("load")),e("'"+o.result.url+"' served from the indexedDB cache without revalidation");else if(t(o.result.url)&&(o.result.responseHeaders["Last-Modified"]||o.result.responseHeaders.ETag)){var s=new XMLHttpRequest;s.open("HEAD",o.result.url),s.onload=function(){o.revalidated=["Last-Modified","ETag"].every(function(e){return!o.result.responseHeaders[e]||o.result.responseHeaders[e]==s.getResponseHeader(e)}),o.revalidated?(o.result.revalidated=o.result.accessed,l.execute(i.name,"put",[o.result]),n.dispatchEvent(new Event("load")),e("'"+o.result.url+"' successfully revalidated and served from the indexedDB cache")):n.send.apply(n,a)},s.onerror=function(){n.send.apply(n,a)},s.send()}else o.result.responseHeaders["Last-Modified"]?(n.setRequestHeader("If-Modified-Since",o.result.responseHeaders["Last-Modified"]),n.setRequestHeader("Cache-Control","no-cache")):o.result.responseHeaders.ETag&&(n.setRequestHeader("If-None-Match",o.result.responseHeaders.ETag),n.setRequestHeader("Cache-Control","no-cache")),n.send.apply(n,a)},function(e){n.send.apply(n,a)}):n.send.apply(n,a)},a.prototype.open=function(e,t,n,a,s){return this.cache.result=o(r(t),this.cache.company,this.cache.product,Date.now()),this.cache.enabled=["must-revalidate","immutable"].indexOf(this.cache.control)!=-1&&"GET"==e&&this.cache.result.url.match("^https?://")&&("undefined"==typeof n||n)&&"undefined"==typeof a&&"undefined"==typeof s,this.cache.revalidated=!1,this.xhr.open.apply(this.xhr,arguments)},a.prototype.setRequestHeader=function(e,r){return this.cache.enabled=!1,this.xhr.setRequestHeader.apply(this.xhr,arguments)};var u=new XMLHttpRequest;for(var c in u)a.prototype.hasOwnProperty(c)||!function(e){Object.defineProperty(a.prototype,e,"function"==typeof u[e]?{value:function(){return this.xhr[e].apply(this.xhr,arguments)}}:{get:function(){return this.cache.revalidated&&this.cache.result.xhr.hasOwnProperty(e)?this.cache.result.xhr[e]:this.xhr[e]},set:function(r){this.xhr[e]=r}})}(c);return a}(),new Promise(function(e,r){c.SystemInfo.hasWebGL?c.SystemInfo.hasWasm?(1==c.SystemInfo.hasWebGL&&c.print('Warning: Your browser does not support "WebGL 2" Graphics API, switching to "WebGL 1"'),c.startupErrorHandler=r,t(0),c.postRun.push(function(){t(1),delete c.startupErrorHandler,e(h)}),u()):r("Your browser does not support WebAssembly."):r("Your browser does not support WebGL.")})}
@@ -19,6 +19,7 @@ const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeM
19
19
  const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
20
20
  const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
21
21
  const ESLintPlugin = require('eslint-webpack-plugin');
22
+ const eslintConfig = require('./eslintConfig');
22
23
  const paths = require('./paths');
23
24
  const modules = require('./modules');
24
25
  const getClientEnvironment = require('./env');
@@ -31,6 +32,7 @@ const restrictedGlobals = require('confusing-browser-globals');
31
32
  const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
32
33
  // @remove-on-eject-end
33
34
 
35
+
34
36
  // Source maps are resource heavy and can cause out of memory issue for large source files.
35
37
  const sourceMapVar = process.env.GENERATE_SOURCEMAP;
36
38
  const shouldUseSourceMap = sourceMapVar !== 'false' && !!sourceMapVar;
@@ -58,19 +60,6 @@ const cssModuleRegex = /\.module\.css$/;
58
60
  const sassRegex = /\.(scss|sass)$/;
59
61
  const sassModuleRegex = /\.module\.(scss|sass)$/;
60
62
 
61
- const hasJsxRuntime = (() => {
62
- if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
63
- return false;
64
- }
65
-
66
- try {
67
- require.resolve('react/jsx-runtime');
68
- return true;
69
- } catch (e) {
70
- return false;
71
- }
72
- })();
73
-
74
63
  // This is the production and development configuration.
75
64
  // It is focused on developer experience, fast rebuilds, and a minimal bundle.
76
65
  module.exports = function (webpackEnv) {
@@ -284,8 +273,6 @@ module.exports = function (webpackEnv) {
284
273
  module: {
285
274
  strictExportPresence: true,
286
275
  rules: [
287
- // Disable require.ensure as it's not a standard language feature.
288
- { parser: { requireEnsure: false } },
289
276
  {
290
277
  // "oneOf" will traverse all following loaders until one will
291
278
  // match the requirements. When no loader matches it will fall
@@ -316,7 +303,7 @@ module.exports = function (webpackEnv) {
316
303
  [
317
304
  require.resolve('babel-preset-react-app'),
318
305
  {
319
- runtime: hasJsxRuntime ? 'automatic' : 'classic',
306
+ runtime: modules.hasJsxRuntime ? 'automatic' : 'classic',
320
307
  absoluteRuntime: false,
321
308
  },
322
309
  ],
@@ -494,7 +481,7 @@ module.exports = function (webpackEnv) {
494
481
  loader: require.resolve('file-loader'),
495
482
  // Exclude `js` files to keep "css" loader working as it injects
496
483
  // its runtime that would otherwise be processed through "file" loader.
497
- // Also exclude `html` and `json` extensions so they get processed
484
+ // Also exclude `json` extensions so they get processed
498
485
  // by webpacks internal loaders.
499
486
  exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.json$/],
500
487
  options: {
@@ -586,49 +573,11 @@ module.exports = function (webpackEnv) {
586
573
  }),
587
574
  !disableESLintPlugin &&
588
575
  new ESLintPlugin({
589
- // Plugin options
590
- extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
591
576
  formatter: require.resolve('react-dev-utils/eslintFormatter'),
592
577
  eslintPath: require.resolve('eslint'),
593
578
  failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
594
579
  context: paths.appSrc,
595
- cache: true,
596
- cacheLocation: path.resolve(
597
- paths.appNodeModules,
598
- '.cache/.eslintcache'
599
- ),
600
- // ESLint class options
601
- cwd: paths.appPath,
602
- resolvePluginsRelativeTo: __dirname,
603
- baseConfig: {
604
- extends: [require.resolve('eslint-config-react-app')],
605
- rules: {
606
- ...(!hasJsxRuntime && {
607
- 'react/react-in-jsx-scope': 'error',
608
- }),
609
-
610
- // Disable jsx-ally as it is irrelevant for us
611
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
612
- 'jsx-a11y/alt-text': 'off',
613
- 'jsx-a11y/anchor-has-content': 'off',
614
- 'jsx-a11y/anchor-is-valid': 'off',
615
- 'jsx-a11y/aria-activedescendant-has-tabindex': 'off',
616
- 'jsx-a11y/aria-props': 'off',
617
- 'jsx-a11y/aria-proptypes': 'off',
618
- 'jsx-a11y/aria-role': 'off',
619
- 'jsx-a11y/aria-unsupported-elements': 'off',
620
- 'jsx-a11y/heading-has-content': 'off',
621
- 'jsx-a11y/iframe-has-title': 'off',
622
- 'jsx-a11y/img-redundant-alt': 'off',
623
- 'jsx-a11y/no-access-key': 'off',
624
- 'jsx-a11y/no-distracting-elements': 'off',
625
- 'jsx-a11y/no-redundant-roles': 'off',
626
- 'jsx-a11y/role-has-required-aria-props': 'off',
627
- 'jsx-a11y/role-supports-aria-props': 'off',
628
- 'jsx-a11y/scope': 'off',
629
- 'no-restricted-globals': ['error'].concat(restrictedGlobals.filter(x => x !== 'location')),
630
- },
631
- },
580
+ ...eslintConfig,
632
581
  }),
633
582
  ].filter(Boolean),
634
583
  // Turn off performance processing because we utilize
@@ -1,9 +1,7 @@
1
- /// <reference types="node" />
1
+ /// <reference no-default-lib="true"/>
2
+ /// <reference lib="es2021" />
2
3
  /// <reference types="react" />
3
- /// <reference types="mocha" />
4
- /// <reference types="chai" />
5
-
6
- declare var expect: Chai.ExpectStatic;
4
+ /// <reference types="webpack-env" />
7
5
 
8
6
  declare namespace NodeJS {
9
7
  interface ProcessEnv {
@@ -67,6 +65,11 @@ declare module '*.txt' {
67
65
  export default value;
68
66
  }
69
67
 
68
+ declare module '*.html' {
69
+ const value: string;
70
+ export default value;
71
+ }
72
+
70
73
  declare module '!!raw-loader!*' {
71
74
  const value: string;
72
75
  export default value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactunity/scripts",
3
- "version": "0.6.0",
3
+ "version": "0.8.1",
4
4
  "description": "Configuration and scripts for React Unity.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,6 +26,9 @@
26
26
  "types": "./lib/types/main.d.ts",
27
27
  "typesVersions": {
28
28
  "*": {
29
+ "main": [
30
+ "./lib/types/main.d.ts"
31
+ ],
29
32
  "editor": [
30
33
  "./lib/types/editor.d.ts"
31
34
  ],
@@ -40,68 +43,63 @@
40
43
  ]
41
44
  }
42
45
  },
43
- "scripts": {
44
- "preinstall": "npx only-allow@1.0.0 yarn"
45
- },
46
46
  "dependencies": {
47
- "@babel/core": "7.15.5",
47
+ "@babel/core": "7.16.0",
48
48
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.1",
49
- "@types/react": "^17.0.21",
50
- "@types/webpack-env": "1.16.2",
51
- "@typescript-eslint/eslint-plugin": "^4.31.1",
52
- "@typescript-eslint/parser": "^4.31.1",
49
+ "@types/react": "^17.0.33",
50
+ "@types/webpack-env": "1.16.3",
51
+ "@typescript-eslint/eslint-plugin": "^5.2.0",
52
+ "@typescript-eslint/parser": "^5.2.0",
53
53
  "babel-eslint": "^10.1.0",
54
- "babel-loader": "8.2.2",
54
+ "babel-loader": "8.2.3",
55
55
  "babel-plugin-named-asset-import": "^0.3.7",
56
56
  "babel-preset-react-app": "^10.0.0",
57
57
  "bfj": "^7.0.2",
58
58
  "camelcase": "^6.2.0",
59
59
  "case-sensitive-paths-webpack-plugin": "2.4.0",
60
60
  "confusing-browser-globals": "^1.0.10",
61
- "css-loader": "6.3.0",
61
+ "css-loader": "6.5.0",
62
62
  "dotenv": "10.0.0",
63
63
  "dotenv-expand": "5.1.0",
64
64
  "eslint": "^7.32.0",
65
65
  "eslint-config-react-app": "^6.0.0",
66
- "eslint-plugin-flowtype": "^6.0.1",
67
- "eslint-plugin-import": "^2.24.2",
68
- "eslint-plugin-jsx-a11y": "6.4.1",
69
- "eslint-plugin-react": "^7.25.2",
66
+ "eslint-plugin-import": "^2.25.2",
67
+ "eslint-plugin-react": "^7.26.1",
70
68
  "eslint-plugin-react-hooks": "^4.2.0",
71
- "eslint-plugin-testing-library": "^4.12.2",
72
- "eslint-webpack-plugin": "^3.0.1",
69
+ "eslint-plugin-testing-library": "^4.12.4",
70
+ "eslint-webpack-plugin": "^3.1.0",
73
71
  "file-loader": "6.2.0",
74
72
  "fs-extra": "^10.0.0",
75
73
  "identity-obj-proxy": "3.0.0",
76
74
  "null-loader": "^4.0.1",
77
75
  "pnp-webpack-plugin": "1.7.0",
78
- "prompts": "2.4.1",
76
+ "prompts": "2.4.2",
79
77
  "raw-loader": "^4.0.2",
80
78
  "react-app-polyfill": "^2.0.0",
81
79
  "react-dev-utils": "https://github.com/ReactUnity/scripts/raw/main/temp/react-dev-utils-11.0.3-hotfix.tgz",
82
80
  "react-refresh": "^0.10.0",
83
81
  "resolve": "1.20.0",
84
82
  "resolve-url-loader": "^4.0.0",
85
- "sass-loader": "^12.1.0",
83
+ "sass-loader": "^12.3.0",
86
84
  "semver": "7.3.5",
87
- "style-loader": "3.2.1",
85
+ "style-loader": "3.3.1",
88
86
  "terser-webpack-plugin": "5.2.4",
89
87
  "ts-pnp": "1.2.0",
90
88
  "url-loader": "4.1.1",
91
- "webpack": "5.53.0",
92
- "webpack-dev-server": "4.2.1"
89
+ "webpack": "5.61.0",
90
+ "webpack-dev-server": "4.4.0"
93
91
  },
94
92
  "devDependencies": {
95
93
  "react": "^17.0.2",
96
- "typescript": "^4.4.3"
94
+ "typescript": "^4.4.4"
97
95
  },
98
96
  "optionalDependencies": {
99
97
  "fsevents": "^2.3.2",
100
- "sass": "^1.41.1"
98
+ "sass": "^1.43.4"
101
99
  },
102
100
  "peerDependencies": {
103
- "@reactunity/renderer": "^0.6.0",
104
- "typescript": "^4.4.3"
101
+ "@reactunity/renderer": "^0.8.0",
102
+ "typescript": "^4.4.4"
105
103
  },
106
104
  "peerDependenciesMeta": {
107
105
  "typescript": {
package/scripts/init.js CHANGED
@@ -195,6 +195,7 @@ module.exports = function (
195
195
  build: 'react-unity-scripts build',
196
196
  test: 'react-unity-scripts test',
197
197
  eject: 'react-unity-scripts eject',
198
+ lint: 'react-unity-scripts lint',
198
199
  },
199
200
  templateScripts
200
201
  );
@@ -0,0 +1,39 @@
1
+ // @remove-on-eject-begin
2
+ /**
3
+ * Copyright (c) 2015-present, Facebook, Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ // @remove-on-eject-end
9
+ 'use strict';
10
+
11
+ // Do this as the first thing so that any code reading it knows the right env.
12
+ process.env.BABEL_ENV = process.env.BABEL_ENV || process.env.NODE_ENV || 'development';
13
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development';
14
+
15
+ // Makes the script crash on unhandled rejections instead of silently
16
+ // ignoring them. In the future, promise rejections that are not handled will
17
+ // terminate the Node.js process with a non-zero exit code.
18
+ process.on('unhandledRejection', err => {
19
+ throw err;
20
+ });
21
+
22
+ // Ensure environment variables are read.
23
+ require('../config/env');
24
+
25
+ const paths = require('../config/paths');
26
+ const eslintConfig = require('../config/eslintConfig');
27
+ const formatter = require('react-dev-utils/eslintFormatter');
28
+
29
+ const { ESLint } = require("eslint");
30
+
31
+ (async function main() {
32
+ const eslint = new ESLint(eslintConfig);
33
+ const results = await eslint.lintFiles([paths.appSrc]);
34
+ const resultText = formatter(results);
35
+ console.log(resultText);
36
+ })().catch((error) => {
37
+ process.exitCode = 1;
38
+ console.error(error);
39
+ });
@@ -263,6 +263,30 @@ function verifyTypeScriptSetup() {
263
263
  );
264
264
  }
265
265
 
266
+ const types = appTsConfig.compilerOptions.types || (appTsConfig.compilerOptions.types = []);
267
+
268
+ if (!types.includes('@reactunity/scripts/main')) {
269
+ types.push('@reactunity/scripts/main');
270
+ messages.push(
271
+ `${chalk.cyan('types')} should include ${chalk.cyan.bold('@reactunity/scripts/main')}`
272
+ );
273
+ }
274
+
275
+ if (!types.includes('@reactunity/scripts/ugui') && !types.includes('@reactunity/scripts/uitoolkit')
276
+ && !types.includes('@reactunity/scripts/editor') && !types.includes('@reactunity/scripts/tests')) {
277
+ types.push('@reactunity/scripts/ugui');
278
+ messages.push(
279
+ `${chalk.cyan('types')} should include a valid platform target. Assuming ${chalk.cyan.bold('@reactunity/scripts/ugui')}`
280
+ );
281
+ }
282
+
283
+ // Deprecate `react-unity-scripts` types
284
+ if (fs.existsSync(paths.appTypeDeclarations)) {
285
+ messages.push(
286
+ `References to ${chalk.cyan('@reactunity/scripts')} does not have to be in ${chalk.cyan.bold('react-unity.d.ts')} anymore. It can be removed.`
287
+ );
288
+ }
289
+
266
290
  if (messages.length > 0) {
267
291
  if (firstTimeSetup) {
268
292
  console.log(
@@ -288,14 +312,6 @@ function verifyTypeScriptSetup() {
288
312
  }
289
313
  writeJson(paths.appTsConfig, appTsConfig);
290
314
  }
291
-
292
- // Reference `react-unity-scripts` types
293
- if (!fs.existsSync(paths.appTypeDeclarations)) {
294
- fs.writeFileSync(
295
- paths.appTypeDeclarations,
296
- `/// <reference types="@reactunity/scripts" />${os.EOL}`
297
- );
298
- }
299
315
  }
300
316
 
301
317
  module.exports = verifyTypeScriptSetup;