bb-relay 0.0.35 → 0.0.36

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.
package/dist/index.d.mts CHANGED
@@ -37,6 +37,7 @@ type Manifest = {
37
37
  repository?: string;
38
38
  theme?: string;
39
39
  [key: string]: unknown;
40
+ status?: string;
40
41
  };
41
42
 
42
43
  declare const validateManifest: (manifestContent: string) => {
package/dist/index.d.ts CHANGED
@@ -37,6 +37,7 @@ type Manifest = {
37
37
  repository?: string;
38
38
  theme?: string;
39
39
  [key: string]: unknown;
40
+ status?: string;
40
41
  };
41
42
 
42
43
  declare const validateManifest: (manifestContent: string) => {
package/dist/index.js CHANGED
@@ -61,6 +61,9 @@ var validateManifest = (manifestContent) => {
61
61
  fileChecks.push(content.sidebar.icon);
62
62
  }
63
63
  }
64
+ if (content.status) {
65
+ fileChecks.push(content.status);
66
+ }
64
67
  if (content.iconsPath) {
65
68
  fileChecks.push(content.iconsPath + "/bb.png");
66
69
  }
package/dist/index.mjs CHANGED
@@ -61,6 +61,9 @@ var validateManifest = (manifestContent) => {
61
61
  fileChecks.push(content.sidebar.icon);
62
62
  }
63
63
  }
64
+ if (content.status) {
65
+ fileChecks.push(content.status);
66
+ }
64
67
  if (content.iconsPath) {
65
68
  fileChecks.push(content.iconsPath + "/bb.png");
66
69
  }
