@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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "table": "4750b3540882158b35c1f7cc946edc1acb18561345bc70f9151fb913e59268b8",
2
+ "table": "a9db25bde548594d86b2439e8dfd11335a87004ee374a31e2d1a557c40543886",
3
3
  "names": [
4
4
  "$vm",
5
5
  "AbortController",
package/aot/pin.ts CHANGED
@@ -45,7 +45,7 @@ export function pinnedCompilerInfo(pin: ToolchainPin): CompilerInfo {
45
45
  frontend: pin.frontend.revision,
46
46
  engine: pin.engine.revision,
47
47
  tableId: pin.table.id,
48
- compileOptions: `x86_64;references=narrow;image=pic;threads=1;admit=FilesRunByHost;default-options@${pin.engine.revision}`,
48
+ compileOptions: `x86_64;references=narrow;image=pic;threads=1;default-options@${pin.engine.revision}`,
49
49
  };
50
50
  }
51
51
 
@@ -3,15 +3,15 @@
3
3
  "version": 1,
4
4
  "target": "x86_64-windows",
5
5
  "frontend": {
6
- "revision": "7ca0042d3ba23ed60fd9cd8af1a1ce6ec3f8d074",
6
+ "revision": "237bba51e98a8b3d5b62d2d6c33853c2e83820a7",
7
7
  "sourceRepository": "https://github.com/oven-sh/bun.git"
8
8
  },
9
9
  "engine": {
10
- "revision": "4d45755fed4aeef19e95beb90d3d0c884a2812bd",
11
- "archiveSha256": "fd79937b7f8becd5c0961646cd7f8af4409122e9cf710ffd766dc0c89df1f619"
10
+ "revision": "3bc94211496460feda299ef85eef710eb67fafb3",
11
+ "archiveSha256": "837f06ecd569791d4497ea7e8703f636fac5a1869ca5ee7c5f49b4c4eaa40e3d"
12
12
  },
13
13
  "table": {
14
- "id": "4750b3540882158b35c1f7cc946edc1acb18561345bc70f9151fb913e59268b8",
15
- "dumpSha256": "afac4f15bc41518c037d80965fed1c53edd36b96837602cab40660b3a0f5beb2"
14
+ "id": "a9db25bde548594d86b2439e8dfd11335a87004ee374a31e2d1a557c40543886",
15
+ "dumpSha256": "b379cd1e35c090880b6b4ae4fdbdab9b1566a06c829e3e9d6824ac7aaa11cdc7"
16
16
  }
17
17
  }
package/aot/transform.ts CHANGED
@@ -64,6 +64,14 @@ export function opaqueGlobals(tableGlobals: readonly string[] = HOST_TABLE.names
64
64
  return [...new Set([...tableGlobals, ...BROWSER_GLOBALS])].sort();
65
65
  }
66
66
 
67
+ /** A builtin global stays read-only unless the image spells out an assignment to it; writes through
68
+ * `__sk_host` (the runtime wraps setTimeout and WebSocket) are not spelled out, so this dead branch is. */
69
+ function openHostGlobals(names: readonly string[]): string {
70
+ const host = new Set(HOST_TABLE.names);
71
+ const opened = names.filter((name) => host.has(name));
72
+ return `if (__SK_AOT_HOST__ === undefined) {\n${opened.map((name) => `globalThis.${name} = undefined;`).join("\n")}\n}\n`;
73
+ }
74
+
67
75
  export function opaqueHost(source: string, names: readonly string[] = opaqueGlobals()): string {
68
- return `// ${TRANSFORM}: stable host API references are opaque inputs.\n(function(__sk_host) {\nconst globalThis = __sk_host;\nconst {${names.join(",")}} = __sk_host;\n${source}\n})(__SK_AOT_HOST__);\n`;
76
+ return `// ${TRANSFORM}: stable host API references are opaque inputs.\n${openHostGlobals(names)}(function(__sk_host) {\nconst globalThis = __sk_host;\nconst {${names.join(",")}} = __sk_host;\n${source}\n})(__SK_AOT_HOST__);\n`;
69
77
  }
package/build.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  //
4
4
  // dist/vendor.js IIFE: @vue/runtime-core + src/runtime.ts + src/loader.ts.
5
5
  // dist/modules/<enc>.js one classic script per app module; <enc> is the id with "/" -> "__".
6
- // dist/manifest.json { rev, vendorRev, entry, modules, deps }
6
+ // dist/manifest.json { rev, vendorRev, entry, appRoot, modules, deps }
7
7
  // dist/changes.json { rev, vendorRev, changed: [{ id, kind }] }
