@kazzle/app 0.1.693 → 0.1.697
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/README.md +15 -7
- package/dist/migrations.d.ts +4 -4
- package/dist/migrations.js +13 -24
- package/package.json +36 -10
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @kazzle/app
|
|
2
2
|
|
|
3
3
|
The one versioned package for building Kazzle apps. It owns the app-facing
|
|
4
|
-
TypeScript contracts, tool helpers, the Vite preview helper,
|
|
5
|
-
|
|
4
|
+
TypeScript contracts, tool helpers, the Vite preview helper, app templates, and
|
|
5
|
+
server/CLI-only app migrations.
|
|
6
6
|
|
|
7
7
|
This file is the ownership doc referenced by the code comments in this package
|
|
8
8
|
and in the server. Read it before changing exports, templates, or the
|
|
@@ -33,22 +33,30 @@ and the root export must stay tiny and dependency-free.
|
|
|
33
33
|
| `@kazzle/app/client` | install-scoped client: per-install secrets, sibling component URLs | none |
|
|
34
34
|
| `@kazzle/app/vite` | `kazzleAppVite` preview/runtime Vite helper | `vite` (peer, type-only) |
|
|
35
35
|
| `@kazzle/app/templates` | programmatic template manifest + asset readers (server/generator only) | none |
|
|
36
|
-
| `@kazzle/app/migrations` | app
|
|
36
|
+
| `@kazzle/app/migrations` | versioned app upgrade metadata + codemods (server/CLI only) | none |
|
|
37
37
|
|
|
38
|
-
To add an export: add the `src/*.ts` file, add it to
|
|
39
|
-
`
|
|
38
|
+
To add an export: add the `src/*.ts` file, add it to `exports` in
|
|
39
|
+
`package.json`, and document it in the table above.
|
|
40
40
|
|
|
41
41
|
## Build model — source in dev, dist on npm
|
|
42
42
|
|
|
43
43
|
- Workspace consumers (server, tests, typecheck) resolve `exports` → raw `.ts`
|
|
44
44
|
source. Bun and `tsc` read TS directly, so there is no build step for the
|
|
45
45
|
monorepo. This mirrors `@kazzle/framework`.
|
|
46
|
-
- The published package resolves `
|
|
46
|
+
- The published package resolves package `exports` → compiled `dist/*.js`
|
|
47
47
|
+ `dist/*.d.ts`, because apps installed from npm need JS + types.
|
|
48
|
-
- `bun run build` (`scripts/build.ts`) emits `dist
|
|
48
|
+
- `bun run build` (`scripts/build.ts`) emits `dist/`; templates ship directly
|
|
49
|
+
from the package `templates/` directory.
|
|
49
50
|
- Templates ship as package assets (`files: ["dist", "templates"]`) so the
|
|
50
51
|
server generator reads the exact versioned template for every app it creates.
|
|
51
52
|
|
|
53
|
+
## Package size
|
|
54
|
+
|
|
55
|
+
Templates are package assets, not runtime imports. A generated app that imports
|
|
56
|
+
`@kazzle/app`, `@kazzle/app/tools`, or `@kazzle/app/vite` only loads that
|
|
57
|
+
subpath. Keep templates source-only and avoid generated artifacts so the npm
|
|
58
|
+
tarball stays small; use `npm pack --dry-run` when adding large files.
|
|
59
|
+
|
|
52
60
|
## Versioning
|
|
53
61
|
|
|
54
62
|
`@kazzle/app` shares the root Kazzle version during pre-launch (`package.json`
|
package/dist/migrations.d.ts
CHANGED
|
@@ -3,17 +3,17 @@ export type AppFileMap = Record<string, string>;
|
|
|
3
3
|
export interface AppMigration {
|
|
4
4
|
/** Unique migration id, e.g. "app-api-v0.2". Referenced by compat policy. */
|
|
5
5
|
id: string;
|
|
6
|
-
/** Human range this migration upgrades
|
|
6
|
+
/** Human range this migration upgrades from, e.g. "<0.2". */
|
|
7
7
|
appliesTo: string;
|
|
8
8
|
/** What the migration does. */
|
|
9
9
|
description: string;
|
|
10
|
-
/** Globs the migration may edit
|
|
10
|
+
/** Globs the migration may edit, for dry-run summaries. */
|
|
11
11
|
files: string[];
|
|
12
|
-
/** Pure transform: returns only the files it changed
|
|
12
|
+
/** Pure transform: returns only the files it changed or added. */
|
|
13
13
|
run(files: AppFileMap): AppFileMap;
|
|
14
14
|
}
|
|
15
15
|
export declare const APP_MIGRATIONS: AppMigration[];
|
|
16
16
|
/** Look up a migration by id. */
|
|
17
17
|
export declare function getAppMigration(id: string): AppMigration | undefined;
|
|
18
|
-
/** Add the `@kazzle/app` dependency to an app package.json string
|
|
18
|
+
/** Add the `@kazzle/app` dependency to an app package.json string. */
|
|
19
19
|
export declare function addPackageDependency(pkgJson: string, version: string): string;
|
package/dist/migrations.js
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
// @kazzle/app/migrations — versioned app migration metadata + codemods.
|
|
2
2
|
//
|
|
3
|
-
// SERVER/CLI ONLY.
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// app checkout when the app contract changes between package versions.
|
|
3
|
+
// SERVER/CLI ONLY. This is the long-term upgrade path for existing generated
|
|
4
|
+
// app repos when the app contract changes. Normal app runtime code must not
|
|
5
|
+
// import this subpath.
|
|
7
6
|
//
|
|
8
|
-
// Codemods are
|
|
9
|
-
// return
|
|
10
|
-
// checkout
|
|
11
|
-
// without a filesystem and keeps fs/permission policy server-side.
|
|
7
|
+
// Codemods are pure: they take an in-memory `{ path -> contents }` map and
|
|
8
|
+
// return only changed files. The server/CLI owns reading and writing the actual
|
|
9
|
+
// checkout so filesystem and permission policy stays server-side.
|
|
12
10
|
//
|
|
13
11
|
// To add a migration:
|
|
14
12
|
// 1. Append an `AppMigration` to `APP_MIGRATIONS` with a unique `id`.
|
|
15
|
-
// 2. Set `appliesTo`
|
|
16
|
-
// policy) and `files` (globs it may touch, for the dry-run summary).
|
|
13
|
+
// 2. Set `appliesTo` and `files` for dry-run summaries.
|
|
17
14
|
// 3. Implement `run` as a pure file-map transform.
|
|
18
|
-
// 4. Point the server
|
|
19
|
-
/** Rewrite
|
|
15
|
+
// 4. Point the server compatibility blocker/deprecation text at the id.
|
|
16
|
+
/** Rewrite old vendored helper imports to the versioned package. */
|
|
20
17
|
function rewriteImports(contents) {
|
|
21
18
|
return contents
|
|
22
|
-
// `from './kazzle.types'`, `from '../../kazzle.types'`, etc → '@kazzle/app'
|
|
23
19
|
.replace(/(from\s*['"])((?:\.\.?\/)+)kazzle\.types(['"])/g, '$1@kazzle/app$3')
|
|
24
|
-
// vite helper → '@kazzle/app/vite'
|
|
25
20
|
.replace(/(from\s*['"])((?:\.\.?\/)+)kazzle\.vite(['"])/g, '$1@kazzle/app/vite$3');
|
|
26
21
|
}
|
|
27
22
|
/** Ensure `@kazzle/app` is a dependency of the app root package.json. */
|
|
@@ -33,22 +28,16 @@ function ensurePackageDependency(pkgJson, version) {
|
|
|
33
28
|
parsed.dependencies['@kazzle/app'] = `^${version}`;
|
|
34
29
|
return JSON.stringify(parsed, null, 2) + '\n';
|
|
35
30
|
}
|
|
36
|
-
/**
|
|
37
|
-
* v0.2: apps stop vendoring kazzle.types.ts / kazzle.vite.ts and import the
|
|
38
|
-
* contracts from `@kazzle/app`. Rewrites imports, adds the dependency, and
|
|
39
|
-
* deletes the vendored files (represented by an empty-string body, which the
|
|
40
|
-
* server/CLI turns into a delete).
|
|
41
|
-
*/
|
|
42
31
|
function migrateToPackageImports(files) {
|
|
43
32
|
const changed = {};
|
|
44
33
|
for (const [path, contents] of Object.entries(files)) {
|
|
45
34
|
const base = path.split('/').pop() ?? path;
|
|
46
35
|
if (base === 'kazzle.types.ts' || base === 'kazzle.vite.ts') {
|
|
47
|
-
changed[path] = '';
|
|
36
|
+
changed[path] = '';
|
|
48
37
|
continue;
|
|
49
38
|
}
|
|
50
39
|
if (path === 'package.json')
|
|
51
|
-
continue;
|
|
40
|
+
continue;
|
|
52
41
|
const rewritten = rewriteImports(contents);
|
|
53
42
|
if (rewritten !== contents)
|
|
54
43
|
changed[path] = rewritten;
|
|
@@ -59,7 +48,7 @@ export const APP_MIGRATIONS = [
|
|
|
59
48
|
{
|
|
60
49
|
id: 'app-api-v0.2',
|
|
61
50
|
appliesTo: '<0.2',
|
|
62
|
-
description: 'Import Kazzle app contracts from @kazzle/app instead of vendored
|
|
51
|
+
description: 'Import Kazzle app contracts from @kazzle/app instead of vendored helper files.',
|
|
63
52
|
files: ['**/*.ts', '**/*.tsx', 'package.json'],
|
|
64
53
|
run: migrateToPackageImports,
|
|
65
54
|
},
|
|
@@ -68,7 +57,7 @@ export const APP_MIGRATIONS = [
|
|
|
68
57
|
export function getAppMigration(id) {
|
|
69
58
|
return APP_MIGRATIONS.find(m => m.id === id);
|
|
70
59
|
}
|
|
71
|
-
/** Add the `@kazzle/app` dependency to an app package.json string
|
|
60
|
+
/** Add the `@kazzle/app` dependency to an app package.json string. */
|
|
72
61
|
export function addPackageDependency(pkgJson, version) {
|
|
73
62
|
return ensurePackageDependency(pkgJson, version);
|
|
74
63
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kazzle/app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.697",
|
|
4
4
|
"description": "Contracts, tool helpers, Vite helper, and templates for building Kazzle apps.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
|
-
"repository": {
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Kazzle-ai/kazzle.git",
|
|
9
|
+
"directory": "packages/kazzle-app"
|
|
10
|
+
},
|
|
7
11
|
"type": "module",
|
|
8
12
|
"sideEffects": false,
|
|
9
13
|
"//exports": "Exports point at compiled dist so isolated consumers (Vite/Node under node_modules, deployed apps, published npm tarball) never load raw .ts — Node/Vite can't type-strip TS under node_modules. dist is a build artifact (gitignored), kept fresh by the `prepare` script below on `bun install`/`npm publish` and by the local pack step in server/templates/template-local-harness.ts.",
|
|
10
14
|
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"./
|
|
16
|
-
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./tools": {
|
|
20
|
+
"types": "./dist/tools.d.ts",
|
|
21
|
+
"import": "./dist/tools.js"
|
|
22
|
+
},
|
|
23
|
+
"./client": {
|
|
24
|
+
"types": "./dist/client.d.ts",
|
|
25
|
+
"import": "./dist/client.js"
|
|
26
|
+
},
|
|
27
|
+
"./vite": {
|
|
28
|
+
"types": "./dist/vite.d.ts",
|
|
29
|
+
"import": "./dist/vite.js"
|
|
30
|
+
},
|
|
31
|
+
"./templates": {
|
|
32
|
+
"types": "./dist/templates.d.ts",
|
|
33
|
+
"import": "./dist/templates.js"
|
|
34
|
+
},
|
|
35
|
+
"./migrations": {
|
|
36
|
+
"types": "./dist/migrations.d.ts",
|
|
37
|
+
"import": "./dist/migrations.js"
|
|
38
|
+
},
|
|
17
39
|
"./package.json": "./package.json"
|
|
18
40
|
},
|
|
19
41
|
"publishConfig": {
|
|
@@ -35,8 +57,12 @@
|
|
|
35
57
|
"zod": "^3 || ^4"
|
|
36
58
|
},
|
|
37
59
|
"peerDependenciesMeta": {
|
|
38
|
-
"vite": {
|
|
39
|
-
|
|
60
|
+
"vite": {
|
|
61
|
+
"optional": true
|
|
62
|
+
},
|
|
63
|
+
"zod": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
40
66
|
},
|
|
41
67
|
"devDependencies": {
|
|
42
68
|
"@types/node": "^25.1.0",
|