kin-lang 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.
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "kin-lang",
3
+ "version": "1.0.0",
4
+ "description": "The Kin programming language — compiler, CLI, and toolchain",
5
+ "main": "dist/kin.js",
6
+ "bin": {
7
+ "kin": "dist/kin-cli.js"
8
+ },
9
+ "files": [
10
+ "dist/",
11
+ "src/std/",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "scripts": {
16
+ "start": "ts-node src/main.ts",
17
+ "kin": "ts-node src/cli/index.ts",
18
+ "test": "jest --testPathPattern=src/__tests__",
19
+ "build": "npm run build:cli && npm run build:lsp && npm run build:launcher",
20
+ "build:cli": "esbuild src/cli/index.ts --bundle --platform=node --target=node18 --outfile=dist/kin.js --external:typescript",
21
+ "build:lsp": "esbuild src/lsp/server.ts --bundle --platform=node --target=node18 --outfile=dist/lsp/server.js",
22
+ "build:launcher": "node -e \"require('fs').writeFileSync('dist/kin-cli.js', '#!/usr/bin/env node\\nrequire(\\\"./kin.js\\\");\\n')\"",
23
+ "build:ext": "npm run build:lsp && npm --prefix vscode-extension run compile",
24
+ "package:ext": "npm run build:ext && npm --prefix vscode-extension run package",
25
+ "install:ext": "npm run package:ext && code --install-extension vscode-extension/kin-lang.vsix",
26
+ "prepublishOnly": "npm run build && npm test"
27
+ },
28
+ "keywords": [
29
+ "kin",
30
+ "programming-language",
31
+ "compiler",
32
+ "cli",
33
+ "language",
34
+ "react",
35
+ "react-native",
36
+ "electron"
37
+ ],
38
+ "author": "Kin Language Team",
39
+ "license": "MIT",
40
+ "type": "commonjs",
41
+ "engines": {
42
+ "node": ">=18.0.0"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "https://github.com/kin-lang/kin-lang.git"
47
+ },
48
+ "homepage": "https://kin-lang.dev",
49
+ "bugs": {
50
+ "url": "https://github.com/kin-lang/kin-lang/issues"
51
+ },
52
+ "dependencies": {
53
+ "ts-node": "^10.9.2",
54
+ "typescript": "^6.0.3"
55
+ },
56
+ "devDependencies": {
57
+ "@types/jest": "^29.5.12",
58
+ "@types/node": "^26.0.0",
59
+ "esbuild": "^0.25.0",
60
+ "fast-check": "3.19.0",
61
+ "jest": "29.7.0",
62
+ "ts-jest": "^29.4.11"
63
+ }
64
+ }
@@ -0,0 +1,5 @@
1
+ // Kin Standard Library — console
2
+ export function log(...args) { console.log(...args); }
3
+ export function warn(...args) { console.warn(...args); }
4
+ export function error(...args) { console.error(...args); }
5
+ export function clear() { console.clear(); }
package/src/std/fs.js ADDED
@@ -0,0 +1,26 @@
1
+ // Kin Standard Library — fs (Node.js file system)
2
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, unlinkSync } from "fs";
3
+
4
+ export function read(filePath) {
5
+ return readFileSync(filePath, "utf8");
6
+ }
7
+
8
+ export function write(filePath, content) {
9
+ writeFileSync(filePath, content, "utf8");
10
+ }
11
+
12
+ export function exists(filePath) {
13
+ return existsSync(filePath);
14
+ }
15
+
16
+ export function mkdir(dirPath) {
17
+ mkdirSync(dirPath, { recursive: true });
18
+ }
19
+
20
+ export function list(dirPath) {
21
+ return readdirSync(dirPath);
22
+ }
23
+
24
+ export function remove(filePath) {
25
+ unlinkSync(filePath);
26
+ }
@@ -0,0 +1,17 @@
1
+ // Kin Standard Library — http
2
+ export async function get(url) {
3
+ const res = await fetch(url);
4
+ if (!res.ok) throw new Error(`http.get: ${res.status} ${res.statusText}`);
5
+ const contentType = res.headers.get("content-type") ?? "";
6
+ return contentType.includes("application/json") ? res.json() : res.text();
7
+ }
8
+
9
+ export async function post(url, body) {
10
+ const res = await fetch(url, {
11
+ method: "POST",
12
+ headers: { "Content-Type": "application/json" },
13
+ body: JSON.stringify(body),
14
+ });
15
+ if (!res.ok) throw new Error(`http.post: ${res.status} ${res.statusText}`);
16
+ return res.json();
17
+ }
@@ -0,0 +1,14 @@
1
+ // Kin Standard Library — json
2
+ export function parse(str) {
3
+ try {
4
+ return JSON.parse(str);
5
+ } catch (e) {
6
+ throw new Error("json.parse: invalid JSON string");
7
+ }
8
+ }
9
+
10
+ export function stringify(value, pretty) {
11
+ return pretty
12
+ ? JSON.stringify(value, null, 2)
13
+ : JSON.stringify(value);
14
+ }
@@ -0,0 +1,16 @@
1
+ // Kin Standard Library — math
2
+ export function add(a, b) { return a + b; }
3
+ export function subtract(a, b) { return a - b; }
4
+ export function multiply(a, b) { return a * b; }
5
+ export function divide(a, b) {
6
+ if (b === 0) throw new Error("Division by zero");
7
+ return a / b;
8
+ }
9
+ export function abs(n) { return Math.abs(n); }
10
+ export function pow(a,b) { return Math.pow(a, b); }
11
+ export function sqrt(n) { return Math.sqrt(n); }
12
+ export function square(n){ return n * n; }
13
+ export function floor(n) { return Math.floor(n); }
14
+ export function ceil(n) { return Math.ceil(n); }
15
+ export function round(n) { return Math.round(n); }
16
+ export const PI = Math.PI;
@@ -0,0 +1,12 @@
1
+ // Kin Standard Library — time
2
+ export function now() {
3
+ return Date.now();
4
+ }
5
+
6
+ export function wait(ms) {
7
+ return new Promise(resolve => setTimeout(resolve, ms));
8
+ }
9
+
10
+ export function format(timestamp) {
11
+ return new Date(timestamp).toISOString();
12
+ }
package/src/std/ui.js ADDED
@@ -0,0 +1,173 @@
1
+ import React from 'react';
2
+
3
+ let RN = null;
4
+ try {
5
+ RN = require('react-native');
6
+ } catch (e) {}
7
+
8
+ export function Navbar({ title }) {
9
+ if (RN) {
10
+ const { View, Text } = RN;
11
+ return (
12
+ <View style={nativeStyles.navbar}>
13
+ <Text style={nativeStyles.navbarTitle}>{title}</Text>
14
+ </View>
15
+ );
16
+ } else {
17
+ return (
18
+ <div style={webStyles.navbar}>
19
+ <span style={webStyles.navbarTitle}>{title}</span>
20
+ </div>
21
+ );
22
+ }
23
+ }
24
+
25
+ export function Card({ title, body }) {
26
+ if (RN) {
27
+ const { View, Text } = RN;
28
+ return (
29
+ <View style={nativeStyles.card}>
30
+ <Text style={nativeStyles.cardTitle}>{title}</Text>
31
+ <Text style={nativeStyles.cardBody}>{body}</Text>
32
+ </View>
33
+ );
34
+ } else {
35
+ return (
36
+ <div style={webStyles.card}>
37
+ <div style={webStyles.cardTitle}>{title}</div>
38
+ <div style={webStyles.cardBody}>{body}</div>
39
+ </div>
40
+ );
41
+ }
42
+ }
43
+
44
+ export function Badge({ text }) {
45
+ if (RN) {
46
+ const { View, Text } = RN;
47
+ return (
48
+ <View style={nativeStyles.badge}>
49
+ <Text style={nativeStyles.badgeText}>{text}</Text>
50
+ </View>
51
+ );
52
+ } else {
53
+ return (
54
+ <span style={webStyles.badge}>
55
+ {text}
56
+ </span>
57
+ );
58
+ }
59
+ }
60
+
61
+ const webStyles = {
62
+ navbar: {
63
+ display: 'flex',
64
+ alignItems: 'center',
65
+ justifyContent: 'center',
66
+ height: '64px',
67
+ background: 'linear-gradient(135deg, #1e1b4b 0%, #311042 100%)',
68
+ borderBottom: '1px solid rgba(255, 255, 255, 0.1)',
69
+ boxShadow: '0 4px 20px rgba(0, 0, 0, 0.25)',
70
+ padding: '0 24px',
71
+ width: '100%',
72
+ boxSizing: 'border-box',
73
+ },
74
+ navbarTitle: {
75
+ color: '#f8fafc',
76
+ fontSize: '20px',
77
+ fontWeight: '700',
78
+ fontFamily: '"Outfit", "Inter", sans-serif',
79
+ letterSpacing: '0.5px',
80
+ },
81
+ card: {
82
+ background: 'rgba(30, 41, 59, 0.7)',
83
+ backdropFilter: 'blur(16px)',
84
+ WebkitBackdropFilter: 'blur(16px)',
85
+ border: '1px solid rgba(255, 255, 255, 0.08)',
86
+ borderRadius: '16px',
87
+ padding: '24px',
88
+ margin: '16px auto',
89
+ maxWidth: '480px',
90
+ boxShadow: '0 10px 30px rgba(0, 0, 0, 0.3)',
91
+ color: '#ffffff',
92
+ fontFamily: '"Inter", sans-serif',
93
+ },
94
+ cardTitle: {
95
+ fontSize: '18px',
96
+ fontWeight: '600',
97
+ marginBottom: '8px',
98
+ color: '#38bdf8',
99
+ },
100
+ cardBody: {
101
+ fontSize: '14px',
102
+ lineHeight: '1.6',
103
+ color: '#cbd5e1',
104
+ },
105
+ badge: {
106
+ display: 'inline-block',
107
+ padding: '6px 12px',
108
+ fontSize: '12px',
109
+ fontWeight: '600',
110
+ color: '#ffffff',
111
+ background: 'linear-gradient(135deg, #0d9488 0%, #0f766e 100%)',
112
+ borderRadius: '100px',
113
+ boxShadow: '0 2px 8px rgba(13, 148, 136, 0.3)',
114
+ fontFamily: '"Inter", sans-serif',
115
+ textTransform: 'uppercase',
116
+ letterSpacing: '0.5px',
117
+ }
118
+ };
119
+
120
+ const nativeStyles = {
121
+ navbar: {
122
+ height: 64,
123
+ backgroundColor: '#1e1b4b',
124
+ borderBottomWidth: 1,
125
+ borderBottomColor: 'rgba(255, 255, 255, 0.1)',
126
+ justifyContent: 'center',
127
+ alignItems: 'center',
128
+ paddingHorizontal: 20,
129
+ },
130
+ navbarTitle: {
131
+ color: '#f8fafc',
132
+ fontSize: 18,
133
+ fontWeight: 'bold',
134
+ },
135
+ card: {
136
+ backgroundColor: '#1e293b',
137
+ borderRadius: 16,
138
+ padding: 20,
139
+ marginVertical: 10,
140
+ marginHorizontal: 15,
141
+ borderWidth: 1,
142
+ borderColor: 'rgba(255, 255, 255, 0.08)',
143
+ shadowColor: '#000',
144
+ shadowOffset: { width: 0, height: 4 },
145
+ shadowOpacity: 0.3,
146
+ shadowRadius: 5,
147
+ elevation: 6,
148
+ },
149
+ cardTitle: {
150
+ fontSize: 18,
151
+ fontWeight: 'bold',
152
+ color: '#38bdf8',
153
+ marginBottom: 6,
154
+ },
155
+ cardBody: {
156
+ fontSize: 14,
157
+ color: '#cbd5e1',
158
+ lineHeight: 20,
159
+ },
160
+ badge: {
161
+ backgroundColor: '#0d9488',
162
+ borderRadius: 100,
163
+ paddingVertical: 4,
164
+ paddingHorizontal: 10,
165
+ alignSelf: 'flex-start',
166
+ },
167
+ badgeText: {
168
+ color: '#ffffff',
169
+ fontSize: 11,
170
+ fontWeight: 'bold',
171
+ textTransform: 'uppercase',
172
+ }
173
+ };