nanoshell 1.7.4 → 1.7.6
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 +34 -47
- package/SKILL.md +23 -13
- package/app/app.js +75 -43
- package/app/index.html +2 -0
- package/cli/index.js +43 -1
- package/example_app/app.js +22 -2
- package/example_app/index.html +2 -0
- package/package.json +15 -5
- package/zig-out/bin/cacert.pem +3363 -0
- package/zig-out/bin/example_app.exe +0 -0
- package/zig-out/bin/icudt67l.dat +0 -0
- package/zig-out/bin/nanoshell.exe +0 -0
- package/zig-out/bin/resources/cacert.pem +3363 -0
- package/zig-out/bin/resources/icudt67l.dat +0 -0
- package/cli/bundler.zig +0 -128
- package/cli/dev_server.zig +0 -192
- package/cli/installer.zig +0 -362
- package/cli/main.zig +0 -264
- package/vendor/bin/AppCore.dll +0 -0
- package/vendor/bin/Ultralight.dll +0 -0
- package/vendor/bin/UltralightCore.dll +0 -0
- package/vendor/bin/WebCore.dll +0 -0
- package/vendor/bin/msvcp140.dll +0 -0
- package/vendor/bin/vcruntime140.dll +0 -0
- package/vendor/bin/vcruntime140_1.dll +0 -0
package/cli/main.zig
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
const installer = @import("installer.zig");
|
|
3
|
-
|
|
4
|
-
extern "kernel32" fn GetCommandLineW() callconv(.c) [*:0]const u16;
|
|
5
|
-
|
|
6
|
-
pub fn main() !void {
|
|
7
|
-
const allocator = std.heap.page_allocator;
|
|
8
|
-
|
|
9
|
-
const cmd_line_ptr = GetCommandLineW();
|
|
10
|
-
const len = std.mem.indexOfSentinel(u16, 0, cmd_line_ptr);
|
|
11
|
-
|
|
12
|
-
var args_iter = try std.process.Args.Iterator.Windows.init(allocator, cmd_line_ptr[0..len]);
|
|
13
|
-
defer args_iter.deinit();
|
|
14
|
-
|
|
15
|
-
_ = args_iter.skip(); // skip executable name
|
|
16
|
-
|
|
17
|
-
const subcmd = args_iter.next() orelse "";
|
|
18
|
-
|
|
19
|
-
if (std.mem.eql(u8, subcmd, "build")) {
|
|
20
|
-
std.log.info("NanoShell Build", .{});
|
|
21
|
-
std.log.info("Building production release binary...", .{});
|
|
22
|
-
|
|
23
|
-
const io = std.Io.Threaded.global_single_threaded.io();
|
|
24
|
-
_ = std.Io.Dir.cwd().createDir(io, "dist", .default_dir) catch {};
|
|
25
|
-
|
|
26
|
-
var config = installer.loadConfig(allocator) catch installer.AppConfig{};
|
|
27
|
-
defer config.deinit(allocator);
|
|
28
|
-
|
|
29
|
-
var bundler = @import("bundler.zig").SingleBinaryBundler.init(allocator, .{
|
|
30
|
-
.app_name = config.name,
|
|
31
|
-
.entry_point = "app/index.html",
|
|
32
|
-
.output_dir = "dist",
|
|
33
|
-
});
|
|
34
|
-
try bundler.bundle();
|
|
35
|
-
|
|
36
|
-
std.log.info("Build complete.", .{});
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (std.mem.eql(u8, subcmd, "package") or std.mem.eql(u8, subcmd, "installer")) {
|
|
41
|
-
std.log.info("NanoShell Build & Package", .{});
|
|
42
|
-
std.log.info("Building production release binary...", .{});
|
|
43
|
-
|
|
44
|
-
const io = std.Io.Threaded.global_single_threaded.io();
|
|
45
|
-
_ = std.Io.Dir.cwd().createDir(io, "dist", .default_dir) catch {};
|
|
46
|
-
|
|
47
|
-
var config = installer.loadConfig(allocator) catch installer.AppConfig{};
|
|
48
|
-
defer config.deinit(allocator);
|
|
49
|
-
|
|
50
|
-
var bundler = @import("bundler.zig").SingleBinaryBundler.init(allocator, .{
|
|
51
|
-
.app_name = config.name,
|
|
52
|
-
.entry_point = "app/index.html",
|
|
53
|
-
.output_dir = "dist",
|
|
54
|
-
});
|
|
55
|
-
try bundler.bundle();
|
|
56
|
-
|
|
57
|
-
try installer.run(allocator);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const dev_server = @import("dev_server.zig");
|
|
62
|
-
|
|
63
|
-
if (std.mem.eql(u8, subcmd, "start")) {
|
|
64
|
-
var server = dev_server.DevServer.init(allocator);
|
|
65
|
-
try server.runDevMode(".");
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Scaffolding a new NanoShell project if an app name is passed
|
|
70
|
-
if (subcmd.len > 0 and !std.mem.startsWith(u8, subcmd, "-")) {
|
|
71
|
-
const app_dir_name = subcmd;
|
|
72
|
-
std.log.info("Scaffolding new NanoShell app in .\\{s}...", .{app_dir_name});
|
|
73
|
-
|
|
74
|
-
const io = std.Io.Threaded.global_single_threaded.io();
|
|
75
|
-
_ = std.Io.Dir.cwd().createDir(io, app_dir_name, .default_dir) catch |err| {
|
|
76
|
-
if (err != error.PathAlreadyExists) {
|
|
77
|
-
std.log.err("Failed to create directory '{s}': {s}", .{ app_dir_name, @errorName(err) });
|
|
78
|
-
return err;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
var app_dir = std.Io.Dir.cwd().openDir(io, app_dir_name, .{}) catch |err| {
|
|
83
|
-
std.log.err("Failed to open directory '{s}': {s}", .{ app_dir_name, @errorName(err) });
|
|
84
|
-
return err;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
_ = app_dir.createDir(io, "app", .default_dir) catch {};
|
|
88
|
-
_ = app_dir.createDir(io, "assets", .default_dir) catch {};
|
|
89
|
-
_ = app_dir.createDir(io, "resources", .default_dir) catch {};
|
|
90
|
-
_ = app_dir.createDir(io, "bin", .default_dir) catch {};
|
|
91
|
-
_ = app_dir.createDir(io, "bin/resources", .default_dir) catch {};
|
|
92
|
-
|
|
93
|
-
// Write placeholder assets/icon.ico
|
|
94
|
-
try app_dir.writeFile(io, .{ .sub_path = "assets/icon.ico", .data = "NANO_ICON" });
|
|
95
|
-
|
|
96
|
-
// Write default nanoshell.json with full window management settings
|
|
97
|
-
const json_content = try std.fmt.allocPrint(allocator,
|
|
98
|
-
"{{\n" ++
|
|
99
|
-
" \"name\": \"{s}\",\n" ++
|
|
100
|
-
" \"version\": \"1.0.0\",\n" ++
|
|
101
|
-
" \"author\": \"Your Name\",\n" ++
|
|
102
|
-
" \"description\": \"Blazing fast desktop app created with NanoShell\",\n" ++
|
|
103
|
-
" \"icon\": \"assets\\\\icon.ico\",\n" ++
|
|
104
|
-
" \"exe_name\": \"{s}.exe\",\n" ++
|
|
105
|
-
" \"window\": {{\n" ++
|
|
106
|
-
" \"width\": 1280,\n" ++
|
|
107
|
-
" \"height\": 720,\n" ++
|
|
108
|
-
" \"resizable\": true,\n" ++
|
|
109
|
-
" \"frameless\": false,\n" ++
|
|
110
|
-
" \"transparent\": false,\n" ++
|
|
111
|
-
" \"always_on_top\": false\n" ++
|
|
112
|
-
" }}\n" ++
|
|
113
|
-
"}}\n",
|
|
114
|
-
.{ app_dir_name, app_dir_name }
|
|
115
|
-
);
|
|
116
|
-
defer allocator.free(json_content);
|
|
117
|
-
|
|
118
|
-
try app_dir.writeFile(io, .{ .sub_path = "nanoshell.json", .data = json_content });
|
|
119
|
-
|
|
120
|
-
// Write default HTML/CSS/JS inside app/
|
|
121
|
-
const html_content =
|
|
122
|
-
\\<!DOCTYPE html>
|
|
123
|
-
\\<html lang="en">
|
|
124
|
-
\\<head>
|
|
125
|
-
\\ <meta charset="UTF-8">
|
|
126
|
-
\\ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
127
|
-
\\ <title>NanoShell Application</title>
|
|
128
|
-
\\ <link rel="stylesheet" href="styles.css">
|
|
129
|
-
\\</head>
|
|
130
|
-
\\<body>
|
|
131
|
-
\\ <div class="container">
|
|
132
|
-
\\ <div class="fps-badge"><span id="fps-val">120</span> FPS Locked</div>
|
|
133
|
-
\\ <h1>⚡ NanoShell Desktop App</h1>
|
|
134
|
-
\\ <p>Ultra-lightweight WebKit desktop runtime</p>
|
|
135
|
-
\\ <button id="btn">Click Me</button>
|
|
136
|
-
\\ </div>
|
|
137
|
-
\\ <!-- app.js is injected inline by the NanoShell engine at load time -->
|
|
138
|
-
\\</body>
|
|
139
|
-
\\</html>
|
|
140
|
-
;
|
|
141
|
-
try app_dir.writeFile(io, .{ .sub_path = "app/index.html", .data = html_content });
|
|
142
|
-
|
|
143
|
-
const css_content =
|
|
144
|
-
\\body {
|
|
145
|
-
\\ margin: 0;
|
|
146
|
-
\\ font-family: system-ui, -apple-system, sans-serif;
|
|
147
|
-
\\ background: #0f172a;
|
|
148
|
-
\\ color: #f8fafc;
|
|
149
|
-
\\ display: flex;
|
|
150
|
-
\\ justify-content: center;
|
|
151
|
-
\\ align-items: center;
|
|
152
|
-
\\ height: 100vh;
|
|
153
|
-
\\}
|
|
154
|
-
\\.container {
|
|
155
|
-
\\ position: relative;
|
|
156
|
-
\\ text-align: center;
|
|
157
|
-
\\ background: #1e293b;
|
|
158
|
-
\\ padding: 2.5rem;
|
|
159
|
-
\\ border-radius: 1rem;
|
|
160
|
-
\\ box-shadow: 0 10px 25px rgba(0,0,0,0.5);
|
|
161
|
-
\\}
|
|
162
|
-
\\.fps-badge {
|
|
163
|
-
\\ position: absolute;
|
|
164
|
-
\\ top: 1rem;
|
|
165
|
-
\\ right: 1rem;
|
|
166
|
-
\\ font-size: 0.75rem;
|
|
167
|
-
\\ font-weight: bold;
|
|
168
|
-
\\ color: #38bdf8;
|
|
169
|
-
\\ background: rgba(56, 189, 248, 0.1);
|
|
170
|
-
\\ padding: 0.25rem 0.5rem;
|
|
171
|
-
\\ border-radius: 0.25rem;
|
|
172
|
-
\\}
|
|
173
|
-
\\button {
|
|
174
|
-
\\ background: #38bdf8;
|
|
175
|
-
\\ color: #0f172a;
|
|
176
|
-
\\ border: none;
|
|
177
|
-
\\ padding: 0.75rem 1.5rem;
|
|
178
|
-
\\ font-weight: bold;
|
|
179
|
-
\\ border-radius: 0.5rem;
|
|
180
|
-
\\ cursor: pointer;
|
|
181
|
-
\\}
|
|
182
|
-
\\button:hover { background: #7dd3fc; }
|
|
183
|
-
;
|
|
184
|
-
try app_dir.writeFile(io, .{ .sub_path = "app/styles.css", .data = css_content });
|
|
185
|
-
|
|
186
|
-
const js_content =
|
|
187
|
-
\\// NanoShell Application JavaScript (0% Idle CPU Overhead)
|
|
188
|
-
\\console.log('⚡ [NanoShell] App loaded successfully');
|
|
189
|
-
\\
|
|
190
|
-
\\const btn = document.getElementById('btn');
|
|
191
|
-
\\if (btn) {
|
|
192
|
-
\\ btn.addEventListener('click', () => {
|
|
193
|
-
\\ alert('Hello from NanoShell!');
|
|
194
|
-
\\ });
|
|
195
|
-
\\}
|
|
196
|
-
;
|
|
197
|
-
try app_dir.writeFile(io, .{ .sub_path = "app/app.js", .data = js_content });
|
|
198
|
-
|
|
199
|
-
// Copy prebuilt runtime binaries and DLLs into scaffolded project
|
|
200
|
-
const cwd = std.Io.Dir.cwd();
|
|
201
|
-
const exe_dst_path = try std.fmt.allocPrint(allocator, "bin/{s}.exe", .{app_dir_name});
|
|
202
|
-
defer allocator.free(exe_dst_path);
|
|
203
|
-
|
|
204
|
-
_ = cwd.copyFile("zig-out/bin/example_app.exe", app_dir, exe_dst_path, io, .{}) catch
|
|
205
|
-
cwd.copyFile("example_app.exe", app_dir, exe_dst_path, io, .{}) catch {};
|
|
206
|
-
|
|
207
|
-
_ = cwd.copyFile("zig-out/bin/AppCore.dll", app_dir, "bin/AppCore.dll", io, .{}) catch
|
|
208
|
-
cwd.copyFile("AppCore.dll", app_dir, "bin/AppCore.dll", io, .{}) catch {};
|
|
209
|
-
|
|
210
|
-
_ = cwd.copyFile("zig-out/bin/Ultralight.dll", app_dir, "bin/Ultralight.dll", io, .{}) catch
|
|
211
|
-
cwd.copyFile("Ultralight.dll", app_dir, "bin/Ultralight.dll", io, .{}) catch {};
|
|
212
|
-
|
|
213
|
-
_ = cwd.copyFile("zig-out/bin/UltralightCore.dll", app_dir, "bin/UltralightCore.dll", io, .{}) catch
|
|
214
|
-
cwd.copyFile("UltralightCore.dll", app_dir, "bin/UltralightCore.dll", io, .{}) catch {};
|
|
215
|
-
|
|
216
|
-
_ = cwd.copyFile("zig-out/bin/WebCore.dll", app_dir, "bin/WebCore.dll", io, .{}) catch
|
|
217
|
-
cwd.copyFile("WebCore.dll", app_dir, "bin/WebCore.dll", io, .{}) catch {};
|
|
218
|
-
|
|
219
|
-
_ = cwd.copyFile("vendor/bin/vcruntime140.dll", app_dir, "bin/vcruntime140.dll", io, .{}) catch
|
|
220
|
-
cwd.copyFile("zig-out/bin/vcruntime140.dll", app_dir, "bin/vcruntime140.dll", io, .{}) catch {};
|
|
221
|
-
|
|
222
|
-
_ = cwd.copyFile("vendor/bin/msvcp140.dll", app_dir, "bin/msvcp140.dll", io, .{}) catch
|
|
223
|
-
cwd.copyFile("zig-out/bin/msvcp140.dll", app_dir, "bin/msvcp140.dll", io, .{}) catch {};
|
|
224
|
-
|
|
225
|
-
_ = cwd.copyFile("vendor/bin/vcruntime140_1.dll", app_dir, "bin/vcruntime140_1.dll", io, .{}) catch
|
|
226
|
-
cwd.copyFile("zig-out/bin/vcruntime140_1.dll", app_dir, "bin/vcruntime140_1.dll", io, .{}) catch {};
|
|
227
|
-
|
|
228
|
-
_ = cwd.copyFile("vendor/resources/icudt67l.dat", app_dir, "bin/icudt67l.dat", io, .{}) catch
|
|
229
|
-
cwd.copyFile("bin/icudt67l.dat", app_dir, "bin/icudt67l.dat", io, .{}) catch {};
|
|
230
|
-
|
|
231
|
-
_ = cwd.copyFile("vendor/resources/cacert.pem", app_dir, "bin/cacert.pem", io, .{}) catch
|
|
232
|
-
cwd.copyFile("bin/cacert.pem", app_dir, "bin/cacert.pem", io, .{}) catch {};
|
|
233
|
-
|
|
234
|
-
_ = cwd.copyFile("vendor/resources/icudt67l.dat", app_dir, "bin/resources/icudt67l.dat", io, .{}) catch
|
|
235
|
-
cwd.copyFile("bin/resources/icudt67l.dat", app_dir, "bin/resources/icudt67l.dat", io, .{}) catch {};
|
|
236
|
-
|
|
237
|
-
_ = cwd.copyFile("vendor/resources/cacert.pem", app_dir, "bin/resources/cacert.pem", io, .{}) catch
|
|
238
|
-
cwd.copyFile("bin/resources/cacert.pem", app_dir, "bin/resources/cacert.pem", io, .{}) catch {};
|
|
239
|
-
|
|
240
|
-
std.log.info("=================================================================", .{});
|
|
241
|
-
std.log.info(" SUCCESS! Scaffolded new NanoShell app: .\\{s}", .{app_dir_name});
|
|
242
|
-
std.log.info(" To get started:", .{});
|
|
243
|
-
std.log.info(" cd {s}", .{app_dir_name});
|
|
244
|
-
std.log.info(" npx nanoshell package", .{});
|
|
245
|
-
std.log.info("=================================================================", .{});
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Help banner if no command or invalid command is provided
|
|
250
|
-
std.log.info("+===================================================+", .{});
|
|
251
|
-
std.log.info("| NanoShell CLI v1.0.4 . by Suman Biswas |", .{});
|
|
252
|
-
std.log.info("| 17MB RAM . 120 FPS . WebKit-powered desktop apps |", .{});
|
|
253
|
-
std.log.info("+===================================================+", .{});
|
|
254
|
-
std.log.info("Usage:", .{});
|
|
255
|
-
std.log.info(" npx nanoshell <my-app> Scaffold a new NanoShell app", .{});
|
|
256
|
-
std.log.info(" npx nanoshell build Build production release binary only", .{});
|
|
257
|
-
std.log.info(" npx nanoshell start Launch the dev engine", .{});
|
|
258
|
-
std.log.info(" npx nanoshell package Build binary and generate Windows installer", .{});
|
|
259
|
-
std.log.info("nanoshell package:", .{});
|
|
260
|
-
std.log.info(" - Reads nanoshell.json for app name, version, author", .{});
|
|
261
|
-
std.log.info(" - Generates setup.iss (Inno Setup script)", .{});
|
|
262
|
-
std.log.info(" - Auto-compiles to dist\\AppName-Setup.exe if ISCC found", .{});
|
|
263
|
-
std.log.info(" - Installer lets user choose: Admin OR per-user install", .{});
|
|
264
|
-
}
|
package/vendor/bin/AppCore.dll
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/vendor/bin/WebCore.dll
DELETED
|
Binary file
|
package/vendor/bin/msvcp140.dll
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|