bb-relay 0.0.30 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/COLOR_LIST-BfSSBFUY.d.mts +4 -0
  2. package/dist/COLOR_LIST-BfSSBFUY.d.ts +4 -0
  3. package/dist/{Locale-BZo4MfHK.d.mts → Locale-DvFwr_9k.d.mts} +4 -0
  4. package/dist/{Locale-BZo4MfHK.d.ts → Locale-DvFwr_9k.d.ts} +4 -0
  5. package/dist/constant.d.mts +2 -3
  6. package/dist/constant.d.ts +2 -3
  7. package/dist/editor.d.mts +4 -2
  8. package/dist/editor.d.ts +4 -2
  9. package/dist/locale.d.mts +2 -2
  10. package/dist/locale.d.ts +2 -2
  11. package/dist/locale.js +10 -2
  12. package/dist/locale.mjs +10 -2
  13. package/dist/plugin.d.mts +154 -194
  14. package/dist/plugin.d.ts +154 -194
  15. package/dist/plugin.js +115 -211
  16. package/dist/plugin.mjs +111 -207
  17. package/package.json +4 -3
  18. package/src/constants/COLOR_LIST.ts +4 -0
  19. package/src/editor.ts +2 -0
  20. package/src/lib/plugin/ElementInstruction/BaseInstruction.ts +28 -0
  21. package/src/lib/plugin/ElementInstruction/ButtonInstruction.ts +5 -11
  22. package/src/lib/plugin/ElementInstruction/CheckboxInstruction.ts +5 -4
  23. package/src/lib/plugin/ElementInstruction/ContainerInstruction.ts +3 -0
  24. package/src/lib/plugin/ElementInstruction/ContentInstruction.ts +3 -0
  25. package/src/lib/plugin/ElementInstruction/HeaderInstruction.ts +3 -0
  26. package/src/lib/plugin/ElementInstruction/IconInstruction.ts +8 -9
  27. package/src/lib/plugin/ElementInstruction/InputInstruction.ts +5 -8
  28. package/src/lib/plugin/ElementInstruction/MarkdownInstruction.ts +5 -0
  29. package/src/lib/plugin/ElementInstruction/MenuInstruction.ts +6 -21
  30. package/src/lib/plugin/ElementInstruction/MenuItemInstruction.ts +3 -0
  31. package/src/lib/plugin/ElementInstruction/TextInstruction.ts +3 -6
  32. package/src/lib/plugin/ElementInstruction/TextareaInstruction.ts +4 -9
  33. package/src/lib/plugin/ElementInstruction/ViewInstruction.ts +6 -0
  34. package/src/lib/plugin/ElementInstruction/index.ts +16 -5
  35. package/src/lib/plugin/EventHandler.ts +3 -1
  36. package/src/lib/plugin/InstructionArg.ts +4 -2
  37. package/src/lib/plugin/Message.ts +5 -0
  38. package/src/lib/plugin/PluginElement/ButtonElement.ts +2 -6
  39. package/src/lib/plugin/PluginElement/CheckboxElement.ts +2 -6
  40. package/src/lib/plugin/PluginElement/ContainerElement.ts +6 -0
  41. package/src/lib/plugin/PluginElement/ContentElement.ts +6 -0
  42. package/src/lib/plugin/PluginElement/HeaderElement.ts +5 -9
  43. package/src/lib/plugin/PluginElement/IconElement.ts +2 -6
  44. package/src/lib/plugin/PluginElement/InputElement.ts +2 -7
  45. package/src/lib/plugin/PluginElement/MarkdownElement.ts +6 -0
  46. package/src/lib/plugin/PluginElement/MenuElement.ts +3 -24
  47. package/src/lib/plugin/PluginElement/MenuItemElement.ts +6 -0
  48. package/src/lib/plugin/PluginElement/TextElement.ts +4 -12
  49. package/src/lib/plugin/PluginElement/TextareaElement.ts +3 -7
  50. package/src/lib/plugin/PluginElement/ViewElement.ts +6 -0
  51. package/src/lib/plugin/PluginElement/index.ts +11 -3
  52. package/src/lib/plugin/RenderStatusType.ts +2 -2
  53. package/src/lib/plugin/index.ts +164 -245
  54. package/src/locales/en-GB.ts +4 -0
  55. package/src/locales/fr-FR.ts +4 -0
  56. package/src/plugin.ts +18 -2
  57. package/src/types/editor/Settings.ts +2 -0
  58. package/src/lib/plugin/ElementInstruction/LayoutInstruction.ts +0 -7
  59. package/src/lib/plugin/IconType.ts +0 -3
  60. package/src/lib/plugin/PluginElement/LayoutElement.ts +0 -8
  61. package/src/lib/plugin/genKey.ts +0 -8
