@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
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Codemine Forge
|
|
2
|
+
|
|
3
|
+
Codemine Forge is the browser-side runtime layer for Codemine demos.
|
|
4
|
+
|
|
5
|
+
It is not a full Node.js emulator and it is not a backend runner. Its job is to
|
|
6
|
+
make browser-hosted projects feel like a small StackBlitz-style environment by
|
|
7
|
+
owning the virtual workspace, simulated terminal commands, dependency
|
|
8
|
+
resolution, browser bundling, and preview runtime.
|
|
9
|
+
|
|
10
|
+
## Scope
|
|
11
|
+
|
|
12
|
+
Forge owns these capabilities:
|
|
13
|
+
|
|
14
|
+
- Virtual file system for project files, snapshots, package cache, and build
|
|
15
|
+
cache.
|
|
16
|
+
- Fake terminal with a controlled command registry.
|
|
17
|
+
- Browser bundling through `esbuild-wasm`.
|
|
18
|
+
- TS, JSX, TSX, CSS, JSON, and static asset bundling.
|
|
19
|
+
- `package.json` dependency parsing.
|
|
20
|
+
- Import map generation or bundle alias generation.
|
|
21
|
+
- Simulated `npm install`, `npm run build`, and `npm run dev` experience.
|
|
22
|
+
- Vite-like dev server compatibility for preview workflows.
|
|
23
|
+
|
|
24
|
+
Forge does not own:
|
|
25
|
+
|
|
26
|
+
- User accounts, billing, permissions, or product navigation.
|
|
27
|
+
- Server-side execution, containers, SSH, or unrestricted shell access.
|
|
28
|
+
- Full npm CLI compatibility.
|
|
29
|
+
- Native Node modules, `node-gyp`, install scripts, or arbitrary process
|
|
30
|
+
spawning.
|
|
31
|
+
- Generated frontend output in the main Codemine repository.
|
|
32
|
+
|
|
33
|
+
## Runtime Shape
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
Codemine host app
|
|
37
|
+
Editor / file tree / demo page
|
|
38
|
+
|
|
|
39
|
+
v
|
|
40
|
+
Codemine Forge
|
|
41
|
+
Virtual FS
|
|
42
|
+
Fake terminal
|
|
43
|
+
Package resolver
|
|
44
|
+
Build worker
|
|
45
|
+
Dev server facade
|
|
46
|
+
|
|
|
47
|
+
v
|
|
48
|
+
Preview iframe
|
|
49
|
+
Runs compiled browser modules
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Forge should expose a small API to the host application. The host application
|
|
53
|
+
can render its own editor, file tree, tabs, and buttons, while Forge provides
|
|
54
|
+
the runtime behavior behind those controls.
|
|
55
|
+
|
|
56
|
+
## Document Map
|
|
57
|
+
|
|
58
|
+
- [Architecture](docs/architecture.md)
|
|
59
|
+
- [Virtual File System](docs/virtual-file-system.md)
|
|
60
|
+
- [Package Resolution](docs/package-resolution.md)
|
|
61
|
+
- [Build Pipeline](docs/build-pipeline.md)
|
|
62
|
+
- [Terminal Commands](docs/terminal-commands.md)
|
|
63
|
+
- [Vite-like Dev Server](docs/vite-like-dev-server.md)
|
|
64
|
+
- [Roadmap](docs/roadmap.md)
|
|
65
|
+
|
|
66
|
+
## Publishing
|
|
67
|
+
|
|
68
|
+
Publish prerelease builds to npm with:
|
|
69
|
+
|
|
70
|
+
```powershell
|
|
71
|
+
pnpm run publish:npm
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The script validates the package, checks that the current version is not already
|
|
75
|
+
published, runs a package dry run, and publishes with the `alpha` dist-tag by
|
|
76
|
+
default. If npm login is required, it starts the npm web login flow in the
|
|
77
|
+
browser and waits for authentication to complete.
|
|
78
|
+
|
|
79
|
+
Useful options:
|
|
80
|
+
|
|
81
|
+
```powershell
|
|
82
|
+
pnpm run publish:npm -- --dry-run
|
|
83
|
+
pnpm run publish:npm -- --tag next
|
|
84
|
+
pnpm run publish:npm -- --login-only
|
|
85
|
+
pnpm run publish:npm -- --otp 123456
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Design Principles
|
|
89
|
+
|
|
90
|
+
- Prefer browser-native execution over hidden backend work.
|
|
91
|
+
- Keep commands deterministic and explicitly supported.
|
|
92
|
+
- Treat `npm` commands as product affordances, not a real shell.
|
|
93
|
+
- Make unsupported Node behavior fail early with clear diagnostics.
|
|
94
|
+
- Cache aggressively, but keep cache invalidation visible and debuggable.
|
|
95
|
+
- Keep the preview iframe isolated from Codemine application privileges.
|
|
96
|
+
|
|
97
|
+
## First Milestone
|
|
98
|
+
|
|
99
|
+
The first useful milestone is a browser-only runner that can:
|
|
100
|
+
|
|
101
|
+
- Load a template workspace from memory.
|
|
102
|
+
- Persist edits in IndexedDB.
|
|
103
|
+
- Parse `package.json`.
|
|
104
|
+
- Resolve public browser-compatible dependencies.
|
|
105
|
+
- Bundle a React or Vue entry with `esbuild-wasm`.
|
|
106
|
+
- Simulate `npm install`, `npm run build`, and `npm run dev`.
|
|
107
|
+
- Render the result in an iframe.
|
|
108
|
+
- Rebuild and refresh the iframe after file changes.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ForgePackageResolutionResult } from "../package-resolution";
|
|
2
|
+
import { type ForgeVirtualFileSystem } from "../virtual-file-system";
|
|
3
|
+
import type { ForgeBrowserBundle, ForgeBuildOutputFile, ForgeBuildPipelineDiagnostic } from "./types";
|
|
4
|
+
export interface ForgeBrowserBundleResult {
|
|
5
|
+
readonly browserBundle?: ForgeBrowserBundle;
|
|
6
|
+
readonly diagnostics: readonly ForgeBuildPipelineDiagnostic[];
|
|
7
|
+
readonly outputFiles: readonly ForgeBuildOutputFile[];
|
|
8
|
+
}
|
|
9
|
+
interface CreateBrowserBundleOptions {
|
|
10
|
+
readonly entry: string;
|
|
11
|
+
readonly fileSystem: ForgeVirtualFileSystem;
|
|
12
|
+
readonly packageResolution: ForgePackageResolutionResult;
|
|
13
|
+
readonly scriptTransformer?: ForgeBrowserBundleScriptTransformer;
|
|
14
|
+
}
|
|
15
|
+
export type ForgeBrowserBundleScriptLoader = "ts" | "tsx";
|
|
16
|
+
export interface ForgeBrowserBundleScriptTransformRequest {
|
|
17
|
+
readonly loader: ForgeBrowserBundleScriptLoader;
|
|
18
|
+
readonly sourcePath: string;
|
|
19
|
+
readonly sourceText: string;
|
|
20
|
+
}
|
|
21
|
+
export type ForgeBrowserBundleScriptTransformResult = {
|
|
22
|
+
readonly success: true;
|
|
23
|
+
readonly outputText: string;
|
|
24
|
+
readonly diagnostics: readonly [];
|
|
25
|
+
} | {
|
|
26
|
+
readonly success: false;
|
|
27
|
+
readonly diagnostics: readonly ForgeBuildPipelineDiagnostic[];
|
|
28
|
+
};
|
|
29
|
+
export type ForgeBrowserBundleScriptTransformer = (request: ForgeBrowserBundleScriptTransformRequest) => Promise<ForgeBrowserBundleScriptTransformResult>;
|
|
30
|
+
export declare function createBrowserBundle(options: CreateBrowserBundleOptions): Promise<ForgeBrowserBundleResult>;
|
|
31
|
+
export {};
|