93 lines
3.5 KiB
Plaintext
93 lines
3.5 KiB
Plaintext
workspace Reader id "workspace:reader" revision "workspace:reader@1" commit "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" {
|
|
import interface DocumentData;
|
|
import interface HighlightData;
|
|
import interface CommentData;
|
|
import interface DocumentActions;
|
|
import interface DocumentFactory;
|
|
import package ReaderRuntime;
|
|
// Shared record definitions, repeated explicitly in independently locked resources.
|
|
|
|
type SourceRange = record {
|
|
sourceRevision: string;
|
|
start: int32;
|
|
end: int32;
|
|
};
|
|
|
|
type CommentContent = record {
|
|
text: string;
|
|
tags: list<string>;
|
|
};
|
|
|
|
type DocumentSeed = record { sourceRevision: string; content: string; };
|
|
|
|
atom Document id "atom:reader:document";
|
|
atom Highlight id "atom:reader:highlight";
|
|
atom Comment id "atom:reader:comment";
|
|
|
|
conform Document as DocumentData id "conformance:reader:document-data" {
|
|
private state Revision id "slot:document:revision"
|
|
on Document : string policy register;
|
|
private state Content id "slot:document:content"
|
|
on Document : string policy register;
|
|
private edge DocumentHighlights id "edge:document-highlights" {
|
|
atom Document projection highlights id "projection:highlights" many-unique;
|
|
atom Highlight projection document id "projection:document"
|
|
exactly-one public-traversal;
|
|
}
|
|
initialize {
|
|
sourceRevision to state Revision;
|
|
content to state Content;
|
|
};
|
|
bind sourceRevision.get to state Revision.read;
|
|
bind content.get to state Content.read;
|
|
bind highlights.resolve to edge DocumentHighlights.highlights.resolve;
|
|
bind highlights.connect to edge DocumentHighlights.highlights.connect;
|
|
}
|
|
|
|
conform Document as DocumentActions id "conformance:reader:document-actions" {
|
|
bind annotate.call to package ReaderRuntime.addHighlight with {
|
|
document to interface DocumentData;
|
|
highlight to creation Highlight with { HighlightData from input; };
|
|
comment to creation Comment with { CommentData from input; };
|
|
};
|
|
}
|
|
|
|
conform Document as DocumentFactory id "conformance:reader:document-factory" {
|
|
bind create.call to package ReaderRuntime.createDocument with {
|
|
document to creation Document with { DocumentData from input; };
|
|
};
|
|
}
|
|
|
|
conform Highlight as HighlightData id "conformance:reader:highlight-data" {
|
|
private state Range id "slot:highlight:range"
|
|
on Highlight : SourceRange policy register;
|
|
private state Color id "slot:highlight:color"
|
|
on Highlight : string policy register default "yellow";
|
|
private edge HighlightComments id "edge:highlight-comments" {
|
|
atom Highlight projection comments id "projection:comments" many-unique;
|
|
atom Comment projection highlight id "projection:highlight"
|
|
exactly-one public-traversal;
|
|
}
|
|
initialize {
|
|
range to state Range;
|
|
comments to edge HighlightComments.comments;
|
|
};
|
|
bind range.get to state Range.read;
|
|
bind color.get to state Color.read;
|
|
bind color.set to state Color.write;
|
|
bind comments.resolve to edge HighlightComments.comments.resolve;
|
|
bind excerpt.get to package ReaderRuntime.excerpt with {
|
|
range to state Range;
|
|
document to interface DocumentData via edge DocumentHighlights.document;
|
|
};
|
|
}
|
|
|
|
conform Comment as CommentData id "conformance:reader:comment-data" {
|
|
private state CommentBody id "slot:comment:content"
|
|
on Comment : CommentContent policy crdt(CommentContent);
|
|
initialize { content to state CommentBody; };
|
|
bind content.get to state CommentBody.read;
|
|
bind content.edit to state CommentBody.edit;
|
|
}
|
|
}
|