@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const SDK_VERSION = typeof "0.2.0
|
|
2
|
-
? "0.2.0
|
|
1
|
+
const SDK_VERSION = typeof "0.2.0+12c5b00" === 'string' && "0.2.0+12c5b00".length > 0
|
|
2
|
+
? "0.2.0+12c5b00"
|
|
3
3
|
: '0.0.0-dev';
|
|
4
4
|
|
|
5
5
|
const ORCHESTRATOR_BASE_URL = typeof "https://devices.zerogpu.ai" === 'string' && "https://devices.zerogpu.ai".length > 0
|
|
@@ -253,6 +253,24 @@ const getTelegramUser = () => {
|
|
|
253
253
|
}
|
|
254
254
|
return parseTelegramUserFromHash();
|
|
255
255
|
};
|
|
256
|
+
/**
|
|
257
|
+
* True inside a Telegram Mini App WebView — detected via the injected bridge
|
|
258
|
+
* object or the tgWebAppData launch hash (the same two signals the registry's
|
|
259
|
+
* sdk-type classification trusts). Environment quirks key off this; above all
|
|
260
|
+
* the fabricated navigator.storage.estimate() answers of embedded WebViews.
|
|
261
|
+
*/
|
|
262
|
+
const isTelegramWebAppContext = () => {
|
|
263
|
+
try {
|
|
264
|
+
if (typeof window === 'undefined')
|
|
265
|
+
return false;
|
|
266
|
+
if (window.Telegram?.WebApp)
|
|
267
|
+
return true;
|
|
268
|
+
return (window.location?.hash || '').includes('tgWebAppData');
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
256
274
|
const collectDeviceInfo = async (config, appUserId, sdkDeviceId) => {
|
|
257
275
|
const screen = window.screen || { width: null, height: null };
|
|
258
276
|
const tg = window.Telegram?.WebApp;
|
|
@@ -2097,20 +2115,26 @@ const evaluateResourceGate = async (model, stage, deviceInfo) => {
|
|
|
2097
2115
|
if (stage === 'download') {
|
|
2098
2116
|
try {
|
|
2099
2117
|
const estimate = await navigator.storage?.estimate?.();
|
|
2100
|
-
// quota > 0 is required for the numbers to mean anything
|
|
2101
|
-
//
|
|
2102
|
-
//
|
|
2103
|
-
//
|
|
2104
|
-
//
|
|
2105
|
-
//
|
|
2106
|
-
//
|
|
2107
|
-
//
|
|
2108
|
-
|
|
2118
|
+
// quota > 0 is required for the numbers to mean anything — and even
|
|
2119
|
+
// then, never inside a Telegram WebView. Embedded WebViews fabricate
|
|
2120
|
+
// estimates in BOTH directions while writes succeed anyway: Telegram
|
|
2121
|
+
// iOS WKWebViews answered quota=0 on some devices and quota===usage
|
|
2122
|
+
// (free=0) on others (2026-07-24 prod, two incident rounds). Inside
|
|
2123
|
+
// that context this check is skipped and the download itself is the
|
|
2124
|
+
// arbiter — a genuinely impossible download fails fast and cleanly.
|
|
2125
|
+
// In real browsers a full origin (quota > 0, usage ≈ quota) still
|
|
2126
|
+
// blocks before wasting the bandwidth.
|
|
2127
|
+
if (estimate &&
|
|
2128
|
+
typeof estimate.quota === 'number' &&
|
|
2129
|
+
typeof estimate.usage === 'number' &&
|
|
2130
|
+
estimate.quota > 0 &&
|
|
2131
|
+
!isTelegramWebAppContext()) {
|
|
2109
2132
|
const free = estimate.quota - estimate.usage;
|
|
2110
2133
|
if (sizeBytes * guardrails.storageHeadroom > free) {
|
|
2111
2134
|
return {
|
|
2112
2135
|
code: 'storage_quota_exceeded',
|
|
2113
|
-
message: `need ${Math.round(sizeBytes * guardrails.storageHeadroom)} B, quota headroom ${free} B`
|
|
2136
|
+
message: `need ${Math.round(sizeBytes * guardrails.storageHeadroom)} B, quota headroom ${free} B ` +
|
|
2137
|
+
`(quota ${estimate.quota} B, usage ${estimate.usage} B)`
|
|
2114
2138
|
};
|
|
2115
2139
|
}
|
|
2116
2140
|
}
|