@loomcycle/explorer 0.16.0 → 0.18.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.
- package/dist/DocumentViewer.d.ts +8 -1
- package/dist/PathExplorer.d.ts +3 -1
- package/dist/components/AnnotationPanel.d.ts +12 -0
- package/dist/components/DocumentViewerBody.d.ts +5 -2
- package/dist/components/DownloadMenu.d.ts +27 -0
- package/dist/components/PathTree.d.ts +3 -0
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2071 -1569
- package/dist/index.js.map +1 -1
- package/dist/lib/annotation.d.ts +14 -0
- package/dist/lib/colorScheme.d.ts +1 -0
- package/dist/lib/dataLayer.d.ts +13 -1
- package/dist/lib/download.d.ts +30 -0
- package/dist/styles.css +194 -0
- package/dist/types.d.ts +34 -0
- package/package.json +2 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Annotation, AnnotationEdit, AnnotationLevel, BrowseScope, DocScope } from "../types";
|
|
2
|
+
import type { ExplorerDataLayer } from "./dataLayer";
|
|
3
|
+
export declare function annotationsApply(scope: DocScope): boolean;
|
|
4
|
+
export declare const BRIEF_MAX_CHARS = 240;
|
|
5
|
+
export declare const ABSTRACT_MAX_CHARS = 2000;
|
|
6
|
+
export declare function usableAnnotations(records: unknown, chunkId: string): Annotation[];
|
|
7
|
+
export declare function loadAnnotations(data: Pick<ExplorerDataLayer, "documentGetAnnotation">, chunkId: string, scope: DocScope, browse?: BrowseScope): Promise<Annotation[]>;
|
|
8
|
+
export declare function annotationLevelFor(isRoot: boolean): AnnotationLevel;
|
|
9
|
+
export declare function codePoints(s: string): number;
|
|
10
|
+
export declare function annotationDraftProblem(brief: string, abstract: string): string | undefined;
|
|
11
|
+
export declare function setAnnotationInput(edit: AnnotationEdit, scope: DocScope): Record<string, unknown>;
|
|
12
|
+
export declare function writtenByLabel(writtenBy: string | undefined): string | undefined;
|
|
13
|
+
export declare function writtenAtLabel(writtenAt: string | undefined): string | undefined;
|
|
14
|
+
export declare const ANNOTATION_ENTRY = "_annotation";
|
package/dist/lib/dataLayer.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { LoomcycleClient } from "@loomcycle/client";
|
|
3
|
-
import type { AcceptClassificationAnswer, Backlink, BrowseScope, CanvasDoc, ChunkDetail, ChunkRevision, ChunkRow, ClassifyAnswer, ClassifyWrite, DocEdge, DocScope, PathEntry, StatementStatus, PathScope, RelatedChunk, UnlinkedMention } from "../types";
|
|
3
|
+
import type { AcceptClassificationAnswer, Annotation, AnnotationEdit, Backlink, BrowseScope, CanvasDoc, ChunkDetail, ChunkRevision, ChunkRow, ClassifyAnswer, ClassifyWrite, DocEdge, DocScope, PathEntry, StatementStatus, PathScope, RelatedChunk, UnlinkedMention } from "../types";
|
|
4
4
|
import type { DocSummary, DocumentMeta } from "./colorScheme";
|
|
5
5
|
import type { AssetFetch, JsonPost } from "./createClient";
|
|
6
6
|
import type { RulingCounts, RulingRequest } from "./ruling";
|
|
7
7
|
import { type TransferRequest, type TransferResult } from "./transfer";
|
|
8
|
+
import { type DocumentExportOptions, type RenderFormat } from "./download";
|
|
8
9
|
export interface ChunkPatch {
|
|
9
10
|
body?: string;
|
|
10
11
|
fields?: unknown;
|
|
@@ -103,7 +104,17 @@ export interface ExplorerDataLayer {
|
|
|
103
104
|
documentClassify?(documentId: string, write: ClassifyWrite, scope: DocScope, browse?: BrowseScope): Promise<ClassifyAnswer>;
|
|
104
105
|
documentAcceptClassification?(documentId: string, scope: DocScope, browse?: BrowseScope): Promise<AcceptClassificationAnswer>;
|
|
105
106
|
documentEntityTypes?(scope: DocScope, browse?: BrowseScope): Promise<string[]>;
|
|
107
|
+
documentGetAnnotation?(chunkId: string, scope: DocScope, browse?: BrowseScope): Promise<{
|
|
108
|
+
annotations: Annotation[];
|
|
109
|
+
}>;
|
|
110
|
+
documentSetAnnotation?(edit: AnnotationEdit, scope: DocScope, browse?: BrowseScope): Promise<{
|
|
111
|
+
annotation: Annotation;
|
|
112
|
+
}>;
|
|
106
113
|
documentAssetObjectUrl?(chunkId: string, scope: DocScope, browse?: BrowseScope): Promise<string>;
|
|
114
|
+
documentExportFile?(documentId: string, scope: DocScope, format: RenderFormat, browse?: BrowseScope, opts?: DocumentExportOptions): Promise<{
|
|
115
|
+
blob: Blob;
|
|
116
|
+
filename: string;
|
|
117
|
+
}>;
|
|
107
118
|
documentUpdateChunk(id: string, revision: number, patch: ChunkPatch, scope: DocScope, browse?: BrowseScope): Promise<ChunkDetail>;
|
|
108
119
|
documentExportMd(documentId: string, scope: DocScope, includeMetadata: boolean, browse?: BrowseScope): Promise<{
|
|
109
120
|
markdown: string;
|
|
@@ -141,6 +152,7 @@ export interface ExplorerDataLayer {
|
|
|
141
152
|
}>;
|
|
142
153
|
}
|
|
143
154
|
export declare function dataLayerFromClient(client: LoomcycleClient, assetFetch?: AssetFetch, jsonPost?: JsonPost): ExplorerDataLayer;
|
|
155
|
+
export declare function documentExportPath(documentId: string, scope: DocScope, format: RenderFormat, browse?: BrowseScope, opts?: DocumentExportOptions): string;
|
|
144
156
|
export declare function ExplorerDataProvider({ value, children, }: {
|
|
145
157
|
value: ExplorerDataLayer;
|
|
146
158
|
children: ReactNode;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The file formats the runtime renders a document into (RFC GR). */
|
|
2
|
+
export type RenderFormat = "pdf" | "docx" | "html" | "md";
|
|
3
|
+
/** Options of a rendered export — `GET /v1/_document/export/{id}`. Unset
|
|
4
|
+
* options are left to the server's defaults. */
|
|
5
|
+
export interface DocumentExportOptions {
|
|
6
|
+
/** Render only the subtree under this chunk. */
|
|
7
|
+
chunk?: string;
|
|
8
|
+
toc?: boolean;
|
|
9
|
+
titlePage?: boolean;
|
|
10
|
+
pageSize?: "a4" | "letter";
|
|
11
|
+
language?: string;
|
|
12
|
+
/** false leaves the provenance note out (the server puts it in by default). */
|
|
13
|
+
provenance?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** The file name a Content-Disposition header names: the RFC 8187
|
|
16
|
+
* `filename*=UTF-8''…` form first (it carries non-ASCII names), then the plain
|
|
17
|
+
* `filename="…"` / `filename=token` fallback. Undefined when it names none, or
|
|
18
|
+
* only an undecodable `filename*` with no fallback. Any directory part is
|
|
19
|
+
* dropped — the name is used as a download name, never a path. */
|
|
20
|
+
export declare function filenameFromContentDisposition(header: string | null | undefined): string | undefined;
|
|
21
|
+
/** The message of a refused request: the `error` field of the runtime's
|
|
22
|
+
* `{"code","error"}` body, else the status line (e.g. a proxy's HTML page). */
|
|
23
|
+
export declare function errorMessageFromBody(text: string, status: number, statusText?: string): string;
|
|
24
|
+
/** A title made safe as a file-name stem — the rule the .md download has
|
|
25
|
+
* always used. */
|
|
26
|
+
export declare function fileStem(title: string | undefined): string;
|
|
27
|
+
/** Hand a Blob to the browser as a download named `filename`. The object URL
|
|
28
|
+
* is revoked on the next tick, not at once: some browsers start reading the
|
|
29
|
+
* blob only after click() returns. */
|
|
30
|
+
export declare function saveBlob(blob: Blob, filename: string): void;
|
package/dist/styles.css
CHANGED
|
@@ -680,6 +680,45 @@
|
|
|
680
680
|
color: white;
|
|
681
681
|
border-color: var(--accent);
|
|
682
682
|
}
|
|
683
|
+
.loomcycle-explorer .doc-toolbar-actions .doc-download-menu > button:disabled {
|
|
684
|
+
cursor: default;
|
|
685
|
+
opacity: 0.7;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/* The toolbar's download menu (DownloadMenu): one button, a small list under it. */
|
|
689
|
+
.loomcycle-explorer .doc-download-menu {
|
|
690
|
+
position: relative;
|
|
691
|
+
}
|
|
692
|
+
.loomcycle-explorer .doc-download-list {
|
|
693
|
+
position: absolute;
|
|
694
|
+
top: calc(100% + 4px);
|
|
695
|
+
right: 0;
|
|
696
|
+
z-index: 30;
|
|
697
|
+
min-width: 170px;
|
|
698
|
+
padding: 4px;
|
|
699
|
+
display: flex;
|
|
700
|
+
flex-direction: column;
|
|
701
|
+
background: var(--bg-soft);
|
|
702
|
+
border: 1px solid var(--border);
|
|
703
|
+
border-radius: 4px;
|
|
704
|
+
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
|
|
705
|
+
}
|
|
706
|
+
.loomcycle-explorer .doc-toolbar-actions .doc-download-list button {
|
|
707
|
+
padding: 5px 10px;
|
|
708
|
+
border: none;
|
|
709
|
+
border-radius: 3px;
|
|
710
|
+
background: transparent;
|
|
711
|
+
color: var(--fg);
|
|
712
|
+
font-size: var(--lc-text-sm);
|
|
713
|
+
text-align: left;
|
|
714
|
+
white-space: nowrap;
|
|
715
|
+
}
|
|
716
|
+
.loomcycle-explorer .doc-toolbar-actions .doc-download-list button:hover,
|
|
717
|
+
.loomcycle-explorer .doc-toolbar-actions .doc-download-list button:focus {
|
|
718
|
+
background: var(--bg);
|
|
719
|
+
color: var(--accent);
|
|
720
|
+
outline: none;
|
|
721
|
+
}
|
|
683
722
|
|
|
684
723
|
/* Id + copy affordance (IdCopy): the document id in the toolbar, the selected
|
|
685
724
|
chunk id in the content head, and a compact copy on every chunk-tree row.
|
|
@@ -1271,6 +1310,7 @@
|
|
|
1271
1310
|
overflow-wrap: anywhere;
|
|
1272
1311
|
}
|
|
1273
1312
|
.loomcycle-explorer .doc-stmt-stale,
|
|
1313
|
+
.loomcycle-explorer .doc-stmt-part,
|
|
1274
1314
|
.loomcycle-explorer .doc-stmt-more {
|
|
1275
1315
|
color: var(--fg-muted);
|
|
1276
1316
|
font-style: italic;
|
|
@@ -1833,3 +1873,157 @@
|
|
|
1833
1873
|
.loomcycle-explorer .doc-bulk .doc-conn-row input[type="checkbox"] {
|
|
1834
1874
|
margin: 0 4px 0 0;
|
|
1835
1875
|
}
|
|
1876
|
+
|
|
1877
|
+
/* Annotations: a document's brief under its title and its abstract in a
|
|
1878
|
+
collapsible panel (the same for a selected chunk), and a brief under a Path
|
|
1879
|
+
tree row. Stale and manual are small muted markers, never hidden. Restyle
|
|
1880
|
+
with --annotation-accent / --annotation-stale / --annotation-manual. */
|
|
1881
|
+
.loomcycle-explorer .doc-annotation {
|
|
1882
|
+
display: flex;
|
|
1883
|
+
flex-direction: column;
|
|
1884
|
+
gap: 4px;
|
|
1885
|
+
padding: 6px 12px;
|
|
1886
|
+
border-bottom: 1px solid var(--border);
|
|
1887
|
+
}
|
|
1888
|
+
.loomcycle-explorer .annotation-brief {
|
|
1889
|
+
margin: 0 0 6px;
|
|
1890
|
+
color: var(--fg-soft);
|
|
1891
|
+
font-size: var(--lc-text-sm);
|
|
1892
|
+
line-height: 1.4;
|
|
1893
|
+
}
|
|
1894
|
+
.loomcycle-explorer .doc-annotation .annotation-brief {
|
|
1895
|
+
margin: 0;
|
|
1896
|
+
}
|
|
1897
|
+
.loomcycle-explorer .annotation-badge {
|
|
1898
|
+
display: inline-block;
|
|
1899
|
+
margin-left: 6px;
|
|
1900
|
+
padding: 0 5px;
|
|
1901
|
+
border: 1px solid var(--border);
|
|
1902
|
+
border-radius: 3px;
|
|
1903
|
+
font-size: var(--lc-text-xs);
|
|
1904
|
+
color: var(--fg-muted);
|
|
1905
|
+
vertical-align: baseline;
|
|
1906
|
+
}
|
|
1907
|
+
.loomcycle-explorer .annotation-badge.annotation-stale {
|
|
1908
|
+
color: var(--annotation-stale, var(--fg-muted));
|
|
1909
|
+
border-style: dashed;
|
|
1910
|
+
}
|
|
1911
|
+
.loomcycle-explorer .annotation-badge.annotation-manual {
|
|
1912
|
+
color: var(--annotation-manual, var(--fg-soft));
|
|
1913
|
+
}
|
|
1914
|
+
.loomcycle-explorer .annotation-panel {
|
|
1915
|
+
margin: 0 0 6px;
|
|
1916
|
+
font-size: var(--lc-text-sm);
|
|
1917
|
+
}
|
|
1918
|
+
.loomcycle-explorer .annotation-panel > summary {
|
|
1919
|
+
cursor: pointer;
|
|
1920
|
+
color: var(--fg-soft);
|
|
1921
|
+
font-size: var(--lc-text-xs);
|
|
1922
|
+
user-select: none;
|
|
1923
|
+
}
|
|
1924
|
+
.loomcycle-explorer .annotation-title {
|
|
1925
|
+
text-transform: uppercase;
|
|
1926
|
+
letter-spacing: 0.04em;
|
|
1927
|
+
color: var(--annotation-accent, var(--fg-soft));
|
|
1928
|
+
}
|
|
1929
|
+
.loomcycle-explorer .annotation-none,
|
|
1930
|
+
.loomcycle-explorer .annotation-empty,
|
|
1931
|
+
.loomcycle-explorer .annotation-hint {
|
|
1932
|
+
color: var(--fg-muted);
|
|
1933
|
+
font-size: var(--lc-text-xs);
|
|
1934
|
+
}
|
|
1935
|
+
.loomcycle-explorer .annotation-none {
|
|
1936
|
+
margin-left: 6px;
|
|
1937
|
+
font-style: italic;
|
|
1938
|
+
}
|
|
1939
|
+
.loomcycle-explorer .annotation-record {
|
|
1940
|
+
margin: 6px 0 0;
|
|
1941
|
+
padding-left: 10px;
|
|
1942
|
+
border-left: 2px solid var(--annotation-accent, var(--border));
|
|
1943
|
+
}
|
|
1944
|
+
.loomcycle-explorer .annotation-abstract {
|
|
1945
|
+
margin: 0 0 6px;
|
|
1946
|
+
white-space: pre-wrap;
|
|
1947
|
+
line-height: 1.5;
|
|
1948
|
+
}
|
|
1949
|
+
.loomcycle-explorer .annotation-meta {
|
|
1950
|
+
display: grid;
|
|
1951
|
+
grid-template-columns: max-content 1fr;
|
|
1952
|
+
gap: 0 10px;
|
|
1953
|
+
margin: 0 0 6px;
|
|
1954
|
+
font-size: var(--lc-text-xs);
|
|
1955
|
+
color: var(--fg-muted);
|
|
1956
|
+
}
|
|
1957
|
+
.loomcycle-explorer .annotation-meta dt {
|
|
1958
|
+
color: var(--fg-soft);
|
|
1959
|
+
}
|
|
1960
|
+
.loomcycle-explorer .annotation-meta dd {
|
|
1961
|
+
margin: 0;
|
|
1962
|
+
overflow-wrap: anywhere;
|
|
1963
|
+
}
|
|
1964
|
+
.loomcycle-explorer .annotation-actions {
|
|
1965
|
+
display: flex;
|
|
1966
|
+
gap: 6px;
|
|
1967
|
+
align-items: center;
|
|
1968
|
+
}
|
|
1969
|
+
.loomcycle-explorer .annotation-actions button {
|
|
1970
|
+
padding: 2px 10px;
|
|
1971
|
+
border: 1px solid var(--border);
|
|
1972
|
+
background: var(--bg);
|
|
1973
|
+
color: var(--fg);
|
|
1974
|
+
border-radius: 4px;
|
|
1975
|
+
cursor: pointer;
|
|
1976
|
+
font-size: var(--lc-text-xs);
|
|
1977
|
+
}
|
|
1978
|
+
.loomcycle-explorer .annotation-actions button:hover:not(:disabled) {
|
|
1979
|
+
border-color: var(--accent);
|
|
1980
|
+
}
|
|
1981
|
+
.loomcycle-explorer .annotation-actions button:disabled {
|
|
1982
|
+
opacity: 0.5;
|
|
1983
|
+
cursor: default;
|
|
1984
|
+
}
|
|
1985
|
+
.loomcycle-explorer .annotation-actions button.primary {
|
|
1986
|
+
background: var(--accent);
|
|
1987
|
+
border-color: var(--accent);
|
|
1988
|
+
color: white;
|
|
1989
|
+
}
|
|
1990
|
+
.loomcycle-explorer .annotation-editor {
|
|
1991
|
+
display: flex;
|
|
1992
|
+
flex-direction: column;
|
|
1993
|
+
gap: 6px;
|
|
1994
|
+
margin: 6px 0 0;
|
|
1995
|
+
}
|
|
1996
|
+
.loomcycle-explorer .annotation-editor label {
|
|
1997
|
+
display: flex;
|
|
1998
|
+
flex-direction: column;
|
|
1999
|
+
gap: 2px;
|
|
2000
|
+
font-size: var(--lc-text-xs);
|
|
2001
|
+
color: var(--fg-soft);
|
|
2002
|
+
}
|
|
2003
|
+
.loomcycle-explorer .annotation-editor textarea {
|
|
2004
|
+
resize: vertical;
|
|
2005
|
+
font-family: inherit;
|
|
2006
|
+
}
|
|
2007
|
+
.loomcycle-explorer .annotation-hint,
|
|
2008
|
+
.loomcycle-explorer .annotation-err {
|
|
2009
|
+
margin: 0;
|
|
2010
|
+
}
|
|
2011
|
+
.loomcycle-explorer .annotation-err {
|
|
2012
|
+
color: var(--failed);
|
|
2013
|
+
font-size: var(--lc-text-xs);
|
|
2014
|
+
}
|
|
2015
|
+
/* A Path row with a brief wraps it onto a second line inside the row box,
|
|
2016
|
+
indented past the caret. */
|
|
2017
|
+
.loomcycle-explorer .path-row:has(.path-brief) {
|
|
2018
|
+
flex-wrap: wrap;
|
|
2019
|
+
row-gap: 2px;
|
|
2020
|
+
}
|
|
2021
|
+
.loomcycle-explorer .path-brief {
|
|
2022
|
+
flex-basis: 100%;
|
|
2023
|
+
padding-left: 22px;
|
|
2024
|
+
color: var(--fg-muted);
|
|
2025
|
+
font-size: var(--lc-text-xs);
|
|
2026
|
+
overflow: hidden;
|
|
2027
|
+
text-overflow: ellipsis;
|
|
2028
|
+
white-space: nowrap;
|
|
2029
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface PathEntry {
|
|
|
9
9
|
kind: string;
|
|
10
10
|
full_path: string;
|
|
11
11
|
resource_ref?: unknown;
|
|
12
|
+
has_children?: boolean;
|
|
12
13
|
}
|
|
13
14
|
export interface ChunkRow {
|
|
14
15
|
id: string;
|
|
@@ -42,6 +43,7 @@ export interface EdgeEvidence {
|
|
|
42
43
|
scope?: string;
|
|
43
44
|
natural_key?: string;
|
|
44
45
|
quote: string;
|
|
46
|
+
part?: "body" | "title";
|
|
45
47
|
char_start?: number;
|
|
46
48
|
char_end?: number;
|
|
47
49
|
stale?: boolean;
|
|
@@ -209,3 +211,35 @@ export interface ClassificationRecord {
|
|
|
209
211
|
proposed_tags?: string[];
|
|
210
212
|
statements?: string[];
|
|
211
213
|
}
|
|
214
|
+
export type AnnotationLevel = "branch" | "document" | "path";
|
|
215
|
+
export interface Annotation {
|
|
216
|
+
chunk_id: string;
|
|
217
|
+
document_id: string;
|
|
218
|
+
level: AnnotationLevel;
|
|
219
|
+
brief: string;
|
|
220
|
+
abstract: string;
|
|
221
|
+
language?: string;
|
|
222
|
+
class?: string;
|
|
223
|
+
ontology_version?: number;
|
|
224
|
+
inputs_sha256?: string;
|
|
225
|
+
prompt_version?: number;
|
|
226
|
+
model?: string;
|
|
227
|
+
manual?: boolean;
|
|
228
|
+
written_at?: string;
|
|
229
|
+
written_by?: string;
|
|
230
|
+
folder?: string;
|
|
231
|
+
stale?: boolean;
|
|
232
|
+
}
|
|
233
|
+
export interface AnnotationEdit {
|
|
234
|
+
id: string;
|
|
235
|
+
level: AnnotationLevel;
|
|
236
|
+
brief: string;
|
|
237
|
+
abstract: string;
|
|
238
|
+
}
|
|
239
|
+
export interface AnnotationTarget {
|
|
240
|
+
documentId: string;
|
|
241
|
+
chunkId: string;
|
|
242
|
+
level: AnnotationLevel;
|
|
243
|
+
scope: DocScope;
|
|
244
|
+
folder?: string;
|
|
245
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomcycle/explorer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"@types/react": "^19.0.0",
|
|
71
71
|
"@types/react-dom": "^19.0.0",
|
|
72
72
|
"@vitejs/plugin-react": "^6.1.2",
|
|
73
|
+
"happy-dom": "^21.0.4",
|
|
73
74
|
"mermaid": "^12.2.0",
|
|
74
75
|
"react": "^19.0.0",
|
|
75
76
|
"react-dom": "^19.0.0",
|