Skip to content

Commit

Permalink
Merge branch 'develop' into feature/webgl
Browse files Browse the repository at this point in the history
* develop: (144 commits)
  refactor(examples): update all examples
  fix(interceptors): update EventBus ctor args
  fix(hdom-components): update CanvasHandler args
  feat(csp): update Mult.tap() to use set semantics
  test: update various tests for TS strictNullChecks
  fix(unionstruct): allow undefined/null args
  fix(iterators): update concat/mapcat, fnil args
  refactor(diff): allow args to be undefined/null
  build: enable strictNullChecks for all packages
  refactor(hiccup-markdown): TS strictNullChecks, add tests
  fix(fsm): callback return types
  refactor(sax): TS strictNullChecks
  feat(color): TS strictNullChecks, update color conversion fns
  refactor(associative): TS strictNullChecks, fix #88
  refactor(rstream-query): TS strictNullChecks
  refactor(rstream-log): TS strictNullChecks
  refactor(rstream-graph): TS strictNullChecks
  refactor(rstream-gestures): TS strictNullChecks
  refactor(rstream-dot): TS strictNullChecks
  fix(rstream): TS strictNullChecks, add assertions
  ...
  • Loading branch information
postspectacular committed Jun 11, 2019
2 parents 703d912 + 3d0a673 commit d007434
Show file tree
Hide file tree
Showing 572 changed files with 4,665 additions and 3,550 deletions.
4 changes: 2 additions & 2 deletions examples/async-effect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"devDependencies": {
"parcel-bundler": "^1.12.3",
"terser": "^3.17.0",
"typescript": "^3.4.1"
"typescript": "^3.4.5"
},
"dependencies": {
"@thi.ng/api": "latest",
Expand All @@ -26,4 +26,4 @@
"browser": {
"process": false
}
}
}
4 changes: 2 additions & 2 deletions examples/bitmap-font/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"parcel-bundler": "^1.12.3",
"rimraf": "^2.6.3",
"terser": "^3.17.0",
"typescript": "^3.4.1"
"typescript": "^3.4.5"
},
"dependencies": {
"@thi.ng/api": "latest",
Expand All @@ -30,4 +30,4 @@
"browser": {
"process": false
}
}
}
22 changes: 16 additions & 6 deletions examples/bitmap-font/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { IObjectOf } from "@thi.ng/api";
import { dropdown } from "@thi.ng/hdom-components";
import { clamp } from "@thi.ng/math";
import { stream, Stream, sync } from "@thi.ng/rstream";
import {
stream,
Stream,
Subscription,
sync
} from "@thi.ng/rstream";
import {
comp,
map,
Expand All @@ -17,6 +22,9 @@ import { bits } from "@thi.ng/transducers-binary";
import { updateDOM } from "@thi.ng/transducers-hdom";
import { FONT } from "./font";

const emitOnStream = (stream: Subscription<any, any>) => (e: Event) =>
stream.next((<HTMLSelectElement>e.target).value);

// retrieve font bytes for given char
const lookupChar = (c: string) =>
FONT[clamp(c.charCodeAt(0) - 32, 0, FONT.length - 1)];
Expand Down Expand Up @@ -62,7 +70,7 @@ const charSelector = (stream: Stream<string>) => [
dropdown,
{
class: "ml3",
onchange: (e) => stream.next(e.target.value)
onchange: emitOnStream(stream)
},
[
["#", "#"],
Expand All @@ -80,14 +88,14 @@ const charSelector = (stream: Stream<string>) => [
];

// main UI root component
const app = ({ raw, result }) => [
const app = ({ raw, result }: any) => [
"div",
[
"div",
[
"input",
{
oninput: (e) => input.next(e.target.value),
oninput: emitOnStream(input),
value: raw
}
],
Expand All @@ -103,9 +111,11 @@ const on = stream<string>();
const off = stream<string>();

// transforming stream combinator
const xformer = sync({ src: { input, on, off } }).transform(map(banner));
const xformer = sync<any, any>({ src: { input, on, off } }).transform(
map(banner)
);

const main = sync({ src: { raw: input, result: xformer } });
const main = sync<any, any>({ src: { raw: input, result: xformer } });
main.transform(map(app), updateDOM());

// kick off
Expand Down
7 changes: 3 additions & 4 deletions examples/bitmap-font/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"compilerOptions": {
"outDir": ".",
"target": "es6",
"sourceMap": true
"sourceMap": true,
"strictBindCallApply": false
},
"include": [
"./src/**/*.ts"
]
"include": ["./src/**/*.ts"]
}
4 changes: 2 additions & 2 deletions examples/canvas-dial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"devDependencies": {
"parcel-bundler": "^1.12.3",
"terser": "^3.17.0",
"typescript": "^3.4.1"
"typescript": "^3.4.5"
},
"dependencies": {
"@thi.ng/api": "latest",
Expand All @@ -33,4 +33,4 @@
"browser": {
"process": false
}
}
}
8 changes: 4 additions & 4 deletions examples/canvas-dial/src/dial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ const TAU = 2 * PI;
*
* @param opts
*/
export const dial = (opts: Partial<DialOpts>) => {
opts = {
export const dial = (_opts: Partial<DialOpts>) => {
const opts = <DialOpts>{
cx: 0.5,
cy: 0.5,
r1: 0.5,
Expand All @@ -126,10 +126,10 @@ export const dial = (opts: Partial<DialOpts>) => {
labelColor: "black",
labelYOffset: 0,
font: "10px sans-serif",
...opts
..._opts
};
let events: Subscription<any, GestureEvent>;
let cx, cy;
let cx: number, cy: number;
const startTheta = opts.base + opts.gap / 2;

const drawRing = (
Expand Down
4 changes: 2 additions & 2 deletions examples/canvas-dial/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const app = () => {
label: (x) => percent(2)(x),
onchange: (x) => ctx.streams.c.next(x)
});
return ({ a, b, c }) => [
return ({ a, b, c }: any) => [
"div",
ctx.ui.root,
[dialA, ctx.ui.dial, a],
Expand All @@ -67,7 +67,7 @@ const app = () => {
};

// stream combinator & reactive DOM update
sync({
sync<any, any>({
src: ctx.streams,
xform: comp(map(app()), updateDOM())
});
Expand Down
4 changes: 2 additions & 2 deletions examples/cellular-automata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"devDependencies": {
"parcel-bundler": "^1.12.3",
"terser": "^3.17.0",
"typescript": "^3.4.1"
"typescript": "^3.4.5"
},
"dependencies": {
"@thi.ng/hdom": "latest",
Expand All @@ -26,4 +26,4 @@
"browser": {
"process": false
}
}
}
27 changes: 17 additions & 10 deletions examples/cellular-automata/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const parseRules = step(
comp(map((x: string) => parseInt(x.replace("-", ""), 2)), bits(18))
);

const applyRules = (raw) => {
const applyRules = (raw: string) => {
if (raw.length >= 18) {
rules = <number[]>parseRules(raw);
randomizeGrid();
Expand All @@ -55,7 +55,7 @@ const applyRules = (raw) => {
};

// create random bit sequence w/ ones appearing in given probability
const randomSeq = (num, prob = 0.5) => [
const randomSeq = (num: number, prob = 0.5) => [
...repeatedly(() => (Math.random() < prob ? 1 : 0), num)
];

Expand All @@ -80,7 +80,7 @@ export const convolve = (
rstride = 9,
wrap = true
) =>
transduce(
transduce<number[], number, number[]>(
comp(
convolve2d({ src, width, height, kernel, wrap }),
mapIndexed((i, x) => rules[x + src[i] * rstride])
Expand All @@ -102,32 +102,36 @@ const format = (src: number[], width: number, fill = "\u2588", empty = " ") =>
);

// event handler for rule edits
const setRule = (i: number, j: number, s: number, rstride = 9) => {
const setRule = (i: number, j: number, s: boolean, rstride = 9) => {
rules[i * rstride + j] = s ? 1 : 0;
setHash();
};

// single checkbox component
const checkbox = (x, onchange) => [
const checkbox = (x: number, onchange: EventListener) => [
"input",
{ type: "checkbox", checked: !!x, onchange }
];

// component for single CA rule group (alive / dead FSM)
const ruleBoxes = (prefix, i, rstride = 9) => [
const ruleBoxes = (prefix: string, i: number, rstride = 9) => [
"div",
["label", prefix],
...rules
.slice(i * rstride, (i + 1) * rstride)
.map((rule, j) =>
checkbox(rule, (e) => setRule(i, j, e.target.checked))
checkbox(rule, (e) =>
setRule(i, j, (<HTMLInputElement>e.target).checked)
)
)
];

const isPreset = (id) => presets.findIndex((x) => x[0] === id) !== -1;
const isPreset = (id: string) => presets.findIndex((x) => x[0] === id) !== -1;

// Use Conway CA default state rules [[dead], [alive]] if no preset present in hash
applyRules(location.hash.length > 18 ? location.hash.substr(1) : presets[1][0]);
applyRules(
location.hash.length > 18 ? location.hash.substr(1) : <string>presets[1][0]
);

// define & start main app component
start(() => {
Expand All @@ -142,7 +146,10 @@ start(() => {
["button", { onclick: () => randomizeGrid() }, "reset grid"],
[
dropdown,
{ onchange: (e) => applyRules(e.target.value) },
{
onchange: (e: Event) =>
applyRules((<HTMLSelectElement>e.target).value)
},
presets,
isPreset(id) ? id : ""
]
Expand Down
4 changes: 2 additions & 2 deletions examples/commit-table-ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"parcel-bundler": "^1.12.3",
"terser": "^3.17.0",
"typescript": "^3.4.1"
"typescript": "^3.4.5"
},
"dependencies": {
"express": "^4.16.3",
Expand All @@ -33,4 +33,4 @@
"browser": {
"process": false
}
}
}
4 changes: 2 additions & 2 deletions examples/crypto-chart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"devDependencies": {
"parcel-bundler": "^1.12.3",
"terser": "^3.17.0",
"typescript": "^3.4.1"
"typescript": "^3.4.5"
},
"dependencies": {
"@thi.ng/hdom-components": "latest",
Expand All @@ -30,4 +30,4 @@
"browser": {
"process": false
}
}
}
Loading

0 comments on commit d007434

Please sign in to comment.