diff --git a/Crafter.CppDOM-Bindings.o b/Crafter.CppDOM-Bindings.o new file mode 100644 index 0000000..9336cb6 Binary files /dev/null and b/Crafter.CppDOM-Bindings.o differ diff --git a/Crafter.CppDOM-HtmlElement.o b/Crafter.CppDOM-HtmlElement.o new file mode 100644 index 0000000..701dcf9 Binary files /dev/null and b/Crafter.CppDOM-HtmlElement.o differ diff --git a/Crafter.CppDOM.o b/Crafter.CppDOM.o new file mode 100644 index 0000000..f7510e6 Binary files /dev/null and b/Crafter.CppDOM.o differ diff --git a/README.md b/README.md index 1c5363e..fd0fe6e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Crafter.CppDOM is a C++ library that exposes the browser DOM api's to C++ WebAssembly. # How to use -Please view the samples folder, this is a snippit from the HelloElement sample: +Please view the examples folder, this is a snippit from the HelloElement example: ```cpp import Crafter.CppDOM; @@ -18,31 +18,26 @@ int main(){ ``` You can also view the wiki for more detailed information. -It is highly recommended to use this with [Crafter.WebBuild](https://github.com/Catcrafts/Crafter.WebBuild), but it is not strictly required if the same way of injecting the env is followed. The following instructions will be for Crafter.WebBuild. +It is highly recommended to use this with [Crafter.Build](https://forgejo.catcrafts.net/Catcrafts/Crafter.Build), but it is not strictly required if the same way of injecting the env is followed. The following instructions will be for Crafter.Build. ## Quickstart create a ``project.json`` in an empty folder, open it in your preferred text editor. Create a basic project file, that describes your web project. ```JSON { - "name": "sample-project", + "name": "main", "configurations": [ { - "name": "debug", - "standard": "c++26", - "source_files": ["main"], - "module_files": [], - "build_dir": "./build", - "output_dir": "./bin", - "optimization_level": "0", - "target": "wasm32-unknown-wasi", - "type": "executable", + "name": "executable", + "implementations": ["main"], + "target": "wasm32-wasi", + "debug" : true, "dependencies": [ { - "path":"https://github.com/Catcrafts/Crafter.CppDOM.git", - "configuration":"debug" + "path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.CppDOM.git", + "configuration":"lib-debug" } - ] + ], } ] } @@ -59,6 +54,6 @@ int main(){ } ``` -Save and close, then run ``crafter-webbuild serve -c debug``. Now you can open the browser at ``http://localhost:8080/`` and ``Hello World!`` will appear in the browser. +Save and close, then run ``crafter-build build executable && caddy file-server --listen :8080 --root bin/executable``. if you have caddy installed, if not use your favorite static file server instead. Now you can open the browser at ``http://localhost:8080`` and ``Hello World!`` will appear in the browser. -This sample can also be viewed in the [HelloElement sample](https://github.com/Catcrafts/Crafter.CppDOM/tree/master/samples/HelloElement) +This sample can also be viewed in the [HelloElement example](https://forgejo.catcrafts.net/Catcrafts/Crafter.CppDOM/src/branch/master/examples) diff --git a/Crafter.CppDOM.js b/additional/env.js similarity index 90% rename from Crafter.CppDOM.js rename to additional/env.js index f97b6fa..6c6ef3c 100644 --- a/Crafter.CppDOM.js +++ b/additional/env.js @@ -43,8 +43,4 @@ let env = { setInnerHTML:setInnerHTML, } -if(window.crafter_webbuild_env){ - window.crafter_webbuild_env = {...crafter_webbuild_env, env}; -} else { - window.crafter_webbuild_env = env; -} +window.crafter_webbuild_env = env; \ No newline at end of file diff --git a/examples/HelloElement/README.md b/examples/HelloElement/README.md new file mode 100644 index 0000000..cee586e --- /dev/null +++ b/examples/HelloElement/README.md @@ -0,0 +1,12 @@ +![alt text](https://github.com/Catcrafts/Crafter.Web/blob/master/samples/HelloWorld/HelloWorld.png?raw=true) + +This sample demonstrates how to use the element class + +```bash +crafter-build build executable +run.sh +``` + +and go to `http://localhost:8080/` + +if caddy is not installed you can use your favorite static file server instead \ No newline at end of file diff --git a/samples/HelloElement/main.cpp b/examples/HelloElement/main.cpp similarity index 100% rename from samples/HelloElement/main.cpp rename to examples/HelloElement/main.cpp diff --git a/examples/HelloElement/project.json b/examples/HelloElement/project.json new file mode 100644 index 0000000..9750e20 --- /dev/null +++ b/examples/HelloElement/project.json @@ -0,0 +1,17 @@ +{ + "name": "main", + "configurations": [ + { + "name": "executable", + "implementations": ["main"], + "target": "wasm32-wasi", + "debug" : true, + "dependencies": [ + { + "path":"../../project.json", + "configuration":"lib-debug" + } + ] + } + ] +} \ No newline at end of file diff --git a/examples/HelloElement/run.sh b/examples/HelloElement/run.sh new file mode 100755 index 0000000..e706621 --- /dev/null +++ b/examples/HelloElement/run.sh @@ -0,0 +1 @@ +caddy file-server --listen :8080 --root bin/executable \ No newline at end of file diff --git a/samples/HelloWorld/HelloWorld.png b/examples/HelloWorld/HelloWorld.png similarity index 100% rename from samples/HelloWorld/HelloWorld.png rename to examples/HelloWorld/HelloWorld.png diff --git a/examples/HelloWorld/README.md b/examples/HelloWorld/README.md new file mode 100644 index 0000000..1d6bd26 --- /dev/null +++ b/examples/HelloWorld/README.md @@ -0,0 +1,12 @@ +![alt text](https://github.com/Catcrafts/Crafter.Web/blob/master/samples/HelloWorld/HelloWorld.png?raw=true) + +This sample demonstrates a simple hello world. + +```bash +crafter-build build executable +run.sh +``` + +and go to `http://localhost:8080/` + +if caddy is not installed you can use your favorite static file server instead \ No newline at end of file diff --git a/samples/HelloWorld/main.cpp b/examples/HelloWorld/main.cpp similarity index 100% rename from samples/HelloWorld/main.cpp rename to examples/HelloWorld/main.cpp diff --git a/examples/HelloWorld/project.json b/examples/HelloWorld/project.json new file mode 100644 index 0000000..660f28d --- /dev/null +++ b/examples/HelloWorld/project.json @@ -0,0 +1,17 @@ +{ + "name": "main", + "configurations": [ + { + "name": "example", + "implementations": ["main"], + "target": "wasm32-wasi", + "debug" : true, + "dependencies": [ + { + "path":"../../project.json", + "configuration":"lib-debug" + } + ] + } + ] +} \ No newline at end of file diff --git a/examples/HelloWorld/run.sh b/examples/HelloWorld/run.sh new file mode 100644 index 0000000..e706621 --- /dev/null +++ b/examples/HelloWorld/run.sh @@ -0,0 +1 @@ +caddy file-server --listen :8080 --root bin/executable \ No newline at end of file diff --git a/Crafter.CppDOM-Bindings.cppm b/interfaces/Crafter.CppDOM-Bindings.cppm similarity index 98% rename from Crafter.CppDOM-Bindings.cppm rename to interfaces/Crafter.CppDOM-Bindings.cppm index afa02a8..5ead784 100644 --- a/Crafter.CppDOM-Bindings.cppm +++ b/interfaces/Crafter.CppDOM-Bindings.cppm @@ -18,9 +18,8 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -module; -#include export module Crafter.CppDOM:Bindings; +import std; export namespace Crafter::CppDOM::Bindings { __attribute__((import_module("env"), import_name("freeJs"))) void FreeJs(void* ptr); diff --git a/Crafter.CppDOM-HtmlElement.cppm b/interfaces/Crafter.CppDOM-HtmlElement.cppm similarity index 98% rename from Crafter.CppDOM-HtmlElement.cppm rename to interfaces/Crafter.CppDOM-HtmlElement.cppm index 74b656b..32cee49 100644 --- a/Crafter.CppDOM-HtmlElement.cppm +++ b/interfaces/Crafter.CppDOM-HtmlElement.cppm @@ -18,9 +18,8 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -module; -#include export module Crafter.CppDOM:HtmlElement; +import std; import :Bindings; namespace Crafter::CppDOM { diff --git a/Crafter.CppDOM.cppm b/interfaces/Crafter.CppDOM.cppm similarity index 85% rename from Crafter.CppDOM.cppm rename to interfaces/Crafter.CppDOM.cppm index 20313a0..b1f2e0b 100644 --- a/Crafter.CppDOM.cppm +++ b/interfaces/Crafter.CppDOM.cppm @@ -20,14 +20,4 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA export module Crafter.CppDOM; export import :Bindings; -export import :HtmlElement; - -extern "C" { - void __cxa_allocate_exception() { - - } - - void __cxa_throw(int, int, int) { - - } -} +export import :HtmlElement; \ No newline at end of file diff --git a/project.json b/project.json index 9de4828..330c796 100644 --- a/project.json +++ b/project.json @@ -2,25 +2,16 @@ "name": "crafter-cppdom", "configurations": [ { - "name": "base", - "standard": "c++26", - "source_files": [], - "module_files": ["Crafter.CppDOM-HtmlElement", "Crafter.CppDOM", "Crafter.CppDOM-Bindings"], - "additional_files": ["Crafter.CppDOM.js"], - "build_dir": "./build", - "output_dir": "./bin", + "name": "lib", + "interfaces": ["interfaces/Crafter.CppDOM-HtmlElement", "interfaces/Crafter.CppDOM", "interfaces/Crafter.CppDOM-Bindings"], + "additional_files": ["additional/env.js"], "type":"library", - "target":"wasm32-unknown-wasi" + "target":"wasm32-wasi" }, { - "name": "debug", - "extends": ["base"], - "optimization_level": "0" - }, - { - "name": "release", - "extends": ["base"], - "optimization_level": "3" + "name": "lib-debug", + "extends": ["lib"], + "debug": true } ] } diff --git a/samples/HelloElement/README.md b/samples/HelloElement/README.md deleted file mode 100644 index 66f7395..0000000 --- a/samples/HelloElement/README.md +++ /dev/null @@ -1,5 +0,0 @@ -![alt text](https://github.com/Catcrafts/Crafter.Web/blob/master/samples/HelloWorld/HelloWorld.png?raw=true) - -This sample demonstrates the use of the ``HtmlElement`` class. - -Run ``crafter-webbuild serve -c debug`` and go to ``localhost:8080`` to view it. \ No newline at end of file diff --git a/samples/HelloElement/project.json b/samples/HelloElement/project.json deleted file mode 100644 index 34fe905..0000000 --- a/samples/HelloElement/project.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "hello-element", - "configurations": [ - { - "name": "debug", - "standard": "c++26", - "source_files": ["main"], - "module_files": [], - "additional_files": [], - "build_dir": "./build", - "output_dir": "./bin", - "optimization_level": "0", - "target": "wasm32-unknown-wasi", - "type": "executable", - "dependencies": [ - { - "path":"../../project.json", - "configuration":"debug" - } - ] - } - ] -} diff --git a/samples/HelloWorld/README.md b/samples/HelloWorld/README.md deleted file mode 100644 index 7dd4354..0000000 --- a/samples/HelloWorld/README.md +++ /dev/null @@ -1,5 +0,0 @@ -![alt text](https://github.com/Catcrafts/Crafter.Web/blob/master/samples/HelloWorld/HelloWorld.png?raw=true) - -This sample demonstrates a simple hello world. - -Run ``crafter-webbuild serve -c debug`` and go to ``localhost:8080`` to view it. \ No newline at end of file diff --git a/samples/HelloWorld/project.json b/samples/HelloWorld/project.json deleted file mode 100644 index de6c4fb..0000000 --- a/samples/HelloWorld/project.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "hello-world", - "configurations": [ - { - "name": "debug", - "standard": "c++26", - "source_files": ["main"], - "module_files": [], - "additional_files": [], - "build_dir": "./build", - "output_dir": "./bin", - "optimization_level": "0", - "target": "wasm32-unknown-wasi", - "type": "executable", - "dependencies": [ - { - "path":"../../project.json", - "configuration":"debug" - } - ] - } - ] -}