orgnote-api 0.40.23 → 0.40.26

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/api.d.ts CHANGED
@@ -3,6 +3,8 @@ import { WebSocketClient } from './websocket/client.js';
3
3
  import { WidgetType } from './models/widget-type.js';
4
4
  import { NodeType } from 'org-mode-ast';
5
5
  import { ExtensionStoreDefinition } from './models/extension-store.js';
6
+ import { EditorStoreDefinition } from './models/editor-store.js';
7
+ import { BabelStoreDefinition } from './models/babel-store.js';
6
8
  import { FileSystemStoreDefinition } from './models/file-system-store.js';
7
9
  import { EncryptionStoreDefinition } from './models/encryption-store.js';
8
10
  import { PlatformSpecificFn } from './models/platform-specific.js';
@@ -67,6 +69,8 @@ export interface OrgNoteApi {
67
69
  useFileGuard: FileGuardStoreDefinition;
68
70
  useAuth: AuthStoreDefinition;
69
71
  useSync: SyncStoreDefinition;
72
+ useEditor: EditorStoreDefinition;
73
+ useBabel: BabelStoreDefinition;
70
74
  app: App;
71
75
  };
72
76
  utils: {
@@ -49,6 +49,7 @@ export declare enum i18n {
49
49
  CANCEL = "cancel",
50
50
  CONFIRM_DELETE_ALL_DATA = "are you sure you want to delete all data? this is an irreversible event",
51
51
  RESET_SYSTEM = "Reset system",
52
+ RESET_SYSTEM_WARNING = "A local reset will result in complete local data deletion. Be careful: if there is no backup, it\u2019s impossible to restore the data.",
52
53
  RESET_SYSTEM_DESCRIPTION = "Delete all local data, including notes, files, account information, settings, etc.",
53
54
  IRREVERSIBLE_EVENT = "This is an irreversible event",
54
55
  CONFIRM_DELETE_NOTES = "Are you sure you want to delete all notes? This is an irreversible event",
@@ -134,6 +135,8 @@ export declare enum i18n {
134
135
  CONFIRM_CLEAR_LOGS = "confirm clear logs",
135
136
  SYSTEM_INFO = "system info",
136
137
  FILE_DELETED_EXTERNALLY = "file was deleted externally",
138
+ IMAGE_LOAD_FAILED = "failed to load image",
139
+ IMAGE_NOT_FOUND = "image not found",
137
140
  USED_SPACE = "used space",
138
141
  STORAGE = "storage",
139
142
  AUTHENTICATION_STATUS = "authentication status",
@@ -188,7 +191,6 @@ export declare const I18N: {
188
191
  SPONSOR: DefaultCommands.SPONSOR;
189
192
  DELETE_ALL_DATA: DefaultCommands.DELETE_ALL_DATA;
190
193
  RESET_SYSTEM: DefaultCommands.RESET_SYSTEM;
191
- RESET_SYSTEM_WARNING: DefaultCommands.RESET_SYSTEM_WARNING;
192
194
  DELETE_ALL_NOTES: DefaultCommands.DELETE_ALL_NOTES;
193
195
  DELETE_ACCOUNT: DefaultCommands.DELETE_ACCOUNT;
194
196
  STORAGE_SETTINGS: DefaultCommands.STORAGE_SETTINGS;
@@ -212,7 +214,6 @@ export declare const I18N: {
212
214
  CONFIRM_FILE_DELETION: DefaultCommands.CONFIRM_FILE_DELETION;
213
215
  NEW_FILE_PATH: DefaultCommands.NEW_FILE_PATH;
214
216
  OPEN_NOTE: DefaultCommands.OPEN_NOTE;
215
- OPEN_CODE_EDITOR: DefaultCommands.OPEN_CODE_EDITOR;
216
217
  TABS: DefaultCommands.TABS;
217
218
  SHOW_TAB_SWITCHER: DefaultCommands.SHOW_TAB_SWITCHER;
218
219
  CLOSE_TAB: DefaultCommands.CLOSE_TAB;
@@ -279,6 +280,7 @@ export declare const I18N: {
279
280
  CONFIRM: i18n.CONFIRM;
280
281
  CANCEL: i18n.CANCEL;
281
282
  CONFIRM_DELETE_ALL_DATA: i18n.CONFIRM_DELETE_ALL_DATA;
283
+ RESET_SYSTEM_WARNING: i18n.RESET_SYSTEM_WARNING;
282
284
  RESET_SYSTEM_DESCRIPTION: i18n.RESET_SYSTEM_DESCRIPTION;
283
285
  IRREVERSIBLE_EVENT: i18n.IRREVERSIBLE_EVENT;
284
286
  CONFIRM_DELETE_NOTES: i18n.CONFIRM_DELETE_NOTES;
@@ -360,6 +362,8 @@ export declare const I18N: {
360
362
  CONFIRM_CLEAR_LOGS: i18n.CONFIRM_CLEAR_LOGS;
361
363
  SYSTEM_INFO: i18n.SYSTEM_INFO;
362
364
  FILE_DELETED_EXTERNALLY: i18n.FILE_DELETED_EXTERNALLY;
365
+ IMAGE_LOAD_FAILED: i18n.IMAGE_LOAD_FAILED;
366
+ IMAGE_NOT_FOUND: i18n.IMAGE_NOT_FOUND;
363
367
  USED_SPACE: i18n.USED_SPACE;
364
368
  STORAGE: i18n.STORAGE;
365
369
  AUTHENTICATION_STATUS: i18n.AUTHENTICATION_STATUS;
@@ -50,6 +50,7 @@ export var i18n;
50
50
  i18n["CANCEL"] = "cancel";
51
51
  i18n["CONFIRM_DELETE_ALL_DATA"] = "are you sure you want to delete all data? this is an irreversible event";
52
52
  i18n["RESET_SYSTEM"] = "Reset system";
53
+ i18n["RESET_SYSTEM_WARNING"] = "A local reset will result in complete local data deletion. Be careful: if there is no backup, it\u2019s impossible to restore the data.";
53
54
  i18n["RESET_SYSTEM_DESCRIPTION"] = "Delete all local data, including notes, files, account information, settings, etc.";
54
55
  i18n["IRREVERSIBLE_EVENT"] = "This is an irreversible event";
55
56
  i18n["CONFIRM_DELETE_NOTES"] = "Are you sure you want to delete all notes? This is an irreversible event";
@@ -138,6 +139,9 @@ export var i18n;
138
139
  i18n["SYSTEM_INFO"] = "system info";
139
140
  // Buffer
140
141
  i18n["FILE_DELETED_EXTERNALLY"] = "file was deleted externally";
142
+ // Images
143
+ i18n["IMAGE_LOAD_FAILED"] = "failed to load image";
144
+ i18n["IMAGE_NOT_FOUND"] = "image not found";
141
145
  // Subscription limits
142
146
  i18n["USED_SPACE"] = "used space";
143
147
  i18n["STORAGE"] = "storage";
@@ -8,6 +8,7 @@ export declare enum RouteNames {
8
8
  UserGraph = "UserGraph",
9
9
  EditNote = "EditNote",
10
10
  EditCode = "EditCode",
11
+ File = "File",
11
12
  SettingsPage = "SettingsPage",
12
13
  SystemSettings = "SystemSettings",
13
14
  ExtensionsSettings = "ExtensionsSettings",
@@ -9,6 +9,7 @@ export var RouteNames;
9
9
  RouteNames["UserGraph"] = "UserGraph";
10
10
  RouteNames["EditNote"] = "EditNote";
11
11
  RouteNames["EditCode"] = "EditCode";
12
+ RouteNames["File"] = "File";
12
13
  RouteNames["SettingsPage"] = "SettingsPage";
13
14
  RouteNames["SystemSettings"] = "SystemSettings";
14
15
  RouteNames["ExtensionsSettings"] = "ExtensionsSettings";
@@ -0,0 +1,13 @@
1
+ import type { Ref } from 'vue';
2
+ import type { StoreDefinition } from './store.js';
3
+ export interface OrgBabel {
4
+ executor: (code: string) => Promise<string> | string;
5
+ languages?: string[];
6
+ }
7
+ export interface BabelStore {
8
+ orgBabels: Ref<Record<string, OrgBabel>>;
9
+ register: (babel: OrgBabel) => void;
10
+ unregister: (languages: string[]) => void;
11
+ execute: (lang: string, code: string) => Promise<string>;
12
+ }
13
+ export type BabelStoreDefinition = StoreDefinition<BabelStore>;
@@ -0,0 +1 @@
1
+ export {};
@@ -11,7 +11,10 @@ export interface BufferGuard {
11
11
  export interface Buffer<T = unknown> {
12
12
  path: string;
13
13
  title: string;
14
- content: string;
14
+ rawContent: Uint8Array;
15
+ readonly text: string;
16
+ readonly base64: string;
17
+ setText: (value: string) => void;
15
18
  isSaving: boolean;
16
19
  isLoading: boolean;
17
20
  encryptionStatus?: boolean;
@@ -1,6 +1,6 @@
1
1
  import type { Ref, UnwrapNestedRefs } from 'vue';
2
- import { OrgNoteConfig } from './orgnote-config.js';
3
- import { StoreDefinition } from './store.js';
2
+ import type { OrgNoteConfig } from './orgnote-config.js';
3
+ import type { StoreDefinition } from './store.js';
4
4
  export interface ConfigStore {
5
5
  config: UnwrapNestedRefs<OrgNoteConfig>;
6
6
  configErrors: Ref<string[]>;
@@ -35,7 +35,6 @@ export declare enum DefaultCommands {
35
35
  SPONSOR = "sponsor",
36
36
  DELETE_ALL_DATA = "delete all data",
37
37
  RESET_SYSTEM = "Reset system",
38
- RESET_SYSTEM_WARNING = "A local reset will result in complete local data deletion. Be careful: if there is no backup, it\u2019s impossible to restore the data.",
39
38
  DELETE_ALL_NOTES = "delete all notes",
40
39
  DELETE_ACCOUNT = "delete account",
41
40
  STORAGE_SETTINGS = "storage settings",
@@ -59,7 +58,6 @@ export declare enum DefaultCommands {
59
58
  CONFIRM_FILE_DELETION = "are you sure you want to delete file?",
60
59
  NEW_FILE_PATH = "new file path",
61
60
  OPEN_NOTE = "open note",
62
- OPEN_CODE_EDITOR = "open code editor",
63
61
  TABS = "show tabs",
64
62
  SHOW_TAB_SWITCHER = "show tab switcher",
65
63
  CLOSE_TAB = "close tab",
@@ -44,7 +44,6 @@ export var DefaultCommands;
44
44
  DefaultCommands["SPONSOR"] = "sponsor";
45
45
  DefaultCommands["DELETE_ALL_DATA"] = "delete all data";
46
46
  DefaultCommands["RESET_SYSTEM"] = "Reset system";
47
- DefaultCommands["RESET_SYSTEM_WARNING"] = "A local reset will result in complete local data deletion. Be careful: if there is no backup, it\u2019s impossible to restore the data.";
48
47
  DefaultCommands["DELETE_ALL_NOTES"] = "delete all notes";
49
48
  DefaultCommands["DELETE_ACCOUNT"] = "delete account";
50
49
  DefaultCommands["STORAGE_SETTINGS"] = "storage settings";
@@ -73,7 +72,6 @@ export var DefaultCommands;
73
72
  DefaultCommands["NEW_FILE_PATH"] = "new file path";
74
73
  // Notes commands
75
74
  DefaultCommands["OPEN_NOTE"] = "open note";
76
- DefaultCommands["OPEN_CODE_EDITOR"] = "open code editor";
77
75
  // Windows & buffers
78
76
  DefaultCommands["TABS"] = "show tabs";
79
77
  DefaultCommands["SHOW_TAB_SWITCHER"] = "show tab switcher";
@@ -0,0 +1,16 @@
1
+ import type { ComputedRef, ShallowRef } from 'vue';
2
+ import type { InlineEmbeddedWidgets, MultilineEmbeddedWidgets, OrgLineClasses } from './widget.js';
3
+ import type { EditorExtension } from './editor.js';
4
+ import type { WidgetMeta } from '../api.js';
5
+ import type { StoreDefinition } from './store.js';
6
+ export interface EditorStore {
7
+ inlineWidgets: ComputedRef<InlineEmbeddedWidgets>;
8
+ multilineWidgets: ComputedRef<MultilineEmbeddedWidgets>;
9
+ lineClasses: ComputedRef<OrgLineClasses>;
10
+ extensions: ShallowRef<EditorExtension[]>;
11
+ addWidgets: (...widgets: WidgetMeta[]) => void;
12
+ removeWidget: (widgetId: string) => void;
13
+ addExtensions: (...extensions: EditorExtension[]) => void;
14
+ removeExtensions: (...extensions: EditorExtension[]) => void;
15
+ }
16
+ export type EditorStoreDefinition = StoreDefinition<EditorStore>;
@@ -0,0 +1 @@
1
+ export {};
@@ -12,12 +12,12 @@ interface DynamicComponent {
12
12
  };
13
13
  }
14
14
  export interface EditorExtensionParams {
15
- orgNodeGetter: () => OrgNode;
15
+ orgNodeGetter: () => OrgNode | null;
16
16
  readonly: boolean;
17
17
  showSpecialSymbols?: boolean;
18
18
  dynamicComponent: DynamicComponent;
19
19
  foldWidget?: InlineEmbeddedWidget;
20
- editorViewGetter: () => EditorView;
20
+ editorViewGetter: () => EditorView | undefined;
21
21
  }
22
22
  export type EditorExtension = (params: EditorExtensionParams) => Extension;
23
23
  export {};
@@ -12,6 +12,9 @@ declare const GIT_SOURCE_SCHEMA: import("valibot").ObjectSchema<{
12
12
  declare const LOCAL_SOURCE_SCHEMA: import("valibot").ObjectSchema<{
13
13
  readonly type: import("valibot").LiteralSchema<"local", undefined>;
14
14
  }, undefined>;
15
+ declare const BUILTIN_SOURCE_SCHEMA: import("valibot").ObjectSchema<{
16
+ readonly type: import("valibot").LiteralSchema<"builtin", undefined>;
17
+ }, undefined>;
15
18
  declare const SOURCE_SCHEMA: import("valibot").UnionSchema<[import("valibot").ObjectSchema<{
16
19
  readonly type: import("valibot").LiteralSchema<"git", undefined>;
17
20
  readonly repo: import("valibot").StringSchema<undefined>;
@@ -19,6 +22,8 @@ declare const SOURCE_SCHEMA: import("valibot").UnionSchema<[import("valibot").Ob
19
22
  readonly tag: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
20
23
  }, undefined>, import("valibot").ObjectSchema<{
21
24
  readonly type: import("valibot").LiteralSchema<"local", undefined>;
25
+ }, undefined>, import("valibot").ObjectSchema<{
26
+ readonly type: import("valibot").LiteralSchema<"builtin", undefined>;
22
27
  }, undefined>], undefined>;
23
28
  declare const COMMAND_SCHEMA: import("valibot").ObjectSchema<{
24
29
  readonly id: import("valibot").StringSchema<undefined>;
@@ -41,6 +46,8 @@ export declare const EXTENSION_MANIFEST_SCHEMA: import("valibot").ObjectSchema<{
41
46
  readonly tag: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
42
47
  }, undefined>, import("valibot").ObjectSchema<{
43
48
  readonly type: import("valibot").LiteralSchema<"local", undefined>;
49
+ }, undefined>, import("valibot").ObjectSchema<{
50
+ readonly type: import("valibot").LiteralSchema<"builtin", undefined>;
44
51
  }, undefined>], undefined>;
45
52
  readonly author: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
46
53
  readonly description: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
@@ -81,6 +88,7 @@ export type ExtensionCategory = InferOutput<typeof CATEGORY_SCHEMA>;
81
88
  export type ExtensionSourceInfo = InferOutput<typeof SOURCE_SCHEMA>;
82
89
  export type GitSource = InferOutput<typeof GIT_SOURCE_SCHEMA>;
83
90
  export type LocalSource = InferOutput<typeof LOCAL_SOURCE_SCHEMA>;
91
+ export type BuiltinSource = InferOutput<typeof BUILTIN_SOURCE_SCHEMA>;
84
92
  export type ExtensionCommand = InferOutput<typeof COMMAND_SCHEMA>;
85
93
  export type ExtensionKeybinding = InferOutput<typeof KEYBINDING_SCHEMA>;
86
94
  export type ExtensionPlatform = InferOutput<typeof PLATFORM_SCHEMA>;
@@ -41,7 +41,10 @@ const GIT_SOURCE_SCHEMA = object({
41
41
  const LOCAL_SOURCE_SCHEMA = object({
42
42
  type: literal('local'),
43
43
  });
44
- const SOURCE_SCHEMA = union([GIT_SOURCE_SCHEMA, LOCAL_SOURCE_SCHEMA]);
44
+ const BUILTIN_SOURCE_SCHEMA = object({
45
+ type: literal('builtin'),
46
+ });
47
+ const SOURCE_SCHEMA = union([GIT_SOURCE_SCHEMA, LOCAL_SOURCE_SCHEMA, BUILTIN_SOURCE_SCHEMA]);
45
48
  const COMMAND_SCHEMA = object({
46
49
  id: string(),
47
50
  title: string(),
@@ -1,7 +1,22 @@
1
- import { StoreDefinition } from './store.js';
1
+ import type { Component } from 'vue';
2
+ import type { StoreDefinition } from './store.js';
3
+ export type FileReaderComponent = Component | (() => Promise<Component>);
4
+ export interface ReaderMeta {
5
+ id: string;
6
+ name: string;
7
+ icon?: string;
8
+ priority?: number;
9
+ }
10
+ export interface FileReaderEntry {
11
+ pattern: string;
12
+ component: FileReaderComponent;
13
+ meta: ReaderMeta;
14
+ }
2
15
  export interface FileReaderStore {
3
- addReader: (readerMatch: string, reader: (path: string) => Promise<void>) => void;
4
- addReaders: (readers: Record<string, (path: string) => Promise<void>>) => void;
16
+ register: (entry: FileReaderEntry) => void;
17
+ unregister: (readerId: string) => void;
18
+ getReaders: (path: string) => FileReaderEntry[];
19
+ getReader: (path: string) => FileReaderEntry | undefined;
5
20
  openFile: (path: string) => Promise<void>;
6
21
  }
7
22
  export type FileReaderStoreDefinition = StoreDefinition<FileReaderStore>;
package/models/index.d.ts CHANGED
@@ -61,6 +61,8 @@ export * from './panes-store.js';
61
61
  export * from './layout-store.js';
62
62
  export * from './file-system-manager-store.js';
63
63
  export * from './config-store.js';
64
+ export * from './editor-store.js';
65
+ export * from './babel-store.js';
64
66
  export * from './notifications-store.js';
65
67
  export * from './notification-config.js';
66
68
  export * from './buffer-store.js';
package/models/index.js CHANGED
@@ -63,6 +63,8 @@ export * from "./panes-store.js";
63
63
  export * from "./layout-store.js";
64
64
  export * from "./file-system-manager-store.js";
65
65
  export * from "./config-store.js";
66
+ export * from "./editor-store.js";
67
+ export * from "./babel-store.js";
66
68
  export * from "./notifications-store.js";
67
69
  export * from "./notification-config.js";
68
70
  export * from "./buffer-store.js";
@@ -34,6 +34,9 @@ export declare const ORG_NOTE_CONFIG_SCHEMA: import("valibot").SchemaWithPipe<re
34
34
  readonly persistantPanesSaveDelay: import("valibot").NumberSchema<undefined>;
35
35
  readonly dropZoneEdgeRatio: import("valibot").NumberSchema<undefined>;
36
36
  }, undefined>;
37
+ readonly fileReaders: import("valibot").OptionalSchema<import("valibot").ObjectSchema<{
38
+ readonly preferredReaders: import("valibot").OptionalSchema<import("valibot").ObjectWithRestSchema<{}, import("valibot").StringSchema<undefined>, undefined>, undefined>;
39
+ }, undefined>, undefined>;
37
40
  readonly extensions: import("valibot").ObjectSchema<{
38
41
  readonly sources: import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>;
39
42
  }, undefined>;
@@ -35,6 +35,9 @@ export const ORG_NOTE_CONFIG_SCHEMA = pipe(objectWithRest({
35
35
  persistantPanesSaveDelay: number(),
36
36
  dropZoneEdgeRatio: number(),
37
37
  }),
38
+ fileReaders: optional(object({
39
+ preferredReaders: optional(objectWithRest({}, string())),
40
+ })),
38
41
  extensions: object({
39
42
  sources: array(string()),
40
43
  }),
@@ -1,32 +1,41 @@
1
1
  import type { ChangeSpec } from '@codemirror/state';
2
- import { EditorView } from '@codemirror/view';
2
+ import type { EditorView } from '@codemirror/view';
3
3
  import type { NodeType, OrgNode } from 'org-mode-ast';
4
+ import type { Component } from 'vue';
4
5
  export type EmbeddedWidget = {
5
6
  destroy: () => void;
6
7
  refresh?: (...args: unknown[]) => void;
7
8
  };
8
- export interface WidgetBuilderParams {
9
+ export interface WidgetBuilderParams<TEditorView = EditorView> {
9
10
  wrap: HTMLElement;
10
11
  orgNode: OrgNode;
11
- rootNodeSrc: () => OrgNode;
12
+ orgNodeGetter?: () => OrgNode;
13
+ rootNodeSrc: () => OrgNode | null;
12
14
  onUpdateFn?: (newVal: string) => void;
13
- editorView: EditorView;
15
+ onEditMode?: () => void;
16
+ editorView: TEditorView;
14
17
  readonly?: boolean;
18
+ suppressEdit?: boolean;
15
19
  }
16
20
  export type WidgetBuilder = (params: WidgetBuilderParams) => EmbeddedWidget;
17
21
  export interface CommonEmbeddedWidget {
22
+ id: string;
18
23
  satisfied?: (orgNode: OrgNode) => boolean;
19
24
  widgetBuilder?: WidgetBuilder;
25
+ component?: Component;
26
+ componentProps?: Record<string, unknown>;
20
27
  viewUpdater?: (orgNode: OrgNode, newVal: string) => ViewUpdateSchema;
21
28
  ignoreEvent?: boolean;
22
29
  showRangeOffset?: [number, number];
30
+ priority?: number;
23
31
  }
24
32
  export interface MultilineEmbeddedWidget extends CommonEmbeddedWidget {
25
- widgetBuilder: WidgetBuilder;
33
+ widgetBuilder?: WidgetBuilder;
34
+ component?: Component;
26
35
  suppressEdit?: boolean;
27
36
  }
28
37
  export type MultilineEmbeddedWidgets = {
29
- [key in NodeType]?: MultilineEmbeddedWidget;
38
+ [key in NodeType]?: MultilineEmbeddedWidget[];
30
39
  };
31
40
  export type ViewUpdateSchema = ChangeSpec;
32
41
  export interface InlineEmbeddedWidget extends CommonEmbeddedWidget {
@@ -38,14 +47,13 @@ export interface InlineEmbeddedWidget extends CommonEmbeddedWidget {
38
47
  inclusive?: boolean;
39
48
  }
40
49
  export type InlineEmbeddedWidgets = {
41
- [key in NodeType]?: InlineEmbeddedWidget;
50
+ [key in NodeType]?: InlineEmbeddedWidget[];
42
51
  };
43
- export type EmbeddedWidgetBuilder = (wrap: HTMLElement, dynamicProps?: {
44
- [key: string]: unknown;
45
- }) => EmbeddedWidget;
46
- export type OrgLineClass = {
52
+ export interface OrgLineClass {
53
+ id: string;
47
54
  class: string | ((orgNode: OrgNode) => string);
48
- };
55
+ priority?: number;
56
+ }
49
57
  export type OrgLineClasses = {
50
- [key in NodeType]?: OrgLineClass;
58
+ [key in NodeType]?: OrgLineClass[];
51
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.40.23",
3
+ "version": "0.40.26",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -67,8 +67,8 @@
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@capacitor/filesystem": ">=6.0.0",
70
- "@codemirror/state": ">=6.0.0",
71
- "@codemirror/view": ">=6.0.0",
70
+ "@codemirror/state": "6.5.3",
71
+ "@codemirror/view": "6.39.5",
72
72
  "@faker-js/faker": ">=9.0.0",
73
73
  "pinia": ">=2.0.0",
74
74
  "quasar": ">=2.0.0",
@@ -0,0 +1,4 @@
1
+ export declare const uint8ArrayToBase64: (bytes: Uint8Array) => string;
2
+ export declare const base64ToUint8Array: (base64: string) => Uint8Array;
3
+ export declare const textToUint8Array: (text: string) => Uint8Array;
4
+ export declare const uint8ArrayToText: (bytes: Uint8Array) => string;
@@ -0,0 +1,17 @@
1
+ export const uint8ArrayToBase64 = (bytes) => {
2
+ let binary = '';
3
+ for (let i = 0; i < bytes.length; i++) {
4
+ binary += String.fromCharCode(bytes[i]);
5
+ }
6
+ return btoa(binary);
7
+ };
8
+ export const base64ToUint8Array = (base64) => {
9
+ const binary = atob(base64);
10
+ const bytes = new Uint8Array(binary.length);
11
+ for (let i = 0; i < binary.length; i++) {
12
+ bytes[i] = binary.charCodeAt(i);
13
+ }
14
+ return bytes;
15
+ };
16
+ export const textToUint8Array = (text) => new TextEncoder().encode(text);
17
+ export const uint8ArrayToText = (bytes) => new TextDecoder().decode(bytes);
package/utils/index.d.ts CHANGED
@@ -11,3 +11,4 @@ export * from './to-absolute-path.js';
11
11
  export * from './to-error.js';
12
12
  export * from './auth-state.js';
13
13
  export * from './nullable-guards.js';
14
+ export * from './binary.js';
package/utils/index.js CHANGED
@@ -11,3 +11,4 @@ export * from "./to-absolute-path.js";
11
11
  export * from "./to-error.js";
12
12
  export * from "./auth-state.js";
13
13
  export * from "./nullable-guards.js";
14
+ export * from "./binary.js";