bb-relay 0.0.1

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 (100) hide show
  1. package/.husky/pre-commit +1 -0
  2. package/README.md +47 -0
  3. package/dist/chunk-S47CVTVK.mjs +33 -0
  4. package/dist/chunk-UJCSKKID.mjs +30 -0
  5. package/dist/dev.d.mts +11 -0
  6. package/dist/dev.d.ts +11 -0
  7. package/dist/dev.js +5028 -0
  8. package/dist/dev.mjs +4991 -0
  9. package/dist/index.d.mts +666 -0
  10. package/dist/index.d.ts +666 -0
  11. package/dist/index.js +405 -0
  12. package/dist/index.mjs +376 -0
  13. package/eslint.config.mts +19 -0
  14. package/jest.config.js +11 -0
  15. package/package.json +60 -0
  16. package/src/dev.ts +4 -0
  17. package/src/index.ts +72 -0
  18. package/src/load-virtual-editor/app/StatusState.ts +6 -0
  19. package/src/load-virtual-editor/app/css.ts +154 -0
  20. package/src/load-virtual-editor/app/store.ts +25 -0
  21. package/src/load-virtual-editor/events/handle-dir-update.ts +23 -0
  22. package/src/load-virtual-editor/events/handle-file-update.ts +23 -0
  23. package/src/load-virtual-editor/events/handle-load.ts +39 -0
  24. package/src/load-virtual-editor/events/handle-selected.ts +30 -0
  25. package/src/load-virtual-editor/index.ts +52 -0
  26. package/src/load-virtual-editor/lib/indexedStorage.ts +28 -0
  27. package/src/load-virtual-editor/mocks/generate-files.ts +25 -0
  28. package/src/load-virtual-editor/node/NodeState.ts +23 -0
  29. package/src/load-virtual-editor/node/copyDir.ts +14 -0
  30. package/src/load-virtual-editor/node/copyFile.ts +14 -0
  31. package/src/load-virtual-editor/node/createDir.ts +10 -0
  32. package/src/load-virtual-editor/node/createFile.ts +13 -0
  33. package/src/load-virtual-editor/node/deleteDir.ts +10 -0
  34. package/src/load-virtual-editor/node/deleteFile.ts +13 -0
  35. package/src/load-virtual-editor/node/formatPath.ts +13 -0
  36. package/src/load-virtual-editor/node/formatText.ts +19 -0
  37. package/src/load-virtual-editor/node/generateDirs.ts +13 -0
  38. package/src/load-virtual-editor/node/getDescendantLevel.ts +9 -0
  39. package/src/load-virtual-editor/node/getDirInfo.ts +33 -0
  40. package/src/load-virtual-editor/node/getFileInfo.ts +31 -0
  41. package/src/load-virtual-editor/node/getFiles.ts +17 -0
  42. package/src/load-virtual-editor/node/getParent.ts +11 -0
  43. package/src/load-virtual-editor/node/readDir.ts +41 -0
  44. package/src/load-virtual-editor/node/readFile.ts +46 -0
  45. package/src/load-virtual-editor/node/store.ts +206 -0
  46. package/src/load-virtual-editor/node/watch.ts +9 -0
  47. package/src/load-virtual-editor/node/writeFile.ts +21 -0
  48. package/src/load-virtual-editor/postResponse.ts +21 -0
  49. package/src/load-virtual-editor/request/requestFS.ts +199 -0
  50. package/src/load-virtual-editor/request/requestSelected.ts +45 -0
  51. package/src/load-virtual-editor/selected/SelectedState.ts +7 -0
  52. package/src/load-virtual-editor/selected/selectDir.ts +13 -0
  53. package/src/load-virtual-editor/selected/selectFile.ts +13 -0
  54. package/src/load-virtual-editor/selected/store.ts +27 -0
  55. package/src/load-virtual-editor/selected/watch.ts +9 -0
  56. package/src/locales/en-GB.ts +117 -0
  57. package/src/locales/fr-FR.ts +125 -0
  58. package/src/relay/index.ts +89 -0
  59. package/src/relay/registerEvent.ts +16 -0
  60. package/src/relay/registerRequest.ts +16 -0
  61. package/src/relay/storage-bridge.ts +71 -0
  62. package/src/types/BBEvent.ts +51 -0
  63. package/src/types/BBRequest.ts +8 -0
  64. package/src/types/Checkpoint.ts +11 -0
  65. package/src/types/CopyArg.ts +6 -0
  66. package/src/types/DirectoryContents.ts +4 -0
  67. package/src/types/DirectoryStats.ts +4 -0
  68. package/src/types/EventParam.ts +8 -0
  69. package/src/types/EventReturn.ts +9 -0
  70. package/src/types/FileContent.ts +9 -0
  71. package/src/types/GitFileStatus.ts +5 -0
  72. package/src/types/IconArg.ts +6 -0
  73. package/src/types/Language.ts +5 -0
  74. package/src/types/Locale.ts +3 -0
  75. package/src/types/MenuContent.ts +10 -0
  76. package/src/types/Nav.ts +3 -0
  77. package/src/types/PluginItem.ts +14 -0
  78. package/src/types/RenameType.ts +4 -0
  79. package/src/types/RequestParam.ts +9 -0
  80. package/src/types/RequestReturn.ts +11 -0
  81. package/src/types/Result.ts +6 -0
  82. package/src/types/Route.ts +1 -0
  83. package/src/types/Settings.ts +7 -0
  84. package/src/types/TutorialHeader.ts +10 -0
  85. package/src/types/User.ts +9 -0
  86. package/src/types/WatchFSEvent.ts +1 -0
  87. package/src/types/database.types.ts +266 -0
  88. package/src/types/dir/DirInfo.ts +10 -0
  89. package/src/types/dir/index.ts +32 -0
  90. package/src/types/files/FileInfo.ts +12 -0
  91. package/src/types/files/FileTypes.ts +13 -0
  92. package/src/types/files/ReadFile.ts +17 -0
  93. package/src/types/files/index.ts +31 -0
  94. package/src/types/project/Project.ts +35 -0
  95. package/src/types/project/index.ts +11 -0
  96. package/src/types/status/Load.ts +16 -0
  97. package/src/types/storage/index.ts +11 -0
  98. package/src/utils/inject-styles.ts +13 -0
  99. package/tsconfig.json +20 -0
  100. package/tsup.config.ts +16 -0
