Is there any support or tutorial to build as a web component ?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- rust, wasm
- Domain
- documentation, web-dev
Research direction
Start by reading the linked trunk-rs/trunk issue 1034 and the provided cargo build and wasm-bindgen commands to understand the current web-component approach. No repository file or test is named; done would require a clearly scoped support article or tutorial covering the requested build flow.
Written by the indexing model from the issue text.
Description
Linked to https://github.com/trunk-rs/trunk/issues/1034
#!/bin/bash
cargo build --target wasm32-unknown-unknown
# cargo install -f wasm-bindgen-cli --version 0.2.106
OUTPUT=web_component
ELEMENT=eframe-example
rm -rf "$OUTPUT"
wasm-bindgen --target=web "--out-dir=target/wasm-bindgen/debug" "--out-name=eframe_template" "target/wasm32-unknown-unknown/debug/eframe_template.wasm" "--no-typescript"
mkdir -p "$OUTPUT"
cp target/wasm-bindgen/debug/eframe_template_bg.wasm "$OUTPUT"
cp target/wasm-bindgen/debug/eframe_template.js "$OUTPUT"
cat "$OUTPUT/eframe_template.js" > "$OUTPUT/temp.js"
echo "customElements.define('$ELEMENT',class extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: 'open' });
const canvas = document.createElement('canvas');
canvas.id = 'the_canvas_id';
shadowRoot.appendChild(canvas);
}
connectedCallback() {
this.init();
}
async init() {
const wasm = await __wbg_init({ module_or_path: './eframe_template_bg.wasm' });
// window.wasmBindings = bindings;
dispatchEvent(new CustomEvent('TrunkApplicationStarted', {detail: {wasm}}));
}
},
);" >> "$OUTPUT/temp.js"
mv "$OUTPUT/temp.js" "$OUTPUT/eframe_template.js"
echo "
<script type='module' src='eframe_template.js'></script>
<eframe-example></eframe-example>
" > "$OUTPUT/index.html"
code to get the canvas inside the shadowRoot
let canvas = document
.body()
.expect("Failed to find <body>")
.child_nodes()
.get(0)
.expect("Failed to find the CustomElement")
.dyn_into::<web_sys::Element>()
.expect("convert failed")
.shadow_root()
.expect("Failed to find shadowRoot")
.dyn_into::<web_sys::ShadowRoot>()
.expect("failed convert ShadowRoot")
.get_element_by_id("the_canvas_id")
.expect("Failed to find the_canvas_id")
.dyn_into::<web_sys::HtmlCanvasElement>()
.expect("the_canvas_id was not a HtmlCanvasElement");
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 235
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from emilk/eframe_template
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
emilk/eframe_template#218 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 64/100
emilk/eframe_template#84 · 6 comments ·
-
Doesn't runOpen
Difficulty 3/5 1-2 days Newbie friendliness 38/100
emilk/eframe_template#229 ·
-
Name empty?Open
Difficulty 1/5 Under an hour Newbie friendliness 55/100
emilk/eframe_template#228 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
emilk/eframe_template#217 ·
All issues in emilk/eframe_template
Similar issues
-
claim
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Nixitov/Riptide-Native#946 ·
Maintainers usually reply within 1 day
-
area: ai-assistants documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
BetaBots-LLC/latticegate#17 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
storytold/craft-libs#5594 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
听歌识曲历史跳转后对应音源界面无法返回Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
LingyunStudio/RustMusic#16 ·