8
8
  //
9
9
  // Module ids are workspace-relative POSIX paths. Change kind: script or <style> scoped/module/lang
@@ -54,6 +54,9 @@ import {
54
54
  viteShapesPlugin,
55
55
  } from "./vitecompat";
56
56
  import { colorEnabled, paint } from "./cli/term";
57
+ import { parseCheckConfig } from "./check/config";
58
+ import { CssWarnings } from "./check/css";
59
+ import { diagnosticLine } from "./check/finding";
57
60
  import { SVELTE_SOURCE, compileSvelte } from "./svelte";
58
61
 
59
62
  const C = paint(colorEnabled(process.stdout));
@@ -391,8 +394,18 @@ function devAdvise(m: string) {
391
394
  warn(`${stamp()} advisory: ${m}`);
392
395
  }
393
396
 
397
+ /** Every .css file the dev build has read, @imports too: what the CSS warnings watch. */
398
+ const styleSheets = new Set<string>();
399
+
400
+ function inlineImports(text: string, from: string): string {
401
+ const seen = new Set([resolve(from)]);
402
+ const css = inlineCssImports(text, from, SK_CONFIG_DIR, devAdvise, seen);
403
+ for (const file of seen) if (/\.css$/i.test(file)) styleSheets.add(file);
404
+ return css;
405
+ }
406
+
394
407
  async function viteCss(text: string, from: string, label: string): Promise<string> {
395
- const css = inlineCssImports(text, from, SK_CONFIG_DIR, devAdvise);
408
+ const css = inlineImports(text, from);
396
409
  if (!TW_CONFIG || !needsTailwindPass(css)) return css;
397
410
  try {
398
411
  return await generateTailwind(TW_CONFIG, { text: css, from });
@@ -501,6 +514,18 @@ const vuePlugin = {
501
514
  const source = await Bun.file(args.path).text();
502
515
  return compileVue(args.path, source);
503
516
  });
517
+ // A package's Svelte components (the runtime's `<SkWindow>`, a component library), compiled as the app's are,
518
+ // without HMR: a package module is rebuilt whole.
519
+ build.onLoad({ filter: SVELTE_SOURCE }, async (args: Bun.OnLoadArgs) => {
520
+ const id = toId(args.path);
521
+ const out = await compileSvelte(APP_ROOT, args.path, await Bun.file(args.path).text(), {
522
+ dev: false,
523
+ filename: id,
524
+ });
525
+ for (const w of out.warnings) devAdvise(w);
526
+ if (out.css) devAdvise(`${id}: a package component's <style> is applied by sk build, not by sk dev`);
527
+ return { contents: out.js, loader: "js" as const };
528
+ });
504
529
  },
505
530
  };
506
531
 
@@ -684,7 +709,7 @@ const cssIds = () => Array.from(cssModules.keys());
684
709
  */
