Skip to content

Commit

Permalink
Update asdom to AssemblyScript (and loader) v0.27.5
Browse files Browse the repository at this point in the history
In the process, the finalizer for the Object class (now JSObject) has
been changed to work properly for this version. Also, some definite
assignments have been added for the example to properly compile. Lastly,
the asconfig.json has been updated to use the "outFile" field, instead
of "binaryFile".
  • Loading branch information
CountBleck committed Jun 10, 2023
1 parent 370337b commit 6e5dcb7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
10 changes: 10 additions & 0 deletions assembly/JSObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {toString} from './imports'

/**
* The base class that all objects extend from.
*/
export class JSObject {
toString(): string {
return toString(this)
}
}
4 changes: 2 additions & 2 deletions example/asconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"targets": {
"debug": {
"binaryFile": "build/untouched.wasm",
"outFile": "build/untouched.wasm",
"textFile": "build/untouched.wat",
"sourceMap": true,
"debug": true
},
"release": {
"binaryFile": "build/optimized.wasm",
"outFile": "build/optimized.wasm",
"textFile": "build/optimized.wat",
"sourceMap": true,
"optimizeLevel": 3,
Expand Down
10 changes: 5 additions & 5 deletions example/assembly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ if (document.firstElementChild!.tagName != 'HTML') throw new Error('document.fir
if (document.lastElementChild!.tagName != 'HTML') throw new Error('document.lastElementChild should be <html>')

let imgRotation: f32 = 0
let img: HTMLImageElement
let logoRotationLoop: () => void
let img!: HTMLImageElement
let logoRotationLoop!: () => void

let firstClick: boolean = true

// This is quick and dirty. It is quickly wanting to become a class (ideally a
// re-usable <dot-burst> custom element once asdom supports custom elements).
let explosionLoop: () => void
let explosionLoop!: () => void
const dotsLength: i32 = 10
const dots: StaticArray<HTMLDivElement> = new StaticArray(dotsLength)
const dotPositions: StaticArray<f32> = new StaticArray(dotsLength)
Expand All @@ -76,9 +76,9 @@ const dotPositionDeltas: StaticArray<f32> = new StaticArray(dotsLength)
let dotScale: f32 = 1.0
let explosionLoopFrame: i32 = -1

let text2: Text
let text2!: Text

let container: HTMLElement
let container!: HTMLElement

const style = document.createElement('style')

Expand Down
8 changes: 4 additions & 4 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"dev": "npm run build:untouched && npm run serve",
"build": "npm run build:untouched && npm run build:optimized",
"serve": "serve ./",
"build:untouched": "asc assembly/index.ts --target debug --exportRuntime --exportTable --explicitStart",
"build:optimized": "asc assembly/index.ts --target release --exportRuntime --exportTable --explicitStart",
"build:untouched": "asc assembly/index.ts --target debug --exportRuntime --exportTable --exportStart _start",
"build:optimized": "asc assembly/index.ts --target release --exportRuntime --exportTable --exportStart _start",
"test": "node tests"
},
"dependencies": {
"@assemblyscript/loader": "^0.19.5",
"@assemblyscript/loader": "^0.27.5",
"asdom": "lume/asdom",
"ecmassembly": "^0.1.8"
},
"devDependencies": {
"assemblyscript": "^0.19.5",
"assemblyscript": "^0.27.5",
"serve": "^12.0.0"
}
}

0 comments on commit 6e5dcb7

Please sign in to comment.