kadence-lang 0.2.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 (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +208 -0
  3. package/bin/kadence.js +806 -0
  4. package/package.json +64 -0
  5. package/src/compiler.js +2291 -0
  6. package/src/vite-plugin-kadence.js +39 -0
  7. package/stdlib/check-helpers.js +13 -0
  8. package/stdlib/check.js +57 -0
  9. package/stdlib/check.kade +21 -0
  10. package/stdlib/color-helpers.js +34 -0
  11. package/stdlib/color.js +60 -0
  12. package/stdlib/color.kade +24 -0
  13. package/stdlib/console.js +57 -0
  14. package/stdlib/console.kade +21 -0
  15. package/stdlib/crypto-helpers.js +17 -0
  16. package/stdlib/crypto.js +46 -0
  17. package/stdlib/crypto.kade +11 -0
  18. package/stdlib/datetime.js +68 -0
  19. package/stdlib/datetime.kade +32 -0
  20. package/stdlib/encoding.js +55 -0
  21. package/stdlib/encoding.kade +19 -0
  22. package/stdlib/env.js +46 -0
  23. package/stdlib/env.kade +11 -0
  24. package/stdlib/file.js +94 -0
  25. package/stdlib/file.kade +57 -0
  26. package/stdlib/html.js +65 -0
  27. package/stdlib/html.kade +29 -0
  28. package/stdlib/json.js +63 -0
  29. package/stdlib/json.kade +28 -0
  30. package/stdlib/list.js +109 -0
  31. package/stdlib/list.kade +75 -0
  32. package/stdlib/math.js +76 -0
  33. package/stdlib/math.kade +39 -0
  34. package/stdlib/network.js +66 -0
  35. package/stdlib/network.kade +38 -0
  36. package/stdlib/number.js +53 -0
  37. package/stdlib/number.kade +17 -0
  38. package/stdlib/object-helpers.js +44 -0
  39. package/stdlib/object.js +59 -0
  40. package/stdlib/object.kade +23 -0
  41. package/stdlib/path.js +58 -0
  42. package/stdlib/path.kade +23 -0
  43. package/stdlib/process-helpers.js +18 -0
  44. package/stdlib/process.js +62 -0
  45. package/stdlib/process.kade +29 -0
  46. package/stdlib/promise-helpers.js +21 -0
  47. package/stdlib/promise.js +54 -0
  48. package/stdlib/promise.kade +19 -0
  49. package/stdlib/random.js +82 -0
  50. package/stdlib/random.kade +46 -0
  51. package/stdlib/regex-helpers.js +18 -0
  52. package/stdlib/regex.js +46 -0
  53. package/stdlib/regex.kade +11 -0
  54. package/stdlib/stream.js +58 -0
  55. package/stdlib/stream.kade +22 -0
  56. package/stdlib/string-helpers.js +16 -0
  57. package/stdlib/string.js +101 -0
  58. package/stdlib/string.kade +66 -0
  59. package/stdlib/system.js +66 -0
  60. package/stdlib/system.kade +31 -0
  61. package/stdlib/test-helpers.js +18 -0
  62. package/stdlib/test.js +72 -0
  63. package/stdlib/test.kade +37 -0
  64. package/stdlib/url.js +50 -0
  65. package/stdlib/url.kade +14 -0
  66. package/stdlib/uuid.js +70 -0
  67. package/stdlib/uuid.kade +35 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The Kadence Team
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,208 @@
1
+ # Kadence Programming Language πŸš€
2
+
3
+ [![npm version](https://img.shields.io/npm/v/kadence-lang.svg?style=flat-square)](https://www.npmjs.com/package/kadence-lang)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
5
+ [![Build Status](https://img.shields.io/badge/build-passing-brightgreen?style=flat-square)](https://github.com/kadence-lang/kadence-lang)
6
+
7
+ **A human-readable programming language that feels like poetry.**
8
+
9
+ Kadence is designed to make code read like natural English while maintaining the full power of modern programming environments. It bridges the gap between readable intent and high-performance execution by compiling into clean, optimized ES6+ JavaScript.
10
+
11
+ ---
12
+
13
+ ## 🌟 Why Kadence?
14
+
15
+ * **Poetic Syntax**: Express logic in sentences, not just symbols.
16
+ * **Zero Punctuation Fatigue**: Minimal requirement for braces, semicolons, or boilerplate.
17
+ * **Modern Power**: Built-in support for Classes, Async/Await, Pattern Matching, and Functional Programming.
18
+ * **Universal**: Run in Node.js for CLI tools or in any modern browser for web apps.
19
+ * **Smart DX**: Intelligent preprocessor for indentation-based blocks with optional `end` keywords.
20
+
21
+ ---
22
+
23
+ ## πŸš€ Quick Start
24
+
25
+ ### Try it now (No Install)
26
+ Use `npx` to initialize a new Kadence project instantly:
27
+
28
+ ```bash
29
+ # For a Web Application (Vite-powered)
30
+ npx kadence-lang create my-poetic-app --web
31
+
32
+ # For a CLI/Node Application
33
+ npx kadence-lang create my-poetic-tool
34
+ ```
35
+
36
+ ### Manual Installation
37
+ Install the CLI globally for the best experience:
38
+
39
+ ```bash
40
+ npm install -g kadence-lang
41
+ ```
42
+
43
+ ---
44
+
45
+ ## πŸ“ The Kadence Experience
46
+
47
+ Create a file named `intro.kade`:
48
+
49
+ ```kadence
50
+ let name be "Kadence"
51
+ say "Welcome to {name}!"
52
+
53
+ let numbers be list 1 2 3 4 5
54
+ let avg = average of numbers
55
+
56
+ if avg more than 3
57
+ say "Success: The average is high! ({avg})"
58
+ else
59
+ say "The average is {avg}"
60
+ end
61
+
62
+ // Functional power
63
+ let doubled = map numbers with (x) => x * 2
64
+ say "Doubled: {doubled}"
65
+ ```
66
+
67
+ Run it immediately:
68
+ ```bash
69
+ kadence intro.kade
70
+ ```
71
+
72
+ Validate your install with the bundled example:
73
+ ```bash
74
+ kadence examples/01_hello_world.kade
75
+ ```
76
+
77
+ ---
78
+
79
+ ## πŸ—οΈ Language Features
80
+
81
+ ### Variables & Blocks
82
+ Kadence uses `let`, `const`, `be`, and `is` for natural declarations.
83
+ ```kadence
84
+ let mutable be 42
85
+ const fixed is "eternal"
86
+
87
+ // Blocks can be indentation-based or explicit
88
+ if status equals "ok"
89
+ say "Proceeding..."
90
+ end
91
+ ```
92
+
93
+ ### Pattern Matching
94
+ Modern branching logic that reads like a story.
95
+ ```kadence
96
+ match status_code
97
+ when 200 then say "Success"
98
+ when 404 then say "Not Found"
99
+ else say "Unknown Error"
100
+ end
101
+ ```
102
+
103
+ ### Async/Await
104
+ First-class support for the modern web and I/O.
105
+ ```kadence
106
+ async function fetchUser id
107
+ say "Fetching user {id}..."
108
+ let data = await get from "https://api.example.com/users/{id}"
109
+ give data
110
+ end
111
+ ```
112
+
113
+ ### Classes
114
+ Clean, readable Object-Oriented programming.
115
+ ```kadence
116
+ class Manager
117
+ function constructor name
118
+ this.name = name
119
+ end
120
+
121
+ function greet
122
+ say "Manager {this.name} reports for duty!"
123
+ end
124
+ end
125
+
126
+ let boss = new Manager "Alice"
127
+ run boss.greet
128
+ ```
129
+
130
+ ---
131
+
132
+ ## πŸ“¦ Standard Library
133
+
134
+ Kadence ships with a comprehensive set of modules for common tasks.
135
+
136
+ | Module | Core Functionality |
137
+ | :--- | :--- |
138
+ | `list` | `first`, `lastOf`, `shuffle`, `range`, `unique` |
139
+ | `string` | `trimmed`, `repeated`, `toCamelCase`, `padStart`, `words` |
140
+ | `math` | `clamp`, `randomFloat`, `toRadians`, `hypotenuse` |
141
+ | `datetime` | `the time now`, `the date today`, `diffDays`, `toIso` |
142
+ | `file` | `readFile`, `writeFile`, `copyDir`, `removeDir`, `stat` |
143
+ | `path` | `joinPaths`, `resolve`, `basename`, `dirname`, `extension` |
144
+ | `env` | `getEnv`, `hasEnv` (Environment Variables) |
145
+ | `process` | `args`, `exit`, `cwd` |
146
+ | `system` | `platform`, `arch`, `totalMemory`, `freeMemory` |
147
+ | `network` | `serve`, `fetchJson` (Simple HTTP Server) |
148
+ | `json` | `readJson`, `writeJson`, `format`, `parseSafe` |
149
+ | `check` | `isNumber`, `isString`, `isEmail`, `between` |
150
+ | `test` | `suite`, `assertEquals`, `assertTrue`, `assertThrows` |
151
+ | `color` | `randomHex`, `rgbToHex`, `hexToRgb` |
152
+ | `html` | `div`, `span`, `p`, `img`, `link` (Browser only) |
153
+ | `crypto` | `hash`, `randomBytes`, `uuid` |
154
+
155
+ *Usage Example:*
156
+ ```kadence
157
+ import "stdlib/math.kade" as math
158
+ let result = run math.clamp index 0 100
159
+ ```
160
+
161
+ ---
162
+
163
+ ## πŸ› οΈ Tooling
164
+
165
+ ### VS Code Extension
166
+ The official extension provides:
167
+ * ✨ Syntax Highlighting
168
+ * ⌨️ Intelligent Snippets (`if`, `for`, `function`, `class`, `match`)
169
+ * πŸ“ Auto-Indentation
170
+
171
+ **To install:** Copy the `kadence-vscode` folder to your `.vscode/extensions` directory or search for "Kadence" in the marketplace.
172
+
173
+ ### CLI Commands
174
+ ```bash
175
+ kadence <file> # Run a file
176
+ kadence -c <file> # Compile to JS
177
+ kadence build # Build project (src -> dist)
178
+ kadence dev # Start dev server (for --web projects)
179
+ kadence help # View all commands
180
+ ```
181
+
182
+ ---
183
+
184
+ ## πŸ—ΊοΈ Roadmap
185
+
186
+ - [x] Full Module System (`import`/`export`)
187
+ - [x] Standard Library Core (40+ modules)
188
+ - [x] Browser Runtime & Vite Plugin
189
+ - [x] Source Maps for easy debugging
190
+ - [ ] Language Server Protocol (LSP) for enhanced IDE support
191
+ - [ ] Integrated Package Registry for Kadence modules
192
+ - [ ] Native Mobile Build Target
193
+
194
+ ---
195
+
196
+ ## 🀝 Contributing
197
+
198
+ We love poetic code. If you want to contribute, please check our [Contributing Guide](docs/CONTRIBUTING.md).
199
+
200
+ ---
201
+
202
+ ## πŸ“„ License
203
+
204
+ Kadence is released under the **MIT License**.
205
+
206
+ ---
207
+
208
+ **Made with ❀️ for developers who believe code should be beautiful.**