Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP adopt new viz types package #883

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 5 additions & 28 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,14 @@
// FileId
// * A unique ID for a file.
// * This is a random string.
export type FileId = string;
import { VizFile, VizFileId, VizFiles } from './viz-types';

export type FileId = VizFileId;
export type File = VizFile;
export type Files = VizFiles;

// ItemId
// * A unique ID for an item in the sidebar.
// * This could be either a file ID or a directory path.
export type ItemId = FileId | FileTreePath;

// Files
// * A collection of files.
// * Keys are _not_ file names or array indices,
// because based on past experience, that
// leads to very difficult frontend logic around
// OT in the case that a file is renamed or deleted.
// * When the file name changes, or files are added/deleted,
// this ID stays the same, simplifying things re:OT.
export interface Files {
[fileId: FileId]: File;
}

// File
// * A file with `name` and `text`.
export interface File {
// The file name.
// e.g. "index.html".
name: string;

// The text content of the file.
// e.g. "<body>Hello</body>"
text: string;
}

// FileTreePath
// * The path to the directory, e.g. "src/components", OR
// * The path to the file e.g. "src/components/HelloWorld.js".
Expand Down
28 changes: 28 additions & 0 deletions src/viz-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// VizFileId
// * A unique ID for a file.
// * This is a random string.
export type VizFileId = string;

// VizFiles
// * A collection of files.
// * Keys are _not_ file names or array indices,
// because based on past experience, that
// leads to very difficult frontend logic around
// OT in the case that a file is renamed or deleted.
// * When the file name changes, or files are added/deleted,
// this ID stays the same, simplifying things re:OT.
export type VizFiles = {
[fileId: VizFileId]: VizFile;
};

// VizFile
// * A file with `name` and `text`.
export type VizFile = {
// The file name.
// e.g. "index.html".
name: string;

// The text content of the file.
// e.g. "<body>Hello</body>"
text: string;
};