orgnote-api 0.40.39 → 0.41.0

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
@@ -1,4 +1,4 @@
1
- import { InlineEmbeddedWidget, MultilineEmbeddedWidget, OrgLineClass, SyncStoreDefinition, FileReaderStoreDefinition, CommandsStoreDefinition, CommandsGroupStoreDefinition, ModalStoreDefinition, SettingsStoreDefinition, SettingsUiStoreDefinition, MultipleUploadParams, UploadParams, CompletionStoreDefinition, PaneStoreDefinition, LayoutStoreDefinition, FileManagerStoreDefinition, UseScreenDetection, UseKeyboardState, NotificationsStoreDefinition, BufferStoreDefinition, Repositories, LogStoreDefinition, UseSystemInfo, ContextMenuStoreDefinition, QueueStoreDefinition, FileGuardStoreDefinition, FileWatcherStoreDefinition, BuildOrgNoteUrl, AuthStoreDefinition, FileSearchStoreDefinition, FileMetaStoreDefinition, FontStoreDefinition } from './models/index.js';
1
+ import { InlineEmbeddedWidget, MultilineEmbeddedWidget, OrgLineClass, SyncStoreDefinition, FileReaderStoreDefinition, CommandsStoreDefinition, CommandsGroupStoreDefinition, ModalStoreDefinition, SettingsStoreDefinition, SettingsUiStoreDefinition, MultipleUploadParams, UploadParams, CompletionStoreDefinition, PaneStoreDefinition, LayoutStoreDefinition, FileManagerStoreDefinition, UseScreenDetection, UseKeyboardState, NotificationsStoreDefinition, BufferStoreDefinition, BufferProviderStoreDefinition, Repositories, LogStoreDefinition, UseSystemInfo, ContextMenuStoreDefinition, QueueStoreDefinition, FileGuardStoreDefinition, FileWatcherStoreDefinition, BuildOrgNoteUrl, AuthStoreDefinition, FileSearchStoreDefinition, FileMetaStoreDefinition, FontStoreDefinition } from './models/index.js';
2
2
  import { WebSocketClient } from './websocket/client.js';
3
3
  import { WidgetType } from './models/widget-type.js';
4
4
  import { NodeType } from 'org-mode-ast';
