@skathi-native/cli 0.2.0 → 0.3.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/aot/host-globals.json +1 -1
- package/aot/pin.ts +1 -1
- package/aot/toolchain.lock.json +5 -5
- package/aot/transform.ts +9 -1
- package/build.ts +43 -4
- package/check/builtins.json +11 -11
- package/check/codes.ts +46 -0
- package/check/css-catalog.json +451 -0
- package/check/css.ts +512 -0
- package/check/finding.ts +63 -1
- package/check/graph.ts +11 -0
- package/check/index.ts +20 -48
- package/cli/aot-build.ts +2 -6
- package/cli/build-app.ts +19 -0
- package/cli/create.ts +44 -8
- package/cli/dev.ts +11 -6
- package/cli/effects.ts +39 -18
- package/cli/gallery.ts +106 -0
- package/cli/sk.ts +5 -2
- package/devtools/commands.ts +1 -1
- package/devtools/ctl.ts +4 -3
- package/effects/sk.slang +6 -1
- package/gallery.json +1 -0
- package/package.json +4 -3
- package/prod.ts +38 -3
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "git+https://github.com/argon-chat/skathi.git",
|
|
7
7
|
"directory": "packages/cli"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.3.0",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"files": [
|
|
12
12
|
"aot",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"check",
|
|
15
15
|
"effects",
|
|
16
16
|
"templates",
|
|
17
|
+
"gallery.json",
|
|
17
18
|
"devtools/apps.ts",
|
|
18
19
|
"devtools/commands.ts",
|
|
19
20
|
"devtools/ctl.ts",
|
|
@@ -34,12 +35,12 @@
|
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@clack/prompts": "^1.9.0",
|
|
36
37
|
"@commander-js/extra-typings": "~15.1.0",
|
|
37
|
-
"@skathi-native/runtime": "0.
|
|
38
|
+
"@skathi-native/runtime": "0.3.0",
|
|
38
39
|
"@vue/compiler-sfc": "^3.5.41",
|
|
39
40
|
"commander": "~15.1.0",
|
|
40
41
|
"postcss": "^8.4.31",
|
|
41
42
|
"tailwindcss": "3.4",
|
|
42
|
-
"typescript": "
|
|
43
|
+
"typescript": "6"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
package/prod.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// `sk build` (cli/build-app.ts) packs it into the SKPK payload.
|
|
7
7
|
// dist/window.json the `window` block of sk.config.json
|
|
8
8
|
// dist/assets.json [{ key, path }]: every file imported by URL, packed into the payload under key
|
|
9
|
+
// dist/styles.json { files, tailwind }: the files whose CSS the bundle includes, for sk build's CSS warnings
|
|
9
10
|
//
|
|
10
11
|
// Unlike build.ts: "vue" and "@skathi-native/runtime" alias to src/runtime.ts, inlineTemplate is true (no HMR),
|
|
11
12
|
// styles go to (globalThis.__SK_CSS__ ??= []) ahead of the bundle, no HMR epilogue.
|
|
@@ -19,7 +20,7 @@ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "
|
|
|
19
20
|
|
|
20
21
|
import { asciiOnly, checkAscii, nonAsciiCount } from "./ascii";
|
|
21
22
|
import { AotInputs, aotEngineIdentity } from "./aot-inputs";
|
|
22
|
-
import type { ModuleGraph } from "./check/graph";
|
|
23
|
+
import type { BuildStyles, ModuleGraph } from "./check/graph";
|
|
23
24
|
import { pruneVendorPrefixes } from "./css-prefixes";
|
|
24
25
|
import { SVELTE_SOURCE, compileSvelte } from "./svelte";
|
|
25
26
|
import {
|
|
@@ -83,6 +84,7 @@ const SK_CONFIG_DIR = appRootOverride ?? (APP_SRC_DIR.endsWith(`${sep}src`) ? di
|
|
|
83
84
|
const SK_CONFIG_PATH = configOverride ?? join(SK_CONFIG_DIR, "sk.config.json");
|
|
84
85
|
const WINDOW_JSON = join(dirname(OUT_FILE), "window.json");
|
|
85
86
|
const ASSETS_JSON = join(dirname(OUT_FILE), "assets.json");
|
|
87
|
+
const STYLES_JSON = join(dirname(OUT_FILE), "styles.json");
|
|
86
88
|
|
|
87
89
|
function readSkConfig(): Record<string, unknown> {
|
|
88
90
|
const path = SK_CONFIG_PATH;
|
|
@@ -237,9 +239,26 @@ const scopeIdOf = (id: string) => Bun.hash(id).toString(16).slice(0, 8);
|
|
|
237
239
|
const PROD_TEMPLATE_COMMENTS = false;
|
|
238
240
|
|
|
239
241
|
const cssById = new Map<string, string>();
|
|
242
|
+
/** Every .css file whose CSS the build includes, @imports too, and index.html when it has a `<style>`. */
|
|
243
|
+
const STYLE_FILES = new Set<string>();
|
|
244
|
+
/** The .vue and .svelte files whose `<style>` the build includes. */
|
|
245
|
+
const STYLED_COMPONENTS = new Set<string>();
|
|
246
|
+
|
|
247
|
+
function noteStyles(seen: Set<string>) {
|
|
248
|
+
for (const file of seen) if (/\.css$/i.test(file)) STYLE_FILES.add(file);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** An index.html `<style>` piece: noted as the page itself. */
|
|
252
|
+
function inlinePage(piece: CssPiece): boolean {
|
|
253
|
+
if (!piece.from.startsWith(`${INDEX_HTML}?`)) return false;
|
|
254
|
+
STYLE_FILES.add(INDEX_HTML);
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
240
257
|
|
|
241
258
|
async function viteCss(text: string, from: string, label: string): Promise<string> {
|
|
242
|
-
|
|
259
|
+
const seen = new Set([resolve(from)]);
|
|
260
|
+
let css = inlineCssImports(text, from, SK_CONFIG_DIR, advise, seen, ASSETS);
|
|
261
|
+
noteStyles(seen);
|
|
243
262
|
if (TW_CONFIG && needsTailwindPass(css)) {
|
|
244
263
|
try {
|
|
245
264
|
css = await generateTailwind(TW_CONFIG, { text: css, from: from.replace(/\?.*$/, "") });
|
|
@@ -322,6 +341,7 @@ async function compileVue(absPath: string, source: string): Promise<{ contents:
|
|
|
322
341
|
}
|
|
323
342
|
code = transformSource(code, absPath, SHAPES) ?? code;
|
|
324
343
|
|
|
344
|
+
STYLED_COMPONENTS.add(absPath);
|
|
325
345
|
const cssChunks: string[] = [];
|
|
326
346
|
for (const style of descriptor.styles) {
|
|
327
347
|
let text = style.content;
|
|
@@ -476,6 +496,7 @@ const vuePlugin = {
|
|
|
476
496
|
const out = await compileSvelte(APP_ROOT, args.path, source, { dev: false, filename: id });
|
|
477
497
|
AOT_INPUTS?.svelte(args.path, source, out.js);
|
|
478
498
|
for (const w of out.warnings) advise(w);
|
|
499
|
+
STYLED_COMPONENTS.add(args.path);
|
|
479
500
|
if (out.css) cssById.set(id, await viteCss(out.css, args.path, `${id} <style>`));
|
|
480
501
|
return { contents: transformSource(out.js, args.path, SHAPES) ?? out.js, loader: "js" as const };
|
|
481
502
|
});
|
|
@@ -575,6 +596,12 @@ async function writeGraph(out: string) {
|
|
|
575
596
|
});
|
|
576
597
|
bundle = { code: await code.text(), sources, mappings: raw.mappings };
|
|
577
598
|
}
|
|
599
|
+
for (const piece of LIFTED ? [...LIFTED.headCss, ...LIFTED.bodyCss] : []) {
|
|
600
|
+
if (inlinePage(piece)) continue;
|
|
601
|
+
const seen = new Set([resolve(piece.from)]);
|
|
602
|
+
inlineCssImports(piece.text, piece.from, SK_CONFIG_DIR, () => {}, seen);
|
|
603
|
+
noteStyles(seen);
|
|
604
|
+
}
|
|
578
605
|
const graph: ModuleGraph = {
|
|
579
606
|
schema: "skathi.module-graph",
|
|
580
607
|
version: 1,
|
|
@@ -588,6 +615,8 @@ async function writeGraph(out: string) {
|
|
|
588
615
|
},
|
|
589
616
|
declarations: [...new Bun.Glob("*.d.ts").scanSync({ cwd: RUNTIME_SRC_DIR, absolute: true })],
|
|
590
617
|
modules: [...modules].sort(),
|
|
618
|
+
styles: [...STYLE_FILES].sort(),
|
|
619
|
+
tailwind: TW_CONFIG !== null,
|
|
591
620
|
...(bundle ? { bundle } : {}),
|
|
592
621
|
errors: result.logs
|
|
593
622
|
.filter((log) => log.level === "error")
|
|
@@ -652,6 +681,7 @@ async function build() {
|
|
|
652
681
|
const htmlCss = async (pieces: CssPiece[]) => {
|
|
653
682
|
const out: string[] = [];
|
|
654
683
|
for (const p of pieces) {
|
|
684
|
+
inlinePage(p);
|
|
655
685
|
if (declaresUtilities(p.text)) appOwnsUtilities = true;
|
|
656
686
|
out.push(await viteCss(p.text, p.from, toId(p.from)));
|
|
657
687
|
}
|
|
@@ -691,8 +721,13 @@ async function build() {
|
|
|
691
721
|
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
692
722
|
.map(([key, path]) => ({ key, path }));
|
|
693
723
|
writeAtomic(ASSETS_JSON, JSON.stringify(assets, null, 2) + "\n");
|
|
724
|
+
const styles: BuildStyles = {
|
|
725
|
+
files: [...STYLED_COMPONENTS, ...STYLE_FILES].sort(),
|
|
726
|
+
tailwind: TW_CONFIG !== null,
|
|
727
|
+
};
|
|
728
|
+
writeAtomic(STYLES_JSON, JSON.stringify(styles, null, 2) + "\n");
|
|
694
729
|
if (AOT_INPUTS) {
|
|
695
|
-
const pinsPath = join(WS_ROOT, "vendor", "redjs", "pins.txt");
|
|
730
|
+
const pinsPath = join(WS_ROOT, "vendor", "redjs", "redjs", "pins.txt");
|
|
696
731
|
const engine = aotEngineIdentity(existsSync(pinsPath) ? readFileSync(pinsPath, "utf8") : null);
|
|
697
732
|
const manifest = AOT_INPUTS.write({
|
|
698
733
|
script: out,
|