@ketvietlab/create-view 0.1.24

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KETVIET JSC, Vietnam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @ketvietlab/create-view
2
+
3
+ Project generator for static Ket view sites.
4
+
5
+ Run `npm create @ketvietlab/view@latest my-site`, install dependencies, and start the development server with `npm run dev`.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../../packages/create-view/src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ import { resolve } from 'node:path';
3
+ import { scaffoldView } from './index.js';
4
+ const VERSION = '0.1.24';
5
+ const HELP = `Create Ket view ${VERSION}
6
+
7
+ Usage:
8
+ npm create @ketvietlab/view@latest PROJECT [-- --dir DIR]
9
+
10
+ Creates a static HTML project with TypeScript, CSS and explicit client islands.`;
11
+ const args = process.argv.slice(2);
12
+ const option = (name) => {
13
+ const index = args.indexOf(`--${name}`);
14
+ return index < 0 ? undefined : args[index + 1];
15
+ };
16
+ try {
17
+ if (args.includes('--version')) {
18
+ console.log(VERSION);
19
+ process.exit(0);
20
+ }
21
+ if (args.includes('--help')) {
22
+ console.log(HELP);
23
+ process.exit(0);
24
+ }
25
+ const name = args.find((arg) => !arg.startsWith('--'));
26
+ if (!name || name === 'help') {
27
+ console.log(HELP);
28
+ }
29
+ else if (name === 'version') {
30
+ console.log(VERSION);
31
+ }
32
+ else {
33
+ const dir = resolve(option('dir') ?? name);
34
+ for (const line of scaffoldView(name, dir))
35
+ console.log(line);
36
+ }
37
+ }
38
+ catch (error) {
39
+ console.error(error instanceof Error ? error.message : error);
40
+ process.exitCode = 1;
41
+ }
42
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../../../packages/create-view/src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzC,MAAM,OAAO,GAAG,QAAQ,CAAA;AACxB,MAAM,IAAI,GAAG,mBAAmB,OAAO;;;;;gFAKyC,CAAA;AAEhF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAClC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAsB,EAAE;IAClD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CA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,CAAA;IAC7D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function scaffoldView(name: string, dir: string): string[];
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/create-view/src/index.ts"],"names":[],"mappings":"AAwBA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAkBhE"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ const VERSION = '0.1.24';
4
+ const TEMPLATES = new URL('./templates/', import.meta.url);
5
+ const LAYOUT = [
6
+ ['package.json.tmpl', 'package.json'],
7
+ ['tsconfig.json.tmpl', 'tsconfig.json'],
8
+ ['ket-view.config.ts.tmpl', 'ket-view.config.ts'],
9
+ ['README.md.tmpl', 'README.md'],
10
+ ['gitignore.tmpl', '.gitignore'],
11
+ ['index.ts.tmpl', 'src/pages/index.ts'],
12
+ ['about.ts.tmpl', 'src/pages/about.ts'],
13
+ ['counter.ts.tmpl', 'src/islands/counter.ts'],
14
+ ['main.css.tmpl', 'src/styles/main.css'],
15
+ ['favicon.svg.tmpl', 'public/favicon.svg'],
16
+ ];
17
+ const render = (template, name) => readFileSync(new URL(template, TEMPLATES), 'utf8')
18
+ .replaceAll('__NAME__', name)
19
+ .replaceAll('__VERSION__', VERSION);
20
+ export function scaffoldView(name, dir) {
21
+ if (!/^[a-z][a-z0-9-]*$/.test(name))
22
+ throw new Error(`invalid project name "${name}" — use lowercase letters, digits and hyphens, starting with a letter`);
23
+ const files = LAYOUT.map(([template, path]) => [path, render(template, name)]);
24
+ const clashes = files.map(([path]) => path).filter((path) => existsSync(join(dir, path)));
25
+ if (clashes.length)
26
+ throw new Error(`refusing to overwrite: ${clashes.map((path) => join(dir, path)).join(', ')}`);
27
+ const output = [];
28
+ for (const [path, contents] of files) {
29
+ const target = join(dir, path);
30
+ mkdirSync(join(target, '..'), { recursive: true });
31
+ writeFileSync(target, contents);
32
+ output.push(` wrote ${target}`);
33
+ }
34
+ output.push('', ` cd ${dir}`, ' npm install', ' npm run dev');
35
+ return output;
36
+ }
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/create-view/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,OAAO,GAAG,QAAQ,CAAA;AACxB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,cAAc,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;AAE1D,MAAM,MAAM,GAA4B;IACtC,CAAC,mBAAmB,EAAE,cAAc,CAAC;IACrC,CAAC,oBAAoB,EAAE,eAAe,CAAC;IACvC,CAAC,yBAAyB,EAAE,oBAAoB,CAAC;IACjD,CAAC,gBAAgB,EAAE,WAAW,CAAC;IAC/B,CAAC,gBAAgB,EAAE,YAAY,CAAC;IAChC,CAAC,eAAe,EAAE,oBAAoB,CAAC;IACvC,CAAC,eAAe,EAAE,oBAAoB,CAAC;IACvC,CAAC,iBAAiB,EAAE,wBAAwB,CAAC;IAC7C,CAAC,eAAe,EAAE,qBAAqB,CAAC;IACxC,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;CAC3C,CAAA;AAED,MAAM,MAAM,GAAG,CAAC,QAAgB,EAAE,IAAY,EAAU,EAAE,CACxD,YAAY,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC;KAC/C,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC;KAC5B,UAAU,CAAC,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AAC,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,eAAe,EAAE,eAAe,CAAC,CAAA;IAChE,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,8 @@
1
+ # __NAME__
2
+
3
+ A static HTML site built with Ket view.
4
+
5
+ - `npm run dev` starts the local development server.
6
+ - `npm run build` writes deployable HTML, CSS, and JavaScript to `dist`.
7
+ - `npm run preview` serves the built output.
8
+ - `npm run check` type-checks and validates pages and island bundles.
@@ -0,0 +1,24 @@
1
+ import { html } from '@ketvietlab/ketjs-view'
2
+ import { definePage } from '@ketvietlab/ketjs-view-tools'
3
+
4
+ export default definePage({
5
+ head: {
6
+ title: 'About · __NAME__',
7
+ description: 'A fully static page with no hydration markers or client JavaScript of its own.',
8
+ lang: 'en',
9
+ },
10
+ view: () => html`
11
+ <header class="site-header">
12
+ <a class="brand" href="../">__NAME__</a>
13
+ <nav aria-label="Main navigation"><a aria-current="page" href="./">About</a></nav>
14
+ </header>
15
+ <main>
16
+ <article class="prose">
17
+ <p class="eyebrow">A plain static route</p>
18
+ <h1>Nothing to hydrate here.</h1>
19
+ <p>This file becomes <code>dist/about/index.html</code> with its shared, hashed stylesheet.</p>
20
+ <p><a href="../">Back home</a></p>
21
+ </article>
22
+ </main>
23
+ `,
24
+ })
@@ -0,0 +1,16 @@
1
+ import { html, signal } from '@ketvietlab/ketjs-view'
2
+ import type { IslandFactory } from '@ketvietlab/ketjs-view'
3
+
4
+ type CounterProps = { initial: number }
5
+
6
+ const counter: IslandFactory<CounterProps> = (props) => {
7
+ const count = signal(props.initial)
8
+ return () => html`
9
+ <div class="counter">
10
+ <span>Count: ${count()}</span>
11
+ <button type="button" on:click=${() => count.set((value) => value + 1)}>Add one</button>
12
+ </div>
13
+ `
14
+ }
15
+
16
+ export default counter
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#17201b"/>
3
+ <path d="M18 15h9v14l13-14h11L35 32l17 17H40L27 35v14h-9z" fill="#d7f26c"/>
4
+ </svg>
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ .DS_Store
@@ -0,0 +1,26 @@
1
+ import { html } from '@ketvietlab/ketjs-view'
2
+ import { definePage, island } from '@ketvietlab/ketjs-view-tools'
3
+ import counter from '../islands/counter.ts'
4
+
5
+ export default definePage({
6
+ head: {
7
+ title: '__NAME__',
8
+ description: 'A static site powered by Ket view.',
9
+ lang: 'en',
10
+ links: [{ rel: 'icon', href: './favicon.svg', type: 'image/svg+xml' }],
11
+ },
12
+ view: () => html`
13
+ <header class="site-header">
14
+ <a class="brand" href="./">__NAME__</a>
15
+ <nav aria-label="Main navigation"><a href="./about/">About</a></nav>
16
+ </header>
17
+ <main>
18
+ <section class="hero">
19
+ <p class="eyebrow">Ket view static starter</p>
20
+ <h1>Ship plain HTML.<br />Add JavaScript only where it earns its place.</h1>
21
+ <p class="lede">The page stays marker-free. The counter below is an explicit island.</p>
22
+ ${island('counter', counter, { initial: 0 })}
23
+ </section>
24
+ </main>
25
+ `,
26
+ })
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from '@ketvietlab/ketjs-view-tools'
2
+
3
+ export default defineConfig({
4
+ pages: 'src/pages',
5
+ styles: ['src/styles/main.css'],
6
+ islands: {
7
+ counter: 'src/islands/counter.ts',
8
+ },
9
+ base: './',
10
+ })
@@ -0,0 +1,34 @@
1
+ :root {
2
+ color: #17201b;
3
+ background: #f3f0e8;
4
+ font-family: Inter, ui-sans-serif, system-ui, sans-serif;
5
+ font-synthesis: none;
6
+ }
7
+
8
+ * { box-sizing: border-box; }
9
+ body { margin: 0; min-width: 20rem; }
10
+ a { color: inherit; text-underline-offset: 0.2em; }
11
+ .site-header {
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: space-between;
15
+ width: min(72rem, calc(100% - 3rem));
16
+ margin: 0 auto;
17
+ padding: 1.5rem 0;
18
+ border-bottom: 1px solid #c7c2b6;
19
+ }
20
+ .brand { font-weight: 750; text-decoration: none; }
21
+ main { width: min(72rem, calc(100% - 3rem)); margin: 0 auto; }
22
+ .hero, .prose { max-width: 52rem; padding: clamp(5rem, 12vw, 10rem) 0; }
23
+ .eyebrow { color: #3e6b51; font-size: 0.82rem; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }
24
+ h1 { margin: 0.5rem 0 1.5rem; font-family: Georgia, serif; font-size: clamp(3rem, 7vw, 6.8rem); font-weight: 500; letter-spacing: -0.055em; line-height: 0.92; }
25
+ .prose h1 { font-size: clamp(3rem, 6vw, 5rem); }
26
+ .lede, .prose p { max-width: 40rem; font-size: clamp(1.05rem, 2vw, 1.3rem); line-height: 1.65; }
27
+ .counter { display: flex; align-items: center; gap: 1rem; width: fit-content; margin-top: 2.5rem; padding: 0.55rem 0.6rem 0.55rem 1.1rem; color: #f8f6ef; background: #17201b; border-radius: 999px; }
28
+ button { padding: 0.7rem 1rem; color: #17201b; background: #d7f26c; border: 0; border-radius: 999px; font: inherit; font-weight: 750; cursor: pointer; }
29
+ code { padding: 0.12em 0.35em; background: #e4dfd3; border-radius: 0.25rem; }
30
+
31
+ @media (max-width: 40rem) {
32
+ .site-header, main { width: min(100% - 2rem, 72rem); }
33
+ .hero, .prose { padding: 4rem 0; }
34
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "__NAME__",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=24.0.0"
8
+ },
9
+ "scripts": {
10
+ "dev": "ket-view dev",
11
+ "build": "ket-view build",
12
+ "preview": "ket-view preview",
13
+ "check": "tsc --noEmit && ket-view check"
14
+ },
15
+ "dependencies": {
16
+ "@ketvietlab/ketjs-view": "__VERSION__"
17
+ },
18
+ "devDependencies": {
19
+ "@ketvietlab/ketjs-view-tools": "__VERSION__",
20
+ "typescript": "^7.0.2"
21
+ }
22
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2022",
4
+ "module": "nodenext",
5
+ "moduleResolution": "nodenext",
6
+ "lib": ["es2022", "dom"],
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "verbatimModuleSyntax": true,
10
+ "allowImportingTsExtensions": true
11
+ },
12
+ "include": ["ket-view.config.ts", "src/**/*.ts", "src/**/*.tsx"]
13
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@ketvietlab/create-view",
3
+ "version": "0.1.24",
4
+ "description": "Create a static HTML project powered by Ket view.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "bin": {
10
+ "create-view": "./dist/cli.js"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/ketvietlab/ketjs.git",
15
+ "directory": "packages/create-view"
16
+ },
17
+ "homepage": "https://github.com/ketvietlab/ketjs#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/ketvietlab/ketjs/issues"
20
+ },
21
+ "keywords": [
22
+ "create",
23
+ "static-site",
24
+ "scaffold",
25
+ "ketjs",
26
+ "typescript"
27
+ ],
28
+ "engines": {
29
+ "node": ">=24.0.0"
30
+ },
31
+ "scripts": {
32
+ "prepack": "npm run build --prefix ../.."
33
+ },
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "default": "./dist/index.js"
38
+ }
39
+ },
40
+ "dependencies": {},
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "provenance": true,
44
+ "registry": "https://registry.npmjs.org/"
45
+ },
46
+ "files": [
47
+ "dist"
48
+ ]
49
+ }