update electron to v43

This commit is contained in:
olcxja 2026-07-09 22:38:33 +02:00
commit fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions

View file

@ -511,6 +511,15 @@ export interface CapacitorConfig {
packageTraits?: {
[pluginId: string]: string[];
};
/**
* Define options to apply to the package.
* The key is the plugin ID (e.g. `@capacitor-community/device`)
*
* @since 8.4.0
*/
packageOptions?: {
[pluginId: string]: PackageOptions;
};
};
};
};
@ -546,7 +555,7 @@ export interface CapacitorConfig {
* Configure the local scheme on Android.
*
* Custom schemes on Android are unable to change the URL path as of Webview 117. Changing this value from anything other than `http` or `https` can result in your
* application unable to resolve routing. If you must change this for some reason, consider using a hash-based url strategy, but there are no guarentees that this
* application unable to resolve routing. If you must change this for some reason, consider using a hash-based url strategy, but there are no guarantees that this
* will continue to work long term as allowing non-standard schemes to modify query parameters and url fragments is only allowed for compatibility reasons.
* https://ionic.io/blog/capacitor-android-customscheme-issue-with-chrome-117
*
@ -732,3 +741,17 @@ export interface PluginsConfig {
animation?: 'FADE' | 'NONE';
};
}
export interface PackageOptions {
/**
* Create a symlink to the plugin folder instead of pointing to the plugin path.
* Useful when plugin names conflict.
*/
symlink?: boolean;
/**
* Useful to avoid target name conflicts in dependencies
* [see](https://docs.swift.org/swiftpm/documentation/packagemanagerdocs/modulealiasing/)
*/
moduleAliases?: {
[target: string]: string;
};
}

View file

