Access WASM DOM

Is there a way to read / write access to the DOM and / or WebAPI (i.e. full screen API) without JavaScript?

I am trying to create a basic application in C (the source code for C is actually the result of transpiling from the GC language). The application that I create will work as a desktop application (it is not intended to run in "real" browsers), so I can configure the environment (that is, the linking mechanism) if necessary.

+6
source share
2 answers

In the smallest viable WebAssembly product, the only way to invoke and exit WebAssembly is to import and export. In the future, WebAssembly may get features that allow you to embed APIs directly ; in browser embedding this may include the DOM.

Imports and exports are not very complex: from your C extern , they look like an extern call, similar to a DLL on a Windows platform. You will probably compile C code with Emscripten, see its documentation, β€œCall JavaScript Functions from C / C ++” , to find out how it works (since this is not the question you ask, but I assume this is the following question).


This is not clear from your question if you:

  • Want to compile C code and run it in WebAssembly inside a browser.
  • Want to compile C code and run it in WebAssembly outside the browser.

Or both.

+6
source

WebAssembly users do not yet have any strong idea of ​​what JS objects in WebAssembly will look like.

I would look at PR # 1080 , which concerns the specification of the Garbage collection being highlighted in my own repo. But while this is happening, they only remove references to the web platform and interact with the JS objects that exist in the specification, which is described as:

 It more aspirational that concrete, 
+1
source

Source: https://habr.com/ru/post/1015528/


All Articles