@akanjs/cli 2.4.1-rc.1 → 2.4.1-rc.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.
Files changed (25) hide show
  1. package/agent.command-h4afc69n.js +1 -1
  2. package/{application.command-47mj9qsy.js → application.command-jkmbsd1x.js} +1 -1
  3. package/{applicationBuildRunner-yz144508.js → applicationBuildRunner-ny84tjhc.js} +1 -1
  4. package/buildBatch.proc.js +175 -0
  5. package/{cloud.command-qgjxja3n.js → cloud.command-53j76grx.js} +6 -6
  6. package/{context.command-nqbtak4f.js → context.command-ds3mka9p.js} +9 -9
  7. package/incrementalBuilder.proc.js +249 -151
  8. package/{index-z9gvz7b0.js → index-0hjg9qs5.js} +7 -7
  9. package/{index-qhtr07v8.js → index-1fpjvqhs.js} +13 -13
  10. package/{index-sgmas1fc.js → index-dynknvzd.js} +3 -3
  11. package/{index-73pr2cmy.js → index-m9pca6jv.js} +1 -1
  12. package/{index-wq8jwx8z.js → index-n6h3482q.js} +161 -6
  13. package/{index-a5rmdgy4.js → index-q7zcac6n.js} +1403 -1405
  14. package/{index-77crfweb.js → index-rgfxj6qc.js} +176 -10
  15. package/index.js +10 -10
  16. package/{localRegistry.command-p1pgxw78.js → localRegistry.command-25sv5hmt.js} +4 -4
  17. package/{module.command-qrj3kmyz.js → module.command-tnj2bzst.js} +2 -2
  18. package/{package.command-r8sq5kzp.js → package.command-5x5m0ej1.js} +1 -1
  19. package/package.json +2 -2
  20. package/{primitive.command-pv9ssmtf.js → primitive.command-q1ycj5vr.js} +3 -3
  21. package/{scalar.command-kabkd6wd.js → scalar.command-bmrmp8n4.js} +2 -2
  22. package/{workflow.command-64r6cw0w.js → workflow.command-64550hka.js} +5 -5
  23. package/{workspace.command-xk68sd6c.js → workspace.command-pmfxxfew.js} +16 -16
  24. package/{index-8pkbzj26.js → index-fmky5k3p.js} +3 -3
  25. package/{index-y3hdhy4p.js → index-gb26e7z0.js} +3 -3
@@ -3,8 +3,8 @@ import {
3
3
  AgentScript
4
4
  } from "./index-hwzpw9c1.js";
5
5
  import"./index-8rc0bm04.js";
6
- import"./index-qaq13qk3.js";
7
6
  import"./index-h6ca6qg0.js";
7
+ import"./index-qaq13qk3.js";
8
8
  import {
9
9
  Workspace,
10
10
  command
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  ApplicationScript
4
- } from "./index-77crfweb.js";
4
+ } from "./index-rgfxj6qc.js";
5
5
  import {
6
6
  getMobileTargetChoices
7
7
  } from "./index-76rn3g2c.js";
@@ -4,7 +4,7 @@ import {
4
4
  CsrArtifactBuilder,
5
5
  SsrBaseArtifactBuilder,
6
6
  precompressArtifacts
7
- } from "./index-a5rmdgy4.js";
7
+ } from "./index-q7zcac6n.js";
8
8
  import {
9
9
  Spinner
10
10
  } from "./index-6pz1j0zj.js";
