@akanjs/cli 3.2.0-rc.9 → 3.3.0-rc.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/.build-stamp +2 -2
- package/CodeAgent-fx6088tv.js +11 -0
- package/{CodeTui-qstk5vpj.js → CodeTui-zee8atsr.js} +822 -666
- package/README.ko.md +7 -0
- package/README.md +7 -0
- package/TunnelShare-9ry4vh0y.js +18 -0
- package/agent.command-x65f2ags.js +61 -0
- package/akanCode.js +12 -12
- package/appExecutor-79azsb2w.js +11 -0
- package/{application.command-m4rq4wc2.js → application.command-azbd1pb2.js} +83 -37
- package/{applicationBuildRunner-df7rx3ra.js → applicationBuildRunner-trfxv3pd.js} +49 -18
- package/buildBatch.proc.js +25 -11
- package/{cloud.command-a0gy0qq2.js → cloud.command-gapp4634.js} +33 -29
- package/cloud.script-3b401efv.js +35 -0
- package/{code.command-5rsdqw8s.js → code.command-5smx61yf.js} +13 -9
- package/context.command-ym5jbkny.js +64 -0
- package/context.runner-kctbfsde.js +34 -0
- package/{dependencyScanner-78sq8m4q.js → dependencyScanner-ge10gb52.js} +2 -2
- package/{devTui-h77zrjv5.js → devTui-rf374y2w.js} +1 -1
- package/{fileSys-zpvt5gtf.js → fileSys-q22646yc.js} +1 -1
- package/{guideline.command-mffxknbr.js → guideline.command-zwypaqsh.js} +9 -5
- package/guidelines/agentRule/agentRule.instruction.md +25 -9
- package/guidelines/akanApi/akanApi.instruction.md +6 -4
- package/guidelines/conventions/core.md +23 -5
- package/guidelines/conventions/rules/app.md +4 -1
- package/guidelines/conventions/rules/page.md +5 -4
- package/guidelines/conventions/rules/ts.md +3 -3
- package/guidelines/errorCodes/errorCodes.instruction.md +165 -0
- package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
- package/guidelines/mcpRule/mcpRule.instruction.md +225 -5
- package/guidelines/pageRule/pageRule.instruction.md +10 -1
- package/guidelines/queryRule/queryRule.instruction.md +3 -1
- package/guidelines/runtimeRule/runtimeRule.instruction.md +14 -8
- package/guidelines/transportRule/transportRule.instruction.md +31 -1
- package/incrementalBuilder.proc.js +577 -411
- package/{index-w15mg3km.js → index-0dm25wvf.js} +1 -1
- package/{index-0gg15zwa.js → index-0s7w2085.js} +6 -6
- package/{index-hj6w4ka1.js → index-1p81ecbz.js} +1 -1
- package/{index-swwjakt0.js → index-275a4r3n.js} +11 -11
- package/{index-j6gc8n14.js → index-2jmvfa62.js} +11 -9
- package/{index-qd7xn2bk.js → index-2ny1e95c.js} +2 -2
- package/{index-exn38bzx.js → index-2yn3r67f.js} +116 -54
- package/{index-34792nh7.js → index-3txdtztz.js} +1 -1
- package/{index-28x1aszt.js → index-41a03gkj.js} +149 -53
- package/{index-2mf1aen9.js → index-4ss4gkv3.js} +2 -2
- package/{index-an76bdrv.js → index-612fdtbk.js} +1 -1
- package/{index-5radqwn2.js → index-67sd09ag.js} +12 -12
- package/{index-0hbtve0a.js → index-6dzjer7p.js} +32 -28
- package/{index-3ghdb7p5.js → index-71y6176j.js} +2777 -3676
- package/{index-xyn02k0w.js → index-78y75t0a.js} +662 -433
- package/index-7wf8snar.js +80 -0
- package/{index-skmtj8rm.js → index-8jtqfye2.js} +27 -10
- package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
- package/{index-nmvhjn8c.js → index-9wh04mqy.js} +93 -82
- package/{index-xvk2a75m.js → index-a860mx0m.js} +3 -3
- package/{index-5zwr4n6k.js → index-baccvws5.js} +65 -8
- package/{index-yf9wc28h.js → index-bejy9zyc.js} +1 -1
- package/{index-bns3wcpc.js → index-by2tvsq6.js} +1 -1
- package/{index-r0a604h4.js → index-c669pbyb.js} +5 -4
- package/{index-x40bdsca.js → index-dadwp2aw.js} +33 -98
- package/{index-vm0dn0mt.js → index-dmcpetwe.js} +200 -138
- package/{index-43f4h4cm.js → index-ebn9kgea.js} +6 -6
- package/{index-hqv34wzq.js → index-gt8phqpt.js} +10 -10
- package/{index-yckz5t8b.js → index-h901f24n.js} +516 -434
- package/{index-j3v29pq7.js → index-j0wr4e32.js} +219 -175
- package/{index-gcx48get.js → index-j592zfqc.js} +2 -2
- package/{index-grxs6fts.js → index-j6jjmn2r.js} +57 -31
- package/{index-w8yasvpc.js → index-jek2re5k.js} +2136 -2175
- package/{index-ny2k80mv.js → index-jf4vk1s0.js} +9 -2
- package/{index-gxav1bjz.js → index-k6vwww45.js} +9 -9
- package/{index-99qvtff2.js → index-kfvjzk8r.js} +5 -5
- package/{index-j6eeh5d7.js → index-knpm8sdm.js} +5 -5
- package/{index-2r9ff9qm.js → index-nc3br31y.js} +2 -2
- package/{index-35j83zkd.js → index-p5zh7pmc.js} +2 -2
- package/{index-cmg5ngqa.js → index-p7beqww9.js} +2 -2
- package/{index-b4qq3rq0.js → index-rwgqba9p.js} +1 -1
- package/{index-rfzp4pqs.js → index-s885g0jj.js} +3 -3
- package/{index-9p260r4e.js → index-trffs83s.js} +538 -250
- package/{index-k92x3vne.js → index-v7ajmsh3.js} +1 -1
- package/index-w1zexzpx.js +127 -0
- package/{index-h7hehkw6.js → index-xczjdng6.js} +3 -1
- package/{index-39jz41jb.js → index-xs9a3ddt.js} +3 -3
- package/{index-rp4yf32g.js → index-xwwex8rf.js} +36 -29
- package/{index-ra9fvn7s.js → index-ybcb9wc8.js} +74 -38
- package/index-z92zm3wd.js +788 -0
- package/{index-j9790rhk.js → index-z96ks033.js} +1509 -1121
- package/index-zfnz878d.js +30 -0
- package/{index-2vgv7fs7.js → index-zmd9xxgd.js} +727 -693
- package/{index-ygdbn9jn.js → index-zyb0ebm4.js} +1 -1
- package/index.js +28 -24
- package/libExecutor-jc6f8hm6.js +10 -0
- package/{library.command-bmd7zc5m.js → library.command-nxvesvhb.js} +12 -5
- package/{localRegistry.command-y6en1599.js → localRegistry.command-xz62e4ng.js} +29 -24
- package/{module.command-7exfffqw.js → module.command-aaws9byg.js} +11 -7
- package/{package.command-adskw2rj.js → package.command-j7hv26p0.js} +14 -10
- package/package.json +8 -8
- package/{page.command-dw01272p.js → page.command-7yffs7n9.js} +8 -4
- package/{pipeline.command-0b1r3y5r.js → pipeline.command-7yk0zcng.js} +15 -9
- package/pkgExecutor-arxmvx4t.js +10 -0
- package/{primitive.command-byw6vc04.js → primitive.command-7a1pt715.js} +12 -8
- package/{projectTypecheck-kkrpq60a.js → projectTypecheck-f4qhbecd.js} +1 -1
- package/{prompter-qrwx1p17.js → prompter-qyggfhqd.js} +2 -2
- package/{quality.command-6rqnhzct.js → quality.command-c6mvrjh1.js} +25 -16
- package/{recipeScanner-4b69ybe0.js → recipeScanner-rrx69awy.js} +1 -1
- package/{repair.command-rw5zymak.js → repair.command-093adzt9.js} +12 -8
- package/{routeSourceValidator-4h947v7c.js → routeSourceValidator-8n6j1vn7.js} +4 -2
- package/{scalar.command-2dyp9nh9.js → scalar.command-2ex84spb.js} +10 -6
- package/skills/akan-debug/SKILL.md +8 -5
- package/skills/akan-err/SKILL.md +7 -0
- package/skills/akan-mcp/SKILL.md +19 -1
- package/skills/akan-scaffold/SKILL.md +1 -1
- package/skills/akan-validate/SKILL.md +3 -3
- package/{subspace.command-111ynwv1.js → subspace.command-4n4n4jpv.js} +32 -24
- package/templates/app/page/_layout.tsx +13 -0
- package/templates/app/page/styles.css.template +40 -0
- package/templates/appSample/page/_index.tsx +9 -9
- package/templates/appSample/page/_layout.tsx +1 -0
- package/templates/appSample/page/styles.css.template +40 -5
- package/templates/appSample/ui/Recipe/jellyButton.ts +1 -1
- package/templates/biomeForm.ts +1 -1
- package/templates/env/_env.server.type.ts +1 -1
- package/templates/facetIndex/index.ts +2 -37
- package/templates/lib/sig.ts +0 -4
- package/templates/lib/useClient.ts +1 -1
- package/templates/workspaceRoot/.devcontainer/devcontainer.json.template +1 -1
- package/templates/workspaceRoot/AGENTS.md.template +2 -1
- package/templates/workspaceRoot/README.ts +4 -2
- package/{tunnel.command-2gcpfbdj.js → tunnel.command-f7ep1qfa.js} +17 -13
- package/{typeChecker-s640r6c0.js → typeChecker-7jt6abrs.js} +1 -1
- package/typecheck.proc.js +3 -2
- package/{verify.command-djgs86ma.js → verify.command-zrkxnvct.js} +21 -17
- package/{workflow.command-n0k2mxr5.js → workflow.command-ks16jegk.js} +21 -14
- package/{workspace.command-fh1qwxfx.js → workspace.command-ahhfpaag.js} +60 -54
- package/CodeAgent-x2p3a3e0.js +0 -11
- package/TunnelShare-c4xsfzg5.js +0 -15
- package/agent.command-9et2e27p.js +0 -52
- package/cloud.script-xze4zh7n.js +0 -31
- package/context.command-rk1dwrg4.js +0 -57
- package/context.runner-83ky5m1b.js +0 -30
- /package/templates/{appSample → app}/public/fonts/Pretendard-Bold.woff2 +0 -0
- /package/templates/{appSample → app}/public/fonts/Pretendard-Medium.woff2 +0 -0
- /package/templates/{appSample → app}/public/fonts/Pretendard-Regular.woff2 +0 -0
- /package/templates/{appSample → app}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
JsonFormatter
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-71y6176j.js";
|
|
5
5
|
|
|
6
|
-
// pkgs/@akanjs/devkit/maintainabilityBaseline.ts
|
|
6
|
+
// pkgs/@akanjs/devkit/quality/maintainabilityBaseline.ts
|
|
7
7
|
class MaintainabilityBaseline {
|
|
8
8
|
sections;
|
|
9
9
|
reasons;
|
|
@@ -19,8 +19,12 @@ class MaintainabilityBaseline {
|
|
|
19
19
|
"akan.store.root-write-chain",
|
|
20
20
|
"akan.component.write-chain",
|
|
21
21
|
"akan.write.placement",
|
|
22
|
-
"akan.service.call-in-loop"
|
|
22
|
+
"akan.service.call-in-loop",
|
|
23
|
+
"akan.error.bare-error"
|
|
23
24
|
];
|
|
25
|
+
static lateRules = new Set(["akan.error.bare-error"]);
|
|
26
|
+
static totalRules = new Set(["akan.error.bare-error"]);
|
|
27
|
+
static totalKey = "(total)";
|
|
24
28
|
static reasonedRules = new Set([
|
|
25
29
|
"akan.size.file",
|
|
26
30
|
"akan.size.component",
|
|
@@ -40,6 +44,8 @@ class MaintainabilityBaseline {
|
|
|
40
44
|
return violation.writeCount;
|
|
41
45
|
if (violation.kind === "writePlacement")
|
|
42
46
|
return violation.writes.length;
|
|
47
|
+
if (violation.kind === "bareError")
|
|
48
|
+
return violation.lines.length;
|
|
43
49
|
return violation.calls.length;
|
|
44
50
|
}
|
|
45
51
|
static isDebtRule(name) {
|
|
@@ -97,6 +103,21 @@ class MaintainabilityBaseline {
|
|
|
97
103
|
const recorded = this.recordedOf(violation);
|
|
98
104
|
return recorded !== undefined && MaintainabilityBaseline.countOf(violation) <= recorded;
|
|
99
105
|
}
|
|
106
|
+
unallowed(violations) {
|
|
107
|
+
const measured = MaintainabilityBaseline.of(violations);
|
|
108
|
+
return violations.filter((violation) => !(MaintainabilityBaseline.totalRules.has(violation.rule) && measured.totalOf(violation.rule) <= this.totalOf(violation.rule)) && !this.allows(violation));
|
|
109
|
+
}
|
|
110
|
+
staleTotals(violations) {
|
|
111
|
+
const measured = MaintainabilityBaseline.of(violations);
|
|
112
|
+
return [...MaintainabilityBaseline.totalRules].flatMap((rule) => {
|
|
113
|
+
const count = measured.totalOf(rule);
|
|
114
|
+
const recorded = this.totalOf(rule);
|
|
115
|
+
return count < recorded ? [{ rule, count, recorded }] : [];
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
totalOf(rule) {
|
|
119
|
+
return [...this.sections.get(rule)?.values() ?? []].reduce((sum, count) => sum + count, 0);
|
|
120
|
+
}
|
|
100
121
|
recordedOf(violation) {
|
|
101
122
|
return this.sections.get(violation.rule)?.get(violation.key);
|
|
102
123
|
}
|
|
@@ -114,19 +135,55 @@ class MaintainabilityBaseline {
|
|
|
114
135
|
}))
|
|
115
136
|
]));
|
|
116
137
|
}
|
|
138
|
+
rulesOutside(other) {
|
|
139
|
+
return [...this.sections].filter(([rule, counts]) => counts.size && (other === null || MaintainabilityBaseline.lateRules.has(rule) && !other.sections.has(rule))).map(([rule]) => rule);
|
|
140
|
+
}
|
|
141
|
+
withSectionsOf(other, rules) {
|
|
142
|
+
if (!other)
|
|
143
|
+
return this;
|
|
144
|
+
const sections = new Map(this.sections);
|
|
145
|
+
for (const rule of rules)
|
|
146
|
+
sections.set(rule, other.sections.get(rule) ?? new Map);
|
|
147
|
+
return new MaintainabilityBaseline(sections, this.reasons);
|
|
148
|
+
}
|
|
149
|
+
movedBy(moves) {
|
|
150
|
+
if (!moves.size)
|
|
151
|
+
return this;
|
|
152
|
+
const movedKey = (key) => {
|
|
153
|
+
const file = key.split("#", 1)[0] ?? key;
|
|
154
|
+
const to = moves.get(file);
|
|
155
|
+
return to === undefined ? key : `${to}${key.slice(file.length)}`;
|
|
156
|
+
};
|
|
157
|
+
const sections = new Map([...this.sections].map(([rule, counts]) => {
|
|
158
|
+
const moved = new Map;
|
|
159
|
+
for (const [key, count] of counts) {
|
|
160
|
+
const to = movedKey(key);
|
|
161
|
+
moved.set(to, Math.max(moved.get(to) ?? 0, count));
|
|
162
|
+
}
|
|
163
|
+
return [rule, moved];
|
|
164
|
+
}));
|
|
165
|
+
return new MaintainabilityBaseline(sections, new Map([...this.reasons].map(([key, reason]) => [movedKey(key), reason])));
|
|
166
|
+
}
|
|
117
167
|
tightenedBy(violations) {
|
|
118
168
|
const current = MaintainabilityBaseline.of(violations);
|
|
119
|
-
const sections = new Map([...this.sections].map(([rule, counts]) =>
|
|
120
|
-
rule
|
|
121
|
-
MaintainabilityBaseline
|
|
122
|
-
|
|
169
|
+
const sections = new Map([...this.sections].map(([rule, counts]) => {
|
|
170
|
+
const measured = current.sections.get(rule) ?? new Map;
|
|
171
|
+
if (!MaintainabilityBaseline.totalRules.has(rule))
|
|
172
|
+
return [rule, MaintainabilityBaseline.#lowered(counts, measured)];
|
|
173
|
+
return [rule, current.totalOf(rule) > this.totalOf(rule) ? counts : measured];
|
|
174
|
+
}));
|
|
123
175
|
return new MaintainabilityBaseline(sections).#withReasonsOf(this.reasons);
|
|
124
176
|
}
|
|
125
177
|
#withReasonsOf(reasons) {
|
|
126
178
|
return new MaintainabilityBaseline(this.sections, new Map([...reasons].filter(([key]) => this.#holdsReasoned(key))));
|
|
127
179
|
}
|
|
128
180
|
grownFrom(committed) {
|
|
129
|
-
return [...this.sections].flatMap(([rule, counts]) => MaintainabilityBaseline.#raised(counts, committed.sections.get(rule) ?? new Map).filter(([key]) => !(MaintainabilityBaseline.reasonedRules.has(rule) && this.reasonOf(key))).map(([key, count, recorded]) => ({ rule, key, count, committed: recorded })));
|
|
181
|
+
return [...this.sections].flatMap(([rule, counts]) => MaintainabilityBaseline.totalRules.has(rule) ? this.#totalGrownFrom(committed, rule) : MaintainabilityBaseline.#raised(counts, committed.sections.get(rule) ?? new Map).filter(([key]) => !(MaintainabilityBaseline.reasonedRules.has(rule) && this.reasonOf(key))).map(([key, count, recorded]) => ({ rule, key, count, committed: recorded })));
|
|
182
|
+
}
|
|
183
|
+
#totalGrownFrom(committed, rule) {
|
|
184
|
+
const count = this.totalOf(rule);
|
|
185
|
+
const recorded = committed.sections.has(rule) ? committed.totalOf(rule) : undefined;
|
|
186
|
+
return count > (recorded ?? 0) ? [{ rule, key: MaintainabilityBaseline.totalKey, count, committed: recorded }] : [];
|
|
130
187
|
}
|
|
131
188
|
stringify() {
|
|
132
189
|
const sections = MaintainabilityBaseline.debtRules.flatMap((rule) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// pkgs/@akanjs/devkit/typeChecker.ts
|
|
2
|
+
// pkgs/@akanjs/devkit/typecheck/typeChecker.ts
|
|
3
3
|
import { readFileSync } from "fs";
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
import chalk from "chalk";
|
|
@@ -132,12 +132,13 @@ ${summary.join(", ")} found${output.join(`
|
|
|
132
132
|
return false;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
static checkProject(configPath) {
|
|
135
|
+
static checkProject(configPath, overrides = {}) {
|
|
136
136
|
const parsedConfig = TypeChecker2.parseConfig(configPath);
|
|
137
|
-
const
|
|
137
|
+
const options = { ...parsedConfig.options, ...overrides };
|
|
138
|
+
const host = ts.createIncrementalCompilerHost(options);
|
|
138
139
|
const builderProgram = ts.createIncrementalProgram({
|
|
139
140
|
rootNames: parsedConfig.fileNames,
|
|
140
|
-
options
|
|
141
|
+
options,
|
|
141
142
|
projectReferences: parsedConfig.projectReferences,
|
|
142
143
|
configFileParsingDiagnostics: parsedConfig.errors,
|
|
143
144
|
host
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ROOT_LAYOUT_SYSTEM,
|
|
4
4
|
isImplicitRootLayoutKey,
|
|
5
5
|
resolveSsrPageEntriesForApp
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-z92zm3wd.js";
|
|
7
7
|
import {
|
|
8
8
|
computeRouteSeedIndex,
|
|
9
9
|
saveRouteSeedIndex,
|
|
@@ -11,12 +11,11 @@ import {
|
|
|
11
11
|
ClientEntriesBundler,
|
|
12
12
|
VENDOR_SPECIFIERS,
|
|
13
13
|
RouteClientBuilder
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-jek2re5k.js";
|
|
15
15
|
import {
|
|
16
16
|
SOURCE_EXTS,
|
|
17
|
-
FontOptimizer
|
|
18
|
-
|
|
19
|
-
} from "./index-vm0dn0mt.js";
|
|
17
|
+
FontOptimizer
|
|
18
|
+
} from "./index-dmcpetwe.js";
|
|
20
19
|
import {
|
|
21
20
|
BarrelAnalyzer,
|
|
22
21
|
createTsconfigPackageResolver,
|
|
@@ -24,7 +23,7 @@ import {
|
|
|
24
23
|
CsrEntryFiles,
|
|
25
24
|
toClientReferencePath,
|
|
26
25
|
PagesBundleBuilder
|
|
27
|
-
} from "./index-
|
|
26
|
+
} from "./index-9wh04mqy.js";
|
|
28
27
|
import {
|
|
29
28
|
CssBlockParser
|
|
30
29
|
} from "./index-62md4dwy.js";
|
|
@@ -734,76 +733,12 @@ function declaredCustomProperties(css) {
|
|
|
734
733
|
function getPageKeyBasePath(pageKey, basePaths) {
|
|
735
734
|
return CsrEntryFiles.basePathOfPageKey(pageKey, basePaths);
|
|
736
735
|
}
|
|
737
|
-
// pkgs/@akanjs/devkit/frontendBuild/precompressArtifacts.ts
|
|
738
|
-
import fs from "fs";
|
|
739
|
-
import path4 from "path";
|
|
740
|
-
import zlib from "zlib";
|
|
741
|
-
var COMPRESSIBLE_EXTS = new Set([".css", ".html", ".js", ".json", ".svg"]);
|
|
742
|
-
var MIN_COMPRESS_BYTES = 1024;
|
|
743
|
-
var MAX_BROTLI_QUALITY = 11;
|
|
744
|
-
var BROTLI_QUALITY_BY_EXT = { ".css": MAX_BROTLI_QUALITY };
|
|
745
|
-
var DEFAULT_BROTLI_QUALITY = 9;
|
|
746
|
-
var GZIP_LEVEL = 9;
|
|
747
|
-
var { formatBytes } = FontPruner;
|
|
748
|
-
async function precompressArtifacts(app) {
|
|
749
|
-
const artifactDir = path4.join(app.dist.cwdPath, ".akan/artifact");
|
|
750
|
-
const roots = [
|
|
751
|
-
{ root: path4.join(artifactDir, "client") },
|
|
752
|
-
{ root: path4.join(artifactDir, "styles") },
|
|
753
|
-
{ root: path4.join(artifactDir, "dict"), brotliQuality: MAX_BROTLI_QUALITY }
|
|
754
|
-
];
|
|
755
|
-
const result = { files: 0, inputBytes: 0, outputBytes: 0, brotliBytes: 0 };
|
|
756
|
-
await Promise.all(roots.map(({ root, brotliQuality }) => precompressRoot(root, result, brotliQuality)));
|
|
757
|
-
if (result.files > 0) {
|
|
758
|
-
app.verbose(`[precompress] wrote ${result.files} sidecars (${formatBytes(result.inputBytes)} -> gzip ${formatBytes(result.outputBytes)} / br ${formatBytes(result.brotliBytes)})`);
|
|
759
|
-
}
|
|
760
|
-
return result;
|
|
761
|
-
}
|
|
762
|
-
async function precompressRoot(root, result, brotliQuality) {
|
|
763
|
-
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory())
|
|
764
|
-
return;
|
|
765
|
-
const glob = new Bun.Glob("**/*");
|
|
766
|
-
for await (const filePath of glob.scan({ cwd: root, absolute: true })) {
|
|
767
|
-
if (!await shouldPrecompress(filePath))
|
|
768
|
-
continue;
|
|
769
|
-
const bytes = await Bun.file(filePath).bytes();
|
|
770
|
-
const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
771
|
-
const gz = Bun.gzipSync(buffer, { level: GZIP_LEVEL });
|
|
772
|
-
const br = brotliCompress(buffer, brotliQuality ?? brotliQualityOf(path4.extname(filePath).toLowerCase()));
|
|
773
|
-
await Promise.all([Bun.write(`${filePath}.gz`, gz), Bun.write(`${filePath}.br`, br)]);
|
|
774
|
-
result.files += 1;
|
|
775
|
-
result.inputBytes += bytes.byteLength;
|
|
776
|
-
result.outputBytes += gz.byteLength;
|
|
777
|
-
result.brotliBytes += br.byteLength;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
function brotliQualityOf(ext) {
|
|
781
|
-
return BROTLI_QUALITY_BY_EXT[ext] ?? DEFAULT_BROTLI_QUALITY;
|
|
782
|
-
}
|
|
783
|
-
function brotliCompress(buffer, quality) {
|
|
784
|
-
return zlib.brotliCompressSync(buffer, {
|
|
785
|
-
params: {
|
|
786
|
-
[zlib.constants.BROTLI_PARAM_QUALITY]: quality,
|
|
787
|
-
[zlib.constants.BROTLI_PARAM_SIZE_HINT]: buffer.byteLength
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
async function shouldPrecompress(filePath) {
|
|
792
|
-
if (filePath.endsWith(".gz") || filePath.endsWith(".br"))
|
|
793
|
-
return false;
|
|
794
|
-
if (!COMPRESSIBLE_EXTS.has(path4.extname(filePath).toLowerCase()))
|
|
795
|
-
return false;
|
|
796
|
-
const file = Bun.file(filePath);
|
|
797
|
-
if (!await file.exists())
|
|
798
|
-
return false;
|
|
799
|
-
return file.size >= MIN_COMPRESS_BYTES;
|
|
800
|
-
}
|
|
801
736
|
// pkgs/@akanjs/devkit/frontendBuild/ssrBaseArtifactBuilder.ts
|
|
802
|
-
import
|
|
737
|
+
import path6 from "path";
|
|
803
738
|
import { optimize } from "@tailwindcss/node";
|
|
804
739
|
|
|
805
740
|
// pkgs/@akanjs/devkit/frontendBuild/dictionaryAssetBuilder.ts
|
|
806
|
-
import
|
|
741
|
+
import path4 from "path";
|
|
807
742
|
import { Translator } from "akanjs/client";
|
|
808
743
|
|
|
809
744
|
class DictionaryAssetBuilder {
|
|
@@ -823,7 +758,7 @@ class DictionaryAssetBuilder {
|
|
|
823
758
|
return Object.fromEntries(assets);
|
|
824
759
|
}
|
|
825
760
|
async#loadAllDictionary() {
|
|
826
|
-
const dictPath =
|
|
761
|
+
const dictPath = path4.resolve(this.#app.cwdPath, "lib", "dict.ts");
|
|
827
762
|
if (!await Bun.file(dictPath).exists())
|
|
828
763
|
return null;
|
|
829
764
|
const { getAllDictionary } = await import(dictPath);
|
|
@@ -833,7 +768,7 @@ class DictionaryAssetBuilder {
|
|
|
833
768
|
const source = DictionaryAssetBuilder.source(lang, dictionary);
|
|
834
769
|
const name = `${lang}-${Bun.hash(source).toString(36)}.js`;
|
|
835
770
|
const relPath = `dict/${name}`;
|
|
836
|
-
await Bun.write(
|
|
771
|
+
await Bun.write(path4.join(this.#absArtifactDir, relPath), source);
|
|
837
772
|
return [lang, { url: `${DictionaryAssetBuilder.urlPrefix}/${name}`, relPath }];
|
|
838
773
|
}
|
|
839
774
|
static source(lang, dictionary) {
|
|
@@ -844,8 +779,8 @@ export default JSON.parse(${JSON.stringify(JSON.stringify(dictionary))});
|
|
|
844
779
|
}
|
|
845
780
|
|
|
846
781
|
// pkgs/@akanjs/devkit/frontendBuild/vendorNarrowing.ts
|
|
847
|
-
import
|
|
848
|
-
import
|
|
782
|
+
import fs from "fs";
|
|
783
|
+
import path5 from "path";
|
|
849
784
|
var deprecatedReexports = { "akanjs/store": "store/deprecatedAgent.ts" };
|
|
850
785
|
|
|
851
786
|
class VendorNarrowing {
|
|
@@ -854,12 +789,12 @@ class VendorNarrowing {
|
|
|
854
789
|
static entriesIn(akanServerPath) {
|
|
855
790
|
return VENDOR_SPECIFIERS.map((specifier) => ({
|
|
856
791
|
specifier,
|
|
857
|
-
absPath:
|
|
858
|
-
})).filter(({ absPath }) =>
|
|
792
|
+
absPath: path5.resolve(akanServerPath, "vendor", `${specifier.replaceAll("/", "-").replaceAll(".", "-")}.ts`)
|
|
793
|
+
})).filter(({ absPath }) => fs.existsSync(absPath));
|
|
859
794
|
}
|
|
860
795
|
constructor(akanjsRoot, vendorExports) {
|
|
861
796
|
this.#akanjsRoot = akanjsRoot;
|
|
862
|
-
const current = Object.values(deprecatedReexports).every((file) =>
|
|
797
|
+
const current = Object.values(deprecatedReexports).every((file) => fs.existsSync(path5.join(akanjsRoot, file)));
|
|
863
798
|
this.#vendorExports = current ? vendorExports : {};
|
|
864
799
|
}
|
|
865
800
|
entryExports(vendorEntries) {
|
|
@@ -874,7 +809,7 @@ class VendorNarrowing {
|
|
|
874
809
|
const used = this.#vendorExports[specifier];
|
|
875
810
|
if (!used)
|
|
876
811
|
continue;
|
|
877
|
-
const source = await Bun.file(
|
|
812
|
+
const source = await Bun.file(path5.join(this.#akanjsRoot, file)).text();
|
|
878
813
|
const names = new Bun.Transpiler({ loader: "ts" }).scan(source).exports;
|
|
879
814
|
if (!names.some((name) => used.includes(name)))
|
|
880
815
|
blanked.push(`akanjs/${file}`);
|
|
@@ -917,7 +852,7 @@ class SsrBaseArtifactBuilder {
|
|
|
917
852
|
this.#serverEnv = serverEnv;
|
|
918
853
|
this.#vendorExports = vendorExports;
|
|
919
854
|
this.#artifactDir = `${command === "build" ? app.dist.cwdPath : app.cwdPath}/.akan/artifact`;
|
|
920
|
-
this.#absArtifactDir =
|
|
855
|
+
this.#absArtifactDir = path6.resolve(this.#artifactDir);
|
|
921
856
|
}
|
|
922
857
|
static servedWeb(command, web) {
|
|
923
858
|
return command === "start" ? { ssr: true, csr: true } : web;
|
|
@@ -944,7 +879,7 @@ class SsrBaseArtifactBuilder {
|
|
|
944
879
|
vendorMap,
|
|
945
880
|
cssAssets,
|
|
946
881
|
dictAssets,
|
|
947
|
-
pagesBundlePath: this.#command === "build" ?
|
|
882
|
+
pagesBundlePath: this.#command === "build" ? path6.relative(this.#absArtifactDir, pagesBundle.bundlePath) : pagesBundle.bundlePath,
|
|
948
883
|
pagesBundleBuildId: pagesBundle.buildId,
|
|
949
884
|
domains: [...akanConfig.domains],
|
|
950
885
|
subRoutes: Object.fromEntries(Array.from(akanConfig.subRoutes.entries()).map(([basePath, domains]) => [basePath, [...domains]])),
|
|
@@ -962,18 +897,18 @@ class SsrBaseArtifactBuilder {
|
|
|
962
897
|
androidSha256CertFingerprints: target.android?.sha256CertFingerprints
|
|
963
898
|
}))
|
|
964
899
|
};
|
|
965
|
-
await Bun.write(
|
|
900
|
+
await Bun.write(path6.join(this.#absArtifactDir, "base-artifact.json"), `${JSON.stringify(artifact, null, 2)}
|
|
966
901
|
`);
|
|
967
902
|
this.#app.verbose(`[base-artifact] complete in ${Date.now() - this.#started}ms`);
|
|
968
903
|
return { artifact, seedIndex, cssCompiler, optimizedFonts, runtimeChunks };
|
|
969
904
|
}
|
|
970
905
|
async#buildRuntimeClientEntries() {
|
|
971
906
|
const akanServerPath = await this.#resolveAkanServerPath();
|
|
972
|
-
const rscClientEntry =
|
|
973
|
-
const rscSegmentOutletEntry =
|
|
907
|
+
const rscClientEntry = path6.resolve(akanServerPath, "rscClient.tsx");
|
|
908
|
+
const rscSegmentOutletEntry = path6.resolve(akanServerPath, "rscSegmentOutlet.tsx");
|
|
974
909
|
const vendorEntries = VendorNarrowing.entriesIn(akanServerPath);
|
|
975
910
|
const entries = [rscClientEntry, rscSegmentOutletEntry, ...vendorEntries.map((v) => v.absPath)];
|
|
976
|
-
const narrowing = new VendorNarrowing(
|
|
911
|
+
const narrowing = new VendorNarrowing(path6.dirname(akanServerPath), this.#vendorExports);
|
|
977
912
|
const clientBundle = await new ClientEntriesBundler({
|
|
978
913
|
app: this.#app,
|
|
979
914
|
entries,
|
|
@@ -1024,15 +959,15 @@ class SsrBaseArtifactBuilder {
|
|
|
1024
959
|
async#resolveAkanServerPath() {
|
|
1025
960
|
const candidates = [];
|
|
1026
961
|
try {
|
|
1027
|
-
candidates.push(
|
|
962
|
+
candidates.push(path6.dirname(Bun.resolveSync("akanjs/server", this.#app.workspace.workspaceRoot)));
|
|
1028
963
|
} catch {}
|
|
1029
|
-
candidates.push(
|
|
964
|
+
candidates.push(path6.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server"), path6.join(this.#app.workspace.workspaceRoot, "node_modules/akanjs/server"));
|
|
1030
965
|
try {
|
|
1031
|
-
candidates.push(
|
|
966
|
+
candidates.push(path6.dirname(Bun.resolveSync("akanjs/server", path6.dirname(Bun.main))));
|
|
1032
967
|
} catch {}
|
|
1033
|
-
candidates.push(
|
|
968
|
+
candidates.push(path6.join(path6.dirname(Bun.main), "node_modules/akanjs/server"), path6.join(path6.dirname(Bun.main), "../../akanjs/server"), path6.resolve(import.meta.dir, "../../server"), path6.resolve(import.meta.dir, "../server"));
|
|
1034
969
|
for (const candidate of candidates) {
|
|
1035
|
-
if (await Bun.file(
|
|
970
|
+
if (await Bun.file(path6.join(candidate, "rscClient.tsx")).exists())
|
|
1036
971
|
return candidate;
|
|
1037
972
|
}
|
|
1038
973
|
throw new Error(`[base-artifact] failed to locate akanjs/server; looked in: ${candidates.join(", ")}`);
|
|
@@ -1061,7 +996,7 @@ ${preparedCssText}`).toString(36);
|
|
|
1061
996
|
`styles/${cssAssetName}-${cssHash}.css`,
|
|
1062
997
|
`/_akan/styles/${cssAssetName}-${cssHash}.css`
|
|
1063
998
|
];
|
|
1064
|
-
await Bun.write(
|
|
999
|
+
await Bun.write(path6.join(this.#absArtifactDir, cssRelPath), preparedCssText);
|
|
1065
1000
|
SsrBaseArtifactBuilder.#warnDroppedImports(this.#app, cssRelPath, preparedCssText, imported);
|
|
1066
1001
|
this.#app.verbose(`[base-artifact] wrote ${preparedCssText.length} bytes of CSS for ${basePath} -> ${cssRelPath}`);
|
|
1067
1002
|
return [basePath, { cssUrl, cssRelPath }];
|
|
@@ -1078,8 +1013,8 @@ ${preparedCssText}`).toString(36);
|
|
|
1078
1013
|
}
|
|
1079
1014
|
}
|
|
1080
1015
|
// pkgs/@akanjs/devkit/frontendBuild/vendorImportScanner.ts
|
|
1081
|
-
import
|
|
1082
|
-
import
|
|
1016
|
+
import fs2 from "fs";
|
|
1017
|
+
import path7 from "path";
|
|
1083
1018
|
import ts from "typescript";
|
|
1084
1019
|
|
|
1085
1020
|
class VendorImportScanner {
|
|
@@ -1094,10 +1029,10 @@ class VendorImportScanner {
|
|
|
1094
1029
|
static async exportsUsedIn(dir, specifiers, entryUrls) {
|
|
1095
1030
|
const scanner = new VendorImportScanner(specifiers);
|
|
1096
1031
|
const scanned = [];
|
|
1097
|
-
if (
|
|
1032
|
+
if (fs2.existsSync(dir))
|
|
1098
1033
|
for await (const relative of new Bun.Glob("**/*.js").scan({ cwd: dir })) {
|
|
1099
|
-
scanner.scan(await Bun.file(
|
|
1100
|
-
scanned.push(`/${relative.split(
|
|
1034
|
+
scanner.scan(await Bun.file(path7.join(dir, relative)).text(), relative);
|
|
1035
|
+
scanned.push(`/${relative.split(path7.sep).join("/")}`);
|
|
1101
1036
|
}
|
|
1102
1037
|
const unread = [...new Set(entryUrls)].filter((url) => !scanned.some((relative) => url.endsWith(relative)));
|
|
1103
1038
|
if (unread.length > 0) {
|
|
@@ -1172,4 +1107,4 @@ class VendorImportScanner {
|
|
|
1172
1107
|
this.#names.get(specifier)?.add(name);
|
|
1173
1108
|
}
|
|
1174
1109
|
}
|
|
1175
|
-
export { AllRoutesBuilder, CssCompiler,
|
|
1110
|
+
export { AllRoutesBuilder, CssCompiler, SsrBaseArtifactBuilder, VendorImportScanner };
|