@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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Bundle, Library } from "../workspace/workspace.ts";
|
|
2
|
+
import { StorageFiles, type IStorageZone } from "../workspace/storage.ts";
|
|
3
|
+
import { BuildTarget } from "./build-target.ts";
|
|
4
|
+
export type BuildBundleOptions = {
|
|
5
|
+
bundle: Bundle;
|
|
6
|
+
shelve: StorageFiles;
|
|
7
|
+
version: string;
|
|
8
|
+
devmode: boolean;
|
|
9
|
+
watch: boolean;
|
|
10
|
+
clean: boolean;
|
|
11
|
+
artifactDir?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare enum PathStatus {
|
|
14
|
+
Unknown,
|
|
15
|
+
Internal = 1,
|
|
16
|
+
External = 2,
|
|
17
|
+
Dependency = 3,
|
|
18
|
+
ExternalBundle = 4
|
|
19
|
+
}
|
|
20
|
+
export declare function create_bundle_target(opts: {
|
|
21
|
+
bundle: Bundle;
|
|
22
|
+
library: Library;
|
|
23
|
+
storage: IStorageZone;
|
|
24
|
+
version: string;
|
|
25
|
+
devmode: boolean;
|
|
26
|
+
watch: boolean;
|
|
27
|
+
clean: boolean;
|
|
28
|
+
}): BuildTarget;
|
|
29
|
+
export declare function build_app_composable_bundle(opts: BuildBundleOptions): Promise<BuildTarget>;
|
|
@@ -8,6 +8,7 @@ import { PathQualifier } from "./helpers/path-helpers.js";
|
|
|
8
8
|
import { create_export_map } from "../workspace/helpers/create-manifests.js";
|
|
9
9
|
import { DependencyDeduplicationPlugin, collectLibraryGraph } from "./helpers/emit-esmodules.js";
|
|
10
10
|
import { BundleManifestTask } from "./helpers/emit-bundle-manifest.js";
|
|
11
|
+
import { ArtifactNpmTask } from "./helpers/emit-artifact.js";
|
|
11
12
|
export var PathStatus;
|
|
12
13
|
(function (PathStatus) {
|
|
13
14
|
PathStatus[PathStatus["Unknown"] = undefined] = "Unknown";
|
|
@@ -18,7 +19,7 @@ export var PathStatus;
|
|
|
18
19
|
})(PathStatus || (PathStatus = {}));
|
|
19
20
|
export function create_bundle_target(opts) {
|
|
20
21
|
const { bundle, library: lib, storage } = opts;
|
|
21
|
-
const target = new BuildTarget(bundle.id, storage, lib
|
|
22
|
+
const target = new BuildTarget(bundle.id, storage, lib, opts.devmode == true, opts.watch == true, opts.clean == true);
|
|
22
23
|
// Prepare esm setup
|
|
23
24
|
target.esmodules.set_root(lib.path);
|
|
24
25
|
// Add bundle package.json
|
|
@@ -26,7 +27,7 @@ export function create_bundle_target(opts) {
|
|
|
26
27
|
// Add bundle types.d.ts
|
|
27
28
|
target.tasks.push(new TypescriptDefinitionTask(target, lib));
|
|
28
29
|
// Add bundle exporteds
|
|
29
|
-
const entries = create_export_map(lib, lib.
|
|
30
|
+
const entries = create_export_map(lib, lib.master);
|
|
30
31
|
for (const exp_id in entries) {
|
|
31
32
|
const exp = entries[exp_id];
|
|
32
33
|
target.esmodules.add_entry(exp.basename, exp.source);
|
|
@@ -34,11 +35,11 @@ export function create_bundle_target(opts) {
|
|
|
34
35
|
// Add bundle content
|
|
35
36
|
if (bundle) {
|
|
36
37
|
// Add bundle manifest
|
|
37
|
-
target.tasks.push(new BundleManifestTask(target,
|
|
38
|
+
target.tasks.push(new BundleManifestTask(target, bundle));
|
|
38
39
|
// Add bundle components
|
|
39
40
|
for (const [path, desc] of bundle.components) {
|
|
40
41
|
const baseDir = Path.dirname(path);
|
|
41
|
-
target.add_component(desc, baseDir,
|
|
42
|
+
target.add_component(desc, baseDir, bundle);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
// Add declarations descriptors
|
|
@@ -158,7 +159,7 @@ export function create_bundle_target(opts) {
|
|
|
158
159
|
return {
|
|
159
160
|
contents,
|
|
160
161
|
loader: "js",
|
|
161
|
-
resolveDir:
|
|
162
|
+
resolveDir: lib.path,
|
|
162
163
|
};
|
|
163
164
|
});
|
|
164
165
|
// Handle imports from within the proxy modules - these should be truly external
|
|
@@ -187,6 +188,9 @@ export async function build_app_composable_bundle(opts) {
|
|
|
187
188
|
watch: opts.watch,
|
|
188
189
|
clean: opts.clean,
|
|
189
190
|
});
|
|
191
|
+
if (opts.artifactDir) {
|
|
192
|
+
target.finalTasks.push(new ArtifactNpmTask(target, opts.artifactDir));
|
|
193
|
+
}
|
|
190
194
|
target.log.info(`Build bundle: ${target.name}`);
|
|
191
195
|
await target.build();
|
|
192
196
|
return target;
|
|
@@ -195,4 +199,3 @@ export async function build_app_composable_bundle(opts) {
|
|
|
195
199
|
bundle.log.info(`Prebuild bundle: ${opts.bundle.id}`);
|
|
196
200
|
}
|
|
197
201
|
}
|
|
198
|
-
//# sourceMappingURL=build-app-bundle.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Bundle, Workspace } from "../workspace/workspace.ts";
|
|
2
|
+
import { BuildTarget } from "./build-target.ts";
|
|
3
|
+
import { type BuildApplicationOptions } from "./build-application.ts";
|
|
4
|
+
import { type BundleID } from "../workspace/component.ts";
|
|
5
|
+
import { BuildTask } from "./helpers/task.ts";
|
|
6
|
+
export declare class ShelveManifestTask extends BuildTask {
|
|
7
|
+
readonly target: BuildTarget;
|
|
8
|
+
readonly bundles: Bundle[];
|
|
9
|
+
constructor(target: BuildTarget, bundles: Bundle[]);
|
|
10
|
+
execute(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare function build_app_composable_host(opts: BuildApplicationOptions): Promise<void>;
|
|
13
|
+
export declare class BundleSelector {
|
|
14
|
+
readonly workspace: Workspace;
|
|
15
|
+
readonly selected: Map<string, Bundle>;
|
|
16
|
+
readonly missing: BundleID[];
|
|
17
|
+
constructor(workspace: Workspace);
|
|
18
|
+
/** Add a bundle and recursively collect all its dependencies */
|
|
19
|
+
add(bundle: string | Bundle): this;
|
|
20
|
+
/** Check if the selector has any bundles */
|
|
21
|
+
get isEmpty(): boolean;
|
|
22
|
+
/** Get all selected bundles as an array in topological order (dependencies first) */
|
|
23
|
+
toArray(): Bundle[];
|
|
24
|
+
/** Get all selected bundle IDs */
|
|
25
|
+
getIds(): BundleID[];
|
|
26
|
+
/** Iterate over selected bundles */
|
|
27
|
+
[Symbol.iterator](): Iterator<Bundle>;
|
|
28
|
+
}
|
|
@@ -7,6 +7,7 @@ import { PWAPackageTask, WebviewTask } from "./build-application.js";
|
|
|
7
7
|
import { makeComponentPublication } from "../workspace/component.js";
|
|
8
8
|
import { topologicalSort } from "../utils/graph-ordering.js";
|
|
9
9
|
import { BuildTask } from "./helpers/task.js";
|
|
10
|
+
import { ArtifactZipTask } from "./helpers/emit-artifact.js";
|
|
10
11
|
export class ShelveManifestTask extends BuildTask {
|
|
11
12
|
target;
|
|
12
13
|
bundles;
|
|
@@ -45,11 +46,9 @@ export class ShelveManifestTask extends BuildTask {
|
|
|
45
46
|
}
|
|
46
47
|
function create_application_composable_target(opts) {
|
|
47
48
|
const { app, bundles, version } = opts;
|
|
48
|
-
const {
|
|
49
|
-
const lib = app
|
|
50
|
-
const
|
|
51
|
-
const ws = lib.workspace;
|
|
52
|
-
const target = new BuildTarget(name, opts.storage, ws, opts.devmode == true, opts.watch == true, opts.clean == true);
|
|
49
|
+
const { name, webviews, modules, components } = app.descriptor;
|
|
50
|
+
const { library: lib } = app;
|
|
51
|
+
const target = new BuildTarget(name, opts.storage, lib, opts.devmode == true, opts.watch == true, opts.clean == true, opts.onNotification);
|
|
53
52
|
// Prepare esm setup
|
|
54
53
|
target.esmodules.set_root(lib.path);
|
|
55
54
|
// Generate hotreload assets
|
|
@@ -70,7 +69,7 @@ function create_application_composable_target(opts) {
|
|
|
70
69
|
const entry_name = lib.make_file_id("webview", name);
|
|
71
70
|
const webview = {
|
|
72
71
|
...webviews[name],
|
|
73
|
-
entry: `./${
|
|
72
|
+
entry: `./${lib.master.id}/${entry_name}.js`,
|
|
74
73
|
favicon: favicon ? app.library.resolve_entry_path(favicon, Path.dirname(app.baseDir)) : null,
|
|
75
74
|
};
|
|
76
75
|
target.tasks.push(new WebviewTask(target, name, title || name, webview, html_injects));
|
|
@@ -82,7 +81,7 @@ function create_application_composable_target(opts) {
|
|
|
82
81
|
for (const name in modules) {
|
|
83
82
|
if (name.endsWith(".js")) {
|
|
84
83
|
const entry_name = lib.make_file_id("module", name.slice(0, -3));
|
|
85
|
-
target.esmodules.add_entry_typescript(`export * from "./${
|
|
84
|
+
target.esmodules.add_entry_typescript(`export * from "./${lib.master.id}/${entry_name}.js"`, name.slice(0, -3));
|
|
86
85
|
if (opts.devserver) {
|
|
87
86
|
target.log.info(`+ 🔌 module: ${name} : ${opts.devserver}/${name}`);
|
|
88
87
|
}
|
|
@@ -107,14 +106,14 @@ function create_application_composable_target(opts) {
|
|
|
107
106
|
}
|
|
108
107
|
}*/
|
|
109
108
|
// Add workspace assets
|
|
110
|
-
for (const
|
|
111
|
-
for (const [path, desc] of
|
|
109
|
+
for (const slib of lib.workspace.libraries) {
|
|
110
|
+
for (const [path, desc] of slib.declarations) {
|
|
112
111
|
if (!matchComponentSelection(components, desc.selectors))
|
|
113
112
|
continue;
|
|
114
113
|
if (desc.assets) {
|
|
115
114
|
const baseDir = Path.dirname(path);
|
|
116
115
|
for (const entry of desc.assets) {
|
|
117
|
-
target.assets.add_entry(entry, baseDir,
|
|
116
|
+
target.assets.add_entry(entry, baseDir, slib);
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
}
|
|
@@ -123,12 +122,11 @@ function create_application_composable_target(opts) {
|
|
|
123
122
|
}
|
|
124
123
|
export async function build_app_composable_host(opts) {
|
|
125
124
|
const { app, storage } = opts;
|
|
126
|
-
const
|
|
125
|
+
const { library: lib } = app;
|
|
127
126
|
opts.storage.clean();
|
|
128
|
-
const shelveBundles = new BundleSelector(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
shelveBundles.add(bundle);
|
|
127
|
+
const shelveBundles = new BundleSelector(lib.workspace);
|
|
128
|
+
if (lib.master)
|
|
129
|
+
shelveBundles.add(lib.master);
|
|
132
130
|
const shelvePendings = [];
|
|
133
131
|
for (const bundle of shelveBundles) {
|
|
134
132
|
shelvePendings.push(build_app_composable_bundle({
|
|
@@ -141,7 +139,7 @@ export async function build_app_composable_host(opts) {
|
|
|
141
139
|
}));
|
|
142
140
|
}
|
|
143
141
|
if (shelveBundles.missing.length > 0) {
|
|
144
|
-
|
|
142
|
+
lib.log.warn(`Missing bundle dependencies: ${shelveBundles.missing.join(", ")}`);
|
|
145
143
|
}
|
|
146
144
|
const target = create_application_composable_target({
|
|
147
145
|
app,
|
|
@@ -152,7 +150,11 @@ export async function build_app_composable_host(opts) {
|
|
|
152
150
|
devserver: opts.devserver,
|
|
153
151
|
watch: opts.devserver ? true : opts.watch,
|
|
154
152
|
clean: opts.clean,
|
|
153
|
+
onNotification: opts.onNotification,
|
|
155
154
|
});
|
|
155
|
+
if (opts.artifactDir) {
|
|
156
|
+
target.finalTasks.push(new ArtifactZipTask(target, opts.artifactDir, target.name));
|
|
157
|
+
}
|
|
156
158
|
target.log.info(`Build app: ${target.name}`);
|
|
157
159
|
return target.build();
|
|
158
160
|
}
|
|
@@ -187,8 +189,8 @@ export class BundleSelector {
|
|
|
187
189
|
if (bun.source) {
|
|
188
190
|
for (const depId in bun.source.descriptor?.dependencies) {
|
|
189
191
|
const lib = this.workspace.get_library(depId);
|
|
190
|
-
if (lib?.
|
|
191
|
-
this.add(lib.
|
|
192
|
+
if (lib?.master)
|
|
193
|
+
this.add(lib.master);
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
return this;
|
|
@@ -214,4 +216,3 @@ export class BundleSelector {
|
|
|
214
216
|
return this.toArray().values();
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
|
-
//# sourceMappingURL=build-app-host.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Sharp from "sharp";
|
|
2
|
+
import { type AppEntry, type ChromeAppManifest, type WebviewEntry } from "../workspace/workspace.ts";
|
|
3
|
+
import { StorageFiles } from "../workspace/storage.ts";
|
|
4
|
+
import { BuildTarget } from "./build-target.ts";
|
|
5
|
+
import type { WebAppManifest } from "web-app-manifest";
|
|
6
|
+
import { BuildTask } from "./helpers/task.ts";
|
|
7
|
+
import type { BuildNotification } from "./build-target.ts";
|
|
8
|
+
export type BuildApplicationOptions = {
|
|
9
|
+
app: AppEntry;
|
|
10
|
+
storage: StorageFiles;
|
|
11
|
+
version: string;
|
|
12
|
+
devmode?: boolean;
|
|
13
|
+
watch?: boolean;
|
|
14
|
+
clean?: boolean;
|
|
15
|
+
devserver?: string;
|
|
16
|
+
artifactDir?: string;
|
|
17
|
+
onNotification?: (event: BuildNotification) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare function create_application_monolith_target(opts: {
|
|
20
|
+
app: AppEntry;
|
|
21
|
+
storage: StorageFiles;
|
|
22
|
+
version: string;
|
|
23
|
+
devmode: boolean;
|
|
24
|
+
devserver?: string;
|
|
25
|
+
watch: boolean;
|
|
26
|
+
clean: boolean;
|
|
27
|
+
onNotification?: BuildApplicationOptions["onNotification"];
|
|
28
|
+
}): BuildTarget;
|
|
29
|
+
export declare function build_app_monolith(opts: BuildApplicationOptions): Promise<void>;
|
|
30
|
+
export declare function build_application(opts: BuildApplicationOptions): Promise<void>;
|
|
31
|
+
export declare class WebviewTask extends BuildTask {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly title: string;
|
|
34
|
+
readonly desc: WebviewEntry;
|
|
35
|
+
readonly html_injects: string[];
|
|
36
|
+
constructor(target: BuildTarget, name: string, title: string, desc: WebviewEntry, html_injects: string[]);
|
|
37
|
+
execute(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export declare class ChromePackageTask extends BuildTask {
|
|
40
|
+
readonly app: AppEntry;
|
|
41
|
+
readonly version: string;
|
|
42
|
+
constructor(target: BuildTarget, app: AppEntry, version: string);
|
|
43
|
+
execute(): Promise<void>;
|
|
44
|
+
createIcons(base: Sharp.Sharp): Promise<ChromeAppManifest["icons"]>;
|
|
45
|
+
}
|
|
46
|
+
export declare class PWAPackageTask extends BuildTask {
|
|
47
|
+
readonly app: AppEntry;
|
|
48
|
+
constructor(target: BuildTarget, app: AppEntry);
|
|
49
|
+
execute(): Promise<void>;
|
|
50
|
+
createIcons(base: Sharp.Sharp): Promise<WebAppManifest["icons"]>;
|
|
51
|
+
}
|
|
@@ -1,41 +1,20 @@
|
|
|
1
1
|
import Path from "node:path";
|
|
2
2
|
import Sharp from "sharp";
|
|
3
|
-
import MIME from
|
|
4
|
-
import {
|
|
3
|
+
import MIME from "mime";
|
|
4
|
+
import { Bundle, matchComponentSelection } from "../workspace/workspace.js";
|
|
5
5
|
import { StorageFiles } from "../workspace/storage.js";
|
|
6
6
|
import { BuildTarget } from "./build-target.js";
|
|
7
7
|
import { build_app_composable_host } from "./build-app-host.js";
|
|
8
8
|
import { DependencyDeduplicationPlugin } from "./helpers/emit-esmodules.js";
|
|
9
|
-
import {
|
|
9
|
+
import { ApplicationManifestTask } from "./helpers/emit-bundle-manifest.js";
|
|
10
10
|
import { BuildTask } from "./helpers/task.js";
|
|
11
|
-
|
|
12
|
-
const libs = [app.library];
|
|
13
|
-
function collect_library_deps(lib) {
|
|
14
|
-
const ws = lib.workspace;
|
|
15
|
-
const deps = {
|
|
16
|
-
...lib.descriptor.dependencies,
|
|
17
|
-
...lib.descriptor.peerDependencies,
|
|
18
|
-
...lib.descriptor.optionalDependencies,
|
|
19
|
-
};
|
|
20
|
-
for (const depId in deps) {
|
|
21
|
-
const lib = ws.get_library(depId);
|
|
22
|
-
if (lib && !libs.includes(lib)) {
|
|
23
|
-
libs.push(lib);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
for (let i = 0; i < libs.length; i++) {
|
|
28
|
-
collect_library_deps(libs[i]);
|
|
29
|
-
}
|
|
30
|
-
return libs;
|
|
31
|
-
}
|
|
11
|
+
import { ArtifactZipTask } from "./helpers/emit-artifact.js";
|
|
32
12
|
export function create_application_monolith_target(opts) {
|
|
33
13
|
const { app, version } = opts;
|
|
34
14
|
const { type, name, webviews, modules, assets, components } = app.descriptor;
|
|
35
|
-
const lib = app
|
|
36
|
-
const target = new BuildTarget(name, opts.storage, lib
|
|
37
|
-
|
|
38
|
-
target.log.info(`+ 🧭 app-library-graph: ${libs.map(lib => `${lib.name}@${lib.descriptor.version}`).join(", ")}`);
|
|
15
|
+
const { library: lib } = app;
|
|
16
|
+
const target = new BuildTarget(name, opts.storage, lib, opts.devmode == true, opts.watch == true, opts.clean == true, opts.onNotification);
|
|
17
|
+
target.log.info(`+ 📚 shelve: ${lib.shelve.map(b => b.id).join(", ")}`);
|
|
39
18
|
// Prepare esm setup
|
|
40
19
|
target.esmodules.set_root(lib.path);
|
|
41
20
|
// Generate hotreload assets
|
|
@@ -62,12 +41,12 @@ export function create_application_monolith_target(opts) {
|
|
|
62
41
|
for (const name in webviews) {
|
|
63
42
|
const { title, favicon, entry } = webviews[name];
|
|
64
43
|
const entry_name = lib.make_file_id("webview", name);
|
|
65
|
-
const entry_path =
|
|
44
|
+
const entry_path = lib.resolve_entry_path(entry, app.baseDir);
|
|
66
45
|
target.esmodules.add_entry(entry_name, entry_path);
|
|
67
46
|
const webview = {
|
|
68
47
|
...webviews[name],
|
|
69
48
|
entry: `./${entry_name}.js`,
|
|
70
|
-
favicon: favicon ?
|
|
49
|
+
favicon: favicon ? lib.resolve_entry_path(favicon, app.baseDir) : null,
|
|
71
50
|
};
|
|
72
51
|
target.tasks.push(new WebviewTask(target, name, title || name, webview, html_injects));
|
|
73
52
|
if (opts.devserver) {
|
|
@@ -76,7 +55,7 @@ export function create_application_monolith_target(opts) {
|
|
|
76
55
|
}
|
|
77
56
|
// Add application modules
|
|
78
57
|
for (const name in modules) {
|
|
79
|
-
const entry_path =
|
|
58
|
+
const entry_path = lib.resolve_entry_path(modules[name], app.baseDir);
|
|
80
59
|
if (!entry_path) {
|
|
81
60
|
target.log.error(`Invalid module '${name}' path at ${entry_path}`);
|
|
82
61
|
}
|
|
@@ -94,65 +73,62 @@ export function create_application_monolith_target(opts) {
|
|
|
94
73
|
// Add application static assets
|
|
95
74
|
if (Array.isArray(assets)) {
|
|
96
75
|
for (const asset of assets) {
|
|
97
|
-
target.assets.add_entry(asset, app.baseDir,
|
|
76
|
+
target.assets.add_entry(asset, app.baseDir, lib);
|
|
98
77
|
}
|
|
99
78
|
}
|
|
100
|
-
// Add
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
text: `${lib.name}@${lib.descriptor.version}`,
|
|
127
|
-
location: path,
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
});
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
const baseDir = Path.dirname(path);
|
|
134
|
-
target.add_component(desc, baseDir, lib);
|
|
135
|
-
added_components.set(cid, { lib, path });
|
|
136
|
-
}
|
|
79
|
+
// Add workspace components
|
|
80
|
+
const added_components = new Map();
|
|
81
|
+
for (const bundle of lib.shelve) {
|
|
82
|
+
for (const [path, desc] of bundle.components) {
|
|
83
|
+
if (!matchComponentSelection(components, desc.selectors))
|
|
84
|
+
continue;
|
|
85
|
+
const cid = desc.$id;
|
|
86
|
+
const added = added_components.get(cid);
|
|
87
|
+
if (added) {
|
|
88
|
+
target.log.error({
|
|
89
|
+
id: "duplicate-component-skip",
|
|
90
|
+
text: `skip duplicate component '${cid}'`,
|
|
91
|
+
notes: [
|
|
92
|
+
{
|
|
93
|
+
title: "kept",
|
|
94
|
+
text: `${added.bundle.id}`,
|
|
95
|
+
location: added.path,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
title: "skipped",
|
|
99
|
+
text: `${bundle.id}`,
|
|
100
|
+
location: path,
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
continue;
|
|
137
105
|
}
|
|
106
|
+
const baseDir = Path.dirname(path);
|
|
107
|
+
target.add_component(desc, baseDir, bundle);
|
|
108
|
+
added_components.set(cid, { bundle, path });
|
|
138
109
|
}
|
|
139
110
|
}
|
|
111
|
+
// Add bundle manifest
|
|
112
|
+
target.tasks.push(new ApplicationManifestTask(target, app.descriptor));
|
|
140
113
|
// Add workspace assets
|
|
141
|
-
for (const
|
|
142
|
-
|
|
114
|
+
for (const bundle of lib.shelve) {
|
|
115
|
+
if (!bundle.source)
|
|
116
|
+
continue;
|
|
117
|
+
for (const [path, desc] of bundle.source.declarations) {
|
|
143
118
|
if (!matchComponentSelection(components, desc.selectors))
|
|
144
119
|
continue;
|
|
145
120
|
if (desc.assets) {
|
|
146
121
|
const baseDir = Path.dirname(path);
|
|
147
122
|
for (const entry of desc.assets) {
|
|
148
|
-
target.assets.add_entry(entry, baseDir,
|
|
123
|
+
target.assets.add_entry(entry, baseDir, bundle.source);
|
|
149
124
|
}
|
|
150
125
|
}
|
|
151
126
|
}
|
|
152
127
|
}
|
|
153
128
|
// Register esbuild plugin for dependency deduplication (graph-based + singleton)
|
|
129
|
+
const bundleLibs = lib.shelve.map(b => b.source).filter(Boolean);
|
|
154
130
|
const rootNodeModules = lib.search_directories[0] || Path.join(lib.path, 'node_modules');
|
|
155
|
-
target.esmodules.plugins.push(DependencyDeduplicationPlugin(
|
|
131
|
+
target.esmodules.plugins.push(DependencyDeduplicationPlugin(bundleLibs, rootNodeModules, target.log));
|
|
156
132
|
return target;
|
|
157
133
|
}
|
|
158
134
|
export async function build_app_monolith(opts) {
|
|
@@ -166,7 +142,11 @@ export async function build_app_monolith(opts) {
|
|
|
166
142
|
devserver: opts.devserver,
|
|
167
143
|
watch: opts.devserver ? true : opts.watch,
|
|
168
144
|
clean: opts.clean,
|
|
145
|
+
onNotification: opts.onNotification,
|
|
169
146
|
});
|
|
147
|
+
if (opts.artifactDir) {
|
|
148
|
+
target.finalTasks.push(new ArtifactZipTask(target, opts.artifactDir, target.name));
|
|
149
|
+
}
|
|
170
150
|
target.log.info(`Build app: ${target.name}`);
|
|
171
151
|
return target.build();
|
|
172
152
|
}
|
|
@@ -312,4 +292,3 @@ function createIcon(base, size, format) {
|
|
|
312
292
|
.toFormat(format, { quality: 80 })
|
|
313
293
|
.toBuffer();
|
|
314
294
|
}
|
|
315
|
-
//# sourceMappingURL=build-application.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Library } from "../workspace/workspace.ts";
|
|
2
|
+
import { StorageFiles } from "../workspace/storage.ts";
|
|
3
|
+
import { BuildTarget } from "./build-target.ts";
|
|
4
|
+
export type BuildLibraryOptions = {
|
|
5
|
+
library: Library;
|
|
6
|
+
storage: StorageFiles;
|
|
7
|
+
version: string;
|
|
8
|
+
devmode: boolean;
|
|
9
|
+
watch: boolean;
|
|
10
|
+
clean: boolean;
|
|
11
|
+
artifactDir?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function create_library_target(opts: {
|
|
14
|
+
library: Library;
|
|
15
|
+
storage: StorageFiles;
|
|
16
|
+
version: string;
|
|
17
|
+
devmode: boolean;
|
|
18
|
+
watch: boolean;
|
|
19
|
+
clean: boolean;
|
|
20
|
+
}): BuildTarget;
|
|
21
|
+
export declare function build_library(opts: BuildLibraryOptions, packageDir?: string): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Path from "node:path";
|
|
2
|
-
import ChildProcess from "child_process";
|
|
2
|
+
import ChildProcess from "node:child_process";
|
|
3
3
|
import { Library } from "../workspace/workspace.js";
|
|
4
4
|
import { StorageFiles } from "../workspace/storage.js";
|
|
5
5
|
import { BuildTarget } from "./build-target.js";
|
|
@@ -8,13 +8,14 @@ import { PackageManifestTask } from "./helpers/emit-package-manifest.js";
|
|
|
8
8
|
import { create_export_map } from "../workspace/helpers/create-manifests.js";
|
|
9
9
|
import { BundleManifestTask } from "./helpers/emit-bundle-manifest.js";
|
|
10
10
|
import { ComponentsDtsTask } from "./helpers/emit-components-dts.js";
|
|
11
|
+
import { ArtifactNpmTask } from "./helpers/emit-artifact.js";
|
|
11
12
|
export function create_library_target(opts) {
|
|
12
13
|
const lib = opts.library;
|
|
13
|
-
const target = new BuildTarget(lib.name, opts.storage, lib
|
|
14
|
+
const target = new BuildTarget(lib.name, opts.storage, lib, opts.devmode == true, opts.watch == true, opts.clean == true);
|
|
14
15
|
// Prepare esm setup
|
|
15
16
|
target.esmodules.set_root(lib.path);
|
|
16
17
|
// Add bundle exporteds
|
|
17
|
-
const entries = create_export_map(lib, lib.
|
|
18
|
+
const entries = create_export_map(lib, lib.master);
|
|
18
19
|
for (const exp_id in entries) {
|
|
19
20
|
const exp = entries[exp_id];
|
|
20
21
|
target.esmodules.add_entry(exp.basename, exp.source);
|
|
@@ -23,16 +24,16 @@ export function create_library_target(opts) {
|
|
|
23
24
|
target.tasks.push(new TypescriptDefinitionTask(target, lib));
|
|
24
25
|
// Add library package.json
|
|
25
26
|
target.tasks.push(new PackageManifestTask(target, lib, opts.version));
|
|
26
|
-
target.tasks.push(new ComponentsDtsTask(target, lib.
|
|
27
|
+
target.tasks.push(new ComponentsDtsTask(target, lib.master));
|
|
27
28
|
// Add bundle content
|
|
28
|
-
const {
|
|
29
|
-
if (
|
|
29
|
+
const { master } = lib;
|
|
30
|
+
if (master) {
|
|
30
31
|
// Add bundle catalog
|
|
31
|
-
target.tasks.push(new BundleManifestTask(target,
|
|
32
|
+
target.tasks.push(new BundleManifestTask(target, master));
|
|
32
33
|
// Add library components
|
|
33
|
-
for (const [path, desc] of
|
|
34
|
+
for (const [path, desc] of master.components) {
|
|
34
35
|
const baseDir = Path.dirname(path);
|
|
35
|
-
target.add_component(desc, baseDir,
|
|
36
|
+
target.add_component(desc, baseDir, master);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
// Add declarations descriptors
|
|
@@ -70,10 +71,12 @@ export async function build_library(opts, packageDir) {
|
|
|
70
71
|
watch: opts.watch,
|
|
71
72
|
clean: opts.clean,
|
|
72
73
|
});
|
|
74
|
+
if (opts.artifactDir) {
|
|
75
|
+
target.finalTasks.push(new ArtifactNpmTask(target, opts.artifactDir));
|
|
76
|
+
}
|
|
73
77
|
target.log.info(`Build library: ${target.name}`);
|
|
74
78
|
await target.build();
|
|
75
79
|
if (!target.watch && packageDir) {
|
|
76
80
|
ChildProcess.execSync("npm pack --pack-destination " + packageDir, { cwd: target.storage.getBaseDirFS() });
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
|
-
//# sourceMappingURL=build-library.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ComponentManifest } from "../workspace/component.ts";
|
|
2
|
+
import { Bundle, Library } from "../workspace/workspace.ts";
|
|
3
|
+
import type { Log } from "../workspace/helpers/logger.ts";
|
|
4
|
+
import { ESModulesTask } from "./helpers/emit-esmodules.ts";
|
|
5
|
+
import { type IStorageTransaction, type IStorageZone } from "../workspace/storage.ts";
|
|
6
|
+
import { AssetsTask } from "./helpers/emit-static-assets.ts";
|
|
7
|
+
import type { BuildTask } from "./helpers/task.ts";
|
|
8
|
+
export type BuildNotification = {
|
|
9
|
+
target?: string;
|
|
10
|
+
task?: string;
|
|
11
|
+
} & ({
|
|
12
|
+
type: "build-complete";
|
|
13
|
+
elapsed: number;
|
|
14
|
+
});
|
|
15
|
+
export declare class BuildTarget {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly storage: IStorageZone;
|
|
18
|
+
readonly library: Library;
|
|
19
|
+
readonly devmode: boolean;
|
|
20
|
+
readonly watch: boolean;
|
|
21
|
+
readonly clean: boolean;
|
|
22
|
+
readonly onNotification?: (event: BuildNotification) => void;
|
|
23
|
+
components: Map<string, ComponentManifest>;
|
|
24
|
+
esmodules: ESModulesTask;
|
|
25
|
+
assets: AssetsTask;
|
|
26
|
+
tasks: BuildTask[];
|
|
27
|
+
finalTasks: BuildTask[];
|
|
28
|
+
transaction: IStorageTransaction;
|
|
29
|
+
readonly log: Log;
|
|
30
|
+
constructor(name: string, storage: IStorageZone, library: Library, devmode: boolean, watch: boolean, clean: boolean, onNotification?: (event: BuildNotification) => void);
|
|
31
|
+
edit(): IStorageTransaction;
|
|
32
|
+
store(): Promise<void>;
|
|
33
|
+
add_component(descriptor: ComponentManifest, baseDir: string, origin: Bundle): boolean;
|
|
34
|
+
private chrona;
|
|
35
|
+
build(): Promise<void>;
|
|
36
|
+
}
|