@@ -0,0 +1,175 @@
1
+ // @bun
2
+ import {
3
+ AppExecutor,
4
+ WorkspaceExecutor
5
+ } from "./index-a6sbyy0b.js";
6
+ import"./index-61keag0s.js";
7
+ import {
8
+ CsrArtifactBuilder,
9
+ CssCompiler,
10
+ FontOptimizer,
11
+ PagesBundleBuilder
12
+ } from "./index-q7zcac6n.js";
13
+ import"./index-6pz1j0zj.js";
14
+ import"./index-r24hmh0q.js";
15
+
16
+ // pkgs/@akanjs/devkit/incrementalBuilder/buildBatch.proc.ts
17
+ import path from "path";
18
+ import { Logger } from "akanjs/common";
19
+
20
+ class BuildBatch {
21
+ #logger = new Logger("BuildBatch");
22
+ #request;
23
+ #app;
24
+ #result;
25
+ constructor(request, app) {
26
+ this.#request = request;
27
+ this.#app = app;
28
+ this.#result = { generation: request.generation, errors: {} };
29
+ }
30
+ async run() {
31
+ if (this.#request.needs.includes("csr"))
32
+ await this.#buildCsr();
33
+ if (this.#request.needs.includes("pages"))
34
+ await this.#buildPages();
35
+ if (this.#request.needs.includes("css"))
36
+ await this.#buildCss();
37
+ return this.#result;
38
+ }
39
+ #emit(message) {
40
+ process.send?.(message);
41
+ }
42
+ #emitStatus(phase, message) {
43
+ this.#emit({
44
+ type: "build-status",
45
+ data: {
46
+ generation: this.#request.generation,
47
+ phase,
48
+ ok: !message,
49
+ files: this.#request.changedFiles,
50
+ message
51
+ }
52
+ });
53
+ }
54
+ async#buildCsr() {
55
+ const started = Date.now();
56
+ try {
57
+ await new CsrArtifactBuilder(this.#app).build();
58
+ this.#logger.verbose(`csr-rebundle ok (${Date.now() - started}ms)`);
59
+ this.#emitStatus("csr");
60
+ } catch (err) {
61
+ const message = err instanceof Error ? err.message : String(err);
62
+ this.#logger.error(`csr-rebundle failed: ${message}`);
63
+ this.#result.errors.csr = message;
64
+ this.#emitStatus("csr", message);
65
+ }
66
+ }
67
+ async#buildPages() {
68
+ const started = Date.now();
69
+ try {
70
+ const next = await new PagesBundleBuilder(this.#app).build();
71
+ this.#emit({
72
+ type: "pages-updated",
73
+ data: {
74
+ bundlePath: next.bundlePath,
75
+ buildId: next.buildId,
76
+ generation: this.#request.generation,
77
+ changedFiles: this.#request.changedFiles
78
+ }
79
+ });
80
+ this.#emitStatus("pages");
81
+ this.#logger.verbose(`pages-rebundle ok buildId=${next.buildId} (${Date.now() - started}ms)`);
82
+ } catch (err) {
83
+ const message = err instanceof Error ? err.message : String(err);
84
+ this.#logger.error(`pages-rebundle failed: ${message}`);
85
+ this.#result.errors.pages = message;
86
+ this.#emitStatus("pages", message);
87
+ }
88
+ }
89
+ async#buildCss() {
90
+ const started = Date.now();
91
+ try {
92
+ const cssByBasePath = await new CssCompiler(this.#app).getCssByBasePath({ refresh: true });
93
+ const optimizedFonts = await this.#optimizeFonts();
94
+ const cssAssetEntries = [];
95
+ const cssBase64ByUrl = {};
96
+ await Promise.all(Object.entries(cssByBasePath).map(async ([basePath, baseCssText]) => {
97
+ const cssText = [baseCssText, optimizedFonts.css].filter(Boolean).join(`
98
+ `);
99
+ if (!cssText)
100
+ return;
101
+ const cssAssetName = basePath || "root";
102
+ const cssHash = Bun.hash(`${basePath}
103
+ ${cssText}`).toString(36);
104
+ const cssRelPath = `styles/${cssAssetName}-${cssHash}.css`;
105
+ const cssUrl = `/_akan/styles/${cssAssetName}-${cssHash}.css`;
106
+ await Bun.write(path.join(this.#request.artifactDir, cssRelPath), cssText);
107
+ cssAssetEntries.push([basePath, { cssUrl, cssRelPath }]);
108
+ cssBase64ByUrl[cssUrl] = Buffer.from(new TextEncoder().encode(cssText)).toString("base64");
109
+ }));
110
+ const cssAssets = Object.fromEntries(cssAssetEntries);
111
+ this.#result.cssAssets = cssAssets;
112
+ this.#emitStatus("css");
113
+ if (JSON.stringify(this.#request.cssAssets ?? {}) === JSON.stringify(cssAssets)) {
114
+ this.#logger.verbose("css-rebuild unchanged assets; broadcast skipped");
115
+ return;
116
+ }
117
+ this.#emit({
118
+ type: "css-updated",
119
+ data: {
120
+ cssAssets,
121
+ cssBase64ByUrl,
122
+ generation: this.#request.generation,
123
+ changedFiles: this.#request.changedFiles
124
+ }
125
+ });
126
+ this.#logger.verbose(`css-compile ok assets=${Object.keys(cssAssets).length} (${Date.now() - started}ms)`);
127
+ } catch (err) {
128
+ const message = err instanceof Error ? err.message : String(err);
129
+ this.#logger.error(`css-rebuild failed: ${message}`);
130
+ this.#result.errors.css = message;
131
+ this.#emitStatus("css", message);
132
+ }
133
+ }
134
+ async#optimizeFonts() {
135
+ const previous = this.#request.optimizedFonts;
136
+ if (previous && !BuildBatch.#shouldReoptimizeFonts(previous, this.#request.changedFiles)) {
137
+ this.#logger.verbose(`font-optimize cached files=${previous.files.length}`);
138
+ return previous;
139
+ }
140
+ const started = Date.now();
141
+ const optimizedFonts = await new FontOptimizer(this.#app, "start").optimize();
142
+ this.#result.optimizedFonts = optimizedFonts;
143
+ this.#logger.verbose(`font-optimize ok files=${optimizedFonts.files.length} (${Date.now() - started}ms)`);
144
+ return optimizedFonts;
145
+ }
146
+ static #shouldReoptimizeFonts(previous, changedFiles) {
147
+ if (changedFiles.length === 0)
148
+ return false;
149
+ return changedFiles.some((file) => {
150
+ const normalized = path.resolve(file);
151
+ if (/\.(woff2?|ttf|otf)$/i.test(normalized))
152
+ return true;
153
+ return previous.files.some((fontFile) => path.resolve(fontFile) === normalized);
154
+ });
155
+ }
156
+ static async main() {
157
+ const raw = process.argv[2];
158
+ if (!raw)
159
+ throw new Error("[build-batch] missing request argument");
160
+ const request = JSON.parse(raw);
161
+ const workspace = WorkspaceExecutor.fromRoot({
162
+ workspaceRoot: request.workspaceRoot,
163
+ repoName: request.repoName
164
+ });
165
+ const app = AppExecutor.from(workspace, request.appName);
166
+ if (request.pageKeys)
167
+ app.setPageKeys(request.pageKeys);
168
+ const result = await new BuildBatch(request, app).run();
169
+ process.send?.({ type: "build-batch-result", data: result });
170
+ }
171
+ }
172
+ BuildBatch.main().catch((err) => {
173
+ console.error(err);
174
+ process.exit(1);
175
+ });
@@ -1,15 +1,15 @@
1
1
  // @bun
