@loomcycle/explorer 0.2.0 → 0.3.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,12 @@ 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): Promise<ChunkDetail>;
40
+ documentSetAsset(chunkId: string, mediaType: string, dataBase64: string, filename: string | undefined, scope: DocScope, browse?: BrowseScope): Promise<ChunkDetail>;
38
41
  documentGetEdges(documentId: string, scope: DocScope, browse?: BrowseScope): Promise<{
39
42
  edges: DocEdge[];
40
43
  }>;
44
+ documentAssetObjectUrl?(chunkId: string, scope: DocScope, browse?: BrowseScope): Promise<string>;
41
45
  documentUpdateChunk(id: string, revision: number, patch: ChunkPatch, scope: DocScope, browse?: BrowseScope): Promise<ChunkDetail>;
42
46
  documentExportMd(documentId: string, scope: DocScope, includeMetadata: boolean, browse?: BrowseScope): Promise<{
43
47
  markdown: string;
@@ -45,7 +49,7 @@ export interface ExplorerDataLayer {
45
49
  document_id: string;
46
50
  }>;
47
51
  }
48
- export declare function dataLayerFromClient(client: LoomcycleClient): ExplorerDataLayer;
52
+ export declare function dataLayerFromClient(client: LoomcycleClient, assetFetch?: AssetFetch): ExplorerDataLayer;
49
53
  export declare function ExplorerDataProvider({ value, children, }: {
50
54
  value: ExplorerDataLayer;
51
55
  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
@@ -1022,3 +1022,40 @@
1022
1022
  margin-top: 6px;
1023
1023
  font-size: var(--lc-text-xs);
1024
1024
  }
1025
+
1026
+ /* ============================================================
1027
+ RFC BO — image & diagram chunks
1028
+ ============================================================ */
1029
+ .loomcycle-explorer .chunk-type-icon {
1030
+ font-size: 0.9em;
1031
+ line-height: 1;
1032
+ margin-right: 2px;
1033
+ }
1034
+ .loomcycle-explorer .doc-image {
1035
+ margin: 0;
1036
+ text-align: center;
1037
+ }
1038
+ .loomcycle-explorer .doc-image img {
1039
+ max-width: 100%;
1040
+ height: auto;
1041
+ border: 1px solid var(--border);
1042
+ border-radius: 4px;
1043
+ background: var(--bg-soft);
1044
+ }
1045
+ .loomcycle-explorer .doc-image figcaption {
1046
+ margin-top: 6px;
1047
+ color: var(--fg-soft);
1048
+ font-size: var(--lc-text-sm);
1049
+ font-style: italic;
1050
+ }
1051
+ .loomcycle-explorer .doc-mermaid-source {
1052
+ margin-top: 10px;
1053
+ }
1054
+ .loomcycle-explorer .chunk-mermaid-preview {
1055
+ border: 1px solid var(--border);
1056
+ border-radius: 4px;
1057
+ padding: 10px;
1058
+ background: var(--bg-soft);
1059
+ margin-bottom: 16px;
1060
+ overflow-x: auto;
1061
+ }
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.3.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",