plainscript-lang 0.1.7-latest

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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +815 -0
  3. package/compiler/bundler.js +86 -0
  4. package/compiler/cli.js +843 -0
  5. package/compiler/dependency-detector.js +173 -0
  6. package/compiler/formatter.js +170 -0
  7. package/compiler/generator.js +2032 -0
  8. package/compiler/lexer.js +413 -0
  9. package/compiler/parser.js +2077 -0
  10. package/compiler/version.js +6 -0
  11. package/docs/PLINJS_SPEC.md +1051 -0
  12. package/docs/index.html +2287 -0
  13. package/docs/logo.jpg +0 -0
  14. package/docs/website/index.html +1500 -0
  15. package/docs/website/script.js +197 -0
  16. package/docs/website/style.css +1117 -0
  17. package/examples/arrays.pln +13 -0
  18. package/examples/cache-and-jobs.pln +29 -0
  19. package/examples/database.pln +41 -0
  20. package/examples/day2.pln +7 -0
  21. package/examples/day3.pln +11 -0
  22. package/examples/deployment.pln +12 -0
  23. package/examples/email-send.pln +22 -0
  24. package/examples/expressions.pln +40 -0
  25. package/examples/football-backend/app.pln +90 -0
  26. package/examples/hello.pln +3 -0
  27. package/examples/id-verification/app.pln +29 -0
  28. package/examples/id-verification/make-sample-id.js +123 -0
  29. package/examples/loops.pln +17 -0
  30. package/examples/objects.pln +12 -0
  31. package/examples/rest-api-fetch.pln +94 -0
  32. package/examples/rest-api.pln +68 -0
  33. package/examples/scheduled-tasks.pln +23 -0
  34. package/examples/server.pln +25 -0
  35. package/examples/start.pln +2 -0
  36. package/examples/stdlib.pln +41 -0
  37. package/examples/telegram-bot.pln +42 -0
  38. package/examples/web-app.pln +20 -0
  39. package/examples/websocket-server.pln +27 -0
  40. package/examples/whatsapp-bot/pairing.pln +17 -0
  41. package/examples/whatsapp-bot/qr.pln +8 -0
  42. package/package.json +47 -0
