feat(web): checkpoint web app init
- frontend (Vite/React) + server (Hono/Drizzle) scaffold under web/ - eeschema WASM embind kicadOpenFile hook + programmatic open-flow - skip KiCad first-run setup wizard by seeding default config in preRun - dev: auto-sync output/ WASM artifacts into tests/apps/kicad via link-wasm Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e28f473040
commit
735e5aa8e9
70 changed files with 7775 additions and 13 deletions
43
wasm/bindings/eeschema_embind.cpp
Normal file
43
wasm/bindings/eeschema_embind.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Embind bindings for KiCad eeschema WASM.
|
||||
*
|
||||
* Picked up automatically by scripts/kicad/build-kicad-target.sh when building
|
||||
* the eeschema app (it compiles wasm/bindings/<app>_embind.cpp if present).
|
||||
*/
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/bind.h>
|
||||
#include <kiway_player.h>
|
||||
#include <kiway.h>
|
||||
#include <vector>
|
||||
#include <wx/app.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/window.h>
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
// Programmatically open a project file (schematic) in the running editor frame,
|
||||
// without UI automation. Mirrors single_top.cpp's MacOpenFile path: the editor
|
||||
// frame is the app's top window and is a KIWAY_PLAYER. Returns the result of
|
||||
// OpenProjectFiles, or false if no frame is available — letting the JS caller
|
||||
// fall back to driving File→Open.
|
||||
bool kicadOpenFile( std::string path )
|
||||
{
|
||||
KIWAY_PLAYER* frame =
|
||||
wxTheApp ? static_cast<KIWAY_PLAYER*>( wxTheApp->GetTopWindow() ) : nullptr;
|
||||
|
||||
if( !frame )
|
||||
return false;
|
||||
|
||||
if( wxWindow* blocking = frame->Kiway().GetBlockingDialog() )
|
||||
blocking->Close( true );
|
||||
|
||||
return frame->OpenProjectFiles(
|
||||
std::vector<wxString>( 1, wxString::FromUTF8( path.c_str() ) ) );
|
||||
}
|
||||
|
||||
EMSCRIPTEN_BINDINGS(eeschema) {
|
||||
// Programmatic file open (preferred over UI automation from the web app).
|
||||
function("kicadOpenFile", &kicadOpenFile);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -14,10 +14,35 @@
|
|||
#include <board.h>
|
||||
#include <footprint.h>
|
||||
#include <pad.h>
|
||||
#include <kiway_player.h>
|
||||
#include <kiway.h>
|
||||
#include <vector>
|
||||
#include <wx/app.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/window.h>
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
// Programmatically open a project file (board/schematic) in the running editor
|
||||
// frame, without UI automation. Mirrors single_top.cpp's MacOpenFile path:
|
||||
// the editor frame is the app's top window and is a KIWAY_PLAYER. Returns the
|
||||
// result of OpenProjectFiles, or false if no frame is available — letting the
|
||||
// JS caller fall back to driving File→Open.
|
||||
bool kicadOpenFile( std::string path )
|
||||
{
|
||||
KIWAY_PLAYER* frame =
|
||||
wxTheApp ? static_cast<KIWAY_PLAYER*>( wxTheApp->GetTopWindow() ) : nullptr;
|
||||
|
||||
if( !frame )
|
||||
return false;
|
||||
|
||||
if( wxWindow* blocking = frame->Kiway().GetBlockingDialog() )
|
||||
blocking->Close( true );
|
||||
|
||||
return frame->OpenProjectFiles(
|
||||
std::vector<wxString>( 1, wxString::FromUTF8( path.c_str() ) ) );
|
||||
}
|
||||
|
||||
// Wrapper to return footprints as vector for JS iteration
|
||||
std::vector<FOOTPRINT*> Board_GetFootprints(BOARD* board) {
|
||||
if (!board) return {};
|
||||
|
|
@ -82,5 +107,8 @@ EMSCRIPTEN_BINDINGS(pcbnew) {
|
|||
function("Footprint_GetValue", &Footprint_GetValue, allow_raw_pointers());
|
||||
function("Pad_GetNumber", &Pad_GetNumber, allow_raw_pointers());
|
||||
function("Pad_GetPinFunction", &Pad_GetPinFunction, allow_raw_pointers());
|
||||
|
||||
// Programmatic file open (preferred over UI automation from the web app).
|
||||
function("kicadOpenFile", &kicadOpenFile);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue