@cloudparse/up-miniapps-sdk 0.6.2 → 0.6.3
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/bin/up-sdk.cjs +3 -1
- package/dist/index.browser.min.js +10 -10
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +106 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -25
- package/dist/index.d.ts +25 -25
- package/dist/index.js +113 -95
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import React__default, { ReactNode } from 'react';
|
|
3
3
|
import { R as RouteResponse, a as RouteStep, b as RouteRequest, c as RoutingBackendConfig } from './index-B9dDciJq.cjs';
|
|
4
4
|
export { C as ClearRouteRequest, D as DrawRouteRequest, h as handleClearRoute, d as handleDrawRoute, e as handleRouteRequest } from './index-B9dDciJq.cjs';
|
|
5
|
-
import { ViewState } from '@vis.gl/react-maplibre';
|
|
5
|
+
import { ViewState, StyleSpecification, ImmutableLike } from '@vis.gl/react-maplibre';
|
|
6
6
|
import * as react_dom_client from 'react-dom/client';
|
|
7
7
|
import { ShapeType, ErrorCorrectionLevel, DotType, Gradient, CornerSquareType, CornerDotType } from 'qr-code-styling';
|
|
8
8
|
import 'maplibre-gl';
|
|
@@ -681,8 +681,8 @@ interface MapProps {
|
|
|
681
681
|
style?: React__default.CSSProperties;
|
|
682
682
|
/** Minimum and maximum bounds for the map. */
|
|
683
683
|
maxBounds?: [[number, number], [number, number]];
|
|
684
|
-
/** MapLibre style URL. Defaults to local server. */
|
|
685
|
-
mapStyle?: string
|
|
684
|
+
/** MapLibre style URL, or an inline style spec object. Defaults to local server. */
|
|
685
|
+
mapStyle?: string | StyleSpecification | ImmutableLike<StyleSpecification>;
|
|
686
686
|
/** Children components (Source, Layer, etc.) */
|
|
687
687
|
children?: React__default.ReactNode;
|
|
688
688
|
/** Additional CSS classes for the map container. */
|
|
@@ -1243,6 +1243,28 @@ declare class MiniAppSDK {
|
|
|
1243
1243
|
*/
|
|
1244
1244
|
render: typeof renderMap;
|
|
1245
1245
|
}>;
|
|
1246
|
+
/**
|
|
1247
|
+
* QR code generation — the single source of truth for every Mini-App.
|
|
1248
|
+
* Runs entirely client-side (canvas, no Host Shell round-trip) and returns
|
|
1249
|
+
* a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
|
|
1250
|
+
* Mini-Apps must not reimplement this on their own.
|
|
1251
|
+
*/
|
|
1252
|
+
readonly qrCode: Readonly<{
|
|
1253
|
+
/**
|
|
1254
|
+
* Decodes a QR code from a static image (base64 data URI or URL) —
|
|
1255
|
+
* e.g. a photo picked via `sdk.media.pickImage()` that already
|
|
1256
|
+
* contains a QR code, as an alternative to the live `<QRScanner>`.
|
|
1257
|
+
* @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
|
|
1258
|
+
* @returns The decoded string, or `null` if no QR code was found.
|
|
1259
|
+
*/
|
|
1260
|
+
decode: (imageDataUrl: string) => Promise<string | null>;
|
|
1261
|
+
/**
|
|
1262
|
+
* @param data The value to encode (e.g. a deep link).
|
|
1263
|
+
* @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
|
|
1264
|
+
* @returns A base64 PNG data URI.
|
|
1265
|
+
*/
|
|
1266
|
+
generate: (data: string, options?: IGenerateQrCodeOptions) => Promise<string>;
|
|
1267
|
+
}>;
|
|
1246
1268
|
private bridge;
|
|
1247
1269
|
/**
|
|
1248
1270
|
* Local SQLite Storage.
|
|
@@ -1349,28 +1371,6 @@ declare class MiniAppSDK {
|
|
|
1349
1371
|
*/
|
|
1350
1372
|
saveImage: (base64: string, filename?: string) => Promise<ISaveImageResult>;
|
|
1351
1373
|
}>;
|
|
1352
|
-
/**
|
|
1353
|
-
* QR code generation — the single source of truth for every Mini-App.
|
|
1354
|
-
* Runs entirely client-side (canvas, no Host Shell round-trip) and returns
|
|
1355
|
-
* a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
|
|
1356
|
-
* Mini-Apps must not reimplement this on their own.
|
|
1357
|
-
*/
|
|
1358
|
-
readonly qrCode: Readonly<{
|
|
1359
|
-
/**
|
|
1360
|
-
* @param data The value to encode (e.g. a deep link).
|
|
1361
|
-
* @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
|
|
1362
|
-
* @returns A base64 PNG data URI.
|
|
1363
|
-
*/
|
|
1364
|
-
generate: (data: string, options?: IGenerateQrCodeOptions) => Promise<string>;
|
|
1365
|
-
/**
|
|
1366
|
-
* Decodes a QR code from a static image (base64 data URI or URL) —
|
|
1367
|
-
* e.g. a photo picked via `sdk.media.pickImage()` that already
|
|
1368
|
-
* contains a QR code, as an alternative to the live `<QRScanner>`.
|
|
1369
|
-
* @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
|
|
1370
|
-
* @returns The decoded string, or `null` if no QR code was found.
|
|
1371
|
-
*/
|
|
1372
|
-
decode: (imageDataUrl: string) => Promise<string | null>;
|
|
1373
|
-
}>;
|
|
1374
1374
|
/**
|
|
1375
1375
|
* Payments integration.
|
|
1376
1376
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import React__default, { ReactNode } from 'react';
|
|
3
3
|
import { R as RouteResponse, a as RouteStep, b as RouteRequest, c as RoutingBackendConfig } from './index-B9dDciJq.js';
|
|
4
4
|
export { C as ClearRouteRequest, D as DrawRouteRequest, h as handleClearRoute, d as handleDrawRoute, e as handleRouteRequest } from './index-B9dDciJq.js';
|
|
5
|
-
import { ViewState } from '@vis.gl/react-maplibre';
|
|
5
|
+
import { ViewState, StyleSpecification, ImmutableLike } from '@vis.gl/react-maplibre';
|
|
6
6
|
import * as react_dom_client from 'react-dom/client';
|
|
7
7
|
import { ShapeType, ErrorCorrectionLevel, DotType, Gradient, CornerSquareType, CornerDotType } from 'qr-code-styling';
|
|
8
8
|
import 'maplibre-gl';
|
|
@@ -681,8 +681,8 @@ interface MapProps {
|
|
|
681
681
|
style?: React__default.CSSProperties;
|
|
682
682
|
/** Minimum and maximum bounds for the map. */
|
|
683
683
|
maxBounds?: [[number, number], [number, number]];
|
|
684
|
-
/** MapLibre style URL. Defaults to local server. */
|
|
685
|
-
mapStyle?: string
|
|
684
|
+
/** MapLibre style URL, or an inline style spec object. Defaults to local server. */
|
|
685
|
+
mapStyle?: string | StyleSpecification | ImmutableLike<StyleSpecification>;
|
|
686
686
|
/** Children components (Source, Layer, etc.) */
|
|
687
687
|
children?: React__default.ReactNode;
|
|
688
688
|
/** Additional CSS classes for the map container. */
|
|
@@ -1243,6 +1243,28 @@ declare class MiniAppSDK {
|
|
|
1243
1243
|
*/
|
|
1244
1244
|
render: typeof renderMap;
|
|
1245
1245
|
}>;
|
|
1246
|
+
/**
|
|
1247
|
+
* QR code generation — the single source of truth for every Mini-App.
|
|
1248
|
+
* Runs entirely client-side (canvas, no Host Shell round-trip) and returns
|
|
1249
|
+
* a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
|
|
1250
|
+
* Mini-Apps must not reimplement this on their own.
|
|
1251
|
+
*/
|
|
1252
|
+
readonly qrCode: Readonly<{
|
|
1253
|
+
/**
|
|
1254
|
+
* Decodes a QR code from a static image (base64 data URI or URL) —
|
|
1255
|
+
* e.g. a photo picked via `sdk.media.pickImage()` that already
|
|
1256
|
+
* contains a QR code, as an alternative to the live `<QRScanner>`.
|
|
1257
|
+
* @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
|
|
1258
|
+
* @returns The decoded string, or `null` if no QR code was found.
|
|
1259
|
+
*/
|
|
1260
|
+
decode: (imageDataUrl: string) => Promise<string | null>;
|
|
1261
|
+
/**
|
|
1262
|
+
* @param data The value to encode (e.g. a deep link).
|
|
1263
|
+
* @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
|
|
1264
|
+
* @returns A base64 PNG data URI.
|
|
1265
|
+
*/
|
|
1266
|
+
generate: (data: string, options?: IGenerateQrCodeOptions) => Promise<string>;
|
|
1267
|
+
}>;
|
|
1246
1268
|
private bridge;
|
|
1247
1269
|
/**
|
|
1248
1270
|
* Local SQLite Storage.
|
|
@@ -1349,28 +1371,6 @@ declare class MiniAppSDK {
|
|
|
1349
1371
|
*/
|
|
1350
1372
|
saveImage: (base64: string, filename?: string) => Promise<ISaveImageResult>;
|
|
1351
1373
|
}>;
|
|
1352
|
-
/**
|
|
1353
|
-
* QR code generation — the single source of truth for every Mini-App.
|
|
1354
|
-
* Runs entirely client-side (canvas, no Host Shell round-trip) and returns
|
|
1355
|
-
* a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
|
|
1356
|
-
* Mini-Apps must not reimplement this on their own.
|
|
1357
|
-
*/
|
|
1358
|
-
readonly qrCode: Readonly<{
|
|
1359
|
-
/**
|
|
1360
|
-
* @param data The value to encode (e.g. a deep link).
|
|
1361
|
-
* @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
|
|
1362
|
-
* @returns A base64 PNG data URI.
|
|
1363
|
-
*/
|
|
1364
|
-
generate: (data: string, options?: IGenerateQrCodeOptions) => Promise<string>;
|
|
1365
|
-
/**
|
|
1366
|
-
* Decodes a QR code from a static image (base64 data URI or URL) —
|
|
1367
|
-
* e.g. a photo picked via `sdk.media.pickImage()` that already
|
|
1368
|
-
* contains a QR code, as an alternative to the live `<QRScanner>`.
|
|
1369
|
-
* @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
|
|
1370
|
-
* @returns The decoded string, or `null` if no QR code was found.
|
|
1371
|
-
*/
|
|
1372
|
-
decode: (imageDataUrl: string) => Promise<string | null>;
|
|
1373
|
-
}>;
|
|
1374
1374
|
/**
|
|
1375
1375
|
* Payments integration.
|
|
1376
1376
|
*/
|
package/dist/index.js
CHANGED
|
@@ -161,35 +161,6 @@ var Bridge = class {
|
|
|
161
161
|
return this.send(type, payload, timeoutMs, retries - 1);
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
sendOnce(type, payload, timeoutMs) {
|
|
165
|
-
return new Promise((resolve, reject) => {
|
|
166
|
-
const callbackId = `${type}_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
167
|
-
const timeout = setTimeout(() => {
|
|
168
|
-
if (this.callbacks.has(callbackId)) {
|
|
169
|
-
this.callbacks.delete(callbackId);
|
|
170
|
-
reject(new BridgeTimeoutError(`Bridge request timeout: ${type}`));
|
|
171
|
-
}
|
|
172
|
-
}, timeoutMs);
|
|
173
|
-
this.callbacks.set(callbackId, {
|
|
174
|
-
reject,
|
|
175
|
-
resolve,
|
|
176
|
-
timeout
|
|
177
|
-
});
|
|
178
|
-
const message = {
|
|
179
|
-
callbackId,
|
|
180
|
-
payload,
|
|
181
|
-
type
|
|
182
|
-
};
|
|
183
|
-
const win = window;
|
|
184
|
-
if (win.ReactNativeWebView?.postMessage) {
|
|
185
|
-
win.ReactNativeWebView.postMessage(JSON.stringify(message));
|
|
186
|
-
} else {
|
|
187
|
-
clearTimeout(timeout);
|
|
188
|
-
this.callbacks.delete(callbackId);
|
|
189
|
-
reject(new Error("Bridge not available"));
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
164
|
/**
|
|
194
165
|
* Internal handler for all incoming messages from the native shell.
|
|
195
166
|
* Matches incoming payloads to either pending callbacks or event listeners.
|
|
@@ -237,6 +208,35 @@ var Bridge = class {
|
|
|
237
208
|
console.warn(`[Bridge] Mock mode active: Unhandled message type ${type}`);
|
|
238
209
|
return Promise.resolve();
|
|
239
210
|
}
|
|
211
|
+
sendOnce(type, payload, timeoutMs) {
|
|
212
|
+
return new Promise((resolve, reject) => {
|
|
213
|
+
const callbackId = `${type}_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
214
|
+
const timeout = setTimeout(() => {
|
|
215
|
+
if (this.callbacks.has(callbackId)) {
|
|
216
|
+
this.callbacks.delete(callbackId);
|
|
217
|
+
reject(new BridgeTimeoutError(`Bridge request timeout: ${type}`));
|
|
218
|
+
}
|
|
219
|
+
}, timeoutMs);
|
|
220
|
+
this.callbacks.set(callbackId, {
|
|
221
|
+
reject,
|
|
222
|
+
resolve,
|
|
223
|
+
timeout
|
|
224
|
+
});
|
|
225
|
+
const message = {
|
|
226
|
+
callbackId,
|
|
227
|
+
payload,
|
|
228
|
+
type
|
|
229
|
+
};
|
|
230
|
+
const win = window;
|
|
231
|
+
if (win.ReactNativeWebView?.postMessage) {
|
|
232
|
+
win.ReactNativeWebView.postMessage(JSON.stringify(message));
|
|
233
|
+
} else {
|
|
234
|
+
clearTimeout(timeout);
|
|
235
|
+
this.callbacks.delete(callbackId);
|
|
236
|
+
reject(new Error("Bridge not available"));
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
240
|
/**
|
|
241
241
|
* Determine environment. Check flag or cache result.
|
|
242
242
|
*/
|
|
@@ -2444,18 +2444,6 @@ var RouteLayer = ({
|
|
|
2444
2444
|
] });
|
|
2445
2445
|
};
|
|
2446
2446
|
|
|
2447
|
-
// src/components/Map/Map.tsx
|
|
2448
|
-
import { Map as MapLibre, MapProvider } from "@vis.gl/react-maplibre";
|
|
2449
|
-
import React4, {
|
|
2450
|
-
useCallback as useCallback6,
|
|
2451
|
-
useContext as useContext5,
|
|
2452
|
-
useEffect as useEffect7,
|
|
2453
|
-
useMemo as useMemo6,
|
|
2454
|
-
useRef as useRef7,
|
|
2455
|
-
useState as useState8
|
|
2456
|
-
} from "react";
|
|
2457
|
-
import "maplibre-gl/dist/maplibre-gl.css";
|
|
2458
|
-
|
|
2459
2447
|
// src/components/Map/utils/geoCircle.ts
|
|
2460
2448
|
var EARTH_RADIUS_METERS = 6371e3;
|
|
2461
2449
|
var buildGeoCircle = (center, radiusMeters, points = 64) => {
|
|
@@ -2847,6 +2835,16 @@ var UserLocationLayer = ({
|
|
|
2847
2835
|
};
|
|
2848
2836
|
|
|
2849
2837
|
// src/components/Map/Map.tsx
|
|
2838
|
+
import { Map as MapLibre, MapProvider } from "@vis.gl/react-maplibre";
|
|
2839
|
+
import React4, {
|
|
2840
|
+
useCallback as useCallback6,
|
|
2841
|
+
useContext as useContext5,
|
|
2842
|
+
useEffect as useEffect7,
|
|
2843
|
+
useMemo as useMemo6,
|
|
2844
|
+
useRef as useRef7,
|
|
2845
|
+
useState as useState8
|
|
2846
|
+
} from "react";
|
|
2847
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
2850
2848
|
import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2851
2849
|
var MapInternal = ({
|
|
2852
2850
|
initialViewState = {
|
|
@@ -3382,7 +3380,12 @@ async function generateQrCode(data, options = {}) {
|
|
|
3382
3380
|
const outerPadding = options.outerPadding ?? 32;
|
|
3383
3381
|
const borderRadiusPercent = options.borderRadius ?? DEFAULT_BORDER_RADIUS_PERCENT;
|
|
3384
3382
|
const composed = label ? await composeWithLabel(qrDataUrl, label, size, backgroundColor, color) : qrDataUrl;
|
|
3385
|
-
return finalizeImage(
|
|
3383
|
+
return finalizeImage(
|
|
3384
|
+
composed,
|
|
3385
|
+
outerPadding,
|
|
3386
|
+
borderRadiusPercent,
|
|
3387
|
+
backgroundColor
|
|
3388
|
+
);
|
|
3386
3389
|
}
|
|
3387
3390
|
var blobToDataUrl = (blob) => new Promise((resolve, reject) => {
|
|
3388
3391
|
const reader = new FileReader();
|
|
@@ -3487,7 +3490,7 @@ var loadImage2 = (src) => new Promise((resolve, reject) => {
|
|
|
3487
3490
|
});
|
|
3488
3491
|
|
|
3489
3492
|
// package.json
|
|
3490
|
-
var version = "0.6.
|
|
3493
|
+
var version = "0.6.3";
|
|
3491
3494
|
|
|
3492
3495
|
// src/sdk.ts
|
|
3493
3496
|
function deepFreeze(obj) {
|
|
@@ -3515,6 +3518,28 @@ var MiniAppSDK = class {
|
|
|
3515
3518
|
*/
|
|
3516
3519
|
render: renderMap
|
|
3517
3520
|
});
|
|
3521
|
+
/**
|
|
3522
|
+
* QR code generation — the single source of truth for every Mini-App.
|
|
3523
|
+
* Runs entirely client-side (canvas, no Host Shell round-trip) and returns
|
|
3524
|
+
* a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
|
|
3525
|
+
* Mini-Apps must not reimplement this on their own.
|
|
3526
|
+
*/
|
|
3527
|
+
qrCode = Object.freeze({
|
|
3528
|
+
/**
|
|
3529
|
+
* Decodes a QR code from a static image (base64 data URI or URL) —
|
|
3530
|
+
* e.g. a photo picked via `sdk.media.pickImage()` that already
|
|
3531
|
+
* contains a QR code, as an alternative to the live `<QRScanner>`.
|
|
3532
|
+
* @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
|
|
3533
|
+
* @returns The decoded string, or `null` if no QR code was found.
|
|
3534
|
+
*/
|
|
3535
|
+
decode: (imageDataUrl) => decodeQrCode(imageDataUrl),
|
|
3536
|
+
/**
|
|
3537
|
+
* @param data The value to encode (e.g. a deep link).
|
|
3538
|
+
* @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
|
|
3539
|
+
* @returns A base64 PNG data URI.
|
|
3540
|
+
*/
|
|
3541
|
+
generate: (data, options) => generateQrCode(data, options)
|
|
3542
|
+
});
|
|
3518
3543
|
bridge;
|
|
3519
3544
|
/**
|
|
3520
3545
|
* Local SQLite Storage.
|
|
@@ -3618,28 +3643,6 @@ var MiniAppSDK = class {
|
|
|
3618
3643
|
*/
|
|
3619
3644
|
saveImage: (base64, filename) => this.bridge.send("SAVE_IMAGE", { base64, filename })
|
|
3620
3645
|
});
|
|
3621
|
-
/**
|
|
3622
|
-
* QR code generation — the single source of truth for every Mini-App.
|
|
3623
|
-
* Runs entirely client-side (canvas, no Host Shell round-trip) and returns
|
|
3624
|
-
* a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
|
|
3625
|
-
* Mini-Apps must not reimplement this on their own.
|
|
3626
|
-
*/
|
|
3627
|
-
qrCode = Object.freeze({
|
|
3628
|
-
/**
|
|
3629
|
-
* @param data The value to encode (e.g. a deep link).
|
|
3630
|
-
* @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
|
|
3631
|
-
* @returns A base64 PNG data URI.
|
|
3632
|
-
*/
|
|
3633
|
-
generate: (data, options) => generateQrCode(data, options),
|
|
3634
|
-
/**
|
|
3635
|
-
* Decodes a QR code from a static image (base64 data URI or URL) —
|
|
3636
|
-
* e.g. a photo picked via `sdk.media.pickImage()` that already
|
|
3637
|
-
* contains a QR code, as an alternative to the live `<QRScanner>`.
|
|
3638
|
-
* @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
|
|
3639
|
-
* @returns The decoded string, or `null` if no QR code was found.
|
|
3640
|
-
*/
|
|
3641
|
-
decode: (imageDataUrl) => decodeQrCode(imageDataUrl)
|
|
3642
|
-
});
|
|
3643
3646
|
/**
|
|
3644
3647
|
* Payments integration.
|
|
3645
3648
|
*/
|
|
@@ -3931,6 +3934,40 @@ function getMockAvatarUrl(seed) {
|
|
|
3931
3934
|
const shortSeed = hashToShortSeed(seed);
|
|
3932
3935
|
return `https://api.dicebear.com/10.x/notionists-neutral/png?seed=${shortSeed}&mouth=${AVATAR_MOUTH_VARIANTS}&eyes=${AVATAR_EYES_VARIANTS}&glassesProbability=50`;
|
|
3933
3936
|
}
|
|
3937
|
+
function decodeMockJWTPayload(token) {
|
|
3938
|
+
try {
|
|
3939
|
+
const raw = token.startsWith("Bearer ") ? token.slice(7) : token;
|
|
3940
|
+
const base64Url = raw.split(".")[1];
|
|
3941
|
+
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
3942
|
+
const jsonPayload = decodeURIComponent(
|
|
3943
|
+
atob(base64).split("").map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`).join("")
|
|
3944
|
+
);
|
|
3945
|
+
return JSON.parse(jsonPayload);
|
|
3946
|
+
} catch {
|
|
3947
|
+
return null;
|
|
3948
|
+
}
|
|
3949
|
+
}
|
|
3950
|
+
function buildMockProfile(mockJWTToken) {
|
|
3951
|
+
const claims = mockJWTToken ? decodeMockJWTPayload(mockJWTToken) : null;
|
|
3952
|
+
const uuid = claims?.sub || "mock-user-42";
|
|
3953
|
+
const fullName = claims?.name || claims?.username || "Smart Caveman";
|
|
3954
|
+
const username = claims?.username || "smart_caveman";
|
|
3955
|
+
const [firstName, ...lastNameParts] = fullName.split(" ");
|
|
3956
|
+
return {
|
|
3957
|
+
admin: true,
|
|
3958
|
+
countryCode: "FR",
|
|
3959
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3960
|
+
email: "caveman@up.app",
|
|
3961
|
+
firstName: firstName || "Smart",
|
|
3962
|
+
fullName,
|
|
3963
|
+
lastName: lastNameParts.join(" ") || "Caveman",
|
|
3964
|
+
localNumber: "0600000000",
|
|
3965
|
+
ups: 100,
|
|
3966
|
+
username,
|
|
3967
|
+
uuid,
|
|
3968
|
+
xp: 500
|
|
3969
|
+
};
|
|
3970
|
+
}
|
|
3934
3971
|
var getBearing = (p1, p2) => {
|
|
3935
3972
|
const lat1 = p1[1] * Math.PI / 180;
|
|
3936
3973
|
const lat2 = p2[1] * Math.PI / 180;
|
|
@@ -4162,20 +4199,7 @@ var BridgeMocker = ({
|
|
|
4162
4199
|
insets: { bottom: 0, left: 0, right: 0, top: 0 },
|
|
4163
4200
|
name: "Vite Dev (Mock)",
|
|
4164
4201
|
params: {},
|
|
4165
|
-
profile:
|
|
4166
|
-
admin: true,
|
|
4167
|
-
countryCode: "FR",
|
|
4168
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4169
|
-
email: "caveman@up.app",
|
|
4170
|
-
firstName: "Smart",
|
|
4171
|
-
fullName: "Smart Caveman",
|
|
4172
|
-
lastName: "Caveman",
|
|
4173
|
-
localNumber: "0600000000",
|
|
4174
|
-
ups: 100,
|
|
4175
|
-
username: "smart_caveman",
|
|
4176
|
-
uuid: "mock-user-42",
|
|
4177
|
-
xp: 500
|
|
4178
|
-
},
|
|
4202
|
+
profile: buildMockProfile(stateRef.current.mockJWTToken),
|
|
4179
4203
|
success: true,
|
|
4180
4204
|
userData: {},
|
|
4181
4205
|
uuid: appId || "mock-app-id",
|
|
@@ -4216,20 +4240,7 @@ var BridgeMocker = ({
|
|
|
4216
4240
|
return Promise.resolve();
|
|
4217
4241
|
}
|
|
4218
4242
|
if (type === "GET_USER_PROFILE") {
|
|
4219
|
-
return Promise.resolve(
|
|
4220
|
-
admin: true,
|
|
4221
|
-
countryCode: "FR",
|
|
4222
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4223
|
-
email: "caveman@up.app",
|
|
4224
|
-
firstName: "Smart",
|
|
4225
|
-
fullName: "Smart Caveman",
|
|
4226
|
-
lastName: "Caveman",
|
|
4227
|
-
localNumber: "0600000000",
|
|
4228
|
-
ups: 100,
|
|
4229
|
-
username: "smart_caveman",
|
|
4230
|
-
uuid: "mock-user-42",
|
|
4231
|
-
xp: 500
|
|
4232
|
-
});
|
|
4243
|
+
return Promise.resolve(buildMockProfile(stateRef.current.mockJWTToken));
|
|
4233
4244
|
}
|
|
4234
4245
|
if (type === "GET_PROFILE_PICTURE") {
|
|
4235
4246
|
const uuids = payload?.uuids || [];
|
|
@@ -5236,9 +5247,16 @@ function createWsService(options) {
|
|
|
5236
5247
|
};
|
|
5237
5248
|
};
|
|
5238
5249
|
if (channelField) {
|
|
5239
|
-
return {
|
|
5250
|
+
return {
|
|
5251
|
+
connect,
|
|
5252
|
+
disconnect,
|
|
5253
|
+
getStatus,
|
|
5254
|
+
onMessage,
|
|
5255
|
+
onStatusChange,
|
|
5256
|
+
subscribe
|
|
5257
|
+
};
|
|
5240
5258
|
}
|
|
5241
|
-
return { connect, disconnect,
|
|
5259
|
+
return { connect, disconnect, getStatus, onMessage, onStatusChange };
|
|
5242
5260
|
}
|
|
5243
5261
|
|
|
5244
5262
|
// src/index.ts
|