@cloudparse/up-miniapps-sdk 0.6.6 → 0.6.7
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/index.browser.min.js +2 -2
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +58 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +58 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -267,11 +267,61 @@ var Bridge = class {
|
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
/**
|
|
270
|
-
* Internal handler for mock message processing, overrideable in test environments
|
|
270
|
+
* Internal handler for mock message processing, overrideable in test environments.
|
|
271
|
+
*
|
|
272
|
+
* Every mini-app that calls a bridge method also has to run standalone in a plain
|
|
273
|
+
* browser (dev, and this vault's own Chrome-based verification) with no native shell
|
|
274
|
+
* attached — `isNative()` is false, so `send()` never round-trips through the real
|
|
275
|
+
* host at all. Before this switch existed, EVERY unhandled type here resolved with
|
|
276
|
+
* plain `undefined` (see the `default` branch below), which silently broke any caller
|
|
277
|
+
* checking a result shape like `{success: boolean}` — `undefined?.success` reads as
|
|
278
|
+
* `false`, not "no answer", so e.g. `sdk.media.saveImage()` looked like a real
|
|
279
|
+
* permission-denied rejection in the browser instead of "there's no native shell
|
|
280
|
+
* here to ask." Add a `case` here — instead of leaving every mini-app to
|
|
281
|
+
* individually special-case "what happens when I call this with no shell attached" —
|
|
282
|
+
* whenever a bridge method's mock behavior should be more than a no-op.
|
|
271
283
|
*/
|
|
272
284
|
handleMockMessage(type, payload) {
|
|
273
|
-
|
|
274
|
-
|
|
285
|
+
switch (type) {
|
|
286
|
+
case "SAVE_IMAGE":
|
|
287
|
+
return this.mockSaveImage(
|
|
288
|
+
payload
|
|
289
|
+
);
|
|
290
|
+
default:
|
|
291
|
+
console.warn(
|
|
292
|
+
`[Bridge] Mock mode active: Unhandled message type ${type}`
|
|
293
|
+
);
|
|
294
|
+
return Promise.resolve();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Standalone-browser stand-in for the native `SAVE_IMAGE` handler: triggers a real
|
|
299
|
+
* browser download (an `<a download>` click) instead of writing to a device photo
|
|
300
|
+
* library, which doesn't exist here. Resolves `{success: true}` on a real trigger so
|
|
301
|
+
* every mini-app's own `result?.success` check gets the same shape/semantics as the
|
|
302
|
+
* real native response — no per-app "am I in mock mode" branching needed. Consumers
|
|
303
|
+
* can still keep their own `catch` fallback for the genuinely different case of a
|
|
304
|
+
* native shell that's missing its WebView bridge (see `sendOnce`'s own rejection
|
|
305
|
+
* path) — that's a real native edge case, not mocking, and this method never runs
|
|
306
|
+
* for it (`send()` only reaches `handleMockMessage` when `!isNative()`).
|
|
307
|
+
*/
|
|
308
|
+
mockSaveImage(payload) {
|
|
309
|
+
if (typeof document === "undefined") {
|
|
310
|
+
return Promise.resolve({ success: false });
|
|
311
|
+
}
|
|
312
|
+
try {
|
|
313
|
+
const href = payload.base64.startsWith("data:") ? payload.base64 : `data:image/png;base64,${payload.base64}`;
|
|
314
|
+
const link = document.createElement("a");
|
|
315
|
+
link.href = href;
|
|
316
|
+
link.download = payload.filename ? `${payload.filename}.png` : "image.png";
|
|
317
|
+
document.body.appendChild(link);
|
|
318
|
+
link.click();
|
|
319
|
+
link.remove();
|
|
320
|
+
return Promise.resolve({ success: true });
|
|
321
|
+
} catch (err) {
|
|
322
|
+
console.warn("[Bridge] Mock SAVE_IMAGE download failed:", err);
|
|
323
|
+
return Promise.resolve({ success: false });
|
|
324
|
+
}
|
|
275
325
|
}
|
|
276
326
|
sendOnce(type, payload, timeoutMs) {
|
|
277
327
|
return new Promise((resolve, reject) => {
|
|
@@ -3715,7 +3765,7 @@ var RoutingService = {
|
|
|
3715
3765
|
};
|
|
3716
3766
|
|
|
3717
3767
|
// package.json
|
|
3718
|
-
var version = "0.6.
|
|
3768
|
+
var version = "0.6.7";
|
|
3719
3769
|
|
|
3720
3770
|
// src/sdk.ts
|
|
3721
3771
|
function deepFreeze(obj) {
|
|
@@ -4870,7 +4920,10 @@ var RESISTANCE = 0.5;
|
|
|
4870
4920
|
var DRAG_DEADZONE = 8;
|
|
4871
4921
|
var FLING_FRICTION = 0.95;
|
|
4872
4922
|
var FLING_MIN_VELOCITY = 0.02;
|
|
4873
|
-
function DefaultIndicator({
|
|
4923
|
+
function DefaultIndicator({
|
|
4924
|
+
progress,
|
|
4925
|
+
isRefreshing
|
|
4926
|
+
}) {
|
|
4874
4927
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
4875
4928
|
"div",
|
|
4876
4929
|
{
|