@kayjs/kay 2.0.0-alpha.0 → 2.0.0-alpha.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kayjs/kay",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.4",
4
4
  "description": "Bun-native TSX web framework with zero-directive automatic islands, fine-grained signals, and single-binary deploys",
5
5
  "license": "MIT",
6
6
  "homepage": "https://kayjs.kaynooo.fr",
@@ -8,6 +8,7 @@ import type { IslandBinding, ModuleAnalysis } from '../compiler/index'
8
8
  import type { BuildPluginContext, KayPlugin } from '../plugins/index'
9
9
  import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
10
10
  import { basename, dirname, extname, join, relative, resolve } from 'node:path'
11
+ import { brotliCompressSync, constants as zlibConstants } from 'node:zlib'
11
12
  import { analyzeModule, compileDom, compileSsr } from '../compiler/index'
12
13
  import { loadConfig } from '../plugins/index'
13
14
  import { actionHash } from '../server/action'
@@ -850,6 +851,21 @@ export async function build(options: BuildOptions): Promise<BuildManifest> {
850
851
  mkdirSync(dirname(dst), { recursive: true })
851
852
  writeFileSync(dst, readFileSync(join(outDir, 'public', rel)))
852
853
  }
854
+ // Emit precompressed .br and .gz sidecars for compressible static files (>= 128 B)
855
+ const COMPRESSIBLE = new Set(['.html', '.js', '.mjs', '.css', '.svg', '.xml', '.json', '.txt', '.webmanifest'])
856
+ for (const abs of walkAllFiles(prerenderDir)) {
857
+ if (!COMPRESSIBLE.has(extname(abs).toLowerCase()))
858
+ continue
859
+ const raw = readFileSync(abs)
860
+ if (raw.byteLength < 128)
861
+ continue
862
+ const br = brotliCompressSync(raw, { params: { [zlibConstants.BROTLI_PARAM_QUALITY]: 6 } })
863
+ if (br.byteLength < raw.byteLength)
864
+ writeFileSync(`${abs}.br`, br)
865
+ const gz = Bun.gzipSync(raw, { level: 9 })
866
+ if (gz.byteLength < raw.byteLength)
867
+ writeFileSync(`${abs}.gz`, gz)
868
+ }
853
869
  }
854
870
 
855
871
  writeFileSync(join(outDir, 'manifest.json'), JSON.stringify(manifest, null, 2))
package/src/cli/new.ts CHANGED
@@ -15,7 +15,7 @@ export function scaffoldProject(targetDir: string, options: ScaffoldOptions = {}
15
15
  const root = resolve(targetDir)
16
16
  const name = basename(root).toLowerCase().replace(/[^a-z0-9-_]/g, '-') || 'kay-app'
17
17
  const template: ScaffoldTemplate = options.template ?? 'minimal'
18
- const kayVersion = options.kayVersion ?? '^2.0.0-alpha.0'
18
+ const kayVersion = options.kayVersion ?? '^2.0.0-alpha.4'
19
19
 
20
20
  if (existsSync(root) && readdirSync(root).length > 0 && !options.force)
21
21
  throw new Error(`kay new: directory "${root}" is not empty (pass --force to overwrite)`)
@@ -150,11 +150,12 @@ export function GET(ctx: RequestContext) {
150
150
  return ctx.json({ ok: true, runtime: 'bun' })
151
151
  }
152
152
  `
153
- files['src/actions/greet.ts'] = `import { action } from 'kay/server'
153
+ files['src/actions/greet.ts'] = `import type { StandardSchemaV1 } from 'kay/server'
154
+ import { action } from 'kay/server'
154
155
 
155
- const nameSchema = {
156
+ const nameSchema: StandardSchemaV1<{ name: string }> = {
156
157
  '~standard': {
157
- version: 1 as const,
158
+ version: 1,
158
159
  vendor: 'kay',
159
160
  validate(raw: unknown) {
160
161
  const name = String((raw as { name?: unknown })?.name ?? '').trim()