@ -4,6 +4,7 @@ exports.installCocoaPodsPlugins = exports.updateIOS = void 0;
const tslib_1 = require("tslib");
const fs_extra_1 = require("fs-extra");
const path_1 = require("path");
const semver_1 = require("semver");
const colors_1 = tslib_1.__importDefault(require("../colors"));
const common_1 = require("../common");
const cordova_1 = require("../cordova");
@ -11,6 +12,7 @@ const errors_1 = require("../errors");
const log_1 = require("../log");
const plugin_1 = require("../plugin");
const copy_1 = require("../tasks/copy");
const migrate_1 = require("../tasks/migrate");
const fs_1 = require("../util/fs");
const iosplugin_1 = require("../util/iosplugin");
const node_1 = require("../util/node");
@ -43,6 +45,22 @@ async function updatePluginFiles(config, plugins, deployment) {
if ((await config.ios.packageManager) === 'SPM') {
await generateCordovaPackageFiles(cordovaPlugins, config);
const validSPMPackages = await (0, spm_1.checkPluginsForPackageSwift)(config, plugins);
await Promise.all(validSPMPackages.map(async (plugin) => {
var _a;
const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
const packageSwiftPath = (0, path_1.join)(plugin.rootPath, 'Package.swift');
let content = await (0, fs_extra_1.readFile)(packageSwiftPath, { encoding: 'utf-8' });
const regex = new RegExp('url:\\s*"https://github.com/ionic-team/capacitor-swift-pm\\.git",\\s*from:\\s*"([^"]+)"');
const version = (_a = content.match(regex)) === null || _a === void 0 ? void 0 : _a[1];
const majorCapVersion = (0, semver_1.major)(iosPlatformVersion);
if (version && (0, semver_1.major)(version) != majorCapVersion) {
const preCapVersion = (0, semver_1.prerelease)(iosPlatformVersion);
const forceVersion = preCapVersion ? iosPlatformVersion : `${majorCapVersion}.0.0`;
content = (0, migrate_1.setAllStringIn)(content, `url: "https://github.com/ionic-team/capacitor-swift-pm.git",`, `)`, ` from: "${forceVersion}"`);
await (0, fs_extra_1.writeFile)(packageSwiftPath, content);
log_1.logger.warn(`${plugin.id} is built for Capacitor ${(0, semver_1.major)(version)}, it might cause issues`);
}
}));
await (0, spm_1.generatePackageFile)(config, validSPMPackages.concat(cordovaPlugins));
}
else {
@ -59,14 +77,159 @@ async function generateCordovaPackageFiles(cordovaPlugins, config) {
});
}
async function generateCordovaPackageFile(p, config) {
var _a;
const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
const platformTag = (0, plugin_1.getPluginPlatform)(p, platform);
if ((_a = platformTag.$) === null || _a === void 0 ? void 0 : _a.package) {
const packageSwiftPath = (0, path_1.join)(p.rootPath, 'Package.swift');
let content = await (0, fs_extra_1.readFile)(packageSwiftPath, { encoding: 'utf-8' });
content = content.replace(`apache`, `ionic-team`).replaceAll(`cordova-ios`, `capacitor-swift-pm`);
content = (0, migrate_1.setAllStringIn)(content, `url: "https://github.com/ionic-team/capacitor-swift-pm.git",`, `)`, ` from: "${iosPlatformVersion}"`);
await (0, fs_extra_1.writeFile)(packageSwiftPath, content);
}
else {
await writeGeneratedPackageSwift(p, config, iosPlatformVersion);
}
}
function buildBinaryTargetEntries(p, frameworks) {
const customXcframeworks = frameworks.filter((f) => f.$.custom === 'true' && f.$.src.endsWith('.xcframework'));
const customFrameworks = frameworks.filter((f) => f.$.custom === 'true' && f.$.src.endsWith('.framework'));
if (customFrameworks.length > 0) {
customFrameworks.forEach((f) => {
log_1.logger.warn(`${p.id}: custom .framework files are not supported as binaryTarget in SPM (${f.$.src}). Convert to .xcframework for SPM compatibility.`);
});
}
const binaryTargetsText = customXcframeworks
.map((f) => {
const name = f.$.src.split('/').pop().replace('.xcframework', '');
return `,
.binaryTarget(
name: "${name}",
path: "${f.$.src}"
)`;
})
.join('');
const binaryDepsText = customXcframeworks
.map((f) => {
const name = f.$.src.split('/').pop().replace('.xcframework', '');
return `,\n .target(name: "${name}")`;
})
.join('');
return { binaryTargetsText, binaryDepsText };
}
function buildResourcesText(resources) {
const resourceEntry = [];
for (const resource of resources) {
resourceEntry.push(`.copy("resources/${resource.$.src.split('/').pop()}")`);
}
return resources.length > 0
? `,
resources: [
${resourceEntry.join(',\n ')}
]`
: '';
}
async function buildDependencyTexts(p, config) {
let allDependencies = (0, plugin_1.getPlatformElement)(p, platform, 'dependency');
if (p.xml['dependency']) {
allDependencies = allDependencies.concat(p.xml['dependency']);
}
let packageText = '';
let productText = '';
await Promise.all(allDependencies.map(async (dep) => {
let plugin = dep.$.id;
if (plugin.includes('@') && plugin.indexOf('@') !== 0) {
[plugin] = plugin.split('@');
}
const depPlugin = await (0, plugin_1.resolvePlugin)(config, plugin);
if (depPlugin) {
const headerFiles = (0, plugin_1.getPlatformElement)(depPlugin, platform, 'header-file');
const resources = (0, plugin_1.getPlatformElement)(depPlugin, platform, 'resource-file');
const sourceFiles = (0, plugin_1.getPlatformElement)(depPlugin, platform, 'source-file');
if (sourceFiles.length === 0 && headerFiles.length === 0 && resources.length === 0) {
return;
}
packageText += `,\n .package(name: "${depPlugin.name}", path: "../${depPlugin.name}")`;
productText += `,\n .product(name: "${depPlugin.name}", package: "${depPlugin.name}")`;
}
}));
return { packageText, productText };
}
function buildCSettingsText(p, sourceFiles) {
var _a;
const pluginId = p.id;
const allFlags = new Set();
for (const sourceFile of sourceFiles) {
const flags = (_a = sourceFile.$) === null || _a === void 0 ? void 0 : _a['compiler-flags'];
if (flags) {
flags
.split(/\s+/)
.map((f) => f.trim())
.filter((f) => f.length > 0)
.forEach((f) => allFlags.add(f));
}
}
if (allFlags.size === 0) {
return '';
}
const entries = [];
const unsupportedFlags = [];
for (const flag of allFlags) {
if (flag.startsWith('-D')) {
const definition = flag.slice(2);
const eqIndex = definition.indexOf('=');
if (eqIndex !== -1) {
const name = definition.slice(0, eqIndex);
const value = definition.slice(eqIndex + 1);
entries.push(` .define("${name}", to: "${value}")`);
}
else {
entries.push(` .define("${definition}")`);
}
}
else {
unsupportedFlags.push(flag);
}
}
if (unsupportedFlags.length > 0) {
log_1.logger.warn(`${pluginId}: the following compiler flags are not supported in SPM and were ignored: ${unsupportedFlags.join(', ')}. ` +
`This might cause the plugin to fail to compile.`);
}
if (entries.length === 0) {
return '';
}
return `,
cSettings: [
${entries.join(',\n')}
]`;
}
async function writeGeneratedPackageSwift(p, config, iosPlatformVersion) {
const iosVersion = (0, common_2.getMajoriOSVersion)(config);
const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
let headersText = '';
if (headerFiles.length > 0) {
headersText = `,
publicHeadersPath: "."`;
const headersText = headerFiles.length > 0
? `,
publicHeadersPath: "."`
: '';
const resources = (0, plugin_1.getPlatformElement)(p, platform, 'resource-file');
const sourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'source-file');
if (sourceFiles.length === 0 && headerFiles.length === 0 && resources.length === 0) {
return;
}
const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
const { binaryTargetsText, binaryDepsText } = buildBinaryTargetEntries(p, frameworks);
const cSettingsText = buildCSettingsText(p, sourceFiles);
const systemFrameworks = frameworks.filter((f) => !f.$.custom && f.$.src.endsWith('.framework'));
const hasWeakFrameworks = systemFrameworks.some((f) => f.$.weak === 'true');
const requiredSystemFrameworks = systemFrameworks.filter((f) => f.$.weak !== 'true');
const resourcesText = buildResourcesText(resources);
const libraryTypeText = hasWeakFrameworks ? `\n type: .dynamic,` : '';
const linkerSettingsText = requiredSystemFrameworks.length > 0
? `,
linkerSettings: [
${requiredSystemFrameworks.map((f) => ` .linkedFramework("${f.$.src.replace('.framework', '')}")`).join(',\n')}
]`
: '';
const { packageText, productText } = await buildDependencyTexts(p, config);
const content = `// swift-tools-version: 5.9
import PackageDescription
@ -76,21 +239,21 @@ let package = Package(
platforms: [.iOS(.v${iosVersion})],
products: [
.library(
name: "${p.name}",
name: "${p.name}",${libraryTypeText}
targets: ["${p.name}"]
)
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "${iosPlatformVersion}")
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "${iosPlatformVersion}")${packageText}
],
targets: [
.target(
name: "${p.name}",
dependencies: [
.product(name: "Cordova", package: "capacitor-swift-pm")
.product(name: "Cordova", package: "capacitor-swift-pm")${binaryDepsText}${productText}
],
path: "."${headersText}
)
path: "."${resourcesText}${headersText}${cSettingsText}${linkerSettingsText}
)${binaryTargetsText}
]
)`;
await (0, fs_extra_1.writeFile)((0, path_1.join)(config.ios.cordovaPluginsDirAbs, 'sources', p.name, 'Package.swift'), content);
@ -354,13 +517,19 @@ function getLinkerFlags(config) {
return '';
}
async function copyPluginsNativeFiles(config, cordovaPlugins) {
var _a;
const isSPM = (await config.ios.packageManager) === 'SPM';
for (const p of cordovaPlugins) {
const platformTag = (0, plugin_1.getPluginPlatform)(p, platform);
if (isSPM && ((_a = platformTag.$) === null || _a === void 0 ? void 0 : _a.package)) {
continue;
}
const sourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'source-file');
const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
const codeFiles = sourceFiles.concat(headerFiles);
const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
let sourcesFolderName = 'sources';
if ((0, cordova_1.needsStaticPod)(p)) {
if (!isSPM && (0, cordova_1.needsStaticPod)(p)) {
sourcesFolderName += 'static';
}
const sourcesFolder = (0, path_1.join)(config.ios.cordovaPluginsDirAbs, sourcesFolderName, p.name);
@ -371,7 +540,7 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
fileName = 'lib' + fileName;
}
let destFolder = sourcesFolderName;
if (codeFile.$['compiler-flags'] && codeFile.$['compiler-flags'] === '-fno-objc-arc') {
if (!isSPM && codeFile.$['compiler-flags'] && codeFile.$['compiler-flags'] === '-fno-objc-arc') {
destFolder = 'noarc';
}
const filePath = (0, plugin_1.getFilePath)(config, p, codeFile.$.src);
@ -390,8 +559,13 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
}
if (fileContent.includes('[NSBundle bundleForClass:[self class]]') ||
fileContent.includes('[NSBundle bundleForClass:[CDVCapture class]]')) {
fileContent = fileContent.replace('[NSBundle bundleForClass:[self class]]', '[NSBundle mainBundle]');
fileContent = fileContent.replace('[NSBundle bundleForClass:[CDVCapture class]]', '[NSBundle mainBundle]');
const bundleName = isSPM ? 'SWIFTPM_MODULE_BUNDLE' : '[NSBundle mainBundle]';
fileContent = fileContent.replace('[NSBundle bundleForClass:[self class]]', bundleName);
fileContent = fileContent.replace('[NSBundle bundleForClass:[CDVCapture class]]', bundleName);
await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
}
if (isSPM && fileContent.includes('[NSBundle mainBundle] URLForResource')) {
fileContent = fileContent.replace('[NSBundle mainBundle] URLForResource', 'SWIFTPM_MODULE_BUNDLE URLForResource');
await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
}
if (fileContent.includes('[self.webView superview]') || fileContent.includes('self.webView.superview')) {
@ -405,7 +579,8 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
const resourceFiles = (0, plugin_1.getPlatformElement)(p, platform, 'resource-file');
for (const resourceFile of resourceFiles) {
const fileName = resourceFile.$.src.split('/').pop();
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(config.ios.cordovaPluginsDirAbs, 'resources', fileName));
const rootResFolder = isSPM ? sourcesFolder : config.ios.cordovaPluginsDirAbs;
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(rootResFolder, 'resources', fileName));
}
for (const framework of frameworks) {
if (framework.$.custom && framework.$.custom === 'true') {
@ -416,6 +591,9 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
}
async function removePluginsNativeFiles(config) {
await (0, fs_extra_1.remove)(config.ios.cordovaPluginsDirAbs);
if ((await config.ios.packageManager) === 'SPM') {
await (0, fs_extra_1.remove)((0, path_1.join)(config.ios.nativeProjectDirAbs, 'CapApp-SPM', 'symlinks'));
}
await (0, template_1.extractTemplate)(config.cli.assets.ios.cordovaPluginsTemplateArchiveAbs, config.ios.cordovaPluginsDirAbs);
}
function filterResources(plugin) {

View file

@ -36,16 +36,16 @@ async function receive(msg) {
const { data } = msg;
// This request is only made if telemetry is on.
const req = (0, https_1.request)({
hostname: 'api.ionicjs.com',
hostname: 'metrics-capacitor.outsystems.com',
port: 443,
path: '/events/metrics',
path: '/metrics',
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
}, (response) => {
debug('Sent %O metric to events service (status: %O)', data.name, response.statusCode);
if (response.statusCode !== 204) {
if (response.statusCode !== 202) {
response.on('data', (chunk) => {
debug('Bad response from events service. Request body: %O', chunk.toString());
});

View file

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.migrateCommand = void 0;
exports.setAllStringIn = exports.migrateCommand = void 0;
const tslib_1 = require("tslib");
const fs_extra_1 = require("fs-extra");
const path_1 = require("path");
@ -497,6 +497,7 @@ function setAllStringIn(data, start, end, replacement) {
}
return result;
}
exports.setAllStringIn = setAllStringIn;
async function updateAndroidManifest(filename) {
const txt = readFile(filename);
if (!txt) {

View file

@ -85,6 +85,9 @@ async function runCommand(config, selectedPlatformName, options) {
}
}
catch (e) {
if (options.liveReload) {
await livereload_1.CapLiveReloadHelper.revertCapConfigForLiveReload();
}
if (!(0, errors_1.isFatal)(e)) {
(0, errors_1.fatal)((_c = e.stack) !== null && _c !== void 0 ? _c : e);
}

View file

@ -1,9 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendMetric = exports.telemetryAction = void 0;
exports.getIOSPackageManager = exports.sendMetric = exports.telemetryAction = void 0;
const tslib_1 = require("tslib");
const commander_1 = require("commander");
const debug_1 = tslib_1.__importDefault(require("debug"));
const fs_extra_1 = require("fs-extra");
const colors_1 = tslib_1.__importDefault(require("./colors"));
const ipc_1 = require("./ipc");
const log_1 = require("./log");
@ -51,8 +52,10 @@ function telemetryAction(config, action) {
error: error ? (error.message ? error.message : String(error)) : null,
node_version: process.version,
os: config.cli.os,
ios_package_manager: await getIOSPackageManager(config),
...Object.fromEntries(versions),
};
debug('metric payload: %O', data);
if ((0, term_1.isInteractive)()) {
let sysconfig = await (0, sysconfig_1.readConfig)();
if (!error && typeof sysconfig.telemetry === 'undefined') {
@ -88,6 +91,24 @@ async function sendMetric(sysconfig, name, data) {
}
}
exports.sendMetric = sendMetric;
/**
* Resolve the iOS dependency manager for telemetry. Returns 'unknown' for
* non-iOS projects or when detection throws, so callers never have to handle
* errors from this signal.
*/
async function getIOSPackageManager(config) {
try {
if (!(await (0, fs_extra_1.pathExists)(config.ios.platformDirAbs))) {
return 'unknown';
}
return await config.ios.packageManager;
}
catch (e) {
debug('Could not resolve iOS package manager for telemetry: %O', e);
return 'unknown';
}
}
exports.getIOSPackageManager = getIOSPackageManager;
/**
* Get a unique anonymous identifier for this app.
*/

View file

@ -45,12 +45,12 @@ exports.generatePackageFile = generatePackageFile;
async function checkPluginsForPackageSwift(config, plugins) {
const iOSCapacitorPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, 'ios') === 0 /* PluginType.Core */);
const packageSwiftPluginList = await pluginsWithPackageSwift(iOSCapacitorPlugins);
if (plugins.length == packageSwiftPluginList.length) {
log_1.logger.debug(`Found ${plugins.length} iOS plugins, ${packageSwiftPluginList.length} have a Package.swift file`);
log_1.logger.info('All plugins have a Package.swift file and will be included in Package.swift');
if (iOSCapacitorPlugins.length == packageSwiftPluginList.length) {
log_1.logger.debug(`Found ${iOSCapacitorPlugins.length} Capacitor iOS plugins, ${packageSwiftPluginList.length} have a Package.swift file`);
log_1.logger.info('All Capacitor plugins have a Package.swift file and will be included in Package.swift');
}
else {
log_1.logger.warn('Some installed packages are not compatable with SPM');
log_1.logger.warn('Some installed Capacitor plugins are not compatible with SPM');
}
return packageSwiftPluginList;
}
@ -84,11 +84,12 @@ async function removeCocoapodsFiles(config) {
}
exports.removeCocoapodsFiles = removeCocoapodsFiles;
async function generatePackageText(config, plugins) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
const iosVersion = (0, common_2.getMajoriOSVersion)(config);
const packageTraits = (_d = (_c = (_b = (_a = config.app.extConfig.experimental) === null || _a === void 0 ? void 0 : _a.ios) === null || _b === void 0 ? void 0 : _b.spm) === null || _c === void 0 ? void 0 : _c.packageTraits) !== null && _d !== void 0 ? _d : {};
const swiftToolsVersion = (_h = (_g = (_f = (_e = config.app.extConfig.experimental) === null || _e === void 0 ? void 0 : _e.ios) === null || _f === void 0 ? void 0 : _f.spm) === null || _g === void 0 ? void 0 : _g.swiftToolsVersion) !== null && _h !== void 0 ? _h : '5.9';
const packageOptions = (_h = (_g = (_f = (_e = config.app.extConfig.experimental) === null || _e === void 0 ? void 0 : _e.ios) === null || _f === void 0 ? void 0 : _f.spm) === null || _g === void 0 ? void 0 : _g.packageOptions) !== null && _h !== void 0 ? _h : {};
const swiftToolsVersion = (_m = (_l = (_k = (_j = config.app.extConfig.experimental) === null || _j === void 0 ? void 0 : _j.ios) === null || _k === void 0 ? void 0 : _k.spm) === null || _l === void 0 ? void 0 : _l.swiftToolsVersion) !== null && _m !== void 0 ? _m : '5.9';
let packageSwiftText = `// swift-tools-version: ${swiftToolsVersion}
import PackageDescription
@ -105,10 +106,28 @@ let package = Package(
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", exact: "${iosPlatformVersion}")`;
for (const plugin of plugins) {
if ((0, plugin_1.getPluginType)(plugin, config.ios.name) === 1 /* PluginType.Cordova */) {
packageSwiftText += `,\n .package(name: "${plugin.name}", path: "../../capacitor-cordova-ios-plugins/sources/${plugin.name}")`;
const platformTag = (0, plugin_1.getPluginPlatform)(plugin, config.ios.name);
if ((_o = platformTag.$) === null || _o === void 0 ? void 0 : _o.package) {
const relPath = (0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath);
packageSwiftText += `,\n .package(name: "${plugin.id}", path: "${relPath}")`;
}
else {
const sourceFiles = (0, plugin_1.getPlatformElement)(plugin, config.ios.name, 'source-file');
const headerFiles = (0, plugin_1.getPlatformElement)(plugin, config.ios.name, 'header-file');
if (sourceFiles.length === 0 && headerFiles.length === 0) {
continue;
}
packageSwiftText += `,\n .package(name: "${plugin.name}", path: "../../capacitor-cordova-ios-plugins/sources/${plugin.name}")`;
}
}
else {
const relPath = (0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath);
const options = packageOptions[plugin.id];
const symlink = options === null || options === void 0 ? void 0 : options.symlink;
const symlinkFolder = (0, path_1.join)('symlinks', plugin.name);
const relPath = symlink ? symlinkFolder : (0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath);
if (symlink) {
await (0, fs_extra_1.ensureSymlink)(plugin.rootPath, (0, path_1.resolve)(config.ios.nativeProjectDirAbs, 'CapApp-SPM', symlinkFolder));
}
const traits = packageTraits[plugin.id];
const traitsSuffix = (traits === null || traits === void 0 ? void 0 : traits.length)
? `, traits: [${traits
@ -118,7 +137,7 @@ let package = Package(
})
.join(', ')}]`
: '';
packageSwiftText += `,\n .package(name: "${(_j = plugin.ios) === null || _j === void 0 ? void 0 : _j.name}", path: "${relPath}"${traitsSuffix})`;
packageSwiftText += `,\n .package(name: "${(_p = plugin.ios) === null || _p === void 0 ? void 0 : _p.name}", path: "${relPath}"${traitsSuffix})`;
}
}
packageSwiftText += `
@ -130,7 +149,29 @@ let package = Package(
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm")`;
for (const plugin of plugins) {
packageSwiftText += `,\n .product(name: "${(_k = plugin.ios) === null || _k === void 0 ? void 0 : _k.name}", package: "${(_l = plugin.ios) === null || _l === void 0 ? void 0 : _l.name}")`;
const aliases = Object.entries((_r = (_q = packageOptions[plugin.id]) === null || _q === void 0 ? void 0 : _q.moduleAliases) !== null && _r !== void 0 ? _r : {});
const aliasText = (aliases === null || aliases === void 0 ? void 0 : aliases.length)
? `, moduleAliases: [${aliases
.map(([target, replacement]) => {
return `"${target}": "${replacement}"`;
})
.join(', ')}]`
: '';
let pluginText = `,\n .product(name: "${(_s = plugin.ios) === null || _s === void 0 ? void 0 : _s.name}", package: "${(_t = plugin.ios) === null || _t === void 0 ? void 0 : _t.name}"${aliasText})`;
if ((0, plugin_1.getPluginType)(plugin, config.ios.name) === 1 /* PluginType.Cordova */) {
const platformTag = (0, plugin_1.getPluginPlatform)(plugin, config.ios.name);
if ((_u = platformTag.$) === null || _u === void 0 ? void 0 : _u.package) {
pluginText = `,\n .product(name: "${plugin.id}", package: "${plugin.id}")`;
}
else {
const sourceFiles = (0, plugin_1.getPlatformElement)(plugin, config.ios.name, 'source-file');
const headerFiles = (0, plugin_1.getPlatformElement)(plugin, config.ios.name, 'header-file');
if (sourceFiles.length === 0 && headerFiles.length === 0) {
pluginText = '';
}
}
}
packageSwiftText += pluginText;
}
packageSwiftText += `
]

View file

@ -61,7 +61,7 @@ const fse = require('fs-extra')
### ESM
There is also an `fs-extra/esm` import, that supports both default and named exports. However, note that `fs` methods are not included in `fs-extra/esm`; you still need to import `fs` and/or `fs/promises` seperately:
There is also an `fs-extra/esm` import, that supports both default and named exports. However, note that `fs` methods are not included in `fs-extra/esm`; you still need to import `fs` and/or `fs/promises` separately:
```js
import { readFileSync } from 'fs'

View file

@ -10,14 +10,14 @@ const { areIdentical } = require('../util/stat')
async function createLink (srcpath, dstpath) {
let dstStat
try {
dstStat = await fs.lstat(dstpath)
dstStat = await fs.lstat(dstpath, { bigint: true })
} catch {
// ignore error
}
let srcStat
try {
srcStat = await fs.lstat(srcpath)
srcStat = await fs.lstat(srcpath, { bigint: true })
} catch (err) {
err.message = err.message.replace('lstat', 'ensureLink')
throw err
@ -39,11 +39,11 @@ async function createLink (srcpath, dstpath) {
function createLinkSync (srcpath, dstpath) {
let dstStat
try {
dstStat = fs.lstatSync(dstpath)
dstStat = fs.lstatSync(dstpath, { bigint: true })
} catch {}
try {
const srcStat = fs.lstatSync(srcpath)
const srcStat = fs.lstatSync(srcpath, { bigint: true })
if (dstStat && areIdentical(srcStat, dstStat)) return
} catch (err) {
err.message = err.message.replace('lstat', 'ensureLink')

View file

@ -24,18 +24,18 @@ async function createSymlink (srcpath, dstpath, type) {
// (standard symlink behavior) or fall back to cwd if that doesn't exist
let srcStat
if (path.isAbsolute(srcpath)) {
srcStat = await fs.stat(srcpath)
srcStat = await fs.stat(srcpath, { bigint: true })
} else {
const dstdir = path.dirname(dstpath)
const relativeToDst = path.join(dstdir, srcpath)
try {
srcStat = await fs.stat(relativeToDst)
srcStat = await fs.stat(relativeToDst, { bigint: true })
} catch {
srcStat = await fs.stat(srcpath)
srcStat = await fs.stat(srcpath, { bigint: true })
}
}
const dstStat = await fs.stat(dstpath)
const dstStat = await fs.stat(dstpath, { bigint: true })
if (areIdentical(srcStat, dstStat)) return
}
@ -61,18 +61,18 @@ function createSymlinkSync (srcpath, dstpath, type) {
// (standard symlink behavior) or fall back to cwd if that doesn't exist
let srcStat
if (path.isAbsolute(srcpath)) {
srcStat = fs.statSync(srcpath)
srcStat = fs.statSync(srcpath, { bigint: true })
} else {
const dstdir = path.dirname(dstpath)
const relativeToDst = path.join(dstdir, srcpath)
try {
srcStat = fs.statSync(relativeToDst)
srcStat = fs.statSync(relativeToDst, { bigint: true })
} catch {
srcStat = fs.statSync(srcpath)
srcStat = fs.statSync(srcpath, { bigint: true })
}
}
const dstStat = fs.statSync(dstpath)
const dstStat = fs.statSync(dstpath, { bigint: true })
if (areIdentical(srcStat, dstStat)) return
}

View file

@ -101,7 +101,10 @@ async function checkParentPaths (src, srcStat, dest, funcName) {
try {
destStat = await fs.stat(destParent, { bigint: true })
} catch (err) {
if (err.code === 'ENOENT') return
// The destination parent does not exist yet, but a deeper ancestor might
// (e.g. when it is a symlink into the source tree). Keep walking up so the
// self-subdirectory check is not bypassed.
if (err.code === 'ENOENT') return checkParentPaths(src, srcStat, destParent, funcName)
throw err
}
@ -120,7 +123,10 @@ function checkParentPathsSync (src, srcStat, dest, funcName) {
try {
destStat = fs.statSync(destParent, { bigint: true })
} catch (err) {
if (err.code === 'ENOENT') return
// The destination parent does not exist yet, but a deeper ancestor might
// (e.g. when it is a symlink into the source tree). Keep walking up so the
// self-subdirectory check is not bypassed.
if (err.code === 'ENOENT') return checkParentPathsSync(src, srcStat, destParent, funcName)
throw err
}
if (areIdentical(srcStat, destStat)) {

View file

@ -4,30 +4,47 @@ const fs = require('../fs')
const u = require('universalify').fromPromise
async function utimesMillis (path, atime, mtime) {
// if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
const fd = await fs.open(path, 'r+')
let closeErr = null
let error = null
try {
await fs.futimes(fd, atime, mtime)
} catch (futimesErr) {
error = futimesErr
} finally {
try {
await fs.close(fd)
} catch (e) {
closeErr = e
} catch (closeErr) {
if (!error) error = closeErr
}
}
if (closeErr) {
throw closeErr
if (error) {
throw error
}
}
function utimesMillisSync (path, atime, mtime) {
const fd = fs.openSync(path, 'r+')
fs.futimesSync(fd, atime, mtime)
return fs.closeSync(fd)
let error = null
try {
fs.futimesSync(fd, atime, mtime)
} catch (futimesErr) {
error = futimesErr
} finally {
try {
fs.closeSync(fd)
} catch (closeErr) {
if (!error) error = closeErr
}
}
if (error) {
throw error
}
}
module.exports = {

View file

@ -1,6 +1,6 @@
{
"name": "fs-extra",
"version": "11.3.4",
"version": "11.3.6",
"description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.",
"engines": {
"node": ">=14.14"

View file

@ -1,6 +1,6 @@
{
"name": "@capacitor/cli",
"version": "8.3.1",
"version": "8.4.1",
"description": "Capacitor: Cross-platform apps with JavaScript and the web",
"homepage": "https://capacitorjs.com",
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",