plainscript-lang 1.0.3-beta → 1.0.35
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 +126 -120
- package/compiler/bundler.js +83 -12
- package/compiler/cli.js +62 -11
- package/compiler/dependency-detector.js +17 -2
- package/compiler/generator.js +699 -63
- package/compiler/lexer.js +2 -0
- package/compiler/parser.js +450 -30
- package/compiler/sourcemap.js +142 -0
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +24 -16
- package/docs/PLAINSCRIPT-SPEC.md +175 -41
- package/docs/index.html +62 -34
- package/docs/logo-pln.jpg +0 -0
- package/docs/visualization-example.svg +32 -0
- package/docs/website/script.js +297 -19
- package/docs/website/style.css +357 -47
- package/examples/ai-providers.pln +1 -1
- package/examples/arrays.pln +1 -1
- package/examples/async-errors.pln +1 -1
- package/examples/auth-api.pln +1 -1
- package/examples/auth-sessions.pln +1 -1
- package/examples/basics.pln +1 -1
- package/examples/bots.pln +1 -1
- package/examples/cache-and-jobs.pln +1 -1
- package/examples/cache-schedule.pln +1 -1
- package/examples/collections.pln +1 -1
- package/examples/concurrency.pln +1 -1
- package/examples/conditions.pln +1 -1
- package/examples/database.pln +1 -1
- package/examples/day2.pln +1 -1
- package/examples/day3.pln +1 -1
- package/examples/deployment.pln +1 -1
- package/examples/email-send.pln +1 -1
- package/examples/error-handling.pln +1 -1
- package/examples/expressions.pln +1 -1
- package/examples/file-uploads.pln +1 -1
- package/examples/files-and-config.pln +1 -1
- package/examples/files.pln +1 -1
- package/examples/football-backend/app.pln +1 -1
- package/examples/functions.pln +1 -1
- package/examples/hello.pln +1 -1
- package/examples/http-client.pln +1 -1
- package/examples/http.pln +1 -1
- package/examples/id-verification/app.pln +1 -1
- package/examples/json.pln +1 -1
- package/examples/loops.pln +1 -1
- package/examples/modules/app.pln +1 -1
- package/examples/modules/main.pln +1 -1
- package/examples/modules/math.pln +1 -1
- package/examples/mongo.pln +33 -0
- package/examples/objects.pln +1 -1
- package/examples/ocr.pln +1 -1
- package/examples/packages.pln +1 -1
- package/examples/record-kinds.pln +1 -1
- package/examples/records.pln +1 -1
- package/examples/rest-api-fetch.pln +1 -1
- package/examples/rest-api.pln +1 -1
- package/examples/scheduled-tasks.pln +1 -1
- package/examples/search-and-filter.pln +1 -1
- package/examples/server.pln +1 -1
- package/examples/sessions-and-cookies.pln +1 -1
- package/examples/sqlite.pln +1 -1
- package/examples/start.pln +1 -1
- package/examples/stdlib.pln +1 -1
- package/examples/string-verbs.pln +16 -0
- package/examples/telegram-ai-bot.pln +1 -1
- package/examples/telegram-bot.pln +1 -1
- package/examples/testing.pln +1 -1
- package/examples/visualization.pln +12 -0
- package/examples/web-api.pln +1 -1
- package/examples/web-app.pln +1 -1
- package/examples/websocket-server.pln +1 -1
- package/examples/websocket.pln +1 -1
- package/examples/whatsapp-bot/pairing.pln +24 -2
- package/examples/whatsapp-bot/qr.pln +18 -2
- package/package.json +4 -2
- package/docs/logo.jpg +0 -0
package/docs/index.html
CHANGED
|
@@ -3,19 +3,32 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<meta name="description" content="PlainScript 1.0.
|
|
7
|
-
<
|
|
6
|
+
<meta name="description" content="PlainScript 1.0.35 language reference and examples">
|
|
7
|
+
<meta name="theme-color" content="#070c16">
|
|
8
|
+
<title>PlainScript 1.0.35</title>
|
|
9
|
+
|
|
10
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
11
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
12
|
+
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@500&display=swap" rel="stylesheet">
|
|
8
13
|
<link rel="stylesheet" href="website/style.css">
|
|
9
14
|
</head>
|
|
10
15
|
<body>
|
|
11
|
-
<
|
|
16
|
+
<div class="bg-scrim" aria-hidden="true"></div>
|
|
17
|
+
<canvas id="bg-canvas" aria-hidden="true"></canvas>
|
|
18
|
+
|
|
19
|
+
<header class="site-nav" id="site-nav">
|
|
12
20
|
<div class="container nav-inner">
|
|
13
21
|
<a class="nav-logo" href="#">
|
|
14
|
-
<img src="logo.jpg" alt=""
|
|
22
|
+
<img class="nav-logo-image" src="logo-pln.jpg" alt="">
|
|
15
23
|
<span>PlainScript</span>
|
|
16
|
-
<span class="logo-ver">1.0.
|
|
24
|
+
<span class="logo-ver">1.0.35</span>
|
|
17
25
|
</a>
|
|
18
|
-
<
|
|
26
|
+
<button class="nav-toggle" id="nav-toggle" aria-label="Toggle navigation" aria-expanded="false" aria-controls="nav-links">
|
|
27
|
+
<span class="nav-toggle-bar"></span>
|
|
28
|
+
<span class="nav-toggle-bar"></span>
|
|
29
|
+
<span class="nav-toggle-bar"></span>
|
|
30
|
+
</button>
|
|
31
|
+
<nav class="nav-links" id="nav-links" aria-label="Primary navigation">
|
|
19
32
|
<a href="#quickstart">Quick start</a>
|
|
20
33
|
<a href="#language">Language</a>
|
|
21
34
|
<a href="#capabilities">Capabilities</a>
|
|
@@ -27,9 +40,9 @@
|
|
|
27
40
|
<main>
|
|
28
41
|
<section class="hero">
|
|
29
42
|
<div class="container hero-content">
|
|
30
|
-
<p class="hero-badge">1.0.
|
|
43
|
+
<p class="hero-badge" data-reveal>1.0.35: Node.js programming for everyone</p>
|
|
31
44
|
<h1 class="hero-title">Code that reads like plain English.</h1>
|
|
32
|
-
<p class="hero-lead">
|
|
45
|
+
<p class="hero-lead">Write what you want in plain words. PlainScript turns it into JavaScript — simple, readable, and easy to check.</p>
|
|
33
46
|
<div class="hero-actions">
|
|
34
47
|
<a class="button button-primary" href="#quickstart">Start building</a>
|
|
35
48
|
<a class="button button-secondary" href="#library">Browse examples</a>
|
|
@@ -43,14 +56,14 @@ done</code></pre>
|
|
|
43
56
|
|
|
44
57
|
<section id="quickstart" class="section">
|
|
45
58
|
<div class="container">
|
|
46
|
-
<p class="section-tag">Quick start</p>
|
|
47
|
-
<h2 class="section-title">
|
|
59
|
+
<p class="section-tag" data-reveal>Quick start</p>
|
|
60
|
+
<h2 class="section-title" data-reveal>A simple three-step workflow.</h2>
|
|
48
61
|
<div class="three-column">
|
|
49
|
-
<article class="info-card"><span class="card-number">01</span><h3>Write</h3><p>Create a <code>.pln</code> file with readable
|
|
50
|
-
<article class="info-card"><span class="card-number">02</span><h3>Check</h3><p>Run <code>plainscript check file.pln</code> to
|
|
51
|
-
<article class="info-card"><span class="card-number">03</span><h3>Build</h3><p>Run <code>plainscript build</code> to
|
|
62
|
+
<article class="info-card" data-reveal><span class="card-number">01</span><h3>Write</h3><p>Create a <code>.pln</code> file with readable code blocks.</p></article>
|
|
63
|
+
<article class="info-card" data-reveal><span class="card-number">02</span><h3>Check</h3><p>Run <code>plainscript check file.pln</code> to catch mistakes.</p></article>
|
|
64
|
+
<article class="info-card" data-reveal><span class="card-number">03</span><h3>Build</h3><p>Run <code>plainscript build</code> to get your files in <code>dist/</code>.</p></article>
|
|
52
65
|
</div>
|
|
53
|
-
<pre class="code-window"><code>npx plainscript new hello
|
|
66
|
+
<pre class="code-window" data-reveal><code>npx plainscript new hello
|
|
54
67
|
cd hello
|
|
55
68
|
npx plainscript check
|
|
56
69
|
npx plainscript build
|
|
@@ -60,36 +73,38 @@ npm start</code></pre>
|
|
|
60
73
|
|
|
61
74
|
<section id="language" class="section section--alt">
|
|
62
75
|
<div class="container">
|
|
63
|
-
<p class="section-tag">Language</p>
|
|
64
|
-
<h2 class="section-title">A
|
|
76
|
+
<p class="section-tag" data-reveal>Language</p>
|
|
77
|
+
<h2 class="section-title" data-reveal>A small set of words you already know.</h2>
|
|
65
78
|
<div class="feature-grid">
|
|
66
|
-
<article class="feature-card"><h3>Variables</h3><p
|
|
67
|
-
<article class="feature-card"><h3>Conditions</h3><p>
|
|
68
|
-
<article class="feature-card"><h3>Functions</h3><p>
|
|
69
|
-
<article class="feature-card"><h3>Records</h3><p>Model data with record kinds and
|
|
70
|
-
<article class="feature-card"><h3>
|
|
71
|
-
<article class="feature-card"><h3>
|
|
72
|
-
<article class="feature-card"><h3>
|
|
79
|
+
<article class="feature-card" data-reveal><h3>Variables</h3><p>Store values with <code>remember name as "Ada"</code> and change them with <code>becomes</code>.</p></article>
|
|
80
|
+
<article class="feature-card" data-reveal><h3>Conditions</h3><p>Compare things with <code>is at least</code>, <code>contains</code>, <code>between</code>, and more.</p></article>
|
|
81
|
+
<article class="feature-card" data-reveal><h3>Functions</h3><p>Create functions with <code>make</code>, return with <code>give</code>, and close with <code>done</code>.</p></article>
|
|
82
|
+
<article class="feature-card" data-reveal><h3>Records</h3><p>Model your data with record kinds and easy constructors.</p></article>
|
|
83
|
+
<article class="feature-card" data-reveal><h3>Modules</h3><p>Import code with <code>bring ... from</code>, <code>@/</code> aliases, and re-exports.</p></article>
|
|
84
|
+
<article class="feature-card" data-reveal><h3>Compound Types</h3><p>Use dictionaries, sets, and tuples with unpacking.</p></article>
|
|
85
|
+
<article class="feature-card" data-reveal><h3>Web apps</h3><p>Set up routes, JSON responses, sessions, cookies, uploads, and auth.</p></article>
|
|
86
|
+
<article class="feature-card" data-reveal><h3>Data and async</h3><p>Work with SQLite, HTTP, files, schedules, concurrency, and WebSockets.</p></article>
|
|
87
|
+
<article class="feature-card" data-reveal><h3>AI providers</h3><p>Call Groq and other OpenAI-compatible providers using your own keys.</p></article>
|
|
73
88
|
</div>
|
|
74
89
|
</div>
|
|
75
90
|
</section>
|
|
76
91
|
|
|
77
92
|
<section id="capabilities" class="section">
|
|
78
93
|
<div class="container">
|
|
79
|
-
<p class="section-tag">Capabilities</p>
|
|
80
|
-
<h2 class="section-title">
|
|
81
|
-
<div class="capability-list">
|
|
82
|
-
<span>JSON</span><span>SQLite and SQL</span><span>HTTP client</span><span>Auth and sessions</span><span>Files</span><span>Packages</span><span>Async</span><span>Errors</span><span>Concurrency</span><span>WebSockets</span><span>Cache</span><span>Bots</span><span>OCR</span><span>Tests</span><span>Modules</span>
|
|
94
|
+
<p class="section-tag" data-reveal>Capabilities</p>
|
|
95
|
+
<h2 class="section-title" data-reveal>Everything you need is built in.</h2>
|
|
96
|
+
<div class="capability-list" data-reveal>
|
|
97
|
+
<span>JSON</span><span>SQLite and SQL</span><span>HTTP client</span><span>Auth and sessions</span><span>Files</span><span>Packages</span><span>Async</span><span>Errors</span><span>Concurrency</span><span>WebSockets</span><span>Cache</span><span>Bots</span><span>OCR</span><span>Tests</span><span>Modules</span><span>Source Maps</span><span>Compound Types</span>
|
|
83
98
|
</div>
|
|
84
99
|
</div>
|
|
85
100
|
</section>
|
|
86
101
|
|
|
87
102
|
<section id="library" class="section section--alt">
|
|
88
103
|
<div class="container">
|
|
89
|
-
<p class="section-tag">Feature library</p>
|
|
90
|
-
<h2 class="section-title">
|
|
91
|
-
<p class="section-lead">These snippets use the
|
|
92
|
-
<div class="library-toolbar">
|
|
104
|
+
<p class="section-tag" data-reveal>Feature library</p>
|
|
105
|
+
<h2 class="section-title" data-reveal>Examples you can try today.</h2>
|
|
106
|
+
<p class="section-lead">These snippets use the PlainScript 1.0.35 grammar.</p>
|
|
107
|
+
<div class="library-toolbar" data-reveal>
|
|
93
108
|
<label class="sr-only" for="lib-search">Search examples</label>
|
|
94
109
|
<input id="lib-search" class="lib-search-input" type="search" placeholder="Search examples">
|
|
95
110
|
<div id="lib-filters" class="lib-filters" aria-label="Filter examples"></div>
|
|
@@ -101,15 +116,28 @@ npm start</code></pre>
|
|
|
101
116
|
|
|
102
117
|
<section class="section">
|
|
103
118
|
<div class="container split">
|
|
104
|
-
<div><p class="section-tag">Reference</p><h2 class="section-title">
|
|
105
|
-
<div
|
|
119
|
+
<div data-reveal><p class="section-tag">Reference</p><h2 class="section-title">The compiler is the source of truth.</h2></div>
|
|
120
|
+
<div data-reveal>
|
|
121
|
+
<p>Read the language specification and the <a href="https://github.com/ayoistooslick/plainscript/blob/main/knowledge.md" target="_blank" rel="noopener noreferrer">AI coding specification</a>. The repository's <code>examples/</code> directory has runnable examples.</p>
|
|
122
|
+
<div class="reference-actions" aria-label="PlainScript resources">
|
|
123
|
+
<a class="button button-reference" href="https://www.npmjs.com/package/plainscript-lang" target="_blank" rel="noopener noreferrer">NPM package</a>
|
|
124
|
+
<a class="button button-reference" href="https://github.com/ayoistooslick/plainscript" target="_blank" rel="noopener noreferrer">GitHub repo</a>
|
|
125
|
+
<a class="button button-reference" href="https://github.com/ayoistooslick/plainscript/blob/main/docs/PLAINSCRIPT-SPEC.md" target="_blank" rel="noopener noreferrer">Language specification</a>
|
|
126
|
+
<a class="button button-reference" href="https://ayoistooslick.github.io/plainscript/" target="_blank" rel="noopener noreferrer">Documentation website</a>
|
|
127
|
+
</div>
|
|
128
|
+
<p>Validate a file with <code>node compiler/cli.js check path/to/file.pln</code>.</p>
|
|
129
|
+
</div>
|
|
106
130
|
</div>
|
|
107
131
|
</section>
|
|
108
132
|
</main>
|
|
109
133
|
|
|
110
134
|
<footer class="site-footer">
|
|
111
|
-
<div class="container footer-bottom"><span>PlainScript</span><span>1.0.
|
|
135
|
+
<div class="container footer-bottom"><span>PlainScript</span><span>1.0.35</span></div>
|
|
112
136
|
</footer>
|
|
137
|
+
|
|
138
|
+
<script src="https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.min.js"></script>
|
|
139
|
+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/gsap.min.js"></script>
|
|
140
|
+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/ScrollTrigger.min.js"></script>
|
|
113
141
|
<script src="website/script.js"></script>
|
|
114
142
|
</body>
|
|
115
143
|
</html>
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="720" height="420" viewBox="0 0 720 420" role="img" aria-labelledby="title desc">
|
|
2
|
+
<title id="title">Monthly signups</title>
|
|
3
|
+
<desc id="desc">A bar chart showing signups increasing from January through April.</desc>
|
|
4
|
+
<rect width="720" height="420" fill="#071b10"/>
|
|
5
|
+
<text x="360" y="34" fill="#e6f1e7" font-family="Arial, sans-serif" font-size="20" text-anchor="middle" font-weight="700">Monthly signups</text>
|
|
6
|
+
<g stroke="#284734" stroke-width="1">
|
|
7
|
+
<line x1="62" y1="362" x2="696" y2="362"/>
|
|
8
|
+
<line x1="62" y1="288.5" x2="696" y2="288.5"/>
|
|
9
|
+
<line x1="62" y1="215" x2="696" y2="215"/>
|
|
10
|
+
<line x1="62" y1="141.5" x2="696" y2="141.5"/>
|
|
11
|
+
<line x1="62" y1="68" x2="696" y2="68"/>
|
|
12
|
+
</g>
|
|
13
|
+
<g fill="#8da99a" font-family="Arial, sans-serif" font-size="11" text-anchor="end">
|
|
14
|
+
<text x="52" y="366">0</text>
|
|
15
|
+
<text x="52" y="292.5">9</text>
|
|
16
|
+
<text x="52" y="219">18</text>
|
|
17
|
+
<text x="52" y="145.5">27</text>
|
|
18
|
+
<text x="52" y="72">36</text>
|
|
19
|
+
</g>
|
|
20
|
+
<g fill="#40c463">
|
|
21
|
+
<rect x="95.813" y="264" width="111.8" height="98" rx="5"/>
|
|
22
|
+
<rect x="254.313" y="215" width="111.8" height="147" rx="5"/>
|
|
23
|
+
<rect x="412.813" y="141.5" width="111.8" height="220.5" rx="5"/>
|
|
24
|
+
<rect x="571.313" y="76.167" width="111.8" height="285.833" rx="5"/>
|
|
25
|
+
</g>
|
|
26
|
+
<g fill="#8da99a" font-family="Arial, sans-serif" font-size="12" text-anchor="middle">
|
|
27
|
+
<text x="151.7" y="396">Jan</text>
|
|
28
|
+
<text x="310.2" y="396">Feb</text>
|
|
29
|
+
<text x="468.7" y="396">Mar</text>
|
|
30
|
+
<text x="627.2" y="396">Apr</text>
|
|
31
|
+
</g>
|
|
32
|
+
</svg>
|
package/docs/website/script.js
CHANGED
|
@@ -1,26 +1,303 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
+
const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5
|
+
|
|
6
|
+
// ── three.js animated background ──────────────────────────────────────
|
|
7
|
+
function mountBackground() {
|
|
8
|
+
const canvas = document.getElementById("bg-canvas");
|
|
9
|
+
if (!canvas || !window.WebGLRenderingContext) return;
|
|
10
|
+
|
|
11
|
+
let context;
|
|
12
|
+
try {
|
|
13
|
+
context = canvas.getContext("webgl", { alpha: true, antialias: true });
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (!context) return;
|
|
18
|
+
|
|
19
|
+
let renderer;
|
|
20
|
+
try {
|
|
21
|
+
renderer = new THREE.WebGLRenderer({ canvas, context, alpha: true, antialias: true });
|
|
22
|
+
} catch (error) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
26
|
+
|
|
27
|
+
const scene = new THREE.Scene();
|
|
28
|
+
const camera = new THREE.PerspectiveCamera(70, 1, 0.1, 100);
|
|
29
|
+
camera.position.z = 16;
|
|
30
|
+
|
|
31
|
+
const group = new THREE.Group();
|
|
32
|
+
scene.add(group);
|
|
33
|
+
|
|
34
|
+
// Distant particle field
|
|
35
|
+
const starCount = prefersReduced ? 0 : 800;
|
|
36
|
+
const positions = new Float32Array(starCount * 3);
|
|
37
|
+
for (let i = 0; i < starCount; i++) {
|
|
38
|
+
positions[i * 3] = (Math.random() - 0.5) * 34;
|
|
39
|
+
positions[i * 3 + 1] = (Math.random() - 0.5) * 22;
|
|
40
|
+
positions[i * 3 + 2] = (Math.random() - 0.5) * 30;
|
|
41
|
+
}
|
|
42
|
+
const starGeo = new THREE.BufferGeometry();
|
|
43
|
+
starGeo.setAttribute("position", new THREE.BufferAttribute(positions, 3));
|
|
44
|
+
const starMat = new THREE.PointsMaterial({
|
|
45
|
+
color: 0x46e6b4,
|
|
46
|
+
size: 0.09,
|
|
47
|
+
transparent: true,
|
|
48
|
+
opacity: 0.55,
|
|
49
|
+
sizeAttenuation: true,
|
|
50
|
+
depthWrite: false,
|
|
51
|
+
});
|
|
52
|
+
const stars = new THREE.Points(starGeo, starMat);
|
|
53
|
+
group.add(stars);
|
|
54
|
+
|
|
55
|
+
// Two soft wireframe rings for structure
|
|
56
|
+
const ringMat = new THREE.MeshBasicMaterial({
|
|
57
|
+
color: 0x46e6b4,
|
|
58
|
+
wireframe: true,
|
|
59
|
+
transparent: true,
|
|
60
|
+
opacity: 0.12,
|
|
61
|
+
});
|
|
62
|
+
for (const [radius, tilt, speed] of [[9.5, 0.4, 0.22], [6.5, -0.25, -0.16]]) {
|
|
63
|
+
const ring = new THREE.Mesh(new THREE.TorusGeometry(radius, 0.05, 8, 96), ringMat);
|
|
64
|
+
ring.rotation.x = tilt;
|
|
65
|
+
ring.rotation.y = 0.6;
|
|
66
|
+
group.add(ring);
|
|
67
|
+
ring.userData.speed = speed;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let mouseX = 0;
|
|
71
|
+
let mouseY = 0;
|
|
72
|
+
window.addEventListener("pointermove", (event) => {
|
|
73
|
+
mouseX = (event.clientX / window.innerWidth) * 2 - 1;
|
|
74
|
+
mouseY = (event.clientY / window.innerHeight) * 2 - 1;
|
|
75
|
+
}, { passive: true });
|
|
76
|
+
|
|
77
|
+
function resize() {
|
|
78
|
+
const width = window.innerWidth;
|
|
79
|
+
const height = window.innerHeight;
|
|
80
|
+
renderer.setSize(width, height);
|
|
81
|
+
camera.aspect = width / height;
|
|
82
|
+
camera.updateProjectionMatrix();
|
|
83
|
+
}
|
|
84
|
+
resize();
|
|
85
|
+
window.addEventListener("resize", resize);
|
|
86
|
+
|
|
87
|
+
const clock = new THREE.Clock();
|
|
88
|
+
function tick() {
|
|
89
|
+
const elapsed = clock.getElapsedTime();
|
|
90
|
+
group.rotation.y = elapsed * 0.06;
|
|
91
|
+
group.children.forEach((child) => {
|
|
92
|
+
if (child.userData.speed) {
|
|
93
|
+
child.rotation.z += child.userData.speed * 0.004;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
// Parallax toward the cursor
|
|
97
|
+
const targetY = elapsed * 0.06 + mouseX * 0.15;
|
|
98
|
+
group.rotation.x += (mouseY * 0.12 - group.rotation.x) * 0.04;
|
|
99
|
+
group.rotation.y += (targetY - group.rotation.y) * 0.04;
|
|
100
|
+
camera.position.x += (mouseX * 1.1 - camera.position.x) * 0.03;
|
|
101
|
+
camera.position.y += (mouseY * 0.7 - camera.position.y) * 0.03;
|
|
102
|
+
camera.lookAt(scene.position);
|
|
103
|
+
renderer.render(scene, camera);
|
|
104
|
+
requestAnimationFrame(tick);
|
|
105
|
+
}
|
|
106
|
+
if (!prefersReduced) tick();
|
|
107
|
+
}
|
|
108
|
+
mountBackground();
|
|
109
|
+
|
|
110
|
+
// ── GSAP entrance + scroll reveals ────────────────────────────────────
|
|
111
|
+
const gsapOk = window.gsap && !prefersReduced;
|
|
112
|
+
|
|
113
|
+
if (gsapOk) {
|
|
114
|
+
gsap.registerPlugin(window.ScrollTrigger);
|
|
115
|
+
|
|
116
|
+
// Hero entrance
|
|
117
|
+
gsap.from(".hero-badge", { opacity: 0, y: 18, duration: 0.7, ease: "power2.out" });
|
|
118
|
+
gsap.from(".hero-title", {
|
|
119
|
+
opacity: 0, y: 30, duration: 0.9, ease: "power3.out", delay: 0.1,
|
|
120
|
+
});
|
|
121
|
+
gsap.from(".hero-lead", { opacity: 0, y: 22, duration: 0.8, ease: "power2.out", delay: 0.22 });
|
|
122
|
+
gsap.from(".hero-actions .button", {
|
|
123
|
+
opacity: 0, y: 18, duration: 0.6, ease: "power2.out", delay: 0.32, stagger: 0.08,
|
|
124
|
+
});
|
|
125
|
+
gsap.from(".hero .code-window", { opacity: 0, y: 26, duration: 0.8, ease: "power2.out", delay: 0.44 });
|
|
126
|
+
|
|
127
|
+
// Scroll reveals for cards and blocks
|
|
128
|
+
gsap.utils.toArray("[data-reveal]").forEach((el) => {
|
|
129
|
+
gsap.from(el, {
|
|
130
|
+
opacity: 0,
|
|
131
|
+
y: 28,
|
|
132
|
+
duration: 0.7,
|
|
133
|
+
ease: "power2.out",
|
|
134
|
+
scrollTrigger: { trigger: el, start: "top 88%", once: true },
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Stagger card grids
|
|
139
|
+
gsap.utils.toArray(".three-column, .feature-grid").forEach((grid) => {
|
|
140
|
+
gsap.from(grid.children, {
|
|
141
|
+
opacity: 0,
|
|
142
|
+
y: 30,
|
|
143
|
+
duration: 0.6,
|
|
144
|
+
ease: "power2.out",
|
|
145
|
+
stagger: 0.08,
|
|
146
|
+
scrollTrigger: { trigger: grid, start: "top 86%", once: true },
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
} else {
|
|
150
|
+
// No-JS / reduced-motion fallback: keep everything visible
|
|
151
|
+
document.querySelectorAll("[data-reveal]").forEach((el) => el.style.opacity = 1);
|
|
152
|
+
document.querySelectorAll(".hero-badge, .hero-title, .hero-lead, .hero .code-window").forEach((el) => {
|
|
153
|
+
el.style.opacity = 1;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Nav blur once scrolled
|
|
158
|
+
const nav = document.getElementById("site-nav");
|
|
159
|
+
const onScroll = () => nav && nav.classList.toggle("is-scrolled", window.scrollY > 10);
|
|
160
|
+
window.addEventListener("scroll", onScroll, { passive: true });
|
|
161
|
+
onScroll();
|
|
162
|
+
|
|
163
|
+
// Mobile nav toggle
|
|
164
|
+
const navToggle = document.getElementById("nav-toggle");
|
|
165
|
+
const navLinks = document.getElementById("nav-links");
|
|
166
|
+
if (navToggle && navLinks) {
|
|
167
|
+
navToggle.addEventListener("click", () => {
|
|
168
|
+
const expanded = navToggle.getAttribute("aria-expanded") === "true";
|
|
169
|
+
navToggle.setAttribute("aria-expanded", String(!expanded));
|
|
170
|
+
navLinks.classList.toggle("is-open", !expanded);
|
|
171
|
+
});
|
|
172
|
+
navLinks.querySelectorAll("a").forEach((link) => {
|
|
173
|
+
link.addEventListener("click", () => {
|
|
174
|
+
navToggle.setAttribute("aria-expanded", "false");
|
|
175
|
+
navLinks.classList.remove("is-open");
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ── Copy controls for every code block ─────────────────────────────────
|
|
181
|
+
const syntaxGroups = {
|
|
182
|
+
declaration: new Set(["remember", "let", "make", "define", "function", "use", "import", "export", "database", "postgres", "record", "list", "create", "websocket", "bot", "whatsapp", "ocr"]),
|
|
183
|
+
web: new Set(["web", "route", "start", "listen", "reply", "respond", "serve", "allow", "cors", "status", "redirect", "param", "query", "header", "upload", "uploads"]),
|
|
184
|
+
database: new Set(["database", "postgres", "query", "insert", "update", "delete", "execute", "transaction", "native", "wasm"]),
|
|
185
|
+
error: new Set(["try", "recover", "finally", "retry", "throw", "raise", "raises", "catch", "catches"]),
|
|
186
|
+
test: new Set(["test", "check", "equals", "contains", "raises"]),
|
|
187
|
+
comparison: new Set(["contains", "starts", "ends", "between", "is", "same", "different", "more", "fewer", "at", "least", "most"]),
|
|
188
|
+
keyword: new Set(["if", "otherwise", "else", "for", "each", "every", "index", "from", "to", "while", "in", "when", "on", "done", "give", "return", "yield", "break", "continue", "with", "and", "or", "not", "field", "instanceof", "show", "print", "display", "accept", "require", "enable", "limit", "cache", "schedule", "background", "socket", "message", "broadcast", "send"])
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
function escapeHtml(value) {
|
|
192
|
+
return value.replace(/[&<>"']/g, (character) => ({
|
|
193
|
+
"&": "&",
|
|
194
|
+
"<": "<",
|
|
195
|
+
">": ">",
|
|
196
|
+
'"': """,
|
|
197
|
+
"'": "'"
|
|
198
|
+
}[character]));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function highlightPlainScript(source) {
|
|
202
|
+
const tokenPattern = /\/\/[^\n]*|"(?:\\.|[^"\\])*"|`(?:\\.|[^`\\])*`|\b\d+(?:\.\d+)?n?\b|\b[A-Za-z_][A-Za-z0-9_]*\b|\?\?|\?\.|\*\*|->|===|!==|==|!=|<=|>=|[+\-*\/%=<>]/g;
|
|
203
|
+
let highlighted = "";
|
|
204
|
+
let lastIndex = 0;
|
|
205
|
+
let match;
|
|
206
|
+
|
|
207
|
+
while ((match = tokenPattern.exec(source))) {
|
|
208
|
+
highlighted += escapeHtml(source.slice(lastIndex, match.index));
|
|
209
|
+
const token = match[0];
|
|
210
|
+
let className = "";
|
|
211
|
+
if (token.startsWith("//")) className = "comment";
|
|
212
|
+
else if (token.startsWith('"')) className = "string";
|
|
213
|
+
else if (token.startsWith("`")) className = "template";
|
|
214
|
+
else if (/^\d/.test(token)) className = "number";
|
|
215
|
+
else if (/^(true|false|null|undefined)$/.test(token)) className = "constant";
|
|
216
|
+
else if (/^(?:\?\?|\?\.|\*\*|->|===|!==|==|!=|<=|>=|[+\-*\/%=<>])$/.test(token)) className = token === "=" ? "assignment" : "operator";
|
|
217
|
+
else if (syntaxGroups.database.has(token)) className = "database";
|
|
218
|
+
else if (syntaxGroups.comparison.has(token)) className = "comparison";
|
|
219
|
+
else if (syntaxGroups.declaration.has(token)) className = "declaration";
|
|
220
|
+
else if (syntaxGroups.web.has(token)) className = "web";
|
|
221
|
+
else if (syntaxGroups.error.has(token)) className = "error";
|
|
222
|
+
else if (syntaxGroups.test.has(token)) className = "test";
|
|
223
|
+
else if (syntaxGroups.keyword.has(token)) className = "keyword";
|
|
224
|
+
else if (/\s*\(/.test(source.slice(match.index + token.length))) className = "function";
|
|
225
|
+
if (token === "becomes") className = "assignment";
|
|
226
|
+
highlighted += className ? `<span class="code-token code-token--${className}">${escapeHtml(token)}</span>` : escapeHtml(token);
|
|
227
|
+
lastIndex = match.index + token.length;
|
|
228
|
+
}
|
|
229
|
+
return highlighted + escapeHtml(source.slice(lastIndex));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function enhanceCodeBlock(pre) {
|
|
233
|
+
if (!pre || pre.querySelector(".copy-button")) return;
|
|
234
|
+
const code = pre.querySelector("code");
|
|
235
|
+
if (!code) return;
|
|
236
|
+
code.innerHTML = highlightPlainScript(code.textContent);
|
|
237
|
+
|
|
238
|
+
const copyButton = document.createElement("button");
|
|
239
|
+
copyButton.type = "button";
|
|
240
|
+
copyButton.className = "copy-button";
|
|
241
|
+
copyButton.textContent = "Copy";
|
|
242
|
+
copyButton.setAttribute("aria-label", "Copy code to clipboard");
|
|
243
|
+
copyButton.addEventListener("click", async () => {
|
|
244
|
+
const originalLabel = "Copy";
|
|
245
|
+
let copied = false;
|
|
246
|
+
try {
|
|
247
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
248
|
+
await navigator.clipboard.writeText(code.textContent);
|
|
249
|
+
copied = true;
|
|
250
|
+
} else {
|
|
251
|
+
const selection = window.getSelection();
|
|
252
|
+
const range = document.createRange();
|
|
253
|
+
range.selectNodeContents(code);
|
|
254
|
+
selection.removeAllRanges();
|
|
255
|
+
selection.addRange(range);
|
|
256
|
+
copied = document.execCommand("copy");
|
|
257
|
+
selection.removeAllRanges();
|
|
258
|
+
}
|
|
259
|
+
} catch (error) {
|
|
260
|
+
copied = false;
|
|
261
|
+
}
|
|
262
|
+
if (!copied) return;
|
|
263
|
+
copyButton.textContent = "Copied";
|
|
264
|
+
copyButton.classList.add("is-copied");
|
|
265
|
+
copyButton.setAttribute("aria-label", "Code copied to clipboard");
|
|
266
|
+
window.setTimeout(() => {
|
|
267
|
+
copyButton.textContent = originalLabel;
|
|
268
|
+
copyButton.classList.remove("is-copied");
|
|
269
|
+
copyButton.setAttribute("aria-label", "Copy code to clipboard");
|
|
270
|
+
}, 1600);
|
|
271
|
+
});
|
|
272
|
+
pre.appendChild(copyButton);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
document.querySelectorAll("pre").forEach(enhanceCodeBlock);
|
|
276
|
+
|
|
277
|
+
// ── Feature library (search + filter) ─────────────────────────────────
|
|
4
278
|
const examples = [
|
|
5
|
-
{ category: "core", name: "Variables", description: "
|
|
6
|
-
{ category: "core", name: "Conditions", description: "
|
|
7
|
-
{ category: "core", name: "Loops", description: "
|
|
8
|
-
{ category: "core", name: "Functions", description: "
|
|
9
|
-
{ category: "
|
|
10
|
-
{ category: "data", name: "
|
|
11
|
-
{ category: "data", name: "
|
|
12
|
-
{ category: "
|
|
13
|
-
{ category: "
|
|
14
|
-
{ category: "web", name: "
|
|
15
|
-
{ category: "
|
|
16
|
-
{ category: "
|
|
17
|
-
{ category: "runtime", name: "
|
|
18
|
-
{ category: "runtime", name: "
|
|
19
|
-
{ category: "
|
|
20
|
-
{ category: "
|
|
21
|
-
{ category: "integrations", name: "
|
|
22
|
-
{ category: "
|
|
23
|
-
{ category: "
|
|
279
|
+
{ category: "core", name: "Variables", description: "Store and update values.", source: 'remember name as "Ada"\nremember count as 3\ncount becomes count + 1\nshow `Hello, ${name}!`' },
|
|
280
|
+
{ category: "core", name: "Conditions", description: "Compare values in plain words.", source: 'if score is at least 80 and name contains "A"\n show "accepted"\notherwise\n show "review"\ndone' },
|
|
281
|
+
{ category: "core", name: "Loops", description: "Go through lists and ranges.", source: 'for each item in list with "one", "two"\n show item\ndone\n\nfor index i from 0 to 2\n show i\ndone' },
|
|
282
|
+
{ category: "core", name: "Functions", description: "Create reusable functions.", source: 'make add(a, b)\n give a + b\ndone\n\nshow add(2, 3)' },
|
|
283
|
+
{ category: "core", name: "Modules", description: "Share code across files.", source: 'bring circleArea from "./math.pln"\nbring button from "@/components/button.pln"\nexport circleArea and squareArea' },
|
|
284
|
+
{ category: "data", name: "Records", description: "Define the shape of your data.", source: 'define a kind called "Player" with\n name is ""\n goals is 0\ndone\nremember player as create a Player with name "Ada" and goals 4' },
|
|
285
|
+
{ category: "data", name: "JSON", description: "Work with JSON data.", source: 'remember payload as {ok: true, count: 2}\nremember encoded as jsonEncode(payload)\nshow encoded' },
|
|
286
|
+
{ category: "data", name: "Compound Types", description: "Use dictionaries, sets, and tuples.", source: 'remember userMap as dictionary with "name" is "Ada" and "role" is "admin" done\nremember tags as set with "admin", "editor" done\nremember point as tuple with 10, 20, 30 done' },
|
|
287
|
+
{ category: "data", name: "SQLite", description: "Run safe SQL queries.", source: 'database "app.db" using "wasm"\nexecute\n CREATE TABLE items (name TEXT)\ndone\nremember items as query\n SELECT name FROM items\ndone' },
|
|
288
|
+
{ category: "web", name: "Web routes", description: "Build an HTTP app with JSON routes.", source: 'web app\nroute get "/health"\n reply json\n ok is true\n done\ndone\nstart 3000' },
|
|
289
|
+
{ category: "web", name: "HTTP client", description: "Fetch data from a URL.", source: 'remember response as get "https://example.com/data" timeout 5000\nshow response.status' },
|
|
290
|
+
{ category: "web", name: "Auth and sessions", description: "Protect routes and track visitors.", source: 'web app\nenable sessions "session-secret"\nrequire api key from env("API_KEY")\nroute get "/me"\n reply json\n user is user of session of request\n done\ndone' },
|
|
291
|
+
{ category: "runtime", name: "Async errors", description: "Handle errors gracefully.", source: 'try\n remember result as get "https://example.com" timeout 5000\nrecover as error\n show message of error\nfinally\n show "finished"' },
|
|
292
|
+
{ category: "runtime", name: "Concurrency", description: "Run several tasks at once.", source: 'remember results as allOf(list with firstJob(), secondJob())\nremember quick as withTimeout(firstJob(), 1000)\nshow results' },
|
|
293
|
+
{ category: "runtime", name: "WebSockets", description: "Chat and push updates live.", source: 'websocket server on 8080\n when socket connects\n send socket "connected"\n done\n when socket sends message\n broadcast message\n done\ndone' },
|
|
294
|
+
{ category: "runtime", name: "Cache", description: "Keep values ready with a TTL.", source: 'cache env("REDIS_URL")\ncacheSet("status", "ready", 60)\nremember status as cacheGet("status")' },
|
|
295
|
+
{ category: "integrations", name: "Telegram", description: "Build a Telegram bot.", source: 'bot env("TELEGRAM_BOT_TOKEN")\nwhen someone sends "/start"\n reply "Welcome"\ndone\nstart telegram bot' },
|
|
296
|
+
{ category: "integrations", name: "WhatsApp", description: "Build a WhatsApp bot.", source: 'whatsapp bot\n auth "session"\n login pairing "2348012345678"\n on message\n if message.text is "/start"\n reply "Welcome!"\n done\n if message.type is "image"\n download "media/photo.jpg"\n reply "Saved your photo!"\n done\n done\ndone' },
|
|
297
|
+
{ category: "integrations", name: "Groq AI", description: "Get AI replies in your code.", source: 'remember answer as chatWith("groq", "llama-3.3-70b-versatile", "Hello")\nshow answer' },
|
|
298
|
+
{ category: "integrations", name: "OCR uploads", description: "Read text from uploaded images.", source: 'web app\naccept uploads limit "5 MB" allow list with "image/png" folder "uploads"\nroute post "/scan"\n remember file as upload("document")\n ocr path of file as text\n reply text\ndone' },
|
|
299
|
+
{ category: "tooling", name: "Native tests", description: "Check that your code works.", source: 'test "addition works"\n check add(2, 3) equals 5\ndone' },
|
|
300
|
+
{ category: "tooling", name: "Source Maps", description: "Debug right in your .pln files.", source: 'plainscript build src/main.pln --sourcemap\n\n// or in code:\n// plainscript run src/main.pln --sourcemap' }
|
|
24
301
|
];
|
|
25
302
|
|
|
26
303
|
const grid = document.getElementById("lib-grid");
|
|
@@ -59,6 +336,7 @@
|
|
|
59
336
|
card.className = "library-card";
|
|
60
337
|
card.innerHTML = `<div class="library-card-top"><span class="library-category">${item.category}</span><h3>${item.name}</h3><p>${item.description}</p></div><pre><code></code></pre>`;
|
|
61
338
|
card.querySelector("code").textContent = item.source;
|
|
339
|
+
enhanceCodeBlock(card.querySelector("pre"));
|
|
62
340
|
grid.appendChild(card);
|
|
63
341
|
});
|
|
64
342
|
empty.hidden = visible.length !== 0;
|