workspaceSession.svelte#

Classes#

WorkspaceRefusedError#

Defined in: editor/src/workspaceSession.svelte.ts:92

A workspace file the reader refused, with its problems.

Extends#

  • Error

Constructors#

Constructor#

new WorkspaceRefusedError(problems): WorkspaceRefusedError

Defined in: editor/src/workspaceSession.svelte.ts:95

Parameters#
problems#

readonly Problem[]

Returns#

WorkspaceRefusedError

Overrides#

Error.constructor

Properties#

problems#

readonly problems: readonly Problem[]

Defined in: editor/src/workspaceSession.svelte.ts:93


WorkspaceSession#

Defined in: editor/src/workspaceSession.svelte.ts:182

The open workspace of one editor: its store, its file, its unsaved changes, the selection and the MatchClaim tables held for its blocks.

Constructors#

Constructor#

new WorkspaceSession(options): WorkspaceSession

Defined in: editor/src/workspaceSession.svelte.ts:215

Parameters#
options#

SessionOptions

Returns#

WorkspaceSession

Properties#

dirty#

readonly dirty: boolean

Defined in: editor/src/workspaceSession.svelte.ts:196

Whether the workspace holds changes its file does not.

fileName#

fileName: string

Defined in: editor/src/workspaceSession.svelte.ts:190

The file the workspace was opened from or last saved to.

handle#

handle: FileSystemFileHandle | null = null

Defined in: editor/src/workspaceSession.svelte.ts:192

Where Save writes back to, when the browser handed over a file handle.

live#

readonly live: LiveStore

Defined in: editor/src/workspaceSession.svelte.ts:186

The open workspace as Svelte state, for the canvas and the inspector.

path#

path: string | null = null

Defined in: editor/src/workspaceSession.svelte.ts:194

Where Save writes back to through the server: the workspace file’s path from its root.

savedView#

savedView: View | null

Defined in: editor/src/workspaceSession.svelte.ts:188

The view as last opened or saved; null for a workspace never saved (a restored one).

store#

store: Store

Defined in: editor/src/workspaceSession.svelte.ts:184

The open workspace.

tables#

readonly tables: MatchClaimTables

Defined in: editor/src/workspaceSession.svelte.ts:198

The MatchClaim tables of the open workspace’s blocks, held for the session, never written to its file.

Accessors#

exportable#
Get Signature#

get exportable(): string | null

Defined in: editor/src/workspaceSession.svelte.ts:783

The block the whole selection lies in, if it lies in exactly one.

Returns#

string | null

files#
Get Signature#

get files(): FileHost | null

Defined in: editor/src/workspaceSession.svelte.ts:305

The user’s files through the server, where it offers them now; null where it does not.

Returns#

FileHost | null

selection#
Get Signature#

get selection(): Selection

Defined in: editor/src/workspaceSession.svelte.ts:228

The viewer’s selection: addresses of blocks and of their elements; never written to the workspace.

Returns#

Selection

Set Signature#

set selection(next): void

Defined in: editor/src/workspaceSession.svelte.ts:232

Parameters#
next#

Selection

Returns#

void

Methods#

chooseOpened()#

chooseOpened(host): Promise<string | null>

Defined in: editor/src/workspaceSession.svelte.ts:577

Let the user choose a workspace or a manifest file in the file dialog (Open… through the server); its path, null when cancelled.

Parameters#
host#

FileHost

Returns#

Promise<string | null>

dispose()#

dispose(): void

Defined in: editor/src/workspaceSession.svelte.ts:248

Stop following the open store; the session is not used afterwards.

Returns#

void

exportManifest()#

exportManifest(): Promise<void>

Defined in: editor/src/workspaceSession.svelte.ts:797

Export the manifest of the block the selection lies in as the block’s manifest file says (manifestFileOf): in its form, with or without its styling, in its serialization, under the file name of that serialization.

Returns#

Promise<void>

importExample()#

importExample(example, canvas, metrics): Promise<void>

Defined in: editor/src/workspaceSession.svelte.ts:732

