@loomcycle/explorer 0.1.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.
@@ -0,0 +1,26 @@
1
+ import type { CSSProperties } from "react";
2
+ export type ColorScheme = Record<string, string>;
3
+ export interface DocSummary {
4
+ document_id: string;
5
+ title: string;
6
+ root_chunk_id?: string;
7
+ type?: string;
8
+ status?: string;
9
+ color_enabled: boolean;
10
+ color_scheme?: ColorScheme;
11
+ }
12
+ export interface DocumentMeta {
13
+ document_id: string;
14
+ title: string;
15
+ root_chunk_id?: string;
16
+ type?: string;
17
+ status?: string;
18
+ color_enabled: boolean;
19
+ color_scheme?: ColorScheme;
20
+ }
21
+ export declare const DEFAULT_SCHEME: ColorScheme;
22
+ export declare function effectiveScheme(scheme: ColorScheme | undefined): ColorScheme;
23
+ export declare function docColor(type: string | undefined, status: string | undefined, scheme: ColorScheme): string | undefined;
24
+ export declare function chunkColor(status: string | undefined, scheme: ColorScheme): string | undefined;
25
+ export declare function hexToTint(hex: string): string | undefined;
26
+ export declare function tintStyle(color: string | undefined): CSSProperties | undefined;
@@ -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;
@@ -1,6 +1,8 @@
1
1
  import { type ReactNode } from "react";
2
2
  import type { LoomcycleClient } from "@loomcycle/client";
