@devframes/plugin-assets 0.9.1 → 0.9.2
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/cli.mjs +1 -1
- package/dist/client/index.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/node/index.d.mts +2 -2
- package/dist/node/index.mjs +2 -2
- package/dist/{node-DUay0toc.mjs → node-Cit_U9yi.mjs} +2 -3
- package/dist/rpc/index.d.mts +45 -108
- package/dist/rpc/index.mjs +2 -2
- package/dist/{rpc-BObgi2mL.mjs → rpc-BOraEthN.mjs} +23 -78
- package/dist/{src-BTiBbgej.mjs → src-77vCG4mn.mjs} +10 -5
- package/dist/{types-DPDOYVFh.d.mts → types-BrE0klRv.d.mts} +6 -0
- package/package.json +17 -11
package/dist/cli.mjs
CHANGED
package/dist/client/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as CodeSnippet, n as AssetInfo, r as AssetType, t as AssetImageMeta } from "../types-
|
|
1
|
+
import { i as CodeSnippet, n as AssetInfo, r as AssetType, t as AssetImageMeta } from "../types-BrE0klRv.mjs";
|
|
2
2
|
import { DevframeRpcClientOptions } from "devframe/client";
|
|
3
3
|
//#region src/client/index.d.ts
|
|
4
4
|
declare function connectAssets(options?: DevframeRpcClientOptions): Promise<import("devframe/client").DevframeRpcClient>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, i as CodeSnippet, n as AssetInfo, r as AssetType, t as AssetImageMeta } from "./types-
|
|
1
|
+
import { a as DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, i as CodeSnippet, n as AssetInfo, r as AssetType, t as AssetImageMeta } from "./types-BrE0klRv.mjs";
|
|
2
2
|
import { DevframeDefinition } from "devframe";
|
|
3
3
|
//#region src/index.d.ts
|
|
4
4
|
interface AssetsDevframeOptions {
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, t as createAssetsDevframe } from "./src-
|
|
1
|
+
import { n as DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, t as createAssetsDevframe } from "./src-77vCG4mn.mjs";
|
|
2
2
|
export { DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, createAssetsDevframe, createAssetsDevframe as default };
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as AssetInfo, r as AssetType } from "../types-
|
|
1
|
+
import { n as AssetInfo, r as AssetType } from "../types-BrE0klRv.mjs";
|
|
2
2
|
import { DevframeNodeContext, RpcStreamingChannel } from "devframe";
|
|
3
3
|
//#region src/node/context.d.ts
|
|
4
4
|
interface AssetsConfig {
|
|
@@ -46,7 +46,7 @@ declare function resolveAssetPath(root: string, relativePath: string): string;
|
|
|
46
46
|
/** Classifies a path by extension, driving preview and icon choice. */
|
|
47
47
|
declare function guessAssetType(path: string): AssetType;
|
|
48
48
|
/** Recursively lists every file under `dir`, sorted alphabetically by path. */
|
|
49
|
-
declare function scanAssets(dir: string, baseURL: string): Promise<AssetInfo[]>;
|
|
49
|
+
declare function scanAssets(dir: string, baseURL: string, includeFsPath?: boolean): Promise<AssetInfo[]>;
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/node/index.d.ts
|
|
52
52
|
interface SetupAssetsOptions {
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as setupAssets, t as disposeAssetsWatcher } from "../node-
|
|
2
|
-
import {
|
|
1
|
+
import { n as setupAssets, t as disposeAssetsWatcher } from "../node-Cit_U9yi.mjs";
|
|
2
|
+
import { _ as getAssetsContext, d as scanAssets, g as configureAssets, u as guessAssetType, v as resolveAssetPath } from "../rpc-BOraEthN.mjs";
|
|
3
3
|
export { configureAssets, disposeAssetsWatcher, getAssetsContext, guessAssetType, resolveAssetPath, scanAssets, setupAssets };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as configureAssets, m as UPLOAD_CHANNEL, r as writeFunctions, t as readFunctions } from "./rpc-BOraEthN.mjs";
|
|
2
|
+
import process from "node:process";
|
|
2
3
|
import { existsSync } from "node:fs";
|
|
3
4
|
import fsp from "node:fs/promises";
|
|
4
|
-
import process from "node:process";
|
|
5
5
|
import { watch } from "chokidar";
|
|
6
6
|
import { debounce } from "perfect-debounce";
|
|
7
7
|
//#region src/constants.ts
|
|
@@ -60,7 +60,6 @@ async function setupAssets(ctx, options) {
|
|
|
60
60
|
});
|
|
61
61
|
if (options.serveStatic) ctx.views.hostStatic(options.baseURL, options.dir);
|
|
62
62
|
for (const fn of readFunctions) ctx.rpc.register(fn);
|
|
63
|
-
for (const fn of alwaysFunctions) ctx.rpc.register(fn);
|
|
64
63
|
if (options.write) for (const fn of writeFunctions) ctx.rpc.register(fn);
|
|
65
64
|
if (ctx.mode === "dev" && options.watch) watchers.set(ctx, watchAssetsDir(ctx, options.dir));
|
|
66
65
|
}
|
package/dist/rpc/index.d.mts
CHANGED
|
@@ -101,12 +101,14 @@ declare const assetInfoSchema: import("devframe/utils/simple-schema").SimpleSche
|
|
|
101
101
|
publicPath: string;
|
|
102
102
|
size: number;
|
|
103
103
|
mtime: number;
|
|
104
|
+
fsPath?: string | undefined;
|
|
104
105
|
}, {
|
|
105
106
|
path: string;
|
|
106
107
|
type: "image" | "font" | "video" | "audio" | "text" | "other";
|
|
107
108
|
publicPath: string;
|
|
108
109
|
size: number;
|
|
109
110
|
mtime: number;
|
|
111
|
+
fsPath?: string | undefined;
|
|
110
112
|
}>;
|
|
111
113
|
declare const list: {
|
|
112
114
|
name: "devframes:plugin:assets:list";
|
|
@@ -119,12 +121,14 @@ declare const list: {
|
|
|
119
121
|
publicPath: string;
|
|
120
122
|
size: number;
|
|
121
123
|
mtime: number;
|
|
124
|
+
fsPath?: string | undefined;
|
|
122
125
|
}[], {
|
|
123
126
|
path: string;
|
|
124
127
|
type: "image" | "font" | "video" | "audio" | "text" | "other";
|
|
125
128
|
publicPath: string;
|
|
126
129
|
size: number;
|
|
127
130
|
mtime: number;
|
|
131
|
+
fsPath?: string | undefined;
|
|
128
132
|
}[]>;
|
|
129
133
|
jsonSerializable?: boolean;
|
|
130
134
|
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
@@ -134,6 +138,7 @@ declare const list: {
|
|
|
134
138
|
publicPath: string;
|
|
135
139
|
size: number;
|
|
136
140
|
mtime: number;
|
|
141
|
+
fsPath?: string | undefined;
|
|
137
142
|
}[]>>>) | undefined;
|
|
138
143
|
handler?: (() => import("devframe/rpc").Thenable<{
|
|
139
144
|
path: string;
|
|
@@ -141,6 +146,7 @@ declare const list: {
|
|
|
141
146
|
publicPath: string;
|
|
142
147
|
size: number;
|
|
143
148
|
mtime: number;
|
|
149
|
+
fsPath?: string | undefined;
|
|
144
150
|
}[]>) | undefined;
|
|
145
151
|
dump?: import("devframe/rpc").RpcDump<[], import("devframe/rpc").Thenable<{
|
|
146
152
|
path: string;
|
|
@@ -148,6 +154,7 @@ declare const list: {
|
|
|
148
154
|
publicPath: string;
|
|
149
155
|
size: number;
|
|
150
156
|
mtime: number;
|
|
157
|
+
fsPath?: string | undefined;
|
|
151
158
|
}[]>, DevframeNodeContext> | undefined;
|
|
152
159
|
snapshot?: boolean;
|
|
153
160
|
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[], import("devframe/rpc").Thenable<{
|
|
@@ -156,6 +163,7 @@ declare const list: {
|
|
|
156
163
|
publicPath: string;
|
|
157
164
|
size: number;
|
|
158
165
|
mtime: number;
|
|
166
|
+
fsPath?: string | undefined;
|
|
159
167
|
}[]>>>> | undefined;
|
|
160
168
|
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[], import("devframe/rpc").Thenable<{
|
|
161
169
|
path: string;
|
|
@@ -163,6 +171,7 @@ declare const list: {
|
|
|
163
171
|
publicPath: string;
|
|
164
172
|
size: number;
|
|
165
173
|
mtime: number;
|
|
174
|
+
fsPath?: string | undefined;
|
|
166
175
|
}[]>>> | undefined;
|
|
167
176
|
};
|
|
168
177
|
//#endregion
|
|
@@ -197,29 +206,6 @@ declare const mkdir: {
|
|
|
197
206
|
}], import("devframe/rpc").Thenable<void>>> | undefined;
|
|
198
207
|
};
|
|
199
208
|
//#endregion
|
|
200
|
-
//#region src/rpc/functions/open-in-editor.d.ts
|
|
201
|
-
/**
|
|
202
|
-
* Reuses devframe's `launchEditor` utility (the same one backing the core
|
|
203
|
-
* `devframe:open-in-editor` recipe) but resolves the path against the
|
|
204
|
-
* managed directory first, so the client only ever sends a root-relative
|
|
205
|
-
* path — never the server's absolute filesystem layout.
|
|
206
|
-
*/
|
|
207
|
-
declare const openInEditor: {
|
|
208
|
-
name: "devframes:plugin:assets:open-in-editor";
|
|
209
|
-
type?: "action" | undefined;
|
|
210
|
-
cacheable?: boolean;
|
|
211
|
-
args: readonly [import("devframe/utils/simple-schema").SimpleSchema<string, string>];
|
|
212
|
-
returns: import("devframe/utils/simple-schema").SimpleSchema<void, void>;
|
|
213
|
-
jsonSerializable?: boolean;
|
|
214
|
-
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
215
|
-
setup?: ((context: DevframeNodeContext) => import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>) | undefined;
|
|
216
|
-
handler?: ((args_0: string) => import("devframe/rpc").Thenable<void>) | undefined;
|
|
217
|
-
dump?: import("devframe/rpc").RpcDump<[string], import("devframe/rpc").Thenable<void>, DevframeNodeContext> | undefined;
|
|
218
|
-
snapshot?: boolean;
|
|
219
|
-
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>> | undefined;
|
|
220
|
-
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>> | undefined;
|
|
221
|
-
};
|
|
222
|
-
//#endregion
|
|
223
209
|
//#region src/rpc/functions/read-image-meta.d.ts
|
|
224
210
|
declare const readImageMeta: {
|
|
225
211
|
name: "devframes:plugin:assets:read-image-meta";
|
|
@@ -311,12 +297,14 @@ declare const rename: {
|
|
|
311
297
|
publicPath: string;
|
|
312
298
|
size: number;
|
|
313
299
|
mtime: number;
|
|
300
|
+
fsPath?: string | undefined;
|
|
314
301
|
}, {
|
|
315
302
|
path: string;
|
|
316
303
|
type: "image" | "font" | "video" | "audio" | "text" | "other";
|
|
317
304
|
publicPath: string;
|
|
318
305
|
size: number;
|
|
319
306
|
mtime: number;
|
|
307
|
+
fsPath?: string | undefined;
|
|
320
308
|
}>;
|
|
321
309
|
jsonSerializable?: boolean;
|
|
322
310
|
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
@@ -329,6 +317,7 @@ declare const rename: {
|
|
|
329
317
|
publicPath: string;
|
|
330
318
|
size: number;
|
|
331
319
|
mtime: number;
|
|
320
|
+
fsPath?: string | undefined;
|
|
332
321
|
}>>>) | undefined;
|
|
333
322
|
handler?: ((args_0: {
|
|
334
323
|
path: string;
|
|
@@ -339,6 +328,7 @@ declare const rename: {
|
|
|
339
328
|
publicPath: string;
|
|
340
329
|
size: number;
|
|
341
330
|
mtime: number;
|
|
331
|
+
fsPath?: string | undefined;
|
|
342
332
|
}>) | undefined;
|
|
343
333
|
dump?: import("devframe/rpc").RpcDump<[{
|
|
344
334
|
path: string;
|
|
@@ -349,6 +339,7 @@ declare const rename: {
|
|
|
349
339
|
publicPath: string;
|
|
350
340
|
size: number;
|
|
351
341
|
mtime: number;
|
|
342
|
+
fsPath?: string | undefined;
|
|
352
343
|
}>, DevframeNodeContext> | undefined;
|
|
353
344
|
snapshot?: boolean;
|
|
354
345
|
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[{
|
|
@@ -360,6 +351,7 @@ declare const rename: {
|
|
|
360
351
|
publicPath: string;
|
|
361
352
|
size: number;
|
|
362
353
|
mtime: number;
|
|
354
|
+
fsPath?: string | undefined;
|
|
363
355
|
}>>>> | undefined;
|
|
364
356
|
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[{
|
|
365
357
|
path: string;
|
|
@@ -370,32 +362,10 @@ declare const rename: {
|
|
|
370
362
|
publicPath: string;
|
|
371
363
|
size: number;
|
|
372
364
|
mtime: number;
|
|
365
|
+
fsPath?: string | undefined;
|
|
373
366
|
}>>> | undefined;
|
|
374
367
|
};
|
|
375
368
|
//#endregion
|
|
376
|
-
//#region src/rpc/functions/reveal-in-folder.d.ts
|
|
377
|
-
/**
|
|
378
|
-
* Reuses devframe's `open` utility (the same one backing the core
|
|
379
|
-
* `devframe:open-in-finder` recipe), opening the asset's containing folder
|
|
380
|
-
* so it's revealed in the OS file manager rather than launched with its
|
|
381
|
-
* default app (which `download` already covers).
|
|
382
|
-
*/
|
|
383
|
-
declare const revealInFolder: {
|
|
384
|
-
name: "devframes:plugin:assets:reveal-in-folder";
|
|
385
|
-
type?: "action" | undefined;
|
|
386
|
-
cacheable?: boolean;
|
|
387
|
-
args: readonly [import("devframe/utils/simple-schema").SimpleSchema<string, string>];
|
|
388
|
-
returns: import("devframe/utils/simple-schema").SimpleSchema<void, void>;
|
|
389
|
-
jsonSerializable?: boolean;
|
|
390
|
-
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
391
|
-
setup?: ((context: DevframeNodeContext) => import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>) | undefined;
|
|
392
|
-
handler?: ((args_0: string) => import("devframe/rpc").Thenable<void>) | undefined;
|
|
393
|
-
dump?: import("devframe/rpc").RpcDump<[string], import("devframe/rpc").Thenable<void>, DevframeNodeContext> | undefined;
|
|
394
|
-
snapshot?: boolean;
|
|
395
|
-
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>> | undefined;
|
|
396
|
-
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>> | undefined;
|
|
397
|
-
};
|
|
398
|
-
//#endregion
|
|
399
369
|
//#region src/rpc/functions/upload.d.ts
|
|
400
370
|
/** Streaming channel name, namespaced like every other RPC name in this plugin. */
|
|
401
371
|
declare const UPLOAD_CHANNEL = "devframes:plugin:assets:upload";
|
|
@@ -461,12 +431,14 @@ declare const readFunctions: readonly [{
|
|
|
461
431
|
publicPath: string;
|
|
462
432
|
size: number;
|
|
463
433
|
mtime: number;
|
|
434
|
+
fsPath?: string | undefined;
|
|
464
435
|
}[], {
|
|
465
436
|
path: string;
|
|
466
437
|
type: "image" | "font" | "video" | "audio" | "text" | "other";
|
|
467
438
|
publicPath: string;
|
|
468
439
|
size: number;
|
|
469
440
|
mtime: number;
|
|
441
|
+
fsPath?: string | undefined;
|
|
470
442
|
}[]>;
|
|
471
443
|
jsonSerializable?: boolean;
|
|
472
444
|
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
@@ -476,6 +448,7 @@ declare const readFunctions: readonly [{
|
|
|
476
448
|
publicPath: string;
|
|
477
449
|
size: number;
|
|
478
450
|
mtime: number;
|
|
451
|
+
fsPath?: string | undefined;
|
|
479
452
|
}[]>>>) | undefined;
|
|
480
453
|
handler?: (() => import("devframe/rpc").Thenable<{
|
|
481
454
|
path: string;
|
|
@@ -483,6 +456,7 @@ declare const readFunctions: readonly [{
|
|
|
483
456
|
publicPath: string;
|
|
484
457
|
size: number;
|
|
485
458
|
mtime: number;
|
|
459
|
+
fsPath?: string | undefined;
|
|
486
460
|
}[]>) | undefined;
|
|
487
461
|
dump?: import("devframe/rpc").RpcDump<[], import("devframe/rpc").Thenable<{
|
|
488
462
|
path: string;
|
|
@@ -490,6 +464,7 @@ declare const readFunctions: readonly [{
|
|
|
490
464
|
publicPath: string;
|
|
491
465
|
size: number;
|
|
492
466
|
mtime: number;
|
|
467
|
+
fsPath?: string | undefined;
|
|
493
468
|
}[]>, import("devframe").DevframeNodeContext> | undefined;
|
|
494
469
|
snapshot?: boolean;
|
|
495
470
|
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[], import("devframe/rpc").Thenable<{
|
|
@@ -498,6 +473,7 @@ declare const readFunctions: readonly [{
|
|
|
498
473
|
publicPath: string;
|
|
499
474
|
size: number;
|
|
500
475
|
mtime: number;
|
|
476
|
+
fsPath?: string | undefined;
|
|
501
477
|
}[]>>>> | undefined;
|
|
502
478
|
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[], import("devframe/rpc").Thenable<{
|
|
503
479
|
path: string;
|
|
@@ -505,6 +481,7 @@ declare const readFunctions: readonly [{
|
|
|
505
481
|
publicPath: string;
|
|
506
482
|
size: number;
|
|
507
483
|
mtime: number;
|
|
484
|
+
fsPath?: string | undefined;
|
|
508
485
|
}[]>>> | undefined;
|
|
509
486
|
}, {
|
|
510
487
|
name: "devframes:plugin:assets:read-image-meta";
|
|
@@ -598,39 +575,6 @@ declare const readFunctions: readonly [{
|
|
|
598
575
|
uploadExtensions: string[] | "*";
|
|
599
576
|
}>>> | undefined;
|
|
600
577
|
}];
|
|
601
|
-
/**
|
|
602
|
-
* Informational actions — launch external apps, never touch the managed
|
|
603
|
-
* directory's contents. Always registered regardless of `write`.
|
|
604
|
-
*/
|
|
605
|
-
declare const alwaysFunctions: readonly [{
|
|
606
|
-
name: "devframes:plugin:assets:open-in-editor";
|
|
607
|
-
type?: "action" | undefined;
|
|
608
|
-
cacheable?: boolean;
|
|
609
|
-
args: readonly [import("devframe/utils/simple-schema").SimpleSchema<string, string>];
|
|
610
|
-
returns: import("devframe/utils/simple-schema").SimpleSchema<void, void>;
|
|
611
|
-
jsonSerializable?: boolean;
|
|
612
|
-
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
613
|
-
setup?: ((context: import("devframe").DevframeNodeContext) => import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>) | undefined;
|
|
614
|
-
handler?: ((args_0: string) => import("devframe/rpc").Thenable<void>) | undefined;
|
|
615
|
-
dump?: import("devframe/rpc").RpcDump<[string], import("devframe/rpc").Thenable<void>, import("devframe").DevframeNodeContext> | undefined;
|
|
616
|
-
snapshot?: boolean;
|
|
617
|
-
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>> | undefined;
|
|
618
|
-
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>> | undefined;
|
|
619
|
-
}, {
|
|
620
|
-
name: "devframes:plugin:assets:reveal-in-folder";
|
|
621
|
-
type?: "action" | undefined;
|
|
622
|
-
cacheable?: boolean;
|
|
623
|
-
args: readonly [import("devframe/utils/simple-schema").SimpleSchema<string, string>];
|
|
624
|
-
returns: import("devframe/utils/simple-schema").SimpleSchema<void, void>;
|
|
625
|
-
jsonSerializable?: boolean;
|
|
626
|
-
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
627
|
-
setup?: ((context: import("devframe").DevframeNodeContext) => import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>) | undefined;
|
|
628
|
-
handler?: ((args_0: string) => import("devframe/rpc").Thenable<void>) | undefined;
|
|
629
|
-
dump?: import("devframe/rpc").RpcDump<[string], import("devframe/rpc").Thenable<void>, import("devframe").DevframeNodeContext> | undefined;
|
|
630
|
-
snapshot?: boolean;
|
|
631
|
-
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>> | undefined;
|
|
632
|
-
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>> | undefined;
|
|
633
|
-
}];
|
|
634
578
|
/** Mutating RPC — registered only when write actions are enabled. */
|
|
635
579
|
declare const writeFunctions: readonly [{
|
|
636
580
|
name: "devframes:plugin:assets:upload";
|
|
@@ -691,12 +635,14 @@ declare const writeFunctions: readonly [{
|
|
|
691
635
|
publicPath: string;
|
|
692
636
|
size: number;
|
|
693
637
|
mtime: number;
|
|
638
|
+
fsPath?: string | undefined;
|
|
694
639
|
}, {
|
|
695
640
|
path: string;
|
|
696
641
|
type: "image" | "font" | "video" | "audio" | "text" | "other";
|
|
697
642
|
publicPath: string;
|
|
698
643
|
size: number;
|
|
699
644
|
mtime: number;
|
|
645
|
+
fsPath?: string | undefined;
|
|
700
646
|
}>;
|
|
701
647
|
jsonSerializable?: boolean;
|
|
702
648
|
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
@@ -709,6 +655,7 @@ declare const writeFunctions: readonly [{
|
|
|
709
655
|
publicPath: string;
|
|
710
656
|
size: number;
|
|
711
657
|
mtime: number;
|
|
658
|
+
fsPath?: string | undefined;
|
|
712
659
|
}>>>) | undefined;
|
|
713
660
|
handler?: ((args_0: {
|
|
714
661
|
path: string;
|
|
@@ -719,6 +666,7 @@ declare const writeFunctions: readonly [{
|
|
|
719
666
|
publicPath: string;
|
|
720
667
|
size: number;
|
|
721
668
|
mtime: number;
|
|
669
|
+
fsPath?: string | undefined;
|
|
722
670
|
}>) | undefined;
|
|
723
671
|
dump?: import("devframe/rpc").RpcDump<[{
|
|
724
672
|
path: string;
|
|
@@ -729,6 +677,7 @@ declare const writeFunctions: readonly [{
|
|
|
729
677
|
publicPath: string;
|
|
730
678
|
size: number;
|
|
731
679
|
mtime: number;
|
|
680
|
+
fsPath?: string | undefined;
|
|
732
681
|
}>, import("devframe").DevframeNodeContext> | undefined;
|
|
733
682
|
snapshot?: boolean;
|
|
734
683
|
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[{
|
|
@@ -740,6 +689,7 @@ declare const writeFunctions: readonly [{
|
|
|
740
689
|
publicPath: string;
|
|
741
690
|
size: number;
|
|
742
691
|
mtime: number;
|
|
692
|
+
fsPath?: string | undefined;
|
|
743
693
|
}>>>> | undefined;
|
|
744
694
|
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[{
|
|
745
695
|
path: string;
|
|
@@ -750,6 +700,7 @@ declare const writeFunctions: readonly [{
|
|
|
750
700
|
publicPath: string;
|
|
751
701
|
size: number;
|
|
752
702
|
mtime: number;
|
|
703
|
+
fsPath?: string | undefined;
|
|
753
704
|
}>>> | undefined;
|
|
754
705
|
}, {
|
|
755
706
|
name: "devframes:plugin:assets:delete";
|
|
@@ -833,12 +784,14 @@ declare const serverFunctions: readonly [{
|
|
|
833
784
|
publicPath: string;
|
|
834
785
|
size: number;
|
|
835
786
|
mtime: number;
|
|
787
|
+
fsPath?: string | undefined;
|
|
836
788
|
}[], {
|
|
837
789
|
path: string;
|
|
838
790
|
type: "image" | "font" | "video" | "audio" | "text" | "other";
|
|
839
791
|
publicPath: string;
|
|
840
792
|
size: number;
|
|
841
793
|
mtime: number;
|
|
794
|
+
fsPath?: string | undefined;
|
|
842
795
|
}[]>;
|
|
843
796
|
jsonSerializable?: boolean;
|
|
844
797
|
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
@@ -848,6 +801,7 @@ declare const serverFunctions: readonly [{
|
|
|
848
801
|
publicPath: string;
|
|
849
802
|
size: number;
|
|
850
803
|
mtime: number;
|
|
804
|
+
fsPath?: string | undefined;
|
|
851
805
|
}[]>>>) | undefined;
|
|
852
806
|
handler?: (() => import("devframe/rpc").Thenable<{
|
|
853
807
|
path: string;
|
|
@@ -855,6 +809,7 @@ declare const serverFunctions: readonly [{
|
|
|
855
809
|
publicPath: string;
|
|
856
810
|
size: number;
|
|
857
811
|
mtime: number;
|
|
812
|
+
fsPath?: string | undefined;
|
|
858
813
|
}[]>) | undefined;
|
|
859
814
|
dump?: import("devframe/rpc").RpcDump<[], import("devframe/rpc").Thenable<{
|
|
860
815
|
path: string;
|
|
@@ -862,6 +817,7 @@ declare const serverFunctions: readonly [{
|
|
|
862
817
|
publicPath: string;
|
|
863
818
|
size: number;
|
|
864
819
|
mtime: number;
|
|
820
|
+
fsPath?: string | undefined;
|
|
865
821
|
}[]>, import("devframe").DevframeNodeContext> | undefined;
|
|
866
822
|
snapshot?: boolean;
|
|
867
823
|
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[], import("devframe/rpc").Thenable<{
|
|
@@ -870,6 +826,7 @@ declare const serverFunctions: readonly [{
|
|
|
870
826
|
publicPath: string;
|
|
871
827
|
size: number;
|
|
872
828
|
mtime: number;
|
|
829
|
+
fsPath?: string | undefined;
|
|
873
830
|
}[]>>>> | undefined;
|
|
874
831
|
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[], import("devframe/rpc").Thenable<{
|
|
875
832
|
path: string;
|
|
@@ -877,6 +834,7 @@ declare const serverFunctions: readonly [{
|
|
|
877
834
|
publicPath: string;
|
|
878
835
|
size: number;
|
|
879
836
|
mtime: number;
|
|
837
|
+
fsPath?: string | undefined;
|
|
880
838
|
}[]>>> | undefined;
|
|
881
839
|
}, {
|
|
882
840
|
name: "devframes:plugin:assets:read-image-meta";
|
|
@@ -969,34 +927,6 @@ declare const serverFunctions: readonly [{
|
|
|
969
927
|
write: boolean;
|
|
970
928
|
uploadExtensions: string[] | "*";
|
|
971
929
|
}>>> | undefined;
|
|
972
|
-
}, {
|
|
973
|
-
name: "devframes:plugin:assets:open-in-editor";
|
|
974
|
-
type?: "action" | undefined;
|
|
975
|
-
cacheable?: boolean;
|
|
976
|
-
args: readonly [import("devframe/utils/simple-schema").SimpleSchema<string, string>];
|
|
977
|
-
returns: import("devframe/utils/simple-schema").SimpleSchema<void, void>;
|
|
978
|
-
jsonSerializable?: boolean;
|
|
979
|
-
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
980
|
-
setup?: ((context: import("devframe").DevframeNodeContext) => import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>) | undefined;
|
|
981
|
-
handler?: ((args_0: string) => import("devframe/rpc").Thenable<void>) | undefined;
|
|
982
|
-
dump?: import("devframe/rpc").RpcDump<[string], import("devframe/rpc").Thenable<void>, import("devframe").DevframeNodeContext> | undefined;
|
|
983
|
-
snapshot?: boolean;
|
|
984
|
-
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>> | undefined;
|
|
985
|
-
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>> | undefined;
|
|
986
|
-
}, {
|
|
987
|
-
name: "devframes:plugin:assets:reveal-in-folder";
|
|
988
|
-
type?: "action" | undefined;
|
|
989
|
-
cacheable?: boolean;
|
|
990
|
-
args: readonly [import("devframe/utils/simple-schema").SimpleSchema<string, string>];
|
|
991
|
-
returns: import("devframe/utils/simple-schema").SimpleSchema<void, void>;
|
|
992
|
-
jsonSerializable?: boolean;
|
|
993
|
-
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
994
|
-
setup?: ((context: import("devframe").DevframeNodeContext) => import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>) | undefined;
|
|
995
|
-
handler?: ((args_0: string) => import("devframe/rpc").Thenable<void>) | undefined;
|
|
996
|
-
dump?: import("devframe/rpc").RpcDump<[string], import("devframe/rpc").Thenable<void>, import("devframe").DevframeNodeContext> | undefined;
|
|
997
|
-
snapshot?: boolean;
|
|
998
|
-
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>>> | undefined;
|
|
999
|
-
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string], import("devframe/rpc").Thenable<void>>> | undefined;
|
|
1000
930
|
}, {
|
|
1001
931
|
name: "devframes:plugin:assets:upload";
|
|
1002
932
|
type?: "action" | undefined;
|
|
@@ -1056,12 +986,14 @@ declare const serverFunctions: readonly [{
|
|
|
1056
986
|
publicPath: string;
|
|
1057
987
|
size: number;
|
|
1058
988
|
mtime: number;
|
|
989
|
+
fsPath?: string | undefined;
|
|
1059
990
|
}, {
|
|
1060
991
|
path: string;
|
|
1061
992
|
type: "image" | "font" | "video" | "audio" | "text" | "other";
|
|
1062
993
|
publicPath: string;
|
|
1063
994
|
size: number;
|
|
1064
995
|
mtime: number;
|
|
996
|
+
fsPath?: string | undefined;
|
|
1065
997
|
}>;
|
|
1066
998
|
jsonSerializable?: boolean;
|
|
1067
999
|
agent?: import("devframe").RpcFunctionAgentOptions;
|
|
@@ -1074,6 +1006,7 @@ declare const serverFunctions: readonly [{
|
|
|
1074
1006
|
publicPath: string;
|
|
1075
1007
|
size: number;
|
|
1076
1008
|
mtime: number;
|
|
1009
|
+
fsPath?: string | undefined;
|
|
1077
1010
|
}>>>) | undefined;
|
|
1078
1011
|
handler?: ((args_0: {
|
|
1079
1012
|
path: string;
|
|
@@ -1084,6 +1017,7 @@ declare const serverFunctions: readonly [{
|
|
|
1084
1017
|
publicPath: string;
|
|
1085
1018
|
size: number;
|
|
1086
1019
|
mtime: number;
|
|
1020
|
+
fsPath?: string | undefined;
|
|
1087
1021
|
}>) | undefined;
|
|
1088
1022
|
dump?: import("devframe/rpc").RpcDump<[{
|
|
1089
1023
|
path: string;
|
|
@@ -1094,6 +1028,7 @@ declare const serverFunctions: readonly [{
|
|
|
1094
1028
|
publicPath: string;
|
|
1095
1029
|
size: number;
|
|
1096
1030
|
mtime: number;
|
|
1031
|
+
fsPath?: string | undefined;
|
|
1097
1032
|
}>, import("devframe").DevframeNodeContext> | undefined;
|
|
1098
1033
|
snapshot?: boolean;
|
|
1099
1034
|
__cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[{
|
|
@@ -1105,6 +1040,7 @@ declare const serverFunctions: readonly [{
|
|
|
1105
1040
|
publicPath: string;
|
|
1106
1041
|
size: number;
|
|
1107
1042
|
mtime: number;
|
|
1043
|
+
fsPath?: string | undefined;
|
|
1108
1044
|
}>>>> | undefined;
|
|
1109
1045
|
__promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[{
|
|
1110
1046
|
path: string;
|
|
@@ -1115,6 +1051,7 @@ declare const serverFunctions: readonly [{
|
|
|
1115
1051
|
publicPath: string;
|
|
1116
1052
|
size: number;
|
|
1117
1053
|
mtime: number;
|
|
1054
|
+
fsPath?: string | undefined;
|
|
1118
1055
|
}>>> | undefined;
|
|
1119
1056
|
}, {
|
|
1120
1057
|
name: "devframes:plugin:assets:delete";
|
|
@@ -1191,4 +1128,4 @@ declare module 'devframe' {
|
|
|
1191
1128
|
interface DevframeRpcServerFunctions extends RpcDefinitionsToFunctions<typeof serverFunctions> {}
|
|
1192
1129
|
}
|
|
1193
1130
|
//#endregion
|
|
1194
|
-
export { type AssetsCapabilities, type RenameArgs, UPLOAD_CHANNEL,
|
|
1131
|
+
export { type AssetsCapabilities, type RenameArgs, UPLOAD_CHANNEL, assetInfoSchema, capabilities, deleteAssets, list, mkdir, readFunctions, readImageMeta, readText, rename, serverFunctions, upload, writeFunctions };
|
package/dist/rpc/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { UPLOAD_CHANNEL,
|
|
1
|
+
import { a as readText, c as assetInfoSchema, f as deleteAssets, h as upload, i as rename, l as list, m as UPLOAD_CHANNEL, n as serverFunctions, o as readImageMeta, p as capabilities, r as writeFunctions, s as mkdir, t as readFunctions } from "../rpc-BOraEthN.mjs";
|
|
2
|
+
export { UPLOAD_CHANNEL, assetInfoSchema, capabilities, deleteAssets, list, mkdir, readFunctions, readImageMeta, readText, rename, serverFunctions, upload, writeFunctions };
|
|
@@ -6,9 +6,7 @@ import { s } from "devframe/utils/simple-schema";
|
|
|
6
6
|
import { defineDiagnostics } from "devframe/utils/nostics";
|
|
7
7
|
import { glob } from "tinyglobby";
|
|
8
8
|
import { joinURL } from "ufo";
|
|
9
|
-
import { launchEditor } from "devframe/utils/launch-editor";
|
|
10
9
|
import { imageMeta } from "image-meta";
|
|
11
|
-
import { open } from "devframe/utils/open";
|
|
12
10
|
//#region src/diagnostics.ts
|
|
13
11
|
const diagnostics = defineDiagnostics({
|
|
14
12
|
docsBase: "https://devfra.me/errors",
|
|
@@ -93,7 +91,7 @@ function getAssetsContext(ctx) {
|
|
|
93
91
|
}
|
|
94
92
|
//#endregion
|
|
95
93
|
//#region src/rpc/functions/upload.ts
|
|
96
|
-
const defineAssetsRpc$
|
|
94
|
+
const defineAssetsRpc$7 = createDefineWrapperWithContext();
|
|
97
95
|
/** Streaming channel name, namespaced like every other RPC name in this plugin. */
|
|
98
96
|
const UPLOAD_CHANNEL = "devframes:plugin:assets:upload";
|
|
99
97
|
function isExtensionAllowed(path, allowed) {
|
|
@@ -106,7 +104,7 @@ function isExtensionAllowed(path, allowed) {
|
|
|
106
104
|
* the `upload` channel opened in `setupAssets` — see the client-side
|
|
107
105
|
* `useUpload` hook for the matching `rpc.streaming.upload()` call.
|
|
108
106
|
*/
|
|
109
|
-
const upload = defineAssetsRpc$
|
|
107
|
+
const upload = defineAssetsRpc$7({
|
|
110
108
|
name: "devframes:plugin:assets:upload",
|
|
111
109
|
type: "action",
|
|
112
110
|
jsonSerializable: true,
|
|
@@ -226,19 +224,24 @@ function toPublicPath(baseURL, posixPath) {
|
|
|
226
224
|
const encoded = posixPath.split("/").map(encodeURIComponent).join("/");
|
|
227
225
|
return joinURL(baseURL, encoded);
|
|
228
226
|
}
|
|
229
|
-
/**
|
|
230
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Builds an {@link AssetInfo} from an already-resolved `fs.Stats`. Pass
|
|
229
|
+
* `includeFsPath` (dev mode only) to attach the absolute `fsPath` the client
|
|
230
|
+
* hands to the open wire service.
|
|
231
|
+
*/
|
|
232
|
+
function statToAssetInfo(dir, baseURL, relPath, stat, includeFsPath = false) {
|
|
231
233
|
const posixPath = relPath.replace(/\\/g, "/");
|
|
232
234
|
return {
|
|
233
235
|
path: posixPath,
|
|
234
236
|
type: guessAssetType(posixPath),
|
|
235
237
|
publicPath: toPublicPath(baseURL, posixPath),
|
|
236
238
|
size: stat.size,
|
|
237
|
-
mtime: stat.mtimeMs
|
|
239
|
+
mtime: stat.mtimeMs,
|
|
240
|
+
...includeFsPath ? { fsPath: join(dir, relPath) } : {}
|
|
238
241
|
};
|
|
239
242
|
}
|
|
240
243
|
/** Recursively lists every file under `dir`, sorted alphabetically by path. */
|
|
241
|
-
async function scanAssets(dir, baseURL) {
|
|
244
|
+
async function scanAssets(dir, baseURL, includeFsPath = false) {
|
|
242
245
|
const files = await glob(["**/*"], {
|
|
243
246
|
cwd: dir,
|
|
244
247
|
onlyFiles: true,
|
|
@@ -246,7 +249,7 @@ async function scanAssets(dir, baseURL) {
|
|
|
246
249
|
});
|
|
247
250
|
return (await Promise.all(files.map(async (relPath) => {
|
|
248
251
|
try {
|
|
249
|
-
return statToAssetInfo(dir, baseURL, relPath, await fsp.lstat(join(dir, relPath)));
|
|
252
|
+
return statToAssetInfo(dir, baseURL, relPath, await fsp.lstat(join(dir, relPath)), includeFsPath);
|
|
250
253
|
} catch {
|
|
251
254
|
return;
|
|
252
255
|
}
|
|
@@ -254,7 +257,7 @@ async function scanAssets(dir, baseURL) {
|
|
|
254
257
|
}
|
|
255
258
|
//#endregion
|
|
256
259
|
//#region src/rpc/functions/list.ts
|
|
257
|
-
const defineAssetsRpc$
|
|
260
|
+
const defineAssetsRpc$4 = createDefineWrapperWithContext();
|
|
258
261
|
const assetInfoSchema = s.object({
|
|
259
262
|
path: s.string(),
|
|
260
263
|
type: s.picklist([
|
|
@@ -267,9 +270,10 @@ const assetInfoSchema = s.object({
|
|
|
267
270
|
]),
|
|
268
271
|
publicPath: s.string(),
|
|
269
272
|
size: s.number(),
|
|
270
|
-
mtime: s.number()
|
|
273
|
+
mtime: s.number(),
|
|
274
|
+
fsPath: s.optional(s.string())
|
|
271
275
|
});
|
|
272
|
-
const list = defineAssetsRpc$
|
|
276
|
+
const list = defineAssetsRpc$4({
|
|
273
277
|
name: "devframes:plugin:assets:list",
|
|
274
278
|
type: "query",
|
|
275
279
|
snapshot: true,
|
|
@@ -284,7 +288,7 @@ const list = defineAssetsRpc$6({
|
|
|
284
288
|
},
|
|
285
289
|
setup: (ctx) => {
|
|
286
290
|
const assets = getAssetsContext(ctx);
|
|
287
|
-
return { handler: (async () => scanAssets(assets.dir, assets.baseURL)) };
|
|
291
|
+
return { handler: (async () => scanAssets(assets.dir, assets.baseURL, ctx.mode === "dev")) };
|
|
288
292
|
}
|
|
289
293
|
});
|
|
290
294
|
const mkdir = createDefineWrapperWithContext()({
|
|
@@ -309,31 +313,6 @@ const mkdir = createDefineWrapperWithContext()({
|
|
|
309
313
|
}) };
|
|
310
314
|
}
|
|
311
315
|
});
|
|
312
|
-
/**
|
|
313
|
-
* Reuses devframe's `launchEditor` utility (the same one backing the core
|
|
314
|
-
* `devframe:open-in-editor` recipe) but resolves the path against the
|
|
315
|
-
* managed directory first, so the client only ever sends a root-relative
|
|
316
|
-
* path — never the server's absolute filesystem layout.
|
|
317
|
-
*/
|
|
318
|
-
const openInEditor = createDefineWrapperWithContext()({
|
|
319
|
-
name: "devframes:plugin:assets:open-in-editor",
|
|
320
|
-
type: "action",
|
|
321
|
-
jsonSerializable: true,
|
|
322
|
-
args: [s.string()],
|
|
323
|
-
returns: s.void(),
|
|
324
|
-
agent: {
|
|
325
|
-
title: "Open an asset in the editor",
|
|
326
|
-
description: "Open an asset in the user's configured editor.",
|
|
327
|
-
safety: "action",
|
|
328
|
-
tags: ["assets"]
|
|
329
|
-
},
|
|
330
|
-
setup: (ctx) => {
|
|
331
|
-
const assets = getAssetsContext(ctx);
|
|
332
|
-
return { handler: (async (path) => {
|
|
333
|
-
launchEditor(assets.resolvePath(path));
|
|
334
|
-
}) };
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
316
|
const readImageMeta = createDefineWrapperWithContext()({
|
|
338
317
|
name: "devframes:plugin:assets:read-image-meta",
|
|
339
318
|
type: "query",
|
|
@@ -369,9 +348,9 @@ const readImageMeta = createDefineWrapperWithContext()({
|
|
|
369
348
|
});
|
|
370
349
|
//#endregion
|
|
371
350
|
//#region src/rpc/functions/read-text.ts
|
|
372
|
-
const defineAssetsRpc$
|
|
351
|
+
const defineAssetsRpc$1 = createDefineWrapperWithContext();
|
|
373
352
|
const DEFAULT_LIMIT = 5e3;
|
|
374
|
-
const readText = defineAssetsRpc$
|
|
353
|
+
const readText = defineAssetsRpc$1({
|
|
375
354
|
name: "devframes:plugin:assets:read-text",
|
|
376
355
|
type: "query",
|
|
377
356
|
jsonSerializable: true,
|
|
@@ -421,7 +400,7 @@ const rename = createDefineWrapperWithContext()({
|
|
|
421
400
|
const to = assets.resolvePath(nextRelPath);
|
|
422
401
|
if (from === to) {
|
|
423
402
|
const stat = await fsp.lstat(from);
|
|
424
|
-
return statToAssetInfo(assets.dir, assets.baseURL, path, stat);
|
|
403
|
+
return statToAssetInfo(assets.dir, assets.baseURL, path, stat, true);
|
|
425
404
|
}
|
|
426
405
|
if (await fsp.access(to).then(() => true).catch(() => false)) throw diagnostics.DP_ASSETS_0003({ path: nextRelPath });
|
|
427
406
|
await fsp.mkdir(dirname(to), { recursive: true });
|
|
@@ -432,32 +411,7 @@ const rename = createDefineWrapperWithContext()({
|
|
|
432
411
|
throw error;
|
|
433
412
|
}
|
|
434
413
|
const stat = await fsp.lstat(to);
|
|
435
|
-
return statToAssetInfo(assets.dir, assets.baseURL, nextRelPath, stat);
|
|
436
|
-
}) };
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
/**
|
|
440
|
-
* Reuses devframe's `open` utility (the same one backing the core
|
|
441
|
-
* `devframe:open-in-finder` recipe), opening the asset's containing folder
|
|
442
|
-
* so it's revealed in the OS file manager rather than launched with its
|
|
443
|
-
* default app (which `download` already covers).
|
|
444
|
-
*/
|
|
445
|
-
const revealInFolder = createDefineWrapperWithContext()({
|
|
446
|
-
name: "devframes:plugin:assets:reveal-in-folder",
|
|
447
|
-
type: "action",
|
|
448
|
-
jsonSerializable: true,
|
|
449
|
-
args: [s.string()],
|
|
450
|
-
returns: s.void(),
|
|
451
|
-
agent: {
|
|
452
|
-
title: "Reveal an asset in the file manager",
|
|
453
|
-
description: "Open the OS file manager at the asset's containing folder.",
|
|
454
|
-
safety: "action",
|
|
455
|
-
tags: ["assets"]
|
|
456
|
-
},
|
|
457
|
-
setup: (ctx) => {
|
|
458
|
-
const assets = getAssetsContext(ctx);
|
|
459
|
-
return { handler: (async (path) => {
|
|
460
|
-
await open(dirname(assets.resolvePath(path)));
|
|
414
|
+
return statToAssetInfo(assets.dir, assets.baseURL, nextRelPath, stat, true);
|
|
461
415
|
}) };
|
|
462
416
|
}
|
|
463
417
|
});
|
|
@@ -470,11 +424,6 @@ const readFunctions = [
|
|
|
470
424
|
readText,
|
|
471
425
|
capabilities
|
|
472
426
|
];
|
|
473
|
-
/**
|
|
474
|
-
* Informational actions — launch external apps, never touch the managed
|
|
475
|
-
* directory's contents. Always registered regardless of `write`.
|
|
476
|
-
*/
|
|
477
|
-
const alwaysFunctions = [openInEditor, revealInFolder];
|
|
478
427
|
/** Mutating RPC — registered only when write actions are enabled. */
|
|
479
428
|
const writeFunctions = [
|
|
480
429
|
upload,
|
|
@@ -482,10 +431,6 @@ const writeFunctions = [
|
|
|
482
431
|
deleteAssets,
|
|
483
432
|
mkdir
|
|
484
433
|
];
|
|
485
|
-
const serverFunctions = [
|
|
486
|
-
...readFunctions,
|
|
487
|
-
...alwaysFunctions,
|
|
488
|
-
...writeFunctions
|
|
489
|
-
];
|
|
434
|
+
const serverFunctions = [...readFunctions, ...writeFunctions];
|
|
490
435
|
//#endregion
|
|
491
|
-
export {
|
|
436
|
+
export { getAssetsContext as _, readText as a, assetInfoSchema as c, scanAssets as d, deleteAssets as f, configureAssets as g, upload as h, rename as i, list as l, UPLOAD_CHANNEL as m, serverFunctions as n, readImageMeta as o, capabilities as p, writeFunctions as r, mkdir as s, readFunctions as t, guessAssetType as u, resolveAssetPath as v };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { n as setupAssets } from "./node-
|
|
1
|
+
import { n as setupAssets } from "./node-Cit_U9yi.mjs";
|
|
2
|
+
import process from "node:process";
|
|
2
3
|
import { defineDevframe } from "devframe";
|
|
3
4
|
import { resolve } from "pathe";
|
|
4
5
|
//#region package.json
|
|
5
6
|
var name = "@devframes/plugin-assets";
|
|
6
|
-
var version = "0.9.
|
|
7
|
+
var version = "0.9.2";
|
|
7
8
|
var description = "Devframe plugin for browsing, previewing, uploading, and managing static assets in a directory.";
|
|
8
9
|
var homepage = "https://github.com/devframes/devframe#readme";
|
|
9
10
|
//#endregion
|
|
@@ -34,8 +35,7 @@ const DEFAULT_ALLOWED_UPLOAD_EXTENSIONS = [
|
|
|
34
35
|
//#region src/index.ts
|
|
35
36
|
const remoteAssets = {
|
|
36
37
|
package: `${name}--assets`,
|
|
37
|
-
version
|
|
38
|
-
resolveFrom: import.meta.url
|
|
38
|
+
version
|
|
39
39
|
};
|
|
40
40
|
const DEFAULT_ID = "devframes_plugin_assets";
|
|
41
41
|
/**
|
|
@@ -48,6 +48,7 @@ const DEFAULT_ID = "devframes_plugin_assets";
|
|
|
48
48
|
*/
|
|
49
49
|
function createAssetsDevframe(options = {}) {
|
|
50
50
|
const id = options.id ?? DEFAULT_ID;
|
|
51
|
+
const dir = options.dir ? resolve(process.cwd(), options.dir) : resolve(process.cwd(), "public");
|
|
51
52
|
const distDir = options.distDir ?? remoteAssets;
|
|
52
53
|
const write = options.write ?? true;
|
|
53
54
|
const serveStatic = options.serveStatic ?? false;
|
|
@@ -57,6 +58,7 @@ function createAssetsDevframe(options = {}) {
|
|
|
57
58
|
name: options.name ?? "Assets",
|
|
58
59
|
version,
|
|
59
60
|
packageName: name,
|
|
61
|
+
importMetaUrl: import.meta.url,
|
|
60
62
|
homepage,
|
|
61
63
|
description,
|
|
62
64
|
icon: options.icon ?? "ph:image-square-duotone",
|
|
@@ -72,9 +74,12 @@ function createAssetsDevframe(options = {}) {
|
|
|
72
74
|
}
|
|
73
75
|
},
|
|
74
76
|
dock: { category: "~builtin" },
|
|
77
|
+
services: [{
|
|
78
|
+
package: "@devframes/service-open",
|
|
79
|
+
options: { roots: [dir] }
|
|
80
|
+
}, { package: "@devframes/service-shiki" }],
|
|
75
81
|
async setup(ctx, info) {
|
|
76
82
|
const readOnlyFlag = info?.flags?.readOnly === true;
|
|
77
|
-
const dir = options.dir ? resolve(ctx.cwd, options.dir) : resolve(ctx.cwd, "public");
|
|
78
83
|
await setupAssets(ctx, {
|
|
79
84
|
dir,
|
|
80
85
|
write: readOnlyFlag ? false : write,
|
|
@@ -11,6 +11,12 @@ interface AssetInfo {
|
|
|
11
11
|
size: number;
|
|
12
12
|
/** `mtimeMs` — milliseconds since epoch. */
|
|
13
13
|
mtime: number;
|
|
14
|
+
/**
|
|
15
|
+
* Absolute filesystem path — populated in `dev` mode only (never baked
|
|
16
|
+
* into a static build's dump), so the client can hand it to the
|
|
17
|
+
* `@devframes/service-open` wire service for open-in-editor / reveal.
|
|
18
|
+
*/
|
|
19
|
+
fsPath?: string;
|
|
14
20
|
}
|
|
15
21
|
interface AssetImageMeta {
|
|
16
22
|
width?: number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devframes/plugin-assets",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.2",
|
|
5
5
|
"description": "Devframe plugin for browsing, previewing, uploading, and managing static assets in a directory.",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -38,13 +38,17 @@
|
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"vite": "^7.0.0 || ^8.0.0",
|
|
41
|
-
"@devframes/
|
|
42
|
-
"devframe": "0.9.
|
|
41
|
+
"@devframes/service-shiki": "0.9.2",
|
|
42
|
+
"devframe": "0.9.2",
|
|
43
|
+
"@devframes/plugin-assets--assets": "0.9.2"
|
|
43
44
|
},
|
|
44
45
|
"peerDependenciesMeta": {
|
|
45
46
|
"@devframes/plugin-assets--assets": {
|
|
46
47
|
"optional": true
|
|
47
48
|
},
|
|
49
|
+
"@devframes/service-shiki": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
48
52
|
"vite": {
|
|
49
53
|
"optional": true
|
|
50
54
|
}
|
|
@@ -56,29 +60,31 @@
|
|
|
56
60
|
"pathe": "^2.0.3",
|
|
57
61
|
"perfect-debounce": "^2.1.0",
|
|
58
62
|
"tinyglobby": "^0.2.17",
|
|
59
|
-
"ufo": "^1.6.4"
|
|
63
|
+
"ufo": "^1.6.4",
|
|
64
|
+
"@devframes/service-open": "0.9.2"
|
|
60
65
|
},
|
|
61
66
|
"devDependencies": {
|
|
62
67
|
"@antfu/design": "^0.3.4",
|
|
63
68
|
"@iconify-json/ph": "^1.2.2",
|
|
64
|
-
"@storybook/addon-a11y": "^10.5.
|
|
65
|
-
"@storybook/addon-docs": "^10.5.
|
|
66
|
-
"@storybook/vue3-vite": "^10.5.
|
|
69
|
+
"@storybook/addon-a11y": "^10.5.8",
|
|
70
|
+
"@storybook/addon-docs": "^10.5.8",
|
|
71
|
+
"@storybook/vue3-vite": "^10.5.8",
|
|
67
72
|
"@types/node": "^26.2.0",
|
|
68
73
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
69
74
|
"colorjs.io": "^0.7.1",
|
|
70
75
|
"floating-vue": "^5.2.2",
|
|
71
76
|
"h3": "^2.0.1-rc.26",
|
|
72
77
|
"reka-ui": "^2.10.3",
|
|
73
|
-
"storybook": "^10.5.
|
|
78
|
+
"storybook": "^10.5.8",
|
|
74
79
|
"tsdown": "^0.22.14",
|
|
75
80
|
"unocss": "^66.7.5",
|
|
76
81
|
"vite": "^8.2.1",
|
|
77
82
|
"vitest": "^4.1.10",
|
|
78
83
|
"vue": "^3.5.41",
|
|
79
|
-
"@devframes/
|
|
80
|
-
"
|
|
81
|
-
"@devframes/
|
|
84
|
+
"@devframes/plugin-assets--assets": "0.9.2",
|
|
85
|
+
"@devframes/service-shiki": "0.9.2",
|
|
86
|
+
"@devframes/vite": "0.9.2",
|
|
87
|
+
"devframe": "0.9.2"
|
|
82
88
|
},
|
|
83
89
|
"scripts": {
|
|
84
90
|
"build": "tsdown && vite build --config src/spa/vite.config.ts",
|