Skip to content

Commit

Permalink
feat!: add native plugin example (#170)
Browse files Browse the repository at this point in the history
* initial pass at updating my-electron-crasher to look like bugsplat-ng (angular)

* address some PR comments.

* open logo and urls in external browser -- not in electron app.

* - add '!' to wow the customer.
- change box sizing of entire app.

* remove border around each error button.

* fix: capitalize plugin in button

Co-authored-by: Bobby Galli <[email protected]>
  • Loading branch information
csmith0651 and bobbyg603 authored Jan 12, 2023
1 parent 9e5c0e9 commit 61ee574
Show file tree
Hide file tree
Showing 14 changed files with 1,635 additions and 104 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
dist
.DS_Store
.env
.env
/build
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.15)
# Name of the project (will be the name of the plugin)
project (addon)
set(CMAKE_CXX_STANDARD 17)
# Don't add this line if you will try_compile with boost.
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Essential include files to build a node addon,
# you should add this line in every CMake.js based project.
include_directories(${CMAKE_JS_INC})
# Declare the location of the source files
file(GLOB SOURCE_FILES "src/plugin/*.cpp" "src/plugin/*.h")
# This line will tell CMake that we're building a shared library
# from the above source files
# named after the project's name
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
# This line will give our library file a .node extension without any "lib" prefix
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
# Essential library files to link to a node addon,
# you should add this line in every CMake.js based project.
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
# Include N-API wrappers
execute_process(COMMAND node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
)
string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR})
add_definitions(-DNAPI_VERSION=3)
83 changes: 42 additions & 41 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>my-electron-crasher</title>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'"/>
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'"/>
<link rel="stylesheet" href="./src/assets/css/styles.css">
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<a id="bugsplat_logo_url" href="https://www.bugsplat.com"><img class="logo" src="./src/assets/img/bugsplat-logo.png"></a>

<head>
<meta charset="UTF-8" />
<title>my-electron-crasher</title>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
<link rel="stylesheet" href="./src/assets/css/styles.css">
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
</head>

<body>
<div class="container-fluid">
<div class="row pt-4">
<div class="col">
<img src="./src/assets/img/logo.png" />
</div>
</div>
<div class="row">
<div class="col">
<h2>my-electron-crasher</h2>
</div>
</div>
<div class="row pt-2">
<div class="col">
<div id="main-error-button-container"></div>
</div>
</div>
<div class="row pt-2">
<div class="col">
<div id="renderer-error-button-container"></div>
</div>
</div>
<div class="row pt-2">
<div class="col">
<div id="native-crash-button-container"></div>
</div>
</div>
<!-- You can also require other files to run in this process -->
<script src="./dist/src/renderer.js"></script>
</body>

<div class="content">
<h1>
Welcome to my-electron-crasher!
</h1>
<p>
This is a sample application that demonstrates <a id="bugsplat_url" href="https://www.bugsplat.com">BugSplat</a>
error reporting for <a id="electron_url" href="https://www.electronjs.org">Electron</a> applications build with JavaScript
or TypeScript.
</p>
<div class="errors">
<h2>Errors</h2>
<button class="error" id="main-error-button">
<h2>Main Error</h2>
<h4>unhandled rejected promise</h4>
<h4>WILL TERMINATE APP</h4>
</button>
<button class="error" id="renderer-error-button">
<h2>Renderer Error</h2>
<h4>uncaught exception</h4>
</button>
<button class="error" id="native-crash-button">
<h2>Native (Plugin) Crash</h2>
<h4>dereference null pointer in native code</h4>
<h4>WILL TERMINATE APP</h4>
</button>
</div>
</div>
</div>
<script src="./dist/src/renderer.js"></script>
</body>
</html>
Loading

0 comments on commit 61ee574

Please sign in to comment.