package/dist/plugin.d.mts CHANGED
@@ -152,6 +152,17 @@ type PluginElement = {
152
152
 
153
153
  type EventHandler<T = unknown> = (payload?: T) => unknown | Promise<unknown>;
154
154
 
155
+ type StatusElement = {
156
+ iconLeft?: IconName;
157
+ iconRight?: IconName;
158
+ message?: string;
159
+ text?: string;
160
+ };
161
+ type RenderStatusType = {
162
+ element: StatusElement[];
163
+ onClick?: () => void;
164
+ };
165
+
155
166
  type Store<T extends Record<string, unknown>> = {
156
167
  get(): T;
157
168
  set(next: SetState<T>): void;
@@ -270,8 +281,12 @@ declare abstract class Plugin<T extends Record<string, unknown>> {
270
281
  protected on(event: "file-changed", callback: (filePath: string) => void): void;
271
282
  protected on(event: "file-deleted", callback: (filePath: string) => void): void;
272
283
  protected on(event: "ping", callback: (arg: unknown) => void): void;
284
+ renderStatusBar?(): RenderStatusType | null;
285
+ private registerStatus;
286
+ private onStatusLoad;
273
287
  protected setState(param: SetState<T>): void;
274
288
  protected getState(): T;
289
+ protected log(message: string): void;
275
290
  selectFile(filePath: string): void;
276
291
  }
277
292
 
@@ -283,17 +298,4 @@ type Message = {
283
298
 
284
299
  declare const getPluginChannel: (event: string, pluginId: string) => string;
285
300
 
286
- type StatusElement = {
287
- type: "icon";
288
- icon: IconName;
289
- } | {
290
- type: "text";
291
- text: string;
292
- };
293
- type RenderStatusType = {
294
- element: StatusElement[];
295
- message: string;
296
- onClick: () => void;
297
- };
298
-
299
301
  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 };
package/dist/plugin.d.ts CHANGED
@@ -152,6 +152,17 @@ type PluginElement = {
152
152
 
153
153
  type EventHandler<T = unknown> = (payload?: T) => unknown | Promise<unknown>;
154
154
 
155
+ type StatusElement = {
156
+ iconLeft?: IconName;
157
+ iconRight?: IconName;
158
+ message?: string;
159
+ text?: string;
160
+ };
161
+ type RenderStatusType = {
162
+ element: StatusElement[];
163
+ onClick?: () => void;
164
+ };
165
+
155
166
  type Store<T extends Record<string, unknown>> = {
156
167
  get(): T;
157
168
  set(next: SetState<T>): void;
@@ -270,8 +281,12 @@ declare abstract class Plugin<T extends Record<string, unknown>> {
270
281
  protected on(event: "file-changed", callback: (filePath: string) => void): void;
271
282
  protected on(event: "file-deleted", callback: (filePath: string) => void): void;
272
283
  protected on(event: "ping", callback: (arg: unknown) => void): void;
284
+ renderStatusBar?(): RenderStatusType | null;
285
+ private registerStatus;
286
+ private onStatusLoad;
273
287
  protected setState(param: SetState<T>): void;
274
288
  protected getState(): T;
289
+ protected log(message: string): void;
275
290
  selectFile(filePath: string): void;
276
291
  }
277
292
 
@@ -283,17 +298,4 @@ type Message = {
283
298
 
284
299
  declare const getPluginChannel: (event: string, pluginId: string) => string;
285
300
 
286
- type StatusElement = {
287
- type: "icon";
288
- icon: IconName;
289
- } | {
290
- type: "text";
291
- text: string;
292
- };
293
- type RenderStatusType = {
294
- element: StatusElement[];
295
- message: string;
296
- onClick: () => void;
297
- };
298
-
299
301
  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 };
package/dist/plugin.js CHANGED
@@ -58,8 +58,11 @@ var Plugin = class {
58
58
  this.eventIds = [];
59
59
  const sidebar = _optionalChain([this, 'access', _ => _.renderSidebar, 'optionalCall', _2 => _2()]) || null;
60
60
  if (sidebar) this.render("sidebar", sidebar);
61
+ const status = _optionalChain([this, 'access', _3 => _3.renderStatusBar, 'optionalCall', _4 => _4()]) || null;
62
+ if (status) this.registerStatus();
61
63
  });
62
64
  this.onSidebarLoad();
65
+ this.onStatusLoad();
63
66
  }
64
67
  // -----------------------------
65
68
  // Element Factory
@@ -92,7 +95,7 @@ var Plugin = class {
92
95
  onSidebarLoad() {
93
96
  this.index = -1;
94
97
  this.registerHandler("sidebar-load", () => {
95
- return _optionalChain([this, 'access', _3 => _3.renderSidebar, 'optionalCall', _4 => _4()]) || null;
98
+ return _optionalChain([this, 'access', _5 => _5.renderSidebar, 'optionalCall', _6 => _6()]) || null;
96
99
  });
97
100
  }
98
101
  // -----------------------------
@@ -165,28 +168,32 @@ var Plugin = class {
165
168
  on(event, callback) {
166
169
  this.registerSubscription(event, callback);
167
170
  }
168
- // -----------------------------
169
- // Status Bar
170
- // -----------------------------
171
- // abstract renderStatusBar(): RenderStatusType | null;
172
- // private registerStatusBar(): void {
173
- // const arg = this.renderStatusBar();
174
- // if (!arg) return;
175
- // const { onClick, ...rest } = arg;
176
- // if (arg) {
177
- // this.sendMessage({
178
- // type: `status`,
179
- // arg: rest,
180
- // });
181
- // this.off("status-click");
182
- // this.registerSubscription("status-click", onClick);
183
- // }
184
- // }
185
- // private onStatusLoad(): void {
186
- // this.registerHandler("status-load", () => {
187
- // return this.renderStatusBar();
188
- // });
189
- // }
171
+ registerStatus() {
172
+ const arg = _optionalChain([this, 'access', _7 => _7.renderStatusBar, 'optionalCall', _8 => _8()]);
173
+ if (!arg) return;
174
+ const { onClick, ...rest } = arg;
175
+ if (arg) {
176
+ this.sendMessage({
177
+ type: `status`,
178
+ arg: rest
179
+ });
180
+ this.off("status-click");
181
+ if (onClick) this.registerSubscription("status-click", onClick);
182
+ }
183
+ }
184
+ onStatusLoad() {
185
+ this.registerHandler("status-load", () => {
186
+ const statusBar = _optionalChain([this, 'access', _9 => _9.renderStatusBar, 'optionalCall', _10 => _10()]);
187
+ if (statusBar) {
188
+ const { onClick, ...rest } = statusBar;
189
+ if (onClick) {
190
+ this.registerSubscription("status-click", onClick);
191
+ }
192
+ return rest;
193
+ }
194
+ return null;
195
+ });
196
+ }
190
197
  // -----------------------------
191
198
  // State
192
199
  // -----------------------------
@@ -199,12 +206,12 @@ var Plugin = class {
199
206
  // -----------------------------
200
207
  // Logging
201
208
  // -----------------------------
202
- // protected notify(message: string): void {
203
- // this.sendMessage({
204
- // type: "notification",
205
- // arg: message,
206
- // });
207
- // }
209
+ log(message) {
210
+ this.sendMessage({
211
+ type: "log",
212
+ arg: message
213
+ });
214
+ }
208
215
  // -----------------------------
209
216
  // Utils
210
217
  // -----------------------------
package/dist/plugin.mjs CHANGED
@@ -58,8 +58,11 @@ var Plugin = class {
58
58
  this.eventIds = [];
59
59
  const sidebar = this.renderSidebar?.() || null;
60
60
  if (sidebar) this.render("sidebar", sidebar);
61
+ const status = this.renderStatusBar?.() || null;
62
+ if (status) this.registerStatus();
61
63
  });
62
64
  this.onSidebarLoad();
65
+ this.onStatusLoad();
63
66
  }
64
67
  // -----------------------------
65
68
  // Element Factory
@@ -165,28 +168,32 @@ var Plugin = class {
165
168
  on(event, callback) {
166
169
  this.registerSubscription(event, callback);
167
170
  }
168
- // -----------------------------
169
- // Status Bar
170
- // -----------------------------
171
- // abstract renderStatusBar(): RenderStatusType | null;
172
- // private registerStatusBar(): void {
173
- // const arg = this.renderStatusBar();
174
- // if (!arg) return;
175
- // const { onClick, ...rest } = arg;
176
- // if (arg) {
177
- // this.sendMessage({
178
- // type: `status`,
179
- // arg: rest,
180
- // });
181
- // this.off("status-click");
182
- // this.registerSubscription("status-click", onClick);
183
- // }
184
- // }
185
- // private onStatusLoad(): void {
186
- // this.registerHandler("status-load", () => {
187
- // return this.renderStatusBar();
188
- // });
189
- // }
171
+ registerStatus() {
172
+ const arg = this.renderStatusBar?.();
173
+ if (!arg) return;
174
+ const { onClick, ...rest } = arg;
175
+ if (arg) {
176
+ this.sendMessage({
177
+ type: `status`,
178
+ arg: rest
179
+ });
180
+ this.off("status-click");
181
+ if (onClick) this.registerSubscription("status-click", onClick);
182
+ }
183
+ }
184
+ onStatusLoad() {
185
+ this.registerHandler("status-load", () => {
186
+ const statusBar = this.renderStatusBar?.();
187
+ if (statusBar) {
188
+ const { onClick, ...rest } = statusBar;
189
+ if (onClick) {
190
+ this.registerSubscription("status-click", onClick);
191
+ }
192
+ return rest;
193
+ }
194
+ return null;
195
+ });
196
+ }
190
197
  // -----------------------------
191
198
  // State
192
199
  // -----------------------------
@@ -199,12 +206,12 @@ var Plugin = class {
199
206
  // -----------------------------
200
207
  // Logging
201
208
  // -----------------------------
202
- // protected notify(message: string): void {
203
- // this.sendMessage({
204
- // type: "notification",
205
- // arg: message,
206
- // });
207
- // }
209
+ log(message) {
210
+ this.sendMessage({
211
+ type: "log",
212
+ arg: message
213
+ });
214
+ }
208
215
  // -----------------------------
209
216
  // Utils
210
217
  // -----------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bb-relay",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "description": "For managing bb-editor extension",
5
5
  "license": "ISC",
6
6
  "author": "Ade Adeola",
@@ -1,17 +1,13 @@
1
1
  import { IconName } from "lucide-react/dynamic";
2
2
 
3
- export type StatusElement =
4
- | {
5
- type: "icon";
6
- icon: IconName;
7
- }
8
- | {
9
- type: "text";
10
- text: string;
11
- };
3
+ export type StatusElement = {
4
+ iconLeft?: IconName;
5
+ iconRight?: IconName;
6
+ message?: string;
7
+ text?: string;
8
+ };
12
9
 
13
10
  export type RenderStatusType = {
14
11
  element: StatusElement[];
15
- message: string;
16
- onClick: () => void;
12
+ onClick?: () => void;
17
13
  };
@@ -11,6 +11,7 @@ import {
11
11
  } from "@/editor";
12
12
  import { Project } from "@/database";
13
13
  import equal from "fast-deep-equal";
14
+ import { RenderStatusType } from "./RenderStatusType";
14
15
 
15
16
  export type Store<T extends Record<string, unknown>> = {
16
17
  get(): T;
@@ -130,9 +131,12 @@ export abstract class Plugin<T extends Record<string, unknown>> {
130
131
  this.eventIds = [];
131
132
  const sidebar = this.renderSidebar?.() || null;
132
133
  if (sidebar) this.render("sidebar", sidebar);
134
+ const status = this.renderStatusBar?.() || null;
135
+ if (status) this.registerStatus();
133
136
  });
134
137
 
135
138
  this.onSidebarLoad();
139
+ this.onStatusLoad();
136
140
  }
137
141
 
138
142
  // -----------------------------
@@ -348,27 +352,35 @@ export abstract class Plugin<T extends Record<string, unknown>> {
348
352
  // Status Bar
349
353
  // -----------------------------
350
354
 
351
- // abstract renderStatusBar(): RenderStatusType | null;
352
-
353
- // private registerStatusBar(): void {
354
- // const arg = this.renderStatusBar();
355
- // if (!arg) return;
356
- // const { onClick, ...rest } = arg;
357
- // if (arg) {
358
- // this.sendMessage({
359
- // type: `status`,
360
- // arg: rest,
361
- // });
362
- // this.off("status-click");
363
- // this.registerSubscription("status-click", onClick);
364
- // }
365
- // }
366
-
367
- // private onStatusLoad(): void {
368
- // this.registerHandler("status-load", () => {
369
- // return this.renderStatusBar();
370
- // });
371
- // }
355
+ renderStatusBar?(): RenderStatusType | null;
356
+
357
+ private registerStatus(): void {
358
+ const arg = this.renderStatusBar?.();
359
+ if (!arg) return;
360
+ const { onClick, ...rest } = arg;
361
+ if (arg) {
362
+ this.sendMessage({
363
+ type: `status`,
364
+ arg: rest,
365
+ });
366
+ this.off("status-click");
367
+ if (onClick) this.registerSubscription("status-click", onClick);
368
+ }
369
+ }
370
+
371
+ private onStatusLoad(): void {
372
+ this.registerHandler("status-load", () => {
373
+ const statusBar = this.renderStatusBar?.();
374
+ if (statusBar) {
375
+ const { onClick, ...rest } = statusBar;
376
+ if (onClick) {
377
+ this.registerSubscription("status-click", onClick);
378
+ }
379
+ return rest;
380
+ }
381
+ return null;
382
+ });
383
+ }
372
384
 
373
385
  // -----------------------------
374
386
  // State
@@ -386,12 +398,12 @@ export abstract class Plugin<T extends Record<string, unknown>> {
386
398
  // Logging
387
399
  // -----------------------------
388
400
 
389
- // protected notify(message: string): void {
390
- // this.sendMessage({
391
- // type: "notification",
392
- // arg: message,
393
- // });
394
- // }
401
+ protected log(message: string): void {
402
+ this.sendMessage({
403
+ type: "log",
404
+ arg: message,
405
+ });
406
+ }
395
407
 
396
408
  // -----------------------------
397
409
  // Utils
@@ -57,6 +57,10 @@ const validateManifest = (manifestContent: string) => {
57
57
  }
58
58
  }
59
59
 
60
+ if (content.status) {
61
+ fileChecks.push(content.status);
62
+ }
63
+
60
64
  if (content.iconsPath) {
61
65
  fileChecks.push(content.iconsPath + "/bb.png");
62
66
  }
@@ -34,4 +34,5 @@ export type Manifest = {
34
34
  repository?: string;
35
35
  theme?: string;
36
36
  [key: string]: unknown;
37
+ status?: string;
37
38
  };
@@ -1,81 +0,0 @@
1
- import { Plugin } from ".";
2
- import { RenderStatusType } from "./RenderStatusType";
3
-
4
- const templateGenerator = () => {
5
- return [
6
- {
7
- path: "chapters/chapter 1.md",
8
- content: "# Chapter 1 \n The content of your book",
9
- },
10
- {
11
- path: "characters/main/Jane Doe.md",
12
- content: "# Jane Doe \n The central characters in your story",
13
- },
14
- {
15
- path: "characters/secondary/John Doe.md",
16
- content: "# John Doe \n The supporting characters in your story",
17
- },
18
- {
19
- path: "characters/tertiary/Tom Dick Harry.md",
20
- content: "# Tom Dick Harry \n Background characters in your story",
21
- },
22
- {
23
- path: "location/House.md",
24
- content: "Places where certain events take place",
25
- },
26
- {
27
- path: "scene/assassination.md",
28
- content: "Combination of location and event/action",
29
- },
30
- ];
31
- };
32
-
33
- export class ExtPlugin extends Plugin {
34
- init(): Promise<void> | void {
35
- console.log("hello");
36
- this.subscribe("project-selected", (arg) => {
37
- console.log(arg.id, arg.workingDir);
38
- });
39
- this.subscribe("file-selected", (path) => {
40
- console.log(path);
41
- });
42
- this.subscribe("new-project", (arg) => {
43
- const workingDir = arg.workingDir;
44
- const fs = this.editor?.fs!;
45
- templateGenerator().forEach(async (file) => {
46
- await fs.writeFile({
47
- path: `${workingDir}/${file.path}`,
48
- content: file.content,
49
- type: "utf8",
50
- });
51
- });
52
- });
53
- }
54
-
55
- renderSidebar() {
56
- return this.element.button({
57
- style: {
58
- color: "red",
59
- },
60
- label: "Hello world",
61
- onClick: () => {
62
- console.log("Hello world");
63
- },
64
- });
65
- }
66
-
67
- renderStatusBar(): RenderStatusType {
68
- return {
69
- element: [
70
- {
71
- type: "text",
72
- text: "Hello world",
73
- },
74
- ],
75
- message: "Hello world",
76
- onClick: () => {
77
- console.log("Hello world");
78
- },
79
- };
80
- }
81
- }