@septkit/shell-lib 0.0.25 → 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.
- package/dist/constants.d.ts +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -23
- package/dist/types/index.d.ts +1 -0
- package/dist/types/storage-source.d.ts +35 -0
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -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-
|
|
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
|
|
141
|
-
let n =
|
|
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:
|
|
157
|
+
method: c((/* @__PURE__ */ Error()).stack),
|
|
147
158
|
ref: t.ref,
|
|
148
159
|
cause: t.cause
|
|
149
|
-
},
|
|
150
|
-
throw
|
|
160
|
+
}, i = Error(t.detail);
|
|
161
|
+
throw i.cause = r, i;
|
|
151
162
|
}
|
|
152
|
-
function
|
|
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
|
|
172
|
+
function l(e, t) {
|
|
162
173
|
if (e) return;
|
|
163
|
-
let { detail: n, key: r = "ASSERTION_FAILED", ref:
|
|
164
|
-
|
|
174
|
+
let { detail: n, key: r = "ASSERTION_FAILED", ref: i } = t;
|
|
175
|
+
s(r, {
|
|
165
176
|
detail: n,
|
|
166
|
-
ref:
|
|
177
|
+
ref: i
|
|
167
178
|
});
|
|
168
179
|
}
|
|
169
180
|
//#endregion
|
|
170
181
|
//#region src/shell-context.ts
|
|
171
|
-
var
|
|
172
|
-
function
|
|
173
|
-
|
|
182
|
+
var u = null;
|
|
183
|
+
function d(e) {
|
|
184
|
+
u = e;
|
|
174
185
|
}
|
|
175
|
-
function
|
|
176
|
-
|
|
186
|
+
function f() {
|
|
187
|
+
u = null;
|
|
177
188
|
}
|
|
178
|
-
function
|
|
179
|
-
return
|
|
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
|
|
182
|
-
return
|
|
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
|
|
185
|
-
return
|
|
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 {
|
|
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 };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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 {};
|