naider 1.17.1 → 1.17.4
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/assets/naide.ico +0 -0
- package/assets/naide_check.png +0 -0
- package/assets/nx.ico +0 -0
- package/assets/nx_check.png +0 -0
- package/bin/generate-icons.js +237 -0
- package/bin/postinstall.js +5 -2
- package/package.json +2 -1
package/assets/naide.ico
ADDED
|
Binary file
|
|
Binary file
|
package/assets/nx.ico
ADDED
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { writeFileSync, mkdirSync } from 'fs';
|
|
4
|
+
import { resolve, dirname } from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import zlib from 'zlib';
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
function createPNG(width, height, pixels) {
|
|
11
|
+
const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
12
|
+
|
|
13
|
+
function makeChunk(type, data) {
|
|
14
|
+
const buf = Buffer.alloc(4 + type.length + data.length + 4);
|
|
15
|
+
buf.writeUInt32BE(data.length, 0);
|
|
16
|
+
buf.write(type, 4);
|
|
17
|
+
data.copy(buf, 4 + type.length);
|
|
18
|
+
const crc = crc32(buf.slice(4, 4 + type.length + data.length));
|
|
19
|
+
buf.writeUInt32BE(crc, buf.length - 4);
|
|
20
|
+
return buf;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ihdr = Buffer.alloc(13);
|
|
24
|
+
ihdr.writeUInt32BE(width, 0);
|
|
25
|
+
ihdr.writeUInt32BE(height, 4);
|
|
26
|
+
ihdr[8] = 8;
|
|
27
|
+
ihdr[9] = 6;
|
|
28
|
+
ihdr[10] = 0;
|
|
29
|
+
ihdr[11] = 0;
|
|
30
|
+
ihdr[12] = 0;
|
|
31
|
+
|
|
32
|
+
const rawData = Buffer.alloc(height * (1 + width * 4));
|
|
33
|
+
for (let y = 0; y < height; y++) {
|
|
34
|
+
rawData[y * (1 + width * 4)] = 0;
|
|
35
|
+
for (let x = 0; x < width; x++) {
|
|
36
|
+
const si = (y * width + x) * 4;
|
|
37
|
+
const di = y * (1 + width * 4) + 1 + x * 4;
|
|
38
|
+
rawData[di + 0] = pixels[si + 0];
|
|
39
|
+
rawData[di + 1] = pixels[si + 1];
|
|
40
|
+
rawData[di + 2] = pixels[si + 2];
|
|
41
|
+
rawData[di + 3] = pixels[si + 3];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const compressed = zlib.deflateSync(rawData);
|
|
45
|
+
|
|
46
|
+
const ihdrChunk = makeChunk('IHDR', ihdr);
|
|
47
|
+
const idatChunk = makeChunk('IDAT', compressed);
|
|
48
|
+
const iendChunk = makeChunk('IEND', Buffer.alloc(0));
|
|
49
|
+
|
|
50
|
+
return Buffer.concat([signature, ihdrChunk, idatChunk, iendChunk]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function createICO(sizes, renderFn) {
|
|
54
|
+
const images = sizes.map(s => {
|
|
55
|
+
const pixels = new Uint8Array(s * s * 4);
|
|
56
|
+
renderFn(pixels, s);
|
|
57
|
+
return { size: s, data: createPNG(s, s, pixels) };
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const headerSize = 6 + images.length * 16;
|
|
61
|
+
let offset = headerSize;
|
|
62
|
+
|
|
63
|
+
const header = Buffer.alloc(6);
|
|
64
|
+
header.writeUInt16LE(0, 0);
|
|
65
|
+
header.writeUInt16LE(1, 2);
|
|
66
|
+
header.writeUInt16LE(images.length, 4);
|
|
67
|
+
|
|
68
|
+
const entries = [];
|
|
69
|
+
for (const img of images) {
|
|
70
|
+
const entry = Buffer.alloc(16);
|
|
71
|
+
entry.writeUInt8(img.size >= 256 ? 0 : img.size, 0);
|
|
72
|
+
entry.writeUInt8(img.size >= 256 ? 0 : img.size, 1);
|
|
73
|
+
entry.writeUInt8(0, 2);
|
|
74
|
+
entry.writeUInt8(0, 3);
|
|
75
|
+
entry.writeUInt16LE(1, 4);
|
|
76
|
+
entry.writeUInt16LE(32, 6);
|
|
77
|
+
entry.writeUInt32LE(img.data.length, 8);
|
|
78
|
+
entry.writeUInt32LE(offset, 12);
|
|
79
|
+
offset += img.data.length;
|
|
80
|
+
entries.push(entry);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return Buffer.concat([header, ...entries, ...images.map(i => i.data)]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const crcTable = new Uint32Array(256);
|
|
87
|
+
for (let n = 0; n < 256; n++) {
|
|
88
|
+
let c = n;
|
|
89
|
+
for (let k = 0; k < 8; k++) c = (c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1);
|
|
90
|
+
crcTable[n] = c;
|
|
91
|
+
}
|
|
92
|
+
function crc32(buf) {
|
|
93
|
+
let crc = 0xFFFFFFFF;
|
|
94
|
+
for (let i = 0; i < buf.length; i++) crc = crcTable[(crc ^ buf[i]) & 0xFF] ^ (crc >>> 8);
|
|
95
|
+
return (crc ^ 0xFFFFFFFF) >>> 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function setPixel(pixels, size, x, y, r, g, b, a = 255) {
|
|
99
|
+
if (x < 0 || x >= size || y < 0 || y >= size) return;
|
|
100
|
+
const i = (y * size + x) * 4;
|
|
101
|
+
const sa = a / 255;
|
|
102
|
+
const da = (pixels[i + 3] / 255) * (1 - sa);
|
|
103
|
+
const oa = sa + da;
|
|
104
|
+
if (oa > 0) {
|
|
105
|
+
pixels[i + 0] = Math.round((r * sa + pixels[i + 0] * da) / oa);
|
|
106
|
+
pixels[i + 1] = Math.round((g * sa + pixels[i + 1] * da) / oa);
|
|
107
|
+
pixels[i + 2] = Math.round((b * sa + pixels[i + 2] * da) / oa);
|
|
108
|
+
pixels[i + 3] = Math.round(oa * 255);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function fillRect(p, s, x0, y0, w, h, r, g, b, a = 255) {
|
|
113
|
+
for (let y = y0; y < y0 + h && y < s; y++)
|
|
114
|
+
for (let x = x0; x < x0 + w && x < s; x++)
|
|
115
|
+
setPixel(p, s, x, y, r, g, b, a);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function fillCircle(p, s, cx, cy, radius, r, g, b, a = 255) {
|
|
119
|
+
const r2 = radius * radius;
|
|
120
|
+
for (let y = Math.floor(cy - radius); y <= Math.ceil(cy + radius); y++) {
|
|
121
|
+
for (let x = Math.floor(cx - radius); x <= Math.ceil(cx + radius); x++) {
|
|
122
|
+
const dx = x - cx + 0.5, dy = y - cy + 0.5;
|
|
123
|
+
const d2 = dx * dx + dy * dy;
|
|
124
|
+
if (d2 <= r2) {
|
|
125
|
+
const edge = Math.max(0, Math.min(1, (radius - Math.sqrt(d2)) * 1.5));
|
|
126
|
+
setPixel(p, s, x, y, r, g, b, Math.round(a * edge));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function fillRoundRect(p, s, x0, y0, w, h, rad, r, g, b, a = 255) {
|
|
133
|
+
for (let y = y0; y < y0 + h; y++) {
|
|
134
|
+
for (let x = x0; x < x0 + w; x++) {
|
|
135
|
+
let draw = true;
|
|
136
|
+
if (x < x0 + rad && y < y0 + rad) {
|
|
137
|
+
const dx = x - (x0 + rad), dy = y - (y0 + rad);
|
|
138
|
+
if (dx * dx + dy * dy > rad * rad) draw = false;
|
|
139
|
+
} else if (x >= x0 + w - rad && y < y0 + rad) {
|
|
140
|
+
const dx = x - (x0 + w - rad - 1), dy = y - (y0 + rad);
|
|
141
|
+
if (dx * dx + dy * dy > rad * rad) draw = false;
|
|
142
|
+
} else if (x < x0 + rad && y >= y0 + h - rad) {
|
|
143
|
+
const dx = x - (x0 + rad), dy = y - (y0 + h - rad - 1);
|
|
144
|
+
if (dx * dx + dy * dy > rad * rad) draw = false;
|
|
145
|
+
} else if (x >= x0 + w - rad && y >= y0 + h - rad) {
|
|
146
|
+
const dx = x - (x0 + w - rad - 1), dy = y - (y0 + h - rad - 1);
|
|
147
|
+
if (dx * dx + dy * dy > rad * rad) draw = false;
|
|
148
|
+
}
|
|
149
|
+
if (draw) setPixel(p, s, x, y, r, g, b, a);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function distToSegment(px, py, ax, ay, bx, by) {
|
|
155
|
+
const dx = bx - ax, dy = by - ay;
|
|
156
|
+
const len2 = dx * dx + dy * dy;
|
|
157
|
+
if (len2 === 0) return Math.hypot(px - ax, py - ay);
|
|
158
|
+
const t = Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / len2));
|
|
159
|
+
return Math.hypot(px - (ax + t * dx), py - (ay + t * dy));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function drawSmooth(p, s, segments, ox, oy, scale, r, g, b) {
|
|
163
|
+
const thick = scale * 0.22;
|
|
164
|
+
const x0 = Math.floor(ox - thick - 1), y0 = Math.floor(oy - thick - 1);
|
|
165
|
+
const x1 = Math.ceil(ox + scale + thick + 1), y1 = Math.ceil(oy + scale + thick + 1);
|
|
166
|
+
for (let y = Math.max(0, y0); y < Math.min(s, y1); y++) {
|
|
167
|
+
for (let x = Math.max(0, x0); x < Math.min(s, x1); x++) {
|
|
168
|
+
let minD = Infinity;
|
|
169
|
+
for (const seg of segments) {
|
|
170
|
+
const d = distToSegment(x + 0.5, y + 0.5,
|
|
171
|
+
ox + seg[0] * scale, oy + seg[1] * scale,
|
|
172
|
+
ox + seg[2] * scale, oy + seg[3] * scale);
|
|
173
|
+
if (d < minD) minD = d;
|
|
174
|
+
}
|
|
175
|
+
if (minD < thick + 1) {
|
|
176
|
+
const alpha = Math.max(0, Math.min(1, (thick + 0.8 - minD) / 1.2));
|
|
177
|
+
setPixel(p, s, x, y, r, g, b, Math.round(255 * alpha));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function drawLetterN(p, s, cx, cy, h, r, g, b) {
|
|
184
|
+
const w = h * 0.7;
|
|
185
|
+
const x0 = cx - w / 2, y0 = cy - h / 2;
|
|
186
|
+
const segments = [
|
|
187
|
+
[0, 0, 0, 1],
|
|
188
|
+
[1, 0, 1, 1],
|
|
189
|
+
[0, 0, 1, 1],
|
|
190
|
+
];
|
|
191
|
+
drawSmooth(p, s, segments, x0, y0, h, r, g, b);
|
|
192
|
+
const extra = h * 0.22;
|
|
193
|
+
drawSmooth(p, s, [[0, 0, 0, 1], [1, 0, 1, 1], [0, 0, 1, 1]], x0, y0, h, r, g, b);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function drawLetterX(p, s, cx, cy, h, r, g, b) {
|
|
197
|
+
const segments = [
|
|
198
|
+
[0, 0, 1, 1],
|
|
199
|
+
[1, 0, 0, 1],
|
|
200
|
+
];
|
|
201
|
+
const x0 = cx - h * 0.35, y0 = cy - h / 2;
|
|
202
|
+
drawSmooth(p, s, segments, x0, y0, h, r, g, b);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function renderNaideIcon(pixels, size) {
|
|
206
|
+
const s = size;
|
|
207
|
+
const pad = Math.max(1, Math.round(s * 0.08));
|
|
208
|
+
const rad = Math.max(3, Math.round(s * 0.22));
|
|
209
|
+
|
|
210
|
+
fillRoundRect(pixels, s, 0, 0, s, s, rad, 35, 70, 150);
|
|
211
|
+
fillRoundRect(pixels, s, pad, pad, s - pad * 2, s - pad * 2, Math.max(2, rad - 2), 55, 110, 210);
|
|
212
|
+
|
|
213
|
+
const letterH = Math.round(s * 0.5);
|
|
214
|
+
drawLetterN(pixels, s, Math.round(s / 2), Math.round(s * 0.46), letterH, 255, 255, 255);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function renderNxIcon(pixels, size) {
|
|
218
|
+
const s = size;
|
|
219
|
+
const pad = Math.max(1, Math.round(s * 0.08));
|
|
220
|
+
const rad = Math.max(3, Math.round(s * 0.22));
|
|
221
|
+
|
|
222
|
+
fillRoundRect(pixels, s, 0, 0, s, s, rad, 25, 110, 60);
|
|
223
|
+
fillRoundRect(pixels, s, pad, pad, s - pad * 2, s - pad * 2, Math.max(2, rad - 2), 45, 160, 90);
|
|
224
|
+
|
|
225
|
+
const letterH = Math.round(s * 0.5);
|
|
226
|
+
drawLetterX(pixels, s, Math.round(s / 2), Math.round(s * 0.46), letterH, 255, 255, 255);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
mkdirSync(resolve(__dirname, '..', 'assets'), { recursive: true });
|
|
230
|
+
|
|
231
|
+
const naideIco = createICO([16, 32, 48, 256], renderNaideIcon);
|
|
232
|
+
const nxIco = createICO([16, 32, 48, 256], renderNxIcon);
|
|
233
|
+
|
|
234
|
+
writeFileSync(resolve(__dirname, '..', 'assets', 'naide.ico'), naideIco);
|
|
235
|
+
writeFileSync(resolve(__dirname, '..', 'assets', 'nx.ico'), nxIco);
|
|
236
|
+
|
|
237
|
+
console.log('Icons generated successfully.');
|
package/bin/postinstall.js
CHANGED
|
@@ -38,8 +38,11 @@ function registerWindows() {
|
|
|
38
38
|
regAdd('HKCU\\Software\\Classes\\NAIDEFile\\shell\\open\\command', cmd);
|
|
39
39
|
regAdd('HKCU\\Software\\Classes\\NAIDEXFile\\shell\\open\\command', cmd);
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
const assetsDir = resolve(__dirname, '..', 'assets');
|
|
42
|
+
const naideIco = resolve(assetsDir, 'naide.ico');
|
|
43
|
+
const nxIco = resolve(assetsDir, 'nx.ico');
|
|
44
|
+
regAdd('HKCU\\Software\\Classes\\NAIDEFile\\DefaultIcon', naideIco);
|
|
45
|
+
regAdd('HKCU\\Software\\Classes\\NAIDEXFile\\DefaultIcon', nxIco);
|
|
43
46
|
|
|
44
47
|
console.log(' .naide and .nx file associations registered (Windows)');
|
|
45
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "naider",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.4",
|
|
4
4
|
"description": "NAIDE - Simpler than Python, compiles to 15 targets. AI-specialized language with 35+ built-in functions, syntax sugar (unless/until/repeat/swap/is/isnt), and 47 features. Targets: Node.js, Python, TypeScript, C, C++, Java, Go, Rust, PHP, Ruby, Kotlin, Swift, Dart, C#, Bun.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"bin/",
|
|
16
16
|
"src/",
|
|
17
|
+
"assets/",
|
|
17
18
|
"lsp/",
|
|
18
19
|
"examples/",
|
|
19
20
|
"vscode-naide/",
|