File tree Expand file tree Collapse file tree 3 files changed +20
-34
lines changed
heartbeat_monitor/src/jsMain Expand file tree Collapse file tree 3 files changed +20
-34
lines changed Original file line number Diff line number Diff line change 11package hello
22
3+ import kotlinx.browser.window
34import kotlinx.coroutines.MainScope
5+ import kotlinx.coroutines.await
46import kotlinx.coroutines.promise
57import kotlin.js.Promise
68
@@ -15,4 +17,20 @@ fun init(): Promise<Unit> = MainScope().promise {
1517 SortPlugin .init ()
1618 FirebaseLoginPlugin .init ()
1719 KanbanBroFirebaseHeartbeatCardProviderPlugin .init ()
20+
21+
22+ FaviconPlugin .apply ().await()
23+
24+ TitlePlugin .apply ().await()
25+ ThemeTogglePlugin .apply ().await()
26+ AutoUpdatePlugin .apply ().await()
27+ UpdatePlugin .apply ().await()
28+
29+ if (false ) SampleCardProviderPlugin .apply ().await()
30+ FirebaseLoginPlugin .apply ().await()
31+ SortPlugin .apply ().await()
32+ KanbanBroFirebaseHeartbeatCardProviderPlugin .apply ().await()
33+
34+ KanbanBro .event.dispatchEvent(new(window.asDynamic().Event , " pluginLoaded" ))
35+
1836}
Original file line number Diff line number Diff line change @@ -4,22 +4,10 @@ import kotlinx.coroutines.MainScope
44import kotlinx.coroutines.promise
55import kotlin.js.Promise
66
7- @JsExport
87interface Plugin {
98 fun apply (): Promise <Unit >
109}
1110
12- @JsExport
13- fun getPlugin (name : String ): Plugin ? = Plugins .plugins[name]
14-
15- @JsExport
16- fun getAllPlugins (): Array <Plugin > = Plugins .plugins.values.toTypedArray()
17-
18- object Plugins {
19- val plugins = mutableMapOf<String , Plugin >()
20- }
21-
22-
2311abstract class AbstractPlugin (val name : String ) : Plugin {
2412 final override fun apply (): Promise <Unit > {
2513 return MainScope ().promise {
@@ -29,7 +17,5 @@ abstract class AbstractPlugin(val name: String) : Plugin {
2917
3018 protected abstract suspend fun applyImpl ()
3119
32- open suspend fun init () {
33- Plugins .plugins[name] = this
34- }
20+ open suspend fun init () = Unit
3521}
Original file line number Diff line number Diff line change 672672
673673</ script >
674674< script type ="module ">
675- import { init , getPlugin } from "./heartbeat_monitor.js" ;
676-
675+ import { init } from "./heartbeat_monitor.js" ;
677676 await init ( ) ;
678-
679- document . addEventListener ( 'DOMContentLoaded' , async ( ) => {
680-
681- await getPlugin ( "FaviconPlugin" ) . apply ( ) ;
682-
683- await getPlugin ( "TitlePlugin" ) . apply ( ) ;
684- await getPlugin ( "ThemeTogglePlugin" ) . apply ( ) ;
685- await getPlugin ( "AutoUpdatePlugin" ) . apply ( ) ;
686- await getPlugin ( "UpdatePlugin" ) . apply ( ) ;
687-
688- if ( false ) await getPlugin ( "SampleCardProviderPlugin" ) . apply ( ) ;
689- await getPlugin ( "FirebaseLoginPlugin" ) . apply ( ) ;
690- await getPlugin ( "SortPlugin" ) . apply ( ) ;
691- await getPlugin ( "KanbanBroFirebaseHeartbeatCardProviderPlugin" ) . apply ( ) ;
692-
693- window . KanbanBro . event . dispatchEvent ( new Event ( 'pluginLoaded' ) ) ;
694- } , { once : true } ) ;
695677</ script >
696678</ body >
697679</ html >
You can’t perform that action at this time.
0 commit comments