@dsh-stack/workspace-files 0.0.0-stage → 0.1.1
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/README.md +2 -2
- package/lib/index.d.ts +30 -0
- package/lib/index.js +48 -0
- package/package.json +35 -4
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# workspace-files
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Workspace file abstractions and client-facing file operations for Stack.
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type FileNodeKind = "file" | "directory" | "workspace" | "repository";
|
|
2
|
+
export type FileRowAction = "open" | "open-new-tab" | "reveal" | "copy-path" | "rename" | "duplicate" | "delete";
|
|
3
|
+
export interface FileNode {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly kind: FileNodeKind;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly parentId?: string;
|
|
9
|
+
readonly hidden?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface FileRowModel extends FileNode {
|
|
12
|
+
readonly actions: readonly FileRowAction[];
|
|
13
|
+
readonly iconRequest: {
|
|
14
|
+
readonly fileName?: string;
|
|
15
|
+
readonly extension?: string;
|
|
16
|
+
readonly languageId?: string;
|
|
17
|
+
readonly folderName?: string;
|
|
18
|
+
readonly isRoot?: boolean;
|
|
19
|
+
readonly expanded?: boolean;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare const defaultFileRowActions: readonly FileRowAction[];
|
|
23
|
+
export interface FileSection {
|
|
24
|
+
readonly id: "pinned" | "active" | "host-root" | "container-root" | "ungrouped" | "archived";
|
|
25
|
+
readonly label: string;
|
|
26
|
+
readonly iconTone: "default" | "muted";
|
|
27
|
+
}
|
|
28
|
+
export declare const defaultFileSections: readonly FileSection[];
|
|
29
|
+
/** createFileRow implementation. */
|
|
30
|
+
export declare function createFileRow(node: FileNode, expanded?: boolean): FileRowModel;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const defaultFileRowActions = [
|
|
2
|
+
"open",
|
|
3
|
+
"open-new-tab",
|
|
4
|
+
"reveal",
|
|
5
|
+
"copy-path",
|
|
6
|
+
"rename",
|
|
7
|
+
"duplicate",
|
|
8
|
+
"delete",
|
|
9
|
+
];
|
|
10
|
+
// jscpd:ignore-start -- index/tab-building mirrors composition/src/sidebar.ts's shape for a different domain; not extracted to keep each package's export self-contained
|
|
11
|
+
export const defaultFileSections = [
|
|
12
|
+
{ id: "pinned", label: "Pinned", iconTone: "default" },
|
|
13
|
+
{ id: "active", label: "Active", iconTone: "default" },
|
|
14
|
+
{ id: "host-root", label: "Host Root", iconTone: "muted" },
|
|
15
|
+
{ id: "container-root", label: "Container", iconTone: "muted" },
|
|
16
|
+
{ id: "ungrouped", label: "Ungrouped", iconTone: "muted" },
|
|
17
|
+
{ id: "archived", label: "Archived", iconTone: "muted" },
|
|
18
|
+
];
|
|
19
|
+
/** createFileRow implementation. */
|
|
20
|
+
export function createFileRow(node, expanded = false) {
|
|
21
|
+
// jscpd:ignore-end
|
|
22
|
+
const extension = extensionOf(node.name);
|
|
23
|
+
const folder = node.kind === "directory" || node.kind === "workspace" || node.kind === "repository"
|
|
24
|
+
? node.name
|
|
25
|
+
: undefined;
|
|
26
|
+
return {
|
|
27
|
+
...node,
|
|
28
|
+
actions: [...defaultFileRowActions],
|
|
29
|
+
iconRequest: {
|
|
30
|
+
fileName: node.kind === "file" ? node.name : undefined,
|
|
31
|
+
extension: extension ?? undefined,
|
|
32
|
+
folderName: folder,
|
|
33
|
+
isRoot: node.kind === "workspace" || node.kind === "repository",
|
|
34
|
+
expanded,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the extension of the given file name if it contains exactly one dot.
|
|
40
|
+
* @param name - The file name to extract the extension from.
|
|
41
|
+
* @returns The lowercased extension if present; otherwise, undefined.
|
|
42
|
+
*/
|
|
43
|
+
function extensionOf(name) {
|
|
44
|
+
const dot = name.lastIndexOf(".");
|
|
45
|
+
if (dot <= 0 || dot === name.length - 1)
|
|
46
|
+
return undefined;
|
|
47
|
+
return name.slice(dot + 1).toLowerCase();
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-stack/workspace-files",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./lib/index.d.ts",
|
|
10
|
+
"default": "./lib/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc -p tsconfig.json",
|
|
15
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
16
|
+
"verify": "node verify.mjs"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^6.0.3"
|
|
20
|
+
},
|
|
21
|
+
"stack": {
|
|
22
|
+
"kind": "plugin",
|
|
23
|
+
"id": "stack.workspace.files"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/marius-patrik/dsh-stack.git",
|
|
35
|
+
"directory": "plugins/workspace-files"
|
|
36
|
+
}
|
|
37
|
+
}
|