Skip to content

Commit 4d7342b

Browse files
committed
Add Deno nif
1 parent 91dc6ea commit 4d7342b

File tree

10 files changed

+1780
-0
lines changed

10 files changed

+1780
-0
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ indent_style = space
44
indent_size = 2
55
end_of_line = lf
66
insert_final_newline = true
7+
8+
[*.rust]
9+
indent_size = 4
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
defmodule ComponentsGuide.Rustler.Molten do
2+
defmodule Native do
3+
use Rustler, otp_app: :components_guide, crate: "molten"
4+
5+
def add(_, _), do: error()
6+
def js(_), do: error()
7+
def typescript_module(_, _, _), do: error()
8+
def parse_js(_), do: error()
9+
10+
defp error, do: :erlang.nif_error(:nif_not_loaded)
11+
end
12+
13+
def add(a, b), do: Native.add(a, b)
14+
def js(source), do: Native.js(source)
15+
def typescript_module(source) do
16+
ref = make_ref()
17+
Native.typescript_module(source, self(), ref)
18+
end
19+
20+
def parse_js(source) do
21+
case Native.parse_js(source) do
22+
{:ok, json} -> {:ok, Jason.decode!(json)}
23+
other -> other
24+
end
25+
end
26+
end

lib/components_guide_web/templates/cheatsheets/astro.html.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,18 @@ description: The overhead of the network vs the overhead of WebAssembly
1515
layout: ../../layouts/MainLayout.astro
1616
---
1717
```
18+
19+
<script type="module">
20+
import * as shiki from "https://jspm.dev/shiki";
21+
22+
shiki
23+
.getHighlighter({
24+
theme: 'nord'
25+
})
26+
.then(highlighter => {
27+
for (const astroCodeEl of document.body.querySelectorAll('code.language-astro')) {
28+
const html = highlighter.codeToHtml(astroCodeEl.textContent, { lang: 'astro' });
29+
astroCodeEl.innerHTML = html;
30+
}
31+
});
32+
</script>

native/molten/.cargo/config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[target.'cfg(target_os = "macos")']
2+
rustflags = [
3+
"-C", "link-arg=-undefined",
4+
"-C", "link-arg=dynamic_lookup",
5+
]

native/molten/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

0 commit comments

Comments
 (0)