@zerogpu/browser-extension-sdk 0.2.0-dev.202607241630.gdb7f26a → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/zerogpu-assets.json +3 -3
- package/dist/extension/zerogpu-offscreen.js +36 -12
- package/dist/extension/zerogpu-offscreen.js.map +1 -1
- package/dist/manifest.json +6 -6
- package/dist/types/device/telemetry.d.ts +7 -0
- package/dist/v/{zerogpu-browser-sdk.75eb370e6d38.umd.js → zerogpu-browser-sdk.af4825958dcb.umd.js} +37 -13
- package/dist/v/zerogpu-browser-sdk.af4825958dcb.umd.js.map +1 -0
- package/dist/zerogpu-browser-sdk.cjs +36 -12
- package/dist/zerogpu-browser-sdk.cjs.map +1 -1
- package/dist/zerogpu-browser-sdk.esm.js +36 -12
- package/dist/zerogpu-browser-sdk.esm.js.map +1 -1
- package/dist/zerogpu-browser-sdk.umd.js +36 -12
- package/dist/zerogpu-browser-sdk.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/v/zerogpu-browser-sdk.75eb370e6d38.umd.js.map +0 -1
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ZeroGpuBrowserSdk = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const SDK_VERSION = typeof "0.2.0
|
|
8
|
-
? "0.2.0
|
|
7
|
+
const SDK_VERSION = typeof "0.2.0+12c5b00" === 'string' && "0.2.0+12c5b00".length > 0
|
|
8
|
+
? "0.2.0+12c5b00"
|
|
9
9
|
: '0.0.0-dev';
|
|
10
10
|
|
|
11
11
|
const ORCHESTRATOR_BASE_URL = typeof "https://devices.zerogpu.ai" === 'string' && "https://devices.zerogpu.ai".length > 0
|
|
@@ -259,6 +259,24 @@
|
|
|
259
259
|
}
|
|
260
260
|
return parseTelegramUserFromHash();
|
|
261
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* True inside a Telegram Mini App WebView — detected via the injected bridge
|
|
264
|
+
* object or the tgWebAppData launch hash (the same two signals the registry's
|
|
265
|
+
* sdk-type classification trusts). Environment quirks key off this; above all
|
|
266
|
+
* the fabricated navigator.storage.estimate() answers of embedded WebViews.
|
|
267
|
+
*/
|
|
268
|
+
const isTelegramWebAppContext = () => {
|
|
269
|
+
try {
|
|
270
|
+
if (typeof window === 'undefined')
|
|
271
|
+
return false;
|
|
272
|
+
if (window.Telegram?.WebApp)
|
|
273
|
+
return true;
|
|
274
|
+
return (window.location?.hash || '').includes('tgWebAppData');
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
262
280
|
const collectDeviceInfo = async (config, appUserId, sdkDeviceId) => {
|
|
263
281
|
const screen = window.screen || { width: null, height: null };
|
|
264
282
|
const tg = window.Telegram?.WebApp;
|
|
@@ -2103,20 +2121,26 @@
|
|
|
2103
2121
|
if (stage === 'download') {
|
|
2104
2122
|
try {
|
|
2105
2123
|
const estimate = await navigator.storage?.estimate?.();
|
|
2106
|
-
// quota > 0 is required for the numbers to mean anything
|
|
2107
|
-
//
|
|
2108
|
-
//
|
|
2109
|
-
//
|
|
2110
|
-
//
|
|
2111
|
-
//
|
|
2112
|
-
//
|
|
2113
|
-
//
|
|
2114
|
-
|
|
2124
|
+
// quota > 0 is required for the numbers to mean anything — and even
|
|
2125
|
+
// then, never inside a Telegram WebView. Embedded WebViews fabricate
|
|
2126
|
+
// estimates in BOTH directions while writes succeed anyway: Telegram
|
|
2127
|
+
// iOS WKWebViews answered quota=0 on some devices and quota===usage
|
|
2128
|
+
// (free=0) on others (2026-07-24 prod, two incident rounds). Inside
|
|
2129
|
+
// that context this check is skipped and the download itself is the
|
|
2130
|
+
// arbiter — a genuinely impossible download fails fast and cleanly.
|
|
2131
|
+
// In real browsers a full origin (quota > 0, usage ≈ quota) still
|
|
2132
|
+
// blocks before wasting the bandwidth.
|
|
2133
|
+
if (estimate &&
|
|
2134
|
+
typeof estimate.quota === 'number' &&
|
|
2135
|
+
typeof estimate.usage === 'number' &&
|
|
2136
|
+
estimate.quota > 0 &&
|
|
2137
|
+
!isTelegramWebAppContext()) {
|
|
2115
2138
|
const free = estimate.quota - estimate.usage;
|
|
2116
2139
|
if (sizeBytes * guardrails.storageHeadroom > free) {
|
|
2117
2140
|
return {
|
|
2118
2141
|
code: 'storage_quota_exceeded',
|
|
2119
|
-
message: `need ${Math.round(sizeBytes * guardrails.storageHeadroom)} B, quota headroom ${free} B`
|
|
2142
|
+
message: `need ${Math.round(sizeBytes * guardrails.storageHeadroom)} B, quota headroom ${free} B ` +
|
|
2143
|
+
`(quota ${estimate.quota} B, usage ${estimate.usage} B)`
|
|
2120
2144
|
};
|
|
2121
2145
|
}
|
|
2122
2146
|
}
|