@caryhu/codemine-forge 0.0.1-alpha.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/README.md +108 -0
- package/dist/build-pipeline/browser-bundle.d.ts +31 -0
- package/dist/build-pipeline/browser-bundle.js +584 -0
- package/dist/build-pipeline/diagnostics.d.ts +7 -0
- package/dist/build-pipeline/diagnostics.js +68 -0
- package/dist/build-pipeline/index.d.ts +3 -0
- package/dist/build-pipeline/index.js +16 -0
- package/dist/build-pipeline/pipeline.d.ts +12 -0
- package/dist/build-pipeline/pipeline.js +273 -0
- package/dist/build-pipeline/types.d.ts +77 -0
- package/dist/build-pipeline/types.js +4 -0
- package/dist/dev-server-preview/diagnostics.d.ts +5 -0
- package/dist/dev-server-preview/diagnostics.js +40 -0
- package/dist/dev-server-preview/index.d.ts +4 -0
- package/dist/dev-server-preview/index.js +16 -0
- package/dist/dev-server-preview/preview-document.d.ts +2 -0
- package/dist/dev-server-preview/preview-document.js +153 -0
- package/dist/dev-server-preview/server.d.ts +26 -0
- package/dist/dev-server-preview/server.js +279 -0
- package/dist/dev-server-preview/types.d.ts +105 -0
- package/dist/dev-server-preview/types.js +4 -0
- package/dist/esbuild-wasm-worker/diagnostics.d.ts +12 -0
- package/dist/esbuild-wasm-worker/diagnostics.js +53 -0
- package/dist/esbuild-wasm-worker/index.d.ts +4 -0
- package/dist/esbuild-wasm-worker/index.js +18 -0
- package/dist/esbuild-wasm-worker/service.d.ts +26 -0
- package/dist/esbuild-wasm-worker/service.js +260 -0
- package/dist/esbuild-wasm-worker/types.d.ts +139 -0
- package/dist/esbuild-wasm-worker/types.js +5 -0
- package/dist/esbuild-wasm-worker/worker-adapter.d.ts +38 -0
- package/dist/esbuild-wasm-worker/worker-adapter.js +165 -0
- package/dist/esbuild-wasm-worker/worker.d.ts +1 -0
- package/dist/esbuild-wasm-worker/worker.js +4 -0
- package/dist/forge-controller.d.ts +38 -0
- package/dist/forge-controller.js +79 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +88 -0
- package/dist/package-resolution/cdn-source.d.ts +11 -0
- package/dist/package-resolution/cdn-source.js +164 -0
- package/dist/package-resolution/diagnostics.d.ts +15 -0
- package/dist/package-resolution/diagnostics.js +51 -0
- package/dist/package-resolution/errors.d.ts +5 -0
- package/dist/package-resolution/errors.js +11 -0
- package/dist/package-resolution/index.d.ts +6 -0
- package/dist/package-resolution/index.js +23 -0
- package/dist/package-resolution/manifest.d.ts +5 -0
- package/dist/package-resolution/manifest.js +128 -0
- package/dist/package-resolution/resolver.d.ts +17 -0
- package/dist/package-resolution/resolver.js +172 -0
- package/dist/package-resolution/types.d.ts +98 -0
- package/dist/package-resolution/types.js +4 -0
- package/dist/terminal-commands/diagnostics.d.ts +3 -0
- package/dist/terminal-commands/diagnostics.js +21 -0
- package/dist/terminal-commands/index.d.ts +7 -0
- package/dist/terminal-commands/index.js +22 -0
- package/dist/terminal-commands/npm-build.d.ts +7 -0
- package/dist/terminal-commands/npm-build.js +63 -0
- package/dist/terminal-commands/npm-dev.d.ts +7 -0
- package/dist/terminal-commands/npm-dev.js +68 -0
- package/dist/terminal-commands/npm-install.d.ts +8 -0
- package/dist/terminal-commands/npm-install.js +56 -0
- package/dist/terminal-commands/parser.d.ts +2 -0
- package/dist/terminal-commands/parser.js +52 -0
- package/dist/terminal-commands/terminal.d.ts +12 -0
- package/dist/terminal-commands/terminal.js +73 -0
- package/dist/terminal-commands/types.d.ts +65 -0
- package/dist/terminal-commands/types.js +4 -0
- package/dist/virtual-file-system/diagnostics.d.ts +14 -0
- package/dist/virtual-file-system/diagnostics.js +55 -0
- package/dist/virtual-file-system/errors.d.ts +5 -0
- package/dist/virtual-file-system/errors.js +11 -0
- package/dist/virtual-file-system/index.d.ts +26 -0
- package/dist/virtual-file-system/index.js +47 -0
- package/dist/virtual-file-system/limits.d.ts +4 -0
- package/dist/virtual-file-system/limits.js +33 -0
- package/dist/virtual-file-system/memory.d.ts +33 -0
- package/dist/virtual-file-system/memory.js +551 -0
- package/dist/virtual-file-system/path.d.ts +9 -0
- package/dist/virtual-file-system/path.js +47 -0
- package/dist/virtual-file-system/storage.d.ts +32 -0
- package/dist/virtual-file-system/storage.js +194 -0
- package/dist/virtual-file-system/types.d.ts +165 -0
- package/dist/virtual-file-system/types.js +2 -0
- package/package.json +43 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createIndexedDbForgeStorage = exports.IndexedDbForgeStorage = exports.FORGE_INDEXED_DB_STORES = exports.FORGE_INDEXED_DB_VERSION = exports.FORGE_INDEXED_DB_NAME = void 0;
|
|
4
|
+
const diagnostics_1 = require("./diagnostics");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
const limits_1 = require("./limits");
|
|
7
|
+
exports.FORGE_INDEXED_DB_NAME = "codemine-forge";
|
|
8
|
+
exports.FORGE_INDEXED_DB_VERSION = 1;
|
|
9
|
+
exports.FORGE_INDEXED_DB_STORES = {
|
|
10
|
+
buildCache: "build-cache",
|
|
11
|
+
packageCache: "package-cache",
|
|
12
|
+
workspaceFiles: "workspace-files",
|
|
13
|
+
workspaceMetadata: "workspace-metadata",
|
|
14
|
+
workspaceSnapshots: "workspace-snapshots",
|
|
15
|
+
};
|
|
16
|
+
class IndexedDbForgeStorage {
|
|
17
|
+
constructor(options = {}) {
|
|
18
|
+
this.databaseName = options.databaseName ?? exports.FORGE_INDEXED_DB_NAME;
|
|
19
|
+
this.limits = (0, limits_1.resolveForgeVirtualFileSystemLimits)(options.limits);
|
|
20
|
+
}
|
|
21
|
+
async loadWorkspace(workspaceId) {
|
|
22
|
+
const database = await this.openDatabase();
|
|
23
|
+
const transaction = database.transaction([
|
|
24
|
+
exports.FORGE_INDEXED_DB_STORES.workspaceMetadata,
|
|
25
|
+
exports.FORGE_INDEXED_DB_STORES.workspaceFiles,
|
|
26
|
+
], "readonly");
|
|
27
|
+
const metadataStore = transaction.objectStore(exports.FORGE_INDEXED_DB_STORES.workspaceMetadata);
|
|
28
|
+
const fileStore = transaction.objectStore(exports.FORGE_INDEXED_DB_STORES.workspaceFiles);
|
|
29
|
+
const metadata = await requestToPromise(metadataStore.get(workspaceId));
|
|
30
|
+
if (metadata === undefined) {
|
|
31
|
+
await transactionDone(transaction);
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const files = await Promise.all(metadata.filePaths.map(async (path) => {
|
|
35
|
+
const fileRecord = await requestToPromise(fileStore.get([workspaceId, path]));
|
|
36
|
+
return fileRecord?.file;
|
|
37
|
+
}));
|
|
38
|
+
await transactionDone(transaction);
|
|
39
|
+
return {
|
|
40
|
+
id: metadata.id,
|
|
41
|
+
name: metadata.name,
|
|
42
|
+
files: files.filter((file) => file !== undefined),
|
|
43
|
+
metadata: {
|
|
44
|
+
createdAt: metadata.createdAt,
|
|
45
|
+
updatedAt: metadata.updatedAt,
|
|
46
|
+
},
|
|
47
|
+
lock: metadata.lock,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async saveWorkspace(workspace) {
|
|
51
|
+
const database = await this.openDatabase();
|
|
52
|
+
const transaction = database.transaction([
|
|
53
|
+
exports.FORGE_INDEXED_DB_STORES.workspaceMetadata,
|
|
54
|
+
exports.FORGE_INDEXED_DB_STORES.workspaceFiles,
|
|
55
|
+
], "readwrite");
|
|
56
|
+
const metadataStore = transaction.objectStore(exports.FORGE_INDEXED_DB_STORES.workspaceMetadata);
|
|
57
|
+
const fileStore = transaction.objectStore(exports.FORGE_INDEXED_DB_STORES.workspaceFiles);
|
|
58
|
+
metadataStore.put({
|
|
59
|
+
id: workspace.id,
|
|
60
|
+
name: workspace.name,
|
|
61
|
+
filePaths: workspace.files.map((file) => file.path),
|
|
62
|
+
createdAt: workspace.metadata.createdAt,
|
|
63
|
+
updatedAt: workspace.metadata.updatedAt,
|
|
64
|
+
lock: workspace.lock,
|
|
65
|
+
});
|
|
66
|
+
for (const file of workspace.files) {
|
|
67
|
+
fileStore.put({
|
|
68
|
+
workspaceId: workspace.id,
|
|
69
|
+
path: file.path,
|
|
70
|
+
file,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
await transactionDone(transaction);
|
|
74
|
+
}
|
|
75
|
+
async getPackageCacheRecord(key) {
|
|
76
|
+
return this.getCacheRecord(exports.FORGE_INDEXED_DB_STORES.packageCache, key);
|
|
77
|
+
}
|
|
78
|
+
async putPackageCacheRecord(record) {
|
|
79
|
+
await this.putCacheRecord(exports.FORGE_INDEXED_DB_STORES.packageCache, record);
|
|
80
|
+
}
|
|
81
|
+
async getBuildCacheRecord(key) {
|
|
82
|
+
return this.getCacheRecord(exports.FORGE_INDEXED_DB_STORES.buildCache, key);
|
|
83
|
+
}
|
|
84
|
+
async putBuildCacheRecord(record) {
|
|
85
|
+
await this.putCacheRecord(exports.FORGE_INDEXED_DB_STORES.buildCache, record);
|
|
86
|
+
}
|
|
87
|
+
async clearBuildCache() {
|
|
88
|
+
const database = await this.openDatabase();
|
|
89
|
+
const transaction = database.transaction([exports.FORGE_INDEXED_DB_STORES.buildCache], "readwrite");
|
|
90
|
+
transaction
|
|
91
|
+
.objectStore(exports.FORGE_INDEXED_DB_STORES.buildCache)
|
|
92
|
+
.clear();
|
|
93
|
+
await transactionDone(transaction);
|
|
94
|
+
}
|
|
95
|
+
async getCacheRecord(storeName, key) {
|
|
96
|
+
const database = await this.openDatabase();
|
|
97
|
+
const transaction = database.transaction([storeName], "readonly");
|
|
98
|
+
const record = await requestToPromise(transaction.objectStore(storeName).get(key));
|
|
99
|
+
await transactionDone(transaction);
|
|
100
|
+
return record;
|
|
101
|
+
}
|
|
102
|
+
async putCacheRecord(storeName, record) {
|
|
103
|
+
await this.assertCacheLimit(storeName, record);
|
|
104
|
+
const database = await this.openDatabase();
|
|
105
|
+
const transaction = database.transaction([storeName], "readwrite");
|
|
106
|
+
transaction.objectStore(storeName).put(record);
|
|
107
|
+
await transactionDone(transaction);
|
|
108
|
+
}
|
|
109
|
+
async assertCacheLimit(storeName, record) {
|
|
110
|
+
const limitName = storeName === exports.FORGE_INDEXED_DB_STORES.packageCache
|
|
111
|
+
? "packageCacheSize"
|
|
112
|
+
: "buildCacheSize";
|
|
113
|
+
const maximum = storeName === exports.FORGE_INDEXED_DB_STORES.packageCache
|
|
114
|
+
? this.limits.maxPackageCacheSizeBytes
|
|
115
|
+
: this.limits.maxBuildCacheSizeBytes;
|
|
116
|
+
const database = await this.openDatabase();
|
|
117
|
+
const transaction = database.transaction([storeName], "readonly");
|
|
118
|
+
const existingRecords = await requestToPromise(transaction.objectStore(storeName).getAll());
|
|
119
|
+
await transactionDone(transaction);
|
|
120
|
+
const existingSize = existingRecords
|
|
121
|
+
.filter((existingRecord) => existingRecord.key !== record.key)
|
|
122
|
+
.reduce((total, existingRecord) => total + existingRecord.size, 0);
|
|
123
|
+
const actual = existingSize + record.size;
|
|
124
|
+
if (actual > maximum) {
|
|
125
|
+
throw new errors_1.ForgeFileSystemError((0, limits_1.createLimitExceededDiagnostic)(limitName, actual, maximum));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
openDatabase() {
|
|
129
|
+
if (this.databasePromise !== undefined) {
|
|
130
|
+
return this.databasePromise;
|
|
131
|
+
}
|
|
132
|
+
if (!isIndexedDbAvailable()) {
|
|
133
|
+
return Promise.reject(new errors_1.ForgeFileSystemError((0, diagnostics_1.createForgeDiagnostic)({
|
|
134
|
+
code: "storage_unavailable",
|
|
135
|
+
message: "IndexedDB is not available in this environment.",
|
|
136
|
+
})));
|
|
137
|
+
}
|
|
138
|
+
this.databasePromise = new Promise((resolve, reject) => {
|
|
139
|
+
const request = indexedDB.open(this.databaseName, exports.FORGE_INDEXED_DB_VERSION);
|
|
140
|
+
request.onerror = () => reject(request.error);
|
|
141
|
+
request.onupgradeneeded = () => ensureStores(request.result);
|
|
142
|
+
request.onsuccess = () => resolve(request.result);
|
|
143
|
+
});
|
|
144
|
+
return this.databasePromise;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.IndexedDbForgeStorage = IndexedDbForgeStorage;
|
|
148
|
+
function createIndexedDbForgeStorage(options) {
|
|
149
|
+
return new IndexedDbForgeStorage(options);
|
|
150
|
+
}
|
|
151
|
+
exports.createIndexedDbForgeStorage = createIndexedDbForgeStorage;
|
|
152
|
+
function ensureStores(database) {
|
|
153
|
+
if (!database.objectStoreNames.contains(exports.FORGE_INDEXED_DB_STORES.workspaceMetadata)) {
|
|
154
|
+
database.createObjectStore(exports.FORGE_INDEXED_DB_STORES.workspaceMetadata, {
|
|
155
|
+
keyPath: "id",
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (!database.objectStoreNames.contains(exports.FORGE_INDEXED_DB_STORES.workspaceFiles)) {
|
|
159
|
+
database.createObjectStore(exports.FORGE_INDEXED_DB_STORES.workspaceFiles, {
|
|
160
|
+
keyPath: ["workspaceId", "path"],
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (!database.objectStoreNames.contains(exports.FORGE_INDEXED_DB_STORES.workspaceSnapshots)) {
|
|
164
|
+
database.createObjectStore(exports.FORGE_INDEXED_DB_STORES.workspaceSnapshots, {
|
|
165
|
+
keyPath: "id",
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if (!database.objectStoreNames.contains(exports.FORGE_INDEXED_DB_STORES.packageCache)) {
|
|
169
|
+
database.createObjectStore(exports.FORGE_INDEXED_DB_STORES.packageCache, {
|
|
170
|
+
keyPath: "key",
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (!database.objectStoreNames.contains(exports.FORGE_INDEXED_DB_STORES.buildCache)) {
|
|
174
|
+
database.createObjectStore(exports.FORGE_INDEXED_DB_STORES.buildCache, {
|
|
175
|
+
keyPath: "key",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function requestToPromise(request) {
|
|
180
|
+
return new Promise((resolve, reject) => {
|
|
181
|
+
request.onerror = () => reject(request.error);
|
|
182
|
+
request.onsuccess = () => resolve(request.result);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function transactionDone(transaction) {
|
|
186
|
+
return new Promise((resolve, reject) => {
|
|
187
|
+
transaction.onabort = () => reject(transaction.error);
|
|
188
|
+
transaction.onerror = () => reject(transaction.error);
|
|
189
|
+
transaction.oncomplete = () => resolve();
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function isIndexedDbAvailable() {
|
|
193
|
+
return typeof indexedDB !== "undefined";
|
|
194
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
export type ForgeFileKind = "file" | "directory";
|
|
2
|
+
export type ForgeFileSource = "user" | "template" | "generated" | "cache";
|
|
3
|
+
export interface ForgeWorkspace {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly rootPath: "/";
|
|
7
|
+
readonly files: readonly ForgeFileRecord[];
|
|
8
|
+
readonly metadata?: ForgeWorkspaceMetadata;
|
|
9
|
+
readonly lock?: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface ForgeWorkspaceMetadata {
|
|
12
|
+
readonly createdAt: string;
|
|
13
|
+
readonly updatedAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ForgeFileRecord {
|
|
16
|
+
readonly path: string;
|
|
17
|
+
readonly kind: ForgeFileKind;
|
|
18
|
+
readonly content?: Uint8Array;
|
|
19
|
+
readonly contentType?: string;
|
|
20
|
+
readonly contentHash?: string;
|
|
21
|
+
readonly size: number;
|
|
22
|
+
readonly createdAt: string;
|
|
23
|
+
readonly updatedAt: string;
|
|
24
|
+
readonly source: ForgeFileSource;
|
|
25
|
+
}
|
|
26
|
+
export interface ForgeDirEntry {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly kind: ForgeFileKind;
|
|
30
|
+
readonly stat: ForgeFileStat;
|
|
31
|
+
}
|
|
32
|
+
export interface ForgeFileStat {
|
|
33
|
+
readonly path: string;
|
|
34
|
+
readonly kind: ForgeFileKind;
|
|
35
|
+
readonly contentType?: string;
|
|
36
|
+
readonly contentHash?: string;
|
|
37
|
+
readonly size: number;
|
|
38
|
+
readonly createdAt: string;
|
|
39
|
+
readonly updatedAt: string;
|
|
40
|
+
readonly source: ForgeFileSource;
|
|
41
|
+
}
|
|
42
|
+
export interface ForgeSnapshot {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly workspaceId: string;
|
|
45
|
+
readonly createdAt: string;
|
|
46
|
+
readonly files: readonly ForgeFileRecord[];
|
|
47
|
+
readonly lock?: unknown;
|
|
48
|
+
readonly metadata?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
export type ForgeDiagnosticSeverity = "info" | "warning" | "error";
|
|
51
|
+
export type ForgeDiagnosticCode = "already_exists" | "directory_not_empty" | "invalid_path" | "is_directory" | "limit_exceeded" | "missing_parent" | "not_directory" | "not_file" | "not_found" | "not_implemented" | "path_traversal" | "storage_unavailable";
|
|
52
|
+
export interface ForgeDiagnostic {
|
|
53
|
+
readonly code: ForgeDiagnosticCode;
|
|
54
|
+
readonly severity: ForgeDiagnosticSeverity;
|
|
55
|
+
readonly message: string;
|
|
56
|
+
readonly path?: string;
|
|
57
|
+
readonly relatedPath?: string;
|
|
58
|
+
readonly limit?: ForgeLimitDiagnostic;
|
|
59
|
+
readonly cause?: unknown;
|
|
60
|
+
}
|
|
61
|
+
export interface ForgeLimitDiagnostic {
|
|
62
|
+
readonly name: "buildCacheSize" | "fileCount" | "fileSize" | "packageCacheSize" | "workspaceSize";
|
|
63
|
+
readonly actual: number;
|
|
64
|
+
readonly maximum: number;
|
|
65
|
+
}
|
|
66
|
+
export type ForgeFileEvent = ForgeFileCreatedEvent | ForgeFileUpdatedEvent | ForgeFileDeletedEvent | ForgeFileRenamedEvent;
|
|
67
|
+
export interface ForgeFileCreatedEvent {
|
|
68
|
+
readonly type: "file:created";
|
|
69
|
+
readonly path: string;
|
|
70
|
+
readonly stat: ForgeFileStat;
|
|
71
|
+
}
|
|
72
|
+
export interface ForgeFileUpdatedEvent {
|
|
73
|
+
readonly type: "file:updated";
|
|
74
|
+
readonly path: string;
|
|
75
|
+
readonly stat: ForgeFileStat;
|
|
76
|
+
readonly previousHash?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface ForgeFileDeletedEvent {
|
|
79
|
+
readonly type: "file:deleted";
|
|
80
|
+
readonly path: string;
|
|
81
|
+
readonly stat?: ForgeFileStat;
|
|
82
|
+
}
|
|
83
|
+
export interface ForgeFileRenamedEvent {
|
|
84
|
+
readonly type: "file:renamed";
|
|
85
|
+
readonly from: string;
|
|
86
|
+
readonly to: string;
|
|
87
|
+
readonly stat: ForgeFileStat;
|
|
88
|
+
}
|
|
89
|
+
export type ForgeFileWatchListener = (event: ForgeFileEvent) => void;
|
|
90
|
+
export type ForgeUnsubscribe = () => void;
|
|
91
|
+
export interface ForgeWriteFileOptions {
|
|
92
|
+
readonly contentType?: string;
|
|
93
|
+
readonly source?: ForgeFileSource;
|
|
94
|
+
}
|
|
95
|
+
export interface ForgeDeleteOptions {
|
|
96
|
+
readonly recursive?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface ForgeMkdirOptions {
|
|
99
|
+
readonly recursive?: boolean;
|
|
100
|
+
readonly source?: ForgeFileSource;
|
|
101
|
+
}
|
|
102
|
+
export interface ForgeSnapshotOptions {
|
|
103
|
+
readonly includeGeneratedFiles?: boolean;
|
|
104
|
+
readonly includeRuntimeMetadata?: boolean;
|
|
105
|
+
}
|
|
106
|
+
export interface ForgeRestoreOptions {
|
|
107
|
+
readonly preserveWorkspaceId?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface ForgeVirtualFileSystemOptions {
|
|
110
|
+
readonly workspaceId?: string;
|
|
111
|
+
readonly workspaceName?: string;
|
|
112
|
+
readonly files?: readonly ForgeFileRecord[];
|
|
113
|
+
readonly metadata?: ForgeWorkspaceMetadata;
|
|
114
|
+
readonly lock?: unknown;
|
|
115
|
+
readonly storage?: ForgeVirtualFileSystemStorage;
|
|
116
|
+
readonly limits?: ForgeVirtualFileSystemLimits;
|
|
117
|
+
}
|
|
118
|
+
export interface ForgeOpenVirtualFileSystemOptions {
|
|
119
|
+
readonly workspaceId: string;
|
|
120
|
+
readonly workspaceName?: string;
|
|
121
|
+
readonly storage?: ForgeVirtualFileSystemStorage;
|
|
122
|
+
readonly limits?: ForgeVirtualFileSystemLimits;
|
|
123
|
+
}
|
|
124
|
+
export interface ForgeVirtualFileSystemStorage {
|
|
125
|
+
loadWorkspace(workspaceId: string): Promise<ForgePersistedWorkspace | undefined>;
|
|
126
|
+
saveWorkspace(workspace: ForgePersistedWorkspace): Promise<void>;
|
|
127
|
+
getPackageCacheRecord(key: string): Promise<ForgePackageCacheRecord | undefined>;
|
|
128
|
+
putPackageCacheRecord(record: ForgePackageCacheRecord): Promise<void>;
|
|
129
|
+
getBuildCacheRecord(key: string): Promise<ForgeBuildCacheRecord | undefined>;
|
|
130
|
+
putBuildCacheRecord(record: ForgeBuildCacheRecord): Promise<void>;
|
|
131
|
+
clearBuildCache(): Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
export interface ForgePersistedWorkspace {
|
|
134
|
+
readonly id: string;
|
|
135
|
+
readonly name: string;
|
|
136
|
+
readonly files: readonly ForgeFileRecord[];
|
|
137
|
+
readonly metadata: ForgeWorkspaceMetadata;
|
|
138
|
+
readonly lock?: unknown;
|
|
139
|
+
}
|
|
140
|
+
export interface ForgePackageCacheRecord {
|
|
141
|
+
readonly key: string;
|
|
142
|
+
readonly value: unknown;
|
|
143
|
+
readonly size: number;
|
|
144
|
+
readonly updatedAt: string;
|
|
145
|
+
}
|
|
146
|
+
export interface ForgeBuildCacheRecord {
|
|
147
|
+
readonly key: string;
|
|
148
|
+
readonly value: unknown;
|
|
149
|
+
readonly size: number;
|
|
150
|
+
readonly updatedAt: string;
|
|
151
|
+
}
|
|
152
|
+
export interface ForgeVirtualFileSystemLimits {
|
|
153
|
+
readonly maxFileSizeBytes?: number;
|
|
154
|
+
readonly maxWorkspaceSizeBytes?: number;
|
|
155
|
+
readonly maxFileCount?: number;
|
|
156
|
+
readonly maxPackageCacheSizeBytes?: number;
|
|
157
|
+
readonly maxBuildCacheSizeBytes?: number;
|
|
158
|
+
}
|
|
159
|
+
export interface ResolvedForgeVirtualFileSystemLimits {
|
|
160
|
+
readonly maxFileSizeBytes: number;
|
|
161
|
+
readonly maxWorkspaceSizeBytes: number;
|
|
162
|
+
readonly maxFileCount: number;
|
|
163
|
+
readonly maxPackageCacheSizeBytes: number;
|
|
164
|
+
readonly maxBuildCacheSizeBytes: number;
|
|
165
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@caryhu/codemine-forge",
|
|
3
|
+
"version": "0.0.1-alpha.0",
|
|
4
|
+
"description": "Browser-side runtime layer for Codemine demos.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"esbuild-wasm": "^0.28.1",
|
|
22
|
+
"typescript": "4.9.5"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"fake-indexeddb": "^6.2.5",
|
|
26
|
+
"playwright": "^1.61.1"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "pnpm run clean && tsc -p tsconfig.build.json",
|
|
30
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
31
|
+
"demo": "pnpm run test:build && node demo/terminal-demo.mjs",
|
|
32
|
+
"demo:web": "pnpm run test:build && node demo/web-demo-server.mjs",
|
|
33
|
+
"demo:static": "node demo/generate-static-demo.mjs",
|
|
34
|
+
"publish:npm": "node scripts/publish-npm.mjs",
|
|
35
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
36
|
+
"test:build": "tsc -p tsconfig.test.json",
|
|
37
|
+
"test": "pnpm run test:build && node test/virtual-file-system.test.mjs && node test/indexeddb-workspace-restore.test.mjs && node test/react-vite-template-dev-loop.test.mjs && node test/react-vite-template-diagnostics.test.mjs && node test/package-resolution.test.mjs && node test/build-pipeline.test.mjs && node test/dev-server-preview.test.mjs && node test/terminal-commands.test.mjs && node test/esbuild-wasm-worker.test.mjs && node test/browser-preview-execution.test.mjs && node test/demo-samples.test.mjs",
|
|
38
|
+
"test:browser-preview": "pnpm run test:build && node test/browser-preview-execution.test.mjs",
|
|
39
|
+
"test:demo-samples": "pnpm run test:build && node test/demo-samples.test.mjs",
|
|
40
|
+
"test:static-demo": "node test/static-demo.test.mjs",
|
|
41
|
+
"validate": "pnpm run typecheck && pnpm test"
|
|
42
|
+
}
|
|
43
|
+
}
|