This file contains hidden or 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
| import React, { useEffect, useRef } from 'react'; | |
| import { fabric } from 'fabric'; | |
| import { useCanvas } from './useCanvas'; | |
| const PVEditor = () => { | |
| const canvasRef = useRef(null); | |
| const { state, addObject, updateObject, deleteObject, selectObject, syncActiveObject } = useCanvas(); | |
| useEffect(() => { | |
| const canvas = new fabric.Canvas('canvas', { width: 800, height: 600 }); |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!-- OPML generated by NetNewsWire --> | |
| <opml version="1.1"> | |
| <head> | |
| <title>sjdonado_feeds.opml</title> | |
| </head> | |
| <body> | |
| <outline text="Allen Pike" title="Allen Pike" description="" type="rss" version="RSS" htmlUrl="" xmlUrl="https://feeds.allenpike.com/feed/"/> | |
| <outline text="furbo.org" title="furbo.org" description="" type="rss" version="RSS" htmlUrl="https://furbo.org/" xmlUrl="https://furbo.org/feed/json"/> | |
| <outline text="jakelazaroff.com" title="jakelazaroff.com" description="" type="rss" version="RSS" htmlUrl="https://jakelazaroff.com/" xmlUrl="https://jakelazaroff.com/rss.xml"/> |
This file contains hidden or 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
| const getHanoiMoves = async (n) => new Promise((resolve) => { | |
| wasmWorker.onmessage = (event) => resolve(event.data); | |
| wasmWorker.postMessage({ n }); | |
| }); |
This file contains hidden or 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
| const wasmWorker = new Worker(new URL('../workers/hanoi.js', import.meta.url), { | |
| type: 'module', | |
| }); |
This file contains hidden or 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
| import { get_moves } from '@wasm/games'; | |
| onmessage = (event) => { | |
| const moves = get_moves(event.data.n); | |
| postMessage(moves); | |
| }; |
This file contains hidden or 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
| use gloo_utils::format::JsValueSerdeExt; | |
| use wasm_bindgen::prelude::*; | |
| #[wasm_bindgen] | |
| pub fn get_moves(n: i32) -> JsValue { | |
| fn move_tower(n: i32, from: i32, to: i32, aux: i32, moves: &mut Vec<String>) { | |
| if n == 1 { | |
| moves.push(format!("{}:{}", from, to)); | |
| } else { | |
| move_tower(n - 1, from, aux, to, moves); |
This file contains hidden or 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
| import { get_moves } from '@wasm/games'; |
This file contains hidden or 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
| import { defineConfig } from 'vite'; | |
| import solidPlugin from 'vite-plugin-solid'; | |
| + import wasm from 'vite-plugin-wasm'; | |
| + import topLevelAwait from 'vite-plugin-top-level-await'; | |
| import path from 'path'; | |
| export default defineConfig({ | |
| plugins: [ |
This file contains hidden or 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
| ... | |
| [lib] | |
| path = "logic/lib.rs" | |
| crate-type = ["cdylib"] | |
| [dependencies] | |
| wasm-bindgen = "0.2" | |
| getrandom = { version = "0.2.8", features = ["js"] } | |
| gloo-utils = { version = "0.1", features = ["serde"] } |
NewerOlder