@@ -0,0 +1,4 @@
1
+ declare const COLOR_LIST: readonly ["red", "slate", "stone", "zinc", "gray", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia", "pink", "rose"];
2
+ type Color = (typeof COLOR_LIST)[number];
3
+
4
+ export { COLOR_LIST as C, type Color as a };
@@ -0,0 +1,4 @@
1
+ declare const COLOR_LIST: readonly ["red", "slate", "stone", "zinc", "gray", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia", "pink", "rose"];
2
+ type Color = (typeof COLOR_LIST)[number];
3
+
4
+ export { COLOR_LIST as C, type Color as a };
@@ -148,6 +148,10 @@ declare const enGB: {
148
148
  paste: string;
149
149
  "en-GB": string;
150
150
  "fr-FR": string;
151
+ "app.minimise": string;
152
+ "app.maximise": string;
153
+ "app.restart": string;
154
+ app: string;
151
155
  };
152
156
 
153
157
  type Language = keyof typeof enGB;
@@ -148,6 +148,10 @@ declare const enGB: {
148
148
  paste: string;
149
149
  "en-GB": string;
150
150
  "fr-FR": string;
151
+ "app.minimise": string;
152
+ "app.maximise": string;
153
+ "app.restart": string;
154
+ app: string;
151
155
  };
152
156
 
153
157
  type Language = keyof typeof enGB;
@@ -1,4 +1,5 @@
1
1
  export { P as PROJECT_CATEGORY } from './PROJECT_CATEGORY-BivLHtB6.mjs';
2
+ export { C as COLOR_LIST } from './COLOR_LIST-BfSSBFUY.mjs';
2
3
 
3
4
  declare const SENTINEL_FILE = ".release.commit";
4
5
 
@@ -13,6 +14,4 @@ declare const DATA_ALIAS = "${userData}";
13
14
 
14
15
  declare const PLUGIN_URL = "https://downloadplugin-jaxucpei2q-uc.a.run.app";
15
16
 
16
- declare const COLOR_LIST: readonly ["red", "slate", "stone", "zinc", "gray", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia", "pink", "rose"];
17
-
18
- export { COLOR_LIST, DATA_ALIAS, PLUGIN_URL, SENTINEL_FILE, WEBSITE };
17
+ export { DATA_ALIAS, PLUGIN_URL, SENTINEL_FILE, WEBSITE };
@@ -1,4 +1,5 @@
1
1
  export { P as PROJECT_CATEGORY } from './PROJECT_CATEGORY-BivLHtB6.js';
2
+ export { C as COLOR_LIST } from './COLOR_LIST-BfSSBFUY.js';
2
3
 
3
4
  declare const SENTINEL_FILE = ".release.commit";
4
5
 
@@ -13,6 +14,4 @@ declare const DATA_ALIAS = "${userData}";
13
14
 
14
15
  declare const PLUGIN_URL = "https://downloadplugin-jaxucpei2q-uc.a.run.app";
15
16
 
16
- declare const COLOR_LIST: readonly ["red", "slate", "stone", "zinc", "gray", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia", "pink", "rose"];
17
-
18
- export { COLOR_LIST, DATA_ALIAS, PLUGIN_URL, SENTINEL_FILE, WEBSITE };
17
+ export { DATA_ALIAS, PLUGIN_URL, SENTINEL_FILE, WEBSITE };
package/dist/editor.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { C as Commit } from './Commit-PdsjrKSG.mjs';
2
2
  export { a as FileStat, F as FolderContent, b as FolderStat } from './FolderStat-Bhmwwc0t.mjs';
3
3
  export { F as FileContent } from './FileContent-BWulmcoi.mjs';
4
- import { L as Language, a as Locale } from './Locale-BZo4MfHK.mjs';
4
+ import { L as Language, a as Locale } from './Locale-DvFwr_9k.mjs';
5
+ import { a as Color } from './COLOR_LIST-BfSSBFUY.mjs';
5
6
  export { R as Result } from './Result-BLbZLEgX.mjs';
6
7
 
7
8
  type CopyArg = {
@@ -52,6 +53,7 @@ type Settings = {
52
53
  showAllFile: boolean;
53
54
  trashBehaviour: "permanent" | "trash";
54
55
  shortcuts: Shortcut[];
56
+ color: Color;
55
57
  /**
56
58
  * { [fileExtension: string]: pluginId }
57
59
  */
@@ -71,4 +73,4 @@ interface TutorialHeader {
71
73
 
72
74
  type WatchFSEvent = "updated" | "deleted" | "updated" | "add";
73
75
 
74
- export type { CopyArg, GitFileStatus, IconArg, MenuContent, Nav, Route, Settings, Shortcut, TutorialHeader, WatchFSEvent };
76
+ export { Color, type CopyArg, type GitFileStatus, type IconArg, type MenuContent, type Nav, type Route, type Settings, type Shortcut, type TutorialHeader, type WatchFSEvent };
package/dist/editor.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { C as Commit } from './Commit-PdsjrKSG.js';
2
2
  export { a as FileStat, F as FolderContent, b as FolderStat } from './FolderStat-Bhmwwc0t.js';
3
3
  export { F as FileContent } from './FileContent-BWulmcoi.js';
4
- import { L as Language, a as Locale } from './Locale-BZo4MfHK.js';
4
+ import { L as Language, a as Locale } from './Locale-DvFwr_9k.js';
5
+ import { a as Color } from './COLOR_LIST-BfSSBFUY.js';
5
6
  export { R as Result } from './Result-BLbZLEgX.js';
6
7
 
7
8
  type CopyArg = {
@@ -52,6 +53,7 @@ type Settings = {
52
53
  showAllFile: boolean;
53
54
  trashBehaviour: "permanent" | "trash";
54
55
  shortcuts: Shortcut[];
56
+ color: Color;
55
57
  /**
56
58
  * { [fileExtension: string]: pluginId }
57
59
  */
@@ -71,4 +73,4 @@ interface TutorialHeader {
71
73
 
72
74
  type WatchFSEvent = "updated" | "deleted" | "updated" | "add";
73
75
 
74
- export type { CopyArg, GitFileStatus, IconArg, MenuContent, Nav, Route, Settings, Shortcut, TutorialHeader, WatchFSEvent };
76
+ export { Color, type CopyArg, type GitFileStatus, type IconArg, type MenuContent, type Nav, type Route, type Settings, type Shortcut, type TutorialHeader, type WatchFSEvent };
package/dist/locale.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as Language } from './Locale-BZo4MfHK.mjs';
2
- export { a as Locale, e as enGB } from './Locale-BZo4MfHK.mjs';
1
+ import { L as Language } from './Locale-DvFwr_9k.mjs';
2
+ export { a as Locale, e as enGB } from './Locale-DvFwr_9k.mjs';
3
3
 
4
4
  declare const frFR: {
5
5
  [key in Language]: string;
package/dist/locale.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as Language } from './Locale-BZo4MfHK.js';
2
- export { a as Locale, e as enGB } from './Locale-BZo4MfHK.js';
1
+ import { L as Language } from './Locale-DvFwr_9k.js';
2
+ export { a as Locale, e as enGB } from './Locale-DvFwr_9k.js';
3
3
 
4
4
  declare const frFR: {
5
5
  [key in Language]: string;
package/dist/locale.js CHANGED
@@ -148,7 +148,11 @@ var enGB = {
148
148
  cut: "Cut",
149
149
  paste: "Paste",
150
150
  "en-GB": "English (UK)",
151
- "fr-FR": "French (France)"
151
+ "fr-FR": "French (France)",
152
+ "app.minimise": "Minimise",
153
+ "app.maximise": "Maximise",
154
+ "app.restart": "Restart",
155
+ app: "App"
152
156
  };
153
157
  var en_GB_default = enGB;
154
158
 
@@ -302,7 +306,11 @@ var frFR = {
302
306
  cut: "Couper",
303
307
  paste: "Coller",
304
308
  "en-GB": "Anglais (UK)",
305
- "fr-FR": "Fran\xE7ais (France)"
309
+ "fr-FR": "Fran\xE7ais (France)",
310
+ "app.minimise": "Minimiser",
311
+ "app.maximise": "Maximiser",
312
+ "app.restart": "Red\xE9marrer",
313
+ app: "App"
306
314
  };
307
315
  var fr_FR_default = frFR;
308
316
 
package/dist/locale.mjs CHANGED
@@ -148,7 +148,11 @@ var enGB = {
148
148
  cut: "Cut",
149
149
  paste: "Paste",
150
150
  "en-GB": "English (UK)",
151
- "fr-FR": "French (France)"
151
+ "fr-FR": "French (France)",
152
+ "app.minimise": "Minimise",
153
+ "app.maximise": "Maximise",
154
+ "app.restart": "Restart",
155
+ app: "App"
152
156
  };
153
157
  var en_GB_default = enGB;
154
158
 
@@ -302,7 +306,11 @@ var frFR = {
302
306
  cut: "Couper",
303
307
  paste: "Coller",
304
308
  "en-GB": "Anglais (UK)",
305
- "fr-FR": "Fran\xE7ais (France)"
309
+ "fr-FR": "Fran\xE7ais (France)",
310
+ "app.minimise": "Minimiser",
311
+ "app.maximise": "Maximiser",
312
+ "app.restart": "Red\xE9marrer",
313
+ app: "App"
306
314
  };
307
315
  var fr_FR_default = frFR;
308
316
  export {
package/dist/plugin.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import Electron from 'electron';
2
- import { icons } from 'lucide';
3
- import { ButtonHTMLAttributes, CSSProperties, InputHTMLAttributes, TextareaHTMLAttributes } from 'react';
1
+ import { CSSProperties } from 'react';
2
+ import { IconName } from 'lucide-react/dynamic';
4
3
  import { F as FolderContent, b as FolderStat, a as FileStat } from './FolderStat-Bhmwwc0t.mjs';
5
4
  import { F as FileContent } from './FileContent-BWulmcoi.mjs';
6
5
  import { R as Result } from './Result-BLbZLEgX.mjs';
@@ -9,178 +8,131 @@ import './PROJECT_CATEGORY-BivLHtB6.mjs';
9
8
  import './Wrapper-DWhYVa7F.mjs';
10
9
  import './Commit-PdsjrKSG.mjs';
11
10
 
12
- type IconType = keyof typeof icons;
13
-
14
- type ButtonInstruction = {
15
- type: "button";
16
- label: string;
17
- click: string;
18
- leftIcon?: IconType;
19
- rightIcon?: IconType;
20
- variant?: "primary" | "secondary" | "ghost";
21
- style?: ButtonHTMLAttributes<CSSProperties>;
11
+ type InstructionTypes = "button" | "view" | "markdown" | "input" | "text" | "menu" | "menuitem" | "checkbox" | "textarea" | "icon" | "container" | "header" | "content";
12
+ type BaseInstruction<T extends InstructionTypes> = {
13
+ key?: string;
14
+ style?: CSSProperties;
15
+ construct: T;
16
+ action: {
17
+ click?: string;
18
+ change?: string;
19
+ };
20
+ children?: ElementInstruction | ElementInstruction[] | string;
22
21
  };
23
22
 
24
- type CheckboxInstruction = {
25
- type: "checkbox";
23
+ interface ButtonInstruction extends BaseInstruction<"button"> {
24
+ variant?: "default" | "secondary" | "ghost" | "outline";
25
+ disabled?: boolean;
26
+ }
27
+
28
+ interface CheckboxInstruction extends BaseInstruction<"checkbox"> {
26
29
  label: string;
27
30
  isChecked: boolean;
28
- check: string;
29
- };
31
+ disabled?: boolean;
32
+ }
33
+
34
+ interface HeaderInstruction extends BaseInstruction<"header"> {
35
+ }
30
36
 
31
- type InputInstruction = {
32
- type: "input";
37
+ interface IconInstruction extends BaseInstruction<"icon"> {
38
+ icon?: IconName;
39
+ variant?: ButtonInstruction["variant"];
40
+ disabled?: boolean;
41
+ }
42
+
43
+ interface InputInstruction extends BaseInstruction<"input"> {
33
44
  placeholder?: string;
34
45
  value: string;
35
46
  change?: string;
36
47
  label?: string;
37
- leftIcon?: IconType;
38
- rightIcon?: IconType;
39
- style?: InputHTMLAttributes<CSSProperties>;
40
- };
48
+ type: HTMLInputElement["type"];
49
+ disabled?: boolean;
50
+ }
41
51
 
42
- type LayoutInstruction = {
52
+ interface ViewInstruction extends BaseInstruction<"view"> {
43
53
  children: ElementInstruction[];
44
- style?: CSSProperties;
45
- };
54
+ }
46
55
 
47
- type MenuInstruction = {
48
- type: "menu";
49
- trigger: {
50
- type: "text";
51
- content: string;
52
- variant?: "header" | "subheader" | "body" | "caption" | "big" | "small";
53
- } | {
54
- type: "icon";
55
- icon: IconType;
56
- variant?: "primary" | "secondary" | "ghost";
57
- };
58
- list: {
59
- label: string;
60
- click: string;
61
- leftIcon?: IconType;
62
- rightIcon?: IconType;
63
- }[];
64
- };
56
+ interface MenuInstruction extends BaseInstruction<"menu"> {
57
+ trigger: ElementInstruction;
58
+ label?: string;
59
+ }
65
60
 
66
- type TextareaInstruction = {
67
- type: "textarea";
61
+ interface TextareaInstruction extends BaseInstruction<"textarea"> {
68
62
  placeholder?: string;
69
63
  value: string;
70
- change?: string;
71
64
  label?: string;
72
- leftIcon?: IconType;
73
- rightIcon?: IconType;
74
- style?: TextareaHTMLAttributes<CSSProperties>;
75
- };
65
+ disabled?: boolean;
66
+ }
76
67
 
77
68
  type TextVariant = "header" | "subheader" | "body" | "caption" | "big" | "small";
78
- type TextInstruction = {
79
- type: "text";
80
- content: string;
69
+ interface TextInstruction extends BaseInstruction<"text"> {
81
70
  variant?: TextVariant;
82
- style?: CSSProperties;
83
- };
71
+ }
84
72
 
85
- type ElementInstruction = (ButtonInstruction | LayoutInstruction | InputInstruction | TextInstruction | MenuInstruction | CheckboxInstruction | TextareaInstruction) & {
86
- key?: string;
87
- };
73
+ interface MenuItemInstruction extends BaseInstruction<"menuitem"> {
74
+ }
75
+
76
+ interface MarkdownInstruction extends BaseInstruction<"markdown"> {
77
+ children: string;
78
+ }
79
+
80
+ interface ContainerInstruction extends BaseInstruction<"container"> {
81
+ }
82
+
83
+ interface ContentInstruction extends BaseInstruction<"content"> {
84
+ }
85
+
86
+ type ElementInstruction = ButtonInstruction | ViewInstruction | MarkdownInstruction | InputInstruction | TextInstruction | MenuInstruction | MenuItemInstruction | CheckboxInstruction | TextareaInstruction | IconInstruction | HeaderInstruction | ContainerInstruction | ContentInstruction;
88
87
 
89
88
  type ExtractStyle<T> = T extends {
90
89
  style?: infer S;
91
90
  } ? S : never;
92
- type InstructionArg<T> = Omit<T, "type" | "click" | "check" | "change"> & {
91
+ type InstructionArg<T, U extends string | boolean | undefined> = Omit<T, "construct" | "action"> & {
93
92
  key?: string;
94
93
  style?: ExtractStyle<T>;
94
+ onClick?: () => void;
95
+ onChange?: (val: U) => void;
95
96
  };
96
97
 
97
- type ButtonArg = InstructionArg<ButtonInstruction> & {
98
- onClick: () => void;
99
- };
100
- type ButtonElement = (props: ButtonArg) => ButtonInstruction & {
101
- key: string;
102
- };
98
+ type ButtonArg = InstructionArg<ButtonInstruction, undefined>;
99
+ type ButtonElement = (props: ButtonArg) => ButtonInstruction;
103
100
 
104
- type CheckboxArg = InstructionArg<CheckboxInstruction> & {
105
- onCheck: (checked: boolean) => void;
106
- };
107
- type CheckboxElement = (props: CheckboxArg) => CheckboxInstruction & {
108
- key: string;
109
- };
101
+ type CheckboxArg = InstructionArg<CheckboxInstruction, boolean>;
102
+ type CheckboxElement = (props: CheckboxArg) => CheckboxInstruction;
110
103
 
111
- type HeaderElement = (props: {
112
- children: ElementInstruction[];
113
- key?: string;
114
- }) => {
115
- type: "header";
116
- children: ElementInstruction[];
117
- key: string;
118
- };
104
+ type HeaderArg = InstructionArg<HeaderInstruction, undefined>;
105
+ type HeaderElement = (props: HeaderArg) => HeaderInstruction;
119
106
 
120
- type IconInstruction = {
121
- type: "icon";
122
- click: string;
123
- icon?: IconType;
124
- variant?: "primary" | "secondary" | "ghost";
125
- style?: ButtonHTMLAttributes<CSSProperties>;
126
- };
107
+ type IconArg = InstructionArg<IconInstruction, undefined>;
108
+ type IconElement = (props: IconArg) => IconInstruction;
127
109
 
128
- type IconArg = InstructionArg<IconInstruction> & {
129
- onClick: () => void;
130
- };
131
- type IconElement = (props: IconArg) => IconInstruction & {
132
- key: string;
133
- };
110
+ type InputArg = InstructionArg<InputInstruction, string>;
111
+ type InputElement = (props: InputArg) => InputInstruction;
134
112
 
135
- type InputArg = InstructionArg<InputInstruction> & {
136
- onChange: (value: string) => void;
137
- };
138
- type InputElement = (props: InputArg) => InputInstruction & {
139
- key: string;
140
- };
113
+ type MenuItemArg = InstructionArg<MenuItemInstruction, undefined>;
114
+ type MenuItemElement = (props: MenuItemArg) => MenuItemInstruction;
141
115
 
142
- type MenuArg = {
143
- key?: string;
144
- trigger: {
145
- type: "text";
146
- content: string;
147
- variant?: "header" | "subheader" | "body" | "caption" | "big" | "small";
148
- } | {
149
- type: "icon";
150
- icon: IconType;
151
- variant?: "primary" | "secondary" | "ghost";
152
- };
153
- list: {
154
- label: string;
155
- onClick: (label: string) => void;
156
- leftIcon?: IconType;
157
- rightIcon?: IconType;
158
- }[];
159
- };
160
- type MenuElement = (props: MenuArg) => MenuInstruction & {
161
- key: string;
162
- };
116
+ type MenuArg = InstructionArg<MenuInstruction, undefined>;
117
+ type MenuElement = (props: MenuArg) => MenuInstruction;
163
118
 
164
- type LayoutArg = InstructionArg<LayoutInstruction>;
165
- type LayoutElement = (props: LayoutArg) => LayoutInstruction & {
166
- key: string;
167
- };
119
+ type ViewArg = InstructionArg<ViewInstruction, undefined>;
120
+ type ViewElement = (props: ViewArg) => ViewInstruction;
168
121
 
169
- type TextArg = {
170
- key?: string;
171
- content: string;
172
- variant?: TextVariant;
173
- };
174
- type TextElement = (props: TextArg) => TextInstruction & {
175
- key: string;
176
- };
122
+ type TextArg = InstructionArg<TextInstruction, undefined>;
123
+ type TextElement = (props: TextArg) => TextInstruction;
177
124
 
178
- type TextareaArg = InstructionArg<TextareaInstruction> & {
179
- onChange: (value: string) => void;
180
- };
181
- type TextareaElement = (props: TextareaArg) => TextareaInstruction & {
182
- key: string;
183
- };
125
+ type TextareaArg = InstructionArg<TextareaInstruction, string>;
126
+ type TextareaElement = (props: TextareaArg) => TextareaInstruction;
127
+
128
+ type MarkdownArg = InstructionArg<MarkdownInstruction, undefined>;
129
+ type MarkdownElement = (props: MarkdownArg) => MarkdownInstruction;
130
+
131
+ type ContentArg = InstructionArg<ContentInstruction, undefined>;
132
+ type ContentElement = (props: ContentArg) => ContentInstruction;
133
+
134
+ type ContainerArg = InstructionArg<ContainerInstruction, undefined>;
135
+ type ContainerElement = (props: ContainerArg) => ContainerInstruction;
184
136
 
185
137
  type PluginElement = {
186
138
  button: ButtonElement;
@@ -188,15 +140,19 @@ type PluginElement = {
188
140
  header: HeaderElement;
189
141
  icon: IconElement;
190
142
  input: InputElement;
143
+ markdown: MarkdownElement;
191
144
  menu: MenuElement;
192
- layout: LayoutElement;
193
- text: TextElement;
145
+ menuitem: MenuItemElement;
194
146
  textarea: TextareaElement;
147
+ text: TextElement;
148
+ view: ViewElement;
149
+ content: ContentElement;
150
+ container: ContainerElement;
195
151
  };
196
152
 
197
153
  type StatusElement = {
198
154
  type: "icon";
199
- icon: keyof typeof icons;
155
+ icon: IconName;
200
156
  } | {
201
157
  type: "text";
202
158
  text: string;
@@ -207,18 +163,14 @@ type RenderStatusType = {
207
163
  onClick: () => void;
208
164
  };
209
165
 
210
- type Editor = {
211
- /**
212
- * This will control app itself like quit, minimise, maximise, fullscreen etc
213
- * @returns
214
- */
215
- app?: {
216
- quit: () => void;
217
- minimize: () => void;
218
- maximize: () => void;
219
- fullscreen: () => void;
220
- fullscreenExit: () => void;
221
- };
166
+ type EventHandler<T = unknown> = (payload?: T) => unknown | Promise<unknown>;
167
+
168
+ type Store<T extends Record<string, unknown>> = {
169
+ get(): T;
170
+ set(next: SetState<T>): void;
171
+ subscribe(listener: (state: T) => void): () => void;
172
+ };
173
+ type EditorAPI = {
222
174
  /**
223
175
  * Enable read/write of files/directories
224
176
  * @returns
@@ -232,39 +184,49 @@ type Editor = {
232
184
  readFile: (arg: Omit<FileContent, "content">) => Promise<Result<FileContent>>;
233
185
  getFileStat: (path: string) => Promise<Result<FileStat>>;
234
186
  deleteFile: (path: string) => Promise<Result>;
235
- rename: (oldPath: string, newPath: string) => Promise<Result>;
236
- copy: (oldPath: string, newPath: string) => Promise<Result>;
237
- listFiles: (glob?: string) => Promise<Result<string[]>>;
187
+ copyFile: (filePath: string, destination: string) => Promise<Result<string>>;
188
+ listFiles: (folder: string, glob?: string) => Promise<Result<string[]>>;
238
189
  };
239
190
  };
240
- declare abstract class Plugin {
191
+ type SetState<T extends Record<string, unknown>> = Partial<T> | ((arg: T) => T);
192
+ declare abstract class Plugin<T extends Record<string, unknown>> {
241
193
  /** CONSTANTS */
242
194
  private readonly pluginId;
243
- private readonly storagePath;
244
195
  /** In-memory reactive state */
245
- protected state: Record<string, unknown>;
246
- private persistTimer?;
247
- private static CHANNEL;
248
- /** Events */
249
- private registeredEvents;
196
+ private store;
197
+ /** Events: ipc.handle()*/
198
+ private registeredHandlers;
199
+ private handler;
200
+ private removeHandler;
201
+ /** Listeners: ipc.on() */
250
202
  private subscriptions;
251
- /** Electron API */
252
- private ipcMain;
253
- private webContents;
203
+ private subscribe;
204
+ private sendMessage;
205
+ private index;
254
206
  /** App api, the ones available will be based on the permissions in the manifest*/
255
- protected editor: Editor | null;
207
+ protected editor: EditorAPI;
256
208
  /** Constructor */
257
- constructor(pluginId: string, storagePath: string, ipcMain: typeof Electron.ipcMain, webContents: typeof Electron.webContents, editor: Editor);
209
+ constructor({ pluginId, editor, handler, removeHandler, subscribe, sendMessage, store, }: {
210
+ pluginId: string;
211
+ editor: EditorAPI;
212
+ handler: (channel: string, arg: EventHandler) => void;
213
+ removeHandler: (channel: string) => void;
214
+ subscribe: (channel: string, handler: EventHandler) => () => void;
215
+ sendMessage: (arg: {
216
+ type: string;
217
+ arg: unknown;
218
+ pluginId: string;
219
+ }) => void;
220
+ store: Store<T>;
221
+ });
222
+ private makeElement;
258
223
  protected element: PluginElement;
259
224
  /** Called once when plugin loads
260
225
  * This is where you should load statusbar or register shortcuts if you want
261
226
  * to
262
- * You can also used it to load or set initial state
263
- * @example init() {
264
- * this.setState({ initialValue: "hello world" })
265
- * }
227
+ * You will also need to set initial state here
266
228
  */
267
- abstract init(): Promise<void> | void;
229
+ abstract init(): T;
268
230
  protected render(message: "sidebar" | "modal", arg: ElementInstruction): void;
269
231
  /**
270
232
  * Used to determine what will be shown at the sidebar whenever a user navigates
@@ -298,40 +260,38 @@ declare abstract class Plugin {
298
260
  */
299
261
  protected renderOverlay(overlay: ElementInstruction): void;
300
262
  protected onOverlayResponse(callback: (arg: unknown) => void): void;
301
- /**
302
- * So right now, if I call destroy, it will clear all handlers
303
- * This is appropriate for temporary components like sidebar that can be
304
- * unmounted in the UI but there are some that should be there for the lifetime
305
- * of the app.
306
- * Hence, perhaps, I could break the registeredEvents into two groups
307
- * and have 2 destroy functions (or one with isTemp boolean params)
308
- */
309
263
  destroy(): void;
310
264
  private getPluginChannel;
311
- private registerEvent;
312
- private sendMessage;
313
- protected subscribe(event: "project-selected", callback: (arg: Project["insert"] & {
265
+ private registerHandler;
266
+ private unregisterHandler;
267
+ private registerSubscription;
268
+ protected off(event: string): void;
269
+ protected on(event: "project-selected", callback: (arg: Project["insert"] & {
314
270
  workingDir: string;
315
271
  id?: string;
316
272
  }) => void): void;
317
- protected subscribe(event: "new-project", callback: (arg: Project["insert"] & {
273
+ protected on(event: "new-project", callback: (arg: Project["insert"] & {
318
274
  workingDir: string;
319
275
  id?: string;
320
276
  }) => void): void;
321
- protected subscribe(event: "file-selected", callback: (filePath: string) => void): void;
322
- protected subscribe(event: "file-created", callback: (filePath: string) => void): void;
323
- protected subscribe(event: "file-changed", callback: (filePath: string) => void): void;
324
- protected subscribe(event: "file-deleted", callback: (filePath: string) => void): void;
277
+ protected on(event: "file-selected", callback: (filePath: string | null) => void): void;
278
+ protected on(event: "file-created", callback: (filePath: string) => void): void;
279
+ protected on(event: "file-changed", callback: (filePath: string) => void): void;
280
+ protected on(event: "file-deleted", callback: (filePath: string) => void): void;
325
281
  abstract renderStatusBar(): RenderStatusType | null;
326
282
  private registerStatusBar;
327
283
  private onStatusLoad;
328
- protected setState(partial: Record<string, unknown>): void;
329
- protected getState<T extends Record<string, unknown>>(): T;
330
- private schedulePersist;
331
- private loadStorage;
284
+ protected setState(param: SetState<T>): void;
285
+ protected getState(): T;
332
286
  protected notify(message: string): void;
333
287
  }
334
288
 
289
+ type Message = {
290
+ type: string;
291
+ arg: unknown;
292
+ pluginId: string;
293
+ };
294
+
335
295
  declare const getPluginChannel: (event: string, pluginId: string) => string;
336
296
 
337
- export { type ElementInstruction, type RenderStatusType, Plugin as default, getPluginChannel };
297
+ export { type EditorAPI, type ElementInstruction, type InputInstruction, type Message, type PluginElement, type RenderStatusType, type SetState, type Store, type TextVariant, type TextareaInstruction, Plugin as default, getPluginChannel };