@tinycloud/web-sdk 3.7.0-beta.1 → 3.7.0-beta.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/README.md +40 -0
- package/dist/adapters/BrowserNotificationHandler.d.ts +22 -6
- package/dist/authorization/WebSpaceCreationHandler.d.ts +12 -0
- package/dist/credentials.cjs +1 -1
- package/dist/credentials.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/modals.cjs +1 -0
- package/dist/modals.mjs +1 -0
- package/dist/modules/tcw.d.ts +16 -2
- package/dist/notifications/ModalManager.d.ts +21 -7
- package/dist/notifications/PermissionRequestModal.d.ts +8 -1
- package/dist/notifications/SpaceCreationModal.d.ts +8 -1
- package/dist/notifications/dialogFocus.d.ts +39 -0
- package/dist/notifications/index.d.ts +1 -6
- package/dist/notifications/lazy-prompts.d.ts +16 -0
- package/dist/notifications/legacy-config.d.ts +11 -0
- package/dist/notifications/modals-entry.d.ts +7 -0
- package/dist/notifications/modals-registry.d.ts +15 -0
- package/dist/notifications/scrollLock.d.ts +2 -0
- package/dist/notifications/types.d.ts +6 -33
- package/dist/notifications/types.schema.d.ts +7 -148
- package/dist/panel-data.cjs +1 -0
- package/dist/panel-data.mjs +1 -0
- package/dist/panel.cjs +1 -0
- package/dist/panel.mjs +1 -0
- package/dist/ui/api.d.ts +30 -0
- package/dist/ui/button.d.ts +10 -0
- package/dist/ui/client.d.ts +27 -0
- package/dist/ui/config.d.ts +35 -0
- package/dist/ui/data/map.d.ts +23 -0
- package/dist/ui/data/prefetch.d.ts +18 -0
- package/dist/ui/data/real.d.ts +12 -0
- package/dist/ui/data.d.ts +241 -0
- package/dist/ui/frame-guard.d.ts +7 -0
- package/dist/ui/host.d.ts +29 -0
- package/dist/ui/ids.d.ts +7 -0
- package/dist/ui/index.d.ts +38 -0
- package/dist/ui/manage-url.d.ts +8 -0
- package/dist/ui/panel-data-entry.d.ts +28 -0
- package/dist/ui/panel-entry.d.ts +23 -0
- package/dist/ui/panel-modal.d.ts +13 -0
- package/dist/ui/panel-styles.d.ts +10 -0
- package/dist/ui/panel-toasts.d.ts +30 -0
- package/dist/ui/panel.d.ts +42 -0
- package/dist/ui/parts/index.d.ts +4 -0
- package/dist/ui/parts/prompts.d.ts +39 -0
- package/dist/ui/parts/storage-watch.d.ts +11 -0
- package/dist/ui/parts/sync-status.d.ts +7 -0
- package/dist/ui/parts/toasts.d.ts +8 -0
- package/dist/ui/pending.d.ts +13 -0
- package/dist/ui/persistence.d.ts +28 -0
- package/dist/ui/phone.d.ts +14 -0
- package/dist/ui/section-data.d.ts +20 -0
- package/dist/ui/section-dialogs.d.ts +10 -0
- package/dist/ui/sections/account.d.ts +3 -0
- package/dist/ui/sections/account.strings.d.ts +29 -0
- package/dist/ui/sections/activity.d.ts +7 -0
- package/dist/ui/sections/activity.strings.d.ts +46 -0
- package/dist/ui/sections/delegations.d.ts +25 -0
- package/dist/ui/sections/delegations.strings.d.ts +143 -0
- package/dist/ui/sections/freshness-copy.d.ts +17 -0
- package/dist/ui/sections/index.d.ts +4 -0
- package/dist/ui/sections/local-copy.d.ts +3 -0
- package/dist/ui/sections/local-copy.strings.d.ts +70 -0
- package/dist/ui/sections/local-tinycloud.d.ts +9 -0
- package/dist/ui/sections/local-tinycloud.strings.d.ts +48 -0
- package/dist/ui/sections/nodes.d.ts +7 -0
- package/dist/ui/sections/nodes.strings.d.ts +27 -0
- package/dist/ui/sections/placeholder.d.ts +8 -0
- package/dist/ui/sections/status.d.ts +10 -0
- package/dist/ui/sections/storage.d.ts +37 -0
- package/dist/ui/sections/storage.strings.d.ts +37 -0
- package/dist/ui/sections/ui.d.ts +77 -0
- package/dist/ui/sections/view-body.d.ts +23 -0
- package/dist/ui/sign-out-purge.d.ts +39 -0
- package/dist/ui/slots.d.ts +218 -0
- package/dist/ui/status.d.ts +16 -0
- package/dist/ui/storage-state.d.ts +12 -0
- package/dist/ui/strings-panel.d.ts +29 -0
- package/dist/ui/strings.d.ts +76 -0
- package/dist/ui/stub/index.d.ts +48 -0
- package/dist/ui/styles.d.ts +9 -0
- package/dist/ui/toast-store.d.ts +46 -0
- package/dist/ui/view-result.d.ts +6 -0
- package/package.json +13 -4
- package/dist/notifications/ErrorHandler.d.ts +0 -32
- package/dist/notifications/NodeSelectionModal.d.ts +0 -29
- package/dist/notifications/ToastContainer.d.ts +0 -16
- package/dist/notifications/ToastElement.d.ts +0 -22
- package/dist/notifications/ToastManager.d.ts +0 -36
package/README.md
CHANGED
|
@@ -272,6 +272,46 @@ and [Postgres Node size job 117210798348](https://github.com/TinyCloudLabs/js-sd
|
|
|
272
272
|
independently reported identical root and optional gzip bytes on `e5b080d5`;
|
|
273
273
|
the historical local measurements cannot set ledger ceilings.
|
|
274
274
|
|
|
275
|
+
## Floating button and panel
|
|
276
|
+
|
|
277
|
+
`TinyCloudWeb` adds a floating button and a panel to the page. The panel is rendered in an open shadow root, so host page styles do not reach it. It is not rendered inside an iframe or an opaque origin. In those cases, and with `ui: false`, nothing is added to the page.
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
const tc = new TinyCloudWeb({
|
|
281
|
+
ui: {
|
|
282
|
+
button: true, // default true; false hides the button only
|
|
283
|
+
toasts: true, // default true; false shows no toasts and stops the unhandled-rejection listener; prompts still render
|
|
284
|
+
developerMode: false, // default false; shows the developer section
|
|
285
|
+
position: "bottom-right", // "bottom-right" | "bottom-left" | "bottom-center"; each "top-*" value places at the matching bottom position; an unrecognised value falls back to "bottom-right"
|
|
286
|
+
appId: "my-app", // identity for the hide flag when no manifest is set
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
tc.ui.open();
|
|
291
|
+
tc.ui.close();
|
|
292
|
+
tc.ui.toggle();
|
|
293
|
+
tc.ui.isOpen; // boolean
|
|
294
|
+
tc.ui.available; // false in iframes, opaque origins, SSR, or when ui is false
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
`open()` also clears the user's hidden flag for the button. The hidden flag is stored per origin and app id under `tinycloud:ui:button-hidden:v1:`. The panel shows sections only for capabilities the client exposes.
|
|
298
|
+
|
|
299
|
+
### Storage section and storage-full toast
|
|
300
|
+
|
|
301
|
+
When the client exposes `storage.status()`, the panel shows a Storage section with the account's usage: "Room left", "Nearly full", "Storage is full", or "No limit", plus a bar and a "Manage storage" link. The link uses the status `manageUrl` only when it is https; otherwise it falls back to `https://account.tinycloud.xyz/storage`. When the storage needs permission, the section shows a neutral note with no numbers.
|
|
302
|
+
|
|
303
|
+
The host also watches the own-storage `storage.full` episode. While the episode is on, the button and panel show "Storage is full", and one info toast with the manage link is shown per episode, even when the panel is closed. The toast shows again only after the episode ends and a new one starts. The episode ends only on a successful write to that storage, so a status read alone does not end it.
|
|
304
|
+
|
|
305
|
+
### Toasts and notification errors
|
|
306
|
+
|
|
307
|
+
Toasts render in the host panel layer and follow the same `ui` options. `ui: false` creates no host, button, toasts, or listeners. `ui: false` refuses SDK prompts (explicit opt-in); `popups: false` and `ui: { button: false, toasts: false }` keep them. `ui: { toasts: false }` shows no toasts and stops the unhandled-rejection listener, and prompts still render. `ui.position` sets placement. Toast copy is fixed text per error kind. The raw error message is written to the console. A toast auto-dismisses after 5 seconds, at most 3 show at once, and an identical visible toast is not shown twice.
|
|
308
|
+
|
|
309
|
+
Consent and space-creation prompts render in the same open shadow root as the panel. Each is a `role="dialog"` with `aria-modal="true"`, named by its title and described by its explanation. Focus moves to the dialog itself, never to Approve or Create, so Enter alone cannot confirm consent. Tab and Shift+Tab stay inside the dialog. When a prompt closes, focus returns to the element that had it before the prompt opened, unless focus has moved elsewhere on the page. While a prompt is open the page's scroll is locked. Releasing the lock restores the page's previous `body` `overflow` value, so a page that set `overflow: clip` keeps it.
|
|
310
|
+
|
|
311
|
+
Space creation has three modes, in this order of precedence. An explicit `spaceCreationHandler` always handles the request. Otherwise `autoCreateSpace: true` creates the space without a dialog, and `autoCreateSpace: false` creates nothing and opens no dialog. When neither is set, the default confirmation dialog opens. With `ui: false` the SDK's own prompts do not render: a consent request resolves as declined and a space-creation request resolves as dismissed, with one console warning.
|
|
312
|
+
|
|
313
|
+
`notifications.throwErrors: true` rethrows the raw error message asynchronously, so global error handlers see it. Identical errors within 200 ms collapse into one throw; distinct errors each throw. It applies whenever `ui` is enabled and `ui.toasts` is not `false`, including on a framed page where the toast is dropped. It never applies with `ui: false` or `ui: { toasts: false }`. The legacy `popups`, `position`, `duration`, and `maxVisible` keys under `notifications` are removed from the TypeScript types. JavaScript callers that still pass them are mapped onto `ui` once per page load, with a console warning per key: `popups: false` becomes `ui: { button: false, toasts: false }` only when `ui` is not set. An explicit `ui` replaces that mapping as a whole, so `popups: false` with `ui: { position: 'bottom-left' }` keeps the button and toasts. `position` becomes `ui.position` unless `ui.position` is set. `duration` and `maxVisible` are ignored, and their warning says so. Migrate to `ui`.
|
|
314
|
+
|
|
275
315
|
## Basic Storage Operations
|
|
276
316
|
|
|
277
317
|
### Storing Data
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
import { INotificationHandler } from "@tinycloud/sdk-core";
|
|
2
|
-
import type {
|
|
1
|
+
import type { INotificationHandler } from "@tinycloud/sdk-core";
|
|
2
|
+
import type { ToastSink } from "../ui/toast-store";
|
|
3
|
+
/**
|
|
4
|
+
* Routes node-sdk notifications to the host toast. Toasts show fixed copy only;
|
|
5
|
+
* the raw message and description go to the console.
|
|
6
|
+
*/
|
|
3
7
|
export declare class BrowserNotificationHandler implements INotificationHandler {
|
|
4
|
-
private
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
private readonly toast;
|
|
9
|
+
private readonly rethrowErrors;
|
|
10
|
+
private readonly pendingThrows;
|
|
11
|
+
/**
|
|
12
|
+
* @param toast Shows a toast in the host. Without it, nothing is shown, but
|
|
13
|
+
* warnings and errors still reach the console.
|
|
14
|
+
* @param rethrowErrors Throw each error's raw message asynchronously, as the
|
|
15
|
+
* old `throwErrors` did. Identical errors within 200 ms collapse into one throw.
|
|
16
|
+
*/
|
|
17
|
+
constructor(toast?: ToastSink, rethrowErrors?: boolean);
|
|
18
|
+
success(message: string): void;
|
|
7
19
|
warning(message: string, description?: string): void;
|
|
8
20
|
error(category: string, message: string, description?: string): void;
|
|
9
|
-
|
|
21
|
+
private show;
|
|
22
|
+
/** A repeat of the same key restarts the window, so only the last of a burst throws. */
|
|
23
|
+
private throwLater;
|
|
24
|
+
/** Drops throws still waiting in their window, so none fires after cleanup. */
|
|
25
|
+
cancelPendingThrows(): void;
|
|
10
26
|
}
|
|
11
27
|
//# sourceMappingURL=BrowserNotificationHandler.d.ts.map
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
import { ISpaceCreationHandler, SpaceCreationContext } from "@tinycloud/sdk-core";
|
|
7
|
+
import type { PromptScope } from "../ui/parts/prompts";
|
|
8
|
+
import type { ToastSink } from "../ui/toast-store";
|
|
7
9
|
/**
|
|
8
10
|
* How long {@link ModalSpaceCreationHandler} waits for the user to answer the
|
|
9
11
|
* space-creation dialog before failing sign-in.
|
|
@@ -38,6 +40,10 @@ export interface ModalSpaceCreationHandlerOptions {
|
|
|
38
40
|
* dialog is actually reachable in your UI.
|
|
39
41
|
*/
|
|
40
42
|
timeoutMs?: number;
|
|
43
|
+
/** Shows the space-creation outcome toasts. Omit to stay silent. */
|
|
44
|
+
toast?: ToastSink;
|
|
45
|
+
/** Scope of the UI client that owns this prompt. Omit for the default enabled scope. */
|
|
46
|
+
promptScope?: PromptScope;
|
|
41
47
|
}
|
|
42
48
|
/**
|
|
43
49
|
* Space creation handler that shows a modal for user confirmation.
|
|
@@ -59,6 +65,8 @@ export interface ModalSpaceCreationHandlerOptions {
|
|
|
59
65
|
*/
|
|
60
66
|
export declare class ModalSpaceCreationHandler implements ISpaceCreationHandler {
|
|
61
67
|
private readonly timeoutMs;
|
|
68
|
+
private readonly toast;
|
|
69
|
+
private readonly promptScope;
|
|
62
70
|
constructor(options?: ModalSpaceCreationHandlerOptions);
|
|
63
71
|
/**
|
|
64
72
|
* Show a modal to confirm space creation.
|
|
@@ -90,6 +98,10 @@ export interface SpaceCreationHandlerConfig {
|
|
|
90
98
|
spaceCreationHandler?: ISpaceCreationHandler;
|
|
91
99
|
/** See `TinyCloudWeb.Config.spaceCreationTimeoutMs`. */
|
|
92
100
|
spaceCreationTimeoutMs?: number;
|
|
101
|
+
/** Shows the space-creation outcome toasts. Omit to stay silent. */
|
|
102
|
+
toast?: ToastSink;
|
|
103
|
+
/** Scope of the UI client that owns this prompt. Omit for the default enabled scope. */
|
|
104
|
+
promptScope?: PromptScope;
|
|
93
105
|
}
|
|
94
106
|
/**
|
|
95
107
|
* Pick the space-creation handler a browser app should run with.
|