feat: initial build - static app kapp-pwa
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,296 @@
|
||||
(self["webpackChunkapp"] = self["webpackChunkapp"] || []).push([[7671],{
|
||||
|
||||
/***/ 97671:
|
||||
/*!*********************************************************************!*\
|
||||
!*** ./node_modules/@capacitor/local-notifications/dist/esm/web.js ***!
|
||||
\*********************************************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "LocalNotificationsWeb": () => (/* binding */ LocalNotificationsWeb)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */ 71670);
|
||||
/* harmony import */ var _capacitor_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @capacitor/core */ 26549);
|
||||
|
||||
|
||||
class LocalNotificationsWeb extends _capacitor_core__WEBPACK_IMPORTED_MODULE_1__.WebPlugin {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.pending = [];
|
||||
this.deliveredNotifications = [];
|
||||
|
||||
this.hasNotificationSupport = () => {
|
||||
if (!('Notification' in window) || !Notification.requestPermission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Notification.permission !== 'granted') {
|
||||
// don't test for `new Notification` if permission has already been granted
|
||||
// otherwise this sends a real notification on supported browsers
|
||||
try {
|
||||
new Notification('');
|
||||
} catch (e) {
|
||||
if (e.name == 'TypeError') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
getDeliveredNotifications() {
|
||||
var _this = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
const deliveredSchemas = [];
|
||||
|
||||
for (const notification of _this.deliveredNotifications) {
|
||||
const deliveredSchema = {
|
||||
title: notification.title,
|
||||
id: parseInt(notification.tag),
|
||||
body: notification.body
|
||||
};
|
||||
deliveredSchemas.push(deliveredSchema);
|
||||
}
|
||||
|
||||
return {
|
||||
notifications: deliveredSchemas
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
removeDeliveredNotifications(delivered) {
|
||||
var _this2 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
for (const toRemove of delivered.notifications) {
|
||||
const found = _this2.deliveredNotifications.find(n => n.tag === String(toRemove.id));
|
||||
|
||||
found === null || found === void 0 ? void 0 : found.close();
|
||||
_this2.deliveredNotifications = _this2.deliveredNotifications.filter(() => !found);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
removeAllDeliveredNotifications() {
|
||||
var _this3 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
for (const notification of _this3.deliveredNotifications) {
|
||||
notification.close();
|
||||
}
|
||||
|
||||
_this3.deliveredNotifications = [];
|
||||
})();
|
||||
}
|
||||
|
||||
createChannel() {
|
||||
var _this4 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
throw _this4.unimplemented('Not implemented on web.');
|
||||
})();
|
||||
}
|
||||
|
||||
deleteChannel() {
|
||||
var _this5 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
throw _this5.unimplemented('Not implemented on web.');
|
||||
})();
|
||||
}
|
||||
|
||||
listChannels() {
|
||||
var _this6 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
throw _this6.unimplemented('Not implemented on web.');
|
||||
})();
|
||||
}
|
||||
|
||||
schedule(options) {
|
||||
var _this7 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
if (!_this7.hasNotificationSupport()) {
|
||||
throw _this7.unavailable('Notifications not supported in this browser.');
|
||||
}
|
||||
|
||||
for (const notification of options.notifications) {
|
||||
_this7.sendNotification(notification);
|
||||
}
|
||||
|
||||
return {
|
||||
notifications: options.notifications.map(notification => ({
|
||||
id: notification.id
|
||||
}))
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
getPending() {
|
||||
var _this8 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
return {
|
||||
notifications: _this8.pending
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
registerActionTypes() {
|
||||
var _this9 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
throw _this9.unimplemented('Not implemented on web.');
|
||||
})();
|
||||
}
|
||||
|
||||
cancel(pending) {
|
||||
var _this0 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
_this0.pending = _this0.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id));
|
||||
})();
|
||||
}
|
||||
|
||||
areEnabled() {
|
||||
var _this1 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
const {
|
||||
display
|
||||
} = yield _this1.checkPermissions();
|
||||
return {
|
||||
value: display === 'granted'
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
changeExactNotificationSetting() {
|
||||
var _this10 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
throw _this10.unimplemented('Not implemented on web.');
|
||||
})();
|
||||
}
|
||||
|
||||
checkExactNotificationSetting() {
|
||||
var _this11 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
throw _this11.unimplemented('Not implemented on web.');
|
||||
})();
|
||||
}
|
||||
|
||||
requestPermissions() {
|
||||
var _this12 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
if (!_this12.hasNotificationSupport()) {
|
||||
throw _this12.unavailable('Notifications not supported in this browser.');
|
||||
}
|
||||
|
||||
const display = _this12.transformNotificationPermission(yield Notification.requestPermission());
|
||||
|
||||
return {
|
||||
display
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
checkPermissions() {
|
||||
var _this13 = this;
|
||||
|
||||
return (0,_Volumes_case_workspace_work_APPS_KA_APP_WORK_NOW_KA_PASS_V2_2_6_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
|
||||
if (!_this13.hasNotificationSupport()) {
|
||||
throw _this13.unavailable('Notifications not supported in this browser.');
|
||||
}
|
||||
|
||||
const display = _this13.transformNotificationPermission(Notification.permission);
|
||||
|
||||
return {
|
||||
display
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
transformNotificationPermission(permission) {
|
||||
switch (permission) {
|
||||
case 'granted':
|
||||
return 'granted';
|
||||
|
||||
case 'denied':
|
||||
return 'denied';
|
||||
|
||||
default:
|
||||
return 'prompt';
|
||||
}
|
||||
}
|
||||
|
||||
sendPending() {
|
||||
var _a;
|
||||
|
||||
const toRemove = [];
|
||||
const now = new Date().getTime();
|
||||
|
||||
for (const notification of this.pending) {
|
||||
if (((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) && notification.schedule.at.getTime() <= now) {
|
||||
this.buildNotification(notification);
|
||||
toRemove.push(notification);
|
||||
}
|
||||
}
|
||||
|
||||
this.pending = this.pending.filter(notification => !toRemove.find(n => n === notification));
|
||||
}
|
||||
|
||||
sendNotification(notification) {
|
||||
var _a;
|
||||
|
||||
if ((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) {
|
||||
const diff = notification.schedule.at.getTime() - new Date().getTime();
|
||||
this.pending.push(notification);
|
||||
setTimeout(() => {
|
||||
this.sendPending();
|
||||
}, diff);
|
||||
return;
|
||||
}
|
||||
|
||||
this.buildNotification(notification);
|
||||
}
|
||||
|
||||
buildNotification(notification) {
|
||||
const localNotification = new Notification(notification.title, {
|
||||
body: notification.body,
|
||||
tag: String(notification.id)
|
||||
});
|
||||
localNotification.addEventListener('click', this.onClick.bind(this, notification), false);
|
||||
localNotification.addEventListener('show', this.onShow.bind(this, notification), false);
|
||||
localNotification.addEventListener('close', () => {
|
||||
this.deliveredNotifications = this.deliveredNotifications.filter(() => !this);
|
||||
}, false);
|
||||
this.deliveredNotifications.push(localNotification);
|
||||
return localNotification;
|
||||
}
|
||||
|
||||
onClick(notification) {
|
||||
const data = {
|
||||
actionId: 'tap',
|
||||
notification
|
||||
};
|
||||
this.notifyListeners('localNotificationActionPerformed', data);
|
||||
}
|
||||
|
||||
onShow(notification) {
|
||||
this.notifyListeners('localNotificationReceived', notification);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***/ })
|
||||
|
||||
}])
|
||||
//# sourceMappingURL=7671.js.map
|
||||
Reference in New Issue
Block a user