You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	Plugins: Added joplin.versionInfo method
This commit is contained in:
		| @@ -1489,6 +1489,9 @@ packages/lib/services/keychain/KeychainServiceDriver.node.js.map | ||||
| packages/lib/services/keychain/KeychainServiceDriverBase.d.ts | ||||
| packages/lib/services/keychain/KeychainServiceDriverBase.js | ||||
| packages/lib/services/keychain/KeychainServiceDriverBase.js.map | ||||
| packages/lib/services/plugins/BasePlatformImplementation.d.ts | ||||
| packages/lib/services/plugins/BasePlatformImplementation.js | ||||
| packages/lib/services/plugins/BasePlatformImplementation.js.map | ||||
| packages/lib/services/plugins/BasePluginRunner.d.ts | ||||
| packages/lib/services/plugins/BasePluginRunner.js | ||||
| packages/lib/services/plugins/BasePluginRunner.js.map | ||||
|   | ||||
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1479,6 +1479,9 @@ packages/lib/services/keychain/KeychainServiceDriver.node.js.map | ||||
| packages/lib/services/keychain/KeychainServiceDriverBase.d.ts | ||||
| packages/lib/services/keychain/KeychainServiceDriverBase.js | ||||
| packages/lib/services/keychain/KeychainServiceDriverBase.js.map | ||||
| packages/lib/services/plugins/BasePlatformImplementation.d.ts | ||||
| packages/lib/services/plugins/BasePlatformImplementation.js | ||||
| packages/lib/services/plugins/BasePlatformImplementation.js.map | ||||
| packages/lib/services/plugins/BasePluginRunner.d.ts | ||||
| packages/lib/services/plugins/BasePluginRunner.js | ||||
| packages/lib/services/plugins/BasePluginRunner.js.map | ||||
|   | ||||
| @@ -1,19 +1,12 @@ | ||||
| import bridge from '../bridge'; | ||||
| import { Implementation as WindowImplementation } from '@joplin/lib/services/plugins/api/JoplinWindow'; | ||||
| import { injectCustomStyles } from '@joplin/lib/CssUtils'; | ||||
| import { VersionInfo } from '@joplin/lib/services/plugins/api/types'; | ||||
| import Setting from '@joplin/lib/models/Setting'; | ||||
| import { reg } from '@joplin/lib/registry'; | ||||
| import BasePlatformImplementation, { Joplin } from '@joplin/lib/services/plugins/BasePlatformImplementation'; | ||||
| const { clipboard, nativeImage } = require('electron'); | ||||
|  | ||||
| interface JoplinViewsDialogs { | ||||
| 	showMessageBox(message: string): Promise<number>; | ||||
| } | ||||
|  | ||||
| interface JoplinViews { | ||||
| 	dialogs: JoplinViewsDialogs; | ||||
| } | ||||
|  | ||||
| interface Joplin { | ||||
| 	views: JoplinViews; | ||||
| } | ||||
| const packageInfo = require('../../packageInfo'); | ||||
|  | ||||
| interface Components { | ||||
| 	[key: string]: any; | ||||
| @@ -22,7 +15,7 @@ interface Components { | ||||
| // PlatformImplementation provides access to platform specific dependencies, | ||||
| // such as the clipboard, message dialog, etc. It allows having the same plugin | ||||
| // API for all platforms, but with different implementations. | ||||
| export default class PlatformImplementation { | ||||
| export default class PlatformImplementation extends BasePlatformImplementation { | ||||
|  | ||||
| 	private static instance_: PlatformImplementation; | ||||
| 	private joplin_: Joplin; | ||||
| @@ -33,6 +26,14 @@ export default class PlatformImplementation { | ||||
| 		return this.instance_; | ||||
| 	} | ||||
|  | ||||
| 	public get versionInfo(): VersionInfo { | ||||
| 		return { | ||||
| 			version: packageInfo.version, | ||||
| 			syncVersion: Setting.value('syncVersion'), | ||||
| 			profileVersion: reg.db().version(), | ||||
| 		}; | ||||
| 	} | ||||
|  | ||||
| 	public get clipboard() { | ||||
| 		return clipboard; | ||||
| 	} | ||||
| @@ -48,6 +49,8 @@ export default class PlatformImplementation { | ||||
| 	} | ||||
|  | ||||
| 	public constructor() { | ||||
| 		super(); | ||||
|  | ||||
| 		this.components_ = {}; | ||||
|  | ||||
| 		this.joplin_ = { | ||||
|   | ||||
							
								
								
									
										50
									
								
								packages/lib/services/plugins/BasePlatformImplementation.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								packages/lib/services/plugins/BasePlatformImplementation.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| // PlatformImplementation provides access to platform specific dependencies, | ||||
| // such as the clipboard, message dialog, etc. It allows having the same plugin | ||||
|  | ||||
| import { VersionInfo } from './api/types'; | ||||
| import { Implementation as WindowImplementation } from './api/JoplinWindow'; | ||||
|  | ||||
| export interface JoplinViewsDialogs { | ||||
| 	showMessageBox(message: string): Promise<number>; | ||||
| } | ||||
|  | ||||
| export interface JoplinViews { | ||||
| 	dialogs: JoplinViewsDialogs; | ||||
| } | ||||
|  | ||||
| export interface Joplin { | ||||
| 	views: JoplinViews; | ||||
| } | ||||
|  | ||||
| // API for all platforms, but with different implementations. | ||||
| export default class BasePlatformImplementation { | ||||
|  | ||||
| 	public get versionInfo(): VersionInfo { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	} | ||||
|  | ||||
| 	public get clipboard(): any { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	} | ||||
|  | ||||
| 	public get nativeImage(): any { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	} | ||||
|  | ||||
| 	public get window(): WindowImplementation { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	} | ||||
|  | ||||
| 	public registerComponent(_name: string, _component: any) { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	} | ||||
|  | ||||
| 	public unregisterComponent(_name: string) { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	} | ||||
|  | ||||
| 	public get joplin(): Joplin { | ||||
| 		throw new Error('Not implemented'); | ||||
| 	} | ||||
|  | ||||
| } | ||||
| @@ -10,6 +10,7 @@ import JoplinSettings from './JoplinSettings'; | ||||
| import JoplinContentScripts from './JoplinContentScripts'; | ||||
| import JoplinClipboard from './JoplinClipboard'; | ||||
| import JoplinWindow from './JoplinWindow'; | ||||
| import BasePlatformImplementation from '../BasePlatformImplementation'; | ||||
|  | ||||
| /** | ||||
|  * This is the main entry point to the Joplin API. You can access various services using the provided accessors. | ||||
| @@ -36,8 +37,10 @@ export default class Joplin { | ||||
| 	private contentScripts_: JoplinContentScripts = null; | ||||
| 	private clipboard_: JoplinClipboard = null; | ||||
| 	private window_: JoplinWindow = null; | ||||
| 	private implementation_: BasePlatformImplementation = null; | ||||
|  | ||||
| 	public constructor(implementation: any, plugin: Plugin, store: any) { | ||||
| 	public constructor(implementation: BasePlatformImplementation, plugin: Plugin, store: any) { | ||||
| 		this.implementation_ = implementation; | ||||
| 		this.data_ = new JoplinData(); | ||||
| 		this.plugins_ = new JoplinPlugins(plugin); | ||||
| 		this.workspace_ = new JoplinWorkspace(store); | ||||
| @@ -117,4 +120,8 @@ export default class Joplin { | ||||
| 		// Just a stub. Implementation has to be done within plugin process, in plugin_index.js | ||||
| 	} | ||||
|  | ||||
| 	public async versionInfo() { | ||||
| 		return this.implementation_.versionInfo; | ||||
| 	} | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -221,6 +221,12 @@ export enum ModelType { | ||||
| 	Command = 16, | ||||
| } | ||||
|  | ||||
| export interface VersionInfo { | ||||
| 	version: string; | ||||
| 	profileVersion: number; | ||||
| 	syncVersion: number; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| // Menu types | ||||
| // ================================================================= | ||||
|   | ||||
							
								
								
									
										15
									
								
								yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								yarn.lock
									
									
									
									
									
								
							| @@ -9200,17 +9200,10 @@ __metadata: | ||||
|   languageName: node | ||||
|   linkType: hard | ||||
| 
 | ||||
| "caniuse-lite@npm:^1.0.30001280": | ||||
|   version: 1.0.30001285 | ||||
|   resolution: "caniuse-lite@npm:1.0.30001285" | ||||
|   checksum: 03abdcea913961f4484a7e9494482a0e8a32d6b2305e3922196d0672897c043ac2e1ce884c69730921400c7cddb41ae27a9fcfdaa7d82d11a75d7331393ab5c6 | ||||
|   languageName: node | ||||
|   linkType: hard | ||||
| 
 | ||||
| "caniuse-lite@npm:^1.0.30001286": | ||||
|   version: 1.0.30001291 | ||||
|   resolution: "caniuse-lite@npm:1.0.30001291" | ||||
|   checksum: ae24be79227036564ccd2ab8a0be8793a2e650941607a9f3e68a967db08d90cf17ded0382c2ce87063051b7200e618ec83bdb12f423ed60665922dc4d8eb8f78 | ||||
| "caniuse-lite@npm:^1.0.30001280, caniuse-lite@npm:^1.0.30001286": | ||||
|   version: 1.0.30001362 | ||||
|   resolution: "caniuse-lite@npm:1.0.30001362" | ||||
|   checksum: bd35704a81aa8ca12e952c2276d205109a5d10bd7d0fb767c27ee9bdbc8011c5c99a9772833701d68ed2fe7143f1744258c1cc440dd7ea4584a1354f6dac9f0a | ||||
|   languageName: node | ||||
|   linkType: hard | ||||
| 
 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user