From 6d4792cf1d9414b256725d5da53c171952a8303d Mon Sep 17 00:00:00 2001 From: Pavol Hejny Date: Sun, 2 Oct 2022 21:20:36 +0200 Subject: [PATCH] Maker draft --- src/config.ts | 49 +++++++++++++++ src/interfaces/IWallpaperConfig.ts | 15 +++-- src/makers/makeBackgroundWallpaperModule.ts | 69 ++++++++++++++++++++- 3 files changed, 126 insertions(+), 7 deletions(-) diff --git a/src/config.ts b/src/config.ts index 1b4557f..306c49a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -9,6 +9,55 @@ export const WALLPAPERS: Array = [ { title: { en: 'Space', cs: 'Vesmír' }, description: { en: 'Changes white background to space.', cs: 'Vymění bílé pozadí za vesmírné.' } + + + + + +/* + +!!! + + + + name: `${packageName}/space`, + version, + deprecatedNames: 'SpaceBackground', + title: { en: 'Space', cs: 'Vesmír' }, + description: { en: 'Changes white background to space.', cs: 'Vymění bílé pozadí za vesmírné.' }, + + categories: [ + 'Wallpaper', + 'Geography', + 'Space', + 'Education' /* Not template because to user do not seem so * /, + ], + icon: '🌌', // TODO: Icon because other planets than Earth and Moon do not have emoji icon + screenshots: [ + /*TODO:* / + ], + author: Authors.hejny, + }, + + async setup(systems) { + const { virtualArtVersioningSystem } = await systems.request('virtualArtVersioningSystem'); + + /** + * Sources: + * https://www.wallpaperflare.com/ + * https://www.wallpaperflare.com/galaxy-wallpaper-landscape-photo-of-sky-star-astrophotography-wallpaper-zubhc + * https://www.pikrepo.com/fgicl/black-and-blue-galaxy-digital-wallpaper + * / + + + + +*/ + + + + + }, ]; diff --git a/src/interfaces/IWallpaperConfig.ts b/src/interfaces/IWallpaperConfig.ts index a8d92a1..73ab595 100644 --- a/src/interfaces/IWallpaperConfig.ts +++ b/src/interfaces/IWallpaperConfig.ts @@ -1,21 +1,26 @@ -import { IStringMessage, string_url_image } from '@collboard/modules-sdk'; +import { string_url_image } from '@collboard/modules-sdk'; -export interface IWallpaperConfig { +// !!! To maker file + +export interface IWallpaperConfig /* !!! Extends IModuleManifest*/{ + /* !!! Remove /** * Unique name of the wallpaper in a module name - */ + * / name: string; /** * Title to display in the UI and module store - */ + * / title: IStringMessage; /** * Description to display in the module store - */ + * / description: IStringMessage; + */ + /** * Source of the wallpaper */ diff --git a/src/makers/makeBackgroundWallpaperModule.ts b/src/makers/makeBackgroundWallpaperModule.ts index 65c9893..ad0c2bc 100644 --- a/src/makers/makeBackgroundWallpaperModule.ts +++ b/src/makers/makeBackgroundWallpaperModule.ts @@ -1,4 +1,69 @@ -makeBackgroundWallpaperModule +import { BackgroundWallpaperArt, IModuleDefinition, IModuleManifest, ISystems } from '@collboard/modules-sdk'; +import { IWallpaperConfig } from '../interfaces/IWallpaperConfig'; +/** + * Makes a module which places a wallpaper + * + */ +export function makeBackgroundWallpaperModule( + wallpaperModuleManifest: IModuleManifest & IWallpaperConfig, +): IModuleDefinition { + const { manifest, place, order, createElement } = wallpaperModuleManifest; -// !!! Use IWallpaperConfig \ No newline at end of file + return { + manifest: wallpaperModuleManifest, + async setup(systems: ISystems) { + const { virtualArtVersioningSystem } = await systems.request('virtualArtVersioningSystem'); + + return virtualArtVersioningSystem + .createPrimaryOperation() + .newArts(new BackgroundWallpaperArt(wallpaperModuleManifest.src)) + .persist(); + }, + }; +} + +/* + + +{ + manifest: { + name: `${packageName}/space`, + version, + deprecatedNames: 'SpaceBackground', + title: { en: 'Space', cs: 'Vesmír' }, + description: { en: 'Changes white background to space.', cs: 'Vymění bílé pozadí za vesmírné.' }, + + categories: [ + 'Wallpaper', + 'Geography', + 'Space', + 'Education' /* Not template because to user do not seem so * /, + ], + icon: '🌌', // TODO: Icon because other planets than Earth and Moon do not have emoji icon + screenshots: [ + /*TODO:* / + ], + author: Authors.hejny, + }, + + async setup(systems) { + + }, + } + + + + + + + + + + + +*/ + +/** + * TODO: Should makers recieve object with manifest OR extended manifest? + */