Skip to content

Commit

Permalink
add build (code) artifacts to main
Browse files Browse the repository at this point in the history
  • Loading branch information
twiddlingbits committed Sep 29, 2024
1 parent eae9db1 commit a5a1942
Show file tree
Hide file tree
Showing 16 changed files with 325 additions and 67 deletions.
4 changes: 2 additions & 2 deletions azure/docsite/api/api-ts-library/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,7 @@ <h1 id="twr-wasm-libraries">twr-wasm Libraries</h1>
<p>There are two kinds of Libraries:</p>
<ul>
<li>Those that have only once instance (such as the math library)</li>
<li>Those that can have multiple instances across one more more library types, where each library type implements the same interface. Consoles are an example of this (see <a href="#interfacename">interfaceName</a>).</li>
<li>Those that can have multiple instances across one or more library types, where each library type implements the same interface. Consoles are an example of this (see <a href="#interfacename">interfaceName</a>).</li>
</ul>
<h2 id="basic-steps">Basic Steps</h2>
<p>twr-wasm Libraries support both <code>twrWasmModule</code> and <code>twrWasmModuleAsync</code>. That is, when you create a twrLibrary, it will function with either type of module. In many cases no extra work is needed for the <code>twrWasmModuleAsync</code>, but in some cases, extra code is needed.</p>
Expand Down Expand Up @@ -2153,7 +2153,7 @@ <h2 id="interfacename">interfaceName</h2>
<ul>
<li>An "interface" refers to the set of functions that the library exposes to C. Ie, the functions in the <code>import</code> object.</li>
<li>The name of the interface is anonymous, unless <code>interfaceName</code> is set. </li>
<li>An undefined interfaceName (anonymous interface) means that only one instance of that class is allowed (for example <code>twrLibMath</code>)</li>
<li>An undefined interfaceName (anonymous interface) also means that only one instance of that class is allowed (for example <code>twrLibMath</code>)</li>
<li>Set <code>interfaceName</code> to a unique name when multiple instances that support the same interface are allowed (for example the twr-wasm Consoles). </li>
<li>Multiple classes may have the same interfaceName (a class is identified by its libSourcePath). For example <code>twrConDiv</code>, <code>twrConDebug</code>, <code>twrConTerminal</code> all have the same interface.</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion azure/docsite/api/api-ts-modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,7 @@ <h2 id="about-twrwasmmodule">About <code>twrWasmModule</code></h2>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="kd">const</span><span class="w"> </span><span class="nx">mod</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">twrWasmModule</span><span class="p">();</span>
</span></code></pre></div></p>
<h2 id="about-twrwasmmoduleasync">About <code>twrWasmModuleAsync</code></h2>
<p><code>class twrWasmModuleAsync</code> allows you to integrate WebAssembly C/C++ code into your Web Page that uses a CLI pattern or code that blocks. For example, with <code>twrWasmModuleAsync</code> your C/C++ code can call a synchronous function for keyboard input (that blocks until the user has entered the keyboard input). Or your C/C++ code can <code>sleep</code> or otherwise block. This is the pattern that is used by many standard C library functions - <code>fread</code>, etc. </p>
<p><code>class twrWasmModuleAsync</code> allows you to integrate WebAssembly C/C++ code into your Web Page that uses a Read-Eval-Print Loop (REPL) pattern, a CLI pattern or code that blocks. For example, with <code>twrWasmModuleAsync</code> your C/C++ code can call a synchronous function for keyboard input (that blocks until the user has entered the keyboard input). Or your C/C++ code can <code>sleep</code> or otherwise block. This is the pattern that is used by many standard C library functions - <code>fread</code>, etc. </p>
<p><code>class twrWasmModuleAsync</code> creates a WorkerThread that runs in parallel to the JavaScript main thread. This Worker thread executes your C/C++ code, and proxies functionality that needs to execute in the JavaScript main thread via remote procedure calls. This allows the JavaScript main thread to <code>await</code> on a blocking <code>callC</code> in your JavaScript main thread. </p>
<p>The <code>Async</code> part of the <code>twrWasmModuleAsync</code> name refers to the property of <code>twrWasmModuleAsync</code> that makes your synchronous C/C++ code asynchronous.</p>
<p>The APIs in <code>class twrWasmModuleAsync</code> are identical to <code>class twrWasmModule</code>, except that certain functions use the <code>async</code> keyword and thus need to be called with <code>await</code>. This happens whenever the function needs to cross the JavaScript main thread and the Worker thread boundary. For example: <code>callC</code> or <code>malloc</code>.</p>
Expand Down
50 changes: 47 additions & 3 deletions azure/docsite/examples/examples-divcon/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">

<meta name="description" content="This C WebAssembly example shows how to printf and get characters to and from an HTML div tag using twr-wasm">
<meta name="description" content="This C WebAssembly example shows how to implement a Read-Eval-Print Loop (REPL) in twr-wasm">



