@loomcycle/explorer 0.2.0 → 0.4.0

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.
@@ -13,3 +13,13 @@ export interface Connection {
13
13
  * browser's native fetch rejects a non-global receiver with "Illegal
14
14
  * invocation" — so we hand it a plain function that calls global fetch. */
15
15
  export declare function createLoomcycleClient(c: Connection): LoomcycleClient;
16
+ /** AssetFetch does a raw authenticated GET against a relative loomcycle path and
17
+ * returns the Response — for BINARY endpoints (RFC BO image assets) the JSON
18
+ * client can't model. It mirrors the Connection's transport: the custom `fetch`
19
+ * (e.g. the Web UI's same-origin cookie fetch) carries cookie auth, and a bearer
20
+ * token is added as an Authorization header when set. */
21
+ export type AssetFetch = (path: string) => Promise<Response>;
22
+ /** Build the AssetFetch from a Connection — the SAME auth transport the JSON
23
+ * client uses, so an image asset loads under both cookie (web) and bearer
24
+ * (standalone package) auth. */
25
+ export declare function assetFetchFromConnection(c: Connection): AssetFetch;
@@ -2,6 +2,7 @@ import { type ReactNode } from "react";
2
2
  import type { LoomcycleClient } from "@loomcycle/client";
3
3
  import type { BrowseScope, ChunkDetail, ChunkRow, DocEdge, DocScope, PathEntry, PathScope } from "../types";
4
4
  import type { DocSummary, DocumentMeta } from "./colorScheme";
5
+ import type { AssetFetch } from "./createClient";
5
6
  export interface ChunkPatch {
6
7
  body?: string;
7
8
  fields?: unknown;
@@ -35,9 +36,14 @@ export interface ExplorerDataLayer {
35
36
  chunks: ChunkRow[];
36
37
  }>;
37
38
  documentGetChunk(id: string, scope: DocScope, browse?: BrowseScope): Promise<ChunkDetail>;
39
+ documentCreateChunk(documentId: string, parentId: string, patch: ChunkPatch, scope: DocScope, browse?: BrowseScope, afterId?: string): Promise<ChunkDetail>;
40
+ documentReorderChunk(id: string, direction: "up" | "down", scope: DocScope, browse?: BrowseScope): Promise<unknown>;
41
+ documentDeleteChunk(id: string, scope: DocScope, browse?: BrowseScope): Promise<unknown>;
42
+ documentSetAsset(chunkId: string, mediaType: string, dataBase64: string, filename: string | undefined, scope: DocScope, browse?: BrowseScope): Promise<ChunkDetail>;
38
43
  documentGetEdges(documentId: string, scope: DocScope, browse?: BrowseScope): Promise<{
39
44
  edges: DocEdge[];
40
45
  }>;
46
+ documentAssetObjectUrl?(chunkId: string, scope: DocScope, browse?: BrowseScope): Promise<string>;
41
47
  documentUpdateChunk(id: string, revision: number, patch: ChunkPatch, scope: DocScope, browse?: BrowseScope): Promise<ChunkDetail>;
42
48
  documentExportMd(documentId: string, scope: DocScope, includeMetadata: boolean, browse?: BrowseScope): Promise<{
43
49
  markdown: string;
@@ -45,7 +51,7 @@ export interface ExplorerDataLayer {
45
51
  document_id: string;
46
52
  }>;
47
53
  }
48
- export declare function dataLayerFromClient(client: LoomcycleClient): ExplorerDataLayer;
54
+ export declare function dataLayerFromClient(client: LoomcycleClient, assetFetch?: AssetFetch): ExplorerDataLayer;
49
55
  export declare function ExplorerDataProvider({ value, children, }: {
50
56
  value: ExplorerDataLayer;
51
57
  children: ReactNode;
@@ -0,0 +1,7 @@
1
+ export declare const IMAGE_MEDIA_TYPES: string[];
2
+ export declare function isSupportedImage(type: string): boolean;
3
+ export declare function readImageAsBase64(file: File | Blob): Promise<{
4
+ mediaType: string;
5
+ data: string;
6
+ }>;
7
+ export declare function imageFileFromPaste(items: DataTransferItemList | null | undefined): File | null;
package/dist/styles.css CHANGED
@@ -655,6 +655,15 @@
655
655
  border-radius: 4px;
656
656
  cursor: pointer;
657
657
  }
658
+ /* RFC BP — up/down reorder + delete controls. */
659
+ .loomcycle-explorer .doc-content-controls > button:disabled {
660
+ opacity: 0.4;
661
+ cursor: default;
662
+ }
663
+ .loomcycle-explorer .doc-content-controls > button.danger {
664
+ color: var(--danger);
665
+ border-color: var(--danger);
666
+ }
658
667
  /* The selected-chunk view (chunk body OR assembled markdown) scrolls
659
668
  independently of the fixed head — both modes can be long. */
660
669
  .loomcycle-explorer .doc-content-body {
@@ -1022,3 +1031,40 @@
1022
1031
  margin-top: 6px;
1023
1032
  font-size: var(--lc-text-xs);
1024
1033
  }
1034
+
1035
+ /* ============================================================
1036
+ RFC BO — image & diagram chunks
1037
+ ============================================================ */
1038
+ .loomcycle-explorer .chunk-type-icon {
1039
+ font-size: 0.9em;
1040
+ line-height: 1;
1041
+ margin-right: 2px;
1042
+ }
1043
+ .loomcycle-explorer .doc-image {
1044
+ margin: 0;
1045
+ text-align: center;
1046
+ }
1047
+ .loomcycle-explorer .doc-image img {
1048
+ max-width: 100%;
1049
+ height: auto;
1050
+ border: 1px solid var(--border);
1051
+ border-radius: 4px;
1052
+ background: var(--bg-soft);
1053
+ }
1054
+ .loomcycle-explorer .doc-image figcaption {
1055
+ margin-top: 6px;
1056
+ color: var(--fg-soft);
1057
+ font-size: var(--lc-text-sm);
1058
+ font-style: italic;
1059
+ }
1060
+ .loomcycle-explorer .doc-mermaid-source {
1061
+ margin-top: 10px;
1062
+ }
1063
+ .loomcycle-explorer .chunk-mermaid-preview {
1064
+ border: 1px solid var(--border);
1065
+ border-radius: 4px;
1066
+ padding: 10px;
1067
+ background: var(--bg-soft);
1068
+ margin-bottom: 16px;
1069
+ overflow-x: auto;
1070
+ }
package/dist/types.d.ts CHANGED
@@ -23,6 +23,10 @@ export interface ChunkRow {
23
23
  export interface ChunkDetail extends ChunkRow {
24
24
  body: string;
25
25
  fields?: unknown;
26
+ asset?: {
27
+ media_type: string;
28
+ size: number;
29
+ };
26
30
  }
27
31
  export interface DocEdge {
28
32
  from_id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcycle/explorer",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "Embeddable React Path VFS + chunked-graph Document browser for the loomcycle agentic runtime (RFC AL / AK) — a themeable, standalone package: a dirent tree with folder/document CRUD and a chunk-tree Document viewer/editor.",
6
6
  "license": "Apache-2.0",