@dxos/app-framework 0.14.0 → 0.16.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/CHANGELOG.md +73 -0
- package/dist/lib/App.mjs +1 -2
- package/dist/lib/Hooks.mjs +1 -2
- package/dist/lib/chunk-App.mjs +11 -0
- package/dist/lib/chunk-App.mjs.map +1 -0
- package/dist/lib/chunk-Cli.mjs +8 -0
- package/dist/lib/chunk-Cli.mjs.map +1 -0
- package/dist/lib/chunk-Devtools.mjs +112 -0
- package/dist/lib/chunk-Devtools.mjs.map +1 -0
- package/dist/lib/chunk-Hooks2.mjs +35 -0
- package/dist/lib/chunk-Hooks2.mjs.map +1 -0
- package/dist/lib/chunk-PluginManagerProvider.mjs +12 -0
- package/dist/lib/chunk-PluginManagerProvider.mjs.map +1 -0
- package/dist/lib/chunk-ProcessManagerPlugin.mjs +3 -3
- package/dist/lib/chunk-ProcessManagerPlugin.mjs.map +1 -1
- package/dist/lib/chunk-Role.mjs +19 -0
- package/dist/lib/chunk-Role.mjs.map +1 -0
- package/dist/lib/chunk-SharedPackages.mjs +11 -0
- package/dist/lib/chunk-SharedPackages.mjs.map +1 -0
- package/dist/lib/chunk-Surface.mjs.map +1 -1
- package/dist/lib/chunk-Surface2.mjs +37 -0
- package/dist/lib/chunk-Surface2.mjs.map +1 -0
- package/dist/lib/chunk-SurfaceManager.mjs +3 -3
- package/dist/lib/chunk-SurfaceManager.mjs.map +1 -1
- package/dist/lib/chunk-activation-event.mjs +86 -0
- package/dist/lib/chunk-activation-event.mjs.map +1 -0
- package/dist/lib/chunk-activation-events.mjs +66 -0
- package/dist/lib/chunk-activation-events.mjs.map +1 -0
- package/dist/lib/chunk-capabilities.mjs +202 -0
- package/dist/lib/chunk-capabilities.mjs.map +1 -0
- package/dist/lib/chunk-capability-manager.mjs +203 -0
- package/dist/lib/chunk-capability-manager.mjs.map +1 -0
- package/dist/lib/chunk-capability2.mjs +2 -2
- package/dist/lib/chunk-capability2.mjs.map +1 -1
- package/dist/lib/chunk-history-tracker.mjs +1 -1
- package/dist/lib/chunk-hooks.mjs +5 -5
- package/dist/lib/chunk-hooks.mjs.map +1 -1
- package/dist/lib/chunk-plugin-asset-cache.mjs +28 -0
- package/dist/lib/chunk-plugin-asset-cache.mjs.map +1 -0
- package/dist/lib/chunk-plugin-manager.mjs +68 -35
- package/dist/lib/chunk-plugin-manager.mjs.map +1 -1
- package/dist/lib/chunk-plugin-manager2.mjs +22 -0
- package/dist/lib/chunk-plugin-manager2.mjs.map +1 -0
- package/dist/lib/chunk-plugin-manifest.mjs +126 -0
- package/dist/lib/chunk-plugin-manifest.mjs.map +1 -0
- package/dist/lib/chunk-plugin.mjs +354 -0
- package/dist/lib/chunk-plugin.mjs.map +1 -0
- package/dist/lib/chunk-process-manager-capability.mjs +11 -10
- package/dist/lib/chunk-process-manager-capability.mjs.map +1 -1
- package/dist/lib/chunk-registry.mjs.map +1 -1
- package/dist/lib/chunk-undo-mapping.mjs +47 -0
- package/dist/lib/{plugin-process-manager/history/undo-mapping.mjs.map → chunk-undo-mapping.mjs.map} +1 -1
- package/dist/lib/chunk-undo-registry.mjs +22 -0
- package/dist/lib/{plugin-process-manager/history/undo-registry.mjs.map → chunk-undo-registry.mjs.map} +1 -1
- package/dist/lib/chunk-url-loader.mjs +345 -0
- package/dist/lib/chunk-url-loader.mjs.map +1 -0
- package/dist/lib/cli.mjs +3 -3
- package/dist/lib/cli.mjs.map +1 -1
- package/dist/lib/common/Role.mjs +1 -19
- package/dist/lib/common/activation-events.mjs +1 -57
- package/dist/lib/common/capabilities.mjs +1 -202
- package/dist/lib/config.mjs +1 -2
- package/dist/lib/core/activation-event.mjs +1 -86
- package/dist/lib/core/capability-manager.mjs +1 -203
- package/dist/lib/core/capability.mjs +1 -2
- package/dist/lib/core/plugin-asset-cache.mjs +1 -28
- package/dist/lib/core/plugin-manager.mjs +2 -19
- package/dist/lib/core/plugin-manifest.mjs +1 -126
- package/dist/lib/core/plugin.mjs +1 -354
- package/dist/lib/core/registry.mjs +1 -2
- package/dist/lib/core/url-loader.mjs +1 -345
- package/dist/lib/index.mjs +19 -19
- package/dist/lib/ns/App.mjs +2 -11
- package/dist/lib/ns/Cli.mjs +2 -8
- package/dist/lib/ns/Devtools.mjs +1 -112
- package/dist/lib/ns/Hooks.mjs +2 -35
- package/dist/lib/ns/PluginManagerProvider.mjs +2 -12
- package/dist/lib/ns/SharedPackages.mjs +2 -11
- package/dist/lib/ns/Surface.mjs +2 -35
- package/dist/lib/ns/Translations.mjs +1 -2
- package/dist/lib/plugin-cli.mjs +2 -4
- package/dist/lib/plugin-cli.mjs.map +1 -1
- package/dist/lib/plugin-process-manager/ProcessManagerPlugin.mjs +1 -2
- package/dist/lib/plugin-process-manager/history/history-tracker.mjs +1 -2
- package/dist/lib/plugin-process-manager/history/undo-mapping.mjs +1 -47
- package/dist/lib/plugin-process-manager/history/undo-registry.mjs +1 -22
- package/dist/lib/testing/react.mjs +1 -1
- package/dist/lib/testing/react.mjs.map +1 -1
- package/dist/lib/testing.mjs +5 -5
- package/dist/lib/testing.mjs.map +1 -1
- package/dist/lib/vite-plugin.mjs +3 -3
- package/dist/lib/vite-plugin.mjs.map +1 -1
- package/dist/types/src/common/activation-events.d.ts +8 -0
- package/dist/types/src/common/activation-events.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager/manager-state.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager/module-loader.d.ts +0 -10
- package/dist/types/src/core/plugin-manager/module-loader.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager/plugin-manager.d.ts.map +1 -1
- package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -32
- package/src/common/activation-events.ts +9 -0
- package/src/core/plugin-manager/manager-state.ts +14 -12
- package/src/core/plugin-manager/module-loader.ts +43 -7
- package/src/core/plugin-manager/plugin-manager.ts +2 -1
- package/src/plugin-process-manager/process-manager-capability.test.ts +66 -1
- package/src/plugin-process-manager/process-manager-capability.ts +22 -2
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +9 -7
- package/src/ui/hooks/useApp.tsx +2 -1
- package/src/vite-plugin/boot-loader/loader-app/boot-loader.css +19 -1
- package/dist/lib/common/Role.mjs.map +0 -1
- package/dist/lib/common/activation-events.mjs.map +0 -1
- package/dist/lib/common/capabilities.mjs.map +0 -1
- package/dist/lib/core/activation-event.mjs.map +0 -1
- package/dist/lib/core/capability-manager.mjs.map +0 -1
- package/dist/lib/core/plugin-asset-cache.mjs.map +0 -1
- package/dist/lib/core/plugin-manager.mjs.map +0 -1
- package/dist/lib/core/plugin-manifest.mjs.map +0 -1
- package/dist/lib/core/plugin.mjs.map +0 -1
- package/dist/lib/core/url-loader.mjs.map +0 -1
- package/dist/lib/ns/App.mjs.map +0 -1
- package/dist/lib/ns/Cli.mjs.map +0 -1
- package/dist/lib/ns/Devtools.mjs.map +0 -1
- package/dist/lib/ns/Hooks.mjs.map +0 -1
- package/dist/lib/ns/PluginManagerProvider.mjs.map +0 -1
- package/dist/lib/ns/SharedPackages.mjs.map +0 -1
- package/dist/lib/ns/Surface.mjs.map +0 -1
|
@@ -1,126 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import { BaseError } from "@dxos/errors";
|
|
4
|
-
import * as Schema from "effect/Schema";
|
|
5
|
-
import { PLUGIN_ENTRY_FILENAME, PluginManifestSchema } from "@dxos/protocols";
|
|
6
|
-
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
7
|
-
import * as HttpClient from "effect/http/HttpClient";
|
|
8
|
-
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
9
|
-
import * as HttpClientResponse from "effect/http/HttpClientResponse";
|
|
10
|
-
import * as Struct from "effect/Struct";
|
|
11
|
-
//#region src/core/plugin-manifest.ts
|
|
12
|
-
var plugin_manifest_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
-
DEV_SERVER_PORT: () => DEV_SERVER_PORT,
|
|
14
|
-
Manifest: () => Manifest,
|
|
15
|
-
PluginManifestError: () => PluginManifestError,
|
|
16
|
-
fetchManifest: () => fetchManifest,
|
|
17
|
-
parse: () => parse
|
|
18
|
-
});
|
|
19
|
-
/**
|
|
20
|
-
* Default port the Vite plugin (`composerPlugin`) binds the dev server to.
|
|
21
|
-
*
|
|
22
|
-
* Shared single source of truth — `composerPlugin` reads it as the default
|
|
23
|
-
* port, and the host's "Load Dev Plugin" affordance pre-fills the manifest URL
|
|
24
|
-
* with `http://localhost:${DEV_SERVER_PORT}/manifest.json`. Lives in
|
|
25
|
-
* app-framework rather than `@dxos/protocols` because the constant is a
|
|
26
|
-
* client-side convention (host loader + Vite plugin) rather than a wire-level
|
|
27
|
-
* protocol.
|
|
28
|
-
*/
|
|
29
|
-
var DEV_SERVER_PORT = 3967;
|
|
30
|
-
/**
|
|
31
|
-
* Tagged error for manifest fetch / parse failures. Construction sites set
|
|
32
|
-
* `context.manifestUrl` and `context.reason` (one of `'fetch-failed' |
|
|
33
|
-
* 'http-error' | 'parse-failed' | 'invalid'`) so handlers can route on the
|
|
34
|
-
* specific failure mode.
|
|
35
|
-
*/
|
|
36
|
-
var PluginManifestError = class extends BaseError.extend("PluginManifestError", "Plugin manifest is invalid") {};
|
|
37
|
-
/**
|
|
38
|
-
* Schema for a third-party plugin manifest.
|
|
39
|
-
*
|
|
40
|
-
* Production manifests are published as a sibling of the plugin's entry module
|
|
41
|
-
* ({@link PLUGIN_ENTRY_FILENAME}) and advertise every file the plugin needs at
|
|
42
|
-
* runtime so the host can eagerly cache them for offline use.
|
|
43
|
-
*
|
|
44
|
-
* Dev manifests (served by `vite dev` via {@link composerPlugin}) set `devEntry`
|
|
45
|
-
* to point at the unbundled source entry. The host's loader treats the presence
|
|
46
|
-
* of `devEntry` as the dev-mode signal: it imports the entry directly from the
|
|
47
|
-
* dev server, skips eager asset caching, and skips static stylesheet injection
|
|
48
|
-
* (Vite handles CSS via runtime `<style>` injection during HMR). `assets` is not
|
|
49
|
-
* required to enumerate every file in dev mode — chunks and styles flow through
|
|
50
|
-
* the dev server on demand.
|
|
51
|
-
*/
|
|
52
|
-
var Manifest = Schema.Struct({
|
|
53
|
-
...PluginManifestSchema.mapFields((fields) => Struct.omit(fields, ["assets"])).fields,
|
|
54
|
-
/**
|
|
55
|
-
* Relative asset paths. Relaxed vs the build `PluginManifestSchema` (which requires >= 1) because
|
|
56
|
-
* dev-server manifests list no assets — chunks/styles flow through the dev server on demand.
|
|
57
|
-
*/
|
|
58
|
-
assets: Schema.Array(Schema.String),
|
|
59
|
-
/** Present only for dev-server manifests; points at the unbundled source entry. */
|
|
60
|
-
devEntry: Schema.optional(Schema.String)
|
|
61
|
-
});
|
|
62
|
-
/**
|
|
63
|
-
* Resolves a parsed manifest's relative asset paths against the manifest's URL.
|
|
64
|
-
* In dev mode the entry comes from `devEntry`; otherwise it's the canonical
|
|
65
|
-
* {@link PLUGIN_ENTRY_FILENAME} sitting next to the manifest.
|
|
66
|
-
*/
|
|
67
|
-
var resolve = (manifestUrl, manifest) => {
|
|
68
|
-
const dev = manifest.devEntry !== void 0;
|
|
69
|
-
return {
|
|
70
|
-
key: manifest.key,
|
|
71
|
-
name: manifest.name,
|
|
72
|
-
version: manifest.version,
|
|
73
|
-
entryUrl: new URL(dev ? manifest.devEntry : PLUGIN_ENTRY_FILENAME, manifestUrl).toString(),
|
|
74
|
-
assetUrls: manifest.assets.map((asset) => new URL(asset, manifestUrl).toString()),
|
|
75
|
-
dev,
|
|
76
|
-
...manifest.dependencies !== void 0 ? { dependencies: manifest.dependencies } : {}
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Synchronous decode + validate + resolve for an in-memory manifest payload. Used
|
|
81
|
-
* by tests and tooling that have the manifest body already loaded; the runtime
|
|
82
|
-
* path goes through {@link fetchManifest}.
|
|
83
|
-
*/
|
|
84
|
-
var parse = (manifestUrl, payload) => {
|
|
85
|
-
const manifest = Schema.decodeUnknownSync(Manifest)(payload);
|
|
86
|
-
if (manifest.devEntry === void 0 && !manifest.assets.includes(PLUGIN_ENTRY_FILENAME)) throw new Error(`Manifest at ${manifestUrl} does not list ${PLUGIN_ENTRY_FILENAME} in assets.`);
|
|
87
|
-
return resolve(manifestUrl, manifest);
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Fetches and parses a manifest from the given URL via Effect's HTTP client and
|
|
91
|
-
* Schema-driven JSON decoding. All failure modes surface as a single tagged
|
|
92
|
-
* {@link PluginManifestError}; callers route on `error.context.reason`.
|
|
93
|
-
*/
|
|
94
|
-
var fetchManifest = (manifestUrl) => Effect.gen(function* () {
|
|
95
|
-
const response = yield* HttpClientRequest.get(manifestUrl).pipe(HttpClient.execute, Effect.mapError((cause) => new PluginManifestError({
|
|
96
|
-
context: {
|
|
97
|
-
manifestUrl,
|
|
98
|
-
reason: "fetch-failed"
|
|
99
|
-
},
|
|
100
|
-
cause
|
|
101
|
-
})));
|
|
102
|
-
if (response.status >= 400) return yield* Effect.fail(new PluginManifestError({ context: {
|
|
103
|
-
manifestUrl,
|
|
104
|
-
reason: "http-error",
|
|
105
|
-
status: response.status
|
|
106
|
-
} }));
|
|
107
|
-
const manifest = yield* HttpClientResponse.schemaBodyJson(Manifest)(response).pipe(Effect.mapError((cause) => new PluginManifestError({
|
|
108
|
-
context: {
|
|
109
|
-
manifestUrl,
|
|
110
|
-
reason: "parse-failed"
|
|
111
|
-
},
|
|
112
|
-
cause
|
|
113
|
-
})));
|
|
114
|
-
if (manifest.devEntry === void 0 && !manifest.assets.includes(PLUGIN_ENTRY_FILENAME)) return yield* Effect.fail(new PluginManifestError({
|
|
115
|
-
context: {
|
|
116
|
-
manifestUrl,
|
|
117
|
-
reason: "invalid"
|
|
118
|
-
},
|
|
119
|
-
cause: `assets does not include ${PLUGIN_ENTRY_FILENAME}`
|
|
120
|
-
}));
|
|
121
|
-
return resolve(manifestUrl, manifest);
|
|
122
|
-
}).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer));
|
|
123
|
-
//#endregion
|
|
124
|
-
export { DEV_SERVER_PORT, Manifest, PluginManifestError, fetchManifest, parse, plugin_manifest_exports as t };
|
|
125
|
-
|
|
126
|
-
//# sourceMappingURL=plugin-manifest.mjs.map
|
|
1
|
+
export { t as DEV_SERVER_PORT, n as Manifest, r as PluginManifestError, i as fetchManifest, a as parse } from "../chunk-plugin-manifest.mjs";
|
package/dist/lib/core/plugin.mjs
CHANGED
|
@@ -1,354 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Idle } from "./activation-event.mjs";
|
|
3
|
-
import { h as getModuleTag, i as ModuleTag } from "../chunk-capability.mjs";
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
|
-
import * as Option from "effect/Option";
|
|
6
|
-
import { DXN } from "@dxos/keys";
|
|
7
|
-
import * as Context from "effect/Context";
|
|
8
|
-
import { BaseError } from "@dxos/errors";
|
|
9
|
-
import * as Pipeable from "effect/Pipeable";
|
|
10
|
-
import * as Schema from "effect/Schema";
|
|
11
|
-
import { invariant } from "@dxos/invariant";
|
|
12
|
-
import { PluginProfileSchema, PluginReleaseSchema } from "@dxos/protocols";
|
|
13
|
-
//#region src/core/plugin.ts
|
|
14
|
-
var plugin_exports = /* @__PURE__ */ __exportAll({
|
|
15
|
-
LazyPluginError: () => LazyPluginError,
|
|
16
|
-
Meta: () => Meta,
|
|
17
|
-
PluginDependencyError: () => PluginDependencyError,
|
|
18
|
-
PluginModuleTypeId: () => PluginModuleTypeId,
|
|
19
|
-
PluginTypeId: () => PluginTypeId,
|
|
20
|
-
Profile: () => Profile,
|
|
21
|
-
Release: () => Release,
|
|
22
|
-
Service: () => Service,
|
|
23
|
-
activate: () => activate,
|
|
24
|
-
addModule: () => addModule,
|
|
25
|
-
define: () => define,
|
|
26
|
-
getMetaFromConfig: () => getMetaFromConfig,
|
|
27
|
-
getURI: () => getURI,
|
|
28
|
-
isLazy: () => isLazy,
|
|
29
|
-
isPlugin: () => isPlugin,
|
|
30
|
-
isPluginModule: () => isPluginModule,
|
|
31
|
-
lazy: () => lazy,
|
|
32
|
-
make: () => make,
|
|
33
|
-
makeMeta: () => makeMeta,
|
|
34
|
-
reset: () => reset,
|
|
35
|
-
resolveLazy: () => resolveLazy,
|
|
36
|
-
shutdown: () => shutdown
|
|
37
|
-
});
|
|
38
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/plugin.ts";
|
|
39
|
-
/**
|
|
40
|
-
* Effect Context.Tag for accessing PluginManager via the Effect layer system.
|
|
41
|
-
* This allows lifecycle operations to access the plugin manager without having it passed as an argument.
|
|
42
|
-
*/
|
|
43
|
-
var Service = class extends Context.Service()("@dxos/app-framework/PluginManager") {};
|
|
44
|
-
/**
|
|
45
|
-
* Activates plugins based on the activation event.
|
|
46
|
-
* Accesses the PluginManager via the Effect layer system.
|
|
47
|
-
* @param event The activation event.
|
|
48
|
-
* @returns Whether the activation was successful.
|
|
49
|
-
*/
|
|
50
|
-
var activate = (event) => Effect.flatMap(Service, (manager) => manager.activate(event));
|
|
51
|
-
/**
|
|
52
|
-
* Re-activates the modules that were activated by the event.
|
|
53
|
-
* Accesses the PluginManager via the Effect layer system.
|
|
54
|
-
* @param event The activation event.
|
|
55
|
-
* @returns Whether the reset was successful.
|
|
56
|
-
*/
|
|
57
|
-
var reset = (event) => Effect.flatMap(Service, (manager) => manager.reset(event));
|
|
58
|
-
/**
|
|
59
|
-
* Shuts down the plugin manager, deactivating all active modules and clearing lifecycle state.
|
|
60
|
-
* Accesses the PluginManager via the Effect layer system.
|
|
61
|
-
*/
|
|
62
|
-
var shutdown = () => Effect.flatMap(Service, (manager) => manager.shutdown());
|
|
63
|
-
/**
|
|
64
|
-
* Computes a module ID from plugin ID and export name.
|
|
65
|
-
*/
|
|
66
|
-
var computeModuleId = (pluginId, moduleName) => {
|
|
67
|
-
return `${pluginId}.module.${moduleName}`;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Identifier denoting a PluginModule.
|
|
71
|
-
*/
|
|
72
|
-
var PluginModuleTypeId = Symbol.for("@dxos/app-framework/PluginModule");
|
|
73
|
-
/**
|
|
74
|
-
* Type guard to check if a value is a PluginModule.
|
|
75
|
-
*/
|
|
76
|
-
var isPluginModule = (value) => {
|
|
77
|
-
return typeof value === "object" && value !== null && PluginModuleTypeId in value;
|
|
78
|
-
};
|
|
79
|
-
var PluginModuleImpl = class {
|
|
80
|
-
[PluginModuleTypeId] = PluginModuleTypeId;
|
|
81
|
-
id;
|
|
82
|
-
activation;
|
|
83
|
-
activate;
|
|
84
|
-
constructor(options) {
|
|
85
|
-
this.id = options.id;
|
|
86
|
-
this.activation = options.activation;
|
|
87
|
-
this.activate = options.activate;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Runtime plugin metadata, derived from the `@dxos/protocols` registry schemas (protocols owns the
|
|
92
|
-
* config + registry schemas; the runtime projection lives here).
|
|
93
|
-
*
|
|
94
|
-
* - {@link Profile}: version-independent identity + display + provenance — the wire `PluginProfileSchema`
|
|
95
|
-
* (which carries `key`, the display fields, `dependsOn`, `spec`) plus `author` (resolved at runtime
|
|
96
|
-
* from the publisher's handle/DID for registry plugins, or self-declared for bundled).
|
|
97
|
-
* - {@link Release}: a specific hosted release — the wire `PluginReleaseSchema` (version, moduleUrl, dependencies).
|
|
98
|
-
* - {@link Meta}: a resolved single-release view — `{ profile, release? }`, both nested. `release` is
|
|
99
|
-
* unset for bundled plugins (compiled in) and set for registry plugins.
|
|
100
|
-
*/
|
|
101
|
-
var Profile = Schema.Struct({
|
|
102
|
-
...PluginProfileSchema.fields,
|
|
103
|
-
author: Schema.optional(Schema.String)
|
|
104
|
-
});
|
|
105
|
-
var Release = PluginReleaseSchema;
|
|
106
|
-
var Meta = Schema.Struct({
|
|
107
|
-
profile: Profile,
|
|
108
|
-
release: Schema.optional(Release)
|
|
109
|
-
});
|
|
110
|
-
/** Constructs a bundled-plugin {@link Meta} from a canonical DXN. `profile.key` is the bare NSID derived from `key`. */
|
|
111
|
-
var makeMeta = (options) => {
|
|
112
|
-
const { key, ...rest } = options;
|
|
113
|
-
return { profile: {
|
|
114
|
-
...rest,
|
|
115
|
-
key: DXN.getName(key)
|
|
116
|
-
} };
|
|
117
|
-
};
|
|
118
|
-
/** Returns the plugin's canonical DXN URI, constructed from `meta.profile.key` and `meta.release?.version`. */
|
|
119
|
-
var getURI = (meta) => DXN.make(meta.profile.key, meta.release?.version);
|
|
120
|
-
/**
|
|
121
|
-
* Derives a runtime {@link Meta} from a loaded `dx.config.ts` (the `@dxos/protocols` `Config2.Config`).
|
|
122
|
-
* Maps the flat authoring config to the nested profile; bundled plugins have no `release`.
|
|
123
|
-
*/
|
|
124
|
-
var getMetaFromConfig = ({ plugin }) => {
|
|
125
|
-
const { key, ...rest } = plugin;
|
|
126
|
-
return makeMeta({
|
|
127
|
-
key: DXN.make(key),
|
|
128
|
-
...rest
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Identifier denoting a Plugin.
|
|
133
|
-
*/
|
|
134
|
-
var PluginTypeId = Symbol.for("@dxos/app-framework/Plugin");
|
|
135
|
-
/**
|
|
136
|
-
* Type guard to check if a value is a Plugin.
|
|
137
|
-
*/
|
|
138
|
-
var isPlugin = (value) => {
|
|
139
|
-
return typeof value === "object" && value !== null && PluginTypeId in value;
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* Internal implementation of Plugin.
|
|
143
|
-
* @internal
|
|
144
|
-
*/
|
|
145
|
-
var PluginImpl = class {
|
|
146
|
-
_meta;
|
|
147
|
-
_modules;
|
|
148
|
-
[PluginTypeId] = PluginTypeId;
|
|
149
|
-
constructor(_meta, _modules) {
|
|
150
|
-
this._meta = _meta;
|
|
151
|
-
this._modules = _modules;
|
|
152
|
-
}
|
|
153
|
-
get meta() {
|
|
154
|
-
return this._meta;
|
|
155
|
-
}
|
|
156
|
-
get modules() {
|
|
157
|
-
return this._modules;
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* Builder implementation for creating plugins incrementally.
|
|
162
|
-
*/
|
|
163
|
-
var PluginBuilderImpl = class {
|
|
164
|
-
meta;
|
|
165
|
-
_modules = [];
|
|
166
|
-
constructor(meta) {
|
|
167
|
-
this.meta = meta;
|
|
168
|
-
}
|
|
169
|
-
get modules() {
|
|
170
|
-
return this._modules;
|
|
171
|
-
}
|
|
172
|
-
addModule(moduleOptions) {
|
|
173
|
-
this._modules.push(moduleOptions);
|
|
174
|
-
return this;
|
|
175
|
-
}
|
|
176
|
-
pipe() {
|
|
177
|
-
return Pipeable.pipeArguments(this, arguments);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* Creates a new PluginBuilder to start building a plugin.
|
|
182
|
-
*/
|
|
183
|
-
var define = (meta) => new PluginBuilderImpl(meta);
|
|
184
|
-
function addModule(moduleOrOptionsOrBuilder, moduleOptions) {
|
|
185
|
-
if (moduleOrOptionsOrBuilder === void 0) return (builder) => builder;
|
|
186
|
-
if (typeof moduleOrOptionsOrBuilder === "function" && ModuleTag in moduleOrOptionsOrBuilder) {
|
|
187
|
-
const module = moduleOrOptionsOrBuilder;
|
|
188
|
-
const { id } = moduleOptions ?? {};
|
|
189
|
-
return (builder) => builder.addModule((pluginOptions) => ({
|
|
190
|
-
id: id ?? getModuleTag(module),
|
|
191
|
-
activatesOn: module.activatesOn,
|
|
192
|
-
requires: module.requires,
|
|
193
|
-
provides: module.provides,
|
|
194
|
-
activate: () => module(pluginOptions)
|
|
195
|
-
}));
|
|
196
|
-
}
|
|
197
|
-
if (moduleOptions !== void 0) return moduleOrOptionsOrBuilder.addModule(moduleOptions);
|
|
198
|
-
const moduleOpts = moduleOrOptionsOrBuilder;
|
|
199
|
-
return (builder) => builder.addModule(moduleOpts);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Normalizes an authoring record to an {@link ActivationSpec} — the single boundary where the
|
|
203
|
-
* optional authoring shape becomes the concrete runtime shape.
|
|
204
|
-
*
|
|
205
|
-
* Omitting `activatesOn` means the module belongs to the IDLE wave: a module that must run at
|
|
206
|
-
* boot states `activatesOn: ActivationEvents.Startup` explicitly. Inverted from a startup default
|
|
207
|
-
* so that forgetting the annotation costs post-paint responsiveness rather than time-to-
|
|
208
|
-
* interactive — startup was the dumping ground, and its cost becomes the transitive demand
|
|
209
|
-
* closure of the boot path, enforced by the capability graph instead of by remembering to
|
|
210
|
-
* annotate. Un-annotated modules stay pullable as providers because the baseline wave is
|
|
211
|
-
* `Startup u Idle`; see `ActivationScheduler.#isBaselineWave`, which moves with this default.
|
|
212
|
-
*/
|
|
213
|
-
var normalizeActivation = (options) => ({
|
|
214
|
-
activatesOn: options.activatesOn ?? Idle,
|
|
215
|
-
requires: options.requires ?? [],
|
|
216
|
-
provides: options.provides ?? []
|
|
217
|
-
});
|
|
218
|
-
/**
|
|
219
|
-
* Resolves a module from either a module entry or a function that returns one.
|
|
220
|
-
*/
|
|
221
|
-
var resolveModule = (meta, module, options) => {
|
|
222
|
-
const moduleOptions = typeof module === "function" ? module(options) : module;
|
|
223
|
-
const pluginName = meta.profile.key;
|
|
224
|
-
return new PluginModuleImpl({
|
|
225
|
-
id: Option.fromNullishOr(moduleOptions.id).pipe(Option.match({
|
|
226
|
-
onNone: () => {
|
|
227
|
-
const exportName = getModuleTag(moduleOptions.activate);
|
|
228
|
-
invariant(exportName, `Plugin module missing name. Plugin: ${meta.profile.key}`, {
|
|
229
|
-
"~LogMeta": "~LogMeta",
|
|
230
|
-
F: __dxlog_file,
|
|
231
|
-
L: 485,
|
|
232
|
-
S: void 0,
|
|
233
|
-
A: ["exportName", "`Plugin module missing name. Plugin: ${meta.profile.key}`"]
|
|
234
|
-
});
|
|
235
|
-
return computeModuleId(pluginName, exportName);
|
|
236
|
-
},
|
|
237
|
-
onSome: (id) => computeModuleId(pluginName, id)
|
|
238
|
-
})),
|
|
239
|
-
activation: normalizeActivation(moduleOptions),
|
|
240
|
-
activate: moduleOptions.activate
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
function make(builder) {
|
|
244
|
-
const meta = builder.meta;
|
|
245
|
-
invariant(!meta.profile.dependsOn?.includes(meta.profile.key), `Plugin ${meta.profile.key} declares itself as a dependency.`, {
|
|
246
|
-
"~LogMeta": "~LogMeta",
|
|
247
|
-
F: __dxlog_file,
|
|
248
|
-
L: 513,
|
|
249
|
-
S: this,
|
|
250
|
-
A: ["!meta.profile.dependsOn?.includes(meta.profile.key)", "`Plugin ${meta.profile.key} declares itself as a dependency.`"]
|
|
251
|
-
});
|
|
252
|
-
const factory = (options) => {
|
|
253
|
-
const resolved = options ?? {};
|
|
254
|
-
const modules = builder.modules.map((module) => resolveModule(meta, module, resolved));
|
|
255
|
-
const ids = /* @__PURE__ */ new Set();
|
|
256
|
-
for (const module of modules) {
|
|
257
|
-
invariant(!ids.has(module.id), `Duplicate module id ${module.id} in plugin ${meta.profile.key}.`, {
|
|
258
|
-
"~LogMeta": "~LogMeta",
|
|
259
|
-
F: __dxlog_file,
|
|
260
|
-
L: 526,
|
|
261
|
-
S: this,
|
|
262
|
-
A: ["!ids.has(module.id)", "`Duplicate module id ${module.id} in plugin ${meta.profile.key}.`"]
|
|
263
|
-
});
|
|
264
|
-
ids.add(module.id);
|
|
265
|
-
}
|
|
266
|
-
return new PluginImpl(meta, modules);
|
|
267
|
-
};
|
|
268
|
-
return Object.assign(factory, { meta });
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Symbol used to tag lazy plugin stubs with their loader closure.
|
|
272
|
-
* Hidden from enumeration so plugin manager iteration / serialization paths
|
|
273
|
-
* don't trip over it.
|
|
274
|
-
*/
|
|
275
|
-
var LazyTag = Symbol.for("@dxos/app-framework/Plugin/Lazy");
|
|
276
|
-
function lazy(meta, loader) {
|
|
277
|
-
const factory = (options) => {
|
|
278
|
-
const stub = new PluginImpl(meta, []);
|
|
279
|
-
Object.defineProperty(stub, LazyTag, {
|
|
280
|
-
value: {
|
|
281
|
-
loader,
|
|
282
|
-
options
|
|
283
|
-
},
|
|
284
|
-
enumerable: false
|
|
285
|
-
});
|
|
286
|
-
return stub;
|
|
287
|
-
};
|
|
288
|
-
return Object.assign(factory, { meta });
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Type guard for lazy plugin stubs produced by {@link lazy}.
|
|
292
|
-
*/
|
|
293
|
-
var isLazy = (plugin) => LazyTag in plugin;
|
|
294
|
-
/**
|
|
295
|
-
* Tagged error for failures during lazy plugin resolution. `context.id` is
|
|
296
|
-
* the lazy plugin's `meta.profile.key`; `context.reason` discriminates the failure
|
|
297
|
-
* mode (`'load-failed' | 'missing-default' | 'invalid-plugin' |
|
|
298
|
-
* 'meta-mismatch'`) so callers can route on it.
|
|
299
|
-
*/
|
|
300
|
-
var LazyPluginError = class extends BaseError.extend("LazyPluginError", "Failed to resolve lazy plugin") {};
|
|
301
|
-
/**
|
|
302
|
-
* Tagged error for plugin-level dependency resolution failures.
|
|
303
|
-
*
|
|
304
|
-
* `context.id` is the plugin id the manager was acting on. `context.reason`
|
|
305
|
-
* discriminates the failure mode:
|
|
306
|
-
* - `'missing'` — declared dep is neither registered nor in the catalog.
|
|
307
|
-
* `context.missing` lists offending ids.
|
|
308
|
-
* - `'install-failed'` — dep was found in the catalog but `add()` failed.
|
|
309
|
-
* `cause` carries the original error.
|
|
310
|
-
* - `'cycle'` — closure walk detected a cycle. `context.path` is the cycle path.
|
|
311
|
-
* - `'core-dependent'` — cascade-disable would have to disable a core plugin.
|
|
312
|
-
* `context.coreDependent` is the blocking id.
|
|
313
|
-
*/
|
|
314
|
-
var PluginDependencyError = class extends BaseError.extend("PluginDependencyError", "Plugin dependency resolution failed") {};
|
|
315
|
-
/**
|
|
316
|
-
* Resolves a lazy plugin stub to its real plugin.
|
|
317
|
-
* Returns the plugin unchanged if it is not lazy. Failures surface as
|
|
318
|
-
* {@link LazyPluginError} with `context.reason` indicating the failure mode
|
|
319
|
-
* and (for loader failures) `cause` set to the original error.
|
|
320
|
-
*/
|
|
321
|
-
var resolveLazy = (plugin) => Effect.gen(function* () {
|
|
322
|
-
if (!isLazy(plugin)) return plugin;
|
|
323
|
-
const id = plugin.meta.profile.key;
|
|
324
|
-
const { loader, options } = plugin[LazyTag];
|
|
325
|
-
const mod = yield* Effect.tryPromise({
|
|
326
|
-
try: loader,
|
|
327
|
-
catch: (error) => new LazyPluginError({
|
|
328
|
-
context: {
|
|
329
|
-
id,
|
|
330
|
-
reason: "load-failed"
|
|
331
|
-
},
|
|
332
|
-
cause: error
|
|
333
|
-
})
|
|
334
|
-
});
|
|
335
|
-
if (!mod || typeof mod.default !== "function") return yield* Effect.fail(new LazyPluginError({ context: {
|
|
336
|
-
id,
|
|
337
|
-
reason: "missing-default"
|
|
338
|
-
} }));
|
|
339
|
-
const result = mod.default(options);
|
|
340
|
-
if (!isPlugin(result)) return yield* Effect.fail(new LazyPluginError({ context: {
|
|
341
|
-
id,
|
|
342
|
-
reason: "invalid-plugin"
|
|
343
|
-
} }));
|
|
344
|
-
if (result.meta.profile.key !== id) return yield* Effect.fail(new LazyPluginError({ context: {
|
|
345
|
-
id,
|
|
346
|
-
reason: "meta-mismatch",
|
|
347
|
-
returnedId: result.meta.profile.key
|
|
348
|
-
} }));
|
|
349
|
-
return result;
|
|
350
|
-
});
|
|
351
|
-
//#endregion
|
|
352
|
-
export { LazyPluginError, Meta, PluginDependencyError, PluginModuleTypeId, PluginTypeId, Profile, Release, Service, activate, addModule, define, getMetaFromConfig, getURI, isLazy, isPlugin, isPluginModule, lazy, make, makeMeta, reset, resolveLazy, shutdown, plugin_exports as t };
|
|
353
|
-
|
|
354
|
-
//# sourceMappingURL=plugin.mjs.map
|
|
1
|
+
export { t as LazyPluginError, n as Meta, r as PluginDependencyError, i as PluginModuleTypeId, a as PluginTypeId, o as Profile, s as Release, c as Service, l as activate, u as addModule, d as define, f as getMetaFromConfig, p as getURI, m as isLazy, h as isPlugin, g as isPluginModule, _ as lazy, v as make, y as makeMeta, x as reset, S as resolveLazy, C as shutdown } from "../chunk-plugin.mjs";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { EdgeRegistryPluginProvider as EdgePluginProvider, Manager };
|
|
1
|
+
export { r as EdgePluginProvider, t as Manager } from "../chunk-registry.mjs";
|