@apps-in-toss/user-scripts 1.9.4

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.
@@ -0,0 +1,4 @@
1
+ declare const afterDocumentLoad = "\"use strict\";(()=>{var e=document.createElement(\"style\");e.textContent=`\n*:not(input):not(textarea) {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n -webkit-touch-callout: none;\n}\n`;document.head.appendChild(e);})();\n";
2
+ declare const beforeDocumentLoad = "\"use strict\";(()=>{var b=class{get _window(){return typeof window<\"u\"?window:{ReactNativeWebView:{postMessage:()=>{}},__GRANITE_NATIVE_EMITTER:{on:()=>()=>{}},__CONSTANT_HANDLER_MAP:{}}}postMessage(e){let t=this._window.ReactNativeWebView;if(!t)throw new Error(\"ReactNativeWebView is not available in browser environment\");t.postMessage(JSON.stringify(e))}on(e,t){let n=this._window.__GRANITE_NATIVE_EMITTER;if(!n)throw new Error(\"__GRANITE_NATIVE_EMITTER is not available\");return n.on(e,t)}getConstant(e){let t=this._window.__CONSTANT_HANDLER_MAP;if(t&&e in t)return t[e];throw new Error(`${e} is not a constant handler`)}},u=new b,y=()=>Math.random().toString(36).substring(2,15),R=e=>{if(e&&e.__isError){let t=new Error(e.message);for(let[n,r]of Object.entries(e))t[n]=r;return t}return e};function h(e){return(...t)=>{let n=y(),r=[],a=()=>{for(let o of r)o()};return new Promise((o,i)=>{r.push(u.on(`${e}/resolve/${n}`,s=>{a(),o(s)})),r.push(u.on(`${e}/reject/${n}`,s=>{a(),i(R(s))})),u.postMessage({type:\"method\",functionName:e,eventId:n,args:t})})}}function g(e){return()=>u.getConstant(e)}var m=class{_log=h(\"debugLog\");log(t,n){try{this._log({log_name:`apps_in_toss_webview_${t}`,log_type:\"debug\",params:{...n,...this.getCommonParams()}})}catch{}}getCommonParams(){return{...this.getLocationInfo(),...this.getNavigatorInfo(),...this.getScreenInfo(),appName:window.__appsInToss.appName,deploymentId:window.__appsInToss.deploymentId,sessionId:window.__appsInToss.sessionId,isGame:window.__appsInToss.webViewType===\"game\",timestampMs:Date.now()}}getLocationInfo(){return{url:window.location.href,urlOrigin:window.location.origin,urlHost:window.location.hostname,urlPath:window.location.pathname,urlSearch:window.location.search}}getNavigatorInfo(){return{userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,cookieEnabled:navigator.cookieEnabled,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:navigator.deviceMemory?navigator.deviceMemory*1024*1024:void 0,maxTouchPoints:navigator.maxTouchPoints}}getScreenInfo(){return{screenWidth:screen.width,screenHeight:screen.height,availableScreenWidth:screen.availWidth,availableScreenHeight:screen.availHeight,devicePixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,pixelDepth:screen.pixelDepth,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}};var l=class{callbacks={};on(t,n){typeof this.callbacks[t]>\"u\"&&(this.callbacks[t]=[]),this.callbacks[t].push(n)}emit(t,n){this.callbacks[t]?.forEach(r=>r(n))}};window.__appsInToss={appName:g(\"getAppName\")(),deploymentId:g(\"getDeploymentId\")(),webViewType:g(\"getWebViewType\")(),sessionId:Math.random().toString(36).substring(2),eventEmitter:new l,debugLogger:new m};var d=/\\.(data|wasm|framework\\.js)(?:\\.gz|\\.br|\\.unityweb)?$/;function f(e){window.fetch=new Proxy(window.fetch,{apply:e})}(()=>{if(window.__appsInToss.webViewType!==\"game\"||typeof caches>\"u\")return;let e=\"@apps-in-toss/caches/\",t=`${e}${window.__appsInToss.deploymentId}`;window.addEventListener(\"load\",async()=>{let n=await caches.keys();for(let r of n)r.startsWith(e)&&r!==t&&await caches.delete(r)}),f(async(n,r,a)=>{let o=new Request(a[0],a[1]);if(!d.test(o.url))return await n.call(r,o);let i=await caches.open(t),s=await i.match(o);if(s){let v=s.headers.get(\"ETag\"),_=s.headers.get(\"Last-Modified\");v&&o.headers.set(\"If-None-Match\",v),_&&o.headers.set(\"If-Modified-Since\",_);let p=await n.call(r,o);return p.status===304?(s.__revalidateResponse=p,s):(i.put(o,p.clone()),p)}let w=await n.call(r,o);return i.put(o,w.clone()),w})})();f(async(e,t,n)=>{let r=new Request(n[0],n[1]),a=Date.now();window.__appsInToss.eventEmitter.emit(\"fetchRequest\",{request:r});let o=await e.call(t,r);return window.__appsInToss.eventEmitter.emit(\"fetchResponse\",{request:r,response:o,requestAt:a}),o});var E=window.__appsInToss.debugLogger;E.log(\"load_start\",{});window.addEventListener(\"load\",()=>{let e=performance.timeOrigin,t=performance.getEntriesByType?.(\"navigation\")[0]??null,n=typeof e<\"u\"&&t!==null,r=n?{navigationStartAtMs:e+t.startTime,navigationRedirectStartAtMs:e+t.redirectStart,navigationRedirectEndAtMs:e+t.redirectEnd,navigationRedirectCount:t.redirectCount,navigationServiceWorkerStartAtMs:e+t.workerStart,navigationFetchStartAtMs:e+t.fetchStart,navigationDomainLookupStartAtMs:e+t.domainLookupStart,navigationDomainLookupEndAtMs:e+t.domainLookupEnd,navigationConnectStartAtMs:e+t.connectStart,navigationSecureConnectStartAtMs:e+t.secureConnectionStart,navigationConnectEndAtMs:e+t.connectEnd,navigationRequestStartAtMs:e+t.requestStart,navigationResponseStartAtMs:e+t.responseStart,navigationResponseEndAtMs:e+t.responseEnd,navigationDomInteractiveAtMs:e+t.domInteractive,navigationDomContentLoadedEventStartAtMs:e+t.domContentLoadedEventStart,navigationDomContentLoadedEventEndAtMs:e+t.domContentLoadedEventEnd,navigationDomCompleteAtMs:e+t.domComplete}:{};E.log(\"load_complete\",{isNavigationDebugSupported:n,...r})});function c(e,t){return parseFloat(e.toFixed(t))}(()=>{if(typeof performance.memory>\"u\"||typeof performance.memory.usedJSHeapSize>\"u\"||typeof performance.memory.totalJSHeapSize>\"u\"||typeof performance.memory.jsHeapSizeLimit>\"u\")return;function e(t){window.__appsInToss.debugLogger.log(t,{usedJSHeapSize:c(performance.memory.usedJSHeapSize/1024,2),totalJSHeapSize:c(performance.memory.totalJSHeapSize/1024,2),jsHeapSizeLimit:c(performance.memory.jsHeapSizeLimit/1024,2)})}e(\"memory_usage_first_0s\"),setTimeout(()=>e(\"memory_usage_first_1s\"),1e3),setTimeout(()=>e(\"memory_usage_first_10s\"),1e4),setTimeout(()=>e(\"memory_usage_first_30s\"),3e4),setTimeout(()=>e(\"memory_usage_first_60s\"),6e4),setInterval(()=>e(\"memory_usage_every_180s\"),18e4)})();(()=>{let e=window.__appsInToss.debugLogger,t=performance.timeOrigin;if(typeof t>\"u\"||typeof PerformanceObserver>\"u\")return;new PerformanceObserver(a=>{a.getEntries().forEach(i=>{i.name===\"first-paint\"?e.log(\"first_paint\",{fpStartAtMs:t+i.startTime}):i.name===\"first-contentful-paint\"&&e.log(\"first_contentful_paint\",{fcpStartAtMs:t+i.startTime})})}).observe({type:\"paint\"}),new PerformanceObserver(a=>{a.getEntries().forEach(i=>{e.log(\"largest_contentful_paint\",{lcpStartAtMs:t+i.startTime,lcpRenderSize:i.size})})}).observe({type:\"largest-contentful-paint\"})})();(()=>{if(window.__appsInToss.webViewType!==\"game\")return;function e(t){let n=t.getContext(\"webgl2\")??t.getContext(\"webgl\");if(n==null)return;let r=n.getExtension(\"WEBGL_debug_renderer_info\"),a=n.getParameter(n.MAX_VIEWPORT_DIMS),o={webGLRenderer:n.getParameter(n.RENDERER),webGLVendor:n.getParameter(n.VENDOR),webGLVersion:n.getParameter(n.VERSION),webGLShadingLanguageVersion:n.getParameter(n.SHADING_LANGUAGE_VERSION),webGLMaxTextureSize:n.getParameter(n.MAX_TEXTURE_SIZE),webGLMaxViewportWidth:a[0],webGLMaxViewportHeight:a[1],webGLMaxRenderbufferSize:n.getParameter(n.MAX_RENDERBUFFER_SIZE)},i=r?{webGLUnmaskedVendor:n.getParameter(r.UNMASKED_VENDOR_WEBGL),webGLUnmaskedRenderer:n.getParameter(r.UNMASKED_RENDERER_WEBGL)}:{};window.__appsInToss.debugLogger.log(\"unity_webgl_info\",{...o,...i})}window.addEventListener(\"load\",()=>{let t=document.querySelector(\"#unity-canvas\");if(t!=null){e(t);return}new MutationObserver((r,a)=>{for(let o of r)o.type===\"childList\"&&o.addedNodes.forEach(i=>{if(i instanceof HTMLCanvasElement&&i.getAttribute(\"id\")===\"unity-canvas\"&&(e(i),a.disconnect()),i instanceof HTMLElement){let s=i.querySelector(\"#unity-canvas\");s!=null&&(e(s),a.disconnect())}})}).observe(document.body,{childList:!0,subtree:!0})})})();(()=>{if(window.__appsInToss.webViewType!==\"game\")return;let e=window.__appsInToss.debugLogger,t=window.__appsInToss.eventEmitter;t.on(\"fetchRequest\",({request:n})=>{d.test(n.url)&&e.log(\"game_resource_download_start\",{gameResourceRequestURL:n.url})}),t.on(\"fetchResponse\",async({request:n,requestAt:r,response:a})=>{if(!d.test(n.url))return;let o=c((await a.clone().blob()).size/1024,2),i=Date.now();e.log(\"game_resource_download_end\",{gameResourceRequestURL:n.url,gameResourceRequestAtMs:r,gameResourceResponseAtMs:i,gameResourceResponseSize:o,gameResourceResponseStatus:a.__revalidateResponse?.status??a.status,gameResourceDownloadDurationMs:i-r})})})();})();\n";
3
+
4
+ export { afterDocumentLoad, beforeDocumentLoad };
@@ -0,0 +1,4 @@
1
+ declare const afterDocumentLoad = "\"use strict\";(()=>{var e=document.createElement(\"style\");e.textContent=`\n*:not(input):not(textarea) {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n -webkit-touch-callout: none;\n}\n`;document.head.appendChild(e);})();\n";
2
+ declare const beforeDocumentLoad = "\"use strict\";(()=>{var b=class{get _window(){return typeof window<\"u\"?window:{ReactNativeWebView:{postMessage:()=>{}},__GRANITE_NATIVE_EMITTER:{on:()=>()=>{}},__CONSTANT_HANDLER_MAP:{}}}postMessage(e){let t=this._window.ReactNativeWebView;if(!t)throw new Error(\"ReactNativeWebView is not available in browser environment\");t.postMessage(JSON.stringify(e))}on(e,t){let n=this._window.__GRANITE_NATIVE_EMITTER;if(!n)throw new Error(\"__GRANITE_NATIVE_EMITTER is not available\");return n.on(e,t)}getConstant(e){let t=this._window.__CONSTANT_HANDLER_MAP;if(t&&e in t)return t[e];throw new Error(`${e} is not a constant handler`)}},u=new b,y=()=>Math.random().toString(36).substring(2,15),R=e=>{if(e&&e.__isError){let t=new Error(e.message);for(let[n,r]of Object.entries(e))t[n]=r;return t}return e};function h(e){return(...t)=>{let n=y(),r=[],a=()=>{for(let o of r)o()};return new Promise((o,i)=>{r.push(u.on(`${e}/resolve/${n}`,s=>{a(),o(s)})),r.push(u.on(`${e}/reject/${n}`,s=>{a(),i(R(s))})),u.postMessage({type:\"method\",functionName:e,eventId:n,args:t})})}}function g(e){return()=>u.getConstant(e)}var m=class{_log=h(\"debugLog\");log(t,n){try{this._log({log_name:`apps_in_toss_webview_${t}`,log_type:\"debug\",params:{...n,...this.getCommonParams()}})}catch{}}getCommonParams(){return{...this.getLocationInfo(),...this.getNavigatorInfo(),...this.getScreenInfo(),appName:window.__appsInToss.appName,deploymentId:window.__appsInToss.deploymentId,sessionId:window.__appsInToss.sessionId,isGame:window.__appsInToss.webViewType===\"game\",timestampMs:Date.now()}}getLocationInfo(){return{url:window.location.href,urlOrigin:window.location.origin,urlHost:window.location.hostname,urlPath:window.location.pathname,urlSearch:window.location.search}}getNavigatorInfo(){return{userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,cookieEnabled:navigator.cookieEnabled,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:navigator.deviceMemory?navigator.deviceMemory*1024*1024:void 0,maxTouchPoints:navigator.maxTouchPoints}}getScreenInfo(){return{screenWidth:screen.width,screenHeight:screen.height,availableScreenWidth:screen.availWidth,availableScreenHeight:screen.availHeight,devicePixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,pixelDepth:screen.pixelDepth,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}};var l=class{callbacks={};on(t,n){typeof this.callbacks[t]>\"u\"&&(this.callbacks[t]=[]),this.callbacks[t].push(n)}emit(t,n){this.callbacks[t]?.forEach(r=>r(n))}};window.__appsInToss={appName:g(\"getAppName\")(),deploymentId:g(\"getDeploymentId\")(),webViewType:g(\"getWebViewType\")(),sessionId:Math.random().toString(36).substring(2),eventEmitter:new l,debugLogger:new m};var d=/\\.(data|wasm|framework\\.js)(?:\\.gz|\\.br|\\.unityweb)?$/;function f(e){window.fetch=new Proxy(window.fetch,{apply:e})}(()=>{if(window.__appsInToss.webViewType!==\"game\"||typeof caches>\"u\")return;let e=\"@apps-in-toss/caches/\",t=`${e}${window.__appsInToss.deploymentId}`;window.addEventListener(\"load\",async()=>{let n=await caches.keys();for(let r of n)r.startsWith(e)&&r!==t&&await caches.delete(r)}),f(async(n,r,a)=>{let o=new Request(a[0],a[1]);if(!d.test(o.url))return await n.call(r,o);let i=await caches.open(t),s=await i.match(o);if(s){let v=s.headers.get(\"ETag\"),_=s.headers.get(\"Last-Modified\");v&&o.headers.set(\"If-None-Match\",v),_&&o.headers.set(\"If-Modified-Since\",_);let p=await n.call(r,o);return p.status===304?(s.__revalidateResponse=p,s):(i.put(o,p.clone()),p)}let w=await n.call(r,o);return i.put(o,w.clone()),w})})();f(async(e,t,n)=>{let r=new Request(n[0],n[1]),a=Date.now();window.__appsInToss.eventEmitter.emit(\"fetchRequest\",{request:r});let o=await e.call(t,r);return window.__appsInToss.eventEmitter.emit(\"fetchResponse\",{request:r,response:o,requestAt:a}),o});var E=window.__appsInToss.debugLogger;E.log(\"load_start\",{});window.addEventListener(\"load\",()=>{let e=performance.timeOrigin,t=performance.getEntriesByType?.(\"navigation\")[0]??null,n=typeof e<\"u\"&&t!==null,r=n?{navigationStartAtMs:e+t.startTime,navigationRedirectStartAtMs:e+t.redirectStart,navigationRedirectEndAtMs:e+t.redirectEnd,navigationRedirectCount:t.redirectCount,navigationServiceWorkerStartAtMs:e+t.workerStart,navigationFetchStartAtMs:e+t.fetchStart,navigationDomainLookupStartAtMs:e+t.domainLookupStart,navigationDomainLookupEndAtMs:e+t.domainLookupEnd,navigationConnectStartAtMs:e+t.connectStart,navigationSecureConnectStartAtMs:e+t.secureConnectionStart,navigationConnectEndAtMs:e+t.connectEnd,navigationRequestStartAtMs:e+t.requestStart,navigationResponseStartAtMs:e+t.responseStart,navigationResponseEndAtMs:e+t.responseEnd,navigationDomInteractiveAtMs:e+t.domInteractive,navigationDomContentLoadedEventStartAtMs:e+t.domContentLoadedEventStart,navigationDomContentLoadedEventEndAtMs:e+t.domContentLoadedEventEnd,navigationDomCompleteAtMs:e+t.domComplete}:{};E.log(\"load_complete\",{isNavigationDebugSupported:n,...r})});function c(e,t){return parseFloat(e.toFixed(t))}(()=>{if(typeof performance.memory>\"u\"||typeof performance.memory.usedJSHeapSize>\"u\"||typeof performance.memory.totalJSHeapSize>\"u\"||typeof performance.memory.jsHeapSizeLimit>\"u\")return;function e(t){window.__appsInToss.debugLogger.log(t,{usedJSHeapSize:c(performance.memory.usedJSHeapSize/1024,2),totalJSHeapSize:c(performance.memory.totalJSHeapSize/1024,2),jsHeapSizeLimit:c(performance.memory.jsHeapSizeLimit/1024,2)})}e(\"memory_usage_first_0s\"),setTimeout(()=>e(\"memory_usage_first_1s\"),1e3),setTimeout(()=>e(\"memory_usage_first_10s\"),1e4),setTimeout(()=>e(\"memory_usage_first_30s\"),3e4),setTimeout(()=>e(\"memory_usage_first_60s\"),6e4),setInterval(()=>e(\"memory_usage_every_180s\"),18e4)})();(()=>{let e=window.__appsInToss.debugLogger,t=performance.timeOrigin;if(typeof t>\"u\"||typeof PerformanceObserver>\"u\")return;new PerformanceObserver(a=>{a.getEntries().forEach(i=>{i.name===\"first-paint\"?e.log(\"first_paint\",{fpStartAtMs:t+i.startTime}):i.name===\"first-contentful-paint\"&&e.log(\"first_contentful_paint\",{fcpStartAtMs:t+i.startTime})})}).observe({type:\"paint\"}),new PerformanceObserver(a=>{a.getEntries().forEach(i=>{e.log(\"largest_contentful_paint\",{lcpStartAtMs:t+i.startTime,lcpRenderSize:i.size})})}).observe({type:\"largest-contentful-paint\"})})();(()=>{if(window.__appsInToss.webViewType!==\"game\")return;function e(t){let n=t.getContext(\"webgl2\")??t.getContext(\"webgl\");if(n==null)return;let r=n.getExtension(\"WEBGL_debug_renderer_info\"),a=n.getParameter(n.MAX_VIEWPORT_DIMS),o={webGLRenderer:n.getParameter(n.RENDERER),webGLVendor:n.getParameter(n.VENDOR),webGLVersion:n.getParameter(n.VERSION),webGLShadingLanguageVersion:n.getParameter(n.SHADING_LANGUAGE_VERSION),webGLMaxTextureSize:n.getParameter(n.MAX_TEXTURE_SIZE),webGLMaxViewportWidth:a[0],webGLMaxViewportHeight:a[1],webGLMaxRenderbufferSize:n.getParameter(n.MAX_RENDERBUFFER_SIZE)},i=r?{webGLUnmaskedVendor:n.getParameter(r.UNMASKED_VENDOR_WEBGL),webGLUnmaskedRenderer:n.getParameter(r.UNMASKED_RENDERER_WEBGL)}:{};window.__appsInToss.debugLogger.log(\"unity_webgl_info\",{...o,...i})}window.addEventListener(\"load\",()=>{let t=document.querySelector(\"#unity-canvas\");if(t!=null){e(t);return}new MutationObserver((r,a)=>{for(let o of r)o.type===\"childList\"&&o.addedNodes.forEach(i=>{if(i instanceof HTMLCanvasElement&&i.getAttribute(\"id\")===\"unity-canvas\"&&(e(i),a.disconnect()),i instanceof HTMLElement){let s=i.querySelector(\"#unity-canvas\");s!=null&&(e(s),a.disconnect())}})}).observe(document.body,{childList:!0,subtree:!0})})})();(()=>{if(window.__appsInToss.webViewType!==\"game\")return;let e=window.__appsInToss.debugLogger,t=window.__appsInToss.eventEmitter;t.on(\"fetchRequest\",({request:n})=>{d.test(n.url)&&e.log(\"game_resource_download_start\",{gameResourceRequestURL:n.url})}),t.on(\"fetchResponse\",async({request:n,requestAt:r,response:a})=>{if(!d.test(n.url))return;let o=c((await a.clone().blob()).size/1024,2),i=Date.now();e.log(\"game_resource_download_end\",{gameResourceRequestURL:n.url,gameResourceRequestAtMs:r,gameResourceResponseAtMs:i,gameResourceResponseSize:o,gameResourceResponseStatus:a.__revalidateResponse?.status??a.status,gameResourceDownloadDurationMs:i-r})})})();})();\n";
3
+
4
+ export { afterDocumentLoad, beforeDocumentLoad };
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},u=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!c.call(t,n)&&n!==o&&a(t,n,{get:()=>e[n],enumerable:!(r=i(e,n))||r.enumerable});return t};var l=t=>u(a({},"__esModule",{value:!0}),t);var m={};d(m,{afterDocumentLoad:()=>p,beforeDocumentLoad:()=>g});module.exports=l(m);var p=`"use strict";(()=>{var e=document.createElement("style");e.textContent=\`
2
+ *:not(input):not(textarea) {
3
+ -webkit-user-select: none;
4
+ -moz-user-select: none;
5
+ -ms-user-select: none;
6
+ user-select: none;
7
+ -webkit-touch-callout: none;
8
+ }
9
+ \`;document.head.appendChild(e);})();
10
+ `,g='"use strict";(()=>{var b=class{get _window(){return typeof window<"u"?window:{ReactNativeWebView:{postMessage:()=>{}},__GRANITE_NATIVE_EMITTER:{on:()=>()=>{}},__CONSTANT_HANDLER_MAP:{}}}postMessage(e){let t=this._window.ReactNativeWebView;if(!t)throw new Error("ReactNativeWebView is not available in browser environment");t.postMessage(JSON.stringify(e))}on(e,t){let n=this._window.__GRANITE_NATIVE_EMITTER;if(!n)throw new Error("__GRANITE_NATIVE_EMITTER is not available");return n.on(e,t)}getConstant(e){let t=this._window.__CONSTANT_HANDLER_MAP;if(t&&e in t)return t[e];throw new Error(`${e} is not a constant handler`)}},u=new b,y=()=>Math.random().toString(36).substring(2,15),R=e=>{if(e&&e.__isError){let t=new Error(e.message);for(let[n,r]of Object.entries(e))t[n]=r;return t}return e};function h(e){return(...t)=>{let n=y(),r=[],a=()=>{for(let o of r)o()};return new Promise((o,i)=>{r.push(u.on(`${e}/resolve/${n}`,s=>{a(),o(s)})),r.push(u.on(`${e}/reject/${n}`,s=>{a(),i(R(s))})),u.postMessage({type:"method",functionName:e,eventId:n,args:t})})}}function g(e){return()=>u.getConstant(e)}var m=class{_log=h("debugLog");log(t,n){try{this._log({log_name:`apps_in_toss_webview_${t}`,log_type:"debug",params:{...n,...this.getCommonParams()}})}catch{}}getCommonParams(){return{...this.getLocationInfo(),...this.getNavigatorInfo(),...this.getScreenInfo(),appName:window.__appsInToss.appName,deploymentId:window.__appsInToss.deploymentId,sessionId:window.__appsInToss.sessionId,isGame:window.__appsInToss.webViewType==="game",timestampMs:Date.now()}}getLocationInfo(){return{url:window.location.href,urlOrigin:window.location.origin,urlHost:window.location.hostname,urlPath:window.location.pathname,urlSearch:window.location.search}}getNavigatorInfo(){return{userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,cookieEnabled:navigator.cookieEnabled,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:navigator.deviceMemory?navigator.deviceMemory*1024*1024:void 0,maxTouchPoints:navigator.maxTouchPoints}}getScreenInfo(){return{screenWidth:screen.width,screenHeight:screen.height,availableScreenWidth:screen.availWidth,availableScreenHeight:screen.availHeight,devicePixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,pixelDepth:screen.pixelDepth,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}};var l=class{callbacks={};on(t,n){typeof this.callbacks[t]>"u"&&(this.callbacks[t]=[]),this.callbacks[t].push(n)}emit(t,n){this.callbacks[t]?.forEach(r=>r(n))}};window.__appsInToss={appName:g("getAppName")(),deploymentId:g("getDeploymentId")(),webViewType:g("getWebViewType")(),sessionId:Math.random().toString(36).substring(2),eventEmitter:new l,debugLogger:new m};var d=/\\.(data|wasm|framework\\.js)(?:\\.gz|\\.br|\\.unityweb)?$/;function f(e){window.fetch=new Proxy(window.fetch,{apply:e})}(()=>{if(window.__appsInToss.webViewType!=="game"||typeof caches>"u")return;let e="@apps-in-toss/caches/",t=`${e}${window.__appsInToss.deploymentId}`;window.addEventListener("load",async()=>{let n=await caches.keys();for(let r of n)r.startsWith(e)&&r!==t&&await caches.delete(r)}),f(async(n,r,a)=>{let o=new Request(a[0],a[1]);if(!d.test(o.url))return await n.call(r,o);let i=await caches.open(t),s=await i.match(o);if(s){let v=s.headers.get("ETag"),_=s.headers.get("Last-Modified");v&&o.headers.set("If-None-Match",v),_&&o.headers.set("If-Modified-Since",_);let p=await n.call(r,o);return p.status===304?(s.__revalidateResponse=p,s):(i.put(o,p.clone()),p)}let w=await n.call(r,o);return i.put(o,w.clone()),w})})();f(async(e,t,n)=>{let r=new Request(n[0],n[1]),a=Date.now();window.__appsInToss.eventEmitter.emit("fetchRequest",{request:r});let o=await e.call(t,r);return window.__appsInToss.eventEmitter.emit("fetchResponse",{request:r,response:o,requestAt:a}),o});var E=window.__appsInToss.debugLogger;E.log("load_start",{});window.addEventListener("load",()=>{let e=performance.timeOrigin,t=performance.getEntriesByType?.("navigation")[0]??null,n=typeof e<"u"&&t!==null,r=n?{navigationStartAtMs:e+t.startTime,navigationRedirectStartAtMs:e+t.redirectStart,navigationRedirectEndAtMs:e+t.redirectEnd,navigationRedirectCount:t.redirectCount,navigationServiceWorkerStartAtMs:e+t.workerStart,navigationFetchStartAtMs:e+t.fetchStart,navigationDomainLookupStartAtMs:e+t.domainLookupStart,navigationDomainLookupEndAtMs:e+t.domainLookupEnd,navigationConnectStartAtMs:e+t.connectStart,navigationSecureConnectStartAtMs:e+t.secureConnectionStart,navigationConnectEndAtMs:e+t.connectEnd,navigationRequestStartAtMs:e+t.requestStart,navigationResponseStartAtMs:e+t.responseStart,navigationResponseEndAtMs:e+t.responseEnd,navigationDomInteractiveAtMs:e+t.domInteractive,navigationDomContentLoadedEventStartAtMs:e+t.domContentLoadedEventStart,navigationDomContentLoadedEventEndAtMs:e+t.domContentLoadedEventEnd,navigationDomCompleteAtMs:e+t.domComplete}:{};E.log("load_complete",{isNavigationDebugSupported:n,...r})});function c(e,t){return parseFloat(e.toFixed(t))}(()=>{if(typeof performance.memory>"u"||typeof performance.memory.usedJSHeapSize>"u"||typeof performance.memory.totalJSHeapSize>"u"||typeof performance.memory.jsHeapSizeLimit>"u")return;function e(t){window.__appsInToss.debugLogger.log(t,{usedJSHeapSize:c(performance.memory.usedJSHeapSize/1024,2),totalJSHeapSize:c(performance.memory.totalJSHeapSize/1024,2),jsHeapSizeLimit:c(performance.memory.jsHeapSizeLimit/1024,2)})}e("memory_usage_first_0s"),setTimeout(()=>e("memory_usage_first_1s"),1e3),setTimeout(()=>e("memory_usage_first_10s"),1e4),setTimeout(()=>e("memory_usage_first_30s"),3e4),setTimeout(()=>e("memory_usage_first_60s"),6e4),setInterval(()=>e("memory_usage_every_180s"),18e4)})();(()=>{let e=window.__appsInToss.debugLogger,t=performance.timeOrigin;if(typeof t>"u"||typeof PerformanceObserver>"u")return;new PerformanceObserver(a=>{a.getEntries().forEach(i=>{i.name==="first-paint"?e.log("first_paint",{fpStartAtMs:t+i.startTime}):i.name==="first-contentful-paint"&&e.log("first_contentful_paint",{fcpStartAtMs:t+i.startTime})})}).observe({type:"paint"}),new PerformanceObserver(a=>{a.getEntries().forEach(i=>{e.log("largest_contentful_paint",{lcpStartAtMs:t+i.startTime,lcpRenderSize:i.size})})}).observe({type:"largest-contentful-paint"})})();(()=>{if(window.__appsInToss.webViewType!=="game")return;function e(t){let n=t.getContext("webgl2")??t.getContext("webgl");if(n==null)return;let r=n.getExtension("WEBGL_debug_renderer_info"),a=n.getParameter(n.MAX_VIEWPORT_DIMS),o={webGLRenderer:n.getParameter(n.RENDERER),webGLVendor:n.getParameter(n.VENDOR),webGLVersion:n.getParameter(n.VERSION),webGLShadingLanguageVersion:n.getParameter(n.SHADING_LANGUAGE_VERSION),webGLMaxTextureSize:n.getParameter(n.MAX_TEXTURE_SIZE),webGLMaxViewportWidth:a[0],webGLMaxViewportHeight:a[1],webGLMaxRenderbufferSize:n.getParameter(n.MAX_RENDERBUFFER_SIZE)},i=r?{webGLUnmaskedVendor:n.getParameter(r.UNMASKED_VENDOR_WEBGL),webGLUnmaskedRenderer:n.getParameter(r.UNMASKED_RENDERER_WEBGL)}:{};window.__appsInToss.debugLogger.log("unity_webgl_info",{...o,...i})}window.addEventListener("load",()=>{let t=document.querySelector("#unity-canvas");if(t!=null){e(t);return}new MutationObserver((r,a)=>{for(let o of r)o.type==="childList"&&o.addedNodes.forEach(i=>{if(i instanceof HTMLCanvasElement&&i.getAttribute("id")==="unity-canvas"&&(e(i),a.disconnect()),i instanceof HTMLElement){let s=i.querySelector("#unity-canvas");s!=null&&(e(s),a.disconnect())}})}).observe(document.body,{childList:!0,subtree:!0})})})();(()=>{if(window.__appsInToss.webViewType!=="game")return;let e=window.__appsInToss.debugLogger,t=window.__appsInToss.eventEmitter;t.on("fetchRequest",({request:n})=>{d.test(n.url)&&e.log("game_resource_download_start",{gameResourceRequestURL:n.url})}),t.on("fetchResponse",async({request:n,requestAt:r,response:a})=>{if(!d.test(n.url))return;let o=c((await a.clone().blob()).size/1024,2),i=Date.now();e.log("game_resource_download_end",{gameResourceRequestURL:n.url,gameResourceRequestAtMs:r,gameResourceResponseAtMs:i,gameResourceResponseSize:o,gameResourceResponseStatus:a.__revalidateResponse?.status??a.status,gameResourceDownloadDurationMs:i-r})})})();})();\n';0&&(module.exports={afterDocumentLoad,beforeDocumentLoad});
package/dist/index.mjs ADDED
@@ -0,0 +1,10 @@
1
+ var e=`"use strict";(()=>{var e=document.createElement("style");e.textContent=\`
2
+ *:not(input):not(textarea) {
3
+ -webkit-user-select: none;
4
+ -moz-user-select: none;
5
+ -ms-user-select: none;
6
+ user-select: none;
7
+ -webkit-touch-callout: none;
8
+ }
9
+ \`;document.head.appendChild(e);})();
10
+ `,t='"use strict";(()=>{var b=class{get _window(){return typeof window<"u"?window:{ReactNativeWebView:{postMessage:()=>{}},__GRANITE_NATIVE_EMITTER:{on:()=>()=>{}},__CONSTANT_HANDLER_MAP:{}}}postMessage(e){let t=this._window.ReactNativeWebView;if(!t)throw new Error("ReactNativeWebView is not available in browser environment");t.postMessage(JSON.stringify(e))}on(e,t){let n=this._window.__GRANITE_NATIVE_EMITTER;if(!n)throw new Error("__GRANITE_NATIVE_EMITTER is not available");return n.on(e,t)}getConstant(e){let t=this._window.__CONSTANT_HANDLER_MAP;if(t&&e in t)return t[e];throw new Error(`${e} is not a constant handler`)}},u=new b,y=()=>Math.random().toString(36).substring(2,15),R=e=>{if(e&&e.__isError){let t=new Error(e.message);for(let[n,r]of Object.entries(e))t[n]=r;return t}return e};function h(e){return(...t)=>{let n=y(),r=[],a=()=>{for(let o of r)o()};return new Promise((o,i)=>{r.push(u.on(`${e}/resolve/${n}`,s=>{a(),o(s)})),r.push(u.on(`${e}/reject/${n}`,s=>{a(),i(R(s))})),u.postMessage({type:"method",functionName:e,eventId:n,args:t})})}}function g(e){return()=>u.getConstant(e)}var m=class{_log=h("debugLog");log(t,n){try{this._log({log_name:`apps_in_toss_webview_${t}`,log_type:"debug",params:{...n,...this.getCommonParams()}})}catch{}}getCommonParams(){return{...this.getLocationInfo(),...this.getNavigatorInfo(),...this.getScreenInfo(),appName:window.__appsInToss.appName,deploymentId:window.__appsInToss.deploymentId,sessionId:window.__appsInToss.sessionId,isGame:window.__appsInToss.webViewType==="game",timestampMs:Date.now()}}getLocationInfo(){return{url:window.location.href,urlOrigin:window.location.origin,urlHost:window.location.hostname,urlPath:window.location.pathname,urlSearch:window.location.search}}getNavigatorInfo(){return{userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,cookieEnabled:navigator.cookieEnabled,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:navigator.deviceMemory?navigator.deviceMemory*1024*1024:void 0,maxTouchPoints:navigator.maxTouchPoints}}getScreenInfo(){return{screenWidth:screen.width,screenHeight:screen.height,availableScreenWidth:screen.availWidth,availableScreenHeight:screen.availHeight,devicePixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,pixelDepth:screen.pixelDepth,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}};var l=class{callbacks={};on(t,n){typeof this.callbacks[t]>"u"&&(this.callbacks[t]=[]),this.callbacks[t].push(n)}emit(t,n){this.callbacks[t]?.forEach(r=>r(n))}};window.__appsInToss={appName:g("getAppName")(),deploymentId:g("getDeploymentId")(),webViewType:g("getWebViewType")(),sessionId:Math.random().toString(36).substring(2),eventEmitter:new l,debugLogger:new m};var d=/\\.(data|wasm|framework\\.js)(?:\\.gz|\\.br|\\.unityweb)?$/;function f(e){window.fetch=new Proxy(window.fetch,{apply:e})}(()=>{if(window.__appsInToss.webViewType!=="game"||typeof caches>"u")return;let e="@apps-in-toss/caches/",t=`${e}${window.__appsInToss.deploymentId}`;window.addEventListener("load",async()=>{let n=await caches.keys();for(let r of n)r.startsWith(e)&&r!==t&&await caches.delete(r)}),f(async(n,r,a)=>{let o=new Request(a[0],a[1]);if(!d.test(o.url))return await n.call(r,o);let i=await caches.open(t),s=await i.match(o);if(s){let v=s.headers.get("ETag"),_=s.headers.get("Last-Modified");v&&o.headers.set("If-None-Match",v),_&&o.headers.set("If-Modified-Since",_);let p=await n.call(r,o);return p.status===304?(s.__revalidateResponse=p,s):(i.put(o,p.clone()),p)}let w=await n.call(r,o);return i.put(o,w.clone()),w})})();f(async(e,t,n)=>{let r=new Request(n[0],n[1]),a=Date.now();window.__appsInToss.eventEmitter.emit("fetchRequest",{request:r});let o=await e.call(t,r);return window.__appsInToss.eventEmitter.emit("fetchResponse",{request:r,response:o,requestAt:a}),o});var E=window.__appsInToss.debugLogger;E.log("load_start",{});window.addEventListener("load",()=>{let e=performance.timeOrigin,t=performance.getEntriesByType?.("navigation")[0]??null,n=typeof e<"u"&&t!==null,r=n?{navigationStartAtMs:e+t.startTime,navigationRedirectStartAtMs:e+t.redirectStart,navigationRedirectEndAtMs:e+t.redirectEnd,navigationRedirectCount:t.redirectCount,navigationServiceWorkerStartAtMs:e+t.workerStart,navigationFetchStartAtMs:e+t.fetchStart,navigationDomainLookupStartAtMs:e+t.domainLookupStart,navigationDomainLookupEndAtMs:e+t.domainLookupEnd,navigationConnectStartAtMs:e+t.connectStart,navigationSecureConnectStartAtMs:e+t.secureConnectionStart,navigationConnectEndAtMs:e+t.connectEnd,navigationRequestStartAtMs:e+t.requestStart,navigationResponseStartAtMs:e+t.responseStart,navigationResponseEndAtMs:e+t.responseEnd,navigationDomInteractiveAtMs:e+t.domInteractive,navigationDomContentLoadedEventStartAtMs:e+t.domContentLoadedEventStart,navigationDomContentLoadedEventEndAtMs:e+t.domContentLoadedEventEnd,navigationDomCompleteAtMs:e+t.domComplete}:{};E.log("load_complete",{isNavigationDebugSupported:n,...r})});function c(e,t){return parseFloat(e.toFixed(t))}(()=>{if(typeof performance.memory>"u"||typeof performance.memory.usedJSHeapSize>"u"||typeof performance.memory.totalJSHeapSize>"u"||typeof performance.memory.jsHeapSizeLimit>"u")return;function e(t){window.__appsInToss.debugLogger.log(t,{usedJSHeapSize:c(performance.memory.usedJSHeapSize/1024,2),totalJSHeapSize:c(performance.memory.totalJSHeapSize/1024,2),jsHeapSizeLimit:c(performance.memory.jsHeapSizeLimit/1024,2)})}e("memory_usage_first_0s"),setTimeout(()=>e("memory_usage_first_1s"),1e3),setTimeout(()=>e("memory_usage_first_10s"),1e4),setTimeout(()=>e("memory_usage_first_30s"),3e4),setTimeout(()=>e("memory_usage_first_60s"),6e4),setInterval(()=>e("memory_usage_every_180s"),18e4)})();(()=>{let e=window.__appsInToss.debugLogger,t=performance.timeOrigin;if(typeof t>"u"||typeof PerformanceObserver>"u")return;new PerformanceObserver(a=>{a.getEntries().forEach(i=>{i.name==="first-paint"?e.log("first_paint",{fpStartAtMs:t+i.startTime}):i.name==="first-contentful-paint"&&e.log("first_contentful_paint",{fcpStartAtMs:t+i.startTime})})}).observe({type:"paint"}),new PerformanceObserver(a=>{a.getEntries().forEach(i=>{e.log("largest_contentful_paint",{lcpStartAtMs:t+i.startTime,lcpRenderSize:i.size})})}).observe({type:"largest-contentful-paint"})})();(()=>{if(window.__appsInToss.webViewType!=="game")return;function e(t){let n=t.getContext("webgl2")??t.getContext("webgl");if(n==null)return;let r=n.getExtension("WEBGL_debug_renderer_info"),a=n.getParameter(n.MAX_VIEWPORT_DIMS),o={webGLRenderer:n.getParameter(n.RENDERER),webGLVendor:n.getParameter(n.VENDOR),webGLVersion:n.getParameter(n.VERSION),webGLShadingLanguageVersion:n.getParameter(n.SHADING_LANGUAGE_VERSION),webGLMaxTextureSize:n.getParameter(n.MAX_TEXTURE_SIZE),webGLMaxViewportWidth:a[0],webGLMaxViewportHeight:a[1],webGLMaxRenderbufferSize:n.getParameter(n.MAX_RENDERBUFFER_SIZE)},i=r?{webGLUnmaskedVendor:n.getParameter(r.UNMASKED_VENDOR_WEBGL),webGLUnmaskedRenderer:n.getParameter(r.UNMASKED_RENDERER_WEBGL)}:{};window.__appsInToss.debugLogger.log("unity_webgl_info",{...o,...i})}window.addEventListener("load",()=>{let t=document.querySelector("#unity-canvas");if(t!=null){e(t);return}new MutationObserver((r,a)=>{for(let o of r)o.type==="childList"&&o.addedNodes.forEach(i=>{if(i instanceof HTMLCanvasElement&&i.getAttribute("id")==="unity-canvas"&&(e(i),a.disconnect()),i instanceof HTMLElement){let s=i.querySelector("#unity-canvas");s!=null&&(e(s),a.disconnect())}})}).observe(document.body,{childList:!0,subtree:!0})})})();(()=>{if(window.__appsInToss.webViewType!=="game")return;let e=window.__appsInToss.debugLogger,t=window.__appsInToss.eventEmitter;t.on("fetchRequest",({request:n})=>{d.test(n.url)&&e.log("game_resource_download_start",{gameResourceRequestURL:n.url})}),t.on("fetchResponse",async({request:n,requestAt:r,response:a})=>{if(!d.test(n.url))return;let o=c((await a.clone().blob()).size/1024,2),i=Date.now();e.log("game_resource_download_end",{gameResourceRequestURL:n.url,gameResourceRequestAtMs:r,gameResourceResponseAtMs:i,gameResourceResponseSize:o,gameResourceResponseStatus:a.__revalidateResponse?.status??a.status,gameResourceDownloadDurationMs:i-r})})})();})();\n';export{e as afterDocumentLoad,t as beforeDocumentLoad};
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@apps-in-toss/user-scripts",
3
+ "version": "1.9.4",
4
+ "main": "./dist/index.js",
5
+ "import": "./dist/index.mjs",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": {
10
+ "types": "./dist/index.d.mts",
11
+ "default": "./dist/index.mjs"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "scripts": {
23
+ "build": "node ./build.mjs"
24
+ },
25
+ "devDependencies": {
26
+ "@apps-in-toss/bridge-core": "^1.9.4",
27
+ "tsup": "^8.3.5",
28
+ "typescript": "5.8.3"
29
+ }
30
+ }