@wendoo/bridge-app 0.2.2
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 +44 -0
- package/dist/app-bridge.d.ts +77 -0
- package/dist/app-bridge.d.ts.map +1 -0
- package/dist/app-bridge.js +205 -0
- package/dist/app-environment-host.d.ts +524 -0
- package/dist/app-environment-host.d.ts.map +1 -0
- package/dist/app-environment-host.js +1560 -0
- package/dist/brain-diagnostics.d.ts +47 -0
- package/dist/brain-diagnostics.d.ts.map +1 -0
- package/dist/brain-diagnostics.js +100 -0
- package/dist/bridge-project.d.ts +32 -0
- package/dist/bridge-project.d.ts.map +1 -0
- package/dist/bridge-project.js +69 -0
- package/dist/compilation.d.ts +145 -0
- package/dist/compilation.d.ts.map +1 -0
- package/dist/compilation.js +404 -0
- package/dist/core-extension.d.ts +10 -0
- package/dist/core-extension.d.ts.map +1 -0
- package/dist/core-extension.js +9 -0
- package/dist/embedded-extension-id-gate.d.ts +38 -0
- package/dist/embedded-extension-id-gate.d.ts.map +1 -0
- package/dist/embedded-extension-id-gate.js +55 -0
- package/dist/embedded-extension-loader.d.ts +33 -0
- package/dist/embedded-extension-loader.d.ts.map +1 -0
- package/dist/embedded-extension-loader.js +90 -0
- package/dist/embedded-extension-vite-plugin.d.ts +34 -0
- package/dist/embedded-extension-vite-plugin.d.ts.map +1 -0
- package/dist/embedded-extension-vite-plugin.js +39 -0
- package/dist/embedded-extensions.d.ts +293 -0
- package/dist/embedded-extensions.d.ts.map +1 -0
- package/dist/embedded-extensions.js +526 -0
- package/dist/extension-catalog.d.ts +243 -0
- package/dist/extension-catalog.d.ts.map +1 -0
- package/dist/extension-catalog.js +408 -0
- package/dist/extension-install-log.d.ts +54 -0
- package/dist/extension-install-log.d.ts.map +1 -0
- package/dist/extension-install-log.js +22 -0
- package/dist/extension-install.d.ts +162 -0
- package/dist/extension-install.d.ts.map +1 -0
- package/dist/extension-install.js +412 -0
- package/dist/extension-report-presenter.d.ts +40 -0
- package/dist/extension-report-presenter.d.ts.map +1 -0
- package/dist/extension-report-presenter.js +36 -0
- package/dist/fetched-extension-snapshots.d.ts +66 -0
- package/dist/fetched-extension-snapshots.d.ts.map +1 -0
- package/dist/fetched-extension-snapshots.js +137 -0
- package/dist/folder-host-session.d.ts +85 -0
- package/dist/folder-host-session.d.ts.map +1 -0
- package/dist/folder-host-session.js +210 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/library-offer.d.ts +60 -0
- package/dist/library-offer.d.ts.map +1 -0
- package/dist/library-offer.js +47 -0
- package/dist/library-uninstall-guard.d.ts +66 -0
- package/dist/library-uninstall-guard.d.ts.map +1 -0
- package/dist/library-uninstall-guard.js +103 -0
- package/dist/manifest-files.d.ts +53 -0
- package/dist/manifest-files.d.ts.map +1 -0
- package/dist/manifest-files.js +242 -0
- package/dist/node.d.ts +4 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +2 -0
- package/dist/project-file-bridge.d.ts +10 -0
- package/dist/project-file-bridge.d.ts.map +1 -0
- package/dist/project-file-bridge.js +87 -0
- package/dist/user-tile-registration.d.ts +89 -0
- package/dist/user-tile-registration.d.ts.map +1 -0
- package/dist/user-tile-registration.js +100 -0
- package/dist/vfs-asset-url-provider.d.ts +22 -0
- package/dist/vfs-asset-url-provider.d.ts.map +1 -0
- package/dist/vfs-asset-url-provider.js +52 -0
- package/dist/workspace-folder-project-store.d.ts +125 -0
- package/dist/workspace-folder-project-store.d.ts.map +1 -0
- package/dist/workspace-folder-project-store.js +400 -0
- package/package.json +103 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { IBrainDef } from "@wendoo/core/app";
|
|
2
|
+
import type { ActionKey } from "@wendoo/core/runtime";
|
|
3
|
+
import type { TileCompileDiagnostics } from "./user-tile-registration.js";
|
|
4
|
+
/**
|
|
5
|
+
* One brain diagnostic as the compiler emitted it: the stable code, the rule
|
|
6
|
+
* location within the brain, and the compiler's message text verbatim.
|
|
7
|
+
* Rendered on console-style surfaces only, where machine forms are the
|
|
8
|
+
* expected content.
|
|
9
|
+
*/
|
|
10
|
+
export interface BrainDiagnosticEntry {
|
|
11
|
+
/** Stable diagnostic code of the underlying parse or type diagnostic. */
|
|
12
|
+
readonly code: number;
|
|
13
|
+
/** Rule location within the brain: the page name followed by the rule chain. */
|
|
14
|
+
readonly location: string;
|
|
15
|
+
/** The compiler's diagnostic message, verbatim. */
|
|
16
|
+
readonly message: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Collect a brain's error diagnostics from the typecheck results stored on its
|
|
20
|
+
* rules, verbatim. Reads stored state only; the brain is not re-typechecked.
|
|
21
|
+
* A rule that has never been typechecked contributes nothing, and
|
|
22
|
+
* informational type-conversion diagnostics are excluded.
|
|
23
|
+
*
|
|
24
|
+
* @param brain - The brain to read.
|
|
25
|
+
*/
|
|
26
|
+
export declare function collectBrainErrorDiagnostics(brain: IBrainDef): readonly BrainDiagnosticEntry[];
|
|
27
|
+
/**
|
|
28
|
+
* Look up a user tile's compile diagnostics and defining source path by the
|
|
29
|
+
* tile's {@link ActionKey}. Returns `undefined` when the tile compiled cleanly
|
|
30
|
+
* or is absent from the latest compile. Supplied by the host, which holds the
|
|
31
|
+
* latest workspace compile.
|
|
32
|
+
*/
|
|
33
|
+
export type TileCompileDiagnosticsLookup = (key: ActionKey) => TileCompileDiagnostics | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Collect compile diagnostics for the broken user tiles a brain uses, verbatim.
|
|
36
|
+
* Traverses every rule's WHEN and DO tiles (recursing into child rules), and for
|
|
37
|
+
* each DISTINCT action tile key resolves the tile's compile diagnostics through
|
|
38
|
+
* `lookup`. A tile used in several rules contributes its diagnostics once. Each
|
|
39
|
+
* emitted entry carries the compiler's `code` and `message` unchanged and a
|
|
40
|
+
* `location` composed from the tile's source path and the diagnostic's
|
|
41
|
+
* `line`/`column`. A brain whose tiles all compiled cleanly yields an empty list.
|
|
42
|
+
*
|
|
43
|
+
* @param brain - The brain to traverse.
|
|
44
|
+
* @param lookup - Resolves a tile key to its compile diagnostics and source path.
|
|
45
|
+
*/
|
|
46
|
+
export declare function collectBrainTileCompileDiagnostics(brain: IBrainDef, lookup: TileCompileDiagnosticsLookup): readonly BrainDiagnosticEntry[];
|
|
47
|
+
//# sourceMappingURL=brain-diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-diagnostics.d.ts","sourceRoot":"","sources":["../src/brain-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AA0BD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,oBAAoB,EAAE,CAQ9F;AAED;;;;;GAKG;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,GAAG,EAAE,SAAS,KAAK,sBAAsB,GAAG,SAAS,CAAC;AA2BlG;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,4BAA4B,GACnC,SAAS,oBAAoB,EAAE,CAuBjC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { TypeDiagCode } from "@wendoo/core/brain/compiler";
|
|
2
|
+
import { BrainRuleDef } from "@wendoo/core/brain/model";
|
|
3
|
+
function collectRuleDiagnostics(rule, out) {
|
|
4
|
+
if (rule instanceof BrainRuleDef) {
|
|
5
|
+
const result = rule.when().typecheckResult();
|
|
6
|
+
if (result) {
|
|
7
|
+
const location = rule.getLocationPath();
|
|
8
|
+
result.whenParseResult.diags.forEach((diag) => {
|
|
9
|
+
out.push({ code: diag.code, location, message: diag.message });
|
|
10
|
+
});
|
|
11
|
+
result.doParseResult.diags.forEach((diag) => {
|
|
12
|
+
out.push({ code: diag.code, location, message: diag.message });
|
|
13
|
+
});
|
|
14
|
+
result.typeInfo.diags.forEach((diag) => {
|
|
15
|
+
if (diag.code === TypeDiagCode.DataTypeConverted) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
out.push({ code: diag.code, location, message: diag.message });
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
rule.children().forEach((child) => {
|
|
23
|
+
collectRuleDiagnostics(child, out);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Collect a brain's error diagnostics from the typecheck results stored on its
|
|
28
|
+
* rules, verbatim. Reads stored state only; the brain is not re-typechecked.
|
|
29
|
+
* A rule that has never been typechecked contributes nothing, and
|
|
30
|
+
* informational type-conversion diagnostics are excluded.
|
|
31
|
+
*
|
|
32
|
+
* @param brain - The brain to read.
|
|
33
|
+
*/
|
|
34
|
+
export function collectBrainErrorDiagnostics(brain) {
|
|
35
|
+
const out = [];
|
|
36
|
+
brain.pages().forEach((page) => {
|
|
37
|
+
page.children().forEach((rule) => {
|
|
38
|
+
collectRuleDiagnostics(rule, out);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
function composeTileLocation(path, diagnostic) {
|
|
44
|
+
if (diagnostic.line === undefined) {
|
|
45
|
+
return path;
|
|
46
|
+
}
|
|
47
|
+
if (diagnostic.column === undefined) {
|
|
48
|
+
return `${path}:${diagnostic.line}`;
|
|
49
|
+
}
|
|
50
|
+
return `${path}:${diagnostic.line}:${diagnostic.column}`;
|
|
51
|
+
}
|
|
52
|
+
function collectRuleTileKeys(rule, keys) {
|
|
53
|
+
const collectSide = (side) => {
|
|
54
|
+
side.tiles().forEach((tile) => {
|
|
55
|
+
if ("action" in tile) {
|
|
56
|
+
keys.add(tile.action.key);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
collectSide(rule.when());
|
|
61
|
+
collectSide(rule.do());
|
|
62
|
+
rule.children().forEach((child) => {
|
|
63
|
+
collectRuleTileKeys(child, keys);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Collect compile diagnostics for the broken user tiles a brain uses, verbatim.
|
|
68
|
+
* Traverses every rule's WHEN and DO tiles (recursing into child rules), and for
|
|
69
|
+
* each DISTINCT action tile key resolves the tile's compile diagnostics through
|
|
70
|
+
* `lookup`. A tile used in several rules contributes its diagnostics once. Each
|
|
71
|
+
* emitted entry carries the compiler's `code` and `message` unchanged and a
|
|
72
|
+
* `location` composed from the tile's source path and the diagnostic's
|
|
73
|
+
* `line`/`column`. A brain whose tiles all compiled cleanly yields an empty list.
|
|
74
|
+
*
|
|
75
|
+
* @param brain - The brain to traverse.
|
|
76
|
+
* @param lookup - Resolves a tile key to its compile diagnostics and source path.
|
|
77
|
+
*/
|
|
78
|
+
export function collectBrainTileCompileDiagnostics(brain, lookup) {
|
|
79
|
+
const keys = new Set();
|
|
80
|
+
brain.pages().forEach((page) => {
|
|
81
|
+
page.children().forEach((rule) => {
|
|
82
|
+
collectRuleTileKeys(rule, keys);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
const out = [];
|
|
86
|
+
keys.forEach((key) => {
|
|
87
|
+
const tileDiagnostics = lookup(key);
|
|
88
|
+
if (!tileDiagnostics) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
tileDiagnostics.diagnostics.forEach((diagnostic) => {
|
|
92
|
+
out.push({
|
|
93
|
+
code: diagnostic.code,
|
|
94
|
+
location: composeTileLocation(tileDiagnostics.path, diagnostic),
|
|
95
|
+
message: diagnostic.message,
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FileSystemSnapshot } from "@wendoo/bridge-client";
|
|
2
|
+
import { Project } from "@wendoo/bridge-client";
|
|
3
|
+
import type { AppClientMessage, AppServerMessage, FileSystemNotification } from "@wendoo/bridge-protocol";
|
|
4
|
+
import { CompilationManager, type CompilationProvider } from "./compilation.js";
|
|
5
|
+
/** Options for {@link BridgeProject}. */
|
|
6
|
+
export interface BridgeProjectOptions {
|
|
7
|
+
bridgeUrl: string;
|
|
8
|
+
initialFileSnapshot: FileSystemSnapshot;
|
|
9
|
+
/** Token used to rebind to a previously established session. */
|
|
10
|
+
bindingToken?: string;
|
|
11
|
+
/** Optional provider that compiles project files and emits diagnostics over the bridge. */
|
|
12
|
+
compilationProvider?: CompilationProvider;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* App-side bridge {@link Project} that exposes the join code and an optional
|
|
16
|
+
* compilation manager.
|
|
17
|
+
*/
|
|
18
|
+
export declare class BridgeProject extends Project<AppClientMessage, AppServerMessage> {
|
|
19
|
+
private _joinCode;
|
|
20
|
+
private readonly _joinCodeListeners;
|
|
21
|
+
private readonly _sessionUnsubs;
|
|
22
|
+
private readonly _compilation;
|
|
23
|
+
private readonly _remoteFileChangeListeners;
|
|
24
|
+
constructor(options: BridgeProjectOptions);
|
|
25
|
+
get compilation(): CompilationManager | undefined;
|
|
26
|
+
get joinCode(): string | undefined;
|
|
27
|
+
onJoinCodeChange(fn: (joinCode: string | undefined) => void): () => void;
|
|
28
|
+
onRemoteFileChange(fn: (ev: FileSystemNotification) => void): () => void;
|
|
29
|
+
private wireJoinCode;
|
|
30
|
+
private setJoinCode;
|
|
31
|
+
}
|
|
32
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GAAG,MAAM,IAAI;IAOxE,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Project } from "@wendoo/bridge-client";
|
|
2
|
+
import { CompilationManager } from "./compilation.js";
|
|
3
|
+
/**
|
|
4
|
+
* App-side bridge {@link Project} that exposes the join code and an optional
|
|
5
|
+
* compilation manager.
|
|
6
|
+
*/
|
|
7
|
+
export class BridgeProject extends Project {
|
|
8
|
+
_joinCode;
|
|
9
|
+
_joinCodeListeners = new Set();
|
|
10
|
+
_sessionUnsubs = [];
|
|
11
|
+
_compilation;
|
|
12
|
+
_remoteFileChangeListeners = new Set();
|
|
13
|
+
constructor(options) {
|
|
14
|
+
const projectOptions = {
|
|
15
|
+
...options,
|
|
16
|
+
wsPath: "app",
|
|
17
|
+
};
|
|
18
|
+
super(projectOptions);
|
|
19
|
+
this.wireJoinCode();
|
|
20
|
+
if (options.compilationProvider) {
|
|
21
|
+
this._compilation = new CompilationManager(options.compilationProvider, (msg) => this.session.send(msg), () => this.session.status === "connected");
|
|
22
|
+
this._sessionUnsubs.push(this.onDidSync(() => {
|
|
23
|
+
this._compilation?.sendDiagnostics();
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
this.fromRemoteFileChange = (ev) => {
|
|
27
|
+
if (this._compilation) {
|
|
28
|
+
this._compilation.handleFileChange(ev);
|
|
29
|
+
}
|
|
30
|
+
for (const fn of this._remoteFileChangeListeners) {
|
|
31
|
+
fn(ev);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
get compilation() {
|
|
36
|
+
return this._compilation;
|
|
37
|
+
}
|
|
38
|
+
get joinCode() {
|
|
39
|
+
return this._joinCode;
|
|
40
|
+
}
|
|
41
|
+
onJoinCodeChange(fn) {
|
|
42
|
+
this._joinCodeListeners.add(fn);
|
|
43
|
+
return () => {
|
|
44
|
+
this._joinCodeListeners.delete(fn);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
onRemoteFileChange(fn) {
|
|
48
|
+
this._remoteFileChangeListeners.add(fn);
|
|
49
|
+
return () => {
|
|
50
|
+
this._remoteFileChangeListeners.delete(fn);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
wireJoinCode() {
|
|
54
|
+
this._sessionUnsubs.push(this.session.on("session:welcome", (msg) => {
|
|
55
|
+
this.setJoinCode(msg.payload.joinCode);
|
|
56
|
+
}));
|
|
57
|
+
this._sessionUnsubs.push(this.session.on("session:joinCode", (msg) => {
|
|
58
|
+
this.setJoinCode(msg.payload.joinCode);
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
setJoinCode(joinCode) {
|
|
62
|
+
if (this._joinCode === joinCode)
|
|
63
|
+
return;
|
|
64
|
+
this._joinCode = joinCode;
|
|
65
|
+
for (const fn of this._joinCodeListeners) {
|
|
66
|
+
fn(joinCode);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { FileContent } from "@wendoo/app-host";
|
|
2
|
+
import type { AppClientMessage, CompileDiagnosticEntry, FileSystemNotification } from "@wendoo/bridge-protocol";
|
|
3
|
+
import type { WendooEnvironment } from "@wendoo/core";
|
|
4
|
+
import { type DependencyMount, type Mount, type ProjectDependency, type WorkspaceCompiler as TsWorkspaceCompiler, type WorkspaceCompileResult } from "@wendoo/ts-compiler";
|
|
5
|
+
import type { AppBridge, AppBridgeFeature, DiagnosticEntry, ProjectFileChange, ProjectFileSnapshot, ProjectFileSystem } from "./app-bridge.js";
|
|
6
|
+
/** Latest compile diagnostics, keyed by file path. */
|
|
7
|
+
export interface DiagnosticSnapshot {
|
|
8
|
+
files: ReadonlyMap<string, readonly DiagnosticEntry[]>;
|
|
9
|
+
}
|
|
10
|
+
/** Project file compiler that the {@link createCompilationFeature} drives. */
|
|
11
|
+
export interface ProjectFileCompiler {
|
|
12
|
+
replaceProjectFiles(snapshot: ProjectFileSnapshot): void;
|
|
13
|
+
applyProjectFileChange(change: ProjectFileChange): void;
|
|
14
|
+
/** Run a compile pass and return the resulting diagnostics. */
|
|
15
|
+
compile(): DiagnosticSnapshot;
|
|
16
|
+
/** Subscribe to compile completions. Returns an unsubscribe function. */
|
|
17
|
+
onDidCompile(listener: (snapshot: DiagnosticSnapshot) => void): () => void;
|
|
18
|
+
}
|
|
19
|
+
/** Options for {@link createCompilationFeature}. */
|
|
20
|
+
export interface CompilationFeatureOptions {
|
|
21
|
+
compiler: ProjectFileCompiler;
|
|
22
|
+
/** When `true` (the default), per-file pass/fail status is published alongside diagnostics. */
|
|
23
|
+
publishStatus?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Result of a compile pass driven by {@link CompilationManager}. */
|
|
26
|
+
export interface CompilationResult {
|
|
27
|
+
files: Map<string, CompileDiagnosticEntry[]>;
|
|
28
|
+
}
|
|
29
|
+
/** Lower-level compile interface used by {@link CompilationManager}. */
|
|
30
|
+
export interface CompilationProvider {
|
|
31
|
+
fileWritten(path: string, content: string): void;
|
|
32
|
+
fileDeleted(path: string): void;
|
|
33
|
+
fileRenamed(oldPath: string, newPath: string): void;
|
|
34
|
+
/** Replace the provider's view of the project files with `files`. */
|
|
35
|
+
fullSync(files: Iterable<[string, {
|
|
36
|
+
kind: string;
|
|
37
|
+
content?: string;
|
|
38
|
+
}]>): void;
|
|
39
|
+
/** Compile every known file and return per-file diagnostics. */
|
|
40
|
+
compileAll(): CompilationResult;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build an {@link AppBridgeFeature} that compiles project files on remote
|
|
44
|
+
* changes and publishes diagnostics (and, by default, per-file status) to the
|
|
45
|
+
* peer.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createCompilationFeature(options: CompilationFeatureOptions): AppBridgeFeature;
|
|
48
|
+
/**
|
|
49
|
+
* Drives a {@link CompilationProvider} from incoming filesystem notifications
|
|
50
|
+
* and emits diagnostics to the peer. Sends version-tagged `compile:diagnostics`
|
|
51
|
+
* and `compile:status` messages when connected.
|
|
52
|
+
*/
|
|
53
|
+
export declare class CompilationManager {
|
|
54
|
+
private readonly _provider;
|
|
55
|
+
private readonly _send;
|
|
56
|
+
private readonly _isConnected;
|
|
57
|
+
private readonly _versions;
|
|
58
|
+
private readonly _previousFiles;
|
|
59
|
+
private readonly _compilationListeners;
|
|
60
|
+
private _lastResult;
|
|
61
|
+
private readonly _removalListeners;
|
|
62
|
+
constructor(provider: CompilationProvider, send: (msg: AppClientMessage) => void, isConnected: () => boolean);
|
|
63
|
+
handleFileChange(ev: FileSystemNotification): void;
|
|
64
|
+
onCompilation(fn: (result: CompilationResult) => void): () => void;
|
|
65
|
+
onRemoval(fn: (path: string) => void): () => void;
|
|
66
|
+
sendDiagnostics(): void;
|
|
67
|
+
private compileAndEmit;
|
|
68
|
+
private emitDiagnostics;
|
|
69
|
+
}
|
|
70
|
+
export type { WorkspaceCompileResult } from "@wendoo/ts-compiler";
|
|
71
|
+
/** Options for {@link createProjectCompiler}. */
|
|
72
|
+
export interface CreateProjectCompilerOptions {
|
|
73
|
+
environment: WendooEnvironment;
|
|
74
|
+
filesystem: ProjectFileSystem;
|
|
75
|
+
/** Namespace of the project being compiled (its store id); prefixes every symbol key minted from the project's content. */
|
|
76
|
+
projectNamespace: string;
|
|
77
|
+
/** Read-only content mounts exposed to the compiler and remote VFS peers. */
|
|
78
|
+
mounts: readonly Mount[];
|
|
79
|
+
/** Extension dependencies of the project, each a `<owner>/<repo>` coordinate resolving its `@lib/<owner>/<repo>` imports. */
|
|
80
|
+
dependencies?: readonly ProjectDependency[];
|
|
81
|
+
/** Read-only content of each dependency, mounted for `@lib/<owner>/<repo>` resolution. */
|
|
82
|
+
dependencyMounts?: readonly DependencyMount[];
|
|
83
|
+
onDidCompile?: (result: WorkspaceCompileResult) => void;
|
|
84
|
+
}
|
|
85
|
+
/** Handle returned by {@link createProjectCompiler}. */
|
|
86
|
+
export interface ProjectCompilerHandle {
|
|
87
|
+
readonly compiler: TsWorkspaceCompiler;
|
|
88
|
+
/** Seed the compiler from the current project file snapshot and run an initial compile. */
|
|
89
|
+
initialize(): void;
|
|
90
|
+
/** Re-seed the compiler with the latest project file snapshot and recompile. */
|
|
91
|
+
replaceProjectFiles(): void;
|
|
92
|
+
}
|
|
93
|
+
/** Wrap a {@link ProjectFileSystem} as a TS workspace compiler over the live project files. */
|
|
94
|
+
export declare function createProjectCompiler(options: CreateProjectCompilerOptions): ProjectCompilerHandle;
|
|
95
|
+
/** Options for {@link createBridgeProject}. */
|
|
96
|
+
export interface CreateBridgeProjectOptions {
|
|
97
|
+
projectCompiler: ProjectCompilerHandle;
|
|
98
|
+
/**
|
|
99
|
+
* The served file system whose snapshot already carries the raw project
|
|
100
|
+
* files plus the compiler-controlled files (produced by
|
|
101
|
+
* {@link augmentProjectFileSystem}). The bridge exposes this to the remote
|
|
102
|
+
* peer, so the peer and any local asset server read identical content.
|
|
103
|
+
*/
|
|
104
|
+
servedFileSystem: ProjectFileSystem;
|
|
105
|
+
bridgeUrl: string;
|
|
106
|
+
bindingToken?: string;
|
|
107
|
+
onBindingTokenChange?: (token: string) => void;
|
|
108
|
+
}
|
|
109
|
+
/** Handle returned by {@link createBridgeProject}. */
|
|
110
|
+
export interface BridgeProjectHandle {
|
|
111
|
+
readonly bridge: AppBridge;
|
|
112
|
+
/** Tear down the current bridge and create a new one pointing at `bridgeUrl`. */
|
|
113
|
+
recreateBridge(bridgeUrl: string): void;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Wire up an {@link AppBridge} that uses `projectCompiler` for diagnostics and
|
|
117
|
+
* surfaces compiler-controlled files to the remote peer.
|
|
118
|
+
*/
|
|
119
|
+
export declare function createBridgeProject(options: CreateBridgeProjectOptions): BridgeProjectHandle;
|
|
120
|
+
/** Options for {@link augmentProjectFileSystem}. */
|
|
121
|
+
export interface AugmentProjectFileSystemOptions {
|
|
122
|
+
/**
|
|
123
|
+
* Invoked with the full compiler-controlled file set whenever a compile
|
|
124
|
+
* changes that set.
|
|
125
|
+
*/
|
|
126
|
+
onCompilerControlledFilesChanged?: (files: ReadonlyMap<string, FileContent>) => void;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Wrap a {@link ProjectFileSystem} so its exported snapshot also carries the
|
|
130
|
+
* compiler-controlled files (ambient declarations, `tsconfig.json`, and the
|
|
131
|
+
* read-only installed-extensions tree), all marked read-only. Local and remote
|
|
132
|
+
* changes targeting those augmented paths are filtered out, leaving them
|
|
133
|
+
* read-only from the peer's side.
|
|
134
|
+
*
|
|
135
|
+
* When a compile changes the compiler-controlled file set (installing or
|
|
136
|
+
* uninstalling an extension adds or removes its `.libraries/` subtree), the
|
|
137
|
+
* wrapper emits one full-snapshot `import` local change and invokes the
|
|
138
|
+
* options' change callback with the new set. The peer reconciles the whole
|
|
139
|
+
* tree from the import: newly installed paths appear and uninstalled paths
|
|
140
|
+
* are pruned. The read-only compiler-controlled paths cannot be updated by an
|
|
141
|
+
* incremental write/delete notification, so the full-snapshot import is their
|
|
142
|
+
* propagation channel.
|
|
143
|
+
*/
|
|
144
|
+
export declare function augmentProjectFileSystem(filesystem: ProjectFileSystem, compiler: TsWorkspaceCompiler, options?: AugmentProjectFileSystemOptions): ProjectFileSystem;
|
|
145
|
+
//# sourceMappingURL=compilation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compilation.d.ts","sourceRoot":"","sources":["../src/compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAChH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,KAAK,EACV,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,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