@@ -61,6 +61,7 @@ export interface OrgNoteApi {
61
61
  useFileReader: FileReaderStoreDefinition;
62
62
  useNotifications: NotificationsStoreDefinition;
63
63
  useBuffers: BufferStoreDefinition;
64
+ useBufferProviders: BufferProviderStoreDefinition;
64
65
  useSystemInfo: UseSystemInfo;
65
66
  useLog: LogStoreDefinition;
66
67
  useQueue: QueueStoreDefinition;
@@ -136,6 +136,7 @@ export declare enum i18n {
136
136
  SYSTEM_INFO = "system info",
137
137
  FONTS = "fonts",
138
138
  FILE_DELETED_EXTERNALLY = "file was deleted externally",
139
+ BUFFER_READONLY = "buffer is read-only",
139
140
  IMAGE_LOAD_FAILED = "failed to load image",
140
141
  IMAGE_NOT_FOUND = "image not found",
141
142
  USED_SPACE = "used space",
@@ -402,6 +403,7 @@ export declare const I18N: {
402
403
  SYSTEM_INFO: i18n.SYSTEM_INFO;
403
404
  FONTS: i18n.FONTS;
404
405
  FILE_DELETED_EXTERNALLY: i18n.FILE_DELETED_EXTERNALLY;
406
+ BUFFER_READONLY: i18n.BUFFER_READONLY;
405
407
  IMAGE_LOAD_FAILED: i18n.IMAGE_LOAD_FAILED;
406
408
  IMAGE_NOT_FOUND: i18n.IMAGE_NOT_FOUND;
407
409
  USED_SPACE: i18n.USED_SPACE;
@@ -140,6 +140,7 @@ export var i18n;
140
140
  i18n["FONTS"] = "fonts";
141
141
  // Buffer
142
142
  i18n["FILE_DELETED_EXTERNALLY"] = "file was deleted externally";
143
+ i18n["BUFFER_READONLY"] = "buffer is read-only";
143
144
  // Images
144
145
  i18n["IMAGE_LOAD_FAILED"] = "failed to load image";
145
146
  i18n["IMAGE_NOT_FOUND"] = "image not found";
@@ -0,0 +1,9 @@
1
+ import type { BufferProvider } from './buffer-provider.js';
2
+ import type { BufferScheme } from './buffer-uri.js';
3
+ import type { StoreDefinition } from './store.js';
4
+ export interface BufferProviderStore {
5
+ register(provider: BufferProvider): void;
6
+ unregister(scheme: BufferScheme): void;
7
+ get(scheme: BufferScheme): BufferProvider | undefined;
8
+ }
9
+ export type BufferProviderStoreDefinition = StoreDefinition<BufferProviderStore>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { FileSystemChange } from './file-system.js';
2
+ import type { BufferScheme } from './buffer-uri.js';
3
+ export interface BufferContext {
4
+ title?: string;
5
+ icon?: string;
6
+ [key: string]: unknown;
7
+ }
8
+ export interface BufferProvider {
9
+ readonly scheme: BufferScheme;
10
+ read(path: string): Promise<Uint8Array>;
11
+ write?(path: string, content: Uint8Array): Promise<void>;
12
+ watch?(path: string, callback: (change: FileSystemChange) => void): () => void;
13
+ getContext?(path: string): BufferContext;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,13 +1,13 @@
1
1
  import type { ComputedRef, Ref } from 'vue';
2
- import { StoreDefinition } from './store.js';
3
- import { Buffer } from './buffer.js';
2
+ import type { StoreDefinition } from './store.js';
3
+ import type { Buffer } from './buffer.js';
4
4
  export interface BufferStore {
5
5
  buffers: Ref<Map<string, Buffer>>;
6
6
  allBuffers: ComputedRef<Buffer[]>;
7
- getOrCreateBuffer: (path: string) => Promise<Buffer>;
8
- releaseBuffer: (path: string) => void;
9
- closeBuffer: (path: string, force?: boolean) => Promise<boolean>;
10
- getBufferByPath: (path: string) => Buffer | undefined;
7
+ getOrCreateBuffer: (uri: string) => Promise<Buffer>;
8
+ releaseBuffer: (uri: string) => void;
9
+ closeBuffer: (uri: string, force?: boolean) => Promise<boolean>;
10
+ getBufferByUri: (uri: string) => Buffer | undefined;
11
11
  saveAllBuffers: () => Promise<void>;
12
12
  cleanup: () => void;
13
13
  }
@@ -0,0 +1,9 @@
1
+ export type BuiltinBufferScheme = 'file' | 'memory' | 'shared' | 'remote' | 'embedded';
2
+ export type BufferScheme = BuiltinBufferScheme | (string & {});
3
+ export interface BufferUri {
4
+ scheme: BufferScheme;
5
+ path: string;
6
+ raw: string;
7
+ }
8
+ export declare const parseBufferUri: (uri: string) => BufferUri;
9
+ export declare const buildBufferUri: (scheme: BufferScheme, path: string) => string;
@@ -0,0 +1,18 @@
1
+ const DEFAULT_SCHEME = 'file';
2
+ const SCHEME_SEPARATOR = '://';
3
+ export const parseBufferUri = (uri) => {
4
+ const separatorIndex = uri.indexOf(SCHEME_SEPARATOR);
5
+ if (separatorIndex === -1) {
6
+ return {
7
+ scheme: DEFAULT_SCHEME,
8
+ path: uri,
9
+ raw: `${DEFAULT_SCHEME}${SCHEME_SEPARATOR}${uri}`,
10
+ };
11
+ }
12
+ return {
13
+ scheme: uri.slice(0, separatorIndex),
14
+ path: uri.slice(separatorIndex + SCHEME_SEPARATOR.length),
15
+ raw: uri,
16
+ };
17
+ };
18
+ export const buildBufferUri = (scheme, path) => `${scheme}${SCHEME_SEPARATOR}${path}`;
@@ -1,4 +1,5 @@
1
1
  import type { ValidationState } from './file-guard.js';
2
+ import type { BufferScheme } from './buffer-uri.js';
2
3
  type BufferError = string;
3
4
  export interface BufferMetadata<T = unknown> {
4
5
  [key: string]: T;
@@ -9,6 +10,8 @@ export interface BufferGuard {
9
10
  validation?: ValidationState;
10
11
  }
11
12
  export interface Buffer<T = unknown> {
13
+ uri: string;
14
+ scheme: BufferScheme;
12
15
  path: string;
13
16
  title: string;
14
17
  rawContent: Uint8Array;
package/models/index.d.ts CHANGED
@@ -26,6 +26,9 @@ export * from './file-upload.js';
26
26
  export * from './confirmation-modal.js';
27
27
  export * from './pane.js';
28
28
  export * from './buffer.js';
29
+ export * from './buffer-uri.js';
30
+ export * from './buffer-provider.js';
31
+ export * from './buffer-provider-store.js';
29
32
  export * from './log.js';
30
33
  export * from './logger.js';
31
34
  export * from './layout.js';
package/models/index.js CHANGED
@@ -26,6 +26,9 @@ export * from "./file-upload.js";
26
26
  export * from "./confirmation-modal.js";
27
27
  export * from "./pane.js";
28
28
  export * from "./buffer.js";
29
+ export * from "./buffer-uri.js";
30
+ export * from "./buffer-provider.js";
31
+ export * from "./buffer-provider-store.js";
29
32
  export * from "./log.js";
30
33
  export * from "./logger.js";
31
34
  export * from "./layout.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.40.39",
3
+ "version": "0.41.0",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.js",