2024-03-11 17:02:15 +02:00
|
|
|
export { runPlugin, stopPlugin } from './startStopPlugin';
|
|
|
|
|
2024-03-14 21:04:32 +02:00
|
|
|
// Old plugins allowed to import legacy APIs
|
|
|
|
const legacyPluginIds = [
|
|
|
|
'outline',
|
|
|
|
'ylc395.noteLinkSystem',
|
|
|
|
];
|
|
|
|
|
2024-03-11 17:02:15 +02:00
|
|
|
const pathLibrary = require('path');
|
2024-03-14 21:04:32 +02:00
|
|
|
const punycode = require('punycode/');
|
|
|
|
|
|
|
|
export const requireModule = (moduleName: string, fromPluginId: string) => {
|
2024-03-11 17:02:15 +02:00
|
|
|
if (moduleName === 'path') {
|
|
|
|
return pathLibrary;
|
|
|
|
}
|
|
|
|
|
2024-03-14 21:04:32 +02:00
|
|
|
if (legacyPluginIds.includes(fromPluginId)) {
|
|
|
|
if (moduleName === 'punycode') {
|
|
|
|
console.warn('Requiring punycode is deprecated. Please transition to a newer API.');
|
|
|
|
return punycode;
|
|
|
|
}
|
|
|
|
if (moduleName === 'fs' || moduleName === 'fs-extra') {
|
|
|
|
console.warn('The fs library is unavailable to mobile plugins. A non-functional mock will be returned.');
|
|
|
|
return {
|
|
|
|
existsSync: () => false,
|
|
|
|
pathExists: () => false,
|
|
|
|
readFileSync: () => '',
|
|
|
|
readFile: () => '',
|
|
|
|
writeFileSync: () => '',
|
|
|
|
writeFile: () => '',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (moduleName === 'process') {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
if (moduleName === 'url') {
|
|
|
|
return { parse: (u: string) => new URL(u) };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-11 17:02:15 +02:00
|
|
|
throw new Error(`Unable to require module ${moduleName} on mobile.`);
|
|
|
|
};
|
|
|
|
|
|
|
|
export { default as initializePluginBackgroundIframe } from './initializePluginBackgroundIframe';
|
2024-03-14 21:04:32 +02:00
|
|
|
export { default as initializeDialogWebView } from './initializeDialogWebView';
|