windowpp 0.1.1
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/bin/windowpp.js +86 -0
- package/cmake/embed_assets.py +144 -0
- package/framework/CMakeLists.txt +176 -0
- package/framework/include/windowpp/windowpp.h +704 -0
- package/framework/src/AppData/API/AppData.ts +137 -0
- package/framework/src/AppData/appdata_bridge.h +138 -0
- package/framework/src/AppData/appdata_manager.cpp +126 -0
- package/framework/src/AppData/appdata_manager.h +3 -0
- package/framework/src/FileSystem/API/FileSystem.ts +389 -0
- package/framework/src/FileSystem/Linux/filesearch.cpp +148 -0
- package/framework/src/FileSystem/Linux/readfile.cpp +79 -0
- package/framework/src/FileSystem/Linux/savefile.cpp +333 -0
- package/framework/src/FileSystem/MacOS/filesearch.cpp +149 -0
- package/framework/src/FileSystem/MacOS/readfile.cpp +80 -0
- package/framework/src/FileSystem/MacOS/savefile.cpp +264 -0
- package/framework/src/FileSystem/Windows/filesearch.cpp +195 -0
- package/framework/src/FileSystem/Windows/readfile.cpp +122 -0
- package/framework/src/FileSystem/Windows/savefile.cpp +290 -0
- package/framework/src/FileSystem/file_index_service.cpp +262 -0
- package/framework/src/FileSystem/file_index_service.h +55 -0
- package/framework/src/FileSystem/filesystem_bridge.h +243 -0
- package/framework/src/FileSystem/filesystem_handler.h +93 -0
- package/framework/src/FileSystem/filesystem_json.h +241 -0
- package/framework/src/FileSystem/filesystem_search_service.cpp +414 -0
- package/framework/src/FileSystem/filesystem_search_service.h +94 -0
- package/framework/src/Input/API/Input.ts +161 -0
- package/framework/src/Input/Linux/linux_key_utils.h +135 -0
- package/framework/src/Input/MacOS/macos_key_utils.h +137 -0
- package/framework/src/Input/Windows/win32_key_utils.h +199 -0
- package/framework/src/Input/input_bridge.h +192 -0
- package/framework/src/Input/input_service.cpp +584 -0
- package/framework/src/Input/input_service.h +21 -0
- package/framework/src/application.cpp +29 -0
- package/framework/src/common/hit_test.cpp +40 -0
- package/framework/src/common/image_loader.cpp +24 -0
- package/framework/src/common/paths.cpp +75 -0
- package/framework/src/filedrop/filedrop.cpp +316 -0
- package/framework/src/filedrop/filedrop.css +421 -0
- package/framework/src/filedrop/filedrop.hpp +92 -0
- package/framework/src/filedrop/filedrop.ts +183 -0
- package/framework/src/platform/API/App.ts +156 -0
- package/framework/src/platform/API/Window.ts +249 -0
- package/framework/src/platform/linux/app_linux.cpp +256 -0
- package/framework/src/platform/linux/app_linux.h +64 -0
- package/framework/src/platform/linux/linux_helpers.cpp +26 -0
- package/framework/src/platform/linux/linux_helpers.h +19 -0
- package/framework/src/platform/linux/tray_linux.cpp +21 -0
- package/framework/src/platform/linux/tray_linux.h +26 -0
- package/framework/src/platform/linux/window_linux.cpp +256 -0
- package/framework/src/platform/linux/window_linux.h +70 -0
- package/framework/src/platform/macos/app_macos.h +59 -0
- package/framework/src/platform/macos/app_macos.mm +223 -0
- package/framework/src/platform/macos/macos_helpers.h +21 -0
- package/framework/src/platform/macos/tray_macos.h +22 -0
- package/framework/src/platform/macos/tray_macos.mm +53 -0
- package/framework/src/platform/macos/window_macos.h +74 -0
- package/framework/src/platform/macos/window_macos.mm +318 -0
- package/framework/src/platform/platform_bridge.h +514 -0
- package/framework/src/platform/platform_factory.cpp +33 -0
- package/framework/src/platform/platform_factory.h +19 -0
- package/framework/src/platform/win32/app_win32.cpp +572 -0
- package/framework/src/platform/win32/app_win32.h +83 -0
- package/framework/src/platform/win32/tray_win32.cpp +57 -0
- package/framework/src/platform/win32/tray_win32.h +30 -0
- package/framework/src/platform/win32/win32_helpers.h +61 -0
- package/framework/src/platform/win32/window_win32.cpp +267 -0
- package/framework/src/platform/win32/window_win32.h +79 -0
- package/framework/src/renderer/webgpu.h +128 -0
- package/framework/src/renderer/webview/include/WebView2.h +48014 -0
- package/framework/src/renderer/webview/include/WebView2EnvironmentOptions.h +342 -0
- package/framework/src/renderer/webview/webview.h +13 -0
- package/framework/src/renderer/webview/webview_linux.cpp +392 -0
- package/framework/src/renderer/webview/webview_macos.mm +388 -0
- package/framework/src/renderer/webview/webview_win32.cpp +688 -0
- package/framework/src/renderer/webview/x64/WebView2Loader.dll +0 -0
- package/framework/src/renderer/webview/x64/WebView2Loader.lib +0 -0
- package/framework/src/renderer/webview/x64/WebView2LoaderStatic.lib +0 -0
- package/lib/build.js +112 -0
- package/lib/create.js +283 -0
- package/lib/dev.js +155 -0
- package/package.json +24 -0
- package/scripts/publish.js +67 -0
- package/scripts/sync-framework.js +73 -0
- package/templates/solid/CMakeLists.txt +56 -0
- package/templates/solid/frontend/package.json +22 -0
- package/templates/solid/frontend/vite.config.ts +25 -0
- package/templates/solid/main.cpp +72 -0
- package/templates/solid/package.json +12 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// cli/scripts/sync-framework.js
|
|
3
|
+
//
|
|
4
|
+
// Copies the WindowPP C++ framework source from the monorepo into
|
|
5
|
+
// cli/framework/ so it gets bundled inside the npm package on publish.
|
|
6
|
+
//
|
|
7
|
+
// Run manually during local dev:
|
|
8
|
+
// node cli/scripts/sync-framework.js
|
|
9
|
+
//
|
|
10
|
+
// Called automatically by:
|
|
11
|
+
// npm run sync (in cli/package.json)
|
|
12
|
+
// prepublishOnly (before npm publish)
|
|
13
|
+
|
|
14
|
+
'use strict';
|
|
15
|
+
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const fs = require('fs');
|
|
18
|
+
|
|
19
|
+
const SCRIPT_DIR = __dirname;
|
|
20
|
+
const CLI_DIR = path.join(SCRIPT_DIR, '..');
|
|
21
|
+
const REPO_ROOT = path.join(CLI_DIR, '..');
|
|
22
|
+
const FRAMEWORK_DIR = path.join(CLI_DIR, 'framework');
|
|
23
|
+
|
|
24
|
+
const COPY_DIRS = ['src', 'include'];
|
|
25
|
+
|
|
26
|
+
function syncDir(src, dest) {
|
|
27
|
+
if (!fs.existsSync(src)) {
|
|
28
|
+
console.warn(` skip (not found): ${src}`);
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
32
|
+
let count = 0;
|
|
33
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
34
|
+
const srcPath = path.join(src, entry.name);
|
|
35
|
+
const destPath = path.join(dest, entry.name);
|
|
36
|
+
if (entry.isDirectory()) {
|
|
37
|
+
count += syncDir(srcPath, destPath);
|
|
38
|
+
} else {
|
|
39
|
+
fs.copyFileSync(srcPath, destPath);
|
|
40
|
+
count++;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return count;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function run() {
|
|
47
|
+
console.log('\n=== windowpp: syncing framework source ===\n');
|
|
48
|
+
console.log(` from: ${REPO_ROOT}`);
|
|
49
|
+
console.log(` to: ${FRAMEWORK_DIR}\n`);
|
|
50
|
+
|
|
51
|
+
let total = 0;
|
|
52
|
+
for (const dir of COPY_DIRS) {
|
|
53
|
+
const src = path.join(REPO_ROOT, dir);
|
|
54
|
+
const dest = path.join(FRAMEWORK_DIR, dir);
|
|
55
|
+
const n = syncDir(src, dest);
|
|
56
|
+
console.log(` synced ${dir}/ → ${n} file(s)`);
|
|
57
|
+
total += n;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Also keep cmake/embed_assets.py in sync
|
|
61
|
+
const embedSrc = path.join(REPO_ROOT, 'cmake', 'embed_assets.py');
|
|
62
|
+
const embedDest = path.join(CLI_DIR, 'cmake', 'embed_assets.py');
|
|
63
|
+
if (fs.existsSync(embedSrc)) {
|
|
64
|
+
fs.mkdirSync(path.dirname(embedDest), { recursive: true });
|
|
65
|
+
fs.copyFileSync(embedSrc, embedDest);
|
|
66
|
+
console.log(' synced cmake/embed_assets.py');
|
|
67
|
+
total++;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log(`\n✓ Synced ${total} file(s) into cli/framework/\n`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
run();
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.16)
|
|
2
|
+
project({{CMAKE_TARGET}} VERSION 0.1.0 LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
|
|
7
|
+
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
|
8
|
+
|
|
9
|
+
# ─── WindowPP Framework ───────────────────────────────────────────────────────
|
|
10
|
+
# WPP_FRAMEWORK_DIR is injected by `windowpp build` / `windowpp dev`.
|
|
11
|
+
# To build manually without the CLI:
|
|
12
|
+
# cmake -S . -B build -DWPP_FRAMEWORK_DIR=/path/to/windowpp/framework
|
|
13
|
+
if(NOT DEFINED WPP_FRAMEWORK_DIR)
|
|
14
|
+
message(FATAL_ERROR
|
|
15
|
+
"WPP_FRAMEWORK_DIR is not set.\n"
|
|
16
|
+
" Build via: windowpp build\n"
|
|
17
|
+
" Or pass: -DWPP_FRAMEWORK_DIR=<path/to/windowpp/cli/framework>"
|
|
18
|
+
)
|
|
19
|
+
endif()
|
|
20
|
+
|
|
21
|
+
add_subdirectory("${WPP_FRAMEWORK_DIR}" "${CMAKE_BINARY_DIR}/windowpp_lib")
|
|
22
|
+
|
|
23
|
+
# ─── App Target ───────────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
set(GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
|
|
26
|
+
set(EMBEDDED_ASSETS_CPP ${GENERATED_DIR}/embedded_assets.cpp)
|
|
27
|
+
set(EMBEDDED_ASSETS_H ${GENERATED_DIR}/embedded_assets.h)
|
|
28
|
+
|
|
29
|
+
add_custom_command(
|
|
30
|
+
OUTPUT ${EMBEDDED_ASSETS_CPP} ${EMBEDDED_ASSETS_H}
|
|
31
|
+
COMMAND ${CMAKE_COMMAND} -E make_directory ${GENERATED_DIR}
|
|
32
|
+
COMMAND ${Python3_EXECUTABLE}
|
|
33
|
+
${WPP_EMBED_SCRIPT}
|
|
34
|
+
${CMAKE_CURRENT_SOURCE_DIR}/frontend/dist
|
|
35
|
+
${EMBEDDED_ASSETS_CPP}
|
|
36
|
+
${EMBEDDED_ASSETS_H}
|
|
37
|
+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/frontend/dist/index.html
|
|
38
|
+
COMMENT "Embedding {{APP_TITLE}} frontend assets into C++ byte arrays..."
|
|
39
|
+
VERBATIM
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
set_source_files_properties(
|
|
43
|
+
${EMBEDDED_ASSETS_CPP}
|
|
44
|
+
${EMBEDDED_ASSETS_H}
|
|
45
|
+
PROPERTIES GENERATED TRUE
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
add_custom_target({{CMAKE_TARGET}}_frontend_assets ALL
|
|
49
|
+
DEPENDS ${EMBEDDED_ASSETS_CPP} ${EMBEDDED_ASSETS_H}
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
add_executable({{CMAKE_TARGET}} main.cpp ${EMBEDDED_ASSETS_CPP})
|
|
53
|
+
target_include_directories({{CMAKE_TARGET}} PRIVATE ${GENERATED_DIR})
|
|
54
|
+
target_compile_definitions({{CMAKE_TARGET}} PRIVATE WPP_EMBEDDED_ASSETS)
|
|
55
|
+
target_link_libraries({{CMAKE_TARGET}} PRIVATE windowpp windowpp_deps nlohmann_json::nlohmann_json)
|
|
56
|
+
add_dependencies({{CMAKE_TARGET}} {{CMAKE_TARGET}}_frontend_assets)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{APP_NAME}}-frontend",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"serve": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@solidjs/router": "^0.16.1",
|
|
13
|
+
"solid-js": "^1.9.9"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@tailwindcss/vite": "^4.1.13",
|
|
17
|
+
"tailwindcss": "^4.1.13",
|
|
18
|
+
"typescript": "^5.9.2",
|
|
19
|
+
"vite": "^7.1.4",
|
|
20
|
+
"vite-plugin-solid": "^2.11.8"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import solidPlugin from 'vite-plugin-solid';
|
|
5
|
+
|
|
6
|
+
const REPO_ROOT = '{{REPO_ROOT}}';
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [solidPlugin(), tailwindcss()],
|
|
10
|
+
base: './',
|
|
11
|
+
resolve: {
|
|
12
|
+
alias: {
|
|
13
|
+
'@wpp': resolve(REPO_ROOT, 'src/platform/API'),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
server: {
|
|
17
|
+
port: 3000,
|
|
18
|
+
fs: {
|
|
19
|
+
allow: [REPO_ROOT],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
build: {
|
|
23
|
+
target: 'esnext',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// main.cpp — {{APP_TITLE}} (WindowPP App)
|
|
3
|
+
//
|
|
4
|
+
// Build modes
|
|
5
|
+
// ───────────
|
|
6
|
+
// Release: Assets embedded in binary via embedded_assets.cpp
|
|
7
|
+
// Dev: WPP_DEV_URL=http://localhost:3000 ./{{CMAKE_TARGET}}
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
#include <windowpp/windowpp.h>
|
|
11
|
+
#include "../../src/platform/platform_bridge.h"
|
|
12
|
+
#include <cstdlib>
|
|
13
|
+
#include <memory>
|
|
14
|
+
|
|
15
|
+
#ifdef WPP_EMBEDDED_ASSETS
|
|
16
|
+
#include "embedded_assets.h"
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
int main() {
|
|
20
|
+
wpp::AppConfig app_config;
|
|
21
|
+
app_config.name = "{{APP_TITLE}}";
|
|
22
|
+
app_config.quit_on_last_close = true;
|
|
23
|
+
|
|
24
|
+
auto app = wpp::create_app(app_config);
|
|
25
|
+
|
|
26
|
+
wpp::WindowConfig main_win;
|
|
27
|
+
main_win.id = "main";
|
|
28
|
+
main_win.title = "{{APP_TITLE}}";
|
|
29
|
+
main_win.width = 1280;
|
|
30
|
+
main_win.height = 800;
|
|
31
|
+
main_win.center = true;
|
|
32
|
+
main_win.frameless = true;
|
|
33
|
+
main_win.transparent = true;
|
|
34
|
+
main_win.background = {0, 0, 0, 0};
|
|
35
|
+
|
|
36
|
+
main_win.webview.enabled = true;
|
|
37
|
+
main_win.scrollbars = false;
|
|
38
|
+
|
|
39
|
+
const char* dev_url = std::getenv("WPP_DEV_URL");
|
|
40
|
+
|
|
41
|
+
#ifdef WPP_EMBEDDED_ASSETS
|
|
42
|
+
if (!dev_url) {
|
|
43
|
+
main_win.webview.custom_scheme = "app";
|
|
44
|
+
main_win.webview.scheme_handler = [](const wpp::SchemeRequest& req, wpp::SchemeResponse& res) {
|
|
45
|
+
resolve_embedded_asset(req, res);
|
|
46
|
+
};
|
|
47
|
+
main_win.webview.url = "app://localhost/index.html";
|
|
48
|
+
} else {
|
|
49
|
+
main_win.webview.url = dev_url;
|
|
50
|
+
}
|
|
51
|
+
#else
|
|
52
|
+
main_win.webview.url = dev_url ? dev_url : "http://localhost:3000";
|
|
53
|
+
#endif
|
|
54
|
+
|
|
55
|
+
auto win = app->create_window(main_win);
|
|
56
|
+
|
|
57
|
+
auto platform_bridge = std::make_shared<wpp::PlatformBridge>(
|
|
58
|
+
[&win](const std::string& js) {
|
|
59
|
+
if (win && win->webview()) win->webview()->eval(js);
|
|
60
|
+
},
|
|
61
|
+
[&app](std::function<void()> fn) {
|
|
62
|
+
app->dispatch(std::move(fn));
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
win->webview()->on_message([platform_bridge](const std::string& msg) {
|
|
67
|
+
platform_bridge->handle(msg);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
app->run();
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{APP_NAME}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "{{APP_TITLE}} — a WindowPP app",
|
|
5
|
+
"cmakeTarget": "{{CMAKE_TARGET}}",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "windowpp dev",
|
|
8
|
+
"dev:clean": "windowpp dev --clean",
|
|
9
|
+
"build": "windowpp build",
|
|
10
|
+
"build:clean": "windowpp build --clean"
|
|
11
|
+
}
|
|
12
|
+
}
|