ep_desktop_notifications 11.0.23 → 11.0.25

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.
@@ -29,7 +29,7 @@ jobs:
29
29
  - uses: actions/setup-node@v6
30
30
  name: Install Node.js
31
31
  with:
32
- node-version: 22
32
+ node-version: 25
33
33
  - uses: pnpm/action-setup@v6
34
34
  name: Install pnpm
35
35
  with:
@@ -19,7 +19,7 @@ jobs:
19
19
  - uses: actions/setup-node@v6
20
20
  name: Install Node.js
21
21
  with:
22
- node-version: 22
22
+ node-version: 25
23
23
  - uses: pnpm/action-setup@v6
24
24
  name: Install pnpm
25
25
  with:
@@ -23,7 +23,7 @@ jobs:
23
23
  # OIDC trusted publishing needs npm >= 11.5.1, which requires
24
24
  # Node >= 20.17.0. setup-node's `20` resolves to the latest
25
25
  # 20.x, which satisfies that.
26
- node-version: 20
26
+ node-version: 25
27
27
  registry-url: https://registry.npmjs.org/
28
28
  - name: Upgrade npm to >=11.5.1 (required for trusted publishing)
29
29
  run: npm install -g npm@latest
@@ -1,20 +1,36 @@
1
1
  'use strict';
2
2
 
3
- const eejs = require('ep_etherpad-lite/node/eejs/');
4
- const settings = require('ep_etherpad-lite/node/utils/Settings');
5
- let checkedState = '';
3
+ const {padToggle} = require('ep_plugin_helpers/pad-toggle-server');
6
4
 
