@devframes/plugin-assets 0.9.9 → 0.9.11

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/bin.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import process from 'node:process'
3
- import { createAssetsCli } from './dist/cli.mjs'
3
+ import { createAssetsCli } from './dist/node/cli.mjs'
4
4
 
5
5
  async function main() {
6
6
  await createAssetsCli().parse()
@@ -1,5 +1,5 @@
1
1
  import { CacHandle } from "devframe/adapters/cac";
2
- //#region src/cli.d.ts
2
+ //#region src/node/cli.d.ts
3
3
  declare function createAssetsCli(): CacHandle;
4
4
  //#endregion
5
5
  export { createAssetsCli };
@@ -1,6 +1,6 @@
1
- import { t as createAssetsDevframe } from "./src-BpDib51Z.mjs";
1
+ import { t as createAssetsDevframe } from "../node-Bv-v7YvO.mjs";
2
2
  import { createCac } from "devframe/adapters/cac";
3
- //#region src/cli.ts
3
+ //#region src/node/cli.ts
4
4
  function createAssetsCli() {
5
5
  return createCac(createAssetsDevframe({ serveStatic: true }));
6
6
  }
@@ -1,102 +1,79 @@
1
- import { n as AssetInfo, r as AssetType } from "../types-BKiX3RbA.mjs";
2
- import { DevframeNodeContext, RpcStreamingChannel } from "devframe";
3
- //#region src/node/context.d.ts
4
- interface AssetsConfig {
5
- /** Directory this devframe manages. */
6
- dir: string;
7
- /** Whether upload / rename / delete / mkdir are registered. */
8
- write: boolean;
9
- /** Extensions `upload` accepts, or `'*'` to accept any. */
10
- uploadExtensions: readonly string[] | '*';
1
+ import { a as DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, i as CodeSnippet, n as AssetInfo, r as AssetType, t as AssetImageMeta } from "../types-Bspm5Ylo.mjs";
2
+ import { DevframeDefinition } from "devframe";
3
+ //#region src/node/index.d.ts
4
+ interface AssetsDevframeOptions {
5
+ id?: string;
6
+ name?: string;
7
+ icon?: string;
11
8
  /**
12
- * URL base the managed directory is served at. Normally the host
13
- * (Vite / Nuxt / …) serves `public/` at `/`, so asset `publicPath`s are
14
- * `joinURL(baseURL, path)` and the plugin serves nothing itself.
9
+ * Directory this devframe manages. Defaults to `<cwd>/public`, the
10
+ * conventional static-asset folder for Nuxt, Vite, and most static-site
11
+ * frameworks. Pass an absolute path, or one relative to the devframe's
12
+ * own `cwd`.
15
13
  */
16
- baseURL: string;
17
- /** The upload streaming channel, created once in `setupAssets` when `write` is enabled. */
18
- uploadChannel?: RpcStreamingChannel<Uint8Array>;
19
- }
20
- interface AssetsContext extends AssetsConfig {
14
+ dir?: string;
21
15
  /**
22
- * Resolve a root-relative path to an absolute one, rejecting lexical
23
- * escapes. Symlink-aware containment for reads and mutations lives in
24
- * `node/paths` (`resolveAssetReadPath` / `assertAssetMutationPath`), which
25
- * the RPC handlers call directly with {@link AssetsContext.dir}.
16
+ * URL base the **host** serves the managed directory at, used to build
17
+ * each asset's `publicPath`. Defaults to `/`; Vite, Nuxt, and most
18
+ * frameworks serve their `public/` folder at the site root. Set this to
19
+ * match a non-root deployment base (e.g. Nuxt's `app.baseURL`).
26
20
  */
27
- resolvePath: (relativePath: string) => string;
28
- }
29
- /**
30
- * Record the managed directory and write policy for a context. Called from
31
- * the devframe's `setup` before any RPC handler runs.
32
- */
33
- declare function configureAssets(ctx: DevframeNodeContext, config: AssetsConfig): void;
34
- /**
35
- * Per-`DevframeNodeContext` assets state. Each RPC function pulls its
36
- * managed directory and path resolver from here instead of re-reading
37
- * `configureAssets`'s config on every call.
38
- */
39
- declare function getAssetsContext(ctx: DevframeNodeContext): AssetsContext;
40
- //#endregion
41
- //#region src/node/paths.d.ts
42
- /**
43
- * Resolve a client-supplied, root-relative path against the managed
44
- * directory, rejecting anything that would escape it lexically (`..`
45
- * traversal, a rogue absolute path). The first guard every RPC handler runs;
46
- * symlink-aware containment is layered on by {@link resolveAssetReadPath}
47
- * (reads) and {@link assertAssetMutationPath} (mutations).
48
- */
49
- declare function resolveAssetPath(root: string, relativePath: string): string;
50
- //#endregion
51
- //#region src/node/scanner.d.ts
52
- /** Classifies a path by extension, driving preview and icon choice. */
53
- declare function guessAssetType(path: string): AssetType;
54
- /** Recursively lists every file under `dir`, sorted alphabetically by path. */
55
- declare function scanAssets(dir: string, baseURL: string, includeFsPath?: boolean): Promise<AssetInfo[]>;
56
- //#endregion
57
- //#region src/node/index.d.ts
58
- interface SetupAssetsOptions {
59
- /** Directory this devframe manages. */
60
- dir: string;
61
- /** Whether upload / rename / delete / mkdir are registered. */
62
- write: boolean;
63
- /** Extensions `upload` accepts, or `'*'` to accept any. */
64
- uploadExtensions: readonly string[] | '*';
21
+ baseURL?: string;
22
+ /**
23
+ * Serve the managed directory's bytes from this devframe itself.
24
+ * Defaults to `false`: when mounted into a host (Vite/Nuxt/…) that host
25
+ * already serves `public/` at {@link baseURL}, so the plugin references
26
+ * those URLs instead of standing up its own route. The standalone CLI
27
+ * sets this to `true` (it is its own host), serving the directory under
28
+ * a dedicated base so it doesn't collide with the SPA at `/`.
29
+ */
30
+ serveStatic?: boolean;
31
+ basePath?: string;
32
+ distDir?: string;
33
+ /** Preferred standalone CLI port (default 9015). */
34
+ port?: number;
35
+ /**
36
+ * Enable upload, rename, delete, and folder creation from the UI.
37
+ * Enabled by default; set `false` (or pass `--read-only` on the
38
+ * standalone CLI) for a browse-only deployment.
39
+ */
40
+ write?: boolean;
41
+ /**
42
+ * Extensions `upload` accepts, or `'*'` to accept any file. Defaults to
43
+ * the same allow-list Nuxt DevTools ships.
44
+ */
45
+ uploadExtensions?: readonly string[] | '*';
46
+ /**
47
+ * Watch the managed directory in dev mode and push live listing updates.
48
+ * Enabled by default. Set `false` to skip the file watcher, useful when a
49
+ * host mounts the devframe in a short-lived or repeatedly-recreated
50
+ * context (tests, some SSR dev servers) where a background watcher isn't
51
+ * wanted.
52
+ */
53
+ watch?: boolean;
65
54
  /**
66
- * URL base the managed directory is served at, the base every asset's
67
- * `publicPath` is resolved against.
55
+ * Require the trust handshake on the standalone server. Enabled by
56
+ * default, because this devframe can read, write, and delete real files.
68
57
  */
69
- baseURL: string;
58
+ auth?: boolean;
70
59
  /**
71
- * Whether this devframe should serve the managed directory's bytes
72
- * itself. Left `false` when mounted into a host (Vite / Nuxt / …) that
73
- * already serves `public/` at {@link baseURL}; set `true` only for the
74
- * standalone CLI, which is its own host.
60
+ * Register the `build` CLI subcommand. Disabled by default: a static
61
+ * export can only ever list file metadata from a baked snapshot; there
62
+ * is no live host serving the files, and every write action is inherently
63
+ * excluded from a static dump, so the command would produce a broken,
64
+ * write-less shell of the tool. Opt back in if that degraded export is
65
+ * still useful to you.
75
66
  */
76
- serveStatic: boolean;
77
- /** Start the live file watcher (dev mode only). */
78
- watch: boolean;
67
+ build?: boolean;
79
68
  }
80
69
  /**
81
- * Register the assets RPC surface on a devframe node context: ensures the
82
- * managed directory exists, registers the read RPCs (always) and write
83
- * RPCs (when enabled), and starts a live file watcher in dev mode.
70
+ * Create the assets manager devframe, a framework-neutral port of Nuxt
71
+ * DevTools' Assets tab. Mount it into any host via devframe's adapters, or
72
+ * run it standalone with the bundled CLI (`devframe-assets`).
84
73
  *
85
- * Raw asset bytes (for `<img>`/`<video>`/download previews) are served by
86
- * the **host** the plugin is attached to: Vite, Nuxt, or any framework
87
- * already serves its `public/` dir at {@link SetupAssetsOptions.baseURL}.
88
- * The plugin only serves them itself when `serveStatic` is set (the
89
- * standalone CLI, which is its own host).
90
- *
91
- * Called from the definition's `setup(ctx)` and reusable by host adapters
92
- * that wire their own context.
93
- */
94
- declare function setupAssets(ctx: DevframeNodeContext, options: SetupAssetsOptions): Promise<void>;
95
- /**
96
- * Stop the live file watcher started by {@link setupAssets}. Test harnesses
97
- * wrap their dev-server `close()` with this (see `test/_utils.ts`), so a
98
- * leaked chokidar watcher doesn't keep the process alive.
74
+ * @experimental This plugin is experimental and may change without a major
75
+ * version bump until it stabilizes.
99
76
  */
100
- declare function disposeAssetsWatcher(ctx: DevframeNodeContext): Promise<void>;
77
+ declare function createAssetsDevframe(options?: AssetsDevframeOptions): DevframeDefinition;
101
78
  //#endregion
102
- export { SetupAssetsOptions, configureAssets, disposeAssetsWatcher, getAssetsContext, guessAssetType, resolveAssetPath, scanAssets, setupAssets };
79
+ export { type AssetImageMeta, type AssetInfo, type AssetType, AssetsDevframeOptions, type CodeSnippet, DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, createAssetsDevframe, createAssetsDevframe as default };
@@ -1,3 +1,2 @@
1
- import { n as setupAssets, t as disposeAssetsWatcher } from "../node-Diynhcd3.mjs";
2
- import { _ as getAssetsContext, d as scanAssets, g as configureAssets, u as guessAssetType, v as resolveAssetPath } from "../rpc-Pau8tZGm.mjs";
3
- export { configureAssets, disposeAssetsWatcher, getAssetsContext, guessAssetType, resolveAssetPath, scanAssets, setupAssets };
1
+ import { n as DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, t as createAssetsDevframe } from "../node-Bv-v7YvO.mjs";
2
+ export { DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, createAssetsDevframe, createAssetsDevframe as default };
@@ -1,6 +1,6 @@
1
1
  import { DevframeNodeContext } from "devframe";
2
2
  import { RpcDefinitionsToFunctions } from "devframe/rpc";
3
- //#region src/rpc/functions/capabilities.d.ts
3
+ //#region src/node/rpc/functions/capabilities.d.ts
4
4
  interface AssetsCapabilities {
5
5
  write: boolean;
6
6
  uploadExtensions: readonly string[] | '*';
@@ -48,7 +48,7 @@ declare const capabilities: {
48
48
  }>>> | undefined;
49
49
  };
50
50
  //#endregion
51
- //#region src/rpc/functions/delete.d.ts
51
+ //#region src/node/rpc/functions/delete.d.ts
52
52
  /** One request covers both single- and multi-select delete. */
53
53
  declare const deleteAssets: {
54
54
  name: "devframes:plugin:assets:delete";
@@ -94,7 +94,7 @@ declare const deleteAssets: {
94
94
  }>>> | undefined;
95
95
  };
96
96
  //#endregion
97
- //#region src/rpc/functions/list.d.ts
97
+ //#region src/node/rpc/functions/list.d.ts
98
98
  declare const assetInfoSchema: import("devframe/utils/simple-schema").SimpleSchema<{
99
99
  path: string;
100
100
  type: "image" | "font" | "video" | "audio" | "text" | "other";
@@ -175,7 +175,7 @@ declare const list: {
175
175
  }[]>>> | undefined;
176
176
  };
177
177
  //#endregion
178
- //#region src/rpc/functions/mkdir.d.ts
178
+ //#region src/node/rpc/functions/mkdir.d.ts
179
179
  declare const mkdir: {
180
180
  name: "devframes:plugin:assets:mkdir";
181
181
  type?: "action" | undefined;
@@ -206,7 +206,7 @@ declare const mkdir: {
206
206
  }], import("devframe/rpc").Thenable<void>>> | undefined;
207
207
  };
208
208
  //#endregion
209
- //#region src/rpc/functions/read-image-meta.d.ts
209
+ //#region src/node/rpc/functions/read-image-meta.d.ts
210
210
  declare const readImageMeta: {
211
211
  name: "devframes:plugin:assets:read-image-meta";
212
212
  type?: "query" | undefined;
@@ -251,7 +251,7 @@ declare const readImageMeta: {
251
251
  } | null>>> | undefined;
252
252
  };
253
253
  //#endregion
254
- //#region src/rpc/functions/read-text.d.ts
254
+ //#region src/node/rpc/functions/read-text.d.ts
255
255
  declare const readText: {
256
256
  name: "devframes:plugin:assets:read-text";
257
257
  type?: "query" | undefined;
@@ -268,7 +268,7 @@ declare const readText: {
268
268
  __promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[string, number | undefined], import("devframe/rpc").Thenable<string | null>>> | undefined;
269
269
  };
270
270
  //#endregion
271
- //#region src/rpc/functions/rename.d.ts
271
+ //#region src/node/rpc/functions/rename.d.ts
272
272
  interface RenameArgs {
273
273
  /** Root-relative path of the asset to rename. */
274
274
  path: string;
@@ -366,7 +366,7 @@ declare const rename: {
366
366
  }>>> | undefined;
367
367
  };
368
368
  //#endregion
369
- //#region src/rpc/functions/upload.d.ts
369
+ //#region src/node/rpc/functions/upload.d.ts
370
370
  /** Streaming channel name, namespaced like every other RPC name in this plugin. */
371
371
  declare const UPLOAD_CHANNEL = "devframes:plugin:assets:upload";
372
372
  /**
@@ -418,7 +418,7 @@ declare const upload: {
418
418
  }>>> | undefined;
419
419
  };
420
420
  //#endregion
421
- //#region src/rpc/index.d.ts
421
+ //#region src/node/rpc/index.d.ts
422
422
  /** Read-only RPC, always registered. */
423
423
  declare const readFunctions: readonly [{
424
424
  name: "devframes:plugin:assets:list";
@@ -1,2 +1,2 @@
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-Pau8tZGm.mjs";
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-DG9tV_c_.mjs";
2
2
  export { UPLOAD_CHANNEL, assetInfoSchema, capabilities, deleteAssets, list, mkdir, readFunctions, readImageMeta, readText, rename, serverFunctions, upload, writeFunctions };
@@ -0,0 +1,102 @@
1
+ import { n as AssetInfo, r as AssetType } from "../types-Bspm5Ylo.mjs";
2
+ import { DevframeNodeContext, RpcStreamingChannel } from "devframe";
3
+ //#region src/node/context.d.ts
4
+ interface AssetsConfig {
5
+ /** Directory this devframe manages. */
6
+ dir: string;
7
+ /** Whether upload / rename / delete / mkdir are registered. */
8
+ write: boolean;
9
+ /** Extensions `upload` accepts, or `'*'` to accept any. */
10
+ uploadExtensions: readonly string[] | '*';
11
+ /**
12
+ * URL base the managed directory is served at. Normally the host
13
+ * (Vite / Nuxt / …) serves `public/` at `/`, so asset `publicPath`s are
14
+ * `joinURL(baseURL, path)` and the plugin serves nothing itself.
15
+ */
16
+ baseURL: string;
17
+ /** The upload streaming channel, created once in `setupAssets` when `write` is enabled. */
18
+ uploadChannel?: RpcStreamingChannel<Uint8Array>;
19
+ }
20
+ interface AssetsContext extends AssetsConfig {
21
+ /**
22
+ * Resolve a root-relative path to an absolute one, rejecting lexical
23
+ * escapes. Symlink-aware containment for reads and mutations lives in
24
+ * `node/paths` (`resolveAssetReadPath` / `assertAssetMutationPath`), which
25
+ * the RPC handlers call directly with {@link AssetsContext.dir}.
26
+ */
27
+ resolvePath: (relativePath: string) => string;
28
+ }
29
+ /**
30
+ * Record the managed directory and write policy for a context. Called from
31
+ * the devframe's `setup` before any RPC handler runs.
32
+ */
33
+ declare function configureAssets(ctx: DevframeNodeContext, config: AssetsConfig): void;
34
+ /**
35
+ * Per-`DevframeNodeContext` assets state. Each RPC function pulls its
36
+ * managed directory and path resolver from here instead of re-reading
37
+ * `configureAssets`'s config on every call.
38
+ */
39
+ declare function getAssetsContext(ctx: DevframeNodeContext): AssetsContext;
40
+ //#endregion
41
+ //#region src/node/paths.d.ts
42
+ /**
43
+ * Resolve a client-supplied, root-relative path against the managed
44
+ * directory, rejecting anything that would escape it lexically (`..`
45
+ * traversal, a rogue absolute path). The first guard every RPC handler runs;
46
+ * symlink-aware containment is layered on by {@link resolveAssetReadPath}
47
+ * (reads) and {@link assertAssetMutationPath} (mutations).
48
+ */
49
+ declare function resolveAssetPath(root: string, relativePath: string): string;
50
+ //#endregion
51
+ //#region src/node/scanner.d.ts
52
+ /** Classifies a path by extension, driving preview and icon choice. */
53
+ declare function guessAssetType(path: string): AssetType;
54
+ /** Recursively lists every file under `dir`, sorted alphabetically by path. */
55
+ declare function scanAssets(dir: string, baseURL: string, includeFsPath?: boolean): Promise<AssetInfo[]>;
56
+ //#endregion
57
+ //#region src/node/setup.d.ts
58
+ interface SetupAssetsOptions {
59
+ /** Directory this devframe manages. */
60
+ dir: string;
61
+ /** Whether upload / rename / delete / mkdir are registered. */
62
+ write: boolean;
63
+ /** Extensions `upload` accepts, or `'*'` to accept any. */
64
+ uploadExtensions: readonly string[] | '*';
65
+ /**
66
+ * URL base the managed directory is served at, the base every asset's
67
+ * `publicPath` is resolved against.
68
+ */
69
+ baseURL: string;
70
+ /**
71
+ * Whether this devframe should serve the managed directory's bytes
72
+ * itself. Left `false` when mounted into a host (Vite / Nuxt / …) that
73
+ * already serves `public/` at {@link baseURL}; set `true` only for the
74
+ * standalone CLI, which is its own host.
75
+ */
76
+ serveStatic: boolean;
77
+ /** Start the live file watcher (dev mode only). */
78
+ watch: boolean;
79
+ }
80
+ /**
81
+ * Register the assets RPC surface on a devframe node context: ensures the
82
+ * managed directory exists, registers the read RPCs (always) and write
83
+ * RPCs (when enabled), and starts a live file watcher in dev mode.
84
+ *
85
+ * Raw asset bytes (for `<img>`/`<video>`/download previews) are served by
86
+ * the **host** the plugin is attached to: Vite, Nuxt, or any framework
87
+ * already serves its `public/` dir at {@link SetupAssetsOptions.baseURL}.
88
+ * The plugin only serves them itself when `serveStatic` is set (the
89
+ * standalone CLI, which is its own host).
90
+ *
91
+ * Called from the definition's `setup(ctx)` and reusable by host adapters
92
+ * that wire their own context.
93
+ */
94
+ declare function setupAssets(ctx: DevframeNodeContext, options: SetupAssetsOptions): Promise<void>;
95
+ /**
96
+ * Stop the live file watcher started by {@link setupAssets}. Test harnesses
97
+ * wrap their dev-server `close()` with this (see `test/_utils.ts`), so a
98
+ * leaked chokidar watcher doesn't keep the process alive.
99
+ */
100
+ declare function disposeAssetsWatcher(ctx: DevframeNodeContext): Promise<void>;
101
+ //#endregion
102
+ export { SetupAssetsOptions, configureAssets, disposeAssetsWatcher, getAssetsContext, guessAssetType, resolveAssetPath, scanAssets, setupAssets };
@@ -0,0 +1,3 @@
1
+ import { n as setupAssets, t as disposeAssetsWatcher } from "../setup-BIpnpKP0.mjs";
2
+ import { _ as getAssetsContext, d as scanAssets, g as configureAssets, u as guessAssetType, v as resolveAssetPath } from "../rpc-DG9tV_c_.mjs";
3
+ export { configureAssets, disposeAssetsWatcher, getAssetsContext, guessAssetType, resolveAssetPath, scanAssets, setupAssets };
@@ -1,14 +1,14 @@
1
- import { n as setupAssets } from "./node-Diynhcd3.mjs";
1
+ import { n as setupAssets } from "./setup-BIpnpKP0.mjs";
2
2
  import process from "node:process";
3
3
  import { defineDevframe } from "devframe";
4
4
  import { resolve } from "pathe";
5
5
  //#region package.json
6
6
  var name = "@devframes/plugin-assets";
7
- var version = "0.9.9";
7
+ var version = "0.9.11";
8
8
  var description = "Devframe plugin for browsing, previewing, uploading, and managing static assets in a directory.";
9
9
  var homepage = "https://github.com/devframes/devframe#readme";
10
10
  //#endregion
11
- //#region src/types.ts
11
+ //#region src/node/types.ts
12
12
  /** Mirrors Nuxt DevTools' own default upload allow-list. */
13
13
  const DEFAULT_ALLOWED_UPLOAD_EXTENSIONS = [
14
14
  "png",
@@ -32,7 +32,7 @@ const DEFAULT_ALLOWED_UPLOAD_EXTENSIONS = [
32
32
  "eot"
33
33
  ];
34
34
  //#endregion
35
- //#region src/index.ts
35
+ //#region src/node/index.ts
36
36
  const remoteAssets = {
37
37
  package: `${name}--assets`,
38
38
  version
@@ -1,13 +1,13 @@
1
1
  import { dirname, extname, join, normalize, resolve } from "pathe";
2
2
  import { createWriteStream } from "node:fs";
3
3
  import fsp from "node:fs/promises";
4
+ import { defineDiagnostics } from "devframe/utils/nostics";
4
5
  import { createDefineWrapperWithContext } from "devframe/rpc";
5
6
  import { s } from "devframe/utils/simple-schema";
6
- import { defineDiagnostics } from "devframe/utils/nostics";
7
7
  import { glob } from "tinyglobby";
8
8
  import { joinURL } from "ufo";
9
9
  import { imageMeta } from "image-meta";
10
- //#region src/diagnostics.ts
10
+ //#region src/node/diagnostics.ts
11
11
  /**
12
12
  * Uses the plugin's own `DP_ASSETS_` prefix per the built-in plugin
13
13
  * convention, keeping it collision-free with devframe core (`DF`) and the
@@ -137,7 +137,7 @@ function getAssetsContext(ctx) {
137
137
  return built;
138
138
  }
139
139
  //#endregion
140
- //#region src/rpc/functions/upload.ts
140
+ //#region src/node/rpc/functions/upload.ts
141
141
  const defineAssetsRpc$7 = createDefineWrapperWithContext();
142
142
  /** Streaming channel name, namespaced like every other RPC name in this plugin. */
143
143
  const UPLOAD_CHANNEL = "devframes:plugin:assets:upload";
@@ -311,7 +311,7 @@ async function scanAssets(dir, baseURL, includeFsPath = false) {
311
311
  }))).filter((info) => info !== void 0).sort((a, b) => a.path.localeCompare(b.path));
312
312
  }
313
313
  //#endregion
314
- //#region src/rpc/functions/list.ts
314
+ //#region src/node/rpc/functions/list.ts
315
315
  const defineAssetsRpc$4 = createDefineWrapperWithContext();
316
316
  const assetInfoSchema = s.object({
317
317
  path: s.string(),
@@ -414,7 +414,7 @@ handler: (async (path) => {
414
414
  }
415
415
  });
416
416
  //#endregion
417
- //#region src/rpc/functions/read-text.ts
417
+ //#region src/node/rpc/functions/read-text.ts
418
418
  const defineAssetsRpc$1 = createDefineWrapperWithContext();
419
419
  const DEFAULT_LIMIT = 5e3;
420
420
  const readText = defineAssetsRpc$1({
@@ -489,7 +489,7 @@ handler: (async ({ path, newName }) => {
489
489
  }
490
490
  });
491
491
  //#endregion
492
- //#region src/rpc/index.ts
492
+ //#region src/node/rpc/index.ts
493
493
  /** Read-only RPC, always registered. */
494
494
  const readFunctions = [
495
495
  list,
@@ -1,10 +1,10 @@
1
- import { g as configureAssets, m as UPLOAD_CHANNEL, r as writeFunctions, t as readFunctions } from "./rpc-Pau8tZGm.mjs";
1
+ import { g as configureAssets, m as UPLOAD_CHANNEL, r as writeFunctions, t as readFunctions } from "./rpc-DG9tV_c_.mjs";
2
2
  import process from "node:process";
3
3
  import { existsSync } from "node:fs";
4
4
  import fsp from "node:fs/promises";
5
5
  import { watch } from "chokidar";
6
6
  import { debounce } from "perfect-debounce";
7
- //#region src/constants.ts
7
+ //#region src/node/constants.ts
8
8
  /** Broadcast whenever a file is added, removed, or changed under the managed directory. */
9
9
  const CHANGED_EVENT = "devframes:plugin:assets:changed";
10
10
  /** Preferred standalone CLI port. */
@@ -41,7 +41,7 @@ function watchAssetsDir(ctx, dir) {
41
41
  };
42
42
  }
43
43
  //#endregion
44
- //#region src/node/index.ts
44
+ //#region src/node/setup.ts
45
45
  const watchers = /* @__PURE__ */ new WeakMap();
46
46
  /**
47
47
  * Register the assets RPC surface on a devframe node context: ensures the
@@ -1,4 +1,4 @@
1
- //#region src/types.d.ts
1
+ //#region src/node/types.d.ts
2
2
  /** Broad category guessed from a file's extension, driving preview/icon choice. */
3
3
  type AssetType = 'image' | 'font' | 'video' | 'audio' | 'text' | 'other';
4
4
  /** One file under the managed directory. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devframes/plugin-assets",
3
3
  "type": "module",
4
- "version": "0.9.9",
4
+ "version": "0.9.11",
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",
@@ -21,14 +21,13 @@
21
21
  ],
22
22
  "sideEffects": false,
23
23
  "exports": {
24
- ".": "./dist/index.mjs",
25
- "./client": "./dist/client/index.mjs",
26
- "./cli": "./dist/cli.mjs",
27
- "./node": "./dist/node/index.mjs",
28
- "./rpc": "./dist/rpc/index.mjs",
24
+ ".": "./dist/node/index.mjs",
25
+ "./cli": "./dist/node/cli.mjs",
26
+ "./node": "./dist/node/setup.mjs",
27
+ "./rpc": "./dist/node/rpc/index.mjs",
29
28
  "./package.json": "./package.json"
30
29
  },
31
- "types": "./dist/index.d.mts",
30
+ "types": "./dist/node/index.d.mts",
32
31
  "bin": {
33
32
  "devframe-assets": "./bin.mjs"
34
33
  },
@@ -37,9 +36,9 @@
37
36
  "dist"
38
37
  ],
39
38
  "peerDependencies": {
40
- "@devframes/plugin-assets--assets": "0.9.9",
41
- "@devframes/service-shiki": "0.9.9",
42
- "devframe": "0.9.9",
39
+ "@devframes/plugin-assets--assets": "0.9.11",
40
+ "@devframes/service-shiki": "0.9.11",
41
+ "devframe": "0.9.11",
43
42
  "vite": "^7.0.0 || ^8.0.0"
44
43
  },
45
44
  "peerDependenciesMeta": {
@@ -54,7 +53,7 @@
54
53
  }
55
54
  },
56
55
  "dependencies": {
57
- "@devframes/service-open": "0.9.9",
56
+ "@devframes/service-open": "0.9.11",
58
57
  "cac": "^7.0.0",
59
58
  "chokidar": "^5.0.0",
60
59
  "image-meta": "^0.2.2",
@@ -65,9 +64,9 @@
65
64
  },
66
65
  "devDependencies": {
67
66
  "@antfu/design": "^0.4.0",
68
- "@devframes/plugin-assets--assets": "0.9.9",
69
- "@devframes/service-shiki": "0.9.9",
70
- "@devframes/vite": "0.9.9",
67
+ "@devframes/plugin-assets--assets": "0.9.11",
68
+ "@devframes/service-shiki": "0.9.11",
69
+ "@devframes/vite": "0.9.11",
71
70
  "@iconify-json/ph": "^1.2.2",
72
71
  "@storybook/addon-a11y": "^10.5.10",
73
72
  "@storybook/addon-docs": "^10.5.10",
@@ -75,7 +74,7 @@
75
74
  "@types/node": "^26.4.0",
76
75
  "@vitejs/plugin-vue": "^6.0.8",
77
76
  "colorjs.io": "^0.7.1",
78
- "devframe": "0.9.9",
77
+ "devframe": "0.9.11",
79
78
  "floating-vue": "^5.2.2",
80
79
  "h3": "^2.0.1-rc.29",
81
80
  "reka-ui": "^2.10.4",
@@ -87,9 +86,11 @@
87
86
  "vue": "^3.5.42"
88
87
  },
89
88
  "scripts": {
90
- "build": "tsdown && vite build --config src/spa/vite.config.ts",
91
- "dev": "vite --config src/spa/vite.config.ts --host 0.0.0.0",
89
+ "build": "tsdown && vite build --config app/vite.config.ts",
90
+ "build:app": "vite build --config app/vite.config.ts",
92
91
  "watch": "tsdown --watch",
92
+ "dev": "vite --config app/vite.config.ts --host",
93
+ "play": "pnpm run build && node playgrounds/server.mjs",
93
94
  "storybook": "storybook dev -p 6013 --host 0.0.0.0",
94
95
  "storybook:build": "storybook build",
95
96
  "test": "vitest run",
@@ -1,6 +0,0 @@
1
- import { i as CodeSnippet, n as AssetInfo, r as AssetType, t as AssetImageMeta } from "../types-BKiX3RbA.mjs";
2
- import { DevframeRpcClientOptions } from "devframe/client";
3
- //#region src/client/index.d.ts
4
- declare function connectAssets(options?: DevframeRpcClientOptions): Promise<import("devframe/client").DevframeRpcClient>;
5
- //#endregion
6
- export { type AssetImageMeta, type AssetInfo, type AssetType, type CodeSnippet, connectAssets };
@@ -1,7 +0,0 @@
1
- import { connectDevframe } from "devframe/client";
2
- //#region src/client/index.ts
3
- function connectAssets(options) {
4
- return connectDevframe(options);
5
- }
6
- //#endregion
7
- export { connectAssets };
package/dist/index.d.mts DELETED
@@ -1,79 +0,0 @@
1
- import { a as DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, i as CodeSnippet, n as AssetInfo, r as AssetType, t as AssetImageMeta } from "./types-BKiX3RbA.mjs";
2
- import { DevframeDefinition } from "devframe";
3
- //#region src/index.d.ts
4
- interface AssetsDevframeOptions {
5
- id?: string;
6
- name?: string;
7
- icon?: string;
8
- /**
9
- * Directory this devframe manages. Defaults to `<cwd>/public`, the
10
- * conventional static-asset folder for Nuxt, Vite, and most static-site
11
- * frameworks. Pass an absolute path, or one relative to the devframe's
12
- * own `cwd`.
13
- */
14
- dir?: string;
15
- /**
16
- * URL base the **host** serves the managed directory at, used to build
17
- * each asset's `publicPath`. Defaults to `/`; Vite, Nuxt, and most
18
- * frameworks serve their `public/` folder at the site root. Set this to
19
- * match a non-root deployment base (e.g. Nuxt's `app.baseURL`).
20
- */
21
- baseURL?: string;
22
- /**
23
- * Serve the managed directory's bytes from this devframe itself.
24
- * Defaults to `false`: when mounted into a host (Vite/Nuxt/…) that host
25
- * already serves `public/` at {@link baseURL}, so the plugin references
26
- * those URLs instead of standing up its own route. The standalone CLI
27
- * sets this to `true` (it is its own host), serving the directory under
28
- * a dedicated base so it doesn't collide with the SPA at `/`.
29
- */
30
- serveStatic?: boolean;
31
- basePath?: string;
32
- distDir?: string;
33
- /** Preferred standalone CLI port (default 9015). */
34
- port?: number;
35
- /**
36
- * Enable upload, rename, delete, and folder creation from the UI.
37
- * Enabled by default; set `false` (or pass `--read-only` on the
38
- * standalone CLI) for a browse-only deployment.
39
- */
40
- write?: boolean;
41
- /**
42
- * Extensions `upload` accepts, or `'*'` to accept any file. Defaults to
43
- * the same allow-list Nuxt DevTools ships.
44
- */
45
- uploadExtensions?: readonly string[] | '*';
46
- /**
47
- * Watch the managed directory in dev mode and push live listing updates.
48
- * Enabled by default. Set `false` to skip the file watcher, useful when a
49
- * host mounts the devframe in a short-lived or repeatedly-recreated
50
- * context (tests, some SSR dev servers) where a background watcher isn't
51
- * wanted.
52
- */
53
- watch?: boolean;
54
- /**
55
- * Require the trust handshake on the standalone server. Enabled by
56
- * default, because this devframe can read, write, and delete real files.
57
- */
58
- auth?: boolean;
59
- /**
60
- * Register the `build` CLI subcommand. Disabled by default: a static
61
- * export can only ever list file metadata from a baked snapshot; there
62
- * is no live host serving the files, and every write action is inherently
63
- * excluded from a static dump, so the command would produce a broken,
64
- * write-less shell of the tool. Opt back in if that degraded export is
65
- * still useful to you.
66
- */
67
- build?: boolean;
68
- }
69
- /**
70
- * Create the assets manager devframe, a framework-neutral port of Nuxt
71
- * DevTools' Assets tab. Mount it into any host via devframe's adapters, or
72
- * run it standalone with the bundled CLI (`devframe-assets`).
73
- *
74
- * @experimental This plugin is experimental and may change without a major
75
- * version bump until it stabilizes.
76
- */
77
- declare function createAssetsDevframe(options?: AssetsDevframeOptions): DevframeDefinition;
78
- //#endregion
79
- export { type AssetImageMeta, type AssetInfo, type AssetType, AssetsDevframeOptions, type CodeSnippet, DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, createAssetsDevframe, createAssetsDevframe as default };
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- import { n as DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, t as createAssetsDevframe } from "./src-BpDib51Z.mjs";
2
- export { DEFAULT_ALLOWED_UPLOAD_EXTENSIONS, createAssetsDevframe, createAssetsDevframe as default };