@septkit/shell-lib 0.0.24 → 0.0.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.
@@ -1,3 +1,6 @@
1
+ export declare const SHELL_DB_PREFIX = "SET-SHELL-";
1
2
  export declare const LIBRARY_DB_PREFIX = "SET-LIBRARY-";
2
3
  export declare const TEMP_DOCUMENT_PREFIX = "TEMP-";
3
4
  export declare const TEMP_PROJECT_PREFIX = "TEMP-PROJECT-";
5
+ export declare const RESERVED_DB_PREFIXES: readonly ["_", "SET-SHELL-", "SET-LIBRARY-", "TEMP-"];
6
+ export declare function isReservedDatabaseName(name: string): boolean;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export type * from './types';
2
- export { LIBRARY_DB_PREFIX, TEMP_DOCUMENT_PREFIX, TEMP_PROJECT_PREFIX } from './constants';
2
+ export { SHELL_DB_PREFIX, LIBRARY_DB_PREFIX, TEMP_DOCUMENT_PREFIX, TEMP_PROJECT_PREFIX, RESERVED_DB_PREFIXES, isReservedDatabaseName, } from './constants';
3
3
  export { setShellContext, clearShellContext, getProject, getActiveDocumentId, getCommands, } from './shell-context';
package/dist/index.js CHANGED
@@ -1,5 +1,16 @@
1
1
  //#region src/constants.ts
