feat: multi-material overlays, presentation guides, and release prebuilds
Align control/presentation with presentation screen rect and darkness z-order; sync window titles and session window cleanup. Pack Win/Mac/Linux with npmRebuild disabled and release-native-prep for classic-level and sharp. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,6 +9,11 @@ import { spawnSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { ensureReleaseNativeDeps } from './release-native-prep.mjs';
|
||||
|
||||
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
function run(command, args) {
|
||||
const result = spawnSync(command, args, {
|
||||
@@ -63,5 +68,6 @@ if (process.platform === 'win32') {
|
||||
}
|
||||
|
||||
run('npm', ['run', 'build']);
|
||||
ensureReleaseNativeDeps(projectRoot, 'linux');
|
||||
run('electron-builder', ['--linux']);
|
||||
normalizeLinuxReleaseNames();
|
||||
|
||||
@@ -2,43 +2,18 @@
|
||||
* Перед `electron-builder --mac`: npm ставит sharp только под CPU хоста.
|
||||
* В release идут x64 и arm64 — в .app должны быть оба набора @img/sharp-darwin-*.
|
||||
*/
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const MAC_SHARP_IMG_PACKAGES = [
|
||||
'@img/sharp-darwin-arm64',
|
||||
'@img/sharp-libvips-darwin-arm64',
|
||||
'@img/sharp-darwin-x64',
|
||||
'@img/sharp-libvips-darwin-x64',
|
||||
];
|
||||
import {
|
||||
ensureReleaseNativeDeps,
|
||||
MAC_SHARP_IMG_PACKAGES,
|
||||
sharpImgPackagesToInstall,
|
||||
} from './release-native-prep.mjs';
|
||||
|
||||
/**
|
||||
* @param {string} root
|
||||
* @returns {string[]} entries like `@img/sharp-darwin-x64@0.34.5` missing under node_modules
|
||||
*/
|
||||
/** @deprecated use sharpImgPackagesToInstall(root, MAC_SHARP_IMG_PACKAGES) */
|
||||
export function macSharpImgPackagesToInstall(root) {
|
||||
const sharpPkgPath = path.join(root, 'node_modules', 'sharp', 'package.json');
|
||||
if (!fs.existsSync(sharpPkgPath)) {
|
||||
throw new Error('[release-mac-prep] sharp is not installed — run npm ci first');
|
||||
}
|
||||
|
||||
const sharpPkg = JSON.parse(fs.readFileSync(sharpPkgPath, 'utf8'));
|
||||
const versions = sharpPkg.optionalDependencies ?? {};
|
||||
const missing = [];
|
||||
|
||||
for (const name of MAC_SHARP_IMG_PACKAGES) {
|
||||
const version = versions[name];
|
||||
if (!version) {
|
||||
throw new Error(`[release-mac-prep] sharp optionalDependency missing: ${name}`);
|
||||
}
|
||||
if (!fs.existsSync(path.join(root, 'node_modules', name))) {
|
||||
missing.push(`${name}@${version}`);
|
||||
}
|
||||
}
|
||||
|
||||
return missing;
|
||||
return sharpImgPackagesToInstall(root, MAC_SHARP_IMG_PACKAGES);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,21 +21,7 @@ export function macSharpImgPackagesToInstall(root) {
|
||||
* @param {{ runInstall?: boolean }} [opts]
|
||||
*/
|
||||
export function ensureMacSharpBinaries(root, opts = {}) {
|
||||
const { runInstall = true } = opts;
|
||||
const toInstall = macSharpImgPackagesToInstall(root);
|
||||
|
||||
if (toInstall.length === 0) {
|
||||
console.log('[release-mac-prep] all macOS sharp binaries present');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[release-mac-prep] installing', toInstall.join(', '));
|
||||
if (!runInstall) return;
|
||||
|
||||
execFileSync('npm', ['install', '--no-save', '--force', ...toInstall], {
|
||||
cwd: root,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
ensureReleaseNativeDeps(root, 'mac', opts);
|
||||
}
|
||||
|
||||
const isMain = process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
||||
|
||||
@@ -3,15 +3,33 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { macSharpImgPackagesToInstall } from './release-mac-prep.mjs';
|
||||
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
void test('macSharpImgPackagesToInstall: empty when all four @img darwin packages exist', () => {
|
||||
const missing = macSharpImgPackagesToInstall(root);
|
||||
assert.deepEqual(missing, []);
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'mac-sharp-all-'));
|
||||
try {
|
||||
const sharpOpt = {
|
||||
'@img/sharp-darwin-arm64': '0.34.5',
|
||||
'@img/sharp-libvips-darwin-arm64': '1.2.4',
|
||||
'@img/sharp-darwin-x64': '0.34.5',
|
||||
'@img/sharp-libvips-darwin-x64': '1.2.4',
|
||||
};
|
||||
fs.mkdirSync(path.join(tmp, 'node_modules', 'sharp'), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(tmp, 'node_modules', 'sharp', 'package.json'),
|
||||
JSON.stringify({ optionalDependencies: sharpOpt }),
|
||||
);
|
||||
for (const name of Object.keys(sharpOpt)) {
|
||||
const dir = path.join(tmp, 'node_modules', name);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(path.join(dir, 'package.json'), '{}');
|
||||
}
|
||||
const missing = macSharpImgPackagesToInstall(tmp);
|
||||
assert.deepEqual(missing, []);
|
||||
} finally {
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
void test('macSharpImgPackagesToInstall: lists missing darwin-x64 on arm64-only tree', () => {
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* Релиз без @electron/rebuild: classic-level (N-API prebuilds) и sharp (@img бинарники).
|
||||
* См. package.json → build.npmRebuild = false.
|
||||
*/
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
/** @typedef {'win' | 'mac' | 'linux'} ReleaseNativeProfile */
|
||||
|
||||
/** Папки prebuilds/classic-level из npm-пакета classic-level. */
|
||||
export const CLASSIC_LEVEL_PREBUILD_KEYS = {
|
||||
win: ['win32-x64'],
|
||||
mac: ['darwin-x64+arm64'],
|
||||
linux: ['linux-x64', 'linux-arm64'],
|
||||
};
|
||||
|
||||
export const MAC_SHARP_IMG_PACKAGES = [
|
||||
'@img/sharp-darwin-arm64',
|
||||
'@img/sharp-libvips-darwin-arm64',
|
||||
'@img/sharp-darwin-x64',
|
||||
'@img/sharp-libvips-darwin-x64',
|
||||
];
|
||||
|
||||
/** AppImage x64/arm64 — glibc, не musl. */
|
||||
export const LINUX_SHARP_IMG_PACKAGES = [
|
||||
'@img/sharp-linux-x64',
|
||||
'@img/sharp-libvips-linux-x64',
|
||||
'@img/sharp-linux-arm64',
|
||||
'@img/sharp-libvips-linux-arm64',
|
||||
];
|
||||
|
||||
export const WIN_SHARP_IMG_PACKAGES = ['@img/sharp-win32-x64'];
|
||||
|
||||
/**
|
||||
* @param {string} root
|
||||
* @param {string[]} packageNames
|
||||
* @returns {string[]} entries like `@img/sharp-darwin-x64@0.34.5`
|
||||
*/
|
||||
export function sharpImgPackagesToInstall(root, packageNames) {
|
||||
const sharpPkgPath = path.join(root, 'node_modules', 'sharp', 'package.json');
|
||||
if (!fs.existsSync(sharpPkgPath)) {
|
||||
throw new Error('[release-native-prep] sharp is not installed — run npm ci first');
|
||||
}
|
||||
|
||||
const sharpPkg = JSON.parse(fs.readFileSync(sharpPkgPath, 'utf8'));
|
||||
const versions = sharpPkg.optionalDependencies ?? {};
|
||||
const missing = [];
|
||||
|
||||
for (const name of packageNames) {
|
||||
const version = versions[name];
|
||||
if (!version) {
|
||||
throw new Error(`[release-native-prep] sharp optionalDependency missing: ${name}`);
|
||||
}
|
||||
if (!fs.existsSync(path.join(root, 'node_modules', name))) {
|
||||
missing.push(`${name}@${version}`);
|
||||
}
|
||||
}
|
||||
|
||||
return missing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} root
|
||||
* @param {string} prebuildKey
|
||||
*/
|
||||
export function assertClassicLevelPrebuild(root, prebuildKey) {
|
||||
const dir = path.join(root, 'node_modules', 'classic-level', 'prebuilds', prebuildKey);
|
||||
if (!fs.existsSync(dir)) {
|
||||
throw new Error(
|
||||
`[release-native-prep] classic-level prebuild missing: ${prebuildKey} (run npm ci)`,
|
||||
);
|
||||
}
|
||||
const hasNode = fs.readdirSync(dir).some((f) => f.endsWith('.node'));
|
||||
if (!hasNode) {
|
||||
throw new Error(
|
||||
`[release-native-prep] classic-level prebuild dir empty: ${prebuildKey}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} root
|
||||
* @param {ReleaseNativeProfile} profile
|
||||
* @param {{ runInstall?: boolean }} [opts]
|
||||
*/
|
||||
export function ensureReleaseNativeDeps(root, profile, opts = {}) {
|
||||
const { runInstall = true } = opts;
|
||||
const classicKeys = CLASSIC_LEVEL_PREBUILD_KEYS[profile];
|
||||
for (const key of classicKeys) {
|
||||
assertClassicLevelPrebuild(root, key);
|
||||
}
|
||||
|
||||
let sharpPackages;
|
||||
if (profile === 'mac') sharpPackages = MAC_SHARP_IMG_PACKAGES;
|
||||
else if (profile === 'linux') sharpPackages = LINUX_SHARP_IMG_PACKAGES;
|
||||
else sharpPackages = WIN_SHARP_IMG_PACKAGES;
|
||||
|
||||
const toInstall = sharpImgPackagesToInstall(root, sharpPackages);
|
||||
if (toInstall.length === 0) {
|
||||
console.log(`[release-native-prep] ${profile}: native prebuilds OK`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[release-native-prep] ${profile}: installing`, toInstall.join(', '));
|
||||
if (!runInstall) return;
|
||||
|
||||
execFileSync('npm', ['install', '--no-save', '--force', ...toInstall], {
|
||||
cwd: root,
|
||||
stdio: 'inherit',
|
||||
shell: process.platform === 'win32',
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import {
|
||||
assertClassicLevelPrebuild,
|
||||
CLASSIC_LEVEL_PREBUILD_KEYS,
|
||||
ensureReleaseNativeDeps,
|
||||
sharpImgPackagesToInstall,
|
||||
WIN_SHARP_IMG_PACKAGES,
|
||||
} from './release-native-prep.mjs';
|
||||
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
void test('CLASSIC_LEVEL_PREBUILD_KEYS covers win/mac/linux', () => {
|
||||
assert.deepEqual(CLASSIC_LEVEL_PREBUILD_KEYS.win, ['win32-x64']);
|
||||
assert.ok(CLASSIC_LEVEL_PREBUILD_KEYS.mac.includes('darwin-x64+arm64'));
|
||||
assert.ok(CLASSIC_LEVEL_PREBUILD_KEYS.linux.includes('linux-x64'));
|
||||
assert.ok(CLASSIC_LEVEL_PREBUILD_KEYS.linux.includes('linux-arm64'));
|
||||
});
|
||||
|
||||
void test('assertClassicLevelPrebuild: win32-x64 present after npm ci', () => {
|
||||
assertClassicLevelPrebuild(root, 'win32-x64');
|
||||
});
|
||||
|
||||
void test('ensureReleaseNativeDeps(win): does not throw when prebuilds present', () => {
|
||||
ensureReleaseNativeDeps(root, 'win', { runInstall: false });
|
||||
});
|
||||
|
||||
void test('sharpImgPackagesToInstall: lists missing win32-x64 when absent', () => {
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'native-prep-'));
|
||||
try {
|
||||
const sharpOpt = {
|
||||
'@img/sharp-win32-x64': '0.34.5',
|
||||
};
|
||||
fs.mkdirSync(path.join(tmp, 'node_modules', 'sharp'), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(tmp, 'node_modules', 'sharp', 'package.json'),
|
||||
JSON.stringify({ optionalDependencies: sharpOpt }),
|
||||
);
|
||||
const missing = sharpImgPackagesToInstall(tmp, WIN_SHARP_IMG_PACKAGES);
|
||||
assert.deepEqual(missing, ['@img/sharp-win32-x64@0.34.5']);
|
||||
} finally {
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
@@ -7,6 +7,8 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { ensureReleaseNativeDeps } from './release-native-prep.mjs';
|
||||
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const winUnpacked = path.join(root, 'release', 'win-unpacked');
|
||||
|
||||
@@ -43,3 +45,4 @@ async function tryRmWinUnpacked() {
|
||||
|
||||
tryKillDndPlayer();
|
||||
await tryRmWinUnpacked();
|
||||
ensureReleaseNativeDeps(root, 'win');
|
||||
|
||||
Reference in New Issue
Block a user