@opendevsociety/kine-ui 1.0.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.
Files changed (3) hide show
  1. package/dist/index.js +105 -0
  2. package/package.json +37 -0
  3. package/src/index.ts +127 -0
package/dist/index.js ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // src/index.ts
27
+ var import_commander = require("commander");
28
+ var import_prompts = __toESM(require("prompts"));
29
+ var import_chalk = __toESM(require("chalk"));
30
+ var import_path = __toESM(require("path"));
31
+ var import_fs_extra = __toESM(require("fs-extra"));
32
+ var import_ora = __toESM(require("ora"));
33
+ var import_node_fetch = __toESM(require("node-fetch"));
34
+ var import_child_process = require("child_process");
35
+ var REGISTRY_URL = "https://kine-ui.vercel.app/r/styles/default";
36
+ var program = new import_commander.Command();
37
+ program.name("kine-ui").description("Add spatial computing gestures to your React applications.").version("1.0.0");
38
+ program.command("init").description("Initialize Kine UI in your Next.js project").action(async () => {
39
+ console.log(import_chalk.default.bold.blue("Welcome to Kine UI!"));
40
+ console.log("Let's configure your spatial computing environment.\n");
41
+ const response = await (0, import_prompts.default)([
42
+ {
43
+ type: "text",
44
+ name: "componentsDir",
45
+ message: "Where would you like to install spatial components?",
46
+ initial: "components/kine"
47
+ }
48
+ ]);
49
+ if (!response.componentsDir) {
50
+ console.log(import_chalk.default.yellow("Initialization cancelled."));
51
+ process.exit(0);
52
+ }
53
+ const spinner = (0, import_ora.default)("Installing core dependencies (framer-motion, @mediapipe/tasks-vision)...").start();
54
+ try {
55
+ (0, import_child_process.execSync)("npm install framer-motion @mediapipe/tasks-vision", { stdio: "ignore" });
56
+ spinner.succeed("Core dependencies installed.");
57
+ } catch (error) {
58
+ spinner.fail("Failed to install dependencies.");
59
+ process.exit(1);
60
+ }
61
+ const configPath = import_path.default.join(process.cwd(), "kine-ui.json");
62
+ import_fs_extra.default.writeJSONSync(configPath, { componentsDir: response.componentsDir }, { spaces: 2 });
63
+ console.log(import_chalk.default.green("\n\u2713 Successfully initialized Kine UI and created kine-ui.json"));
64
+ console.log(import_chalk.default.gray("To start building, try adding the global provider and a gesture:\n"));
65
+ console.log(import_chalk.default.cyan(" npx kine-ui add kine-provider"));
66
+ console.log(import_chalk.default.cyan(" npx kine-ui add air-cursor"));
67
+ });
68
+ program.command("add").description("Add a Kine UI gesture component").argument("<component>", "the component to add (e.g. 'air-cursor', 'swipe-area', 'kine-provider')").action(async (component) => {
69
+ let config;
70
+ try {
71
+ config = import_fs_extra.default.readJSONSync(import_path.default.join(process.cwd(), "kine-ui.json"));
72
+ } catch (e) {
73
+ console.log(import_chalk.default.red("kine-ui.json not found. Please run `npx kine-ui init` first."));
74
+ process.exit(1);
75
+ }
76
+ const spinner = (0, import_ora.default)(`Fetching ${component} from registry...`).start();
77
+ try {
78
+ const res = await (0, import_node_fetch.default)(`${REGISTRY_URL}/${component}.json`);
79
+ if (!res.ok) {
80
+ if (res.status === 404) {
81
+ throw new Error(`Component '${component}' not found in registry.`);
82
+ }
83
+ throw new Error(`Failed to fetch component. Status: ${res.status}`);
84
+ }
85
+ const item = await res.json();
86
+ spinner.text = `Installing ${component}...`;
87
+ if (item.dependencies && item.dependencies.length > 0) {
88
+ const deps = item.dependencies.join(" ");
89
+ spinner.text = `Installing additional dependencies: ${deps}...`;
90
+ (0, import_child_process.execSync)(`npm install ${deps}`, { stdio: "ignore" });
91
+ }
92
+ const targetDir = import_path.default.join(process.cwd(), config.componentsDir);
93
+ import_fs_extra.default.ensureDirSync(targetDir);
94
+ for (const fileDoc of item.files) {
95
+ const filePath = import_path.default.join(process.cwd(), fileDoc.target);
96
+ import_fs_extra.default.ensureDirSync(import_path.default.dirname(filePath));
97
+ import_fs_extra.default.writeFileSync(filePath, fileDoc.content, "utf-8");
98
+ }
99
+ spinner.succeed(`Successfully installed ${import_chalk.default.green(component)} to ${config.componentsDir}`);
100
+ } catch (error) {
101
+ spinner.fail(error.message || "Failed to add component.");
102
+ process.exit(1);
103
+ }
104
+ });
105
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@opendevsociety/kine-ui",
3
+ "version": "1.0.0",
4
+ "description": "Spatial computing component registry for React.",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "kine-ui": "dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsup src/index.ts --format cjs",
11
+ "dev": "tsup src/index.ts --format cjs --watch"
12
+ },
13
+ "keywords": [
14
+ "react",
15
+ "spatial",
16
+ "components",
17
+ "shadcn"
18
+ ],
19
+ "author": "Open Dev Society",
20
+ "license": "MIT",
21
+ "dependencies": {
22
+ "chalk": "^4.1.2",
23
+ "commander": "^11.1.0",
24
+ "fs-extra": "^11.2.0",
25
+ "node-fetch": "^2.7.0",
26
+ "ora": "^5.4.1",
27
+ "prompts": "^2.4.2"
28
+ },
29
+ "devDependencies": {
30
+ "@types/fs-extra": "^11.0.4",
31
+ "@types/node": "^20.11.16",
32
+ "@types/node-fetch": "^2.6.11",
33
+ "@types/prompts": "^2.4.9",
34
+ "tsup": "^8.0.1",
35
+ "typescript": "^5.3.3"
36
+ }
37
+ }
package/src/index.ts ADDED
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from "commander";
4
+ import prompts from "prompts";
5
+ import chalk from "chalk";
6
+ import path from "path";
7
+ import fs from "fs-extra";
8
+ import ora from "ora";
9
+ import fetch from "node-fetch";
10
+ import { execSync } from "child_process";
11
+
12
+ // Kine UI public registry URL
13
+ const REGISTRY_URL = "https://kine-ui.vercel.app/r/styles/default";
14
+
15
+ const program = new Command();
16
+
17
+ program
18
+ .name("kine-ui")
19
+ .description("Add spatial computing gestures to your React applications.")
20
+ .version("1.0.0");
21
+
22
+ program
23
+ .command("init")
24
+ .description("Initialize Kine UI in your Next.js project")
25
+ .action(async () => {
26
+ console.log(chalk.bold.blue("Welcome to Kine UI!"));
27
+ console.log("Let's configure your spatial computing environment.\n");
28
+
29
+ const response = await prompts([
30
+ {
31
+ type: "text",
32
+ name: "componentsDir",
33
+ message: "Where would you like to install spatial components?",
34
+ initial: "components/kine",
35
+ }
36
+ ]);
37
+
38
+ if (!response.componentsDir) {
39
+ console.log(chalk.yellow("Initialization cancelled."));
40
+ process.exit(0);
41
+ }
42
+
43
+ const spinner = ora("Installing core dependencies (framer-motion, @mediapipe/tasks-vision)...").start();
44
+
45
+ try {
46
+ execSync("npm install framer-motion @mediapipe/tasks-vision", { stdio: "ignore" });
47
+ spinner.succeed("Core dependencies installed.");
48
+ } catch (error) {
49
+ spinner.fail("Failed to install dependencies.");
50
+ process.exit(1);
51
+ }
52
+
53
+ // Save a config file so `add` knows where to put things
54
+ const configPath = path.join(process.cwd(), "kine-ui.json");
55
+ fs.writeJSONSync(configPath, { componentsDir: response.componentsDir }, { spaces: 2 });
56
+
57
+ console.log(chalk.green("\n✓ Successfully initialized Kine UI and created kine-ui.json"));
58
+ console.log(chalk.gray("To start building, try adding the global provider and a gesture:\n"));
59
+ console.log(chalk.cyan(" npx kine-ui add kine-provider"));
60
+ console.log(chalk.cyan(" npx kine-ui add air-cursor"));
61
+ });
62
+
63
+ program
64
+ .command("add")
65
+ .description("Add a Kine UI gesture component")
66
+ .argument("<component>", "the component to add (e.g. 'air-cursor', 'swipe-area', 'kine-provider')")
67
+ .action(async (component) => {
68
+ let config;
69
+ try {
70
+ config = fs.readJSONSync(path.join(process.cwd(), "kine-ui.json"));
71
+ } catch (e) {
72
+ console.log(chalk.red("kine-ui.json not found. Please run `npx kine-ui init` first."));
73
+ process.exit(1);
74
+ }
75
+
76
+ const spinner = ora(`Fetching ${component} from registry...`).start();
77
+
78
+ try {
79
+ // Note: In production this would point to standard registry endpoints
80
+ // For now, it will look at the public/r/styles/default output
81
+ const res = await fetch(`${REGISTRY_URL}/${component}.json`);
82
+
83
+ if (!res.ok) {
84
+ if (res.status === 404) {
85
+ throw new Error(`Component '${component}' not found in registry.`);
86
+ }
87
+ throw new Error(`Failed to fetch component. Status: ${res.status}`);
88
+ }
89
+
90
+ interface RegistryItem {
91
+ dependencies?: string[];
92
+ files: { target: string; content: string }[];
93
+ }
94
+
95
+ const item = await res.json() as RegistryItem;
96
+ spinner.text = `Installing ${component}...`;
97
+
98
+ // Install specific dependencies if the component asks for them
99
+ if (item.dependencies && item.dependencies.length > 0) {
100
+ const deps = item.dependencies.join(" ");
101
+ spinner.text = `Installing additional dependencies: ${deps}...`;
102
+ execSync(`npm install ${deps}`, { stdio: "ignore" });
103
+ }
104
+
105
+ // Ensure TARGET directory exists
106
+ const targetDir = path.join(process.cwd(), config.componentsDir);
107
+ fs.ensureDirSync(targetDir);
108
+
109
+ // Write all files attached to this component
110
+ for (const fileDoc of item.files) {
111
+ const filePath = path.join(process.cwd(), fileDoc.target);
112
+
113
+ // create the directory for the file itself in case it's nested (like core/kine-engine.ts)
114
+ fs.ensureDirSync(path.dirname(filePath));
115
+
116
+ fs.writeFileSync(filePath, fileDoc.content, "utf-8");
117
+ }
118
+
119
+ spinner.succeed(`Successfully installed ${chalk.green(component)} to ${config.componentsDir}`);
120
+
121
+ } catch (error: any) {
122
+ spinner.fail(error.message || "Failed to add component.");
123
+ process.exit(1);
124
+ }
125
+ });
126
+
127
+ program.parse();