@@ -0,0 +1,10 @@
1
+ export interface TutorialHeader {
2
+ slug: string
3
+ title: string
4
+ tags: string[]
5
+ order: number | null
6
+ date: string | null
7
+ excerpt: string
8
+ filePath: string
9
+ body: string
10
+ }
@@ -0,0 +1,9 @@
1
+ export type User = {
2
+ id: string
3
+ name: string
4
+ email: string
5
+ bio: string
6
+ avatar: string
7
+ createdAt: string
8
+ updatedAt: string
9
+ }
@@ -0,0 +1 @@
1
+ export type WatchFSEvent = "updated" | "deleted"
@@ -0,0 +1,266 @@
1
+ export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[]
2
+
3
+ export type Database = {
4
+ // Allows to automatically instantiate createClient with right options
5
+ // instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
6
+ __InternalSupabase: {
7
+ PostgrestVersion: "13.0.4"
8
+ }
9
+ public: {
10
+ Tables: {
11
+ plugin_versions: {
12
+ Row: {
13
+ archived: boolean
14
+ created_at: string
15
+ id: number
16
+ plugin_id: number
17
+ release_note: string
18
+ size: number
19
+ stage: Database["public"]["Enums"]["version_stage"]
20
+ updated_at: string
21
+ version: string
22
+ }
23
+ Insert: {
24
+ archived?: boolean
25
+ created_at?: string
26
+ id?: number
27
+ plugin_id: number
28
+ release_note: string
29
+ size?: number
30
+ stage?: Database["public"]["Enums"]["version_stage"]
31
+ updated_at?: string
32
+ version: string
33
+ }
34
+ Update: {
35
+ archived?: boolean
36
+ created_at?: string
37
+ id?: number
38
+ plugin_id?: number
39
+ release_note?: string
40
+ size?: number
41
+ stage?: Database["public"]["Enums"]["version_stage"]
42
+ updated_at?: string
43
+ version?: string
44
+ }
45
+ Relationships: [
46
+ {
47
+ foreignKeyName: "plugin_versions_plugin_id_fkey"
48
+ columns: ["plugin_id"]
49
+ isOneToOne: false
50
+ referencedRelation: "plugins"
51
+ referencedColumns: ["id"]
52
+ }
53
+ ]
54
+ }
55
+ plugins: {
56
+ Row: {
57
+ author_id: string
58
+ categories: string[] | null
59
+ created_at: string
60
+ description: string | null
61
+ homepage: string | null
62
+ id: number
63
+ key: string
64
+ name: string | null
65
+ npm_package: string | null
66
+ updated_at: string
67
+ }
68
+ Insert: {
69
+ author_id?: string
70
+ categories?: string[] | null
71
+ created_at?: string
72
+ description?: string | null
73
+ homepage?: string | null
74
+ id?: number
75
+ key?: string
76
+ name?: string | null
77
+ npm_package?: string | null
78
+ updated_at?: string
79
+ }
80
+ Update: {
81
+ author_id?: string
82
+ categories?: string[] | null
83
+ created_at?: string
84
+ description?: string | null
85
+ homepage?: string | null
86
+ id?: number
87
+ key?: string
88
+ name?: string | null
89
+ npm_package?: string | null
90
+ updated_at?: string
91
+ }
92
+ Relationships: [
93
+ {
94
+ foreignKeyName: "plugins_author_id_fkey"
95
+ columns: ["author_id"]
96
+ isOneToOne: false
97
+ referencedRelation: "profiles"
98
+ referencedColumns: ["id"]
99
+ }
100
+ ]
101
+ }
102
+ profiles: {
103
+ Row: {
104
+ avatar_url: string | null
105
+ full_name: string | null
106
+ id: string
107
+ updated_at: string | null
108
+ username: string | null
109
+ website: string | null
110
+ }
111
+ Insert: {
112
+ avatar_url?: string | null
113
+ full_name?: string | null
114
+ id: string
115
+ updated_at?: string | null
116
+ username?: string | null
117
+ website?: string | null
118
+ }
119
+ Update: {
120
+ avatar_url?: string | null
121
+ full_name?: string | null
122
+ id?: string
123
+ updated_at?: string | null
124
+ username?: string | null
125
+ website?: string | null
126
+ }
127
+ Relationships: []
128
+ }
129
+ }
130
+ Views: {
131
+ [_ in never]: never
132
+ }
133
+ Functions: {
134
+ [_ in never]: never
135
+ }
136
+ Enums: {
137
+ version_stage: "DRAFT" | "ALPHA" | "BETA" | "PROD"
138
+ }
139
+ CompositeTypes: {
140
+ [_ in never]: never
141
+ }
142
+ }
143
+ }
144
+
145
+ type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">
146
+
147
+ type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">]
148
+
149
+ export type Tables<
150
+ DefaultSchemaTableNameOrOptions extends
151
+ | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
152
+ | { schema: keyof DatabaseWithoutInternals },
153
+ TableName extends DefaultSchemaTableNameOrOptions extends {
154
+ schema: keyof DatabaseWithoutInternals
155
+ }
156
+ ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
157
+ DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
158
+ : never = never
159
+ > = DefaultSchemaTableNameOrOptions extends {
160
+ schema: keyof DatabaseWithoutInternals
161
+ }
162
+ ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
163
+ DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
164
+ Row: infer R
165
+ }
166
+ ? R
167
+ : never
168
+ : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
169
+ ? (DefaultSchema["Tables"] & DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
170
+ Row: infer R
171
+ }
172
+ ? R
173
+ : never
174
+ : never
175
+
176
+ export type TablesInsert<
177
+ DefaultSchemaTableNameOrOptions extends
178
+ | keyof DefaultSchema["Tables"]
179
+ | { schema: keyof DatabaseWithoutInternals },
180
+ TableName extends DefaultSchemaTableNameOrOptions extends {
181
+ schema: keyof DatabaseWithoutInternals
182
+ }
183
+ ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
184
+ : never = never
185
+ > = DefaultSchemaTableNameOrOptions extends {
186
+ schema: keyof DatabaseWithoutInternals
187
+ }
188
+ ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
189
+ Insert: infer I
190
+ }
191
+ ? I
192
+ : never
193
+ : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
194
+ ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
195
+ Insert: infer I
196
+ }
197
+ ? I
198
+ : never
199
+ : never
200
+
201
+ export type TablesUpdate<
202
+ DefaultSchemaTableNameOrOptions extends
203
+ | keyof DefaultSchema["Tables"]
204
+ | { schema: keyof DatabaseWithoutInternals },
205
+ TableName extends DefaultSchemaTableNameOrOptions extends {
206
+ schema: keyof DatabaseWithoutInternals
207
+ }
208
+ ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
209
+ : never = never
210
+ > = DefaultSchemaTableNameOrOptions extends {
211
+ schema: keyof DatabaseWithoutInternals
212
+ }
213
+ ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
214
+ Update: infer U
215
+ }
216
+ ? U
217
+ : never
218
+ : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
219
+ ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
220
+ Update: infer U
221
+ }
222
+ ? U
223
+ : never
224
+ : never
225
+
226
+ export type Enums<
227
+ DefaultSchemaEnumNameOrOptions extends
228
+ | keyof DefaultSchema["Enums"]
229
+ | { schema: keyof DatabaseWithoutInternals },
230
+ EnumName extends DefaultSchemaEnumNameOrOptions extends {
231
+ schema: keyof DatabaseWithoutInternals
232
+ }
233
+ ? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
234
+ : never = never
235
+ > = DefaultSchemaEnumNameOrOptions extends {
236
+ schema: keyof DatabaseWithoutInternals
237
+ }
238
+ ? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
239
+ : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
240
+ ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
241
+ : never
242
+
243
+ export type CompositeTypes<
244
+ PublicCompositeTypeNameOrOptions extends
245
+ | keyof DefaultSchema["CompositeTypes"]
246
+ | { schema: keyof DatabaseWithoutInternals },
247
+ CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
248
+ schema: keyof DatabaseWithoutInternals
249
+ }
250
+ ? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
251
+ : never = never
252
+ > = PublicCompositeTypeNameOrOptions extends {
253
+ schema: keyof DatabaseWithoutInternals
254
+ }
255
+ ? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
256
+ : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
257
+ ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
258
+ : never
259
+
260
+ export const Constants = {
261
+ public: {
262
+ Enums: {
263
+ version_stage: ["DRAFT", "ALPHA", "BETA", "PROD"]
264
+ }
265
+ }
266
+ } as const
@@ -0,0 +1,10 @@
1
+ type DirInfo = {
2
+ name: string;
3
+ fullPath: string;
4
+ createdAt: string;
5
+ modifiedAt: string;
6
+ fsCount: number;
7
+ size: number;
8
+ };
9
+
10
+ export default DirInfo;
@@ -0,0 +1,32 @@
1
+ import DirInfo from "./DirInfo";
2
+
3
+ export type DirRequests = {
4
+ "create-dir": {
5
+ args: { path: string };
6
+ response: null;
7
+ };
8
+ "read-dir": {
9
+ args: { path: string };
10
+ response: { path: string; type: "file" | "dir" }[];
11
+ };
12
+ "get-files": {
13
+ args: { path: string };
14
+ response: string[];
15
+ };
16
+ "get-dir-info": {
17
+ args: { path: string };
18
+ response: DirInfo;
19
+ };
20
+ "copy-dir": {
21
+ args: { source: string; destination: string };
22
+ response: null;
23
+ };
24
+ "delete-dir": {
25
+ args: { path: string };
26
+ response: null;
27
+ };
28
+ "select-dir": {
29
+ args: { path: string };
30
+ response: null;
31
+ };
32
+ };
@@ -0,0 +1,12 @@
1
+ type FileInfo = {
2
+ name: string;
3
+ fullPath: string;
4
+ createdAt: string;
5
+ modifiedAt: string;
6
+ ext: string;
7
+ size: number;
8
+ wordCount: number;
9
+ summary: string;
10
+ };
11
+
12
+ export default FileInfo;
@@ -0,0 +1,13 @@
1
+ export type BinaryFile = {
2
+ path: string;
3
+ type: "binary";
4
+ content: Uint8Array;
5
+ };
6
+
7
+ export type TextFile = {
8
+ path: string;
9
+ type: "text";
10
+ content: string;
11
+ };
12
+
13
+ export type FileType = TextFile | BinaryFile;
@@ -0,0 +1,17 @@
1
+ import { BinaryFile, TextFile } from "./FileTypes";
2
+
3
+ export type ReadFile =
4
+ | {
5
+ args: {
6
+ path: string;
7
+ type: "text";
8
+ };
9
+ response: TextFile;
10
+ }
11
+ | {
12
+ args: {
13
+ path: string;
14
+ type: "binary";
15
+ };
16
+ response: BinaryFile;
17
+ };
@@ -0,0 +1,31 @@
1
+ import { FileInfo } from "@/index";
2
+ import { ReadFile } from "./ReadFile";
3
+ import { BinaryFile, TextFile } from "./FileTypes";
4
+
5
+ export type FileRequests = {
6
+ "create-file": {
7
+ args: { path: string };
8
+ response: null;
9
+ };
10
+ "copy-file": {
11
+ args: { source: string; destination: string };
12
+ response: null;
13
+ };
14
+ "read-file": ReadFile;
15
+ stat: {
16
+ args: { path: string };
17
+ response: FileInfo;
18
+ };
19
+ "write-file": {
20
+ args: TextFile | BinaryFile;
21
+ response: null;
22
+ };
23
+ "delete-file": {
24
+ args: { path: string };
25
+ response: null;
26
+ };
27
+ "select-file": {
28
+ args: { path: string };
29
+ response: null;
30
+ };
31
+ };
@@ -0,0 +1,35 @@
1
+ export type Category =
2
+ | "Action"
3
+ | "Adventure"
4
+ | "ChickLit"
5
+ | "Comedy"
6
+ | "Drama"
7
+ | "FanFiction"
8
+ | "Fantasy"
9
+ | "Horror"
10
+ | "Mystery / Thriller"
11
+ | "Parody"
12
+ | "Poetry"
13
+ | "Romance"
14
+ | "SciFi"
15
+ | "Thriller"
16
+ | "Western"
17
+ | "Historical Fiction"
18
+ | "No Fiction"
19
+ | "Paranormal"
20
+ | "Adult"
21
+ | "Short story"
22
+ | "Spiritual"
23
+ | "Other";
24
+
25
+ export default interface Project {
26
+ title: string;
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ lastAccessedAt: string;
30
+ remoteId?: string;
31
+ tags?: string[];
32
+ category?: Category;
33
+ description?: string;
34
+ genre?: string | null;
35
+ }
@@ -0,0 +1,11 @@
1
+ type ProjectRequest = {
2
+ "update-project": {
3
+ args: {
4
+ name: string;
5
+ description: string;
6
+ };
7
+ response: null;
8
+ };
9
+ };
10
+
11
+ export default ProjectRequest;
@@ -0,0 +1,16 @@
1
+ type Load = {
2
+ /**
3
+ * Whether the app is in dark mode or not
4
+ */
5
+ mode: "dark" | "light";
6
+ /**
7
+ * The CSS to be applied to the app
8
+ */
9
+ css: string;
10
+ /**
11
+ * The language of the app e.g. en, en-gb
12
+ */
13
+ language: string;
14
+ };
15
+
16
+ export default Load;
@@ -0,0 +1,11 @@
1
+ export type StorageRequests = {
2
+ "sync-storage": {
3
+ args: { data: Record<string, string> };
4
+ response: null;
5
+ };
6
+
7
+ "load-storage": {
8
+ args: null;
9
+ response: Record<string, string>;
10
+ };
11
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This is the function to inject styles to the iframe from the parent window
3
+ * @param css the css styles from parent window
4
+ * @returns function to remove the injected styles
5
+ */
6
+ export default function injectStyles(css: string) {
7
+ const style = document.createElement("style");
8
+ style.textContent = css;
9
+ document.head.appendChild(style);
10
+ return () => {
11
+ document.head.removeChild(style);
12
+ };
13
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "@electron-toolkit/tsconfig/tsconfig.web.json",
3
+ "compilerOptions": {
4
+ "target": "ES2020",
5
+ "module": "ESNext",
6
+ "declaration": true,
7
+ "outDir": "dist",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "moduleResolution": "node",
11
+ "resolveJsonModule": true,
12
+ "isolatedModules": true,
13
+ "skipLibCheck": true,
14
+ "baseUrl": ".",
15
+ "paths": {
16
+ "@/*": ["./src/*"]
17
+ }
18
+ },
19
+ "include": ["src"]
20
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { defineConfig } from "tsup";
2
+ import cssModulesPlugin from "esbuild-css-modules-plugin";
3
+
4
+ export default defineConfig({
5
+ entry: {
6
+ index: "src/index.ts",
7
+ dev: "src/dev.ts",
8
+ },
9
+ format: ["esm", "cjs"],
10
+ dts: true,
11
+ outDir: "dist",
12
+ plugins: [cssModulesPlugin()],
13
+ loader: {
14
+ ".css": "css",
15
+ },
16
+ });