-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9f1799
commit a830a2e
Showing
10 changed files
with
791 additions
and
2,600 deletions.
There are no files selected for viewing
989 changes: 615 additions & 374 deletions
989
docs/examples/prime-ministers/assets/dioxus/dioxus-sortable.js
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+104 KB
(100%)
docs/examples/prime-ministers/assets/dioxus/dioxus-sortable_bg.wasm
Binary file not shown.
1,090 changes: 0 additions & 1,090 deletions
1,090
docs/examples/prime-ministers/assets/dioxus/dioxus.js
This file was deleted.
Oops, something went wrong.
Binary file not shown.
1,090 changes: 0 additions & 1,090 deletions
1,090
docs/examples/prime-ministers/assets/dioxus/prime-ministers.js
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-2.16 MB
docs/examples/prime-ministers/assets/dioxus/prime-ministers_bg.wasm
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...ime-ministers/assets/dioxus/snippets/dioxus-interpreter-js-603636eeca72cf05/src/common.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const bool_attrs = { | ||
allowfullscreen: true, | ||
allowpaymentrequest: true, | ||
async: true, | ||
autofocus: true, | ||
autoplay: true, | ||
checked: true, | ||
controls: true, | ||
default: true, | ||
defer: true, | ||
disabled: true, | ||
formnovalidate: true, | ||
hidden: true, | ||
ismap: true, | ||
itemscope: true, | ||
loop: true, | ||
multiple: true, | ||
muted: true, | ||
nomodule: true, | ||
novalidate: true, | ||
open: true, | ||
playsinline: true, | ||
readonly: true, | ||
required: true, | ||
reversed: true, | ||
selected: true, | ||
truespeed: true, | ||
webkitdirectory: true, | ||
}; | ||
|
||
export function setAttributeInner(node, field, value, ns) { | ||
const name = field; | ||
if (ns === "style") { | ||
// ????? why do we need to do this | ||
if (node.style === undefined) { | ||
node.style = {}; | ||
} | ||
node.style[name] = value; | ||
} else if (ns != null && ns != undefined) { | ||
node.setAttributeNS(ns, name, value); | ||
} else { | ||
switch (name) { | ||
case "value": | ||
if (value !== node.value) { | ||
node.value = value; | ||
} | ||
break; | ||
case "initial_value": | ||
node.defaultValue = value; | ||
break; | ||
case "checked": | ||
node.checked = truthy(value); | ||
break; | ||
case "selected": | ||
node.selected = truthy(value); | ||
break; | ||
case "dangerous_inner_html": | ||
node.innerHTML = value; | ||
break; | ||
default: | ||
// https://github.com/facebook/react/blob/8b88ac2592c5f555f315f9440cbb665dd1e7457a/packages/react-dom/src/shared/DOMProperty.js#L352-L364 | ||
if (!truthy(value) && bool_attrs.hasOwnProperty(name)) { | ||
node.removeAttribute(name); | ||
} else { | ||
node.setAttribute(name, value); | ||
} | ||
} | ||
} | ||
} | ||
|
||
function truthy(val) { | ||
return val === "true" || val === true; | ||
} |
File renamed without changes.
41 changes: 41 additions & 0 deletions
41
docs/examples/prime-ministers/assets/dioxus/snippets/dioxus-web-54817add8ba334eb/src/eval.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export class Dioxus { | ||
constructor(sendCallback, returnCallback) { | ||
this.sendCallback = sendCallback; | ||
this.returnCallback = returnCallback; | ||
this.promiseResolve = null; | ||
this.received = []; | ||
} | ||
|
||
// Receive message from Rust | ||
recv() { | ||
return new Promise((resolve, _reject) => { | ||
// If data already exists, resolve immediately | ||
let data = this.received.shift(); | ||
if (data) { | ||
resolve(data); | ||
return; | ||
} | ||
|
||
// Otherwise set a resolve callback | ||
this.promiseResolve = resolve; | ||
}); | ||
} | ||
|
||
// Send message to rust. | ||
send(data) { | ||
this.sendCallback(data); | ||
} | ||
|
||
// Internal rust send | ||
rustSend(data) { | ||
// If a promise is waiting for data, resolve it, and clear the resolve callback | ||
if (this.promiseResolve) { | ||
this.promiseResolve(data); | ||
this.promiseResolve = null; | ||
return; | ||
} | ||
|
||
// Otherwise add the data to a queue | ||
this.received.push(data); | ||
} | ||
} |