2
- var e = "SET-LIBRARY-", t = "TEMP-", n = "TEMP-PROJECT-", r = {
2
+ var e = "SET-SHELL-", t = "SET-LIBRARY-", n = "TEMP-", r = "TEMP-PROJECT-", i = [
3
+ "_",
4
+ e,
5
+ t,
6
+ n
7
+ ];
8
+ function a(e) {
9
+ return i.some((t) => e.startsWith(t));
10
+ }
11
+ //#endregion
12
+ //#region node_modules/.pnpm/@dialecte+core@0.4.12/node_modules/@dialecte/core/dist/utils-C5_11hqg.js
13
+ var o = {
3
14
  UNKNOWN: {
4
15
  code: "D0001",
5
16
  message: "An unknown error occurred"
@@ -137,19 +148,19 @@ var e = "SET-LIBRARY-", t = "TEMP-", n = "TEMP-PROJECT-", r = {
137
148
  message: "Blob not found in store"
138
149
  }
139
150
  };
140
- function i(e, t) {
141
- let n = r[e], i = {
151
+ function s(e, t) {
152
+ let n = o[e], r = {
142
153
  code: n.code,
143
154
  key: e,
144
155
  message: t.message ?? n.message,
145
156
  detail: t.detail,
146
- method: a((/* @__PURE__ */ Error()).stack),
157
+ method: c((/* @__PURE__ */ Error()).stack),
147
158
  ref: t.ref,
148
159
  cause: t.cause
149
- }, o = Error(t.detail);
150
- throw o.cause = i, o;
160
+ }, i = Error(t.detail);
161
+ throw i.cause = r, i;
151
162
  }
152
- function a(e) {
163
+ function c(e) {
153
164
  if (!e) return "unknown";
154
165
  let t = e.split("\n").slice(1).find((e) => !/\b(throwDialecteError|assert)\b/.test(e));
155
166
  if (!t) return "unknown";
@@ -158,31 +169,31 @@ function a(e) {
158
169
  let a = i.match(/(\w[\w-]*\/src\/[^?:]+)/);
159
170
  return a ? `${a[1].replace(/\.[^/.]+$/, "")}::${r}` : r;
160
171
  }
161
- function o(e, t) {
172
+ function l(e, t) {
162
173
  if (e) return;
163
- let { detail: n, key: r = "ASSERTION_FAILED", ref: a } = t;
164
- i(r, {
174
+ let { detail: n, key: r = "ASSERTION_FAILED", ref: i } = t;
175
+ s(r, {
165
176
  detail: n,
166
- ref: a
177
+ ref: i
167
178
  });
168
179
  }
169
180
  //#endregion
170
181
  //#region src/shell-context.ts
171
- var s = null;
172
- function c(e) {
173
- s = e;
182
+ var u = null;
183
+ function d(e) {
184
+ u = e;
174
185
  }
175
- function l() {
176
- s = null;
186
+ function f() {
187
+ u = null;
177
188
  }
178
- function u() {
179
- return o(s, { detail: "getProject: shell context not set. Call setShellContext(api) before app.mount()." }), s.project;
189
+ function p() {
190
+ return l(u, { detail: "getProject: shell context not set. Call setShellContext(api) before app.mount()." }), u.project;
180
191
  }
181
- function d() {
182
- return o(s, { detail: "getActiveDocumentId: shell context not set. Call setShellContext(api) before app.mount()." }), s.activeDocumentId;
192
+ function m() {
193
+ return l(u, { detail: "getActiveDocumentId: shell context not set. Call setShellContext(api) before app.mount()." }), u.activeDocumentId;
183
194
  }
184
- function f() {
185
- return o(s, { detail: "getCommands: shell context not set. Call setShellContext(api) before app.mount()." }), s.commands;
195
+ function h() {
196
+ return l(u, { detail: "getCommands: shell context not set. Call setShellContext(api) before app.mount()." }), u.commands;
186
197
  }
187
198
  //#endregion
188
- export { e as LIBRARY_DB_PREFIX, t as TEMP_DOCUMENT_PREFIX, n as TEMP_PROJECT_PREFIX, l as clearShellContext, d as getActiveDocumentId, f as getCommands, u as getProject, c as setShellContext };
199
+ export { t as LIBRARY_DB_PREFIX, i as RESERVED_DB_PREFIXES, e as SHELL_DB_PREFIX, n as TEMP_DOCUMENT_PREFIX, r as TEMP_PROJECT_PREFIX, f as clearShellContext, m as getActiveDocumentId, h as getCommands, p as getProject, a as isReservedDatabaseName, d as setShellContext };
@@ -1 +1,2 @@
1
1
  export type * from './api';
2
+ export type * from './storage-source';
@@ -0,0 +1,35 @@
1
+ export interface StorageSources {
2
+ isSupported(): boolean;
3
+ listSources(): Promise<StorageSource[]>;
4
+ attach(options?: {
5
+ mode?: StorageAccessMode;
6
+ }): Promise<StorageSource>;
7
+ requestAccess(id: string): Promise<StorageAccessState>;
8
+ detach(id: string): Promise<void>;
9
+ onChange(listener: (sources: StorageSource[]) => void): Unsubscribe;
10
+ listEntries(id: string, options?: {
11
+ recursive?: boolean;
12
+ }): Promise<StorageEntry[]>;
13
+ readFile(id: string, path: string): Promise<File>;
14
+ writeFile(id: string, path: string, data: Blob | string): Promise<void>;
15
+ deleteFile(id: string, path: string): Promise<void>;
16
+ }
17
+ type Unsubscribe = () => void;
18
+ export type StorageAccessMode = 'read' | 'readwrite';
19
+ export type StorageAccessState = 'granted' | 'prompt' | 'denied';
20
+ export type StorageSource = {
21
+ id: string;
22
+ label: string;
23
+ mode: StorageAccessMode;
24
+ access: StorageAccessState;
25
+ };
26
+ export type StorageEntry = {
27
+ path: string;
28
+ kind: 'file' | 'directory';
29
+ };
30
+ export type StorageErrorReason = 'unsupported' | 'access-denied' | 'cancelled' | 'not-found' | 'io';
31
+ export interface StorageError extends Error {
32
+ reason: StorageErrorReason;
33
+ sourceId?: string;
34
+ }
35
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@septkit/shell-lib",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -13,8 +13,8 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "@dialecte/core": "0.4.11",
17
- "@dialecte/scl": "0.3.13"
16
+ "@dialecte/core": "0.4.12",
17
+ "@dialecte/scl": "0.3.14"
18
18
  },
19
19
  "devDependencies": {
20
20
  "oxlint": "~1.6.0",