@@ -0,0 +1,197 @@
1
+ /* PlainScript v0.1.7 — Documentation Website JS */
2
+
3
+ /* ── Copy buttons ────────────────────────────────────────────────────────── */
4
+ function initCopyButtons() {
5
+ document.querySelectorAll('.code-copy').forEach(btn => {
6
+ btn.addEventListener('click', () => {
7
+ const block = btn.closest('.code-block');
8
+ const pre = block ? block.querySelector('pre') : null;
9
+ if (!pre) return;
10
+
11
+ const text = pre.innerText.trim();
12
+ navigator.clipboard.writeText(text).then(() => {
13
+ const originalHTML = btn.innerHTML;
14
+ btn.innerHTML = '<i class="fa-solid fa-check"></i> Copied';
15
+ btn.classList.add('copied');
16
+ setTimeout(() => {
17
+ btn.innerHTML = originalHTML;
18
+ btn.classList.remove('copied');
19
+ }, 2000);
20
+ });
21
+ });
22
+ });
23
+
24
+ /* install-strip copy buttons */
25
+ document.querySelectorAll('.install-cmd button').forEach(btn => {
26
+ btn.addEventListener('click', () => {
27
+ const cmd = btn.closest('.install-cmd');
28
+ const text = cmd ? cmd.querySelector('code').innerText.trim() : '';
29
+ navigator.clipboard.writeText(text).then(() => {
30
+ const originalHTML = btn.innerHTML;
31
+ btn.innerHTML = '<i class="fa-solid fa-check"></i> Copied';
32
+ btn.classList.add('copied');
33
+ setTimeout(() => {
34
+ btn.innerHTML = originalHTML;
35
+ btn.classList.remove('copied');
36
+ }, 2000);
37
+ });
38
+ });
39
+ });
40
+ }
41
+
42
+ /* ── Mobile menu ─────────────────────────────────────────────────────────── */
43
+ function initMobileMenu() {
44
+ const toggle = document.getElementById('nav-hamburger');
45
+ const menu = document.getElementById('mobile-menu');
46
+ if (!toggle || !menu) return;
47
+
48
+ const setOpen = open => {
49
+ menu.classList.toggle('open', open);
50
+ toggle.setAttribute('aria-expanded', open);
51
+ toggle.querySelector('i').className = open
52
+ ? 'fa-solid fa-xmark'
53
+ : 'fa-solid fa-bars';
54
+ document.body.classList.toggle('menu-open', open);
55
+ };
56
+ const isOpen = () => menu.classList.contains('open');
57
+
58
+ toggle.addEventListener('click', () => setOpen(!isOpen()));
59
+
60
+ /* close on link click */
61
+ menu.querySelectorAll('a').forEach(a => {
62
+ a.addEventListener('click', () => setOpen(false));
63
+ });
64
+
65
+ /* close with Escape */
66
+ document.addEventListener('keydown', e => {
67
+ if (e.key === 'Escape' && isOpen()) setOpen(false);
68
+ });
69
+
70
+ /* close if the viewport grows past the breakpoint */
71
+ window.addEventListener('resize', () => {
72
+ if (window.innerWidth > 800 && isOpen()) setOpen(false);
73
+ });
74
+ }
75
+
76
+ /* ── FAQ accordion ───────────────────────────────────────────────────────── */
77
+ function initFAQ() {
78
+ document.querySelectorAll('.faq-question').forEach(btn => {
79
+ btn.addEventListener('click', () => {
80
+ const item = btn.closest('.faq-item');
81
+ const isOpen = item.classList.contains('open');
82
+
83
+ /* close all others */
84
+ document.querySelectorAll('.faq-item.open').forEach(o => {
85
+ if (o !== item) o.classList.remove('open');
86
+ });
87
+
88
+ item.classList.toggle('open', !isOpen);
89
+ });
90
+ });
91
+ }
92
+
93
+ /* ── Active nav link on scroll ───────────────────────────────────────────── */
94
+ function initScrollSpy() {
95
+ const sections = document.querySelectorAll('section[id]');
96
+ const links = document.querySelectorAll('.nav-links a[href^="#"]');
97
+
98
+ const observer = new IntersectionObserver(entries => {
99
+ entries.forEach(entry => {
100
+ if (!entry.isIntersecting) return;
101
+ const id = entry.target.getAttribute('id');
102
+ links.forEach(a => {
103
+ const active = a.getAttribute('href') === `#${id}`;
104
+ a.classList.toggle('active', active);
105
+ a.style.color = active ? 'var(--text)' : '';
106
+ });
107
+ });
108
+ }, { rootMargin: '-50% 0px -45% 0px' });
109
+
110
+ sections.forEach(s => observer.observe(s));
111
+ }
112
+
113
+ /* ── Scroll progress bar ─────────────────────────────────────────────────── */
114
+ function initScrollProgress() {
115
+ let bar = document.getElementById('scroll-progress');
116
+ if (!bar) {
117
+ bar = document.createElement('div');
118
+ bar.id = 'scroll-progress';
119
+ document.body.appendChild(bar);
120
+ }
121
+ const update = () => {
122
+ const doc = document.documentElement;
123
+ const max = doc.scrollHeight - doc.clientHeight;
124
+ bar.style.width = max > 0 ? `${(doc.scrollTop / max) * 100}%` : '0';
125
+ };
126
+ window.addEventListener('scroll', update, { passive: true });
127
+ window.addEventListener('resize', update);
128
+ update();
129
+ }
130
+
131
+ /* ── Back to top button ──────────────────────────────────────────────────── */
132
+ function initBackToTop() {
133
+ let btn = document.getElementById('to-top');
134
+ if (!btn) {
135
+ btn = document.createElement('button');
136
+ btn.id = 'to-top';
137
+ btn.className = 'to-top';
138
+ btn.setAttribute('aria-label', 'Back to top');
139
+ btn.innerHTML = '<i class="fa-solid fa-arrow-up"></i>';
140
+ document.body.appendChild(btn);
141
+ }
142
+ btn.addEventListener('click', () => {
143
+ window.scrollTo({ top: 0, behavior: 'smooth' });
144
+ });
145
+ const toggle = () => {
146
+ btn.classList.toggle('visible', window.scrollY > 480);
147
+ };
148
+ window.addEventListener('scroll', toggle, { passive: true });
149
+ toggle();
150
+ }
151
+
152
+ /* ── Reveal on scroll ────────────────────────────────────────────────────── */
153
+ function initReveal() {
154
+ /* Skip entirely if the user prefers reduced motion (CSS also guards). */
155
+ if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
156
+
157
+ const targets = document.querySelectorAll(
158
+ '.section > .container > .section-tag, .section > .container > .section-title, .section > .container > .section-lead'
159
+ );
160
+ targets.forEach(el => el.classList.add('reveal'));
161
+
162
+ const observer = new IntersectionObserver(entries => {
163
+ entries.forEach(entry => {
164
+ if (entry.isIntersecting) {
165
+ entry.target.classList.add('visible');
166
+ observer.unobserve(entry.target);
167
+ }
168
+ });
169
+ }, { threshold: 0.1 });
170
+
171
+ targets.forEach(el => observer.observe(el));
172
+ }
173
+
174
+ /* ── Smooth scroll nav highlight on click ────────────────────────────────── */
175
+ function initNavLinks() {
176
+ document.querySelectorAll('a[href^="#"]').forEach(a => {
177
+ a.addEventListener('click', e => {
178
+ const target = document.querySelector(a.getAttribute('href'));
179
+ if (target) {
180
+ e.preventDefault();
181
+ target.scrollIntoView({ behavior: 'smooth' });
182
+ }
183
+ });
184
+ });
185
+ }
186
+
187
+ /* ── Boot ────────────────────────────────────────────────────────────────── */
188
+ document.addEventListener('DOMContentLoaded', () => {
189
+ initCopyButtons();
190
+ initMobileMenu();
191
+ initFAQ();
192
+ initScrollSpy();
193
+ initNavLinks();
194
+ initScrollProgress();
195
+ initBackToTop();
196
+ initReveal();
197
+ });