7
- exports.eejsBlock_mySettings = (hookName, args, cb) => {
8
- if (!settings.ep_desktop_notifications_default) checkedState = 'checked';
9
- args.content +=
10
- eejs.require('ep_desktop_notifications/templates/desktop_notifications_entry.ejs',
11
- {
12
- checked: checkedState,
13
- },
14
- );
15
- return cb();
5
+ // Parallel User Settings + Pad Wide Settings checkboxes for "Desktop
6
+ // Notifications". Helper owns markup, storage, broadcast, enforce, and i18n.
7
+ const desktopToggle = padToggle({
8
+ pluginName: 'ep_desktop_notifications',
9
+ settingId: 'desktopNotifications',
10
+ l10nId: 'ep_desktop_notifications.desktopNotifications',
11
+ defaultLabel: 'Desktop Notifications',
12
+ defaultEnabled: true,
13
+ });
14
+
15
+ // The previous version honored a top-level `ep_desktop_notifications_default`
16
+ // key with inverted semantics (truthy = default off). Translate to the
17
+ // helper's nested `defaultEnabled` so existing installs keep their behavior.
18
+ exports.loadSettings = async (hookName, args) => {
19
+ const root = args && args.settings;
20
+ if (root) {
21
+ const ps = (root.ep_desktop_notifications = root.ep_desktop_notifications || {});
22
+ if (typeof ps.defaultEnabled !== 'boolean' &&
23
+ typeof root.ep_desktop_notifications_default === 'boolean') {
24
+ ps.defaultEnabled = !root.ep_desktop_notifications_default;
25
+ }
26
+ }
27
+ return desktopToggle.loadSettings(hookName, args);
16
28
  };
17
29
 
30
+ exports.clientVars = desktopToggle.clientVars;
31
+ exports.eejsBlock_mySettings = desktopToggle.eejsBlock_mySettings;
32
+ exports.eejsBlock_padSettings = desktopToggle.eejsBlock_padSettings;
33
+
18
34
  exports.eejsBlock_styles = (hookName, args, cb) => {
19
35
  const url = '../static/plugins/ep_desktop_notifications/static/css/desktop_notifications.css';
20
36
  args.content += `<link href="${url}" rel='stylesheet'>`;
package/ep.json CHANGED
@@ -2,12 +2,17 @@
2
2
  "parts": [
3
3
  {
4
4
  "name": "ep_desktop_notifications",
5
+ "hooks": {
6
+ "loadSettings": "ep_desktop_notifications/desktop_notifications",
7
+ "clientVars": "ep_desktop_notifications/desktop_notifications",
8
+ "eejsBlock_mySettings": "ep_desktop_notifications/desktop_notifications",
9
+ "eejsBlock_padSettings": "ep_desktop_notifications/desktop_notifications",
10
+ "eejsBlock_styles": "ep_desktop_notifications/desktop_notifications"
11
+ },
5
12
  "client_hooks": {
6
13
  "postAceInit": "ep_desktop_notifications/static/js/desktop_notifications:postAceInit",
7
- "chatNewMessage": "ep_desktop_notifications/static/js/desktop_notifications:chatNewMessage"
8
- },
9
- "hooks": {
10
- "eejsBlock_mySettings": "ep_desktop_notifications/desktop_notifications"
14
+ "chatNewMessage": "ep_desktop_notifications/static/js/desktop_notifications:chatNewMessage",
15
+ "handleClientMessage_CLIENT_MESSAGE": "ep_desktop_notifications/static/js/desktop_notifications:handleClientMessage_CLIENT_MESSAGE"
11
16
  }
12
17
  }
13
18
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ep_desktop_notifications",
3
- "version": "11.0.23",
3
+ "version": "11.0.25",
4
4
  "keywords": [
5
5
  "desktop",
6
6
  "notifications",
@@ -34,5 +34,8 @@
34
34
  "scripts": {
35
35
  "lint": "eslint .",
36
36
  "lint:fix": "eslint --fix ."
37
+ },
38
+ "dependencies": {
39
+ "ep_plugin_helpers": "^0.5.2"
37
40
  }
38
41
  }
@@ -1,6 +1,25 @@
1
1
  'use strict';
2
2
  /* global webkitNotifications */
3
3
 
4
+ // Sub-path import keeps the client bundle clean — the top-level
5
+ // `ep_plugin_helpers` index pulls in server-only modules.
6
+ const {padToggle} = require('ep_plugin_helpers/pad-toggle');
7
+ const padcookie = require('ep_etherpad-lite/static/js/pad_cookie').padcookie;
8
+
9
+ // Same config as the server-side instance — must agree on pluginName,
10
+ // settingId, l10nId, and defaultLabel so checkbox ids and clientVars line up.
11
+ const desktopToggle = padToggle({
12
+ pluginName: 'ep_desktop_notifications',
13
+ settingId: 'desktopNotifications',
14
+ l10nId: 'ep_desktop_notifications.desktopNotifications',
15
+ defaultLabel: 'Desktop Notifications',
16
+ defaultEnabled: true,
17
+ });
18
+
19
+ // Re-export so the helper sees pad-wide broadcasts and refreshes our state
20
+ // when another user toggles the pad-wide checkbox.
21
+ exports.handleClientMessage_CLIENT_MESSAGE = desktopToggle.handleClientMessage_CLIENT_MESSAGE;
22
+
4
23
  const DesktopNotifications = {
5
24
  /* compatilibility layer */
6
25
  notificationSupported: () => !!window.Notification || !!window.webkitNotifications,
@@ -108,29 +127,24 @@ const postAceInit = (hook, context) => {
108
127
  DesktopNotifications.status = false;
109
128
  DesktopNotifications.helpShown = false;
110
129
 
111
- /* init */
112
- const $optionsDesktopNotifications = $('#options-desktopNotifications');
113
- const urlDesktopNotifications = DesktopNotifications.getParam('DesktopNotifications');
114
- if (urlDesktopNotifications === 'true') {
115
- $optionsDesktopNotifications.attr('checked', 'checked');
116
- } else if (urlDesktopNotifications === 'false') {
117
- $optionsDesktopNotifications.attr('checked', false);
118
- }
119
- if ($optionsDesktopNotifications.is(':checked')) {
120
- DesktopNotifications.handleNotificationPermission(
121
- DesktopNotifications.notificationPermission()
122
- );
123
- } else {
124
- DesktopNotifications.disable();
125
- }
130
+ // The README documents `?DesktopNotifications=true|false` as a way to
131
+ // override the toggle. Now that the helper persists per-user state in
132
+ // padcookie, write the URL value into the cookie before init reads it
133
+ // — that way the override survives reload, matching the original intent.
134
+ const urlOverride = DesktopNotifications.getParam('DesktopNotifications');
135
+ if (urlOverride === 'true') padcookie.setPref('desktopNotifications', true);
136
+ else if (urlOverride === 'false') padcookie.setPref('desktopNotifications', false);
126
137
 
127
- /* on click */
128
- $optionsDesktopNotifications.click(() => {
129
- if ($optionsDesktopNotifications.is(':checked')) {
130
- DesktopNotifications.enable();
131
- } else {
132
- DesktopNotifications.disable();
133
- }
138
+ desktopToggle.init({
139
+ onChange: (enabled) => {
140
+ if (enabled) {
141
+ DesktopNotifications.handleNotificationPermission(
142
+ DesktopNotifications.notificationPermission()
143
+ );
144
+ } else {
145
+ DesktopNotifications.disable();
146
+ }
147
+ },
134
148
  });
135
149
  };
136
150
 
@@ -1,4 +0,0 @@
1
- <p>
2
- <input type="checkbox" data-l10n-id="ep_desktop_notifications.desktopNotifications" id="options-desktopNotifications" <%= checked %>></input>
3
- <label for="options-desktopNotifications" data-l10n-id="ep_desktop_notifications.desktopNotifications">Desktop Notifications</label>
4
- </p>