685
710
  async function buildCssModule(id: string): Promise<boolean> {
686
711
  const abs = cssModules.get(id)!;
687
- let css = inlineCssImports(readFileSync(abs, "utf-8"), abs, SK_CONFIG_DIR, devAdvise);
712
+ let css = inlineImports(readFileSync(abs, "utf-8"), abs);
688
713
  if (TW_CONFIG && needsTailwindPass(css)) {
689
714
  const t0 = Date.now();
690
715
  try {
@@ -1233,6 +1258,7 @@ function writeManifest(files: string[]) {
1233
1258
  rev,
1234
1259
  vendorRev,
1235
1260
  entry: toId(ENTRY_ABS),
1261
+ appRoot: appRootArg ? APP_ROOT : SK_CONFIG_DIR,
1236
1262
  name: readAppName(),
1237
1263
  modules: ids,
1238
1264
  assetFiles: Object.fromEntries(
@@ -1362,7 +1388,19 @@ async function incrementalBuild() {
1362
1388
  );
1363
1389
  }
1364
1390
 
1365
- await fullBuild("startup").catch((e) => {
1391
+ const cssWarnings = new CssWarnings({
1392
+ root: appRootArg ? APP_ROOT : SK_CONFIG_DIR,
1393
+ allow: parseCheckConfig(readSkConfig()?.check).allow,
1394
+ tailwind: TW_CONFIG !== null,
1395
+ });
1396
+
1397
+ /** CSS the engine does not apply, in the styles that changed; each warning once per session. */
1398
+ function reportCss() {
1399
+ const components = [...prevBlocks.keys()].filter((f) => /\.(vue|svelte)$/i.test(f));
1400
+ for (const d of cssWarnings.update([...components, ...styleSheets])) warn(`${stamp()} ${diagnosticLine(d)}`);
1401
+ }
1402
+
1403
+ await fullBuild("startup").then(reportCss, (e) => {
1366
1404
  console.error(e);
1367
1405
  if (!WATCH) process.exit(1);
1368
1406
  });
@@ -1382,6 +1420,7 @@ if (WATCH) {
1382
1420
  try {
1383
1421
  if (full) await fullBuild("runtime source changed");
1384
1422
  else await incrementalBuild();
1423
+ reportCss();
1385
1424
  } catch (e) {
1386
1425
  fail(`${stamp()} ${String(e)}`);
1387
1426
  }
@@ -1,6 +1,6 @@
1
1
  {
2
- "table": "4750b3540882158b35c1f7cc946edc1acb18561345bc70f9151fb913e59268b8",
3
- "engine": "4d45755fed4aeef19e95beb90d3d0c884a2812bd",
2
+ "table": "a9db25bde548594d86b2439e8dfd11335a87004ee374a31e2d1a557c40543886",
3
+ "engine": "3bc94211496460feda299ef85eef710eb67fafb3",
4
4
  "locked": [
5
5
  "AggregateError.prototype",
6
6
  "Array",
@@ -997,7 +997,8 @@
997
997
  "WeakRef.prototype.deref",
998
998
  "WebAssembly",
999
999
  "WebAssembly.CompileError",
1000
- "WebAssembly.CompileError.prototype.constructor",
1000
+ "WebAssembly.CompileError.prototype.message",
1001
+ "WebAssembly.CompileError.prototype.name",
1001
1002
  "WebAssembly.Exception",
1002
1003
  "WebAssembly.Exception.prototype.getArg",
1003
1004
  "WebAssembly.Exception.prototype.is",
@@ -1009,7 +1010,8 @@
1009
1010
  "WebAssembly.Instance.prototype.exports",
1010
1011
  "WebAssembly.JSTag",
1011
1012
  "WebAssembly.LinkError",
1012
- "WebAssembly.LinkError.prototype.constructor",
1013
+ "WebAssembly.LinkError.prototype.message",
1014
+ "WebAssembly.LinkError.prototype.name",
1013
1015
  "WebAssembly.Memory",
1014
1016
  "WebAssembly.Memory.prototype.buffer",
1015
1017
  "WebAssembly.Memory.prototype.grow",
@@ -1020,9 +1022,11 @@
1020
1022
  "WebAssembly.Module.exports",
1021
1023
  "WebAssembly.Module.imports",
1022
1024
  "WebAssembly.RuntimeError",
1023
- "WebAssembly.RuntimeError.prototype.constructor",
1025
+ "WebAssembly.RuntimeError.prototype.message",
1026
+ "WebAssembly.RuntimeError.prototype.name",
1024
1027
  "WebAssembly.SuspendError",
1025
- "WebAssembly.SuspendError.prototype.constructor",
1028
+ "WebAssembly.SuspendError.prototype.message",
1029
+ "WebAssembly.SuspendError.prototype.name",
1026
1030
  "WebAssembly.Suspending",
1027
1031
  "WebAssembly.Table",
1028
1032
  "WebAssembly.Table.prototype.get",
@@ -1050,7 +1054,7 @@
1050
1054
  "parseInt",
1051
1055
  "unescape"
1052
1056
  ],
1053
- "lockedObjects": ["Object.prototype", "Promise.prototype", "RegExp.prototype"],
1057
+ "lockedObjects": ["Object.prototype"],
1054
1058
  "objects": [
1055
1059
  "AggregateError",
1056
1060
  "AggregateError.prototype",
@@ -1187,7 +1191,6 @@
1187
1191
  "WebAssembly",
1188
1192
  "WebAssembly.CompileError",
1189
1193
  "WebAssembly.CompileError.prototype",
1190
- "WebAssembly.CompileError.prototype.constructor",
1191
1194
  "WebAssembly.Exception",
1192
1195
  "WebAssembly.Exception.prototype",
1193
1196
  "WebAssembly.Global",
@@ -1196,17 +1199,14 @@
1196
1199
  "WebAssembly.Instance.prototype",
1197
1200
  "WebAssembly.LinkError",
1198
1201
  "WebAssembly.LinkError.prototype",
1199
- "WebAssembly.LinkError.prototype.constructor",
1200
1202
  "WebAssembly.Memory",
1201
1203
  "WebAssembly.Memory.prototype",
1202
1204
  "WebAssembly.Module",
1203
1205
  "WebAssembly.Module.prototype",
1204
1206
  "WebAssembly.RuntimeError",
1205
1207
  "WebAssembly.RuntimeError.prototype",
1206
- "WebAssembly.RuntimeError.prototype.constructor",
1207
1208
  "WebAssembly.SuspendError",
1208
1209
  "WebAssembly.SuspendError.prototype",
1209
- "WebAssembly.SuspendError.prototype.constructor",
1210
1210
  "WebAssembly.Suspending",
1211
1211
  "WebAssembly.Suspending.prototype",
1212
1212
  "WebAssembly.Table",
package/check/codes.ts CHANGED
@@ -16,6 +16,7 @@ export const RANGES = [
16
16
  { from: 1000, to: 1999, what: "breaks under AOT" },
17
17
  { from: 2000, to: 2999, what: "works under AOT, but slower" },
18
18
  { from: 3000, to: 3999, what: "typing quality: compiles, but AOT gets no type information" },
19
+ { from: 4000, to: 4999, what: "CSS the native renderer does not apply" },
19
20
  ] as const;
20
21
 
21
22
  const CODES: CodeInfo[] = [
@@ -184,6 +185,51 @@ const CODES: CodeInfo[] = [
184
185
  example: 'declare module "some-package";',
185
186
  fix: "Remove the shorthand declaration (or give it a body with real types), and convert the JavaScript file to TypeScript or annotate it with JSDoc.",
186
187
  },
188
+ {
189
+ code: "SK4001",
190
+ severity: "warning",
191
+ title: "a CSS property Skathi does not support",
192
+ explanation:
193
+ "Skathi renders CSS natively, without a browser engine, and this property is not implemented: the declaration has no effect, and the app prints an advisory for it while it runs. Declarations inside `@supports` blocks, values from `var()` and CSS-wide keywords are not reported, nor is a value a browser would compute anyway (`float: none`).",
194
+ example: ".card {\n float: left;\n}",
195
+ fix: "Use what the help line suggests (flex or grid instead of `float`), or remove the declaration. Keep it for a browser build inside `@supports (float: left) { … }`.",
196
+ },
197
+ {
198
+ code: "SK4002",
199
+ severity: "warning",
200
+ title: "a CSS value Skathi does not apply",
201
+ explanation:
202
+ "The property is supported, but not with this value or function: for example the colour functions of `filter`, 3D functions of `transform`, or `width: fit-content`. The declaration is dropped and the app prints an advisory for it while it runs.",
203
+ example: ".avatar {\n filter: grayscale(1);\n}",
204
+ fix: "Use a value the help line names, or remove the declaration. Keep it for a browser build inside `@supports`.",
205
+ },
206
+ {
207
+ code: "SK4003",
208
+ severity: "warning",
209
+ title: "a CSS selector that never matches in Skathi",
210
+ explanation:
211
+ "The selector uses a pseudo-class or pseudo-element the engine cannot answer (`:visited`, `:placeholder-shown`, `::first-line`, `::-webkit-scrollbar`, a hover state inside `:not()`), so the whole rule is dropped.",
212
+ example: "input:placeholder-shown {\n opacity: 0.6;\n}",
213
+ fix: "Select on a class or data attribute the app sets from script, or use the property the help line names.",
214
+ },
215
+ {
216
+ code: "SK4004",
217
+ severity: "warning",
218
+ title: "a CSS at-rule Skathi does not support",
219
+ explanation:
220
+ "`@container`, `@layer` (outside Tailwind), `@scope`, `@starting-style`, `@counter-style`, `@font-feature-values` and `@namespace` are not implemented: the rules inside the block are dropped.",
221
+ example: "@container (min-width: 400px) {\n .card { display: grid; }\n}",
222
+ fix: "Move the rules out of the block, or use `@media` on the window size.",
223
+ },
224
+ {
225
+ code: "SK4005",
226
+ severity: "warning",
227
+ title: "a dependency's CSS uses what Skathi does not apply",
228
+ explanation:
229
+ "Stylesheets the app imports from this package use properties, values, selectors or at-rules the engine does not apply (the SK4001–SK4004 cases). One diagnostic per package; the places are listed as related locations.",
230
+ example: 'import "some-ui-kit/dist/style.css";',
231
+ fix: "Check that the package's components the app uses look right; allow SK4005 for the package once they do.",
232
+ },
187
233
  ];
188
234
 
189
235
  export const REGISTRY: ReadonlyMap<string, CodeInfo> = new Map(CODES.map((c) => [c.code, c]));