3
- import type { BrowseScope, ChunkDetail, ChunkRow, DocScope, PathEntry, PathScope } from "../types";
3
+ import type { BrowseScope, ChunkDetail, ChunkRow, DocEdge, DocScope, PathEntry, PathScope } from "../types";
4
+ import type { DocSummary, DocumentMeta } from "./colorScheme";
5
+ import type { AssetFetch } from "./createClient";
4
6
  export interface ChunkPatch {
5
7
  body?: string;
6
8
  fields?: unknown;
@@ -23,10 +25,23 @@ export interface ExplorerDataLayer {
23
25
  path?: string;
24
26
  }>;
25
27
  documentDelete(id: string, scope: DocScope, browse?: BrowseScope): Promise<unknown>;
28
+ documentGet(id: string, scope: DocScope, browse?: BrowseScope): Promise<DocumentMeta>;
29
+ documentsSummary(opts: {
30
+ documentIds?: string[];
31
+ underPath?: string;
32
+ }, scope: DocScope, browse?: BrowseScope): Promise<{
33
+ documents: DocSummary[];
34
+ }>;
26
35
  documentQueryChunks(documentId: string, scope: DocScope, browse?: BrowseScope): Promise<{
27
36
  chunks: ChunkRow[];
28
37
  }>;
29
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>;
41
+ documentGetEdges(documentId: string, scope: DocScope, browse?: BrowseScope): Promise<{
42
+ edges: DocEdge[];
43
+ }>;
44
+ documentAssetObjectUrl?(chunkId: string, scope: DocScope, browse?: BrowseScope): Promise<string>;
30
45
  documentUpdateChunk(id: string, revision: number, patch: ChunkPatch, scope: DocScope, browse?: BrowseScope): Promise<ChunkDetail>;
31
46
  documentExportMd(documentId: string, scope: DocScope, includeMetadata: boolean, browse?: BrowseScope): Promise<{
32
47
  markdown: string;
@@ -34,7 +49,7 @@ export interface ExplorerDataLayer {
34
49
  document_id: string;
35
50
  }>;
36
51
  }
37
- export declare function dataLayerFromClient(client: LoomcycleClient): ExplorerDataLayer;
52
+ export declare function dataLayerFromClient(client: LoomcycleClient, assetFetch?: AssetFetch): ExplorerDataLayer;
38
53
  export declare function ExplorerDataProvider({ value, children, }: {
39
54
  value: ExplorerDataLayer;
40
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
@@ -240,6 +240,31 @@
240
240
  font-size: var(--lc-text-sm);
241
241
  margin-bottom: 16px;
242
242
  }
243
+ /* RFC BN P1: a sticky top action bar (title + Save/Cancel) so a long chunk body
244
+ never needs scrolling to reach save. The modal itself is the scroll container
245
+ (max-height:80vh; overflow:auto), so a .sticky-top header pins to its top. */
246
+ .loomcycle-explorer .modal-header {
247
+ display: flex;
248
+ align-items: center;
249
+ justify-content: space-between;
250
+ gap: 12px;
251
+ margin-bottom: 12px;
252
+ }
253
+ .loomcycle-explorer .modal-header.sticky-top {
254
+ position: sticky;
255
+ top: 0;
256
+ background: var(--bg);
257
+ padding-bottom: 10px;
258
+ border-bottom: 1px solid var(--border);
259
+ z-index: 1;
260
+ }
261
+ .loomcycle-explorer .modal-header h3 {
262
+ margin: 0;
263
+ }
264
+ .loomcycle-explorer .modal-buttons-top {
265
+ margin: 0;
266
+ flex-shrink: 0;
267
+ }
243
268
  .loomcycle-explorer .modal-textarea {
244
269
  width: 100%;
245
270
  font-family: inherit;
@@ -750,6 +775,50 @@
750
775
  .loomcycle-explorer .md a {
751
776
  color: var(--accent);
752
777
  }
778
+ /* RFC BN — GFM tables + Mermaid diagrams in the chunk Markdown view. */
779
+ .loomcycle-explorer .md table {
780
+ border-collapse: collapse;
781
+ margin: 0.75em 0;
782
+ max-width: 100%;
783
+ display: block;
784
+ overflow-x: auto;
785
+ font-size: 0.92em;
786
+ }
787
+ .loomcycle-explorer .md th,
788
+ .loomcycle-explorer .md td {
789
+ border: 1px solid var(--border);
790
+ padding: 5px 10px;
791
+ text-align: left;
792
+ vertical-align: top;
793
+ }
794
+ .loomcycle-explorer .md th {
795
+ background: var(--bg-soft);
796
+ font-weight: 600;
797
+ }
798
+ .loomcycle-explorer .md tbody tr:nth-child(even) {
799
+ background: rgba(127, 127, 127, 0.06);
800
+ }
801
+ .loomcycle-explorer .md-mermaid {
802
+ margin: 0.75em 0;
803
+ padding: 10px 12px;
804
+ background: var(--bg-soft);
805
+ border: 1px solid var(--border);
806
+ border-radius: 4px;
807
+ overflow-x: auto;
808
+ text-align: center;
809
+ }
810
+ .loomcycle-explorer .md-mermaid svg {
811
+ max-width: 100%;
812
+ height: auto;
813
+ }
814
+ .loomcycle-explorer .md-mermaid-loading {
815
+ color: var(--fg-soft);
816
+ font-size: 0.9em;
817
+ text-align: left;
818
+ }
819
+ .loomcycle-explorer .md-mermaid-error {
820
+ border-left: 3px solid var(--danger);
821
+ }
753
822
 
754
823
  /* ============================================================
755
824
  Document Assistant slot (host-provided content; the package only
@@ -765,3 +834,228 @@
765
834
  border-top: 1px solid var(--border);
766
835
  background: var(--bg-soft);
767
836
  }
837
+
838
+ /* ============================================================
839
+ RFC BN — per-document color-scheme editor
840
+ ============================================================ */
841
+ .loomcycle-explorer .scheme-editor {
842
+ max-width: 520px;
843
+ }
844
+ .loomcycle-explorer .scheme-editor-head {
845
+ display: flex;
846
+ align-items: center;
847
+ justify-content: space-between;
848
+ gap: 12px;
849
+ position: sticky;
850
+ top: 0;
851
+ background: var(--bg);
852
+ padding-bottom: 10px;
853
+ border-bottom: 1px solid var(--border);
854
+ margin-bottom: 12px;
855
+ }
856
+ .loomcycle-explorer .scheme-editor-head h3 {
857
+ margin: 0;
858
+ }
859
+ .loomcycle-explorer .scheme-editor-actions {
860
+ display: flex;
861
+ gap: 8px;
862
+ }
863
+ .loomcycle-explorer .scheme-editor-actions button {
864
+ padding: 8px 16px;
865
+ border: 1px solid var(--border);
866
+ background: var(--bg-soft);
867
+ color: var(--fg);
868
+ border-radius: 4px;
869
+ cursor: pointer;
870
+ }
871
+ .loomcycle-explorer .scheme-editor-actions button.primary {
872
+ background: var(--running);
873
+ color: white;
874
+ border-color: var(--running);
875
+ }
876
+ .loomcycle-explorer .scheme-toggle {
877
+ display: flex;
878
+ align-items: center;
879
+ gap: 8px;
880
+ margin-bottom: 8px;
881
+ font-size: var(--lc-text-sm);
882
+ }
883
+ .loomcycle-explorer .scheme-group {
884
+ margin-top: 14px;
885
+ }
886
+ .loomcycle-explorer .scheme-group h4 {
887
+ margin: 0 0 6px 0;
888
+ font-size: var(--lc-text-sm);
889
+ color: var(--fg-soft);
890
+ text-transform: uppercase;
891
+ letter-spacing: 0.04em;
892
+ }
893
+ .loomcycle-explorer .scheme-row {
894
+ display: flex;
895
+ align-items: center;
896
+ gap: 10px;
897
+ padding: 3px 0;
898
+ }
899
+ .loomcycle-explorer .scheme-row input[type="color"] {
900
+ width: 28px;
901
+ height: 22px;
902
+ padding: 0;
903
+ border: 1px solid var(--border);
904
+ border-radius: 4px;
905
+ background: none;
906
+ cursor: pointer;
907
+ }
908
+ .loomcycle-explorer .scheme-key {
909
+ flex: 1;
910
+ font-size: var(--lc-text-sm);
911
+ }
912
+ .loomcycle-explorer .scheme-hex {
913
+ color: var(--fg-soft);
914
+ font-size: var(--lc-text-xs);
915
+ }
916
+ .loomcycle-explorer .scheme-editor-foot {
917
+ display: flex;
918
+ align-items: center;
919
+ gap: 10px;
920
+ margin-top: 16px;
921
+ padding-top: 12px;
922
+ border-top: 1px solid var(--border);
923
+ }
924
+ .loomcycle-explorer .scheme-editor-foot button {
925
+ padding: 6px 12px;
926
+ border: 1px solid var(--border);
927
+ background: var(--bg-soft);
928
+ color: var(--fg);
929
+ border-radius: 4px;
930
+ cursor: pointer;
931
+ }
932
+ .loomcycle-explorer .scheme-status {
933
+ color: var(--fg-soft);
934
+ font-size: var(--lc-text-xs);
935
+ }
936
+
937
+ /* ============================================================
938
+ RFC BN P4 — cross-reference links + relationship graph
939
+ ============================================================ */
940
+ .loomcycle-explorer .chunk-link-badge {
941
+ font-size: 0.85em;
942
+ line-height: 1;
943
+ opacity: 0.85;
944
+ }
945
+ .loomcycle-explorer .doc-refs {
946
+ margin-top: 14px;
947
+ padding-top: 12px;
948
+ border-top: 1px solid var(--border);
949
+ }
950
+ .loomcycle-explorer .doc-refs h4 {
951
+ margin: 0 0 6px 0;
952
+ font-size: var(--lc-text-sm);
953
+ color: var(--fg-soft);
954
+ text-transform: uppercase;
955
+ letter-spacing: 0.04em;
956
+ }
957
+ .loomcycle-explorer .doc-refs-empty {
958
+ color: var(--fg-soft);
959
+ font-size: var(--lc-text-sm);
960
+ margin: 0;
961
+ }
962
+ .loomcycle-explorer .doc-refs-list {
963
+ list-style: none;
964
+ margin: 0;
965
+ padding: 0;
966
+ display: flex;
967
+ flex-direction: column;
968
+ gap: 4px;
969
+ }
970
+ .loomcycle-explorer .doc-ref {
971
+ display: flex;
972
+ align-items: center;
973
+ gap: 8px;
974
+ font-size: var(--lc-text-sm);
975
+ }
976
+ .loomcycle-explorer .doc-ref-kind {
977
+ font-family: var(--mono);
978
+ font-size: var(--lc-text-xs);
979
+ color: var(--fg-soft);
980
+ background: var(--bg-soft);
981
+ border: 1px solid var(--border);
982
+ border-radius: 3px;
983
+ padding: 1px 5px;
984
+ }
985
+ .loomcycle-explorer .doc-ref-arrow {
986
+ color: var(--fg-muted);
987
+ }
988
+ .loomcycle-explorer .doc-ref-target {
989
+ background: none;
990
+ border: none;
991
+ color: var(--accent);
992
+ cursor: pointer;
993
+ padding: 0;
994
+ font: inherit;
995
+ text-align: left;
996
+ }
997
+ .loomcycle-explorer .doc-ref-target:hover {
998
+ text-decoration: underline;
999
+ }
1000
+ .loomcycle-explorer .doc-ref-target.external {
1001
+ color: var(--fg-soft);
1002
+ cursor: default;
1003
+ }
1004
+ .loomcycle-explorer .doc-graph {
1005
+ margin-top: 12px;
1006
+ }
1007
+ .loomcycle-explorer .doc-graph-toggle,
1008
+ .loomcycle-explorer .doc-graph-more {
1009
+ background: none;
1010
+ border: none;
1011
+ color: var(--fg-soft);
1012
+ cursor: pointer;
1013
+ padding: 2px 0;
1014
+ font: inherit;
1015
+ font-size: var(--lc-text-sm);
1016
+ }
1017
+ .loomcycle-explorer .doc-graph-toggle:hover,
1018
+ .loomcycle-explorer .doc-graph-more:hover {
1019
+ color: var(--accent);
1020
+ }
1021
+ .loomcycle-explorer .doc-graph-more {
1022
+ margin-top: 6px;
1023
+ font-size: var(--lc-text-xs);
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,23 @@ 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
+ };
30
+ }
31
+ export interface DocEdge {
32
+ from_id: string;
33
+ to_id: string;
34
+ kind: string;
35
+ from_title?: string;
36
+ from_type?: string;
37
+ from_status?: string;
38
+ from_document_id?: string;
39
+ to_title?: string;
40
+ to_type?: string;
41
+ to_status?: string;
42
+ to_document_id?: string;
26
43
  }
27
44
  export interface Principal {
28
45
  subject: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcycle/explorer",
3
- "version": "0.1.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",
@@ -49,17 +49,28 @@
49
49
  "test": "vitest run --passWithNoTests",
50
50
  "test:watch": "vitest"
51
51
  },
52
+ "dependencies": {
53
+ "react-markdown": "^9.1.0",
54
+ "remark-gfm": "^4.0.1"
55
+ },
52
56
  "peerDependencies": {
53
57
  "@loomcycle/client": "^1.12.1",
58
+ "mermaid": "^11.0.0",
54
59
  "react": "^18.0.0 || ^19.0.0",
55
60
  "react-dom": "^18.0.0 || ^19.0.0"
56
61
  },
62
+ "peerDependenciesMeta": {
63
+ "mermaid": {
64
+ "optional": true
65
+ }
66
+ },
57
67
  "devDependencies": {
58
68
  "@loomcycle/client": "^1.12.1",
59
69
  "@types/node": "^22.0.0",
60
70
  "@types/react": "^19.0.0",
61
71
  "@types/react-dom": "^19.0.0",
62
72
  "@vitejs/plugin-react": "^5.0.0",
73
+ "mermaid": "^11.0.0",
63
74
  "react": "^19.0.0",
64
75
  "react-dom": "^19.0.0",
65
76
  "typescript": "^5.6.0",