@wssto2/vue-core 0.5.1 → 0.5.2

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.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The version of @wssto2/vue-core (kept equal to package.json by index.test.ts). */
2
- export declare const version = "0.5.1";
2
+ export declare const version = "0.5.2";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const o = "0.5.1";
1
+ const o = "0.5.2";
2
2
  export {
3
3
  o as version
4
4
  };
@@ -7,6 +7,8 @@ export { eventsRoutes } from "../modules/events/routes";
7
7
  export { notificationsFeature } from "./feature";
8
8
  export type { NotificationsFeatureOptions } from "./feature";
9
9
  export type { NotificationCategoryLook, NotificationSettingsSection } from "./context";
10
+ export { usePushState } from "./push/pushState";
11
+ export type { PushState } from "./push/pushState";
10
12
  export { notificationSettingsRoutes } from "./settings/routes";
11
13
  export type { NotificationSettingsRoutes } from "./settings/routes";
12
14
  export { deadLettersRoutes } from "./deadletters/routes";
@@ -1,8 +1,9 @@
1
- import { d as s, e as o, n as a, b as i, c as n } from "../index-BTRv8mcf.js";
1
+ import { d as s, e as a, n as o, b as i, c as n, f as u } from "../index-BPwfLD7i.js";
2
2
  export {
3
3
  s as deadLettersRoutes,
4
- o as eventsRoutes,
5
- a as notificationRoutes,
4
+ a as eventsRoutes,
5
+ o as notificationRoutes,
6
6
  i as notificationSettingsRoutes,
7
- n as notificationsFeature
7
+ n as notificationsFeature,
8
+ u as usePushState
8
9
  };
@@ -0,0 +1,27 @@
1
+ import { type ComputedRef, type Ref } from "vue";
2
+ import type { HttpClient } from "../../client";
3
+ import { type PushBrowser } from "./browser";
4
+ /** This browser's push, for an application's own screens (an onboarding step): the same state the settings page shows. */
5
+ export interface PushState {
6
+ /** Settled: `available`, `permission` and `subscribed` are read. Until then `subscribed` is false, so wait for it before offering push. */
7
+ readonly ready: Readonly<Ref<boolean>>;
8
+ /** The server has push and this browser can use it (not an old browser, not an iPhone Safari tab outside the home-screen app). */
9
+ readonly available: ComputedRef<boolean>;
10
+ /** The browser's permission; `unknown` where there is no Notification API. */
11
+ readonly permission: Readonly<Ref<NotificationPermission | "unknown">>;
12
+ /** This browser holds a push subscription, backed by the permission, which the server was given at sign-in or by `enable()`. */
13
+ readonly subscribed: ComputedRef<boolean>;
14
+ readonly busy: Readonly<Ref<boolean>>;
15
+ /** Asks for the permission and registers this browser; call it from a tap. Resolves to `subscribed`. */
16
+ enable(): Promise<boolean>;
17
+ /** Stops push on this browser only. */
18
+ disable(): Promise<void>;
19
+ }
20
+ /**
21
+ * This browser's push state and its two actions, read at once when called (in `setup`). Built on what the notification settings page uses,
22
+ * so a browser that already has push on is `subscribed` and an onboarding step does not offer it again.
23
+ *
24
+ * const push = usePushState();
25
+ * // v-if="push.ready.value && push.available.value && !push.subscribed.value" -> <Button @click="push.enable()">
26
+ */
27
+ export declare function usePushState(http?: HttpClient, browser?: PushBrowser): PushState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wssto2/vue-core",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "goCore": "v1.8.0",
5
5
  "description": "Shared Vue 3 library for go-core applications: app shell, list / record / form pages and their controls.",
6
6
  "keywords": [