@theaiplatform/miniapp-sdk 0.0.1 → 0.1.0-dev.5264044
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/README.md +2 -58
- package/THIRD_PARTY_NOTICES.md +14 -40
- package/dist/index.d.ts +0 -74
- package/dist/rspack/index.js +0 -119
- package/dist/sdk.d.ts +0 -74
- package/dist/web.d.ts +0 -93
- package/dist/web.js +1 -37
- package/package.json +44 -48
- package/dist/ui/styles.css +0 -3694
- package/dist/ui/tailwind.css +0 -112
- package/dist/ui/theme.css +0 -335
- package/dist/ui.d.ts +0 -826
- package/dist/ui.js +0 -1852
- package/ui-components.json +0 -59
package/README.md
CHANGED
|
@@ -8,9 +8,8 @@ pnpm add @theaiplatform/miniapp-sdk
|
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
The package provides the host-injected SDK API, isolated surface lifecycle
|
|
11
|
-
types, browser helpers,
|
|
12
|
-
|
|
13
|
-
targets.
|
|
11
|
+
types, browser helpers, manifest schema, and the Rspack/Rslib integration used
|
|
12
|
+
to produce descriptor-backed Module Federation targets.
|
|
14
13
|
|
|
15
14
|
Start with the [Miniapp SDK documentation](https://docs.theaiplatform.app/miniapps/).
|
|
16
15
|
|
|
@@ -19,10 +18,6 @@ Start with the [Miniapp SDK documentation](https://docs.theaiplatform.app/miniap
|
|
|
19
18
|
- `@theaiplatform/miniapp-sdk`
|
|
20
19
|
- `@theaiplatform/miniapp-sdk/sdk`
|
|
21
20
|
- `@theaiplatform/miniapp-sdk/web`
|
|
22
|
-
- `@theaiplatform/miniapp-sdk/ui`
|
|
23
|
-
- `@theaiplatform/miniapp-sdk/ui/styles.css`
|
|
24
|
-
- `@theaiplatform/miniapp-sdk/ui/tailwind.css`
|
|
25
|
-
- `@theaiplatform/miniapp-sdk/ui-components.json`
|
|
26
21
|
- `@theaiplatform/miniapp-sdk/surface`
|
|
27
22
|
- `@theaiplatform/miniapp-sdk/config`
|
|
28
23
|
- `@theaiplatform/miniapp-sdk/rspack`
|
|
@@ -30,57 +25,6 @@ Start with the [Miniapp SDK documentation](https://docs.theaiplatform.app/miniap
|
|
|
30
25
|
|
|
31
26
|
The host API is injected at runtime. Importing an entry point is safe in build
|
|
32
27
|
tools and tests; host-backed calls fail when used outside a supported runtime.
|
|
33
|
-
`sdk.storage` provides revisioned non-secret JSON scoped by the host to the
|
|
34
|
-
active workspace and exact package. `sdk.presence` provides host-stamped,
|
|
35
|
-
ephemeral room membership and state; package code never supplies participant
|
|
36
|
-
identity.
|
|
37
|
-
|
|
38
|
-
## Portable UI
|
|
39
|
-
|
|
40
|
-
Import the precompiled stylesheet once at the miniapp entry point, then use
|
|
41
|
-
components from the public UI entry. React 19 is a peer dependency.
|
|
42
|
-
|
|
43
|
-
```tsx
|
|
44
|
-
import '@theaiplatform/miniapp-sdk/ui/styles.css';
|
|
45
|
-
|
|
46
|
-
import {
|
|
47
|
-
Button,
|
|
48
|
-
Card,
|
|
49
|
-
CardContent,
|
|
50
|
-
CardHeader,
|
|
51
|
-
CardTitle,
|
|
52
|
-
} from '@theaiplatform/miniapp-sdk/ui';
|
|
53
|
-
|
|
54
|
-
export function WelcomeCard() {
|
|
55
|
-
return (
|
|
56
|
-
<Card>
|
|
57
|
-
<CardHeader>
|
|
58
|
-
<CardTitle>Ready to build</CardTitle>
|
|
59
|
-
</CardHeader>
|
|
60
|
-
<CardContent>
|
|
61
|
-
<Button>Continue</Button>
|
|
62
|
-
</CardContent>
|
|
63
|
-
</Card>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
Tailwind v4 miniapps can instead import the source integration after
|
|
69
|
-
`tailwindcss` and `tw-animate-css`; it supplies the platform theme and scans the
|
|
70
|
-
SDK's UI bundle for component classes.
|
|
71
|
-
|
|
72
|
-
```css
|
|
73
|
-
@import 'tailwindcss' source(none);
|
|
74
|
-
@import 'tw-animate-css';
|
|
75
|
-
@import '@theaiplatform/miniapp-sdk/ui/tailwind.css';
|
|
76
|
-
|
|
77
|
-
@source './src';
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Use `installMiniAppAppearanceSync()` from the `/web` entry to apply the host's
|
|
81
|
-
light/dark theme and bounded UI scale. Tools and agents can read the exported
|
|
82
|
-
`ui-components.json` catalog to discover the supported component families and
|
|
83
|
-
style entry points without importing application-private packages.
|
|
84
28
|
|
|
85
29
|
## License and public policies
|
|
86
30
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -2,52 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## Scope
|
|
4
4
|
|
|
5
|
-
The `@theaiplatform/miniapp-sdk`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this package and remain subject to their own licenses.
|
|
5
|
+
The `@theaiplatform/miniapp-sdk` package tarball does not embed third-party
|
|
6
|
+
package code. Its `./rspack` entry imports separately installed runtime
|
|
7
|
+
dependencies. Optional peer dependencies are not distributed with this package
|
|
8
|
+
and remain subject to their own licenses.
|
|
10
9
|
|
|
11
10
|
The inventory below records the direct and transitive runtime dependency
|
|
12
|
-
versions resolved by the release workspace lockfile on July
|
|
11
|
+
versions resolved by the release workspace lockfile on July 15, 2026. A
|
|
13
12
|
downstream application may resolve a different compatible transitive version
|
|
14
13
|
and is responsible for reviewing the notices required by its own lockfile and
|
|
15
14
|
distribution artifact.
|
|
16
15
|
|
|
17
|
-
| Relationship | Package
|
|
18
|
-
| ---------------- |
|
|
19
|
-
| Direct
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
| Direct
|
|
25
|
-
|
|
|
26
|
-
| Direct UI | `@radix-ui/react-scroll-area` | 1.2.10 | MIT |
|
|
27
|
-
| Direct UI | `@radix-ui/react-select` | 2.2.6 | MIT |
|
|
28
|
-
| Direct UI | `@radix-ui/react-separator` | 1.1.8 | MIT |
|
|
29
|
-
| Direct UI | `@radix-ui/react-slider` | 1.3.6 | MIT |
|
|
30
|
-
| Direct UI | `@radix-ui/react-slot` | 1.2.4 | MIT |
|
|
31
|
-
| Direct UI | `@radix-ui/react-tabs` | 1.1.13 | MIT |
|
|
32
|
-
| Direct UI | `@radix-ui/react-toggle` | 1.1.10 | MIT |
|
|
33
|
-
| Direct UI | `@radix-ui/react-toggle-group` | 1.1.11 | MIT |
|
|
34
|
-
| Direct UI | `@radix-ui/react-tooltip` | 1.2.8 | MIT |
|
|
35
|
-
| Direct UI | `class-variance-authority` | 0.7.1 | Apache-2.0 |
|
|
36
|
-
| Direct UI | `clsx` | 2.1.1 | MIT |
|
|
37
|
-
| Direct UI | `lucide-react` | 1.20.0 | ISC |
|
|
38
|
-
| Direct UI | `prism-react-renderer` | 2.4.1 | MIT |
|
|
39
|
-
| Direct UI | `react-resizable-panels` | 4.11.1 | MIT |
|
|
40
|
-
| Direct UI | `tailwind-merge` | 3.6.0 | MIT |
|
|
41
|
-
| Styles build | `@tailwindcss/postcss` | 4.3.0 | MIT |
|
|
42
|
-
| Styles build | `tailwindcss` | 4.3.0 | MIT |
|
|
43
|
-
| Styles build | `tw-animate-css` | 1.4.0 | MIT |
|
|
44
|
-
| Direct | `ajv` | 8.20.0 | MIT |
|
|
45
|
-
| Ajv transitive | `fast-deep-equal` | 3.1.3 | MIT |
|
|
46
|
-
| Ajv transitive | `fast-uri` | 3.1.2 | BSD-3-Clause |
|
|
47
|
-
| Ajv transitive | `json-schema-traverse` | 1.0.0 | MIT |
|
|
48
|
-
| Ajv transitive | `require-from-string` | 2.0.2 | MIT |
|
|
49
|
-
| Direct | `saxes` | 6.0.0 | ISC |
|
|
50
|
-
| Saxes transitive | `xmlchars` | 2.2.0 | MIT |
|
|
16
|
+
| Relationship | Package | Version | License |
|
|
17
|
+
| ---------------- | ---------------------- | ------: | ------------ |
|
|
18
|
+
| Direct | `ajv` | 8.20.0 | MIT |
|
|
19
|
+
| Ajv transitive | `fast-deep-equal` | 3.1.3 | MIT |
|
|
20
|
+
| Ajv transitive | `fast-uri` | 3.1.2 | BSD-3-Clause |
|
|
21
|
+
| Ajv transitive | `json-schema-traverse` | 1.0.0 | MIT |
|
|
22
|
+
| Ajv transitive | `require-from-string` | 2.0.2 | MIT |
|
|
23
|
+
| Direct | `saxes` | 6.0.0 | ISC |
|
|
24
|
+
| Saxes transitive | `xmlchars` | 2.2.0 | MIT |
|
|
51
25
|
|
|
52
26
|
## License texts
|
|
53
27
|
|
package/dist/index.d.ts
CHANGED
|
@@ -245,8 +245,6 @@ export declare type MiniAppPlatformApi = {
|
|
|
245
245
|
open(options: OpenNavigationOptions): void | Promise<void>;
|
|
246
246
|
};
|
|
247
247
|
chat: MiniAppChatApi;
|
|
248
|
-
storage: MiniAppStorageApi;
|
|
249
|
-
presence: MiniAppPresenceApi;
|
|
250
248
|
/** Browser capabilities appear only when the selected target supports them. */
|
|
251
249
|
auth?: MiniAppAuthApi;
|
|
252
250
|
vfs?: MiniAppVfsApi;
|
|
@@ -255,41 +253,6 @@ export declare type MiniAppPlatformApi = {
|
|
|
255
253
|
hasHostHttpRequest?: boolean;
|
|
256
254
|
};
|
|
257
255
|
|
|
258
|
-
export declare type MiniAppPresenceAddress = {
|
|
259
|
-
namespace: string;
|
|
260
|
-
room: string;
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Ephemeral realtime presence scoped by the host to the active workspace and
|
|
265
|
-
* exact package. Participant identity is stamped by the host, not the app.
|
|
266
|
-
*/
|
|
267
|
-
export declare type MiniAppPresenceApi = {
|
|
268
|
-
join(options: MiniAppPresenceUpdateOptions): MiniAppMaybePromise<MiniAppPresenceSnapshot>;
|
|
269
|
-
update(options: MiniAppPresenceUpdateOptions): MiniAppMaybePromise<MiniAppPresenceSnapshot>;
|
|
270
|
-
leave(options: MiniAppPresenceAddress): MiniAppMaybePromise<void>;
|
|
271
|
-
subscribe(options: MiniAppPresenceAddress, listener: MiniAppPresenceListener): () => void;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
export declare type MiniAppPresenceListener = (snapshot: MiniAppPresenceSnapshot) => void;
|
|
275
|
-
|
|
276
|
-
export declare type MiniAppPresenceParticipant = {
|
|
277
|
-
/** Host-derived, ephemeral participant identity. */
|
|
278
|
-
participantId: string;
|
|
279
|
-
displayName: string;
|
|
280
|
-
state: MiniAppJsonValue;
|
|
281
|
-
updatedAtMs: number;
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
export declare type MiniAppPresenceSnapshot = MiniAppPresenceAddress & {
|
|
285
|
-
selfParticipantId: string;
|
|
286
|
-
participants: MiniAppPresenceParticipant[];
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
export declare type MiniAppPresenceUpdateOptions = MiniAppPresenceAddress & {
|
|
290
|
-
state: MiniAppJsonValue;
|
|
291
|
-
};
|
|
292
|
-
|
|
293
256
|
export declare type MiniAppProject = {
|
|
294
257
|
id: string;
|
|
295
258
|
name: string;
|
|
@@ -389,43 +352,6 @@ export declare type MiniAppSpecialistTurnResult = {
|
|
|
389
352
|
};
|
|
390
353
|
};
|
|
391
354
|
|
|
392
|
-
/** Caller-selected partition inside the host-derived workspace/package scope. */
|
|
393
|
-
export declare type MiniAppStorageAddress = {
|
|
394
|
-
namespace: string;
|
|
395
|
-
key: string;
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Durable, non-secret JSON storage. The host derives workspace and package
|
|
400
|
-
* identity from the authenticated frame; apps control only the namespace and
|
|
401
|
-
* key inside that scope.
|
|
402
|
-
*/
|
|
403
|
-
export declare type MiniAppStorageApi = {
|
|
404
|
-
get(options: MiniAppStorageAddress): MiniAppMaybePromise<MiniAppStorageEntry>;
|
|
405
|
-
set(options: MiniAppStorageSetOptions): MiniAppMaybePromise<MiniAppStorageMutationResult>;
|
|
406
|
-
delete(options: MiniAppStorageDeleteOptions): MiniAppMaybePromise<void>;
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
export declare type MiniAppStorageDeleteOptions = MiniAppStorageAddress & {
|
|
410
|
-
expectedRevision: number;
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
export declare type MiniAppStorageEntry = {
|
|
414
|
-
value: MiniAppJsonValue | null;
|
|
415
|
-
/** Null means that no value currently exists at this address. */
|
|
416
|
-
revision: number | null;
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
export declare type MiniAppStorageMutationResult = {
|
|
420
|
-
revision: number;
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
export declare type MiniAppStorageSetOptions = MiniAppStorageAddress & {
|
|
424
|
-
value: MiniAppJsonValue;
|
|
425
|
-
/** Optimistic concurrency token returned by `get`; null creates a missing key. */
|
|
426
|
-
expectedRevision: number | null;
|
|
427
|
-
};
|
|
428
|
-
|
|
429
355
|
export declare type MiniAppUserProfile = {
|
|
430
356
|
sub: string;
|
|
431
357
|
name?: string | null;
|
package/dist/rspack/index.js
CHANGED
|
@@ -444,15 +444,8 @@ const HOST_ACTION_RESPONSE = 'tap-miniapp-host-action-response';
|
|
|
444
444
|
const MAX_PENDING_HOST_ACTIONS = 32;
|
|
445
445
|
const MAX_CHECKPOINT_REFERENCE_CHARS = 512;
|
|
446
446
|
const MAX_CHECKPOINT_JSON_BYTES = 32 * 1024;
|
|
447
|
-
const MAX_STORAGE_NAMESPACE_CHARS = 128;
|
|
448
|
-
const MAX_STORAGE_KEY_CHARS = 512;
|
|
449
|
-
const MAX_STORAGE_JSON_BYTES = 5 * 1024 * 1024;
|
|
450
|
-
const MAX_PRESENCE_ROOM_CHARS = 256;
|
|
451
|
-
const MAX_PRESENCE_JSON_BYTES = 16 * 1024;
|
|
452
|
-
const PRESENCE_EVENT = 'tap-miniapp-presence-event';
|
|
453
447
|
const HOST_ACTION_TIMEOUT_MS = 4000;
|
|
454
448
|
const pendingHostActions = new Map();
|
|
455
|
-
const presenceListeners = new Map();
|
|
456
449
|
let hostActionSequence = 0;
|
|
457
450
|
const validCheckpointReference = (reference) =>
|
|
458
451
|
typeof reference === 'string' &&
|
|
@@ -472,24 +465,6 @@ const checkedCheckpointValue = (value) => {
|
|
|
472
465
|
}
|
|
473
466
|
return value;
|
|
474
467
|
};
|
|
475
|
-
const validPlatformPartition = (value, maximumLength) =>
|
|
476
|
-
typeof value === 'string' &&
|
|
477
|
-
value.length > 0 &&
|
|
478
|
-
value.trim() === value &&
|
|
479
|
-
Array.from(value).length <= maximumLength &&
|
|
480
|
-
!/[\u0000-\u001f\u007f-\u009f]/u.test(value);
|
|
481
|
-
const checkedPlatformJson = (value, maximumBytes, label) => {
|
|
482
|
-
let encoded;
|
|
483
|
-
try {
|
|
484
|
-
encoded = JSON.stringify(value);
|
|
485
|
-
} catch {
|
|
486
|
-
throw new Error(label + ' must be JSON serializable.');
|
|
487
|
-
}
|
|
488
|
-
if (encoded === undefined || new TextEncoder().encode(encoded).byteLength > maximumBytes) {
|
|
489
|
-
throw new Error(label + ' exceeds the allowed size.');
|
|
490
|
-
}
|
|
491
|
-
return value;
|
|
492
|
-
};
|
|
493
468
|
const requestHostAction = (action, payload, timeoutMs = HOST_ACTION_TIMEOUT_MS) => {
|
|
494
469
|
if (pendingHostActions.size >= MAX_PENDING_HOST_ACTIONS) {
|
|
495
470
|
return Promise.reject(new Error('Too many miniapp host actions are pending.'));
|
|
@@ -644,79 +619,6 @@ const invokeSdkHostAction = (action, options, label, timeoutMs = HOST_ACTION_TIM
|
|
|
644
619
|
requestHostAction(action, {
|
|
645
620
|
options: requireOptionsObject(options, label),
|
|
646
621
|
}, timeoutMs);
|
|
647
|
-
const checkedStorageAddress = (options, label) => {
|
|
648
|
-
requireOptionsObject(options, label);
|
|
649
|
-
if (!validPlatformPartition(options.namespace, MAX_STORAGE_NAMESPACE_CHARS)) {
|
|
650
|
-
throw new Error(label + ' requires a valid namespace.');
|
|
651
|
-
}
|
|
652
|
-
if (!validPlatformPartition(options.key, MAX_STORAGE_KEY_CHARS)) {
|
|
653
|
-
throw new Error(label + ' requires a valid key.');
|
|
654
|
-
}
|
|
655
|
-
return options;
|
|
656
|
-
};
|
|
657
|
-
const storage = Object.freeze({
|
|
658
|
-
get(options) {
|
|
659
|
-
checkedStorageAddress(options, 'app.storage.get');
|
|
660
|
-
return invokeSdkHostAction('tap.platform.storage.get', options, 'app.storage.get');
|
|
661
|
-
},
|
|
662
|
-
set(options) {
|
|
663
|
-
checkedStorageAddress(options, 'app.storage.set');
|
|
664
|
-
if (options.expectedRevision !== null &&
|
|
665
|
-
(!Number.isInteger(options.expectedRevision) || options.expectedRevision < 1)) {
|
|
666
|
-
throw new Error('app.storage.set expectedRevision must be null or a positive integer.');
|
|
667
|
-
}
|
|
668
|
-
checkedPlatformJson(options.value, MAX_STORAGE_JSON_BYTES, 'app.storage.set value');
|
|
669
|
-
return invokeSdkHostAction('tap.platform.storage.set', options, 'app.storage.set', 12000);
|
|
670
|
-
},
|
|
671
|
-
delete(options) {
|
|
672
|
-
checkedStorageAddress(options, 'app.storage.delete');
|
|
673
|
-
if (!Number.isInteger(options.expectedRevision) || options.expectedRevision < 1) {
|
|
674
|
-
throw new Error('app.storage.delete expectedRevision must be a positive integer.');
|
|
675
|
-
}
|
|
676
|
-
return invokeSdkHostAction('tap.platform.storage.delete', options, 'app.storage.delete');
|
|
677
|
-
},
|
|
678
|
-
});
|
|
679
|
-
const checkedPresenceAddress = (options, label) => {
|
|
680
|
-
requireOptionsObject(options, label);
|
|
681
|
-
if (!validPlatformPartition(options.namespace, MAX_STORAGE_NAMESPACE_CHARS)) {
|
|
682
|
-
throw new Error(label + ' requires a valid namespace.');
|
|
683
|
-
}
|
|
684
|
-
if (!validPlatformPartition(options.room, MAX_PRESENCE_ROOM_CHARS)) {
|
|
685
|
-
throw new Error(label + ' requires a valid room.');
|
|
686
|
-
}
|
|
687
|
-
return options;
|
|
688
|
-
};
|
|
689
|
-
const presenceKey = (options) => options.namespace + '\u0000' + options.room;
|
|
690
|
-
const presence = Object.freeze({
|
|
691
|
-
join(options) {
|
|
692
|
-
checkedPresenceAddress(options, 'app.presence.join');
|
|
693
|
-
checkedPlatformJson(options.state, MAX_PRESENCE_JSON_BYTES, 'app.presence.join state');
|
|
694
|
-
return invokeSdkHostAction('tap.platform.presence.join', options, 'app.presence.join');
|
|
695
|
-
},
|
|
696
|
-
update(options) {
|
|
697
|
-
checkedPresenceAddress(options, 'app.presence.update');
|
|
698
|
-
checkedPlatformJson(options.state, MAX_PRESENCE_JSON_BYTES, 'app.presence.update state');
|
|
699
|
-
return invokeSdkHostAction('tap.platform.presence.update', options, 'app.presence.update');
|
|
700
|
-
},
|
|
701
|
-
leave(options) {
|
|
702
|
-
checkedPresenceAddress(options, 'app.presence.leave');
|
|
703
|
-
return invokeSdkHostAction('tap.platform.presence.leave', options, 'app.presence.leave');
|
|
704
|
-
},
|
|
705
|
-
subscribe(options, listener) {
|
|
706
|
-
checkedPresenceAddress(options, 'app.presence.subscribe');
|
|
707
|
-
if (typeof listener !== 'function') {
|
|
708
|
-
throw new Error('app.presence.subscribe requires a listener.');
|
|
709
|
-
}
|
|
710
|
-
const key = presenceKey(options);
|
|
711
|
-
const listeners = presenceListeners.get(key) ?? new Set();
|
|
712
|
-
listeners.add(listener);
|
|
713
|
-
presenceListeners.set(key, listeners);
|
|
714
|
-
return () => {
|
|
715
|
-
listeners.delete(listener);
|
|
716
|
-
if (listeners.size === 0) presenceListeners.delete(key);
|
|
717
|
-
};
|
|
718
|
-
},
|
|
719
|
-
});
|
|
720
622
|
const channels = Object.freeze({
|
|
721
623
|
create(options) {
|
|
722
624
|
requireOptionString(options?.name, 'app.channels.create name');
|
|
@@ -991,8 +893,6 @@ const miniappSdk = Object.freeze({
|
|
|
991
893
|
workflows,
|
|
992
894
|
navigation,
|
|
993
895
|
chat: miniappChat,
|
|
994
|
-
storage,
|
|
995
|
-
presence,
|
|
996
896
|
auth: platformAuth,
|
|
997
897
|
vfs: platformVfs,
|
|
998
898
|
specialist: platformSpecialist,
|
|
@@ -1121,24 +1021,6 @@ const onHostMessage = async (event) => {
|
|
|
1121
1021
|
}
|
|
1122
1022
|
return;
|
|
1123
1023
|
}
|
|
1124
|
-
if (
|
|
1125
|
-
message.type === PRESENCE_EVENT &&
|
|
1126
|
-
validPlatformPartition(message.namespace, MAX_STORAGE_NAMESPACE_CHARS) &&
|
|
1127
|
-
validPlatformPartition(message.room, MAX_PRESENCE_ROOM_CHARS) &&
|
|
1128
|
-
typeof message.selfParticipantId === 'string' &&
|
|
1129
|
-
Array.isArray(message.participants)
|
|
1130
|
-
) {
|
|
1131
|
-
const snapshot = Object.freeze({
|
|
1132
|
-
namespace: message.namespace,
|
|
1133
|
-
room: message.room,
|
|
1134
|
-
selfParticipantId: message.selfParticipantId,
|
|
1135
|
-
participants: message.participants,
|
|
1136
|
-
});
|
|
1137
|
-
for (const listener of presenceListeners.get(presenceKey(snapshot)) ?? []) {
|
|
1138
|
-
try { await listener(snapshot); } catch { /* isolate observer failures */ }
|
|
1139
|
-
}
|
|
1140
|
-
return;
|
|
1141
|
-
}
|
|
1142
1024
|
if (message.type === HOST_ACTION_RESPONSE) {
|
|
1143
1025
|
const requestId = typeof message.id === 'string' ? message.id : '';
|
|
1144
1026
|
const pending = pendingHostActions.get(requestId);
|
|
@@ -1259,7 +1141,6 @@ window.addEventListener('pagehide', () => {
|
|
|
1259
1141
|
window.removeEventListener('message', onHostMessage);
|
|
1260
1142
|
eventListeners.clear();
|
|
1261
1143
|
hostAuthorityListeners.clear();
|
|
1262
|
-
presenceListeners.clear();
|
|
1263
1144
|
for (const pending of pendingHostActions.values()) {
|
|
1264
1145
|
clearTimeout(pending.timeout);
|
|
1265
1146
|
pending.reject(new Error('The mini app document was removed.'));
|
package/dist/sdk.d.ts
CHANGED
|
@@ -234,8 +234,6 @@ export declare type MiniAppPlatformApi = {
|
|
|
234
234
|
open(options: OpenNavigationOptions): void | Promise<void>;
|
|
235
235
|
};
|
|
236
236
|
chat: MiniAppChatApi;
|
|
237
|
-
storage: MiniAppStorageApi;
|
|
238
|
-
presence: MiniAppPresenceApi;
|
|
239
237
|
/** Browser capabilities appear only when the selected target supports them. */
|
|
240
238
|
auth?: MiniAppAuthApi;
|
|
241
239
|
vfs?: MiniAppVfsApi;
|
|
@@ -244,41 +242,6 @@ export declare type MiniAppPlatformApi = {
|
|
|
244
242
|
hasHostHttpRequest?: boolean;
|
|
245
243
|
};
|
|
246
244
|
|
|
247
|
-
export declare type MiniAppPresenceAddress = {
|
|
248
|
-
namespace: string;
|
|
249
|
-
room: string;
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Ephemeral realtime presence scoped by the host to the active workspace and
|
|
254
|
-
* exact package. Participant identity is stamped by the host, not the app.
|
|
255
|
-
*/
|
|
256
|
-
export declare type MiniAppPresenceApi = {
|
|
257
|
-
join(options: MiniAppPresenceUpdateOptions): MiniAppMaybePromise<MiniAppPresenceSnapshot>;
|
|
258
|
-
update(options: MiniAppPresenceUpdateOptions): MiniAppMaybePromise<MiniAppPresenceSnapshot>;
|
|
259
|
-
leave(options: MiniAppPresenceAddress): MiniAppMaybePromise<void>;
|
|
260
|
-
subscribe(options: MiniAppPresenceAddress, listener: MiniAppPresenceListener): () => void;
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
export declare type MiniAppPresenceListener = (snapshot: MiniAppPresenceSnapshot) => void;
|
|
264
|
-
|
|
265
|
-
export declare type MiniAppPresenceParticipant = {
|
|
266
|
-
/** Host-derived, ephemeral participant identity. */
|
|
267
|
-
participantId: string;
|
|
268
|
-
displayName: string;
|
|
269
|
-
state: MiniAppJsonValue;
|
|
270
|
-
updatedAtMs: number;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
export declare type MiniAppPresenceSnapshot = MiniAppPresenceAddress & {
|
|
274
|
-
selfParticipantId: string;
|
|
275
|
-
participants: MiniAppPresenceParticipant[];
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
export declare type MiniAppPresenceUpdateOptions = MiniAppPresenceAddress & {
|
|
279
|
-
state: MiniAppJsonValue;
|
|
280
|
-
};
|
|
281
|
-
|
|
282
245
|
export declare type MiniAppProject = {
|
|
283
246
|
id: string;
|
|
284
247
|
name: string;
|
|
@@ -378,43 +341,6 @@ export declare type MiniAppSpecialistTurnResult = {
|
|
|
378
341
|
};
|
|
379
342
|
};
|
|
380
343
|
|
|
381
|
-
/** Caller-selected partition inside the host-derived workspace/package scope. */
|
|
382
|
-
export declare type MiniAppStorageAddress = {
|
|
383
|
-
namespace: string;
|
|
384
|
-
key: string;
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Durable, non-secret JSON storage. The host derives workspace and package
|
|
389
|
-
* identity from the authenticated frame; apps control only the namespace and
|
|
390
|
-
* key inside that scope.
|
|
391
|
-
*/
|
|
392
|
-
export declare type MiniAppStorageApi = {
|
|
393
|
-
get(options: MiniAppStorageAddress): MiniAppMaybePromise<MiniAppStorageEntry>;
|
|
394
|
-
set(options: MiniAppStorageSetOptions): MiniAppMaybePromise<MiniAppStorageMutationResult>;
|
|
395
|
-
delete(options: MiniAppStorageDeleteOptions): MiniAppMaybePromise<void>;
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
export declare type MiniAppStorageDeleteOptions = MiniAppStorageAddress & {
|
|
399
|
-
expectedRevision: number;
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
export declare type MiniAppStorageEntry = {
|
|
403
|
-
value: MiniAppJsonValue | null;
|
|
404
|
-
/** Null means that no value currently exists at this address. */
|
|
405
|
-
revision: number | null;
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
export declare type MiniAppStorageMutationResult = {
|
|
409
|
-
revision: number;
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
export declare type MiniAppStorageSetOptions = MiniAppStorageAddress & {
|
|
413
|
-
value: MiniAppJsonValue;
|
|
414
|
-
/** Optimistic concurrency token returned by `get`; null creates a missing key. */
|
|
415
|
-
expectedRevision: number | null;
|
|
416
|
-
};
|
|
417
|
-
|
|
418
344
|
export declare type MiniAppUserProfile = {
|
|
419
345
|
sub: string;
|
|
420
346
|
name?: string | null;
|
package/dist/web.d.ts
CHANGED
|
@@ -7,8 +7,6 @@ export declare const app: MiniAppPlatformApi;
|
|
|
7
7
|
|
|
8
8
|
export declare function applyMiniAppTheme(theme: MiniAppTheme): void;
|
|
9
9
|
|
|
10
|
-
export declare function applyMiniAppUiScale(scale: MiniAppUiScale): void;
|
|
11
|
-
|
|
12
10
|
declare type CreateChannelOptions = {
|
|
13
11
|
workspaceId?: string;
|
|
14
12
|
name: string;
|
|
@@ -63,8 +61,6 @@ declare type GetChannelTimelineResult = {
|
|
|
63
61
|
|
|
64
62
|
export declare function getMiniAppThemeFromSearch(search?: string | URLSearchParams): MiniAppTheme;
|
|
65
63
|
|
|
66
|
-
export declare function getMiniAppUiScaleFromSearch(search?: string | URLSearchParams): MiniAppUiScale;
|
|
67
|
-
|
|
68
64
|
/** Returns the public miniapp API proxy, which fails only when it is used. */
|
|
69
65
|
export declare function getPlatform(): MiniAppPlatform;
|
|
70
66
|
|
|
@@ -77,13 +73,6 @@ declare type GetProjectResult = {
|
|
|
77
73
|
project: MiniAppProject | null;
|
|
78
74
|
};
|
|
79
75
|
|
|
80
|
-
/** Synchronizes both theme and UI scale from the exact parent miniapp host. */
|
|
81
|
-
export declare function installMiniAppAppearanceSync({ applyTheme, applyUiScale, search, }?: InstallMiniAppAppearanceSyncOptions): () => void;
|
|
82
|
-
|
|
83
|
-
export declare type InstallMiniAppAppearanceSyncOptions = InstallMiniAppThemeSyncOptions & {
|
|
84
|
-
applyUiScale?: (scale: MiniAppUiScale) => void;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
76
|
export declare function installMiniAppThemeSync({ applyTheme, search, }?: InstallMiniAppThemeSyncOptions): () => void;
|
|
88
77
|
|
|
89
78
|
export declare type InstallMiniAppThemeSyncOptions = {
|
|
@@ -126,12 +115,6 @@ declare type ListWorkflowsResult = {
|
|
|
126
115
|
workflows: MiniAppWorkflow[];
|
|
127
116
|
};
|
|
128
117
|
|
|
129
|
-
export declare const MINIAPP_UI_SCALE_DEFAULT = 16;
|
|
130
|
-
|
|
131
|
-
export declare const MINIAPP_UI_SCALE_MAX = 20;
|
|
132
|
-
|
|
133
|
-
export declare const MINIAPP_UI_SCALE_MIN = 12;
|
|
134
|
-
|
|
135
118
|
declare type MiniAppAuthApi = {
|
|
136
119
|
getUserProfile(): MiniAppMaybePromise<MiniAppUserProfile | null>;
|
|
137
120
|
};
|
|
@@ -275,8 +258,6 @@ export declare type MiniAppPlatformApi = {
|
|
|
275
258
|
open(options: OpenNavigationOptions): void | Promise<void>;
|
|
276
259
|
};
|
|
277
260
|
chat: MiniAppChatApi;
|
|
278
|
-
storage: MiniAppStorageApi;
|
|
279
|
-
presence: MiniAppPresenceApi;
|
|
280
261
|
/** Browser capabilities appear only when the selected target supports them. */
|
|
281
262
|
auth?: MiniAppAuthApi;
|
|
282
263
|
vfs?: MiniAppVfsApi;
|
|
@@ -285,41 +266,6 @@ export declare type MiniAppPlatformApi = {
|
|
|
285
266
|
hasHostHttpRequest?: boolean;
|
|
286
267
|
};
|
|
287
268
|
|
|
288
|
-
declare type MiniAppPresenceAddress = {
|
|
289
|
-
namespace: string;
|
|
290
|
-
room: string;
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Ephemeral realtime presence scoped by the host to the active workspace and
|
|
295
|
-
* exact package. Participant identity is stamped by the host, not the app.
|
|
296
|
-
*/
|
|
297
|
-
declare type MiniAppPresenceApi = {
|
|
298
|
-
join(options: MiniAppPresenceUpdateOptions): MiniAppMaybePromise<MiniAppPresenceSnapshot>;
|
|
299
|
-
update(options: MiniAppPresenceUpdateOptions): MiniAppMaybePromise<MiniAppPresenceSnapshot>;
|
|
300
|
-
leave(options: MiniAppPresenceAddress): MiniAppMaybePromise<void>;
|
|
301
|
-
subscribe(options: MiniAppPresenceAddress, listener: MiniAppPresenceListener): () => void;
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
declare type MiniAppPresenceListener = (snapshot: MiniAppPresenceSnapshot) => void;
|
|
305
|
-
|
|
306
|
-
declare type MiniAppPresenceParticipant = {
|
|
307
|
-
/** Host-derived, ephemeral participant identity. */
|
|
308
|
-
participantId: string;
|
|
309
|
-
displayName: string;
|
|
310
|
-
state: MiniAppJsonValue;
|
|
311
|
-
updatedAtMs: number;
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
declare type MiniAppPresenceSnapshot = MiniAppPresenceAddress & {
|
|
315
|
-
selfParticipantId: string;
|
|
316
|
-
participants: MiniAppPresenceParticipant[];
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
declare type MiniAppPresenceUpdateOptions = MiniAppPresenceAddress & {
|
|
320
|
-
state: MiniAppJsonValue;
|
|
321
|
-
};
|
|
322
|
-
|
|
323
269
|
declare type MiniAppProject = {
|
|
324
270
|
id: string;
|
|
325
271
|
name: string;
|
|
@@ -419,47 +365,8 @@ declare type MiniAppSpecialistTurnResult = {
|
|
|
419
365
|
};
|
|
420
366
|
};
|
|
421
367
|
|
|
422
|
-
/** Caller-selected partition inside the host-derived workspace/package scope. */
|
|
423
|
-
declare type MiniAppStorageAddress = {
|
|
424
|
-
namespace: string;
|
|
425
|
-
key: string;
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Durable, non-secret JSON storage. The host derives workspace and package
|
|
430
|
-
* identity from the authenticated frame; apps control only the namespace and
|
|
431
|
-
* key inside that scope.
|
|
432
|
-
*/
|
|
433
|
-
declare type MiniAppStorageApi = {
|
|
434
|
-
get(options: MiniAppStorageAddress): MiniAppMaybePromise<MiniAppStorageEntry>;
|
|
435
|
-
set(options: MiniAppStorageSetOptions): MiniAppMaybePromise<MiniAppStorageMutationResult>;
|
|
436
|
-
delete(options: MiniAppStorageDeleteOptions): MiniAppMaybePromise<void>;
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
declare type MiniAppStorageDeleteOptions = MiniAppStorageAddress & {
|
|
440
|
-
expectedRevision: number;
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
declare type MiniAppStorageEntry = {
|
|
444
|
-
value: MiniAppJsonValue | null;
|
|
445
|
-
/** Null means that no value currently exists at this address. */
|
|
446
|
-
revision: number | null;
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
declare type MiniAppStorageMutationResult = {
|
|
450
|
-
revision: number;
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
declare type MiniAppStorageSetOptions = MiniAppStorageAddress & {
|
|
454
|
-
value: MiniAppJsonValue;
|
|
455
|
-
/** Optimistic concurrency token returned by `get`; null creates a missing key. */
|
|
456
|
-
expectedRevision: number | null;
|
|
457
|
-
};
|
|
458
|
-
|
|
459
368
|
export declare type MiniAppTheme = 'light' | 'dark';
|
|
460
369
|
|
|
461
|
-
export declare type MiniAppUiScale = number;
|
|
462
|
-
|
|
463
370
|
declare type MiniAppUserProfile = {
|
|
464
371
|
sub: string;
|
|
465
372
|
name?: string | null;
|