@molecule/app-settings-panel-angular 0.0.0-stage → 1.1.0
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/LICENSE +202 -0
- package/README.md +1992 -2
- package/dist/account-section.component.d.ts +123 -0
- package/dist/account-section.component.d.ts.map +1 -0
- package/dist/account-section.component.js +350 -0
- package/dist/account-section.component.js.map +1 -0
- package/dist/appearance-section.component.d.ts +52 -0
- package/dist/appearance-section.component.d.ts.map +1 -0
- package/dist/appearance-section.component.js +128 -0
- package/dist/appearance-section.component.js.map +1 -0
- package/dist/auth-section.component.d.ts +125 -0
- package/dist/auth-section.component.d.ts.map +1 -0
- package/dist/auth-section.component.js +667 -0
- package/dist/auth-section.component.js.map +1 -0
- package/dist/billing-section.component.d.ts +52 -0
- package/dist/billing-section.component.d.ts.map +1 -0
- package/dist/billing-section.component.js +137 -0
- package/dist/billing-section.component.js.map +1 -0
- package/dist/context.d.ts +46 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +73 -0
- package/dist/context.js.map +1 -0
- package/dist/controlled-switch.d.ts +38 -0
- package/dist/controlled-switch.d.ts.map +1 -0
- package/dist/controlled-switch.js +56 -0
- package/dist/controlled-switch.js.map +1 -0
- package/dist/devices-section.component.d.ts +88 -0
- package/dist/devices-section.component.d.ts.map +1 -0
- package/dist/devices-section.component.js +374 -0
- package/dist/devices-section.component.js.map +1 -0
- package/dist/index.d.ts +107 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/log-out-delete-section.component.d.ts +50 -0
- package/dist/log-out-delete-section.component.d.ts.map +1 -0
- package/dist/log-out-delete-section.component.js +249 -0
- package/dist/log-out-delete-section.component.js.map +1 -0
- package/dist/notifications-section.component.d.ts +78 -0
- package/dist/notifications-section.component.d.ts.map +1 -0
- package/dist/notifications-section.component.js +256 -0
- package/dist/notifications-section.component.js.map +1 -0
- package/dist/push-toggle.d.ts +12 -0
- package/dist/push-toggle.d.ts.map +1 -0
- package/dist/push-toggle.js +11 -0
- package/dist/push-toggle.js.map +1 -0
- package/dist/settings-container.component.d.ts +33 -0
- package/dist/settings-container.component.d.ts.map +1 -0
- package/dist/settings-container.component.js +64 -0
- package/dist/settings-container.component.js.map +1 -0
- package/dist/this-device-section.component.d.ts +40 -0
- package/dist/this-device-section.component.d.ts.map +1 -0
- package/dist/this-device-section.component.js +149 -0
- package/dist/this-device-section.component.js.map +1 -0
- package/dist/tiers-upgrade-section.component.d.ts +89 -0
- package/dist/tiers-upgrade-section.component.d.ts.map +1 -0
- package/dist/tiers-upgrade-section.component.js +407 -0
- package/dist/tiers-upgrade-section.component.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +78 -4
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LogOutDeleteSection component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component, signal } from '@angular/core';
|
|
7
|
+
import { useAuth, useHttpClient, useRouter, useTranslation } from '@molecule/app-angular';
|
|
8
|
+
import { serverErrorMessage } from '@molecule/app-http';
|
|
9
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
import { Alert, Button, Input, Modal } from '@molecule/app-ui-angular';
|
|
11
|
+
import { useSettingsPanelContext } from './context.js';
|
|
12
|
+
import * as i0 from "@angular/core";
|
|
13
|
+
const _c0 = () => ({ defaultValue: "Sign out" });
|
|
14
|
+
const _c1 = () => ({ defaultValue: "Delete account" });
|
|
15
|
+
const _c2 = () => ({ defaultValue: "Delete Account" });
|
|
16
|
+
const _c3 = () => ({ defaultValue: "This action cannot be undone. Please enter your password to confirm." });
|
|
17
|
+
const _c4 = () => ({ defaultValue: "Password" });
|
|
18
|
+
const _c5 = () => ({ defaultValue: "Deleting..." });
|
|
19
|
+
function LogOutDeleteSection_Conditional_8_Template(rf, ctx) { if (rf & 1) {
|
|
20
|
+
i0.ɵɵelementStart(0, "div", 3);
|
|
21
|
+
i0.ɵɵtext(1);
|
|
22
|
+
i0.ɵɵelementEnd();
|
|
23
|
+
} if (rf & 2) {
|
|
24
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
25
|
+
i0.ɵɵproperty("status", "error")("className", ctx_r0.cm.sp("mb", 4));
|
|
26
|
+
i0.ɵɵadvance();
|
|
27
|
+
i0.ɵɵtextInterpolate(ctx);
|
|
28
|
+
} }
|
|
29
|
+
function LogOutDeleteSection_Conditional_15_Template(rf, ctx) { if (rf & 1) {
|
|
30
|
+
i0.ɵɵtext(0);
|
|
31
|
+
} if (rf & 2) {
|
|
32
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
33
|
+
i0.ɵɵtextInterpolate1(" ", ctx_r0.t("settings.deleteAccountModal.deleting", undefined, i0.ɵɵpureFunction0(1, _c5)), " ");
|
|
34
|
+
} }
|
|
35
|
+
function LogOutDeleteSection_Conditional_16_Template(rf, ctx) { if (rf & 1) {
|
|
36
|
+
i0.ɵɵtext(0);
|
|
37
|
+
} if (rf & 2) {
|
|
38
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
39
|
+
i0.ɵɵtextInterpolate1(" ", ctx_r0.t("settings.deleteAccount", undefined, i0.ɵɵpureFunction0(1, _c1)), " ");
|
|
40
|
+
} }
|
|
41
|
+
/**
|
|
42
|
+
* LogOutDeleteSection component.
|
|
43
|
+
*
|
|
44
|
+
* Bottom actions section — Log out + Delete account. React's root is a
|
|
45
|
+
* fragment (the `<section>` plus the delete-account modal), so the host is
|
|
46
|
+
* unwrapped by the DOM normalizer and `display: contents` keeps the layout
|
|
47
|
+
* fragment-like.
|
|
48
|
+
*
|
|
49
|
+
* Owns the delete-account modal internally (the trigger lives in the
|
|
50
|
+
* same section so the modal lives here too). Reads `onClose` from
|
|
51
|
+
* the `<SettingsContainer>` context to dismiss the panel after either
|
|
52
|
+
* action and navigates to `/login`.
|
|
53
|
+
*/
|
|
54
|
+
export class LogOutDeleteSection {
|
|
55
|
+
/** Reactive translation, read in the injection context. */
|
|
56
|
+
i18n = useTranslation();
|
|
57
|
+
/** The translation function for the template. */
|
|
58
|
+
t = this.i18n.t;
|
|
59
|
+
/** The binding's router (throws outside one, like react-router's useNavigate). */
|
|
60
|
+
router = useRouter();
|
|
61
|
+
/** The signed-in user and the auth actions. */
|
|
62
|
+
auth = useAuth();
|
|
63
|
+
http = useHttpClient();
|
|
64
|
+
/** The container's `onClose` (throws outside a `<SettingsContainer>`). */
|
|
65
|
+
panel = useSettingsPanelContext();
|
|
66
|
+
/** Whether the delete-account modal is open. */
|
|
67
|
+
showModal = signal(false, /* @ts-ignore */
|
|
68
|
+
...(ngDevMode ? [{ debugName: "showModal" }] : /* istanbul ignore next */ []));
|
|
69
|
+
/** The delete-account password field's value. */
|
|
70
|
+
password = signal('', /* @ts-ignore */
|
|
71
|
+
...(ngDevMode ? [{ debugName: "password" }] : /* istanbul ignore next */ []));
|
|
72
|
+
/** Whether the delete request is running. */
|
|
73
|
+
loading = signal(false, /* @ts-ignore */
|
|
74
|
+
...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
75
|
+
/** The delete-account modal's error message. */
|
|
76
|
+
deleteError = signal('', /* @ts-ignore */
|
|
77
|
+
...(ngDevMode ? [{ debugName: "deleteError" }] : /* istanbul ignore next */ []));
|
|
78
|
+
/** The bonded ClassMap (styling tokens resolve at render time). */
|
|
79
|
+
cm = getClassMap();
|
|
80
|
+
/** Signs out, closes the panel and returns to `/login` (React's `handleLogout`). */
|
|
81
|
+
async logout() {
|
|
82
|
+
await this.auth.logout();
|
|
83
|
+
this.panel.onClose();
|
|
84
|
+
this.router.navigate('/login');
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Deletes the account (React's `handleDelete`): submits the password,
|
|
88
|
+
* signs out, closes the panel and returns to `/login`; a failure shows the
|
|
89
|
+
* server's message and keeps the modal.
|
|
90
|
+
* @param event - The native submit event.
|
|
91
|
+
*/
|
|
92
|
+
async deleteAccount(event) {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
this.loading.set(true);
|
|
95
|
+
this.deleteError.set('');
|
|
96
|
+
try {
|
|
97
|
+
await this.http.delete(`/api/users/${this.auth.user()?.id}`, {
|
|
98
|
+
data: { password: this.password() },
|
|
99
|
+
});
|
|
100
|
+
await this.auth.logout();
|
|
101
|
+
this.panel.onClose();
|
|
102
|
+
this.router.navigate('/login');
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
this.deleteError.set(serverErrorMessage(err) ??
|
|
106
|
+
this.t('settings.failedToDeleteAccount', undefined, {
|
|
107
|
+
defaultValue: 'Failed to delete account.',
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
this.loading.set(false);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
static ɵfac = function LogOutDeleteSection_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || LogOutDeleteSection)(); };
|
|
115
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LogOutDeleteSection, selectors: [["mol-log-out-delete-section"]], hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], decls: 17, vars: 31, consts: [["mol-button", "", "data-mol-id", "user-menu-logout", 3, "click", "color", "fullWidth"], ["mol-button", "", "data-mol-id", "user-menu-delete-account", 3, "click", "variant", "fullWidth"], [3, "close", "open", "title"], ["mol-alert", "", 3, "status", "className"], [3, "submit"], ["for", "delete-pw"], ["mol-input", "", "type", "password", 3, "change", "id", "required", "value"], ["mol-button", "", "type", "submit", 3, "color", "fullWidth", "loading"]], template: function LogOutDeleteSection_Template(rf, ctx) { if (rf & 1) {
|
|
116
|
+
i0.ɵɵelementStart(0, "section")(1, "button", 0);
|
|
117
|
+
i0.ɵɵlistener("click", function LogOutDeleteSection_Template_button_click_1_listener() { return ctx.logout(); });
|
|
118
|
+
i0.ɵɵtext(2);
|
|
119
|
+
i0.ɵɵelementEnd();
|
|
120
|
+
i0.ɵɵelementStart(3, "button", 1);
|
|
121
|
+
i0.ɵɵlistener("click", function LogOutDeleteSection_Template_button_click_3_listener() { return ctx.showModal.set(true); });
|
|
122
|
+
i0.ɵɵtext(4);
|
|
123
|
+
i0.ɵɵelementEnd()();
|
|
124
|
+
i0.ɵɵelementStart(5, "mol-modal", 2);
|
|
125
|
+
i0.ɵɵlistener("close", function LogOutDeleteSection_Template_mol_modal_close_5_listener() { return ctx.showModal.set(false); });
|
|
126
|
+
i0.ɵɵelementStart(6, "p");
|
|
127
|
+
i0.ɵɵtext(7);
|
|
128
|
+
i0.ɵɵelementEnd();
|
|
129
|
+
i0.ɵɵconditionalCreate(8, LogOutDeleteSection_Conditional_8_Template, 2, 3, "div", 3);
|
|
130
|
+
i0.ɵɵelementStart(9, "form", 4);
|
|
131
|
+
i0.ɵɵlistener("submit", function LogOutDeleteSection_Template_form_submit_9_listener($event) { return ctx.deleteAccount($event); });
|
|
132
|
+
i0.ɵɵelementStart(10, "div")(11, "label", 5);
|
|
133
|
+
i0.ɵɵtext(12);
|
|
134
|
+
i0.ɵɵelementEnd();
|
|
135
|
+
i0.ɵɵelementStart(13, "div", 6);
|
|
136
|
+
i0.ɵɵlistener("change", function LogOutDeleteSection_Template_div_change_13_listener($event) { return ctx.password.set($event.target.value); });
|
|
137
|
+
i0.ɵɵelementEnd()();
|
|
138
|
+
i0.ɵɵelementStart(14, "button", 7);
|
|
139
|
+
i0.ɵɵconditionalCreate(15, LogOutDeleteSection_Conditional_15_Template, 1, 2)(16, LogOutDeleteSection_Conditional_16_Template, 1, 2);
|
|
140
|
+
i0.ɵɵelementEnd()()();
|
|
141
|
+
} if (rf & 2) {
|
|
142
|
+
let tmp_11_0;
|
|
143
|
+
i0.ɵɵclassMap(ctx.cm.stack(3));
|
|
144
|
+
i0.ɵɵadvance();
|
|
145
|
+
i0.ɵɵproperty("color", "error")("fullWidth", true);
|
|
146
|
+
i0.ɵɵadvance();
|
|
147
|
+
i0.ɵɵtextInterpolate1(" ", ctx.t("settings.logOut", undefined, i0.ɵɵpureFunction0(26, _c0)), " ");
|
|
148
|
+
i0.ɵɵadvance();
|
|
149
|
+
i0.ɵɵproperty("variant", "ghost")("fullWidth", true);
|
|
150
|
+
i0.ɵɵadvance();
|
|
151
|
+
i0.ɵɵtextInterpolate1(" ", ctx.t("settings.deleteAccount", undefined, i0.ɵɵpureFunction0(27, _c1)), " ");
|
|
152
|
+
i0.ɵɵadvance();
|
|
153
|
+
i0.ɵɵproperty("open", ctx.showModal())("title", ctx.t("settings.deleteAccountModal.title", undefined, i0.ɵɵpureFunction0(28, _c2)));
|
|
154
|
+
i0.ɵɵadvance();
|
|
155
|
+
i0.ɵɵclassMap(ctx.cm.cn(ctx.cm.textSize("sm"), ctx.cm.textMuted, ctx.cm.sp("mb", 4)));
|
|
156
|
+
i0.ɵɵadvance();
|
|
157
|
+
i0.ɵɵtextInterpolate1(" ", ctx.t("settings.deleteAccountModal.warning", undefined, i0.ɵɵpureFunction0(29, _c3)), " ");
|
|
158
|
+
i0.ɵɵadvance();
|
|
159
|
+
i0.ɵɵconditional((tmp_11_0 = ctx.deleteError()) ? 8 : -1, tmp_11_0);
|
|
160
|
+
i0.ɵɵadvance();
|
|
161
|
+
i0.ɵɵclassMap(ctx.cm.stack(4));
|
|
162
|
+
i0.ɵɵadvance(2);
|
|
163
|
+
i0.ɵɵclassMap(ctx.cm.formLabel);
|
|
164
|
+
i0.ɵɵadvance();
|
|
165
|
+
i0.ɵɵtextInterpolate(ctx.t("settings.deleteAccountModal.password", undefined, i0.ɵɵpureFunction0(30, _c4)));
|
|
166
|
+
i0.ɵɵadvance();
|
|
167
|
+
i0.ɵɵproperty("id", "delete-pw")("required", true)("value", ctx.password());
|
|
168
|
+
i0.ɵɵadvance();
|
|
169
|
+
i0.ɵɵproperty("color", "error")("fullWidth", true)("loading", ctx.loading());
|
|
170
|
+
i0.ɵɵadvance();
|
|
171
|
+
i0.ɵɵconditional(ctx.loading() ? 15 : 16);
|
|
172
|
+
} }, dependencies: [Alert, Button, Input, Modal], encapsulation: 2 });
|
|
173
|
+
}
|
|
174
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LogOutDeleteSection, [{
|
|
175
|
+
type: Component,
|
|
176
|
+
args: [{
|
|
177
|
+
selector: 'mol-log-out-delete-section',
|
|
178
|
+
standalone: true,
|
|
179
|
+
imports: [Alert, Button, Input, Modal],
|
|
180
|
+
host: {
|
|
181
|
+
'data-parity-unwrap': '',
|
|
182
|
+
style: 'display: contents',
|
|
183
|
+
},
|
|
184
|
+
template: `<section [class]="cm.stack(3)">
|
|
185
|
+
<button
|
|
186
|
+
mol-button
|
|
187
|
+
[color]="'error'"
|
|
188
|
+
[fullWidth]="true"
|
|
189
|
+
(click)="logout()"
|
|
190
|
+
data-mol-id="user-menu-logout"
|
|
191
|
+
>
|
|
192
|
+
{{ t('settings.logOut', undefined, { defaultValue: 'Sign out' }) }}
|
|
193
|
+
</button>
|
|
194
|
+
<button
|
|
195
|
+
mol-button
|
|
196
|
+
[variant]="'ghost'"
|
|
197
|
+
[fullWidth]="true"
|
|
198
|
+
(click)="showModal.set(true)"
|
|
199
|
+
data-mol-id="user-menu-delete-account"
|
|
200
|
+
>
|
|
201
|
+
{{ t('settings.deleteAccount', undefined, { defaultValue: 'Delete account' }) }}
|
|
202
|
+
</button>
|
|
203
|
+
</section>
|
|
204
|
+
<mol-modal
|
|
205
|
+
[open]="showModal()"
|
|
206
|
+
(close)="showModal.set(false)"
|
|
207
|
+
[title]="
|
|
208
|
+
t('settings.deleteAccountModal.title', undefined, { defaultValue: 'Delete Account' })
|
|
209
|
+
"
|
|
210
|
+
>
|
|
211
|
+
<p [class]="cm.cn(cm.textSize('sm'), cm.textMuted, cm.sp('mb', 4))">
|
|
212
|
+
{{
|
|
213
|
+
t('settings.deleteAccountModal.warning', undefined, {
|
|
214
|
+
defaultValue: 'This action cannot be undone. Please enter your password to confirm.',
|
|
215
|
+
})
|
|
216
|
+
}}
|
|
217
|
+
</p>
|
|
218
|
+
@if (deleteError(); as submitError) {
|
|
219
|
+
<div mol-alert [status]="'error'" [className]="cm.sp('mb', 4)">{{ submitError }}</div>
|
|
220
|
+
}
|
|
221
|
+
<form [class]="cm.stack(4)" (submit)="deleteAccount($event)">
|
|
222
|
+
<div>
|
|
223
|
+
<label for="delete-pw" [class]="cm.formLabel">{{
|
|
224
|
+
t('settings.deleteAccountModal.password', undefined, { defaultValue: 'Password' })
|
|
225
|
+
}}</label>
|
|
226
|
+
<div
|
|
227
|
+
mol-input
|
|
228
|
+
[id]="'delete-pw'"
|
|
229
|
+
type="password"
|
|
230
|
+
[required]="true"
|
|
231
|
+
[value]="password()"
|
|
232
|
+
(change)="password.set($any($event.target).value)"
|
|
233
|
+
></div>
|
|
234
|
+
</div>
|
|
235
|
+
<button mol-button type="submit" [color]="'error'" [fullWidth]="true" [loading]="loading()">
|
|
236
|
+
@if (loading()) {
|
|
237
|
+
{{
|
|
238
|
+
t('settings.deleteAccountModal.deleting', undefined, { defaultValue: 'Deleting...' })
|
|
239
|
+
}}
|
|
240
|
+
} @else {
|
|
241
|
+
{{ t('settings.deleteAccount', undefined, { defaultValue: 'Delete account' }) }}
|
|
242
|
+
}
|
|
243
|
+
</button>
|
|
244
|
+
</form>
|
|
245
|
+
</mol-modal>`,
|
|
246
|
+
}]
|
|
247
|
+
}], null, null); })();
|
|
248
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(LogOutDeleteSection, { className: "LogOutDeleteSection", filePath: "log-out-delete-section.component.ts", lineNumber: 102 }); })();
|
|
249
|
+
//# sourceMappingURL=log-out-delete-section.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-out-delete-section.component.js","sourceRoot":"","sources":["../src/log-out-delete-section.component.ts"],"names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AAE;oBACxB,KAAK,EAAE,mBAAmB;iBAC3B;gBACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DK;aAChB;;kFACY,mBAAmB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NotificationsSection component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type AfterViewInit, ElementRef } from '@angular/core';
|
|
7
|
+
import type { UIClassMap } from '@molecule/app-ui';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
/**
|
|
10
|
+
* NotificationsSection component.
|
|
11
|
+
*
|
|
12
|
+
* Push-notification toggle section — the full receive-side enable chain:
|
|
13
|
+
* browser permission → runtime VAPID public key
|
|
14
|
+
* (`GET /api/devices/push/public-key`) → `pushManager.subscribe` with
|
|
15
|
+
* `applicationServerKey` → PATCH the subscription onto the current device
|
|
16
|
+
* row (`/api/devices/:id { pushSubscription, hasPushSubscription }`), which
|
|
17
|
+
* is where the api-side push fan-outs look for it. The host IS the
|
|
18
|
+
* `<section>` React renders.
|
|
19
|
+
*
|
|
20
|
+
* Initial state reflects SERVER truth (the current device row's
|
|
21
|
+
* `hasPushSubscription`), and every failure surfaces as an honest inline
|
|
22
|
+
* message — a dev build without a service worker fails fast instead of
|
|
23
|
+
* hanging the switch.
|
|
24
|
+
*/
|
|
25
|
+
export declare class NotificationsSection implements AfterViewInit {
|
|
26
|
+
/** Reactive translation, read in the injection context. */
|
|
27
|
+
protected readonly i18n: import("@molecule/app-angular").UseTranslationResult;
|
|
28
|
+
/** The translation function for the template. */
|
|
29
|
+
protected t: (key: string, values?: import("@molecule/app-i18n").InterpolationValues, options?: import("@molecule/app-i18n").TranslateOptions) => string;
|
|
30
|
+
private readonly http;
|
|
31
|
+
/** The push provider's permission/registration actions. */
|
|
32
|
+
private readonly push;
|
|
33
|
+
/** Whether the current device's push subscription is on. */
|
|
34
|
+
protected readonly enabled: import("@angular/core").WritableSignal<boolean>;
|
|
35
|
+
/** Whether an enable/disable chain is running (the switch is disabled). */
|
|
36
|
+
protected readonly busy: import("@angular/core").WritableSignal<boolean>;
|
|
37
|
+
/** The inline failure message, or null. */
|
|
38
|
+
protected readonly error: import("@angular/core").WritableSignal<string | null>;
|
|
39
|
+
/** The push switch's host element (the hidden checkbox lives inside). */
|
|
40
|
+
pushSwitch?: ElementRef<HTMLElement>;
|
|
41
|
+
/** The controlled-`checked` sync (created once the host exists). */
|
|
42
|
+
private sync?;
|
|
43
|
+
/** The bonded ClassMap (styling tokens resolve at render time). */
|
|
44
|
+
protected readonly cm: UIClassMap;
|
|
45
|
+
/**
|
|
46
|
+
* Reads the server's push state for THIS device (React's mount effect).
|
|
47
|
+
* Resolves false (never throws) when the devices endpoint is unavailable;
|
|
48
|
+
* a result that lands after unmount is dropped like React's cancelled one.
|
|
49
|
+
*/
|
|
50
|
+
constructor();
|
|
51
|
+
/** Captures the mount-time attribute state (hooks run on the mount passes). */
|
|
52
|
+
ngAfterViewInit(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Runs the controlled-`checked` sync once the switch host exists.
|
|
55
|
+
* @param checked - The controlled value this render shows.
|
|
56
|
+
*/
|
|
57
|
+
private runSync;
|
|
58
|
+
/**
|
|
59
|
+
* The switch's change: the hidden checkbox's `checked` at emit time (React
|
|
60
|
+
* reads `e.target.checked` before its controlled restore).
|
|
61
|
+
* @param event - The native change event the UI Switch re-emitted.
|
|
62
|
+
*/
|
|
63
|
+
protected pushToggleChanged(event: Event): void;
|
|
64
|
+
/**
|
|
65
|
+
* The localized message for one toggle failure (React's `failureMessage`).
|
|
66
|
+
* @param result - The failed toggle result.
|
|
67
|
+
* @returns The message text.
|
|
68
|
+
*/
|
|
69
|
+
private failureMessage;
|
|
70
|
+
/**
|
|
71
|
+
* Runs one enable/disable chain (React's `handleToggle`).
|
|
72
|
+
* @param next - Whether the switch turned on.
|
|
73
|
+
*/
|
|
74
|
+
private handleToggle;
|
|
75
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NotificationsSection, never>;
|
|
76
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NotificationsSection, "section[mol-settings-notifications]", never, {}, {}, never, never, true, never>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=notifications-section.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications-section.component.d.ts","sourceRoot":"","sources":["../src/notifications-section.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,aAAa,EAIlB,UAAU,EAKX,MAAM,eAAe,CAAA;AAStB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;;AAMlD;;;;;;;;;;;;;;;GAeG;AACH,qBAiCa,oBAAqB,YAAW,aAAa;IACxD,2DAA2D;IAC3D,SAAS,CAAC,QAAQ,CAAC,IAAI,uDAAmB;IAE1C,iDAAiD;IACjD,SAAS,CAAC,CAAC,8IAAc;IAEzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;IAEvC,2DAA2D;IAC3D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IAEjC,4DAA4D;IAC5D,SAAS,CAAC,QAAQ,CAAC,OAAO,kDAAgB;IAC1C,2EAA2E;IAC3E,SAAS,CAAC,QAAQ,CAAC,IAAI,kDAAgB;IACvC,2CAA2C;IAC3C,SAAS,CAAC,QAAQ,CAAC,KAAK,wDAA8B;IAEtD,yEAAyE;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;IAEnF,oEAAoE;IACpE,OAAO,CAAC,IAAI,CAAC,CAAsB;IAEnC,mEAAmE;IACnE,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAgB;IAEjD;;;;OAIG;;IAmBH,+EAA+E;IAC/E,eAAe,IAAI,IAAI;IAIvB;;;OAGG;IACH,OAAO,CAAC,OAAO;IAOf;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK/C;;;;OAIG;IACH,OAAO,CAAC,cAAc;IA4BtB;;;OAGG;YACW,YAAY;yCAlHf,oBAAoB;2CAApB,oBAAoB;CAkJhC"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NotificationsSection component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component, DestroyRef, effect, ElementRef, inject, signal, untracked, ViewChild, } from '@angular/core';
|
|
7
|
+
import { useHttpClient, usePush, useTranslation } from '@molecule/app-angular';
|
|
8
|
+
import { disablePushOnCurrentDevice, enablePushOnCurrentDevice, readCurrentDevicePushEnabled, } from '@molecule/app-push';
|
|
9
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
import { Flex, Switch } from '@molecule/app-ui-angular';
|
|
11
|
+
import { ControlledSwitchSync } from './controlled-switch.js';
|
|
12
|
+
import * as i0 from "@angular/core";
|
|
13
|
+
const _c0 = ["pushSwitch"];
|
|
14
|
+
const _c1 = () => ({ defaultValue: "Notifications" });
|
|
15
|
+
const _c2 = () => ({ defaultValue: "Push notifications" });
|
|
16
|
+
function NotificationsSection_Conditional_7_Template(rf, ctx) { if (rf & 1) {
|
|
17
|
+
i0.ɵɵelementStart(0, "p", 4);
|
|
18
|
+
i0.ɵɵtext(1);
|
|
19
|
+
i0.ɵɵelementEnd();
|
|
20
|
+
} if (rf & 2) {
|
|
21
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
22
|
+
i0.ɵɵclassMap(ctx_r0.cm.cn(ctx_r0.cm.textSize("xs"), ctx_r0.cm.textError, ctx_r0.cm.sp("mt", 1)));
|
|
23
|
+
i0.ɵɵadvance();
|
|
24
|
+
i0.ɵɵtextInterpolate1(" ", ctx, " ");
|
|
25
|
+
} }
|
|
26
|
+
/**
|
|
27
|
+
* NotificationsSection component.
|
|
28
|
+
*
|
|
29
|
+
* Push-notification toggle section — the full receive-side enable chain:
|
|
30
|
+
* browser permission → runtime VAPID public key
|
|
31
|
+
* (`GET /api/devices/push/public-key`) → `pushManager.subscribe` with
|
|
32
|
+
* `applicationServerKey` → PATCH the subscription onto the current device
|
|
33
|
+
* row (`/api/devices/:id { pushSubscription, hasPushSubscription }`), which
|
|
34
|
+
* is where the api-side push fan-outs look for it. The host IS the
|
|
35
|
+
* `<section>` React renders.
|
|
36
|
+
*
|
|
37
|
+
* Initial state reflects SERVER truth (the current device row's
|
|
38
|
+
* `hasPushSubscription`), and every failure surfaces as an honest inline
|
|
39
|
+
* message — a dev build without a service worker fails fast instead of
|
|
40
|
+
* hanging the switch.
|
|
41
|
+
*/
|
|
42
|
+
export class NotificationsSection {
|
|
43
|
+
/** Reactive translation, read in the injection context. */
|
|
44
|
+
i18n = useTranslation();
|
|
45
|
+
/** The translation function for the template. */
|
|
46
|
+
t = this.i18n.t;
|
|
47
|
+
http = useHttpClient();
|
|
48
|
+
/** The push provider's permission/registration actions. */
|
|
49
|
+
push = usePush();
|
|
50
|
+
/** Whether the current device's push subscription is on. */
|
|
51
|
+
enabled = signal(false, /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
|
|
53
|
+
/** Whether an enable/disable chain is running (the switch is disabled). */
|
|
54
|
+
busy = signal(false, /* @ts-ignore */
|
|
55
|
+
...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
|
|
56
|
+
/** The inline failure message, or null. */
|
|
57
|
+
error = signal(null, /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
59
|
+
/** The push switch's host element (the hidden checkbox lives inside). */
|
|
60
|
+
pushSwitch;
|
|
61
|
+
/** The controlled-`checked` sync (created once the host exists). */
|
|
62
|
+
sync;
|
|
63
|
+
/** The bonded ClassMap (styling tokens resolve at render time). */
|
|
64
|
+
cm = getClassMap();
|
|
65
|
+
/**
|
|
66
|
+
* Reads the server's push state for THIS device (React's mount effect).
|
|
67
|
+
* Resolves false (never throws) when the devices endpoint is unavailable;
|
|
68
|
+
* a result that lands after unmount is dropped like React's cancelled one.
|
|
69
|
+
*/
|
|
70
|
+
constructor() {
|
|
71
|
+
let cancelled = false;
|
|
72
|
+
inject(DestroyRef).onDestroy(() => {
|
|
73
|
+
cancelled = true;
|
|
74
|
+
});
|
|
75
|
+
// Server truth for THIS device; resolves false (never throws) when the
|
|
76
|
+
// devices endpoint is unavailable.
|
|
77
|
+
void readCurrentDevicePushEnabled(this.http).then((serverEnabled) => {
|
|
78
|
+
if (!cancelled && serverEnabled)
|
|
79
|
+
this.enabled.set(true);
|
|
80
|
+
});
|
|
81
|
+
// React's controlled `checked` re-render, as an effect (view hooks are
|
|
82
|
+
// skipped by signal-driven refreshes).
|
|
83
|
+
effect(() => {
|
|
84
|
+
const checked = this.enabled();
|
|
85
|
+
untracked(() => this.runSync(checked));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** Captures the mount-time attribute state (hooks run on the mount passes). */
|
|
89
|
+
ngAfterViewInit() {
|
|
90
|
+
this.runSync(this.enabled());
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Runs the controlled-`checked` sync once the switch host exists.
|
|
94
|
+
* @param checked - The controlled value this render shows.
|
|
95
|
+
*/
|
|
96
|
+
runSync(checked) {
|
|
97
|
+
if (!this.sync && this.pushSwitch) {
|
|
98
|
+
this.sync = new ControlledSwitchSync(this.pushSwitch.nativeElement);
|
|
99
|
+
}
|
|
100
|
+
this.sync?.sync(checked);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The switch's change: the hidden checkbox's `checked` at emit time (React
|
|
104
|
+
* reads `e.target.checked` before its controlled restore).
|
|
105
|
+
* @param event - The native change event the UI Switch re-emitted.
|
|
106
|
+
*/
|
|
107
|
+
pushToggleChanged(event) {
|
|
108
|
+
const checked = event.target?.checked ?? false;
|
|
109
|
+
void this.handleToggle(checked);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The localized message for one toggle failure (React's `failureMessage`).
|
|
113
|
+
* @param result - The failed toggle result.
|
|
114
|
+
* @returns The message text.
|
|
115
|
+
*/
|
|
116
|
+
failureMessage(result) {
|
|
117
|
+
switch (result.reason) {
|
|
118
|
+
case 'permission-denied':
|
|
119
|
+
return this.t('settings.pushPermissionDenied', undefined, {
|
|
120
|
+
defaultValue: 'Notification permission was denied.',
|
|
121
|
+
});
|
|
122
|
+
case 'server-unconfigured':
|
|
123
|
+
return this.t('settings.pushServerUnavailable', undefined, {
|
|
124
|
+
defaultValue: 'Push notifications are not configured on this server.',
|
|
125
|
+
});
|
|
126
|
+
case 'register-failed':
|
|
127
|
+
// The push provider throws already-localized messages (not supported /
|
|
128
|
+
// no service worker in a dev build / push-service rejection).
|
|
129
|
+
return (result.message ||
|
|
130
|
+
this.t('settings.pushUpdateFailed', undefined, {
|
|
131
|
+
defaultValue: 'Could not update push notification settings.',
|
|
132
|
+
}));
|
|
133
|
+
case 'persist-failed':
|
|
134
|
+
// `result.message` here is the HTTP client's error (a status line or a
|
|
135
|
+
// network error), not text written for the user, so it is not shown.
|
|
136
|
+
return this.t('settings.pushUpdateFailed', undefined, {
|
|
137
|
+
defaultValue: 'Could not update push notification settings.',
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Runs one enable/disable chain (React's `handleToggle`).
|
|
143
|
+
* @param next - Whether the switch turned on.
|
|
144
|
+
*/
|
|
145
|
+
async handleToggle(next) {
|
|
146
|
+
if (this.busy())
|
|
147
|
+
return;
|
|
148
|
+
this.busy.set(true);
|
|
149
|
+
this.error.set(null);
|
|
150
|
+
try {
|
|
151
|
+
if (next) {
|
|
152
|
+
const result = await enablePushOnCurrentDevice({
|
|
153
|
+
http: this.http,
|
|
154
|
+
requestPermission: this.push.requestPermission,
|
|
155
|
+
register: this.push.register,
|
|
156
|
+
});
|
|
157
|
+
if (result.ok) {
|
|
158
|
+
this.enabled.set(true);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.error.set(this.failureMessage(result));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const result = await disablePushOnCurrentDevice({
|
|
166
|
+
http: this.http,
|
|
167
|
+
unregister: this.push.unregister,
|
|
168
|
+
});
|
|
169
|
+
// The switch goes off locally either way; a failed server clear is
|
|
170
|
+
// still reported so the user knows sends may continue.
|
|
171
|
+
this.enabled.set(false);
|
|
172
|
+
if (!result.ok) {
|
|
173
|
+
this.error.set(this.failureMessage(result));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
this.busy.set(false);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
static ɵfac = function NotificationsSection_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || NotificationsSection)(); };
|
|
182
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: NotificationsSection, selectors: [["section", "mol-settings-notifications", ""]], viewQuery: function NotificationsSection_Query(rf, ctx) { if (rf & 1) {
|
|
183
|
+
i0.ɵɵviewQuery(_c0, 5, ElementRef);
|
|
184
|
+
} if (rf & 2) {
|
|
185
|
+
let _t;
|
|
186
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.pushSwitch = _t.first);
|
|
187
|
+
} }, decls: 8, vars: 16, consts: [["pushSwitch", ""], ["mol-flex", "", 3, "align", "justify"], ["data-mol-id", "settings-push-toggle", 3, "change", "checked", "disabled", "size"], ["role", "alert", "data-mol-id", "settings-push-error", 3, "class"], ["role", "alert", "data-mol-id", "settings-push-error"]], template: function NotificationsSection_Template(rf, ctx) { if (rf & 1) {
|
|
188
|
+
i0.ɵɵelementStart(0, "h3");
|
|
189
|
+
i0.ɵɵtext(1);
|
|
190
|
+
i0.ɵɵelementEnd();
|
|
191
|
+
i0.ɵɵelementStart(2, "div", 1)(3, "span");
|
|
192
|
+
i0.ɵɵtext(4);
|
|
193
|
+
i0.ɵɵelementEnd();
|
|
194
|
+
i0.ɵɵelementStart(5, "mol-switch", 2, 0);
|
|
195
|
+
i0.ɵɵlistener("change", function NotificationsSection_Template_mol_switch_change_5_listener($event) { return ctx.pushToggleChanged($event); });
|
|
196
|
+
i0.ɵɵelementEnd()();
|
|
197
|
+
i0.ɵɵconditionalCreate(7, NotificationsSection_Conditional_7_Template, 2, 3, "p", 3);
|
|
198
|
+
} if (rf & 2) {
|
|
199
|
+
let tmp_11_0;
|
|
200
|
+
i0.ɵɵclassMap(ctx.cm.cn(ctx.cm.sectionHeading, ctx.cm.sp("mb", 3)));
|
|
201
|
+
i0.ɵɵadvance();
|
|
202
|
+
i0.ɵɵtextInterpolate1(" ", ctx.t("settings.notifications", undefined, i0.ɵɵpureFunction0(13, _c1)), " ");
|
|
203
|
+
i0.ɵɵadvance();
|
|
204
|
+
i0.ɵɵproperty("align", "center")("justify", "between");
|
|
205
|
+
i0.ɵɵadvance();
|
|
206
|
+
i0.ɵɵclassMap(ctx.cm.textSize("sm"));
|
|
207
|
+
i0.ɵɵadvance();
|
|
208
|
+
i0.ɵɵtextInterpolate(ctx.t("settings.pushNotifications", undefined, i0.ɵɵpureFunction0(14, _c2)));
|
|
209
|
+
i0.ɵɵadvance();
|
|
210
|
+
i0.ɵɵproperty("checked", ctx.enabled())("disabled", ctx.busy())("size", "sm");
|
|
211
|
+
i0.ɵɵattribute("aria-label", ctx.t("settings.pushNotifications", undefined, i0.ɵɵpureFunction0(15, _c2)));
|
|
212
|
+
i0.ɵɵadvance(2);
|
|
213
|
+
i0.ɵɵconditional((tmp_11_0 = ctx.error()) ? 7 : -1, tmp_11_0);
|
|
214
|
+
} }, dependencies: [Flex, Switch], encapsulation: 2 });
|
|
215
|
+
}
|
|
216
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NotificationsSection, [{
|
|
217
|
+
type: Component,
|
|
218
|
+
args: [{
|
|
219
|
+
selector: 'section[mol-settings-notifications]',
|
|
220
|
+
standalone: true,
|
|
221
|
+
imports: [Flex, Switch],
|
|
222
|
+
template: `<h3 [class]="cm.cn(cm.sectionHeading, cm.sp('mb', 3))">
|
|
223
|
+
{{ t('settings.notifications', undefined, { defaultValue: 'Notifications' }) }}
|
|
224
|
+
</h3>
|
|
225
|
+
<div mol-flex [align]="'center'" [justify]="'between'">
|
|
226
|
+
<span [class]="cm.textSize('sm')">{{
|
|
227
|
+
t('settings.pushNotifications', undefined, { defaultValue: 'Push notifications' })
|
|
228
|
+
}}</span>
|
|
229
|
+
<mol-switch
|
|
230
|
+
#pushSwitch
|
|
231
|
+
[checked]="enabled()"
|
|
232
|
+
[disabled]="busy()"
|
|
233
|
+
[attr.aria-label]="
|
|
234
|
+
t('settings.pushNotifications', undefined, { defaultValue: 'Push notifications' })
|
|
235
|
+
"
|
|
236
|
+
(change)="pushToggleChanged($event)"
|
|
237
|
+
[size]="'sm'"
|
|
238
|
+
data-mol-id="settings-push-toggle"
|
|
239
|
+
></mol-switch>
|
|
240
|
+
</div>
|
|
241
|
+
@if (error(); as pushError) {
|
|
242
|
+
<p
|
|
243
|
+
[class]="cm.cn(cm.textSize('xs'), cm.textError, cm.sp('mt', 1))"
|
|
244
|
+
role="alert"
|
|
245
|
+
data-mol-id="settings-push-error"
|
|
246
|
+
>
|
|
247
|
+
{{ pushError }}
|
|
248
|
+
</p>
|
|
249
|
+
}`,
|
|
250
|
+
}]
|
|
251
|
+
}], () => [], { pushSwitch: [{
|
|
252
|
+
type: ViewChild,
|
|
253
|
+
args: ['pushSwitch', { read: ElementRef }]
|
|
254
|
+
}] }); })();
|
|
255
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(NotificationsSection, { className: "NotificationsSection", filePath: "notifications-section.component.ts", lineNumber: 81 }); })();
|
|
256
|
+
//# sourceMappingURL=notifications-section.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications-section.component.js","sourceRoot":"","sources":["../src/notifications-section.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,SAAS,EACT,UAAU,EACV,MAAM,EACN,UAAU,EACV,MAAM,EACN,MAAM,EACN,SAAS,EACT,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE9E,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;;;;;;IA0CvD,4BAIC;IACC,YACF;IAAA,iBAAI;;;IALF,iGAAgE;IAIhE,cACF;IADE,oCACF;;AA9CN;;;;;;;;;;;;;;;GAeG;AAkCH,MAAM,OAAO,oBAAoB;IAC/B,2DAA2D;IACxC,IAAI,GAAG,cAAc,EAAE,CAAA;IAE1C,iDAAiD;IACvC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAER,IAAI,GAAG,aAAa,EAAE,CAAA;IAEvC,2DAA2D;IAC1C,IAAI,GAAG,OAAO,EAAE,CAAA;IAEjC,4DAA4D;IACzC,OAAO,GAAG,MAAM,CAAC,KAAK;gFAAC,CAAA;IAC1C,2EAA2E;IACxD,IAAI,GAAG,MAAM,CAAC,KAAK;6EAAC,CAAA;IACvC,2CAA2C;IACxB,KAAK,GAAG,MAAM,CAAgB,IAAI;8EAAC,CAAA;IAEtD,yEAAyE;IAC1B,UAAU,CAA0B;IAEnF,oE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;YARD,6DAQC;4BA5BO,IAAI,EAAE,MAAM;;iFA8BX,oBAAoB;cAjChC,SAAS;eAAC;gBACT,QAAQ,EAAE,qCAAqC;gBAC/C,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC;gBACvB,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2BN;aACL;;kBAqBE,SAAS;mBAAC,YAAY,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;;kFApBlC,oBAAoB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The current-device push toggle behind {@link NotificationsSection}: the
|
|
3
|
+
* full enable/disable chain — permission → runtime VAPID key fetch →
|
|
4
|
+
* subscribe → persist on the device row. It lives in `@molecule/app-push`
|
|
5
|
+
* (`device-toggle.ts`, with the server contract) so every framework's
|
|
6
|
+
* settings panel runs the same functions; this package re-exports them.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export type { PushToggleDevice, PushToggleFailureReason, PushToggleHttp, PushToggleResult, PushToggleToken, } from '@molecule/app-push';
|
|
11
|
+
export { disablePushOnCurrentDevice, enablePushOnCurrentDevice, findCurrentDevice, readCurrentDevicePushEnabled, subscriptionFromToken, } from '@molecule/app-push';
|
|
12
|
+
//# sourceMappingURL=push-toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-toggle.d.ts","sourceRoot":"","sources":["../src/push-toggle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,iBAAiB,EACjB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The current-device push toggle behind {@link NotificationsSection}: the
|
|
3
|
+
* full enable/disable chain — permission → runtime VAPID key fetch →
|
|
4
|
+
* subscribe → persist on the device row. It lives in `@molecule/app-push`
|
|
5
|
+
* (`device-toggle.ts`, with the server contract) so every framework's
|
|
6
|
+
* settings panel runs the same functions; this package re-exports them.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export { disablePushOnCurrentDevice, enablePushOnCurrentDevice, findCurrentDevice, readCurrentDevicePushEnabled, subscriptionFromToken, } from '@molecule/app-push';
|
|
11
|
+
//# sourceMappingURL=push-toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-toggle.js","sourceRoot":"","sources":["../src/push-toggle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,iBAAiB,EACjB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,oBAAoB,CAAA"}
|