Expand Down Expand Up @@ -723,6 +723,24 @@
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>

<li class="md-nav__item">
<a href="#what-it-does" class="md-nav__link">
<span class="md-ellipsis">
What It Does
</span>
</a>

</li>

<li class="md-nav__item">
<a href="#running-examples-and-source" class="md-nav__link">
<span class="md-ellipsis">
Running Examples and Source:
</span>
</a>

</li>

<li class="md-nav__item">
<a href="#screen-grab-of-square-calculator" class="md-nav__link">
<span class="md-ellipsis">
Expand Down Expand Up @@ -1431,6 +1449,24 @@
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>

<li class="md-nav__item">
<a href="#what-it-does" class="md-nav__link">
<span class="md-ellipsis">
What It Does
</span>
</a>

</li>

<li class="md-nav__item">
<a href="#running-examples-and-source" class="md-nav__link">
<span class="md-ellipsis">
Running Examples and Source:
</span>
</a>

</li>

<li class="md-nav__item">
<a href="#screen-grab-of-square-calculator" class="md-nav__link">
<span class="md-ellipsis">
Expand Down Expand Up @@ -1476,8 +1512,16 @@



<h1 id="divcon-printf-and-input-using-a-div-tag">divcon - Printf and Input Using a div Tag</h1>
<p>This simple WebAssembly C program demos inputting and printing characters with a <code>div</code> tag.</p>
<h1 id="divcon-printf-and-input-using-a-div-tag">divcon - Printf and Input Using a <code>div</code> Tag</h1>
<h2 id="what-it-does">What It Does</h2>
<p>This example inputs a number, squares it, and prints the result using standard C library functions.</p>
<p>The divcon example demos:</p>
<ul>
<li>A Read-Eval-Print Loop (REPL) </li>
<li>using twr-wasm <code>class twrWasmModuleAsync</code> to <code>await</code> on blocking C code</li>
<li>getting and print characters to a <code>div</code> tag using twr-wasm <code>class twrConsoleDiv</code></li>
</ul>
<h2 id="running-examples-and-source">Running Examples and Source:</h2>
<ul>
<li><a href="/examples/dist/divcon/index.html">view divcon example running live</a></li>
<li><a href="https://github.com/twiddlingbits/twr-wasm/tree/main/examples/divcon">View divcon source code</a></li>
Expand Down
2 changes: 1 addition & 1 deletion azure/docsite/examples/examples-multi-io/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@



<h1 id="multi-io-multiple-console-example">Multi-io -Multiple Console Example</h1>
<h1 id="multi-io-multiple-console-example">Multi-io Multiple Console Example</h1>
<h2 id="what-it-does">What It Does</h2>
<p>This example demos six simultaneous consoles:</p>
<ul>
Expand Down
22 changes: 11 additions & 11 deletions azure/docsite/examples/examples-overview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,9 @@
</li>

<li class="md-nav__item">
<a href="#draw-2d-examples" class="md-nav__link">
<a href="#draw-2d-and-audio-examples" class="md-nav__link">
<span class="md-ellipsis">
Draw 2D Examples
Draw 2D and Audio Examples
</span>
</a>

Expand All @@ -738,11 +738,11 @@
<li class="md-nav__item">
<a href="#twrlibrary-examples" class="md-nav__link">
<span class="md-ellipsis">
twrLibrary examples
twrLibrary Examples
</span>
</a>

<nav class="md-nav" aria-label="twrLibrary examples">
<nav class="md-nav" aria-label="twrLibrary Examples">
<ul class="md-nav__list">

<li class="md-nav__item">
Expand Down Expand Up @@ -1537,9 +1537,9 @@
</li>

<li class="md-nav__item">
<a href="#draw-2d-examples" class="md-nav__link">
<a href="#draw-2d-and-audio-examples" class="md-nav__link">
<span class="md-ellipsis">
Draw 2D Examples
Draw 2D and Audio Examples
</span>
</a>

Expand All @@ -1557,11 +1557,11 @@
<li class="md-nav__item">
<a href="#twrlibrary-examples" class="md-nav__link">
<span class="md-ellipsis">
twrLibrary examples
twrLibrary Examples
</span>
</a>

<nav class="md-nav" aria-label="twrLibrary examples">
<nav class="md-nav" aria-label="twrLibrary Examples">
<ul class="md-nav__list">

