@next2d/builder 0.4.2 → 0.4.4

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.
@@ -47,12 +47,13 @@ export declare const createElectronPackagerOptions: (root: string, config: IElec
47
47
  entitlements: string;
48
48
  };
49
49
  } | undefined;
50
- extendInfo?: {
51
- NSLocalNetworkUsageDescription: string;
52
- } | undefined;
53
50
  extendHelperInfo?: {
54
51
  NSLocalNetworkUsageDescription: string;
55
52
  } | undefined;
53
+ extendInfo?: {
54
+ LSUIElement?: boolean | undefined;
55
+ NSLocalNetworkUsageDescription?: string | undefined;
56
+ } | undefined;
56
57
  icon?: string | undefined;
57
58
  name: string;
58
59
  executableName: string;
@@ -129,9 +129,16 @@ export const createElectronPackagerOptions = (root, config, os, resources) => {
129
129
  "extraResource": [resources, ...config.nativeBridge ? [path.join(path.dirname(resources), "native")] : []],
130
130
  "ignore": [/^\/native(?:\/|$)/, /^\/resources(?:\/|$)/, /^\/icons(?:\/|$)/, /^\/forge\.config\.[cm]?js$/, /^\/entitlements\.plist$/, /(?:^|\/)steam_appid\.txt$/],
131
131
  ...os !== "linux" && config.icons[os] ? { "icon": path.resolve(root, config.icons[os]) } : {},
132
- ...os === "macos" && config.macos.localNetworkUsageDescription ? {
133
- "extendInfo": { "NSLocalNetworkUsageDescription": config.macos.localNetworkUsageDescription },
134
- "extendHelperInfo": { "NSLocalNetworkUsageDescription": config.macos.localNetworkUsageDescription }
132
+ ...os === "macos" && (config.macos.localNetworkUsageDescription || config.window.overlay?.enabled) ? {
133
+ "extendInfo": {
134
+ ...config.macos.localNetworkUsageDescription ? { "NSLocalNetworkUsageDescription": config.macos.localNetworkUsageDescription } : {},
135
+ // An overlay starts as an agent app (no Dock icon) so that a second launch, which quits at once,
136
+ // never shows one. The first instance shows its Dock icon itself (templates/electron/index.js).
137
+ ...config.window.overlay?.enabled ? { "LSUIElement": true } : {}
138
+ },
139
+ ...config.macos.localNetworkUsageDescription ? {
140
+ "extendHelperInfo": { "NSLocalNetworkUsageDescription": config.macos.localNetworkUsageDescription }
141
+ } : {}
135
142
  } : {},
136
143
  ...os === "macos" && sign ? {
137
144
  "osxSign": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next2d/builder",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Multi-platform builder for Next2d Framework, supporting export to various platforms such as macOS, Windows, iOS, Android and Web(HTML)",
5
5
  "author": "Toshiyuki Ienaga <ienaga@next2d.app>",
6
6
  "license": "MIT",
@@ -51,6 +51,21 @@ const overlayBounds = () => {
51
51
  const placeOverlay = () => {
52
52
  if (mainWindow && !mainWindow.isDestroyed()) mainWindow.setBounds(overlayBounds());
53
53
  };
54
+ // The overlay never takes focus, so Windows does not raise it when another topmost window (the taskbar, another
55
+ // always-on-top app) is activated, nor after the display is turned off and on. Put it back on top.
56
+ const keepOnTop = () => {
57
+ if (!mainWindow || mainWindow.isDestroyed()) return;
58
+ mainWindow.setAlwaysOnTop(true, "floating");
59
+ mainWindow.moveTop();
60
+ };
61
+ // Windows forwards mouse moves to a click-through window with a system mouse hook, and Electron installs it only
62
+ // when forwarding switches on. After sleep (closing the lid) the hook can be gone while Electron still thinks it is
63
+ // installed, so the page never sees the pointer. Switching forwarding off and on again installs a fresh hook.
64
+ const refreshForwarding = () => {
65
+ if (!overlayIgnore || !mainWindow || mainWindow.isDestroyed()) return;
66
+ mainWindow.setIgnoreMouseEvents(false);
67
+ mainWindow.setIgnoreMouseEvents(true, { forward: true });
68
+ };
54
69
  const createWindow = async () => {
55
70
  const { width, height } = screen.getPrimaryDisplay().workAreaSize;
56
71
  // The preload reads these flags; each API is exposed only when its feature is configured.
@@ -89,10 +104,16 @@ const createWindow = async () => {
89
104
  mainWindow.setIgnoreMouseEvents(true, { forward: true });
90
105
  }
91
106
  const events = ["display-metrics-changed", "display-added", "display-removed"];
92
- for (const name of events) screen.on(name, placeOverlay);
107
+ const onDisplayChange = () => { placeOverlay(); keepOnTop(); };
108
+ for (const name of events) screen.on(name, onDisplayChange);
93
109
  mainWindow.once("closed", () => {
94
- for (const name of events) screen.removeListener(name, placeOverlay);
110
+ for (const name of events) screen.removeListener(name, onDisplayChange);
95
111
  });
112
+ if (process.platform === "win32") {
113
+ const timer = setInterval(() => { keepOnTop(); refreshForwarding(); }, 3000);
114
+ timer.unref?.();
115
+ mainWindow.once("closed", () => clearInterval(timer));
116
+ }
96
117
  }
97
118
  mainWindow.webContents.setWindowOpenHandler(() => ({ action: "deny" }));
98
119
  mainWindow.webContents.on("will-navigate", (event, url) => {
@@ -123,6 +144,9 @@ const createWindow = async () => {
123
144
 
124
145
  app.whenReady().then(async () => {
125
146
  if (!hasLock) return;
147
+ // The overlay app is packaged as an agent app (LSUIElement) so a second launch never shows a Dock icon;
148
+ // the instance that keeps running shows it.
149
+ if (process.platform === "darwin" && overlay) app.dock?.show();
126
150
  Menu.setApplicationMenu(process.platform === "darwin" ? Menu.buildFromTemplate([
127
151
  { role: "appMenu" }, { role: "editMenu" }, { role: "windowMenu" }
128
152
  ]) : null);
@@ -180,7 +204,7 @@ app.whenReady().then(async () => {
180
204
  // z-order/bounds. Apply the overlay state again and tell the page so it can recover too.
181
205
  const recoverOverlay = () => {
182
206
  if (!mainWindow || mainWindow.isDestroyed()) return;
183
- mainWindow.setAlwaysOnTop(true, "floating");
207
+ keepOnTop();
184
208
  placeOverlay();
185
209
  mainWindow.setIgnoreMouseEvents(false);
186
210
  mainWindow.setIgnoreMouseEvents(overlayIgnore, overlayIgnore ? { forward: true } : undefined);