Add the manifest of the manifest example example as one new block (#add); the files it names are read from where the example lies, when it says where (Example.source).

Parameters#
example#

Example

canvas#

ImportTarget

metrics#

FontMetrics

Returns#

Promise<void>

importManifest()#

importManifest(canvas, metrics): Promise<void>

Defined in: editor/src/workspaceSession.svelte.ts:538

Import the manifest files the viewer picks, each as one new block: one chosen in the file dialog through the server (importPath), else those picked in the browser, with the MatchClaim tables picked beside them (importPicked).

Parameters#
canvas#

ImportTarget

metrics#

FontMetrics

Returns#

Promise<void>

importPath()#

importPath(host, path, canvas, metrics): Promise<string | null>

Defined in: editor/src/workspaceSession.svelte.ts:561

Import the manifest file at path on the server as one new block (#add), the workspace keeping where it lies (location); the new block, null when the file is no manifest.

Parameters#
host#

FileHost

path#

string

canvas#

ImportTarget

metrics#

FontMetrics

Returns#

Promise<string | null>

importPicked()#

importPicked(picked, canvas, metrics): Promise<string[]>

Defined in: editor/src/workspaceSession.svelte.ts:592

Import the manifest files among picked, each as one new block (#add), with the MatchClaim tables among them (readTables); the new blocks.

Parameters#
picked#

readonly Opened[]

canvas#

ImportTarget

metrics#

FontMetrics

Returns#

Promise<string[]>

listen()#

listen(listener): () => void

Defined in: editor/src/workspaceSession.svelte.ts:242

Call listener after every change of the open store, after the store is replaced, and after a save; returns the removal.

Parameters#
listener#

() => void

Returns#

() => void

loadNamedTables()#

loadNamedTables(): Promise<void>

Defined in: editor/src/workspaceSession.svelte.ts:659

Load the MatchClaim table every block’s manifest names where it is not loaded (what turning Show matches on asks), block after block in the canvas’s one order of blocks (the arranger’s blocksInOrder): from beside the manifest’s file (or where an example came from), silently, else as the user chooses it (MatchClaimTables.loadNamed); what each load says is posted (report). Where no block holds a table then, the message bar says so as information (NO_MATCHES). While no server can read a table nothing is asked: where no block holds a table or a block’s manifest names one the block does not hold, the message bar says as information that matches need a running server and how to start one (HOW_TO_START_A_SERVER), in place of every question. A server that answered reads tables whether or not it offers the user’s files; where it offers none, a table is looked for beside an example alone, else asked for (MatchClaimTables.loadNamed). While the server given has not answered its health check yet (MatchClaimTables.waiting) nothing is said: it may be slow rather than missing, and the editor calls this again once it answers. A call while one is under way is ignored.

Returns#

Promise<void>

manifestPath()#

manifestPath(block): string | null

Defined in: editor/src/workspaceSession.svelte.ts:335

The path from the server’s root of the file block block’s manifest came from, as the workspace states it (location, relative to the workspace file’s folder); null where it states none.

Parameters#
block#

string

Returns#

string | null

open()#

open(text, name?, handle?, path?): LoadError | null

Defined in: editor/src/workspaceSession.svelte.ts:293

Open the workspace file text as saved; the reader’s refusal, or null when it opened.

Parameters#
text#

string

name?#

string = UNTITLED

handle?#

FileSystemFileHandle | null = null

path?#

string | null = null

Returns#

LoadError | null

openPath()#

openPath(host, path): Promise<LoadError | null>

Defined in: editor/src/workspaceSession.svelte.ts:582

Open the workspace file at path on the server as saved; the reader’s refusal, or null when it opened.

Parameters#
host#

FileHost

path#

string

Returns#

Promise<LoadError | null>

openPicked()#

openPicked(picked): Promise<LoadError | null>

Defined in: editor/src/workspaceSession.svelte.ts:703

Open the workspace file among picked (isWorkspaceFile) as saved (open), the MatchClaim tables picked beside it read as its blocks’ (readTables); the reader’s refusal, or null when it opened. Every other file is reported and left.

Parameters#
picked#

readonly Opened[]

Returns#

Promise<LoadError | null>

readTables()#

readTables(picked, blocks): Promise<void>

Defined in: editor/src/workspaceSession.svelte.ts:614

Read the tables among picked as tables of blocks: every one is a MatchClaim table, read through the server as the table of the block whose manifest names a MatchClaim table of its file name, else of the only block; a table no block takes is reported. A block whose table is not among them says nothing: Show matches loads it.

Parameters#
picked#

readonly Opened[]

blocks#

readonly string[]

Returns#

Promise<void>

rename()#

rename(name): string | null

Defined in: editor/src/workspaceSession.svelte.ts:366

Rename the workspace to name (set {} {name}, journalled): null when it is renamed or already so called, else the store’s refusal’s message (an empty name; a rename inside an editor).

Parameters#
name#

string

Returns#

string | null

replace()#

replace(workspace, name, handle, saved, path?): LoadError | null

Defined in: editor/src/workspaceSession.svelte.ts:260

Make workspace the open one, in a new store; saved when it equals its file, which is called name and written back through handle (the browser’s) or at path (the server’s). A workspace whose journal does not reproduce its view is refused (journal_mismatch, at the first place it differs) and the open one kept.

Parameters#
workspace#

Workspace

name#

string

handle#

FileSystemFileHandle | null

saved#

boolean

path?#

string | null = null

Returns#

LoadError | null

report()#

report(messages): void

Defined in: editor/src/workspaceSession.svelte.ts:692

Post what a load of tables says: its information, then its failures as errors.

Parameters#
messages#

TableMessages

Returns#

void

save()#

save(as): Promise<void>

Defined in: editor/src/workspaceSession.svelte.ts:395

Save the open workspace: back into its file, or, with as, without a file to write back to (a new workspace, one without a handle), or after a rename since it was last opened or saved (until the rename is undone), to a file the user chooses now, offered under the workspace’s file name: the one its name gives for a new or renamed workspace, else its file’s. Through the server (FileHost) the file is a path chosen in the file dialog, and a save into another folder first rewrites every block’s manifest location relative to that folder; otherwise it is the browser’s (saveFile), and where that downloads, the page says so once. A save requested while one is under way is ignored.

Parameters#
as#

boolean

Returns#

Promise<void>

saveUnsaved()#

saveUnsaved(): Promise<boolean>

Defined in: editor/src/workspaceSession.svelte.ts:518

Save what unsaved names: the workspace first (save), then each changed MatchClaim table, stopping at the first the viewer does not save (a table that fails to write is reported); whether nothing unsaved is left, so the workspace may be replaced.

Returns#

Promise<boolean>

step()#

step(back): void

Defined in: editor/src/workspaceSession.svelte.ts:815

Undo or redo.

Parameters#
back#

boolean

Returns#

void

text()#

text(): string

Defined in: editor/src/workspaceSession.svelte.ts:379

The open workspace as Save writes it.

Returns#

string

unsaved()#

unsaved(): string | null

Defined in: editor/src/workspaceSession.svelte.ts:506

The question to ask before the workspace and its MatchClaim tables are replaced, naming what holds unsaved changes (unsavedQuestion): the workspace, every table a belief changed; null when nothing does.

Returns#

string | null

Interfaces#

FileHost#

Defined in: editor/src/workspaceSession.svelte.ts:119

The user’s files through the server, as the session uses them: read and written by path from the server’s root, and the editor’s file dialog choosing paths (null when the user cancels).

Properties#

server#

readonly server: Pick<FileServer, "readFile" | "writeFile">

Defined in: editor/src/workspaceSession.svelte.ts:120

Methods#

open()#

open(kinds, start): Promise<string | null>

Defined in: editor/src/workspaceSession.svelte.ts:122

Let the user choose a file of one of kinds, starting in the folder start.

Parameters#
kinds#

readonly FileKind[]

start#

string

Returns#

Promise<string | null>

save()#

save(kind, start, suggested): Promise<string | null>

Defined in: editor/src/workspaceSession.svelte.ts:124

Let the user choose where to save a file of kind, starting in start, offered as suggested.

Parameters#
kind#

FileKind

start#

string

suggested#

string

Returns#

Promise<string | null>


ImportTarget#

Defined in: editor/src/workspaceSession.svelte.ts:109

What the canvas offers an import: where the view is, and the focus.

Methods#

focus()#

focus(): void

Defined in: editor/src/workspaceSession.svelte.ts:111

Returns#

void

visible()#

visible(): Visible

Defined in: editor/src/workspaceSession.svelte.ts:110

Returns#

Visible


SessionOptions#

Defined in: editor/src/workspaceSession.svelte.ts:138

What a WorkspaceSession is made with: where it posts messages, whom it tells of a replaced workspace and a changed selection, the author, and what it reads through a server.

Properties#

askTables?#

readonly optional askTables?: AskTables | null

Defined in: editor/src/workspaceSession.svelte.ts:150

Ask the user for the files of tables a manifest names that cannot be reached; without it none is asked.

author#

readonly author: () => string

Defined in: editor/src/workspaceSession.svelte.ts:146

The user’s name, every store’s author from its creation.

Returns#

string

computes?#

readonly optional computes?: () => boolean

Defined in: editor/src/workspaceSession.svelte.ts:156

Whether the matchClaims server answered its health check now, so it computes: it reads MatchClaim tables from then on, whether or not it offers the user’s files; without it, never.

Returns#

boolean

files?#

readonly optional files?: () => FileHost | null

Defined in: editor/src/workspaceSession.svelte.ts:168

The user’s files through the server as far as it offers them now (null: it offers none, or has not answered its health check yet, and the browser’s pickers serve); without it, never.

Returns#

FileHost | null

healthFailure?#

readonly optional healthFailure?: () => string | null

Defined in: editor/src/workspaceSession.svelte.ts:162

Why the matchClaims server’s health check failed, as the editor’s offline mark says it; null while it has not (answered, or not yet); without it, never.

Returns#

string | null

matchClaims?#

readonly optional matchClaims?: MatchClaimServer | null

Defined in: editor/src/workspaceSession.svelte.ts:148

The server MatchClaim tables are read through; without it (the default) none is read.

pane?#

readonly optional pane?: Pane

Defined in: editor/src/workspaceSession.svelte.ts:170

The canvas’s pane, which a new block is placed by as the canvas draws it; without it, layout’s default view.

post#

readonly post: Post

Defined in: editor/src/workspaceSession.svelte.ts:140

Show a message at its level (Messages.post); editing goes on.

replaced?#

readonly optional replaced?: () => void

Defined in: editor/src/workspaceSession.svelte.ts:142

Called after the open workspace was replaced by another.

Returns#

void

selected?#

readonly optional selected?: (selection) => void

Defined in: editor/src/workspaceSession.svelte.ts:144

Called with the selected addresses whenever the selection changes.

Parameters#
selection#

readonly Address[]

Returns#

void