<li class="md-nav__item">
Expand Down Expand Up @@ -1668,7 +1668,7 @@ <h2 id="console-examples">Console Examples</h2>
</tr>
</tbody>
</table>
<h2 id="draw-2d-examples">Draw 2D Examples</h2>
<h2 id="draw-2d-and-audio-examples">Draw 2D and Audio Examples</h2>
<table>
<thead>
<tr>
Expand All @@ -1685,7 +1685,7 @@ <h2 id="draw-2d-examples">Draw 2D Examples</h2>
</tr>
<tr>
<td>pong</td>
<td>A simple game of Pong written in C++ to demo 2D drawing APIs with a<br>C++ canvas wrapper class and taking user input from JS</td>
<td>A simple game of Pong written in C++ to demo 2D drawing and Audio APIs with<br>a C++ canvas wrapper class and taking user input from JS</td>
<td><a href="../examples-pong/">pong</a></td>
</tr>
<tr>
Expand Down Expand Up @@ -1717,7 +1717,7 @@ <h2 id="call-argument-examples">Call Argument Examples</h2>
</tr>
</tbody>
</table>
<h2 id="twrlibrary-examples">twrLibrary examples</h2>
<h2 id="twrlibrary-examples">twrLibrary Examples</h2>
<table>
<thead>
<tr>
Expand Down
7 changes: 5 additions & 2 deletions azure/docsite/gettingstarted/installation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1543,8 +1543,11 @@ <h2 id="npm-install">npm install</h2>
<h2 id="git-install">git install</h2>
<div class="language-sh highlight"><pre><span></span><code><span id="__span-3-1"><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a><span class="w"> </span>git<span class="w"> </span>clone<span class="w"> </span>https://github.com/twiddlingbits/twr-wasm
</span></code></pre></div>
<p>This method of installation installs the complete code base, including source and built binaries. </p>
<p>The primary downside to this method is that the JavaScript side of twr-wasm will not be placed in a node_modules folder. This will create a little extra work to configure a bundler, TypeScript or VS Code to find the location of imports.</p>
<p>This method of installation installs the complete code base, including source and built binaries.</p>
<p>After twr-wasm is cloned, use VS Code <code>File | Open Folder</code>.</p>
<p><a href="https://github.com/twiddlingbits/twr-wasm/blob/main/examples/readme.md">See here</a> for information on running the examples or building the examples.</p>
<p><a href="../../more/building/">See here</a> for information on building the source.</p>
<p>The primary downside to this method is that the JavaScript side of twr-wasm will not be placed in a node_modules folder. This will create a little extra work to configure a bundler, TypeScript or VS Code to find the location of the twr-wasm module imports.</p>
<p>There are a few solutions to this. For example, in the provided Hello World example, a <code>package.json</code> file with an <code>alias</code> entry is used. This syntax is supported by the Parcel bundler:</p>
<div class="language-json highlight"><pre><span></span><code><span id="__span-4-1"><a id="__codelineno-4-1" name="__codelineno-4-1" href="#__codelineno-4-1"></a><span class="p">{</span>
</span><span id="__span-4-2"><a id="__codelineno-4-2" name="__codelineno-4-2" href="#__codelineno-4-2"></a><span class="w"> </span><span class="nt">&quot;@parcel/resolver-default&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
Expand Down
4 changes: 3 additions & 1 deletion azure/docsite/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,8 @@ <h1 id="easier-webassembly-with-twr-wasmdocumentation-and-examples">Easier WebAs
<li>
<p>the optional TypeScript <code>class twrWasmModuleAsync</code> can be used to:</p>
<ul>
<li>integrate CLI C/C++ code with JavaScript</li>
<li>integrate a C/C++ Read-Eval-Print Loop (REPL) with JavaScript</li>
<li>integrate a C/C++ CLI or Shell with JavaScript</li>
<li>In JavaScript <code>await</code> on blocking/synchronous C/C++ functions. </li>
</ul>
</li>
Expand All @@ -1553,6 +1554,7 @@ <h1 id="easier-webassembly-with-twr-wasmdocumentation-and-examples">Easier WebAs
<li>standard C library optimized for WebAssembly</li>
<li>libc++ built for WebAssembly</li>
<li>comprehensive examples and documentation</li>
<li>TypeScript and JavaScript support</li>
</ul>
<h2 id="live-webassembly-examples-and-source">Live WebAssembly Examples and Source</h2>
<table>
Expand Down
2 changes: 1 addition & 1 deletion azure/docsite/more/building/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ <h2 id="to-build-the-libraries-lib-c-lib-js">To Build the Libraries (lib-c, lib-
</span><span id="__span-2-2"><a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a>mingw32-make
</span></code></pre></div></p>
<h2 id="to-build-the-examples">To Build the Examples</h2>
<p>See examples/readme.md for more information.</p>
<p>See <a href="https://github.com/twiddlingbits/twr-wasm/blob/main/examples/readme.md">examples/readme.md</a> for more information.</p>
<p>To build the examples, but not bundle them.
<div class="language-sh highlight"><pre><span></span><code><span id="__span-3-1"><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a><span class="nb">cd</span><span class="w"> </span>examples
</span><span id="__span-3-2"><a id="__codelineno-3-2" name="__codelineno-3-2" href="#__codelineno-3-2"></a>sh<span class="w"> </span>buildall.sh
Expand Down
2 changes: 1 addition & 1 deletion azure/docsite/search/search_index.json

Large diffs are not rendered by default.

Loading

0 comments on commit a5a1942

Please sign in to comment.