Skip to content

Commit ad34a0a

Browse files
committed
Completed typescript conversion and started basic intro
1 parent c9709bb commit ad34a0a

File tree

11 files changed

+2661
-89
lines changed

11 files changed

+2661
-89
lines changed

dist/bundle.js

Lines changed: 2577 additions & 30 deletions
Large diffs are not rendered by default.

dist/entry.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3838
return (mod && mod.__esModule) ? mod : { "default": mod };
3939
};
4040
Object.defineProperty(exports, "__esModule", { value: true });
41+
var intro_js_1 = __importDefault(require("intro.js"));
4142
var nimble_1 = require("nimble");
4243
window.h = nimble_1.h;
4344
var defaultGraph_1 = __importDefault(require("./defaultGraph"));
@@ -50,6 +51,7 @@ function makeArrow(state, affect, index, direction) {
5051
height: 135,
5152
viewBox: "0 0 38 135",
5253
fill: 'none',
54+
'data-intro': 'Hello step one!',
5355
style: {
5456
width: '100%',
5557
height: '30px',
@@ -123,6 +125,7 @@ function renderNode(state, affect, node, index) {
123125
return nimble_1.h('div.node-cont', [
124126
nimble_1.h('div.node-centraliser', [
125127
nimble_1.h("div.node." + node.kind, {
128+
'data-intro': 'Hello step two!',
126129
onclick: function (ev) {
127130
var isValidEv = ev.target.classList.contains('node') || ev.target.parentElement.classList.contains('node');
128131
if (isValidEv) {
@@ -256,3 +259,8 @@ function initGraph(audioCtx, graph) {
256259
});
257260
return graph;
258261
}
262+
if (!localStorage.getItem('completedIntro')) {
263+
intro_js_1.default()
264+
.onexit(function () { return localStorage.setItem('completedIntro', 'true'); })
265+
.start();
266+
}

dist/nodes/modifiers/customWorklet.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,22 @@ function makeProcessorsFile(id, parsedBinary) {
106106
}
107107
function makeWorkletPromise(audioCtx, ts) {
108108
var id = '' + Date.now(); //TODO: better ID
109-
return $.ajax("/makeWorkletBinary/" + id, {
110-
data: JSON.stringify({
111-
ts: ts
112-
}),
113-
contentType: 'application/JSON',
114-
type: 'POST'
115-
}).then(function (binary) {
116-
var parsedBin = intArrayFromBase64(binary);
117-
var fileContent = makeProcessorsFile(id, parsedBin);
118-
latestParsedBin = parsedBin; //More bad things
119-
return audioCtx.audioWorklet.addModule("data:application/javascript;base64," + btoa(fileContent)).then(function () {
120-
return new AudioWorkletNode(audioCtx, id);
121-
});
109+
return new Promise(function (resolve, reject) {
110+
$.ajax("/makeWorkletBinary/" + id, {
111+
data: JSON.stringify({
112+
ts: ts
113+
}),
114+
contentType: 'application/JSON',
115+
type: 'POST'
116+
}).then(function (binary) {
117+
var parsedBin = intArrayFromBase64(binary);
118+
var fileContent = makeProcessorsFile(id, parsedBin);
119+
latestParsedBin = parsedBin; //More bad things
120+
return audioCtx.audioWorklet.addModule("data:application/javascript;base64," + btoa(fileContent)).then(function () {
121+
return new AudioWorkletNode(audioCtx, id);
122+
});
123+
})
124+
.then(resolve)
125+
.catch(reject);
122126
});
123127
}

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<script src="https://tonejs.github.io/build/Tone.js"></script>
99
<link rel="stylesheet" href="dist/style.css">
1010
<link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Mono" rel="stylesheet">
11+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/introjs.css">
1112
</head>
1213

1314
<body>

package-lock.json

Lines changed: 21 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"@types/es6-shim": "^0.31.37",
1312
"@types/jquery": "^3.3.6",
1413
"@types/node": "^10.9.4",
15-
"@types/webaudioapi": "0.0.27",
1614
"assemblyscript": "github:AssemblyScript/assemblyscript",
1715
"body-parser": "1.18.3",
1816
"express": "4.16.3",
17+
"intro.js": "^2.9.3",
1918
"nimble": "git+https://github.com/ISNIT0/nimble-js.git",
2019
"tone": "^0.12.80",
2120
"webmidi": "^2.2.0"

src/entry.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import introJs from 'intro.js';
12
import {
23
makeRenderLoop,
34
h
@@ -15,6 +16,7 @@ function makeArrow(state: State, affect: Affect, index: number, direction = 'dow
1516
height: 135,
1617
viewBox: "0 0 38 135",
1718
fill: 'none',
19+
'data-intro': 'Hello step one!',
1820
style: {
1921
width: '100%',
2022
height: '30px',
@@ -91,6 +93,7 @@ function renderNode(state: State, affect: Affect, node: NodeDef, index: number)
9193
return h('div.node-cont', [
9294
h('div.node-centraliser', [
9395
h(`div.node.${node.kind}`, {
96+
'data-intro': 'Hello step two!',
9497
onclick(ev: any) {
9598
const isValidEv = ev.target.classList.contains('node') || ev.target.parentElement.classList.contains('node');
9699
if (isValidEv) {
@@ -141,7 +144,7 @@ function renderNode(state: State, affect: Affect, node: NodeDef, index: number)
141144
]);
142145
}
143146

144-
var audioCtx = new (window.AudioContext || (<any>window).webkitAudioContext)();
147+
var audioCtx:AudioContext = new ((<any>window).AudioContext || (<any>window).webkitAudioContext)();
145148

146149
const initState: State = {
147150
graph: initGraph(audioCtx, defaultGraph),
@@ -221,4 +224,10 @@ function initGraph(audioCtx: AudioContext, graph: NodeGraph) {
221224
});
222225

223226
return graph;
227+
}
228+
229+
if (!localStorage.getItem('completedIntro')) {
230+
introJs()
231+
.onexit(() => localStorage.setItem('completedIntro', 'true'))
232+
.start();
224233
}

src/nodes/modifiers/customWorklet.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,25 @@ registerProcessor('${id}', MyWorkletProcessor);
169169

170170

171171

172-
function makeWorkletPromise(audioCtx: BaseAudioContext, ts: string) {
172+
function makeWorkletPromise(audioCtx: BaseAudioContext, ts: string): Promise<AudioWorkletNode> {
173173
const id = '' + Date.now(); //TODO: better ID
174-
return $.ajax(`/makeWorkletBinary/${id}`, {
175-
data: JSON.stringify({
176-
ts
177-
}),
178-
contentType: 'application/JSON',
179-
type: 'POST'
180-
}).then((binary: string) => {
181-
const parsedBin = intArrayFromBase64(binary);
182-
const fileContent = makeProcessorsFile(id, parsedBin);
183-
latestParsedBin = parsedBin; //More bad things
184-
return audioCtx.audioWorklet.addModule(`data:application/javascript;base64,${btoa(fileContent)}`).then(() => {
185-
return new AudioWorkletNode(audioCtx, id);
186-
});
174+
175+
return new Promise((resolve, reject) => {
176+
$.ajax(`/makeWorkletBinary/${id}`, {
177+
data: JSON.stringify({
178+
ts
179+
}),
180+
contentType: 'application/JSON',
181+
type: 'POST'
182+
}).then((binary: string) => {
183+
const parsedBin = intArrayFromBase64(binary);
184+
const fileContent = makeProcessorsFile(id, parsedBin);
185+
latestParsedBin = parsedBin; //More bad things
186+
return audioCtx.audioWorklet.addModule(`data:application/javascript;base64,${btoa(fileContent)}`).then(() => {
187+
return new AudioWorkletNode(audioCtx, id);
188+
});
189+
})
190+
.then(resolve)
191+
.catch(reject);
187192
});
188193
}

src/nodes/outputs/speaker.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { h } from 'nimble';
2-
31
export default class SpeakerOutputNode implements WAGenNode {
42
getDefaultNode() {
53
return <any>{};

src/types.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ type State = {
2727
};
2828

2929
declare module 'tone';
30-
declare module 'webmidi';
30+
declare module 'webmidi';
31+
declare module 'intro.js';

0 commit comments

Comments
 (0)