2
2
  import {
3
3
  CloudScript
4
- } from "./index-z9gvz7b0.js";
5
- import"./index-sgmas1fc.js";
6
- import"./index-77crfweb.js";
7
- import"./index-76rn3g2c.js";
8
- import"./index-pmm9e2jf.js";
9
- import"./index-wq8jwx8z.js";
4
+ } from "./index-0hjg9qs5.js";
5
+ import"./index-dynknvzd.js";
10
6
  import {
11
7
  GlobalConfig
12
8
  } from "./index-5vvwc0cz.js";
9
+ import"./index-rgfxj6qc.js";
10
+ import"./index-76rn3g2c.js";
11
+ import"./index-pmm9e2jf.js";
12
+ import"./index-n6h3482q.js";
13
13
  import {
14
14
  Workspace,
15
15
  command
@@ -1,20 +1,20 @@
1
1
  // @bun
2
2
  import {
3
3
  ContextScript
4
- } from "./index-qhtr07v8.js";
5
- import"./index-45aj5ry0.js";
6
- import"./index-y3hdhy4p.js";
7
- import"./index-73pr2cmy.js";
4
+ } from "./index-1fpjvqhs.js";
8
5
  import"./index-85msc0wg.js";
9
- import"./index-1xdrsbry.js";
10
- import"./index-8rc0bm04.js";
11
- import"./index-76rn3g2c.js";
12
- import"./index-8pkbzj26.js";
6
+ import"./index-45aj5ry0.js";
7
+ import"./index-gb26e7z0.js";
8
+ import"./index-m9pca6jv.js";
9
+ import"./index-fmky5k3p.js";
13
10
  import"./index-swf4bmbg.js";
14
11
  import"./index-ss469dec.js";
15
- import"./index-qaq13qk3.js";
12
+ import"./index-1xdrsbry.js";
13
+ import"./index-8rc0bm04.js";
16
14
  import"./index-h6ca6qg0.js";
15
+ import"./index-qaq13qk3.js";
17
16
  import"./index-5vvwc0cz.js";
17
+ import"./index-76rn3g2c.js";
18
18
  import {
19
19
  Workspace,
20
20
  command