@lapis-notes/api 0.2.7 → 0.3.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.
- package/CHANGELOG.md +63 -0
- package/README.md +13 -0
- package/dist/generated/plugin-host-modules.schema.generated.d.ts +42 -42
- package/dist/generated/plugin-host-modules.schema.generated.js +42 -42
- package/dist/native-editing-intents.d.ts +8 -0
- package/dist/native-editing-recovery.d.ts +1 -1
- package/dist/native-editing-recovery.js +50 -5
- package/dist/plugin-distribution/schemas.d.ts +24 -24
- package/dist/plugin-manager.d.ts +1 -0
- package/dist/plugin-manager.js +18 -2
- package/dist/registry-schema/catalog-v1.d.ts +306 -306
- package/dist/registry-schema/catalog-v2.d.ts +417 -417
- package/dist/storage/browser.js +2 -1
- package/dist/storage/vault-content-adapter.d.ts +2 -2
- package/dist/storage/vault-content-adapter.js +35 -6
- package/dist/storage/vault-resource-type.d.ts +1 -0
- package/dist/storage/vault-resource-type.js +37 -0
- package/dist/vault-changes.js +27 -4
- package/package.json +5 -5
package/dist/storage/browser.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { basename, dirname, joinPath, normalizePath } from "./path";
|
|
2
|
+
import { vaultResourceContentType } from "./vault-resource-type";
|
|
2
3
|
import { clearVaultScopedState, deleteVaultProfile, generateBrowserVaultId, getDefaultVaultStateStore, getVaultProfile, listVaultProfiles, saveVaultProfile, ScopedVaultStore, } from "./vault-state";
|
|
3
4
|
function createFsError(code, path) {
|
|
4
5
|
const error = new Error(`${code}: ${path}`);
|
|
@@ -685,7 +686,7 @@ export class BrowserHandleVaultAdapter {
|
|
|
685
686
|
}
|
|
686
687
|
async getResourceUrl(normalizedPath) {
|
|
687
688
|
const data = await this.readBinary(normalizedPath);
|
|
688
|
-
return URL.createObjectURL(new Blob([data]));
|
|
689
|
+
return URL.createObjectURL(new Blob([data], { type: vaultResourceContentType(normalizedPath) }));
|
|
689
690
|
}
|
|
690
691
|
revokeResourceUrl(url) {
|
|
691
692
|
URL.revokeObjectURL(url);
|
|
@@ -3,6 +3,6 @@ import type { DataAdapter } from "./fs";
|
|
|
3
3
|
* Installed plugin assets are not user content; direct adapter access is
|
|
4
4
|
* unchanged.
|
|
5
5
|
*/
|
|
6
|
-
export declare function isVaultContent(path: string, configDir: string): boolean;
|
|
6
|
+
export declare function isVaultContent(path: string, configDir: string, scope?: "discovery" | "watch"): boolean;
|
|
7
7
|
/** Retain native capabilities while constraining fallback polling discovery. */
|
|
8
|
-
export declare function vaultContentAdapter(adapter: DataAdapter, configDir: () => string): DataAdapter;
|
|
8
|
+
export declare function vaultContentAdapter(adapter: DataAdapter, configDir: () => string, scope?: "discovery" | "watch"): DataAdapter;
|
|
@@ -3,19 +3,48 @@ import { joinPath, normalizePath } from "./path";
|
|
|
3
3
|
* Installed plugin assets are not user content; direct adapter access is
|
|
4
4
|
* unchanged.
|
|
5
5
|
*/
|
|
6
|
-
export function isVaultContent(path, configDir) {
|
|
6
|
+
export function isVaultContent(path, configDir, scope = "discovery") {
|
|
7
7
|
const relative = normalizePath(path).replace(/^\/+|\/+$/gu, "");
|
|
8
8
|
const state = normalizePath(configDir).replace(/^\/+|\/+$/gu, "");
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const excluded = !state
|
|
10
|
+
? []
|
|
11
|
+
: scope === "watch"
|
|
12
|
+
? [state]
|
|
13
|
+
: [`${state}/plugins`, `${state}/plugin-registry-cache`];
|
|
14
|
+
return excluded.every((config) => relative !== config && !relative.startsWith(`${config}/`));
|
|
11
15
|
}
|
|
12
16
|
/** Retain native capabilities while constraining fallback polling discovery. */
|
|
13
|
-
export function vaultContentAdapter(adapter, configDir) {
|
|
17
|
+
export function vaultContentAdapter(adapter, configDir, scope = "discovery") {
|
|
14
18
|
return new Proxy(adapter, {
|
|
15
19
|
get(target, property) {
|
|
20
|
+
if (property === "watch" && scope === "watch") {
|
|
21
|
+
const native = target;
|
|
22
|
+
if (!native.watch)
|
|
23
|
+
return undefined;
|
|
24
|
+
return (path, options, accept) => {
|
|
25
|
+
const roots = (Array.isArray(path) ? path : [path]).map((p) => normalizePath(p).replace(/^\/+|\/+$/gu, ""));
|
|
26
|
+
const included = (p) => isVaultContent(p, configDir(), scope) ||
|
|
27
|
+
(!options.recursive &&
|
|
28
|
+
roots.includes(normalizePath(p).replace(/^\/+|\/+$/gu, "")));
|
|
29
|
+
return native.watch(path, options, (event) => {
|
|
30
|
+
if (event.type === "error") {
|
|
31
|
+
accept(event);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const current = included(event.path);
|
|
35
|
+
const previous = event.previousPath !== undefined && included(event.previousPath);
|
|
36
|
+
if (current && (!event.previousPath || previous))
|
|
37
|
+
accept(event);
|
|
38
|
+
else if (current)
|
|
39
|
+
accept({ type: "create", path: event.path });
|
|
40
|
+
else if (previous)
|
|
41
|
+
accept({ type: "delete", path: event.previousPath });
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
16
45
|
if (property === "list")
|
|
17
46
|
return async (path) => {
|
|
18
|
-
if (!isVaultContent(path, configDir()))
|
|
47
|
+
if (!isVaultContent(path, configDir(), scope))
|
|
19
48
|
return { files: [], folders: [] };
|
|
20
49
|
const listing = await target.list(path);
|
|
21
50
|
const include = (entry) => {
|
|
@@ -24,7 +53,7 @@ export function vaultContentAdapter(adapter, configDir) {
|
|
|
24
53
|
entry === ".." ||
|
|
25
54
|
/[/\\\0]/u.test(entry))
|
|
26
55
|
throw Error("Invalid vault snapshot child path");
|
|
27
|
-
return isVaultContent(joinPath(path, entry), configDir());
|
|
56
|
+
return isVaultContent(joinPath(path, entry), configDir(), scope);
|
|
28
57
|
};
|
|
29
58
|
return {
|
|
30
59
|
files: listing.files.filter(include),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function vaultResourceContentType(path: string): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Passive media types supported by vault readers; unknown files stay binary. */
|
|
2
|
+
const resourceTypes = {
|
|
3
|
+
svg: "image/svg+xml",
|
|
4
|
+
png: "image/png",
|
|
5
|
+
apng: "image/apng",
|
|
6
|
+
jpg: "image/jpeg",
|
|
7
|
+
jpeg: "image/jpeg",
|
|
8
|
+
gif: "image/gif",
|
|
9
|
+
webp: "image/webp",
|
|
10
|
+
avif: "image/avif",
|
|
11
|
+
bmp: "image/bmp",
|
|
12
|
+
ico: "image/vnd.microsoft.icon",
|
|
13
|
+
tif: "image/tiff",
|
|
14
|
+
tiff: "image/tiff",
|
|
15
|
+
mp3: "audio/mpeg",
|
|
16
|
+
wav: "audio/wav",
|
|
17
|
+
ogg: "audio/ogg",
|
|
18
|
+
oga: "audio/ogg",
|
|
19
|
+
opus: "audio/ogg",
|
|
20
|
+
flac: "audio/flac",
|
|
21
|
+
m4a: "audio/mp4",
|
|
22
|
+
aac: "audio/aac",
|
|
23
|
+
mp4: "video/mp4",
|
|
24
|
+
m4v: "video/mp4",
|
|
25
|
+
webm: "video/webm",
|
|
26
|
+
ogv: "video/ogg",
|
|
27
|
+
mov: "video/quicktime",
|
|
28
|
+
pdf: "application/pdf",
|
|
29
|
+
};
|
|
30
|
+
export function vaultResourceContentType(path) {
|
|
31
|
+
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
32
|
+
const dot = name.lastIndexOf(".");
|
|
33
|
+
return dot < 0
|
|
34
|
+
? "application/octet-stream"
|
|
35
|
+
: (resourceTypes[name.slice(dot + 1).toLowerCase()] ??
|
|
36
|
+
"application/octet-stream");
|
|
37
|
+
}
|
package/dist/vault-changes.js
CHANGED
|
@@ -35,7 +35,7 @@ export class VaultChangeService {
|
|
|
35
35
|
const generation = ++this.generation;
|
|
36
36
|
this.active = true;
|
|
37
37
|
this.dirty = true;
|
|
38
|
-
const watcher = new DirectoryWatcher(vaultContentAdapter(this.app.vault.adapter, () => this.app.vault.configDir));
|
|
38
|
+
const watcher = new DirectoryWatcher(vaultContentAdapter(this.app.vault.adapter, () => this.app.vault.configDir, "watch"));
|
|
39
39
|
this.watcher = watcher;
|
|
40
40
|
const projection = this.app.vault.on("all", (event, file, context) => {
|
|
41
41
|
if (!this.live(generation) || !(file instanceof TFile))
|
|
@@ -53,7 +53,13 @@ export class VaultChangeService {
|
|
|
53
53
|
this.changed(event, generation);
|
|
54
54
|
});
|
|
55
55
|
const subscription = watcher.watch("/", { recursive: true });
|
|
56
|
-
|
|
56
|
+
// App configuration is an explicit leaf observer, never a recursive
|
|
57
|
+
// traversal of caches, workspaces, plugin payloads or generated state.
|
|
58
|
+
const configPath = this.app.configuration?.basePath;
|
|
59
|
+
const configuration = configPath
|
|
60
|
+
? watcher.watch(configPath, { recursive: false })
|
|
61
|
+
: undefined;
|
|
62
|
+
await Promise.all([subscription.ready, configuration?.ready]);
|
|
57
63
|
if (!this.live(generation))
|
|
58
64
|
return;
|
|
59
65
|
this.registered = true;
|
|
@@ -160,9 +166,26 @@ export class VaultChangeService {
|
|
|
160
166
|
}
|
|
161
167
|
changed(event, generation) {
|
|
162
168
|
if (event.type !== "error" &&
|
|
163
|
-
|
|
169
|
+
event.path === this.app.configuration?.basePath) {
|
|
170
|
+
if (event.type !== "delete") {
|
|
171
|
+
const pending = this.app.fileEditingSessions.track(() => this.app.fileEditingSessions.afterMutations(() => this.live(generation)
|
|
172
|
+
? this.app.configuration.reloadFromDisk({
|
|
173
|
+
emitPluginDataEvents: true,
|
|
174
|
+
materializeDefaults: false,
|
|
175
|
+
origin: "external-reload",
|
|
176
|
+
})
|
|
177
|
+
: Promise.resolve()));
|
|
178
|
+
this.projections.add(pending);
|
|
179
|
+
void pending
|
|
180
|
+
.catch((error) => this.report(error))
|
|
181
|
+
.finally(() => this.projections.delete(pending));
|
|
182
|
+
}
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (event.type !== "error" &&
|
|
186
|
+
isVaultContent(event.path, this.app.vault.configDir, "watch") === false &&
|
|
164
187
|
(!event.previousPath ||
|
|
165
|
-
!isVaultContent(event.previousPath, this.app.vault.configDir)))
|
|
188
|
+
!isVaultContent(event.previousPath, this.app.vault.configDir, "watch")))
|
|
166
189
|
return;
|
|
167
190
|
this.dirty = true;
|
|
168
191
|
if (event.type === "error") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lapis-notes/api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Lapis Notes API",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"@iconify/types": "^2.0.0",
|
|
23
23
|
"@iconify/utils": "^2.3.0",
|
|
24
24
|
"@lapismd/ai-host": "^0.3.0",
|
|
25
|
-
"@lapismd/design-core": "^0.
|
|
26
|
-
"@lapismd/mira": "~0.1.
|
|
25
|
+
"@lapismd/design-core": "^0.13.0",
|
|
26
|
+
"@lapismd/mira": "~0.1.5",
|
|
27
27
|
"@lezer/common": "^1.2.3",
|
|
28
28
|
"@lezer/lr": "^1.4.2",
|
|
29
29
|
"@lucide/svelte": "^0.523.0",
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
"@codemirror/view": "^6.35.0",
|
|
109
109
|
"@dnd-kit/dom": "^0.4.0",
|
|
110
110
|
"@dnd-kit/svelte": "^0.4.0",
|
|
111
|
-
"@lapis-notes/ui": "^0.1.
|
|
112
|
-
"@lapismd/design-core": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.12.0",
|
|
111
|
+
"@lapis-notes/ui": "^0.1.9",
|
|
112
|
+
"@lapismd/design-core": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.12.0 || ^0.13.0",
|
|
113
113
|
"@lapismd/mira": "~0.1.3",
|
|
114
114
|
"@lezer/highlight": "^1.2.1",
|
|
115
115
|
"@lezer/markdown": "^1.4.3",
|