@toyz/create-loom 0.1.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/README.md ADDED
@@ -0,0 +1,70 @@
1
+ <p align="center">
2
+ <img src="../logo.svg" alt="Loom" width="60" />
3
+ </p>
4
+
5
+ <h1 align="center">@toyz/create-loom</h1>
6
+
7
+ <p align="center">
8
+ Scaffold a new Loom + TypeScript + Vite project in seconds.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@toyz/create-loom"><img src="https://img.shields.io/npm/v/@toyz/create-loom?color=c084fc&label=npm" alt="npm" /></a>
13
+ <a href="https://github.com/Toyz/loom"><img src="https://img.shields.io/badge/framework-@toyz/loom-86efac" alt="loom" /></a>
14
+ <a href="../LICENSE"><img src="https://img.shields.io/badge/license-MIT-fbbf24" alt="MIT" /></a>
15
+ </p>
16
+
17
+ ---
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ npm create @toyz/loom my-app
23
+ cd my-app
24
+ npm install
25
+ npm run dev
26
+ ```
27
+
28
+ That's it. No prompts, no config wizard, no JavaScript option — Loom is TypeScript only.
29
+
30
+ ## What you get
31
+
32
+ ```
33
+ my-app/
34
+ ├── index.html 5 lines
35
+ ├── package.json 1 dep, 2 devDeps
36
+ ├── tsconfig.json Loom JSX pre-configured
37
+ ├── vite.config.ts esbuild JSX wired to Loom
38
+ └── src/
39
+ ├── main.tsx app.start()
40
+ ├── app.tsx starter component
41
+ └── global.d.ts CSS module types
42
+ ```
43
+
44
+ ### Dependencies
45
+
46
+ | Type | Package | Why |
47
+ | ----------------- | ------------ | ------------------------------------ |
48
+ | `dependencies` | `@toyz/loom` | The framework (zero transitive deps) |
49
+ | `devDependencies` | `typescript` | Type checking |
50
+ | `devDependencies` | `vite` | Dev server + bundler |
51
+
52
+ No other packages. No plugins. No polyfills.
53
+
54
+ ## Current directory
55
+
56
+ To scaffold into the current directory:
57
+
58
+ ```bash
59
+ npm create @toyz/loom .
60
+ ```
61
+
62
+ ## Links
63
+
64
+ - **Framework** — [@toyz/loom](https://www.npmjs.com/package/@toyz/loom)
65
+ - **Docs** — [toyz.github.io/loom](https://toyz.github.io/loom/)
66
+ - **Source** — [github.com/Toyz/loom](https://github.com/Toyz/loom)
67
+
68
+ ## License
69
+
70
+ [MIT](../LICENSE) — do whatever you want with it.
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * create-loom — Scaffold a Loom + TypeScript + Vite project.
5
+ *
6
+ * Usage:
7
+ * npm create loom my-app
8
+ * npx create-loom my-app
9
+ * npx create-loom . (current directory)
10
+ */
11
+
12
+ import { existsSync, mkdirSync, cpSync, readFileSync, writeFileSync } from "node:fs";
13
+ import { resolve, basename, join, dirname } from "node:path";
14
+ import { fileURLToPath } from "node:url";
15
+
16
+ const __dirname = dirname(fileURLToPath(import.meta.url));
17
+ const TEMPLATE_DIR = resolve(__dirname, "..", "template");
18
+
19
+ const name = process.argv[2];
20
+
21
+ if (!name) {
22
+ console.error("\n Usage: npm create loom <project-name>\n");
23
+ process.exit(1);
24
+ }
25
+
26
+ const target = resolve(process.cwd(), name);
27
+ const projectName = name === "." ? basename(process.cwd()) : basename(name);
28
+
29
+ // Guard against overwriting
30
+ if (name !== "." && existsSync(target)) {
31
+ console.error(`\n Directory "${name}" already exists.\n`);
32
+ process.exit(1);
33
+ }
34
+
35
+ // Copy template
36
+ if (name !== ".") mkdirSync(target, { recursive: true });
37
+ cpSync(TEMPLATE_DIR, target, { recursive: true });
38
+
39
+ // Patch project name into package.json
40
+ const pkgPath = join(target, "package.json");
41
+ const pkg = readFileSync(pkgPath, "utf-8");
42
+ writeFileSync(pkgPath, pkg.replace(/"name": "loom-app"/, `"name": "${projectName}"`));
43
+
44
+ console.log(`
45
+ ✨ Loom project created in ${name === "." ? "current directory" : name}
46
+
47
+ Get started:
48
+ ${name !== "." ? `cd ${name}` : ""}
49
+ npm install
50
+ npm run dev
51
+
52
+ Weave the web with Loom
53
+ `);
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@toyz/create-loom",
3
+ "version": "0.1.0",
4
+ "description": "Scaffold a new Loom + TypeScript + Vite project",
5
+ "license": "MIT",
6
+ "author": "toyz",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/Toyz/loom.git",
10
+ "directory": "create-loom"
11
+ },
12
+ "type": "module",
13
+ "bin": {
14
+ "create-loom": "./bin/create-loom.js"
15
+ },
16
+ "files": [
17
+ "bin",
18
+ "template"
19
+ ],
20
+ "keywords": [
21
+ "loom",
22
+ "create",
23
+ "scaffold",
24
+ "vite",
25
+ "web-components",
26
+ "decorators",
27
+ "typescript"
28
+ ]
29
+ }
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Loom App</title>
7
+ </head>
8
+ <body>
9
+ <my-app></my-app>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "loom-app",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "@toyz/loom": "^0.10.0"
13
+ },
14
+ "devDependencies": {
15
+ "typescript": "^5.7.0",
16
+ "vite": "^6.0.0"
17
+ }
18
+ }
@@ -0,0 +1,63 @@
1
+ import { LoomElement, component, reactive, css, styles } from "@toyz/loom";
2
+
3
+ const appStyles = css`
4
+ :host {
5
+ display: flex;
6
+ flex-direction: column;
7
+ align-items: center;
8
+ justify-content: center;
9
+ min-height: 100vh;
10
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
11
+ Helvetica, Arial, sans-serif;
12
+ background: #0a0a0a;
13
+ color: #ededed;
14
+ }
15
+ h1 {
16
+ font-size: 3rem;
17
+ font-weight: 200;
18
+ margin: 0 0 1rem;
19
+ background: linear-gradient(135deg, #c084fc, #67e8f9);
20
+ -webkit-background-clip: text;
21
+ -webkit-text-fill-color: transparent;
22
+ }
23
+ p {
24
+ color: #888;
25
+ margin: 0 0 2rem;
26
+ }
27
+ button {
28
+ padding: 0.75rem 1.5rem;
29
+ border: 1px solid #333;
30
+ border-radius: 8px;
31
+ background: #1a1a1a;
32
+ color: #ededed;
33
+ font-size: 1rem;
34
+ cursor: pointer;
35
+ transition: border-color 0.2s, background 0.2s;
36
+ }
37
+ button:hover {
38
+ border-color: #c084fc;
39
+ background: #222;
40
+ }
41
+ span {
42
+ font-weight: bold;
43
+ color: #c084fc;
44
+ }
45
+ `;
46
+
47
+ @component("my-app")
48
+ @styles(appStyles)
49
+ export class MyApp extends LoomElement {
50
+ @reactive accessor count = 0;
51
+
52
+ update() {
53
+ return (
54
+ <div>
55
+ <h1>Loom</h1>
56
+ <p>Weave the web Loom</p>
57
+ <button onClick={() => this.count++}>
58
+ Count: <span>{this.count}</span>
59
+ </button>
60
+ </div>
61
+ );
62
+ }
63
+ }
@@ -0,0 +1 @@
1
+ declare module "*.css";
@@ -0,0 +1,4 @@
1
+ import { app } from "@toyz/loom";
2
+ import "./app";
3
+
4
+ app.start();
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "jsx": "react-jsx",
7
+ "jsxImportSource": "@toyz/loom",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "outDir": "dist"
13
+ },
14
+ "include": ["src"]
15
+ }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from "vite";
2
+
3
+ export default defineConfig({
4
+ esbuild: {
5
+ jsx: "automatic",
6
+ jsxImportSource: "@toyz/loom",
7
+ },
8
+ });