clearkrypt 0.12.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/.well-known/clearkrypt.json +7 -0
- package/.wrangler/cache/pages.json +4 -0
- package/.wrangler/cache/wrangler-account.json +6 -0
- package/DEPLOYMENT_CLEARKRYPT.md +53 -0
- package/README.md +96 -0
- package/ai-plugin.json +12 -0
- package/bin/clearkrypt.js +55 -0
- package/course/duolingo_course.md +127 -0
- package/docs/AI_CRAWLER_GUIDE.md +74 -0
- package/docs/COMPILER_ARCHITECTURE.md +62 -0
- package/docs/COMPLETE_LANGUAGE_GUIDE.md +137 -0
- package/docs/LANGUAGE_SPEC.md +102 -0
- package/docs/LAYOUT_AND_STYLING.md +101 -0
- package/docs/ONLINE_SANDBOX_EXPORTS.md +28 -0
- package/docs/PLATFORM_TARGETS.md +35 -0
- package/docs/README.md +79 -0
- package/docs/STDLIB.md +74 -0
- package/docs/VISUAL_STUDIO.md +36 -0
- package/docs-site/app.css +3 -0
- package/docs-site/app.js +8 -0
- package/docs-site/clearkrypt/app.css +3 -0
- package/docs-site/clearkrypt/app.js +8 -0
- package/docs-site/clearkrypt/index.html +44 -0
- package/examples/fixit-dashboard/main.ck +29 -0
- package/examples/light-test-app/main.ck +38 -0
- package/examples/momeants-mini/main.ck +19 -0
- package/llms.txt +18 -0
- package/openapi.yaml +11 -0
- package/package.json +32 -0
- package/site/.well-known/clearkrypt.json +1 -0
- package/site/ai-index.json +1 -0
- package/site/app.css +3 -0
- package/site/app.js +23 -0
- package/site/assets/app.css +3 -0
- package/site/assets/app.js +23 -0
- package/site/assets/clearkrypt-logo.png +0 -0
- package/site/compiler/index.html +8 -0
- package/site/course/index.html +5 -0
- package/site/docs/index.html +69 -0
- package/site/extensions/index.html +31 -0
- package/site/index.html +19 -0
- package/site/llms.txt +2 -0
- package/site/robots.txt +3 -0
- package/site/sandbox/index.html +24 -0
- package/site/sitemap.xml +1 -0
- package/sitemap.xml +9 -0
- package/src/index.js +55 -0
- package/src/lexer.js +18 -0
- package/src/parser.js +52 -0
- package/src/semantic.js +5 -0
- package/src/targets/js.js +32 -0
- package/src/targets/pc.js +19 -0
- package/src/targets/phone.js +30 -0
- package/src/targets/project.js +24 -0
- package/src/targets/vmbytecode.js +8 -0
- package/src/targets/web.js +37 -0
- package/src/targets/worker.js +8 -0
- package/src/vm.js +5 -0
- package/stdlib/cloud.ck +2 -0
- package/stdlib/data.ck +2 -0
- package/stdlib/ui.ck +2 -0
- package/testapp.ck +35 -0
- package/tests/smoke.test.js +9 -0
- package/tools/print-course.js +2 -0
- package/tools/studio/index.html +1 -0
- package/tools/studio/studio.css +1 -0
- package/tools/studio/studio.js +52 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# ClearKrypt Deployment
|
|
2
|
+
|
|
3
|
+
This v3 package separates the public ClearKrypt website from compiled example apps.
|
|
4
|
+
|
|
5
|
+
Do **not** deploy `dist/web` unless you intentionally want to deploy a compiled sample app.
|
|
6
|
+
|
|
7
|
+
## Deploy the public ClearKrypt site
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
cd C:\Users\COwen\Downloads\clearkrypt\clearkrypt_language
|
|
11
|
+
npx wrangler pages project create clearkrypt
|
|
12
|
+
npx wrangler pages deploy .\site --project-name clearkrypt
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Attach this custom domain to the `clearkrypt` Pages project:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
clearkrypt.clearkey.solutions
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This site includes:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
/
|
|
25
|
+
/sandbox/
|
|
26
|
+
/extensions/
|
|
27
|
+
/llms.txt
|
|
28
|
+
/.well-known/clearkrypt.json
|
|
29
|
+
/sitemap.xml
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Deploy docs at docs.clearkey.solutions/clearkrypt
|
|
33
|
+
|
|
34
|
+
Option A, same site already includes docs at `/docs/clearkrypt`.
|
|
35
|
+
|
|
36
|
+
Option B, separate docs Pages project:
|
|
37
|
+
|
|
38
|
+
```powershell
|
|
39
|
+
npx wrangler pages project create clearkey-docs
|
|
40
|
+
npx wrangler pages deploy .\site\docs --project-name clearkey-docs
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Attach this custom domain to the `clearkey-docs` Pages project:
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
docs.clearkey.solutions
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Then the docs live at:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
https://docs.clearkey.solutions/clearkrypt/
|
|
53
|
+
```
|
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# ClearKrypt
|
|
2
|
+
|
|
3
|
+
ClearKrypt is a powerful cross-platform application language designed for deterministic 1-to-1 export across web, worker, server, and future native targets.
|
|
4
|
+
|
|
5
|
+
This repository contains the first launchable foundation:
|
|
6
|
+
|
|
7
|
+
- npm package
|
|
8
|
+
- CLI
|
|
9
|
+
- parser
|
|
10
|
+
- compiler
|
|
11
|
+
- VM target
|
|
12
|
+
- web target
|
|
13
|
+
- worker target
|
|
14
|
+
- docs
|
|
15
|
+
- standard library plan
|
|
16
|
+
- examples
|
|
17
|
+
- Duolingo-style course
|
|
18
|
+
|
|
19
|
+
## Install locally
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install
|
|
23
|
+
npm link
|
|
24
|
+
ck --help
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Run example
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
ck run examples/fixit-dashboard/main.ck
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Build web app
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
ck build examples/fixit-dashboard/main.ck --target web --out dist/fixit-dashboard
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Open `dist/fixit-dashboard/index.html`.
|
|
40
|
+
|
|
41
|
+
## Build Cloudflare Worker
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
ck build examples/fixit-dashboard/main.ck --target worker --out dist/worker
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Important Reality
|
|
48
|
+
|
|
49
|
+
This is a real runnable foundation, not a complete Dart-sized ecosystem. A truly production-grade language ecosystem normally requires years of compiler, VM, package, IDE, runtime, and platform work. This package gives ClearKrypt a serious launch base that can be expanded without throwing it away.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## New in this package
|
|
53
|
+
|
|
54
|
+
### Multi-platform build environments
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
ck build-all examples/fixit-dashboard/main.ck --out build
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This creates `web/`, `phone/`, `pc/`, and `worker/` folders so developers can see exactly how one ClearKrypt source compiles for browser, mobile, desktop, and edge runtime environments.
|
|
61
|
+
|
|
62
|
+
### Visual drag editor
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
ck studio examples/fixit-dashboard/main.ck --out studio
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Open `studio/index.html`, drag UI nodes, and copy/download the updated `.ck` source. ClearKrypt stores drag positions as `@pos(x, y)` metadata directly in the source code.
|
|
69
|
+
|
|
70
|
+
### AI/crawler friendly
|
|
71
|
+
|
|
72
|
+
This package includes `llms.txt`, `ai-plugin.json`, `.well-known/clearkrypt.json`, `docs/AI_CRAWLER_GUIDE.md`, and `sitemap.xml` so search engines and AI coding tools can understand how to generate ClearKrypt apps without guessing.
|
|
73
|
+
|
|
74
|
+
## Public website vs compiled app output
|
|
75
|
+
|
|
76
|
+
The public ClearKrypt language website is in:
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
site/
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Deploy that folder for the language homepage, sandbox, extensions page, crawler files, and docs shell.
|
|
83
|
+
|
|
84
|
+
Do not deploy `dist/web` unless you are deploying an app generated from a `.ck` file.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx wrangler pages deploy ./site --project-name clearkrypt
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## v4 website deployment
|
|
92
|
+
Deploy the public ClearKrypt website from `site/`, not from `dist/web`. `dist/web` is for compiled user programs.
|
|
93
|
+
|
|
94
|
+
```powershell
|
|
95
|
+
npx wrangler pages deploy .\site --project-name clearkrypt
|
|
96
|
+
```
|
package/ai-plugin.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": "v1",
|
|
3
|
+
"name_for_human": "ClearKrypt Language",
|
|
4
|
+
"name_for_model": "clearkrypt_language",
|
|
5
|
+
"description_for_human": "ClearKrypt is a cross-platform app language with deterministic web, phone, PC, worker, JS, and VM builds.",
|
|
6
|
+
"description_for_model": "Use ClearKrypt syntax to create apps. Read docs/AI_CRAWLER_GUIDE.md, docs/LANGUAGE_SPEC.md, and docs/STDLIB.md before generating code.",
|
|
7
|
+
"auth": { "type": "none" },
|
|
8
|
+
"api": { "type": "openapi", "url": "/openapi.yaml" },
|
|
9
|
+
"logo_url": "/clearKrypt-logo.png",
|
|
10
|
+
"contact_email": "support@example.com",
|
|
11
|
+
"legal_info_url": "/legal"
|
|
12
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { compileFile, runFile, initProject } from '../src/index.js';
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const cmd = args[0];
|
|
8
|
+
function flag(name, fallback=null){ const i=args.indexOf(name); return i>=0 ? args[i+1] : fallback; }
|
|
9
|
+
function has(name){ return args.includes(name); }
|
|
10
|
+
function help(){
|
|
11
|
+
console.log(`ClearKrypt v0.1.0
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
ck init <name>
|
|
15
|
+
ck run <file.ck>
|
|
16
|
+
ck build <file.ck> --target js|web|phone|pc|worker|vm|project --out <dir>
|
|
17
|
+
ck build-all <file.ck> --out <dir>
|
|
18
|
+
ck studio <file.ck> --out <dir>
|
|
19
|
+
ck check <file.ck>
|
|
20
|
+
ck docs
|
|
21
|
+
ck site --out <dir>
|
|
22
|
+
`);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
if(!cmd || has('--help') || has('-h')) help();
|
|
26
|
+
else if(cmd==='init') initProject(args[1] || 'clearkrypt-app');
|
|
27
|
+
else if(cmd==='run') await runFile(args[1]);
|
|
28
|
+
else if(cmd==='check') { const res = await compileFile(args[1], {target:'vm'}); console.log('✓ ClearKrypt check passed:', res.meta.name || args[1]); }
|
|
29
|
+
else if(cmd==='build-all') {
|
|
30
|
+
const input=args[1]; const out=flag('--out','clearkrypt-build');
|
|
31
|
+
const result = await compileFile(input,{target:'project',outDir:out});
|
|
32
|
+
console.log(`✓ Built all environments for ${input} -> ${out}`);
|
|
33
|
+
if(result.files) for(const f of result.files) console.log(' '+f);
|
|
34
|
+
} else if(cmd==='studio') {
|
|
35
|
+
const input=args[1]; const out=flag('--out','clearkrypt-studio');
|
|
36
|
+
const result = await compileFile(input,{target:'web',outDir:out});
|
|
37
|
+
const studioSrc = path.resolve(path.dirname(new URL(import.meta.url).pathname),'../tools/studio');
|
|
38
|
+
fs.cpSync(studioSrc, out, {recursive:true});
|
|
39
|
+
fs.copyFileSync(input, path.join(out,'source.ck'));
|
|
40
|
+
console.log(`✓ Visual studio exported -> ${out}. Open index.html`);
|
|
41
|
+
|
|
42
|
+
} else if(cmd==='site') {
|
|
43
|
+
const out=flag('--out','clearkrypt-site');
|
|
44
|
+
const siteSrc = path.resolve(path.dirname(new URL(import.meta.url).pathname),'../site');
|
|
45
|
+
fs.rmSync(out,{recursive:true,force:true});
|
|
46
|
+
fs.cpSync(siteSrc, out, {recursive:true});
|
|
47
|
+
console.log(`✓ ClearKrypt public website exported -> ${out}`);
|
|
48
|
+
} else if(cmd==='build') {
|
|
49
|
+
const input=args[1]; const target=flag('--target','web'); const out=flag('--out','dist');
|
|
50
|
+
const result = await compileFile(input,{target,outDir:out});
|
|
51
|
+
console.log(`✓ Built ${input} -> ${out} (${target})`);
|
|
52
|
+
if(result.files) for(const f of result.files) console.log(' '+f);
|
|
53
|
+
} else if(cmd==='docs') console.log('Open docs/README.md in this package.');
|
|
54
|
+
else help();
|
|
55
|
+
} catch(e){ console.error('ClearKrypt error:', e.message); if(process.env.CK_DEBUG) console.error(e.stack); process.exit(1); }
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# ClearKrypt Academy — Duolingo-Style Course
|
|
2
|
+
|
|
3
|
+
## Unit 1: First Words
|
|
4
|
+
|
|
5
|
+
Goal: write your first app.
|
|
6
|
+
|
|
7
|
+
### Lesson 1
|
|
8
|
+
Prompt: Translate this into ClearKrypt: The app is called Hello.
|
|
9
|
+
|
|
10
|
+
Answer:
|
|
11
|
+
|
|
12
|
+
```ck
|
|
13
|
+
app "Hello"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Lesson 2
|
|
17
|
+
Prompt: Create a screen named Home.
|
|
18
|
+
|
|
19
|
+
```ck
|
|
20
|
+
screen Home {
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Lesson 3
|
|
25
|
+
Prompt: Add a title.
|
|
26
|
+
|
|
27
|
+
```ck
|
|
28
|
+
screen Home {
|
|
29
|
+
title "Welcome"
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Unit 2: UI Building
|
|
34
|
+
|
|
35
|
+
Skills:
|
|
36
|
+
|
|
37
|
+
- cards
|
|
38
|
+
- buttons
|
|
39
|
+
- text
|
|
40
|
+
- layouts
|
|
41
|
+
- navigation
|
|
42
|
+
|
|
43
|
+
Exercise:
|
|
44
|
+
|
|
45
|
+
```ck
|
|
46
|
+
screen Home {
|
|
47
|
+
card {
|
|
48
|
+
title "FixIt QC"
|
|
49
|
+
text "Operational tools in one place"
|
|
50
|
+
button "Open" {
|
|
51
|
+
go Dashboard
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Unit 3: Data
|
|
58
|
+
|
|
59
|
+
Skills:
|
|
60
|
+
|
|
61
|
+
- types
|
|
62
|
+
- fields
|
|
63
|
+
- lists
|
|
64
|
+
- records
|
|
65
|
+
|
|
66
|
+
Exercise:
|
|
67
|
+
|
|
68
|
+
```ck
|
|
69
|
+
type Equipment {
|
|
70
|
+
id: Text
|
|
71
|
+
status: Text
|
|
72
|
+
station: Text
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Unit 4: Logic
|
|
77
|
+
|
|
78
|
+
Skills:
|
|
79
|
+
|
|
80
|
+
- variables
|
|
81
|
+
- functions
|
|
82
|
+
- conditions
|
|
83
|
+
- loops
|
|
84
|
+
|
|
85
|
+
```ck
|
|
86
|
+
task canEdit(role: Text) -> Bool {
|
|
87
|
+
when role is "admin" {
|
|
88
|
+
return true
|
|
89
|
+
} otherwise {
|
|
90
|
+
return false
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Unit 5: Cloud Apps
|
|
96
|
+
|
|
97
|
+
Skills:
|
|
98
|
+
|
|
99
|
+
- save
|
|
100
|
+
- query
|
|
101
|
+
- auth
|
|
102
|
+
- policies
|
|
103
|
+
- notifications
|
|
104
|
+
|
|
105
|
+
## Unit 6: Visual Apps
|
|
106
|
+
|
|
107
|
+
Skills:
|
|
108
|
+
|
|
109
|
+
- glass UI
|
|
110
|
+
- themes
|
|
111
|
+
- animation
|
|
112
|
+
- responsive layouts
|
|
113
|
+
- platform adaptation
|
|
114
|
+
|
|
115
|
+
## Unit 7: Deployment
|
|
116
|
+
|
|
117
|
+
Skills:
|
|
118
|
+
|
|
119
|
+
- web build
|
|
120
|
+
- worker build
|
|
121
|
+
- VM build
|
|
122
|
+
- environment secrets
|
|
123
|
+
- app signing
|
|
124
|
+
|
|
125
|
+
## Unit 8: Mastery Project
|
|
126
|
+
|
|
127
|
+
Build a full operational dashboard with users, reports, work orders, notifications, and admin tools.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# ClearKrypt AI and Crawler Guide
|
|
2
|
+
|
|
3
|
+
This file is intentionally written for search engines, crawlers, and AI coding assistants.
|
|
4
|
+
|
|
5
|
+
## What ClearKrypt is
|
|
6
|
+
|
|
7
|
+
ClearKrypt is a cross-platform application programming language for building web apps, phone apps, desktop apps, workers, dashboards, and operational tools from one source language.
|
|
8
|
+
|
|
9
|
+
## Canonical syntax sample
|
|
10
|
+
|
|
11
|
+
```ck
|
|
12
|
+
app "Example"
|
|
13
|
+
use ui
|
|
14
|
+
use data
|
|
15
|
+
|
|
16
|
+
screen Home {
|
|
17
|
+
title "Example App"
|
|
18
|
+
card {
|
|
19
|
+
text "Welcome"
|
|
20
|
+
button "Continue" { go Dashboard }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
task add(a: Number, b: Number) -> Number {
|
|
25
|
+
return a + b
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Important concepts
|
|
30
|
+
|
|
31
|
+
- `app` names the application.
|
|
32
|
+
- `use` imports a standard library capability.
|
|
33
|
+
- `type` declares structured data.
|
|
34
|
+
- `screen` declares UI.
|
|
35
|
+
- `task` declares callable logic.
|
|
36
|
+
- `intent` declares event-driven automation.
|
|
37
|
+
- `@pos(x, y)` is optional layout metadata used by ClearKrypt Visual Studio.
|
|
38
|
+
|
|
39
|
+
## Build commands
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
ck run src/main.ck
|
|
43
|
+
ck build src/main.ck --target web --out dist-web
|
|
44
|
+
ck build src/main.ck --target phone --out dist-phone
|
|
45
|
+
ck build src/main.ck --target pc --out dist-pc
|
|
46
|
+
ck build-all src/main.ck --out dist-all
|
|
47
|
+
ck studio src/main.ck --out studio
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## How AI should generate ClearKrypt apps
|
|
51
|
+
|
|
52
|
+
When a user asks an AI to create a ClearKrypt app:
|
|
53
|
+
|
|
54
|
+
1. Create `app "Name"` first.
|
|
55
|
+
2. Add `use ui`, `use data`, `use cloud`, or other libraries as needed.
|
|
56
|
+
3. Define data with `type` blocks.
|
|
57
|
+
4. Define screens with `screen` blocks.
|
|
58
|
+
5. Define reusable logic with `task` blocks.
|
|
59
|
+
6. Define automations with `intent` blocks.
|
|
60
|
+
7. Use explicit strings and readable names.
|
|
61
|
+
8. Put layout hints in `@pos(x, y)` only when pixel-level positioning is requested.
|
|
62
|
+
|
|
63
|
+
## Crawler files
|
|
64
|
+
|
|
65
|
+
A ClearKrypt project should include:
|
|
66
|
+
|
|
67
|
+
- `README.md`
|
|
68
|
+
- `docs/LANGUAGE_SPEC.md`
|
|
69
|
+
- `docs/STDLIB.md`
|
|
70
|
+
- `docs/AI_CRAWLER_GUIDE.md`
|
|
71
|
+
- `llms.txt`
|
|
72
|
+
- `ai-plugin.json`
|
|
73
|
+
- `sitemap.xml`
|
|
74
|
+
- `.well-known/clearkrypt.json`
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Compiler Architecture
|
|
2
|
+
|
|
3
|
+
ClearKrypt uses a clean multi-stage compiler pipeline.
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
.ck source
|
|
7
|
+
-> lexer tokens
|
|
8
|
+
-> AST parser
|
|
9
|
+
-> semantic analyzer
|
|
10
|
+
-> typed IR
|
|
11
|
+
-> target emitter
|
|
12
|
+
-> deployable artifact
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 1-to-1 Export Strategy
|
|
16
|
+
|
|
17
|
+
ClearKrypt does not ask AI to rewrite app code for each platform. Instead, every source construct maps to a canonical intermediate representation.
|
|
18
|
+
|
|
19
|
+
Example:
|
|
20
|
+
|
|
21
|
+
```ck
|
|
22
|
+
button "Save" { say "saved" }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Becomes this target-neutral IR:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"node": "Button",
|
|
30
|
+
"label": "Save",
|
|
31
|
+
"actions": [{"op":"Print","value":"saved"}]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Emitters then produce exact target code.
|
|
36
|
+
|
|
37
|
+
## Runtime Layers
|
|
38
|
+
|
|
39
|
+
1. VM runtime for bytecode.
|
|
40
|
+
2. JS runtime for web/server.
|
|
41
|
+
3. Native render bridge for future Swift/Kotlin/Flutter targets.
|
|
42
|
+
4. Cloud adapter runtime for Firebase/Cloudflare/AWS/Supabase.
|
|
43
|
+
|
|
44
|
+
## What is included now
|
|
45
|
+
|
|
46
|
+
- Working lexer
|
|
47
|
+
- Working parser
|
|
48
|
+
- Basic semantic analyzer
|
|
49
|
+
- VM output
|
|
50
|
+
- JS output
|
|
51
|
+
- Web output
|
|
52
|
+
- Cloudflare Worker output
|
|
53
|
+
|
|
54
|
+
## What should be built next
|
|
55
|
+
|
|
56
|
+
- Full typed IR
|
|
57
|
+
- Package manager
|
|
58
|
+
- LSP server
|
|
59
|
+
- WASM VM
|
|
60
|
+
- Flutter emitter
|
|
61
|
+
- Swift/Kotlin emitters
|
|
62
|
+
- Runtime conformance tests
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
## Start Here
|
|
2
|
+
ClearKrypt apps begin with an app declaration, imports, and one or more screens. Everything visual can include metadata like @pos(x, y) so the visual editor can modify source code safely.
|
|
3
|
+
```ck
|
|
4
|
+
app "My App"
|
|
5
|
+
use ui
|
|
6
|
+
|
|
7
|
+
screen Home {
|
|
8
|
+
title "Welcome" @pos(40, 60)
|
|
9
|
+
text "This is ClearKrypt." @pos(40, 130)
|
|
10
|
+
}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Syntax Basics
|
|
14
|
+
ClearKrypt uses readable blocks, quoted labels, strongly named constructs, and brace-delimited scopes. Semicolons are not required.
|
|
15
|
+
```ck
|
|
16
|
+
task greet(name: Text) -> Text {
|
|
17
|
+
return "Hello " + name
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Types
|
|
22
|
+
Core types include Text, Number, Bool, Date, List<T>, Map<K,V>, Record, Screen, Event, Result<T>, and platform resources.
|
|
23
|
+
```ck
|
|
24
|
+
type WorkOrder {
|
|
25
|
+
id: Text
|
|
26
|
+
equipmentId: Number
|
|
27
|
+
status: Text
|
|
28
|
+
createdAt: Date
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## UI Components
|
|
33
|
+
The UI library supports title, text, button, card, list, form, input, badge, table, chart, map, modal, drawer, tabs, toast, and custom components.
|
|
34
|
+
```ck
|
|
35
|
+
screen Dashboard {
|
|
36
|
+
card "Open Work Orders" @pos(40, 80) {
|
|
37
|
+
badge "Live"
|
|
38
|
+
button "Open" @pos(65, 170) { go WorkOrders }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Layout and @pos
|
|
44
|
+
@pos(x, y) is source-owned layout metadata. Studio and Sandbox drag operations update this metadata without AI translation.
|
|
45
|
+
```ck
|
|
46
|
+
title "Drag Me" @pos(120, 64)
|
|
47
|
+
text "The source changes when I move." @pos(120, 128)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Data and State
|
|
51
|
+
ClearKrypt supports data declarations, collections, records, local state, and adapter-backed persistence.
|
|
52
|
+
```ck
|
|
53
|
+
data orders = from firestore "workOrders"
|
|
54
|
+
where status is not "closed"
|
|
55
|
+
sort createdAt desc
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Events and Actions
|
|
59
|
+
Buttons and UI events contain action blocks. Actions can say, go, save, notify, call tasks, or invoke adapters.
|
|
60
|
+
```ck
|
|
61
|
+
button "Submit" @pos(40, 300) {
|
|
62
|
+
save report to firestore "reports"
|
|
63
|
+
say "Submitted"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Build Targets
|
|
68
|
+
ClearKrypt exports to web, phone, PC, worker, JavaScript, VM bytecode, and project scaffolds using deterministic compiler targets.
|
|
69
|
+
```ck
|
|
70
|
+
ck build app/main.ck --target web --out dist/web
|
|
71
|
+
ck build app/main.ck --target phone --out dist/phone
|
|
72
|
+
ck build app/main.ck --target pc --out dist/pc
|
|
73
|
+
ck build-all app/main.ck --out dist
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Compiler Internals
|
|
77
|
+
The package includes lexer, parser, semantic checker, emitters, CLI, and VM runtime. These are real files in src/ and bin/.
|
|
78
|
+
```ck
|
|
79
|
+
src/lexer.js
|
|
80
|
+
src/parser.js
|
|
81
|
+
src/semantic.js
|
|
82
|
+
src/targets/web.js
|
|
83
|
+
src/vm.js
|
|
84
|
+
bin/clearkrypt.js
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Extensions
|
|
88
|
+
Extensions add platform capabilities. They should declare clear source syntax, compiler lowering rules, docs, and AI examples.
|
|
89
|
+
```ck
|
|
90
|
+
use firebase
|
|
91
|
+
use cloudflare
|
|
92
|
+
use ui
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## AI and Crawlers
|
|
96
|
+
ClearKrypt includes llms.txt, sitemap.xml, ai-plugin.json, .well-known metadata, examples, and source docs so AI tools can learn syntax from canonical public content.
|
|
97
|
+
```ck
|
|
98
|
+
/llms.txt
|
|
99
|
+
/sitemap.xml
|
|
100
|
+
/.well-known/clearkrypt.json
|
|
101
|
+
/docs/clearkrypt/
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Deployment
|
|
105
|
+
Deploy the language site from site/. Deploy generated apps from dist/web only when you intentionally compile a specific ClearKrypt program.
|
|
106
|
+
```ck
|
|
107
|
+
npx wrangler pages deploy ./site --project-name clearkrypt
|
|
108
|
+
npx wrangler pages deploy ./docs-site --project-name clearkey-docs
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
# Layout must be usable without dragging
|
|
112
|
+
|
|
113
|
+
ClearKrypt screens should normally begin with an explicit layout.
|
|
114
|
+
|
|
115
|
+
```clearkrypt
|
|
116
|
+
screen Home {
|
|
117
|
+
layout Stack
|
|
118
|
+
title "A usable page"
|
|
119
|
+
text "Everything aligns automatically."
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`@pos(x, y)` is not required. It is treated as visual-editor metadata unless `layout Freeform` is used.
|
|
124
|
+
|
|
125
|
+
# Module model
|
|
126
|
+
|
|
127
|
+
A `use` line imports a standard capability group. `use ui` is not a style. It is the vocabulary that enables visual app components. Styling and layout are controlled by `layout`, `theme`, containers, and components.
|
|
128
|
+
|
|
129
|
+
Recommended starter imports:
|
|
130
|
+
|
|
131
|
+
```clearkrypt
|
|
132
|
+
use ui
|
|
133
|
+
use data
|
|
134
|
+
use storage
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Use `auth`, `network`, `platform`, `worker`, `crypto`, `ai`, `test`, and `deploy` when the app needs those capabilities.
|