@jointhedots/gear 1.2.0 → 1.2.3
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/esm/builder/build-app-bundle.d.ts +29 -0
- package/esm/builder/build-app-bundle.js +9 -6
- package/esm/builder/build-app-host.d.ts +28 -0
- package/esm/builder/build-app-host.js +20 -19
- package/esm/builder/build-application.d.ts +51 -0
- package/esm/builder/build-application.js +53 -74
- package/esm/builder/build-library.d.ts +21 -0
- package/esm/builder/build-library.js +13 -10
- package/esm/builder/build-target.d.ts +36 -0
- package/esm/builder/build-target.js +20 -12
- package/esm/builder/helpers/emit-artifact.d.ts +13 -0
- package/esm/builder/helpers/emit-artifact.js +40 -0
- package/esm/builder/helpers/emit-bundle-manifest.d.ts +19 -0
- package/esm/builder/helpers/emit-bundle-manifest.js +38 -16
- package/esm/builder/helpers/emit-components-dts.d.ts +9 -0
- package/esm/builder/helpers/emit-components-dts.js +1 -2
- package/esm/builder/helpers/emit-esmodules.d.ts +61 -0
- package/esm/builder/helpers/emit-esmodules.js +22 -23
- package/esm/builder/helpers/emit-package-manifest.d.ts +9 -0
- package/esm/builder/helpers/emit-package-manifest.js +1 -2
- package/esm/builder/helpers/emit-static-assets.d.ts +14 -0
- package/esm/builder/helpers/emit-static-assets.js +1 -2
- package/esm/builder/helpers/emit-typescript-definition.d.ts +35 -0
- package/esm/builder/helpers/emit-typescript-definition.js +7 -8
- package/esm/builder/helpers/path-helpers.d.ts +9 -0
- package/esm/builder/helpers/path-helpers.js +0 -1
- package/esm/builder/helpers/task.d.ts +8 -0
- package/esm/builder/helpers/task.js +0 -1
- package/esm/cli.d.ts +2 -0
- package/esm/cli.js +1 -4
- package/esm/commands/init.d.ts +2 -0
- package/esm/commands/init.js +0 -1
- package/esm/commands/install.d.ts +5 -0
- package/esm/commands/install.js +3 -4
- package/esm/commands/make.d.ts +17 -0
- package/esm/commands/make.js +12 -5
- package/esm/commands/run.d.ts +8 -0
- package/esm/commands/run.js +6 -7
- package/esm/commands/serve.d.ts +9 -0
- package/esm/commands/serve.js +11 -13
- package/esm/core/commands/interface.d.ts +26 -0
- package/esm/core/commands/interface.js +21 -0
- package/esm/core/components/components.d.ts +73 -0
- package/esm/core/components/components.js +2 -0
- package/esm/core/components/helpers.d.ts +7 -0
- package/esm/core/components/helpers.js +68 -0
- package/esm/core/components/manifold.d.ts +77 -0
- package/esm/core/components/manifold.js +442 -0
- package/esm/core/components/mod.d.ts +4 -0
- package/esm/core/components/mod.js +4 -0
- package/esm/core/components/provider.d.ts +42 -0
- package/esm/core/components/provider.js +127 -0
- package/esm/core/logging/mod.d.ts +53 -0
- package/esm/core/logging/mod.js +142 -0
- package/esm/core/logging/trace.d.ts +51 -0
- package/esm/core/logging/trace.js +17 -0
- package/esm/core/mod-browser.d.ts +1 -0
- package/esm/core/mod-browser.js +1 -0
- package/esm/core/mod-node.d.ts +1 -0
- package/esm/core/mod-node.js +1 -0
- package/esm/core/mod.d.ts +5 -0
- package/esm/core/mod.js +5 -0
- package/esm/core/schema/helpers.d.ts +36 -0
- package/esm/core/schema/helpers.js +163 -0
- package/esm/core/schema/mod.d.ts +3 -0
- package/esm/core/schema/mod.js +3 -0
- package/esm/core/schema/schema.d.ts +376 -0
- package/esm/core/schema/schema.js +234 -0
- package/esm/core/schema/zod.d.ts +44 -0
- package/esm/core/schema/zod.js +127 -0
- package/esm/core/services/mod.d.ts +5 -0
- package/esm/core/services/mod.js +5 -0
- package/esm/core/services/service-accessor.d.ts +17 -0
- package/esm/core/services/service-accessor.js +20 -0
- package/esm/core/services/service-definitions.d.ts +37 -0
- package/esm/core/services/service-definitions.js +44 -0
- package/esm/core/services/service-points.d.ts +40 -0
- package/esm/core/services/service-points.js +164 -0
- package/esm/core/services/service-specification.d.ts +52 -0
- package/esm/core/services/service-specification.js +59 -0
- package/esm/core/services/settings.d.ts +29 -0
- package/esm/core/services/settings.js +123 -0
- package/esm/utils/file.d.ts +39 -0
- package/esm/utils/file.js +3 -4
- package/esm/utils/graph-ordering.d.ts +21 -0
- package/esm/utils/graph-ordering.js +0 -1
- package/esm/utils/normalized-name.d.ts +17 -0
- package/esm/utils/normalized-name.js +0 -1
- package/esm/workspace/component.d.ts +70 -0
- package/esm/workspace/component.js +0 -1
- package/esm/workspace/helpers/config-loader.d.ts +37 -0
- package/esm/workspace/helpers/config-loader.js +4 -5
- package/esm/workspace/helpers/create-manifests.d.ts +13 -0
- package/esm/workspace/helpers/create-manifests.js +3 -4
- package/esm/workspace/helpers/discover-workspace.d.ts +4 -0
- package/esm/workspace/helpers/discover-workspace.js +19 -30
- package/esm/workspace/helpers/lockfile.d.ts +5 -0
- package/esm/workspace/helpers/lockfile.js +13 -14
- package/esm/workspace/helpers/logger.d.ts +65 -0
- package/esm/workspace/helpers/logger.js +1 -2
- package/esm/workspace/helpers/package-npm.d.ts +1 -0
- package/esm/workspace/helpers/package-npm.js +0 -1
- package/esm/workspace/mod.d.ts +1 -0
- package/esm/workspace/mod.js +1 -0
- package/esm/workspace/packager.d.ts +5 -0
- package/esm/workspace/packager.js +1 -2
- package/esm/workspace/packagers/packager-standard.d.ts +7 -0
- package/esm/workspace/packagers/packager-standard.js +3 -4
- package/esm/workspace/storage.d.ts +59 -0
- package/esm/workspace/storage.js +4 -5
- package/esm/workspace/workspace.d.ts +165 -0
- package/esm/workspace/workspace.js +27 -16
- package/package.json +74 -66
- package/esm/commands/publish.js +0 -36
- package/esm/publish/publish_aws_s3.js +0 -67
package/esm/commands/init.js
CHANGED
package/esm/commands/install.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Path from
|
|
2
|
-
import Fs from
|
|
1
|
+
import Path from "node:path";
|
|
2
|
+
import Fs from "node:fs";
|
|
3
3
|
import {} from "yargs";
|
|
4
4
|
import { open_workspace } from "../workspace/workspace.js";
|
|
5
5
|
import { makeComponentPublication } from "../workspace/component.js";
|
|
@@ -29,7 +29,7 @@ export function command_install() {
|
|
|
29
29
|
// Select all workspace bundles
|
|
30
30
|
const selector = new BundleSelector(ws);
|
|
31
31
|
for (const lib of ws.libraries) {
|
|
32
|
-
selector.add(lib.
|
|
32
|
+
selector.add(lib.master);
|
|
33
33
|
}
|
|
34
34
|
if (selector.missing.length > 0) {
|
|
35
35
|
ws.log.warn(`Missing bundle dependencies: ${selector.missing.join(", ")}`);
|
|
@@ -64,4 +64,3 @@ export function command_install() {
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CommandModule } from "yargs";
|
|
2
|
+
type MakeOptions = {
|
|
3
|
+
watch?: boolean;
|
|
4
|
+
pack?: boolean;
|
|
5
|
+
versioned?: string;
|
|
6
|
+
devmode?: boolean;
|
|
7
|
+
clean?: boolean;
|
|
8
|
+
dist?: string;
|
|
9
|
+
artifactDir?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function command_make(): CommandModule<any, MakeOptions & {
|
|
12
|
+
apps?: string;
|
|
13
|
+
libs?: string;
|
|
14
|
+
bundles?: string;
|
|
15
|
+
ws?: string;
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
package/esm/commands/make.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import Path from
|
|
1
|
+
import Path from "node:path";
|
|
2
2
|
import {} from "yargs";
|
|
3
3
|
import { StorageFiles } from "../workspace/storage.js";
|
|
4
4
|
import { Bundle, Library, open_workspace } from "../workspace/workspace.js";
|
|
5
5
|
import { build_application } from "../builder/build-application.js";
|
|
6
6
|
import { build_app_composable_bundle } from "../builder/build-app-bundle.js";
|
|
7
7
|
import { build_library } from "../builder/build-library.js";
|
|
8
|
-
import { makeNormalizedName, NameStyle } from
|
|
8
|
+
import { makeNormalizedName, NameStyle } from "../utils/normalized-name.js";
|
|
9
9
|
import { resolvePackageVersion } from "../workspace/helpers/package-npm.js";
|
|
10
10
|
export function command_make() {
|
|
11
11
|
return {
|
|
@@ -59,6 +59,10 @@ export function command_make() {
|
|
|
59
59
|
.option("dist", {
|
|
60
60
|
type: "string",
|
|
61
61
|
default: "./dist",
|
|
62
|
+
})
|
|
63
|
+
.option("artifact-dir", {
|
|
64
|
+
type: "string",
|
|
65
|
+
describe: "Directory to write output artifacts (npm if package.json, zip otherwise)",
|
|
62
66
|
}),
|
|
63
67
|
handler: async (argv) => {
|
|
64
68
|
const ws = await open_workspace({
|
|
@@ -89,8 +93,8 @@ export function command_make() {
|
|
|
89
93
|
const bundles = [];
|
|
90
94
|
if (argv.bundles === "*") {
|
|
91
95
|
for (const lib of ws.libraries) {
|
|
92
|
-
if (lib.
|
|
93
|
-
bundles.push(lib.
|
|
96
|
+
if (lib.master)
|
|
97
|
+
bundles.push(lib.master);
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
else if (argv.bundles) {
|
|
@@ -112,6 +116,7 @@ export function command_make() {
|
|
|
112
116
|
ws.log.error(`application not found: ${appname}`);
|
|
113
117
|
}
|
|
114
118
|
}
|
|
119
|
+
const artifactDir = argv.artifactDir ? Path.resolve(argv.artifactDir) : undefined;
|
|
115
120
|
const pendings = [];
|
|
116
121
|
if (bundles.length > 0) {
|
|
117
122
|
const shelve = new StorageFiles("shelve", Path.resolve(argv.dist, "shelve"));
|
|
@@ -123,6 +128,7 @@ export function command_make() {
|
|
|
123
128
|
devmode: argv.devmode,
|
|
124
129
|
watch: argv.watch,
|
|
125
130
|
clean: argv.clean || !argv.devmode,
|
|
131
|
+
artifactDir,
|
|
126
132
|
}));
|
|
127
133
|
}
|
|
128
134
|
}
|
|
@@ -137,6 +143,7 @@ export function command_make() {
|
|
|
137
143
|
devmode: argv.devmode,
|
|
138
144
|
watch: argv.watch,
|
|
139
145
|
clean: argv.clean || !argv.devmode,
|
|
146
|
+
artifactDir,
|
|
140
147
|
}));
|
|
141
148
|
}
|
|
142
149
|
for (const lib of libraries) {
|
|
@@ -149,10 +156,10 @@ export function command_make() {
|
|
|
149
156
|
devmode: argv.devmode,
|
|
150
157
|
watch: argv.watch,
|
|
151
158
|
clean: argv.clean || !argv.devmode,
|
|
159
|
+
artifactDir,
|
|
152
160
|
}, argv.pack ? Path.resolve(argv.dist) : null));
|
|
153
161
|
}
|
|
154
162
|
await Promise.all(pendings);
|
|
155
163
|
}
|
|
156
164
|
};
|
|
157
165
|
}
|
|
158
|
-
//# sourceMappingURL=make.js.map
|
package/esm/commands/run.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Process from
|
|
3
|
-
import Path from
|
|
4
|
-
import ChildProcess from
|
|
5
|
-
import { createRequire } from "module";
|
|
1
|
+
import Fs from "node:fs";
|
|
2
|
+
import Process from "node:process";
|
|
3
|
+
import Path from "node:path";
|
|
4
|
+
import ChildProcess from "node:child_process";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
6
|
import {} from "yargs";
|
|
7
7
|
const restart_always_on_change = true;
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
@@ -101,10 +101,9 @@ export function command_run() {
|
|
|
101
101
|
Process.stdin.setRawMode(true);
|
|
102
102
|
Process.stdin.resume();
|
|
103
103
|
Process.stdin.on('data', onKeyPress);
|
|
104
|
-
const watcher =
|
|
104
|
+
const watcher = Fs.watch(argv.dir, { recursive: true });
|
|
105
105
|
watcher.on('change', () => restart());
|
|
106
106
|
start();
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
-
//# sourceMappingURL=run.js.map
|
package/esm/commands/serve.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import Path from
|
|
1
|
+
import Path from "node:path";
|
|
2
2
|
import {} from "yargs";
|
|
3
3
|
import { StorageFiles } from "../workspace/storage.js";
|
|
4
4
|
import { open_workspace, Workspace } from "../workspace/workspace.js";
|
|
5
5
|
import { build_application } from "../builder/build-application.js";
|
|
6
|
-
import { makeNormalizedName, NameStyle } from
|
|
7
|
-
import Express from
|
|
6
|
+
import { makeNormalizedName, NameStyle } from "../utils/normalized-name.js";
|
|
7
|
+
import Express from "express";
|
|
8
8
|
import { resolvePackageVersion } from "../workspace/helpers/package-npm.js";
|
|
9
9
|
export function command_serve() {
|
|
10
10
|
return {
|
|
@@ -54,22 +54,21 @@ export function command_serve() {
|
|
|
54
54
|
}
|
|
55
55
|
const outputDir = Path.resolve(argv.dist, makeNormalizedName(argv.app, NameStyle.WEBC));
|
|
56
56
|
const storage = new StorageFiles(ws.name, outputDir);
|
|
57
|
+
let serverStarted = false;
|
|
57
58
|
const building = build_application({
|
|
58
59
|
app,
|
|
59
60
|
storage,
|
|
60
61
|
version,
|
|
61
62
|
devmode: argv.devmode,
|
|
62
63
|
devserver: argv.port && `http://localhost:${argv.port}`,
|
|
64
|
+
onNotification(event) {
|
|
65
|
+
if (event.type === "build-complete" && !serverStarted && argv.port) {
|
|
66
|
+
serverStarted = true;
|
|
67
|
+
serve(ws, argv.port, storage);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
63
70
|
});
|
|
64
|
-
|
|
65
|
-
await Promise.all([
|
|
66
|
-
building,
|
|
67
|
-
serve(ws, argv.port, storage)
|
|
68
|
-
]);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
await building;
|
|
72
|
-
}
|
|
71
|
+
await building;
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
74
|
}
|
|
@@ -90,4 +89,3 @@ async function serve(ws, port, storage) {
|
|
|
90
89
|
process.on('SIGQUIT', () => resolve(null));
|
|
91
90
|
});
|
|
92
91
|
}
|
|
93
|
-
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type Serializable = string | number | boolean | null | Serializable[] | {
|
|
2
|
+
[key: string]: Serializable;
|
|
3
|
+
};
|
|
4
|
+
export type Cmdlet<CmdPayload extends Serializable = Serializable, CmdResult extends Serializable = Serializable> = {
|
|
5
|
+
payload: CmdPayload;
|
|
6
|
+
result: CmdResult;
|
|
7
|
+
};
|
|
8
|
+
export type CmdPayload<C extends Cmdlet> = C extends {
|
|
9
|
+
payload: infer P;
|
|
10
|
+
} ? P : void;
|
|
11
|
+
export type CmdResult<C extends Cmdlet> = C extends {
|
|
12
|
+
result: infer P;
|
|
13
|
+
} ? P : void;
|
|
14
|
+
export interface Command<C extends Cmdlet = Cmdlet> {
|
|
15
|
+
target: string;
|
|
16
|
+
payload?: CmdPayload<C>;
|
|
17
|
+
icon?: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
summary?: string;
|
|
20
|
+
identity?: string;
|
|
21
|
+
signature?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface CommandsService {
|
|
24
|
+
execute<C extends Cmdlet>(cmd: string, data: CmdPayload<C>): Promise<CmdResult<C>>;
|
|
25
|
+
}
|
|
26
|
+
export declare function executeCommand(cmd: Command): Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { URI } from "vscode-uri";
|
|
2
|
+
import { acquireComponent } from "../components/manifold.js";
|
|
3
|
+
import { Log } from "../logging/mod.js";
|
|
4
|
+
export async function executeCommand(cmd) {
|
|
5
|
+
console.log("executeCommand:", cmd.target);
|
|
6
|
+
const uri = URI.parse(cmd.target);
|
|
7
|
+
const comp = acquireComponent(uri.authority);
|
|
8
|
+
if (uri.scheme === "command") {
|
|
9
|
+
try {
|
|
10
|
+
const svc = await comp.fetchResource("commands");
|
|
11
|
+
if (svc?.execute instanceof Function) {
|
|
12
|
+
svc.execute(uri.path, cmd.payload);
|
|
13
|
+
}
|
|
14
|
+
else
|
|
15
|
+
throw new Error(`Invalid commands service`);
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
Log.error(e);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { DocumentationSchema, JSONSchema, ResourceEntry } from "../schema/schema.ts";
|
|
2
|
+
import type { ComponentEntry } from "./manifold.ts";
|
|
3
|
+
import { ServiceAccessor, type ServiceType } from "../services/service-accessor.ts";
|
|
4
|
+
export type ComponentID = string;
|
|
5
|
+
export interface ComponentPublication {
|
|
6
|
+
id: ComponentID;
|
|
7
|
+
ref?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
title: string;
|
|
10
|
+
icon?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
services?: string[];
|
|
13
|
+
keywords?: string[];
|
|
14
|
+
tags?: string[];
|
|
15
|
+
}
|
|
16
|
+
export type ComponentServiceID = string;
|
|
17
|
+
export type ComponentManifest<Data extends any = unknown> = {
|
|
18
|
+
$id: string;
|
|
19
|
+
type?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
icon?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
keywords?: string[];
|
|
24
|
+
tags?: string[];
|
|
25
|
+
doc?: DocumentationSchema;
|
|
26
|
+
specs?: Record<ComponentServiceID, any>;
|
|
27
|
+
apis?: Record<ComponentServiceID, ResourceEntry>;
|
|
28
|
+
data?: Data;
|
|
29
|
+
};
|
|
30
|
+
/** Configuration for a distributed package */
|
|
31
|
+
export interface DistributedConfig {
|
|
32
|
+
/** Version specifier (e.g., "*", "^18.0.0") */
|
|
33
|
+
version?: string;
|
|
34
|
+
/** Interop type: 'esm' | 'cjs-default' | 'cjs-named' */
|
|
35
|
+
interop?: 'esm' | 'cjs-default' | 'cjs-named';
|
|
36
|
+
/** List of named exports to re-export (required for cjs-named interop) */
|
|
37
|
+
exports?: string[];
|
|
38
|
+
}
|
|
39
|
+
export type BundleManifest = ComponentManifest<{
|
|
40
|
+
alias?: string;
|
|
41
|
+
package?: string;
|
|
42
|
+
baseline?: string;
|
|
43
|
+
namespaces?: string[];
|
|
44
|
+
dependencies?: string[];
|
|
45
|
+
distribueds?: {
|
|
46
|
+
[packageName: string]: string | DistributedConfig;
|
|
47
|
+
};
|
|
48
|
+
exports?: {
|
|
49
|
+
[id: string]: string;
|
|
50
|
+
};
|
|
51
|
+
components?: ComponentPublication[];
|
|
52
|
+
}>;
|
|
53
|
+
export type ComponentSchema = {
|
|
54
|
+
readonly name: ServiceType;
|
|
55
|
+
readonly title: string;
|
|
56
|
+
readonly icon: string;
|
|
57
|
+
readonly attributes: Record<string, JSONSchema>;
|
|
58
|
+
};
|
|
59
|
+
export interface ComponentManifestIssue {
|
|
60
|
+
level: "error" | "warn" | "info";
|
|
61
|
+
message: string;
|
|
62
|
+
fix?(descriptor: ComponentManifest): Promise<ComponentManifest>;
|
|
63
|
+
}
|
|
64
|
+
export interface ComponentChecking {
|
|
65
|
+
fixed?: ComponentManifest;
|
|
66
|
+
issues?: ComponentManifestIssue[];
|
|
67
|
+
}
|
|
68
|
+
export interface ComponentController {
|
|
69
|
+
createComponent(component: ComponentEntry, descriptor: ComponentManifest): Promise<void>;
|
|
70
|
+
updateComponent(component: ComponentEntry, descriptor: ComponentManifest): Promise<void>;
|
|
71
|
+
checkDescriptor(descriptor: ComponentManifest): Promise<ComponentChecking>;
|
|
72
|
+
}
|
|
73
|
+
export declare const ComponentControllerKey: ServiceAccessor<ComponentController, ComponentSchema>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { URI } from "vscode-uri";
|
|
2
|
+
import { type ComponentManifest, type ComponentPublication } from "./components.ts";
|
|
3
|
+
import type { ResourceEntry, ResourceImport } from "../schema/schema.ts";
|
|
4
|
+
export declare function parseComponentURI(ref: string): URI;
|
|
5
|
+
export declare function getComponentServicesList(manif: ComponentManifest): Promise<string[]>;
|
|
6
|
+
export declare function createComponentPublication(manif: ComponentManifest): Promise<ComponentPublication>;
|
|
7
|
+
export declare function parseResourceEntry(entry: ResourceEntry): ResourceImport;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { URI } from "vscode-uri";
|
|
2
|
+
import {} from "./components.js";
|
|
3
|
+
import { acquireComponent } from "./manifold.js";
|
|
4
|
+
export function parseComponentURI(ref) {
|
|
5
|
+
if (ref.startsWith("./")) {
|
|
6
|
+
const base = URI.parse(window.location.href);
|
|
7
|
+
const parts = base.path.split("/");
|
|
8
|
+
parts[parts.length - 1] = ref.slice(2);
|
|
9
|
+
return base.with({ path: parts.join("/"), query: "", fragment: "" });
|
|
10
|
+
}
|
|
11
|
+
else if (ref.startsWith("/")) {
|
|
12
|
+
return URI.parse(window.location.href).with({ path: ref, query: "", fragment: "" });
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return URI.parse(ref);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function getComponentServicesList(manif) {
|
|
19
|
+
const services = manif.apis ? Object.keys(manif.apis) : [];
|
|
20
|
+
if (manif.type) {
|
|
21
|
+
const controller = await acquireComponent(manif.type)?.fetch();
|
|
22
|
+
if (controller) {
|
|
23
|
+
for (const key in controller?.apis) {
|
|
24
|
+
if (key.startsWith("component.")) {
|
|
25
|
+
const name = key.slice(10);
|
|
26
|
+
if (!services.includes(name))
|
|
27
|
+
services.push(name);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw new Error("Cannot create publiction properly");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return services;
|
|
36
|
+
}
|
|
37
|
+
export async function createComponentPublication(manif) {
|
|
38
|
+
const { $id } = manif;
|
|
39
|
+
return {
|
|
40
|
+
id: $id,
|
|
41
|
+
type: manif.type,
|
|
42
|
+
icon: manif.icon,
|
|
43
|
+
title: manif.title || $id,
|
|
44
|
+
description: manif.description || "",
|
|
45
|
+
keywords: manif.keywords,
|
|
46
|
+
tags: manif.tags,
|
|
47
|
+
services: await getComponentServicesList(manif),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function parseResourceEntry(entry) {
|
|
51
|
+
if (typeof entry === "string") {
|
|
52
|
+
let [location, fragment] = entry.split("#", 2);
|
|
53
|
+
// Make resource data
|
|
54
|
+
const result = { type: "module", location };
|
|
55
|
+
if (fragment) {
|
|
56
|
+
const [identifier, query] = fragment.split("?", 2);
|
|
57
|
+
result.identifier = identifier;
|
|
58
|
+
if (query) {
|
|
59
|
+
for (const kv of query.split("&")) {
|
|
60
|
+
const [k, v] = kv.split("=");
|
|
61
|
+
result[k] = v === undefined ? true : v;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
return entry;
|
|
68
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type ComponentManifest, type ComponentPublication } from "./components.ts";
|
|
2
|
+
import { type QueryLogResult } from "../logging/mod.ts";
|
|
3
|
+
import { type ComponentFilter, type IComponentProvider, type IContentProvider, type IResourceLoader } from "./provider.ts";
|
|
4
|
+
export type ComponentErrorManifest = ComponentManifest & {
|
|
5
|
+
type: "<error>";
|
|
6
|
+
message: string;
|
|
7
|
+
stack?: string;
|
|
8
|
+
};
|
|
9
|
+
export type ComponentServiceGetter<Service = any> = (entry: ComponentEntry) => Service;
|
|
10
|
+
export declare class ComponentEntry<Instance extends Object = any> {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
protected __instance__?: Instance;
|
|
13
|
+
manifest?: ComponentManifest;
|
|
14
|
+
constructor(id: string);
|
|
15
|
+
get title(): string;
|
|
16
|
+
get namespace(): string;
|
|
17
|
+
get valid(): boolean;
|
|
18
|
+
get loaded(): boolean;
|
|
19
|
+
get installed(): boolean;
|
|
20
|
+
get instance(): Instance;
|
|
21
|
+
set instance(value: Instance);
|
|
22
|
+
get<Manifest extends ComponentManifest = ComponentManifest>(): Manifest;
|
|
23
|
+
set<Manifest extends ComponentManifest = ComponentManifest>(manifest: Manifest): this;
|
|
24
|
+
fetch<Manifest extends ComponentManifest = ComponentManifest>(): Promise<Manifest>;
|
|
25
|
+
install(): Promise<ComponentEntry>;
|
|
26
|
+
acquireResource(identifier: string): ComponentResource;
|
|
27
|
+
getResource(identifier: string): ComponentResource;
|
|
28
|
+
hasResource(identifier: string): boolean;
|
|
29
|
+
getResourceAsync(identifier: string): Promise<ComponentResource>;
|
|
30
|
+
fetchResource<T = any>(identifier: string): Promise<T>;
|
|
31
|
+
getLogStats(): import("../logging/mod.ts").LogInfos;
|
|
32
|
+
getLogs(count: number): QueryLogResult;
|
|
33
|
+
}
|
|
34
|
+
export declare class ComponentResource {
|
|
35
|
+
readonly component: ComponentEntry;
|
|
36
|
+
readonly resource: string;
|
|
37
|
+
entry: any;
|
|
38
|
+
identifier: string;
|
|
39
|
+
constructor(component: ComponentEntry, resource: string);
|
|
40
|
+
get valid(): boolean;
|
|
41
|
+
get loaded(): boolean;
|
|
42
|
+
fetch<T = any>(): Promise<T>;
|
|
43
|
+
get<T = any>(): T;
|
|
44
|
+
set(data: any): void;
|
|
45
|
+
get spec(): any;
|
|
46
|
+
get url(): string;
|
|
47
|
+
}
|
|
48
|
+
export type ComponentsListener = (target: ComponentEntry) => void;
|
|
49
|
+
export declare class ComponentsManifold {
|
|
50
|
+
components: Map<string, ComponentEntry<any>>;
|
|
51
|
+
resources: Map<string, ComponentResource>;
|
|
52
|
+
datamap: WeakMap<any, ComponentEntry<any> | ComponentResource>;
|
|
53
|
+
loadings: Map<any, Promise<any>>;
|
|
54
|
+
installings: Map<any, Promise<ComponentEntry<any>>>;
|
|
55
|
+
listeners: Set<ComponentsListener>;
|
|
56
|
+
components_provider: IComponentProvider;
|
|
57
|
+
resources_loader: IResourceLoader;
|
|
58
|
+
content_provider: IContentProvider;
|
|
59
|
+
constructor();
|
|
60
|
+
listen(l: ComponentsListener): ComponentsListener;
|
|
61
|
+
unlisten(l: ComponentsListener): void;
|
|
62
|
+
notifyError(subject: ComponentEntry, error: Error): void;
|
|
63
|
+
}
|
|
64
|
+
export declare const ComponentsRegistry: ComponentsManifold;
|
|
65
|
+
export declare function getDefaultComponent(): ComponentEntry<any>;
|
|
66
|
+
export declare function getComponentFromData(data: any, is_static?: boolean): ComponentEntry;
|
|
67
|
+
export declare function acquireComponent(id: string): ComponentEntry;
|
|
68
|
+
export declare function acquireFutureComponent(manifest: ComponentManifest): ComponentEntry;
|
|
69
|
+
export declare function acquireResource(ref: string): ComponentResource;
|
|
70
|
+
export declare function resolveRelativeComponent(ref: string, from: ComponentEntry): ComponentEntry;
|
|
71
|
+
export declare function saveComponentManifest(manifest: ComponentManifest): Promise<ComponentEntry<any>>;
|
|
72
|
+
export declare function saveComponent(component: ComponentEntry): Promise<ComponentEntry<any>>;
|
|
73
|
+
export declare function deleteComponent(id: string): Promise<void>;
|
|
74
|
+
export declare function unregisterComponent(id: string): void;
|
|
75
|
+
export declare function searchComponentsPublications(filter: ComponentFilter): Promise<ComponentPublication[]>;
|
|
76
|
+
export declare function fetchComponentsPublications(components_ids: string[]): Promise<ComponentPublication[]>;
|
|
77
|
+
export declare function failedComponentPublication(id: string, title?: string): ComponentPublication;
|