diff --git a/assets/hdom-dataflow.png b/assets/hdom-dataflow.png new file mode 100644 index 0000000000..820ae33df9 Binary files /dev/null and b/assets/hdom-dataflow.png differ diff --git a/assets/hdom-dataflow.svg b/assets/hdom-dataflow.svg deleted file mode 100644 index aa6ea5e2c4..0000000000 --- a/assets/hdom-dataflow.svg +++ /dev/null @@ -1,2 +0,0 @@ - -
App state /
source data
[Not supported by viewer]
DOM tree creation
(nested JS array)
[Not supported by viewer]
Recursive Diff
w/ previous tree
[Not supported by viewer]

State changes
caused by
events

[Not supported by viewer]
Browser DOM
mutation
Browser DOM<div>mutation</div>
Tree expansion
(normalization)
[Not supported by viewer]
element & attrib updates
component lifecycle hooks
[Not supported by viewer]
computes
minimum changeset
[Not supported by viewer]
tag normalization
nested component function execution
tag normalization<div>nested component function execution</div>
static / dynamic arrays
closures
component objects
[Not supported by viewer]
unprescribed /
anything goes...
[Not supported by viewer]
  requestAnimationFrame()  
&nbsp; requestAnimationFrame()&nbsp;&nbsp;
  user code  
[Not supported by viewer]
\ No newline at end of file diff --git a/examples/README.md b/examples/README.md index cf3c9dcfbc..d00b0a0abf 100644 --- a/examples/README.md +++ b/examples/README.md @@ -4,27 +4,29 @@ This directory contains a growing number of standalone example projects, includi If you want to [contribute](../CONTRIBUTING.md) an example, please get in touch via PR, issue tracker, email or twitter! -| # | Name | Description | Packages of interest | Difficulty | -|----|----------------------------------------------|-----------------------------------------------------|-------------------------------------------------------------------|--------------| -| 1 | [async-effect](./async-effect) | Async side effect handling (JSON I/O) | atom, hdom, interceptors | intermediate | -| 2 | [cellular-automata](./cellular-automata) | Transducer based, customizable 2D cellular automata | hdom, hdom-components, transducers | basic | -| 3 | [crypto-chart](./crypto-chart) | Interactive rstream & transducer based SVG chart | hdom, hiccup-svg, rstream, transducers | advanced | -| 4 | [dashboard](./cellular-automata) | Barebones components w/ local state | hdom, transducers | basic | -| 5 | [devcards](./devcards) | Multiple app instances with/without shared state | atom, hdom | intermediate | -| 6 | [hdom-basics](./hdom-basics) | Hello world | hdom, hiccup | basic | -| 7 | [hdom-benchmark](./hdom-benchmark) | hdom rendering perf / stress test, FPS counter | hdom, rstream, transducers | intermediate | -| 8 | [hdom-theme-adr-0003](./hdom-theme-adr-0003) | hdom themed components proposal | hdom | intermediate | -| 9 | [interceptor-basics](./hdom-benchmark) | Event handling w/ interceptors and side effects | atom, hdom, interceptors | intermediate | -| 10 | [json-components](./json-components) | JSON->component transformation, live editor | hdom, transducers | intermediate | -| 11 | [login-form](./login-form) | Basic SPA without router | atom, hdom | intermediate | -| 12 | [pointfree-svg](./pointfree-svg) | Generate SVG using pointfree DSL | hiccup, hiccup-svg, pointfree-lang | intermediate | -| 13 | [router-basics](./router-basics) | Complete mini SPA | atom, hdom, interceptors, router | advanced | -| 14 | [rstream-dataflow](./rstream-dataflow) | Dataflow graph | atom, hdom, rstream, rstream-gestures, rstream-graph, transducers | intermediate | -| 15 | [rstream-grid](./rstream-grid) | Dataflow graph SVG grid | atom, hdom, hiccup-svg, interceptors, rstream-graph, transducers | advanced | -| 16 | [rstream-hdom](./rstream-hdom) | rstream based UI updates & state handling | hdom, rstream, transducers | intermediate | -| 17 | [svg-particles](./svg-particles) | hdom SVG generation / animation | hdom, transducers | basic | -| 18 | [svg-waveform](./svg-waveform) | hdom SVG generation / undo history | atom, hdom, hiccup-svg, interceptors, iterators | intermediate | -| 19 | [todo-list](./todo-list) | Canonical Todo list with undo/redo | atom, hdom, transducers | intermediate | -| 20 | [transducers-hdom](./transducers-hdom) | Transducer & rstream based hdom UI updates | hdom, rstream, transducers-hdom | basic | -| 21 | [triple-query](./triple-query) | Triple store query results & sortable table | atom, hdom, hdom-components, rstream-query, transducers | intermediate | -| 22 | [webgl](./webgl) | Canvas component handling | hdom, hdom-components | basic | +| # | Name | Description | Packages of interest | Difficulty | +|----|----------------------------------------------|----------------------------------------------------------|-------------------------------------------------------------------|--------------| +| 1 | [async-effect](./async-effect) | Async side effect handling (JSON I/O) | atom, hdom, interceptors | intermediate | +| 2 | [canvas-dial](./canvas-dial) | Canvas dial component w/ mouse & touch events | hdom, rstream, rstream-gestures, transducers, transducers-hdom | intermediate | +| 3 | [cellular-automata](./cellular-automata) | Transducer based, customizable 2D cellular automata | hdom, hdom-components, transducers | basic | +| 4 | [commit-table-ssr](./commit-table-ssr) | Server-side & static file rendering of hiccup components | hiccup, transducers | intermediate | +| 5 | [crypto-chart](./crypto-chart) | Interactive rstream & transducer based SVG chart | hdom, hiccup-svg, rstream, transducers | advanced | +| 6 | [dashboard](./dashboard) | Barebones components w/ local state | hdom, transducers | basic | +| 7 | [devcards](./devcards) | Multiple app instances with/without shared state | atom, hdom | intermediate | +| 8 | [hdom-basics](./hdom-basics) | Hello world | hdom, hiccup | basic | +| 9 | [hdom-benchmark](./hdom-benchmark) | hdom rendering perf / stress test, FPS counter | hdom, rstream, transducers | intermediate | +| 10 | [hdom-theme-adr-0003](./hdom-theme-adr-0003) | hdom themed components proposal | hdom | intermediate | +| 11 | [interceptor-basics](./interceptor-basics) | Event handling w/ interceptors and side effects | atom, hdom, interceptors | intermediate | +| 12 | [json-components](./json-components) | JSON->component transformation, live editor | hdom, transducers | intermediate | +| 13 | [login-form](./login-form) | Basic SPA without router | atom, hdom | intermediate | +| 14 | [pointfree-svg](./pointfree-svg) | Generate SVG using pointfree DSL | hiccup, hiccup-svg, pointfree-lang | intermediate | +| 15 | [router-basics](./router-basics) | Complete mini SPA | atom, hdom, interceptors, router | advanced | +| 16 | [rstream-dataflow](./rstream-dataflow) | Dataflow graph | atom, hdom, rstream, rstream-gestures, rstream-graph, transducers | intermediate | +| 17 | [rstream-grid](./rstream-grid) | Dataflow graph SVG grid | atom, hdom, hiccup-svg, interceptors, rstream-graph, transducers | advanced | +| 18 | [rstream-hdom](./rstream-hdom) | rstream based UI updates & state handling | hdom, rstream, transducers | intermediate | +| 19 | [svg-particles](./svg-particles) | hdom SVG generation / animation | hdom, transducers | basic | +| 20 | [svg-waveform](./svg-waveform) | hdom SVG generation / undo history | atom, hdom, hiccup-svg, interceptors, iterators | intermediate | +| 21 | [todo-list](./todo-list) | Canonical Todo list with undo/redo | atom, hdom, transducers | intermediate | +| 22 | [transducers-hdom](./transducers-hdom) | Transducer & rstream based hdom UI updates | hdom, rstream, transducers-hdom | basic | +| 23 | [triple-query](./triple-query) | Triple store query results & sortable table | atom, hdom, hdom-components, rstream-query, transducers | intermediate | +| 24 | [webgl](./webgl) | Canvas component handling | hdom, hdom-components | basic | \ No newline at end of file diff --git a/examples/canvas-dial/.gitignore b/examples/canvas-dial/.gitignore new file mode 100644 index 0000000000..9c418ce79f --- /dev/null +++ b/examples/canvas-dial/.gitignore @@ -0,0 +1,3 @@ +node_modules +yarn.lock +*.js diff --git a/examples/canvas-dial/README.md b/examples/canvas-dial/README.md new file mode 100644 index 0000000000..d74977360d --- /dev/null +++ b/examples/canvas-dial/README.md @@ -0,0 +1,21 @@ +# canvas-dial + +[Live demo](http://demo.thi.ng/umbrella/canvas-dial/) + +Customizable canvas-based radial dial component with mouse & touch +support. + +```bash +git clone https://github.com/thi-ng/umbrella.git +cd umbrella/examples/canvas-dial +yarn install +yarn start +``` + +## Authors + +- Karsten Schmidt + +## License + +© 2018 Karsten Schmidt // Apache Software License 2.0 diff --git a/examples/canvas-dial/index.html b/examples/canvas-dial/index.html new file mode 100644 index 0000000000..62ff6957ad --- /dev/null +++ b/examples/canvas-dial/index.html @@ -0,0 +1,19 @@ + + + + + + + + canvas-dial + + + + + +
+ + + + \ No newline at end of file diff --git a/examples/canvas-dial/package.json b/examples/canvas-dial/package.json new file mode 100644 index 0000000000..de2be1f868 --- /dev/null +++ b/examples/canvas-dial/package.json @@ -0,0 +1,28 @@ +{ + "name": "canvas-dial", + "version": "0.0.1", + "repository": "https://github.com/thi-ng/umbrella", + "author": "Karsten Schmidt ", + "license": "Apache-2.0", + "scripts": { + "build": "webpack --mode production --display-reasons --display-modules", + "start": "webpack-dev-server --open --mode development --devtool inline-source-map" + }, + "devDependencies": { + "ts-loader": "^4.4.2", + "typescript": "^3.0.1", + "webpack": "^4.16.3", + "webpack-cli": "^3.1.0", + "webpack-dev-server": "^3.1.5" + }, + "dependencies": { + "@thi.ng/api": "latest", + "@thi.ng/checks": "latest", + "@thi.ng/hdom": "latest", + "@thi.ng/hdom-components": "latest", + "@thi.ng/rstream": "latest", + "@thi.ng/rstream-gestures": "latest", + "@thi.ng/strings": "latest", + "@thi.ng/transducers": "latest" + } +} \ No newline at end of file diff --git a/examples/canvas-dial/src/dial.ts b/examples/canvas-dial/src/dial.ts new file mode 100644 index 0000000000..139f8e4d8d --- /dev/null +++ b/examples/canvas-dial/src/dial.ts @@ -0,0 +1,209 @@ +import { Fn } from "@thi.ng/api/api"; +import { isString } from "@thi.ng/checks/is-string"; +import { canvas2D } from "@thi.ng/hdom-components/canvas"; +import { GestureEvent, gestureStream, GestureType } from "@thi.ng/rstream-gestures"; +import { Subscription } from "@thi.ng/rstream/subscription"; +import { peek } from "@thi.ng/transducers/func/peek"; +import { fitClamped1 } from "@thi.ng/vectors/math"; +import { heading2, sub2 } from "@thi.ng/vectors/vec2"; + +/** + * Dial component options. + */ +export interface DialOpts { + /** + * Dial center X (normalized) + * Default: 0.5 + */ + cx: number; + /** + * Dial center Y (normalized) + * Default: 0.5 + */ + cy: number; + /** + * Inner radius (normalized) + * Default: 0.5 + */ + r1: number; + /** + * Outer radius (normalized) + * Default: 0.99 + */ + r2: number; + /** + * Dial min value + * Default: 0 + */ + min: number; + /** + * Dial min value + * Default: 1 + */ + max: number; + /** + * Orientation / start angle (in radians) + * Default: PI/2 + */ + base: number; + /** + * Angular gap between min / max values + * Default: PI/10 + */ + gap: number; + /** + * Fill color (or gradient) for value area + * Default: black + */ + color: string | GradientDef; + /** + * Fill color (or gradient) for background ring + * Default: rgba(0,0,0,0.1) + */ + bgColor: string | GradientDef; + /** + * Label formatter. No label will be displayed, if missing. + */ + label: (x: number) => string; + /** + * Label Y offset from `cy` + * Default: 0 + */ + labelYOffset: number; + /** + * Default: black + */ + labelColor: string; + /** + * Label font CSS string + * Default (10px sans-serif) + */ + font: string; + /** + * Event callback (receives new dial value) + */ + onchange: Fn; +} + +/** + * Multi-stop linear gradient definition. + */ +export interface GradientDef { + /** + * Start point (normalized) + */ + from: number[]; + /** + * End point (normalized) + */ + to: number[]; + /** + * Color stops (position normalized) + */ + stops: [number, string][]; +} + +const PI = Math.PI; +const TAU = 2 * PI; + +/** + * HOF component. Returns pre-configured dial component. + * + * @param opts + */ +export const dial = (opts: Partial) => { + opts = { + cx: 0.5, + cy: 0.5, + r1: 0.5, + r2: 0.99, + min: 0, + max: 1, + base: PI * 0.5, + gap: PI * 0.1, + color: "black", + bgColor: "rgba(0,0,0,0.1)", + labelColor: "black", + labelYOffset: 0, + font: "10px sans-serif", + ...opts + }; + let events: Subscription; + let cx, cy; + const startTheta = opts.base + opts.gap / 2; + + const drawRing = (ctx: CanvasRenderingContext2D, amount: number, col: any) => { + const endTheta = startTheta + (TAU - opts.gap) * amount; + ctx.fillStyle = col; + ctx.beginPath(); + ctx.arc(cx, cy, opts.r2, startTheta, endTheta, false); + ctx.arc(cx, cy, opts.r1, endTheta, startTheta, true); + ctx.fill(); + }; + + const makeGradient = (el: HTMLCanvasElement, ctx: CanvasRenderingContext2D, def: GradientDef) => { + const g = ctx.createLinearGradient( + def.from[0] * el.width, def.from[1] * el.height, + def.to[0] * el.width, def.to[1] * el.height + ); + def.stops.forEach(([pos, col]) => g.addColorStop(pos, col)); + return g; + }; + + return canvas2D({ + + init: (el, ctx) => { + cx = el.width * opts.cx; + cy = el.height * opts.cy; + ctx.strokeStyle = "none"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.font = opts.font; + const scale = Math.min(cx, cy); + opts.r1 *= scale; + opts.r2 *= scale; + if (!isString(opts.bgColor)) { + opts.bgColor = makeGradient(el, ctx, opts.bgColor); + } + if (!isString(opts.color)) { + opts.color = makeGradient(el, ctx, opts.color); + } + if (opts.onchange) { + // add interaction event stream (mouse & touch) + // configure stream to return scaled coords (devicePixelRatio) + events = gestureStream(el, { scale: true }) + .subscribe({ + next: (e) => { + if (e[0] === GestureType.START || e[0] === GestureType.DRAG) { + let theta = heading2(sub2(e[1].pos, [cx, cy])) - startTheta; + if (theta < 0) theta += TAU; + theta %= TAU; + opts.onchange.call( + null, + fitClamped1(Math.min(theta / (TAU - opts.gap)), 0, 1, opts.min, opts.max) + ); + } + } + }); + } + }, + + // clean up gesture event stream when component is released + release: () => { + events && events.unsubscribe(); + }, + + // there're a few args we're not interested in here, so we use var args instead. + // the dial value is the last arg + update: (el, ctx, ...args: any[]) => { + const val = peek(args); + ctx.clearRect(0, 0, el.width, el.height); + drawRing(ctx, 1, opts.bgColor); + drawRing(ctx, fitClamped1(val, opts.min, opts.max, 0.005, 1), opts.color); + if (opts.label) { + ctx.fillStyle = opts.labelColor; + ctx.fillText(opts.label(val), cx, cy + opts.labelYOffset); + } + } + }); +}; diff --git a/examples/canvas-dial/src/index.ts b/examples/canvas-dial/src/index.ts new file mode 100644 index 0000000000..d30b653bce --- /dev/null +++ b/examples/canvas-dial/src/index.ts @@ -0,0 +1,76 @@ +import { stream } from "@thi.ng/rstream/stream"; +import { sync } from "@thi.ng/rstream/stream-sync"; +import { percent } from "@thi.ng/strings/percent"; +import { updateUI } from "@thi.ng/transducers-hdom"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { map } from "@thi.ng/transducers/xform/map"; + +import { dial } from "./dial"; + +// hdom context & app state object +export const ctx = { + // streams to hold dial values + streams: { + a: stream(), + b: stream(), + c: stream(), + }, + // component styling + ui: { + root: { class: "vh-100 flex justify-center items-center" }, + dial: { width: 100, height: 100, class: "ma1" }, + } +}; + +/** + * This HOF (higher-order function) returns a mapping function which + * receives a tuple of object of all current stream values and returns a + * hdom root component. It will be used by the `sync()` construct + * further below. + * + * The dial components used here are HOFs themselves and therefore must + * be pre-initialized before use. + */ +const app = () => { + const dialA = dial({ + r1: 0.5, + color: { from: [0, 0], to: [1, 1], stops: [[0, "#075"], [1, "#6f9"]] }, + font: "20px Menlo", + label: (x) => percent(0)(x), + onchange: (x) => ctx.streams.a.next(x) + }); + const dialB = dial({ + r1: 0.66, + base: -Math.PI / 2, + gap: Math.PI / 2, + color: { from: [0, 0], to: [1, 0.75], stops: [[0, "#00f"], [0.5, "#f60"], [1, "#ff0"]] }, + font: "20px Menlo", + label: (x) => percent(1)(x), + onchange: (x) => ctx.streams.b.next(x) + }); + const dialC = dial({ + r1: 0.75, + gap: Math.PI, + color: { from: [0, 0], to: [1, 0], stops: [[0, "#407"], [1, "#09f"]] }, + font: "20px Menlo", + label: (x) => percent(2)(x), + onchange: (x) => ctx.streams.c.next(x) + }); + return ({ a, b, c }) => + ["div", ctx.ui.root, + [dialA, ctx.ui.dial, a], + [dialB, ctx.ui.dial, b], + [dialC, ctx.ui.dial, c] + ]; +}; + +// stream combinator & reactive DOM update +sync({ + src: ctx.streams, + xform: comp(map(app()), updateUI("app")) +}); + +// seed dials with initial values +ctx.streams.a.next(0.66); +ctx.streams.b.next(1); +ctx.streams.c.next(0.75); diff --git a/examples/canvas-dial/tsconfig.json b/examples/canvas-dial/tsconfig.json new file mode 100644 index 0000000000..bd6481a5a6 --- /dev/null +++ b/examples/canvas-dial/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "." + }, + "include": [ + "./src/**/*.ts" + ] +} diff --git a/examples/canvas-dial/webpack.config.js b/examples/canvas-dial/webpack.config.js new file mode 100644 index 0000000000..e2bf1e8d3a --- /dev/null +++ b/examples/canvas-dial/webpack.config.js @@ -0,0 +1,18 @@ +module.exports = { + entry: "./src/index.ts", + output: { + path: __dirname, + filename: "bundle.js" + }, + resolve: { + extensions: [".ts", ".js"] + }, + module: { + rules: [ + { test: /\.ts$/, use: "ts-loader" } + ] + }, + devServer: { + contentBase: "." + } +}; diff --git a/examples/commit-table-ssr/.gitignore b/examples/commit-table-ssr/.gitignore new file mode 100644 index 0000000000..9c418ce79f --- /dev/null +++ b/examples/commit-table-ssr/.gitignore @@ -0,0 +1,3 @@ +node_modules +yarn.lock +*.js diff --git a/examples/commit-table-ssr/README.md b/examples/commit-table-ssr/README.md new file mode 100644 index 0000000000..ee39157b5c --- /dev/null +++ b/examples/commit-table-ssr/README.md @@ -0,0 +1,83 @@ +# commit-table-ssr + +[Live version](http://demo.thi.ng/umbrella/commit-table-ssr/) + +This example demonstrates isomorphic, +[@thi.ng/hiccup](https://github.com/thi-ng/umbrella/tree/master/packages/hiccup)-based +server-side rendering, static file generation and an extended +interactive browser version of a git repo commit log. The server is a +simple [express](https://expressjs.com/) app. + +All of the UI components used on the server side too work in the browser +without change, though the browser version has additional functionality +(i.e. interactive filtering of commits via user provided search filter). + +The server example builds a large table (~700KB worth of HTML) of this +repo's 1460+ commits by shelling out to `git` to retrieve and transform +the raw history / log using +[transducer](https://github.com/thi-ng/umbrella/tree/master/packages/transducers) +pipelines. Since this process doesn't need to be performed for each +server request, the app uses +[TLRUCaches](https://github.com/thi-ng/umbrella/tree/master/packages/cache#tlru) +to cache both the raw commits and the rendered HTML. Reloading the page +will show the timing difference. + +To use another local repo on your hard drive, [update the settings +here](./src/common/config.ts#L24). + +## Building & running + +### Server-side rendering + +See [/src/server/index.ts](./src/server/index.ts) for details... + +```bash +git clone https://github.com/thi-ng/umbrella.git +cd umbrella/examples/commit-table-ssr +yarn install +yarn dev +``` + +Then open http://localhost:3000/ssr in your browser. + +### Browser version + +The browser version uses the same UI components, but realizes them via +[@thi.ng/hdom](https://github.com/thi-ng/umbrella/tree/master/packages/hdom). + +In addition to the SSR version above, this version displays additional +repo stats and allows for interactive filtering of the commits. The +commits themselves are loaded as JSON and therefore also require the +server app. + +Furthermore, this version utilizes +[@thi.ng/rstream](https://github.com/thi-ng/umbrella/tree/master/packages/rstream) +to build a simple dataflow graph and handle app state changes via +various reactive stream constructs. Comments are included. + +See [/src/client/index.ts](./src/client/index.ts) for details... + +``` +yarn dev-client +``` + +Once you see a message that the server is running, open +http://localhost:3000 in your browser. + +### Static file generation + +The result will be saved to `table.html` in this example's root directory. + +See [/src/server/static.ts](./src/server/static.ts) for details... + +```bash +yarn build-static +``` + +## Authors + +- Karsten Schmidt + +## License + +© 2018 Karsten Schmidt // Apache Software License 2.0 diff --git a/examples/commit-table-ssr/package.json b/examples/commit-table-ssr/package.json new file mode 100644 index 0000000000..969a8198b3 --- /dev/null +++ b/examples/commit-table-ssr/package.json @@ -0,0 +1,30 @@ +{ + "name": "commit-table-ssr", + "version": "0.0.1", + "repository": "https://github.com/thi-ng/umbrella", + "author": "Karsten Schmidt ", + "license": "Apache-2.0", + "scripts": { + "build-static": "tsc && node build/server/static.js", + "build-client": "webpack --mode production --display-reasons --display-modules", + "dev": "tsc && node build/server/index.js", + "dev-client": "yarn build-client && yarn dev" + }, + "devDependencies": { + "ts-loader": "^4.4.2", + "typescript": "^3.0.1", + "webpack": "^4.16.3", + "webpack-cli": "^3.1.0", + "webpack-dev-server": "^3.1.5" + }, + "dependencies": { + "express": "^4.16.3", + "@thi.ng/associative": "latest", + "@thi.ng/cache": "latest", + "@thi.ng/hiccup": "latest", + "@thi.ng/resolve-map": "latest", + "@thi.ng/rstream": "latest", + "@thi.ng/transducers": "latest", + "@types/express": "^4.16.0" + } +} \ No newline at end of file diff --git a/examples/commit-table-ssr/src/client/index.ts b/examples/commit-table-ssr/src/client/index.ts new file mode 100644 index 0000000000..35a5801ee7 --- /dev/null +++ b/examples/commit-table-ssr/src/client/index.ts @@ -0,0 +1,126 @@ +import { resolve as resolveMap } from "@thi.ng/resolve-map"; +import { fromInterval } from "@thi.ng/rstream/from/interval"; +import { stream } from "@thi.ng/rstream/stream"; +import { sync } from "@thi.ng/rstream/stream-sync"; +import { resolve as resolvePromise } from "@thi.ng/rstream/subs/resolve"; +import { updateUI } from "@thi.ng/transducers-hdom"; +import { add } from "@thi.ng/transducers/rfn/add"; +import { conj } from "@thi.ng/transducers/rfn/conj"; +import { transduce } from "@thi.ng/transducers/transduce"; +import { map } from "@thi.ng/transducers/xform/map"; +import { pluck } from "@thi.ng/transducers/xform/pluck"; +import { throttleTime } from "@thi.ng/transducers/xform/throttle-time"; + +import { AppContext, Commit } from "../common/api"; +import { header } from "../common/components/header"; +import { link } from "../common/components/link"; +import { repoTable } from "../common/components/repo-table"; +import { ctx } from "../common/config"; + +// UI root component +const app = (state) => + ["div", + [header, ctx.repo.name], + [stats, state], + [repoTable, state.commits], + ]; + +// stats container component +const stats = (ctx: AppContext, state) => + ["div", ctx.ui.stats.root, + ["div.tl", ctx.ui.stats.col, + [searchFilter, state]], + ["div.tc", ctx.ui.stats.col, + ["div", `Authors: ${state.authors}`], + ["div", `Total adds: ${state.adds} (${state.avgAdds} avg / commit)`], + ["div", `Total dels: ${state.dels} (${state.avgDels} avg / commit)`] + ], + ["div.tr", ctx.ui.stats.col, + [link, { ...ctx.ui.stats.link, href: ctx.repo.url }, ctx.repo.url] + ] + ]; + +// search filter input component +const searchFilter = (ctx: AppContext, state) => + ["div", + "Filter:", + ["input", { + ...ctx.ui.search, + type: "text", + value: state.search, + // emit changes on `search` stream + oninput: (e) => search.next(e.target.value.toLowerCase()) + }], + `(${state.commits.length} commits)` + ]; + +// transformation function to filter commits with search string +// doesn't apply filter if search term is empty +const filterCommits = ({ commits, search }) => + ({ + search, + commits: search ? + commits.filter((x) => x.msg.toLowerCase().indexOf(search) !== -1) : + commits + }); + +// transformation function to compute stats of filtered commits +// uses `resolve-map` package to execute given functions in dependency order +const computeStats = (state) => resolveMap({ + ...state, + adds: ({ commits }) => transduce(map((x: Commit) => x.add || 0), add(), commits), + dels: ({ commits }) => transduce(map((x: Commit) => x.del || 0), add(), commits), + authors: ({ commits }) => transduce(pluck("author"), conj(), commits).size, + avgAdds: ({ commits, adds }) => (adds / commits.length) | 0, + avgDels: ({ commits, dels }) => (dels / commits.length) | 0 +}); + +// error stream & handler +const error = stream(); +error.subscribe({ next: (e) => alert(`An error occurred:\n${e}`) }); + +// commit log stream, reloads every 1h +const commits = fromInterval(60 * 60 * 1000) + // fetch commits from server + .transform( + map(() => fetch("./commits").then( + (res) => res.ok ? res.json() : error.next("error loading commits"), + (e) => error.next(e.message) + )) + ) + // the above transducer returns a promise + // this next subscription resolves it and only then + // passes the result downstream + .subscribe( + resolvePromise({ fail: (e) => error.next(e.message) }) + ); + +// stream of commit filter terms +const search = stream(); + +// stream combinator & transformation into UI / DOM update +sync({ + // streams to synchronize + src: { + commits, + // throttle search stream @ 10Hz (100ms) to minimize + // UI lag for fast typists + search: search.transform(throttleTime(100)), + }, +}) + // now transform the combined stream + // each value is an object tuple of: `{ commits, search }` + .transform( + map(filterCommits), + map(computeStats), + // apply root component + map(app), + // apply hdom tree to real DOM + updateUI("app", ctx) + ); + +// manual kick off is needed here, since the above stream sync construct +// will only execute once all of its inputs have delivered a value. +// the other input `commits` is triggered automatically because it's +// tied to a timer +search.next(""); diff --git a/examples/commit-table-ssr/src/common/api.ts b/examples/commit-table-ssr/src/common/api.ts new file mode 100644 index 0000000000..294fb33501 --- /dev/null +++ b/examples/commit-table-ssr/src/common/api.ts @@ -0,0 +1,56 @@ +/** + * Basic HTML document abstraction for hiccup serialization. + * See ./html.ts for usage + */ +export interface HTMLDoc { + lang?: string; + head?: Partial; + body: any[]; + /** + * This object will be passed to all component functions. + */ + ctx: AppContext; +} + +export interface HTMLHead { + title: string; + meta: any[]; + links: { rel: string, href: string }[]; + scripts: { src: string, type?: string }[]; + styles: string[]; +} + +/** + * App context / config object. + * Contains repo information & component styles + */ +export interface AppContext { + repo: Repo; + ui: { + body: any; + link: any; + header: any; + table: any; + stats: any; + search: any; + } +} + +export interface Repo { + name: string; + path: string; + url: string; +} + +/** + * Data structure of a single commit. + */ +export interface Commit { + sha: string; + date: string; + author: string; + msg: string; + files: number; + add: number; + del: number; +} diff --git a/examples/commit-table-ssr/src/common/components/commit-link.ts b/examples/commit-table-ssr/src/common/components/commit-link.ts new file mode 100644 index 0000000000..0015a8f304 --- /dev/null +++ b/examples/commit-table-ssr/src/common/components/commit-link.ts @@ -0,0 +1,13 @@ +import { AppContext } from "../api"; +import { link } from "./link"; + +/** + * Link component which links to given SHA commit hash using the + * context's repo URL. + * + * @param ctx + * @param sha + * @param body + */ +export const commitLink = (ctx: AppContext, sha: string, body: string) => + [link, { ...ctx.ui.link, href: `${ctx.repo.url}/commit/${sha}` }, body]; diff --git a/examples/commit-table-ssr/src/common/components/header.ts b/examples/commit-table-ssr/src/common/components/header.ts new file mode 100644 index 0000000000..8b54cb395e --- /dev/null +++ b/examples/commit-table-ssr/src/common/components/header.ts @@ -0,0 +1,6 @@ +import { AppContext } from "../api"; + +export const header = (ctx: AppContext, title: string) => + ["section", ctx.ui.header.root, + ["h1", ctx.ui.header.title, title] + ]; diff --git a/examples/commit-table-ssr/src/common/components/link.ts b/examples/commit-table-ssr/src/common/components/link.ts new file mode 100644 index 0000000000..69f78e00bc --- /dev/null +++ b/examples/commit-table-ssr/src/common/components/link.ts @@ -0,0 +1,11 @@ +import { AppContext } from "../api"; + +/** + * Generic HTML link component. + * + * @param ctx + * @param href + * @param body + */ +export const link = (_: AppContext, attribs: any, body: string) => + ["a", attribs, body]; diff --git a/examples/commit-table-ssr/src/common/components/repo-table.ts b/examples/commit-table-ssr/src/common/components/repo-table.ts new file mode 100644 index 0000000000..13a672c284 --- /dev/null +++ b/examples/commit-table-ssr/src/common/components/repo-table.ts @@ -0,0 +1,44 @@ +import { comp } from "@thi.ng/transducers/func/comp"; +import { repeat } from "@thi.ng/transducers/iter/repeat"; +import { iterator } from "@thi.ng/transducers/iterator"; +import { map } from "@thi.ng/transducers/xform/map"; +import { mapIndexed } from "@thi.ng/transducers/xform/map-indexed"; +import { partitionBy } from "@thi.ng/transducers/xform/partition-by"; + +import { AppContext, Commit } from "../api"; +import { commitLink } from "./commit-link"; +import { table } from "./table"; + +/** + * Git commit log table component. Consumes iterable of `Commit` objects + * and transforms each into a table row. + * + * @param _ + * @param commits + */ +export const repoTable = (_: AppContext, commits: Iterable) => + [table, + ["15%", "15%", "55%", "5%", "5%", "5%"], + ["Date", "Author", "Description", "Files", "Adds", "Dels"], + iterator( + comp( + // convert commit into tuple, one value per table cell + map((x: Commit) => [ + x.date.substr(0, 10), + x.author, + [commitLink, x.sha, x.msg], + x.files, + x.add ? ["span.green", `+${x.add}`] : null, + x.del ? ["span.red", `-${x.del}`] : null, + ]), + // partition rows by month + partitionBy((row: any[]) => row[0].split("-")[1]), + // insert month headers (but not in 1st chunk) + mapIndexed((i, month) => [ + i > 0 ? [month[0][0].substr(0, 7), ...repeat("", 5)] : null, + month + ]) + ), + commits + ) + ]; diff --git a/examples/commit-table-ssr/src/common/components/table.ts b/examples/commit-table-ssr/src/common/components/table.ts new file mode 100644 index 0000000000..4a32cb6258 --- /dev/null +++ b/examples/commit-table-ssr/src/common/components/table.ts @@ -0,0 +1,58 @@ +import { map } from "@thi.ng/transducers/xform/map"; + +import { AppContext } from "../api"; +import { mapcat } from "@thi.ng/transducers/xform/mapcat"; + +const thead = (ctx: AppContext, head: Iterable) => + ["thead", + [row, ctx.ui.table.head.row, + map((x) => ["th", ctx.ui.table.head.cell, x], head)]]; + +const row = (ctx: AppContext, attribs: any, body: Iterable) => + ["tr", { ...ctx.ui.table.row, ...attribs }, ...body]; + +/** + * Generic HTML table component w/ column layout support & intermediate + * headers. The `body` iterable MUST contain groups of rows, each group + * with an optional new header row: + * + * ``` + * [table, + * // column layout + * ["25%", "25%", "50%"], + * // global header + * ["Price","Item","Description"], + * // body + * [ + * // row group #1 w/o header + * [null, [ + * [10.99, "Yaki Udon", "noodle dish"], + * [4.99, "Asahi", "beer"], + * ]], + * // row group #2 w/ header + * [["Subtotal", "VAT", "Total"], [ + * [15.98, "20%", 19.18] + * ]] + * ] + * ] + * ``` + * + * @param ctx + * @param layout column sizes + * @param head header cell values + * @param body row chunks + */ +export const table = (ctx: AppContext, layout: (string | number)[], head: Iterable, body: Iterable>) => + ["table", ctx.ui.table.root, + map((x) => ["col", { style: { width: x } }], layout || []), + [thead, head], + mapcat(([hd, rows]) => + [ + hd ? [thead, hd] : null, + ["tbody", + map((cols: any) => [row, null, map((x) => ["td", ctx.ui.table.cell, x], cols)], rows) + ] + ], + body + ) + ]; diff --git a/examples/commit-table-ssr/src/common/config.ts b/examples/commit-table-ssr/src/common/config.ts new file mode 100644 index 0000000000..a406e81c6e --- /dev/null +++ b/examples/commit-table-ssr/src/common/config.ts @@ -0,0 +1,56 @@ +import { HTMLDoc, AppContext } from "./api"; + +export const DEFAULT_DOC: HTMLDoc = { + head: { + meta: [ + { "http-equiv": "Content-Type", content: "text/html;charset=UTF-8" }, + { "http-equiv": "X-UA-Compatible", content: "ie=edge" } + ], + links: [ + { rel: "stylesheet", href: "https://unpkg.com/tachyons@4.11.1/css/tachyons.min.css" }, + { rel: "stylesheet", href: "https://fonts.googleapis.com/css?family=Inconsolata" } + ], + scripts: [], + styles: [], + title: "", + }, + ctx: null, + body: [], +}; + +/** + * Main app config. + */ +export const ctx: AppContext = { + repo: { + name: "thi.ng/umbrella", + path: ".", + url: "https://github.com/thi-ng/umbrella", + }, + ui: { + body: { class: "sans-serif vh-100" }, + link: { class: "link blue hover-light-blue" }, + header: { + root: { class: "bg-dark-gray white pa3 ma0 w-100" }, + title: { class: "tc ma0 pa0 fw1" } + }, + table: { + root: { + class: "w-100 collapse ba br2 b--black-10 pv2 ph3 f7 f6-ns", + style: { "font-family": "Inconsolata, monospace" } + }, + head: { + row: { class: "tl bg-black white" }, + cell: { class: "pv1 pv2-ns ph2 ph3-ns" }, + }, + row: { class: "striped--light-gray" }, + cell: { class: "pv1 pv2-ns ph2 ph3-ns" } + }, + stats: { + root: { class: "flex items-center pa2 bg-light-green dark-gray f7" }, + col: { class: "w-33" }, + link: { class: "link dark-gray" } + }, + search: { class: "pa1 mh2" } + } +}; diff --git a/examples/commit-table-ssr/src/server/build-table.ts b/examples/commit-table-ssr/src/server/build-table.ts new file mode 100644 index 0000000000..bf2f22765b --- /dev/null +++ b/examples/commit-table-ssr/src/server/build-table.ts @@ -0,0 +1,18 @@ +import { Commit } from "../common/api"; +import { header } from "../common/components/header"; +import { repoTable } from "../common/components/repo-table"; +import { ctx } from "../common/config"; +import { html } from "./html"; + +/** + * Shared function used by both the server and for static file + * generation. Returns serialized HTML string of commit table. + */ +export const buildRepoTableHTML = (commits: Iterable) => + html({ + ctx, + body: [ + [header, ctx.repo.name], + [repoTable, commits], + ] + }); diff --git a/examples/commit-table-ssr/src/server/git.ts b/examples/commit-table-ssr/src/server/git.ts new file mode 100644 index 0000000000..8120bcca59 --- /dev/null +++ b/examples/commit-table-ssr/src/server/git.ts @@ -0,0 +1,86 @@ +import { + assocObj, + comp, + filter, + iterator, + map, + mapcat, + partitionBy, + transduce, + tuples +} from "@thi.ng/transducers"; +import { execSync } from "child_process"; +import { resolve } from "path"; + +import { Commit } from "../common/api"; + +/** + * Calls out to git to retrieve raw log string. + * + * @param repoPath + */ +const gitLog = (repoPath: string) => + execSync( + `git log --pretty=format:"%ad~~%an~~%h~~%s" --shortstat --date=iso-strict`, + { cwd: resolve(repoPath) } + ).toString().trim(); + +/** + * Transforms 1st line of a raw commit log into a partial commit + * object. + * + * @param log + */ +const parseLog = ([log]: string[]): Partial => { + const [date, author, sha, msg] = log.split("~~"); + return { date, author, sha, msg }; +}; + +/** + * Transforms 2nd line (if present) of a raw commit log into a partial + * commit object. + * + * @param log + */ +const parseStats = ([_, stats]: string[]): Partial => + stats ? + transduce( + map(([k, v]) => [k, parseInt(v)]), + assocObj(), + tuples(["files", "add", "del"], stats.split(",")) + ) : + null; + +/** + * Retrieves git log for given `repoPath` and transforms it into an + * iterable of `Commit` objects. + * + * @param repoPath + */ +export const repoCommits = (repoPath: string) => + iterator( + comp( + // get raw log + map(gitLog), + // split into lines + mapcat((x: string) => x.split("\n")), + // group related lines: + // normal commits have 2 lines + 1 empty + // merge commits have only 1 line + // pick a random number for merge commits + // in case there're successive ones + partitionBy( + (x) => x.indexOf("~~Merge ") !== -1 ? + Math.random() : + x.length > 0 ? 1 : 0 + ), + // remove empty lines + filter((x) => x[0].length > 0), + // parse commit details + map((commit) => { + ...parseLog(commit), + ...parseStats(commit) + }) + ), + [repoPath] + ); diff --git a/examples/commit-table-ssr/src/server/html.ts b/examples/commit-table-ssr/src/server/html.ts new file mode 100644 index 0000000000..07781d8d94 --- /dev/null +++ b/examples/commit-table-ssr/src/server/html.ts @@ -0,0 +1,39 @@ +import { mergeDeepObj } from "@thi.ng/associative/merge-deep"; +import { serialize } from "@thi.ng/hiccup"; +import { map } from "@thi.ng/transducers/xform/map"; + +import { AppContext, HTMLDoc } from "../common/api"; +import { DEFAULT_DOC } from "../common/config"; + +/** + * Takes a `HTMLDoc` object and serializes it into an HTML5 string. The + * `body` field of the document must contain elements in thi.ng/hiccup + * format, i.e. it's an array in which each element is a nested array, + * string or ES6 iterable, each encoding a part of the full DOM to be + * generated. The resulting HTML string will not contain any whitespace + * unless it's part of string values. + * + * See here for more reference: + * https://github.com/thi-ng/umbrella/tree/master/packages/hiccup + * + * @param doc + */ +export const html = (doc: HTMLDoc) => { + doc = mergeDeepObj(DEFAULT_DOC, doc); + return `${serialize( + ["html", { lang: doc.lang || "en" }, + ["head", + map((meta) => ["meta", meta], doc.head.meta), + map((s) => script(null, s), doc.head.scripts), + map((link) => ["link", link], doc.head.links), + map((css) => ["style", css], doc.head.styles), + ["title", doc.head.title], + ], + ["body", doc.ctx.ui.body, ...doc.body] + ], + doc.ctx + )}`; +}; + +export const script = (_: AppContext, script: { src: string, type?: string }) => + ["script", { type: "text/javascript", ...script }]; \ No newline at end of file diff --git a/examples/commit-table-ssr/src/server/index.ts b/examples/commit-table-ssr/src/server/index.ts new file mode 100644 index 0000000000..302ed03339 --- /dev/null +++ b/examples/commit-table-ssr/src/server/index.ts @@ -0,0 +1,65 @@ +import { TLRUCache } from "@thi.ng/cache"; +import * as express from "express"; + +import { Commit } from "../common/api"; +import { ctx } from "../common/config"; +import { buildRepoTableHTML } from "./build-table"; +import { repoCommits } from "./git"; +import { html, script } from "./html"; + +// building the repo commit table takes quite some time +// therefore we cache results with 1h expiry time +// (which is also the default) +const rawCache = new TLRUCache(null, { ttl: 60 * 60 * 1000 }); +const htmlCache = new TLRUCache(null, { ttl: 60 * 60 * 1000 }); + +const app = express(); + +app.use(express.static(".")); + +// route for browser version +// here we simply return a barebone html doc +// with a reference to the built client JS +app.get("/", (_, res) => { + res.send(html({ + ctx, + head: { + title: "commit-table-hdom", + }, + body: [ + ["div#app"], + [script, { src: "bundle.js" }] + ], + })); +}); + +// route for the client to retrieve the commit log as JSON +app.get("/commits", (_, res) => { + // retrieve raw commit log from cache or + // (re)create if missing... + rawCache.getSet( + ctx.repo.path, + async () => [...repoCommits(ctx.repo.path)] + ).then( + (commits) => res.type("json").send(commits) + ) +}); + +// route for server-side rendering +// uses both caches +app.get("/ssr", (_, res) => { + // retrieve rendered html from cache or + // (re)create if missing... + htmlCache.getSet( + ctx.repo.path, + async () => buildRepoTableHTML( + await rawCache.getSet( + ctx.repo.path, + async () => [...repoCommits(ctx.repo.path)] + ) + ) + ).then((doc) => res.send(doc)) +}); + +console.log("starting server @ http://localhost:3000"); +app.listen(3000); diff --git a/examples/commit-table-ssr/src/server/static.ts b/examples/commit-table-ssr/src/server/static.ts new file mode 100644 index 0000000000..4170ca5191 --- /dev/null +++ b/examples/commit-table-ssr/src/server/static.ts @@ -0,0 +1,8 @@ +import { writeFileSync } from "fs"; + +import { ctx } from "../common/config"; +import { buildRepoTableHTML } from "./build-table"; +import { repoCommits } from "./git"; + +// generate as file in example directory +writeFileSync("table.html", buildRepoTableHTML(repoCommits(ctx.repo.path))); diff --git a/examples/commit-table-ssr/tsconfig.json b/examples/commit-table-ssr/tsconfig.json new file mode 100644 index 0000000000..9c5143a908 --- /dev/null +++ b/examples/commit-table-ssr/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "build" + }, + "include": [ + "./src/**/*.ts" + ] +} \ No newline at end of file diff --git a/examples/crypto-chart/README.md b/examples/crypto-chart/README.md index 34357ea635..f6fb86990c 100644 --- a/examples/crypto-chart/README.md +++ b/examples/crypto-chart/README.md @@ -2,7 +2,7 @@ [Live demo](https://s3.amazonaws.com/demo.thi.ng/umbrella/crypto-chart/index.html) -![chart](../../assets/crypto-chart.png) +![chart](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/crypto-chart.png) Price data provided by [cryptocompare.com](https://min-api.cryptocompare.com/). @@ -20,7 +20,7 @@ updates / diffs when there were any relevant upstream value changes. The diagram below shows a schematic of the dataflow graph used: -![dataflow](../../assets/crypto-dflow.svg) +![dataflow](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/crypto-dflow.svg) ## Building diff --git a/examples/pointfree-svg/README.md b/examples/pointfree-svg/README.md index 882b87d0f0..f2835888b0 100644 --- a/examples/pointfree-svg/README.md +++ b/examples/pointfree-svg/README.md @@ -7,13 +7,14 @@ This is a non-interactive demo combining the following packages to generate the - [@thi.ng/pointfree](https://github.com/thi-ng/umbrella/tree/master/packages/pointfree) - [@thi.ng/pointfree-lang](https://github.com/thi-ng/umbrella/tree/master/packages/pointfree-lang) -![generated result](./output.svg) +![generated result](https://raw.githubusercontent.com/thi-ng/umbrella/master/examples/pointfree-svg/output.svg) -Most of the [source code](./src/index.ts) is written in the pointfree -DSL syntax and includes a rudimentary graphics lib to generate SVG -shapes in hiccup format (basically a DOM defined by nested arrays). The -example also demonstrates how to define custom words defined in JS to -easily extend the language. +Most of the [source +code](https://raw.githubusercontent.com/thi-ng/umbrella/master/examples/pointfree-svg/src/index.ts) +is written in the pointfree DSL syntax and includes a rudimentary +graphics lib to generate SVG shapes in hiccup format (basically a DOM +defined by nested arrays). The example also demonstrates how to define +custom words defined in JS to easily extend the language. The generated SVG file will be written in this example's directory... diff --git a/examples/rstream-dataflow/README.md b/examples/rstream-dataflow/README.md index 41159d72c0..75da64947f 100644 --- a/examples/rstream-dataflow/README.md +++ b/examples/rstream-dataflow/README.md @@ -13,7 +13,7 @@ Installs all dependencies, runs `webpack-dev-server` and opens the app in your b ## About -![dataflow graph](../../assets/rs-dflow.png) +![dataflow graph](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/rs-dflow.png) This example combines the following packages to create & execute the above dataflow graph in a declarative manner. The diagram generation diff --git a/packages/associative/CHANGELOG.md b/packages/associative/CHANGELOG.md index 926a15260d..4c7a724220 100644 --- a/packages/associative/CHANGELOG.md +++ b/packages/associative/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.6.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@0.6.0...@thi.ng/associative@0.6.1) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/associative + # [0.6.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@0.5.11...@thi.ng/associative@0.6.0) (2018-08-24) diff --git a/packages/associative/package.json b/packages/associative/package.json index cad40e2e6f..419951e996 100644 --- a/packages/associative/package.json +++ b/packages/associative/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/associative", - "version": "0.6.0", + "version": "0.6.1", "description": "Alternative Set & Map data type implementations with customizable equality semantics & supporting operations", "main": "./index.js", "typings": "./index.d.ts", @@ -31,10 +31,10 @@ "@thi.ng/api": "^4.1.0", "@thi.ng/checks": "^1.5.7", "@thi.ng/compare": "^0.1.6", - "@thi.ng/dcons": "^1.1.0", + "@thi.ng/dcons": "^1.1.1", "@thi.ng/equiv": "^0.1.7", "@thi.ng/errors": "^0.1.6", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "data structures", diff --git a/packages/atom/CHANGELOG.md b/packages/atom/CHANGELOG.md index 5f933d0779..95d8d3780b 100644 --- a/packages/atom/CHANGELOG.md +++ b/packages/atom/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [1.5.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/atom@1.4.7...@thi.ng/atom@1.5.0) (2018-08-27) + + +### Features + +* **atom:** add .value accessor aliases (for deref()/reset()) ([a0cbd2b](https://github.com/thi-ng/umbrella/commit/a0cbd2b)) + + + + ## [1.4.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/atom@1.4.6...@thi.ng/atom@1.4.7) (2018-08-24) diff --git a/packages/atom/package.json b/packages/atom/package.json index 38788878d4..43bb6a58ef 100644 --- a/packages/atom/package.json +++ b/packages/atom/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/atom", - "version": "1.4.7", + "version": "1.5.0", "description": "Mutable wrapper for immutable values", "main": "./index.js", "typings": "./index.d.ts", diff --git a/packages/atom/src/atom.ts b/packages/atom/src/atom.ts index 90e7549118..888d2226cc 100644 --- a/packages/atom/src/atom.ts +++ b/packages/atom/src/atom.ts @@ -20,7 +20,7 @@ export class Atom implements IAtom, IEquiv { - protected value: T; + protected _value: T; protected valid: Predicate; protected _watches: any; @@ -28,12 +28,20 @@ export class Atom implements if (valid && !valid(val)) { illegalState("initial state value did not validate"); } - this.value = val; + this._value = val; this.valid = valid; } + get value() { + return this._value; + } + + set value(val: T) { + this.reset(val); + } + deref() { - return this.value; + return this._value; } equiv(o: any) { @@ -41,25 +49,25 @@ export class Atom implements } reset(val: T) { - const old = this.value; + const old = this._value; if (this.valid && !this.valid(val)) { return old; } - this.value = val; + this._value = val; this.notifyWatches(old, val); return val; } resetIn(path: Path, val: V) { - return this.reset(setIn(this.value, path, val)); + return this.reset(setIn(this._value, path, val)); } swap(fn: SwapFn, ...args: any[]) { - return this.reset(fn.apply(null, [this.value, ...args])); + return this.reset(fn.apply(null, [this._value, ...args])); } swapIn(path: Path, fn: SwapFn, ...args: any[]) { - return this.reset(updateIn(this.value, path, fn, ...args)); + return this.reset(updateIn(this._value, path, fn, ...args)); } // mixin stub @@ -84,7 +92,7 @@ export class Atom implements release() { delete this._watches; - delete this.value; + delete this._value; return true; } } diff --git a/packages/atom/src/cursor.ts b/packages/atom/src/cursor.ts index e873b7d3b4..04e74535d7 100644 --- a/packages/atom/src/cursor.ts +++ b/packages/atom/src/cursor.ts @@ -112,6 +112,14 @@ export class Cursor implements }); } + get value() { + return this.deref(); + } + + set value(val: T) { + this.reset(val); + } + deref() { return this.local.deref(); } diff --git a/packages/atom/src/history.ts b/packages/atom/src/history.ts index 97a1b9a52e..fe473c38ce 100644 --- a/packages/atom/src/history.ts +++ b/packages/atom/src/history.ts @@ -53,6 +53,14 @@ export class History implements this.clear(); } + get value() { + return this.deref(); + } + + set value(val: T) { + this.reset(val); + } + canUndo() { return this.history.length > 0; } diff --git a/packages/atom/src/view.ts b/packages/atom/src/view.ts index 20bfee3485..d0ae30f58c 100644 --- a/packages/atom/src/view.ts +++ b/packages/atom/src/view.ts @@ -88,6 +88,10 @@ export class View implements }); } + get value() { + return this.deref(); + } + /** * Returns view's value. If the view has a transformer, the * transformed value is returned. The transformer is only run once diff --git a/packages/cache/CHANGELOG.md b/packages/cache/CHANGELOG.md index c6f5008399..f3cd3aaa17 100644 --- a/packages/cache/CHANGELOG.md +++ b/packages/cache/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.18](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@0.2.17...@thi.ng/cache@0.2.18) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/cache + + +## [0.2.17](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@0.2.16...@thi.ng/cache@0.2.17) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/cache + ## [0.2.16](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@0.2.15...@thi.ng/cache@0.2.16) (2018-08-24) diff --git a/packages/cache/package.json b/packages/cache/package.json index 1c44a077f0..95a5da6556 100644 --- a/packages/cache/package.json +++ b/packages/cache/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/cache", - "version": "0.2.16", + "version": "0.2.18", "description": "In-memory cache implementations with ES6 Map-like API and different eviction strategies", "main": "./index.js", "typings": "./index.d.ts", @@ -29,8 +29,8 @@ }, "dependencies": { "@thi.ng/api": "^4.1.0", - "@thi.ng/dcons": "^1.1.0", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/dcons": "^1.1.1", + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "cache", diff --git a/packages/cache/src/lru.ts b/packages/cache/src/lru.ts index f937a2d199..4c03175270 100644 --- a/packages/cache/src/lru.ts +++ b/packages/cache/src/lru.ts @@ -39,16 +39,16 @@ export class LRUCache implements ICache { return this.entries(); } - *entries(): IterableIterator]>> { - yield* map((e) => <[K, CacheEntry]>[e.k, e], this.items); + entries(): IterableIterator]>> { + return map((e) => <[K, CacheEntry]>[e.k, e], this.items); } - *keys(): IterableIterator> { - yield* map((e) => e.k, this.items); + keys(): IterableIterator> { + return map((e) => e.k, this.items); } - *values(): IterableIterator> { - yield* map((e) => e.v, this.items); + values(): IterableIterator> { + return map((e) => e.v, this.items); } copy(): ICache { diff --git a/packages/csp/CHANGELOG.md b/packages/csp/CHANGELOG.md index ca122ed170..15be8c8c70 100644 --- a/packages/csp/CHANGELOG.md +++ b/packages/csp/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.3.57](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@0.3.56...@thi.ng/csp@0.3.57) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/csp + ## [0.3.56](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@0.3.55...@thi.ng/csp@0.3.56) (2018-08-24) diff --git a/packages/csp/package.json b/packages/csp/package.json index 8424e473ec..3c5373942c 100644 --- a/packages/csp/package.json +++ b/packages/csp/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/csp", - "version": "0.3.56", + "version": "0.3.57", "description": "ES6 promise based CSP implementation", "main": "./index.js", "typings": "./index.d.ts", @@ -34,9 +34,9 @@ "dependencies": { "@thi.ng/api": "^4.1.0", "@thi.ng/checks": "^1.5.7", - "@thi.ng/dcons": "^1.1.0", + "@thi.ng/dcons": "^1.1.1", "@thi.ng/errors": "^0.1.6", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "async", diff --git a/packages/dcons/CHANGELOG.md b/packages/dcons/CHANGELOG.md index ba6a2db6b2..6c23b1c57d 100644 --- a/packages/dcons/CHANGELOG.md +++ b/packages/dcons/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [1.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@1.1.0...@thi.ng/dcons@1.1.1) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/dcons + # [1.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@1.0.7...@thi.ng/dcons@1.1.0) (2018-08-24) diff --git a/packages/dcons/package.json b/packages/dcons/package.json index 8164a3bee9..da46f84b78 100644 --- a/packages/dcons/package.json +++ b/packages/dcons/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/dcons", - "version": "1.1.0", + "version": "1.1.1", "description": "Comprehensive doubly linked list structure w/ iterator support", "main": "./index.js", "typings": "./index.d.ts", @@ -33,7 +33,7 @@ "@thi.ng/compare": "^0.1.6", "@thi.ng/equiv": "^0.1.7", "@thi.ng/errors": "^0.1.6", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "datastructure", diff --git a/packages/dgraph/CHANGELOG.md b/packages/dgraph/CHANGELOG.md index cc7140eaae..1c3f7bb74e 100644 --- a/packages/dgraph/CHANGELOG.md +++ b/packages/dgraph/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@0.2.12...@thi.ng/dgraph@0.2.13) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/dgraph + ## [0.2.12](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@0.2.11...@thi.ng/dgraph@0.2.12) (2018-08-24) diff --git a/packages/dgraph/package.json b/packages/dgraph/package.json index 33ee783dd8..5407b22c52 100644 --- a/packages/dgraph/package.json +++ b/packages/dgraph/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/dgraph", - "version": "0.2.12", + "version": "0.2.13", "description": "Type-agnostic directed acyclic graph (DAG) & graph operations", "main": "./index.js", "typings": "./index.d.ts", @@ -29,10 +29,10 @@ }, "dependencies": { "@thi.ng/api": "^4.1.0", - "@thi.ng/associative": "^0.6.0", + "@thi.ng/associative": "^0.6.1", "@thi.ng/equiv": "^0.1.7", "@thi.ng/errors": "^0.1.6", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "data structure", diff --git a/packages/dot/CHANGELOG.md b/packages/dot/CHANGELOG.md index 25ae448527..946597a780 100644 --- a/packages/dot/CHANGELOG.md +++ b/packages/dot/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.1.12](https://github.com/thi-ng/umbrella/compare/@thi.ng/dot@0.1.11...@thi.ng/dot@0.1.12) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/dot + ## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/dot@0.1.10...@thi.ng/dot@0.1.11) (2018-08-24) diff --git a/packages/dot/README.md b/packages/dot/README.md index 8d3dce9dbc..aa5c62da3b 100644 --- a/packages/dot/README.md +++ b/packages/dot/README.md @@ -32,7 +32,7 @@ yarn add @thi.ng/dot ## Usage examples -![example graph](../../assets/dot-example.png) +![example graph](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/dot-example.png) The source code of this example is also available in [/test/example.ts](https://github.com/thi-ng/umbrella/tree/master/packages/dot/test/example.ts). diff --git a/packages/dot/package.json b/packages/dot/package.json index 1e957174df..75cf29fae8 100644 --- a/packages/dot/package.json +++ b/packages/dot/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/dot", - "version": "0.1.11", + "version": "0.1.12", "description": "Graphviz DOM abstraction as vanilla JS objects & serialization to DOT format", "main": "./index.js", "typings": "./index.d.ts", diff --git a/packages/hdom-components/CHANGELOG.md b/packages/hdom-components/CHANGELOG.md index 85010d8eb1..ea6adc4939 100644 --- a/packages/hdom-components/CHANGELOG.md +++ b/packages/hdom-components/CHANGELOG.md @@ -3,6 +3,30 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [2.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@2.1.13...@thi.ng/hdom-components@2.2.0) (2018-08-27) + + +### Bug Fixes + +* **hdom-components:** call canvas update from init() ([b25edbe](https://github.com/thi-ng/umbrella/commit/b25edbe)) + + +### Features + +* **hdom-components:** add HDPI adaptation helper for canvas comps ([135d6f1](https://github.com/thi-ng/umbrella/commit/135d6f1)) + + + + + +## [2.1.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@2.1.12...@thi.ng/hdom-components@2.1.13) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/hdom-components + ## [2.1.12](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@2.1.11...@thi.ng/hdom-components@2.1.12) (2018-08-24) diff --git a/packages/hdom-components/package.json b/packages/hdom-components/package.json index 6953e85b2e..1553a5e39b 100644 --- a/packages/hdom-components/package.json +++ b/packages/hdom-components/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/hdom-components", - "version": "2.1.12", + "version": "2.2.0", "description": "Raw, skinnable UI & SVG components for @thi.ng/hdom", "main": "./index.js", "typings": "./index.d.ts", @@ -30,7 +30,7 @@ "dependencies": { "@thi.ng/api": "^4.1.0", "@thi.ng/checks": "^1.5.7", - "@thi.ng/transducers": "^2.0.0", + "@thi.ng/transducers": "^2.0.1", "@types/webgl2": "^0.0.4" }, "keywords": [ diff --git a/packages/hdom-components/src/canvas.ts b/packages/hdom-components/src/canvas.ts index b836455f5c..8e5adca876 100644 --- a/packages/hdom-components/src/canvas.ts +++ b/packages/hdom-components/src/canvas.ts @@ -1,23 +1,28 @@ +export type CanvasContext = + CanvasRenderingContext2D | + WebGLRenderingContext | + WebGL2RenderingContext; + /** * User provided canvas life cycle methods. These differ from the usual * @thi.ng/hdom life cycle methods and are always passed at least the * canvas DOM element, canvas context and hdom user context. Not all * handlers need to be implemented. */ -export interface CanvasHandlers { +export interface CanvasHandlers { /** * user init handler (called only once when canvas first) */ - init: (el: HTMLCanvasElement, gl: T, hctx?: any, ...args: any[]) => void; + init: (el: HTMLCanvasElement, ctx: T, hctx?: any, ...args: any[]) => void; /** * update handler (called for each hdom update iteration) */ - update: (el: HTMLCanvasElement, gl: T, hctx?: any, time?: number, frame?: number, ...args: any[]) => void; + update: (el: HTMLCanvasElement, ctx: T, hctx?: any, time?: number, frame?: number, ...args: any[]) => void; /** * release handler (called only once when canvas element is removed * from DOM) */ - release: (el: HTMLCanvasElement, gl: T, hctx?: any, ...args: any[]) => void; + release: (el: HTMLCanvasElement, ctx: T, hctx?: any, ...args: any[]) => void; } /** @@ -35,9 +40,11 @@ const _canvas = (type, { init, update, release }: Partial>, return { init(_el: HTMLCanvasElement, hctx: any, ...args: any[]) { el = _el; + adaptDPI(el, el.width, el.height); ctx = el.getContext(type, opts); time = Date.now(); init && init(el, ctx, hctx, ...args); + update && update(el, ctx, hctx, time, frame++, ...args); }, render(hctx: any, ...args: any[]) { ctx && update && update(el, ctx, hctx, Date.now() - time, frame++, ...args); @@ -98,3 +105,23 @@ export const canvas2D = ( handlers: Partial>, opts?: Canvas2DContextAttributes) => _canvas("2d", handlers, opts); + +/** + * Sets the canvas size to given `width` & `height` and adjusts style to + * compensate for HDPI devices. Note: For 2D canvases, this will + * automatically clear any prior canvas content. + * + * @param canvas + * @param width uncompensated pixel width + * @param height uncompensated pixel height + */ +export const adaptDPI = (canvas: HTMLCanvasElement, width: number, height: number) => { + const dpr = window.devicePixelRatio || 1; + if (dpr != 1) { + canvas.style.width = `${width}px`; + canvas.style.height = `${height}px`; + } + canvas.width = width * dpr; + canvas.height = height * dpr; + return dpr; +}; diff --git a/packages/hdom/CHANGELOG.md b/packages/hdom/CHANGELOG.md index 08059f31a0..d3e2d4f3ce 100644 --- a/packages/hdom/CHANGELOG.md +++ b/packages/hdom/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [3.0.35](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@3.0.34...@thi.ng/hdom@3.0.35) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/hdom + + +## [3.0.34](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@3.0.33...@thi.ng/hdom@3.0.34) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/hdom + ## [3.0.33](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@3.0.32...@thi.ng/hdom@3.0.33) (2018-08-24) diff --git a/packages/hdom/README.md b/packages/hdom/README.md index 3564218db2..85f7a5ba30 100644 --- a/packages/hdom/README.md +++ b/packages/hdom/README.md @@ -132,7 +132,7 @@ JS arrays). Components can be defined as static arrays, closures or objects with [life cycle methods](#lifecycle-methods) (init, render, release). -![hdom dataflow](../../assets/hdom-dataflow.svg) +![hdom dataflow](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/hdom-dataflow.png) The syntax is inspired by Clojure's [Hiccup](https://github.com/weavejester/hiccup) and diff --git a/packages/hdom/package.json b/packages/hdom/package.json index 816558234d..f9e96fa785 100644 --- a/packages/hdom/package.json +++ b/packages/hdom/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/hdom", - "version": "3.0.33", + "version": "3.0.35", "description": "Lightweight vanilla ES6 UI component & virtual DOM system", "main": "./index.js", "typings": "./index.d.ts", @@ -20,7 +20,7 @@ "test": "rm -rf build && tsc -p test && nyc mocha build/test/*.js" }, "devDependencies": { - "@thi.ng/atom": "^1.4.7", + "@thi.ng/atom": "^1.5.0", "@types/mocha": "^5.2.5", "@types/node": "^10.5.5", "mocha": "^5.2.0", @@ -33,7 +33,7 @@ "@thi.ng/checks": "^1.5.7", "@thi.ng/diff": "^1.0.22", "@thi.ng/equiv": "^0.1.7", - "@thi.ng/hiccup": "^2.0.10" + "@thi.ng/hiccup": "^2.0.11" }, "keywords": [ "browser", diff --git a/packages/hiccup-css/CHANGELOG.md b/packages/hiccup-css/CHANGELOG.md index c00428584d..f2a0f5e5b1 100644 --- a/packages/hiccup-css/CHANGELOG.md +++ b/packages/hiccup-css/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.16](https://github.com/thi-ng/umbrella/compare/@thi.ng/hiccup-css@0.2.15...@thi.ng/hiccup-css@0.2.16) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/hiccup-css + ## [0.2.15](https://github.com/thi-ng/umbrella/compare/@thi.ng/hiccup-css@0.2.14...@thi.ng/hiccup-css@0.2.15) (2018-08-24) diff --git a/packages/hiccup-css/package.json b/packages/hiccup-css/package.json index 0521fd800c..751631f270 100644 --- a/packages/hiccup-css/package.json +++ b/packages/hiccup-css/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/hiccup-css", - "version": "0.2.15", + "version": "0.2.16", "description": "CSS from nested JS data structures", "main": "./index.js", "typings": "./index.d.ts", @@ -31,7 +31,7 @@ "@thi.ng/api": "^4.1.0", "@thi.ng/checks": "^1.5.7", "@thi.ng/errors": "^0.1.6", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "clojure", diff --git a/packages/hiccup-svg/CHANGELOG.md b/packages/hiccup-svg/CHANGELOG.md index 6395ebf2d5..a1d4ef8789 100644 --- a/packages/hiccup-svg/CHANGELOG.md +++ b/packages/hiccup-svg/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [1.0.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/hiccup-svg@1.0.10...@thi.ng/hiccup-svg@1.0.11) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/hiccup-svg + ## [1.0.10](https://github.com/thi-ng/umbrella/compare/@thi.ng/hiccup-svg@1.0.9...@thi.ng/hiccup-svg@1.0.10) (2018-08-24) diff --git a/packages/hiccup-svg/package.json b/packages/hiccup-svg/package.json index e7b8d23648..9791212072 100644 --- a/packages/hiccup-svg/package.json +++ b/packages/hiccup-svg/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/hiccup-svg", - "version": "1.0.10", + "version": "1.0.11", "description": "SVG element functions for @thi.ng/hiccup & @thi.ng/hdom", "main": "./index.js", "typings": "./index.d.ts", @@ -28,7 +28,7 @@ "typescript": "^3.0.1" }, "dependencies": { - "@thi.ng/hiccup": "^2.0.10" + "@thi.ng/hiccup": "^2.0.11" }, "keywords": [ "components", diff --git a/packages/hiccup/CHANGELOG.md b/packages/hiccup/CHANGELOG.md index 72b40acabe..6faeab98d4 100644 --- a/packages/hiccup/CHANGELOG.md +++ b/packages/hiccup/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [2.0.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/hiccup@2.0.10...@thi.ng/hiccup@2.0.11) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/hiccup + ## [2.0.10](https://github.com/thi-ng/umbrella/compare/@thi.ng/hiccup@2.0.9...@thi.ng/hiccup@2.0.10) (2018-08-24) diff --git a/packages/hiccup/package.json b/packages/hiccup/package.json index 38636e955e..3125db76db 100644 --- a/packages/hiccup/package.json +++ b/packages/hiccup/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/hiccup", - "version": "2.0.10", + "version": "2.0.11", "description": "HTML/SVG/XML serialization of nested data structures, iterables & closures", "main": "./index.js", "typings": "./index.d.ts", @@ -20,7 +20,7 @@ "test": "rm -rf build && tsc -p test && nyc mocha build/test/*.js" }, "devDependencies": { - "@thi.ng/atom": "^1.4.7", + "@thi.ng/atom": "^1.5.0", "@types/mocha": "^5.2.5", "@types/node": "^10.5.5", "mocha": "^5.2.0", diff --git a/packages/iges/CHANGELOG.md b/packages/iges/CHANGELOG.md index 1a9f9a3462..03e4c5923f 100644 --- a/packages/iges/CHANGELOG.md +++ b/packages/iges/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/iges@0.2.5...@thi.ng/iges@0.2.6) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/iges + ## [0.2.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/iges@0.2.4...@thi.ng/iges@0.2.5) (2018-08-24) diff --git a/packages/iges/README.md b/packages/iges/README.md index 109d22b29e..693513e4ee 100644 --- a/packages/iges/README.md +++ b/packages/iges/README.md @@ -11,7 +11,7 @@ Bare-bones IGES 5.3 serializer for (currently only) polygonal geometry, both open & closed, for use in various CAD applications (e.g. Rhino, Houdini, Fusion 360) -![houdini](../../assets/iges.png) +![houdini](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/iges.png) ## Installation diff --git a/packages/iges/package.json b/packages/iges/package.json index 31617e6a04..75069725b3 100644 --- a/packages/iges/package.json +++ b/packages/iges/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/iges", - "version": "0.2.5", + "version": "0.2.6", "description": "IGES 5.3 serializer for (currently only) polygonal geometry, both open & closed", "main": "./index.js", "typings": "./index.d.ts", @@ -31,7 +31,7 @@ "@thi.ng/api": "^4.1.0", "@thi.ng/defmulti": "^0.3.8", "@thi.ng/strings": "^0.3.0", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "CAD", diff --git a/packages/interceptors/CHANGELOG.md b/packages/interceptors/CHANGELOG.md index 634c7cb218..1fd6e192ea 100644 --- a/packages/interceptors/CHANGELOG.md +++ b/packages/interceptors/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [1.8.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/interceptors@1.8.10...@thi.ng/interceptors@1.8.11) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/interceptors + ## [1.8.10](https://github.com/thi-ng/umbrella/compare/@thi.ng/interceptors@1.8.9...@thi.ng/interceptors@1.8.10) (2018-08-24) diff --git a/packages/interceptors/package.json b/packages/interceptors/package.json index f7494db1b6..5feb96f74d 100644 --- a/packages/interceptors/package.json +++ b/packages/interceptors/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/interceptors", - "version": "1.8.10", + "version": "1.8.11", "description": "Interceptor based event bus, side effect & immutable state handling", "main": "./index.js", "typings": "./index.d.ts", @@ -29,7 +29,7 @@ }, "dependencies": { "@thi.ng/api": "^4.1.0", - "@thi.ng/atom": "^1.4.7", + "@thi.ng/atom": "^1.5.0", "@thi.ng/checks": "^1.5.7", "@thi.ng/errors": "^0.1.6", "@thi.ng/paths": "^1.5.2" diff --git a/packages/iterators/CHANGELOG.md b/packages/iterators/CHANGELOG.md index 2317d54fe0..fa3eb52510 100644 --- a/packages/iterators/CHANGELOG.md +++ b/packages/iterators/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [4.1.22](https://github.com/thi-ng/umbrella/compare/@thi.ng/iterators@4.1.21...@thi.ng/iterators@4.1.22) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/iterators + ## [4.1.21](https://github.com/thi-ng/umbrella/compare/@thi.ng/iterators@4.1.20...@thi.ng/iterators@4.1.21) (2018-08-24) diff --git a/packages/iterators/package.json b/packages/iterators/package.json index 19b86bc3a0..3da316fd33 100644 --- a/packages/iterators/package.json +++ b/packages/iterators/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/iterators", - "version": "4.1.21", + "version": "4.1.22", "description": "clojure.core inspired, composable ES6 iterators & generators", "main": "./index.js", "typings": "./index.d.ts", @@ -29,7 +29,7 @@ }, "dependencies": { "@thi.ng/api": "^4.1.0", - "@thi.ng/dcons": "^1.1.0", + "@thi.ng/dcons": "^1.1.1", "@thi.ng/errors": "^0.1.6" }, "keywords": [ diff --git a/packages/pointfree-lang/CHANGELOG.md b/packages/pointfree-lang/CHANGELOG.md index e49b8a5192..7f03c9b280 100644 --- a/packages/pointfree-lang/CHANGELOG.md +++ b/packages/pointfree-lang/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.19](https://github.com/thi-ng/umbrella/compare/@thi.ng/pointfree-lang@0.2.18...@thi.ng/pointfree-lang@0.2.19) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/pointfree-lang + ## [0.2.18](https://github.com/thi-ng/umbrella/compare/@thi.ng/pointfree-lang@0.2.17...@thi.ng/pointfree-lang@0.2.18) (2018-08-24) diff --git a/packages/pointfree-lang/README.md b/packages/pointfree-lang/README.md index aed9398619..4c433e5e79 100644 --- a/packages/pointfree-lang/README.md +++ b/packages/pointfree-lang/README.md @@ -78,7 +78,7 @@ example](https://github.com/thi-ng/umbrella/tree/master/examples/pointfree-svg/) generating the below SVG graphic is located in the `/examples` directory. -![generated example output](../../examples/pointfree-svg/output.svg) +![generated example output](https://raw.githubusercontent.com/thi-ng/umbrella/master/examples/pointfree-svg/output.svg) ```ts // DSL source code (syntax described further below) diff --git a/packages/pointfree-lang/package.json b/packages/pointfree-lang/package.json index 79a0b9a10d..6ea4b625e6 100644 --- a/packages/pointfree-lang/package.json +++ b/packages/pointfree-lang/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/pointfree-lang", - "version": "0.2.18", + "version": "0.2.19", "description": "Forth style syntax layer/compiler for the @thi.ng/pointfree DSL", "main": "./index.js", "typings": "./index.d.ts", diff --git a/packages/range-coder/CHANGELOG.md b/packages/range-coder/CHANGELOG.md index 880d6d27a2..077df4fc79 100644 --- a/packages/range-coder/CHANGELOG.md +++ b/packages/range-coder/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.1.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/range-coder@0.1.5...@thi.ng/range-coder@0.1.6) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/range-coder + ## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/range-coder@0.1.4...@thi.ng/range-coder@0.1.5) (2018-08-24) diff --git a/packages/range-coder/package.json b/packages/range-coder/package.json index 5562826539..e274eb5bf7 100644 --- a/packages/range-coder/package.json +++ b/packages/range-coder/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/range-coder", - "version": "0.1.5", + "version": "0.1.6", "description": "Binary data range encoder / decoder", "main": "./index.js", "typings": "./index.d.ts", @@ -20,7 +20,7 @@ "test": "rm -rf build && tsc -p test && nyc mocha build/test/*.js" }, "devDependencies": { - "@thi.ng/transducers": "^2.0.0", + "@thi.ng/transducers": "^2.0.1", "@types/mocha": "^5.2.5", "@types/node": "^10.5.5", "mocha": "^5.2.0", diff --git a/packages/rle-pack/CHANGELOG.md b/packages/rle-pack/CHANGELOG.md index 03bf012bd5..536f3e6998 100644 --- a/packages/rle-pack/CHANGELOG.md +++ b/packages/rle-pack/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/rle-pack@1.0.0...@thi.ng/rle-pack@1.0.1) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/rle-pack + # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/rle-pack@0.2.24...@thi.ng/rle-pack@1.0.0) (2018-08-24) diff --git a/packages/rle-pack/README.md b/packages/rle-pack/README.md index d2295b4a6f..ff3e2f9d6e 100644 --- a/packages/rle-pack/README.md +++ b/packages/rle-pack/README.md @@ -17,7 +17,7 @@ will be encoded using additional RLE chunks... ### Encoding format -![data layout](https://github.com/thi-ng/umbrella/tree/master/packages/assets/rle-layout.png) +![data layout](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/rle-layout.png) - 32 bits - original number of words - 5 bits - word size diff --git a/packages/rle-pack/package.json b/packages/rle-pack/package.json index 2e774dca28..873d0b513f 100644 --- a/packages/rle-pack/package.json +++ b/packages/rle-pack/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/rle-pack", - "version": "1.0.0", + "version": "1.0.1", "description": "Binary run-length encoding packer w/ flexible repeat bit widths", "main": "./index.js", "typings": "./index.d.ts", diff --git a/packages/rstream-csp/CHANGELOG.md b/packages/rstream-csp/CHANGELOG.md index f6fde73b09..04492c9f1d 100644 --- a/packages/rstream-csp/CHANGELOG.md +++ b/packages/rstream-csp/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.1.99](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-csp@0.1.98...@thi.ng/rstream-csp@0.1.99) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/rstream-csp + + +## [0.1.98](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-csp@0.1.97...@thi.ng/rstream-csp@0.1.98) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/rstream-csp + ## [0.1.97](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-csp@0.1.96...@thi.ng/rstream-csp@0.1.97) (2018-08-24) diff --git a/packages/rstream-csp/package.json b/packages/rstream-csp/package.json index 866e69e408..dd83557141 100644 --- a/packages/rstream-csp/package.json +++ b/packages/rstream-csp/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/rstream-csp", - "version": "0.1.97", + "version": "0.1.99", "description": "@thi.ng/csp bridge module for @thi.ng/rstream", "main": "./index.js", "typings": "./index.d.ts", @@ -28,8 +28,8 @@ "typescript": "^3.0.1" }, "dependencies": { - "@thi.ng/csp": "^0.3.56", - "@thi.ng/rstream": "^1.11.3" + "@thi.ng/csp": "^0.3.57", + "@thi.ng/rstream": "^1.11.5" }, "keywords": [ "bridge", diff --git a/packages/rstream-dot/CHANGELOG.md b/packages/rstream-dot/CHANGELOG.md index f1e83827ff..e0e4bb2628 100644 --- a/packages/rstream-dot/CHANGELOG.md +++ b/packages/rstream-dot/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.38](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-dot@0.2.37...@thi.ng/rstream-dot@0.2.38) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/rstream-dot + + +## [0.2.37](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-dot@0.2.36...@thi.ng/rstream-dot@0.2.37) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/rstream-dot + ## [0.2.36](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-dot@0.2.35...@thi.ng/rstream-dot@0.2.36) (2018-08-24) diff --git a/packages/rstream-dot/README.md b/packages/rstream-dot/README.md index 1971fa25c5..c97d80d924 100644 --- a/packages/rstream-dot/README.md +++ b/packages/rstream-dot/README.md @@ -73,7 +73,7 @@ dot -Tsvg -o graph.svg graph.dot This will generate this diagram: -![graphviz output](../../assets/rs-dot-example.svg) +![graphviz output](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/rs-dot-example.svg) ## Authors diff --git a/packages/rstream-dot/package.json b/packages/rstream-dot/package.json index 652290e6c8..e9db75386e 100644 --- a/packages/rstream-dot/package.json +++ b/packages/rstream-dot/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/rstream-dot", - "version": "0.2.36", + "version": "0.2.38", "description": "Graphviz DOT conversion of @thi.ng/rstream dataflow graph topologies", "main": "./index.js", "typings": "./index.d.ts", @@ -28,7 +28,7 @@ "typescript": "^3.0.1" }, "dependencies": { - "@thi.ng/rstream": "^1.11.3" + "@thi.ng/rstream": "^1.11.5" }, "keywords": [ "conversion", diff --git a/packages/rstream-gestures/CHANGELOG.md b/packages/rstream-gestures/CHANGELOG.md index 7d484d27f2..b35f45f3b2 100644 --- a/packages/rstream-gestures/CHANGELOG.md +++ b/packages/rstream-gestures/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [0.5.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-gestures@0.4.18...@thi.ng/rstream-gestures@0.5.0) (2018-08-27) + + +### Features + +* **rstream-gestures:** add options for local & scaled positions ([ccc40a9](https://github.com/thi-ng/umbrella/commit/ccc40a9)) + + + + + +## [0.4.18](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-gestures@0.4.17...@thi.ng/rstream-gestures@0.4.18) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/rstream-gestures + ## [0.4.17](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-gestures@0.4.16...@thi.ng/rstream-gestures@0.4.17) (2018-08-24) diff --git a/packages/rstream-gestures/package.json b/packages/rstream-gestures/package.json index 12679292c7..a3144c672b 100644 --- a/packages/rstream-gestures/package.json +++ b/packages/rstream-gestures/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/rstream-gestures", - "version": "0.4.17", + "version": "0.5.0", "description": "Unified mouse, mouse wheel & single-touch event stream abstraction", "main": "./index.js", "typings": "./index.d.ts", @@ -29,8 +29,8 @@ }, "dependencies": { "@thi.ng/api": "^4.1.0", - "@thi.ng/rstream": "^1.11.3", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/rstream": "^1.11.5", + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "dataflow", diff --git a/packages/rstream-gestures/src/index.ts b/packages/rstream-gestures/src/index.ts index 606be865e8..c7c2be9195 100644 --- a/packages/rstream-gestures/src/index.ts +++ b/packages/rstream-gestures/src/index.ts @@ -50,6 +50,17 @@ export interface GestureStreamOpts extends IID { * Scaling factor for zoom changes. Default: 1 */ smooth: number; + /** + * Local coordinate flag. If true (default), the elements position + * offset is subtracted. + */ + local: boolean; + /** + * If true (default: false), all positions and delta values are + * scaled by `window.devicePixelRatio`. Note: Only enable if `local` + * is true. + */ + scale: boolean; } /** @@ -80,7 +91,7 @@ export interface GestureStreamOpts extends IID { * @param el * @param opts */ -export function gestureStream(el: Element, opts?: Partial): StreamMerge { +export function gestureStream(el: HTMLElement, opts?: Partial): StreamMerge { let isDown = false, clickPos: number[]; opts = Object.assign({ @@ -91,8 +102,11 @@ export function gestureStream(el: Element, opts?: Partial): S smooth: 1, eventOpts: { capture: true }, preventDefault: true, + local: true, + scale: false, }, opts); let zoom = Math.min(Math.max(opts.zoom, opts.minZoom), opts.maxZoom); + const dpr = window.devicePixelRatio || 1; return merge({ id: opts.id, src: [ @@ -120,12 +134,18 @@ export function gestureStream(el: Element, opts?: Partial): S }[e.type]; evt = e; } - const pos = [evt.clientX | 0, evt.clientY | 0]; + const pos = opts.local ? + [(evt.clientX - el.offsetLeft) | 0, (evt.clientY - el.offsetTop) | 0] : + [evt.clientX | 0, evt.clientY | 0]; + if (opts.scale) { + pos[0] *= dpr; + pos[1] *= dpr; + } const body = { pos, zoom }; switch (type) { case GestureType.START: isDown = true; - clickPos = pos; + clickPos = [...pos]; break; case GestureType.END: isDown = false; diff --git a/packages/rstream-graph/CHANGELOG.md b/packages/rstream-graph/CHANGELOG.md index a528ca1fd7..0628fcad89 100644 --- a/packages/rstream-graph/CHANGELOG.md +++ b/packages/rstream-graph/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [2.1.23](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-graph@2.1.22...@thi.ng/rstream-graph@2.1.23) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/rstream-graph + + +## [2.1.22](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-graph@2.1.21...@thi.ng/rstream-graph@2.1.22) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/rstream-graph + ## [2.1.21](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-graph@2.1.20...@thi.ng/rstream-graph@2.1.21) (2018-08-24) diff --git a/packages/rstream-graph/package.json b/packages/rstream-graph/package.json index f20712229b..24fa506a0d 100644 --- a/packages/rstream-graph/package.json +++ b/packages/rstream-graph/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/rstream-graph", - "version": "2.1.21", + "version": "2.1.23", "description": "Declarative dataflow graph construction for @thi.ng/rstream", "main": "./index.js", "typings": "./index.d.ts", @@ -33,8 +33,8 @@ "@thi.ng/errors": "^0.1.6", "@thi.ng/paths": "^1.5.2", "@thi.ng/resolve-map": "^3.0.8", - "@thi.ng/rstream": "^1.11.3", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/rstream": "^1.11.5", + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "compute", diff --git a/packages/rstream-log/CHANGELOG.md b/packages/rstream-log/CHANGELOG.md index 3f27ca137d..ec33a1be0e 100644 --- a/packages/rstream-log/CHANGELOG.md +++ b/packages/rstream-log/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [1.0.50](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-log@1.0.49...@thi.ng/rstream-log@1.0.50) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/rstream-log + + +## [1.0.49](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-log@1.0.48...@thi.ng/rstream-log@1.0.49) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/rstream-log + ## [1.0.48](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-log@1.0.47...@thi.ng/rstream-log@1.0.48) (2018-08-24) diff --git a/packages/rstream-log/package.json b/packages/rstream-log/package.json index 07fb685a23..1c667e4844 100644 --- a/packages/rstream-log/package.json +++ b/packages/rstream-log/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/rstream-log", - "version": "1.0.48", + "version": "1.0.50", "description": "Structured, multilevel & hierarchical loggers based on @thi.ng/rstream", "main": "./index.js", "typings": "./index.d.ts", @@ -31,8 +31,8 @@ "@thi.ng/api": "^4.1.0", "@thi.ng/checks": "^1.5.7", "@thi.ng/errors": "^0.1.6", - "@thi.ng/rstream": "^1.11.3", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/rstream": "^1.11.5", + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "ES6", diff --git a/packages/rstream-query/CHANGELOG.md b/packages/rstream-query/CHANGELOG.md index 708db97bad..9d60464a7e 100644 --- a/packages/rstream-query/CHANGELOG.md +++ b/packages/rstream-query/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.3.37](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-query@0.3.36...@thi.ng/rstream-query@0.3.37) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/rstream-query + + +## [0.3.36](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-query@0.3.35...@thi.ng/rstream-query@0.3.36) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/rstream-query + ## [0.3.35](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-query@0.3.34...@thi.ng/rstream-query@0.3.35) (2018-08-24) diff --git a/packages/rstream-query/README.md b/packages/rstream-query/README.md index 4652db4a45..01d7b9afc7 100644 --- a/packages/rstream-query/README.md +++ b/packages/rstream-query/README.md @@ -160,7 +160,7 @@ addCity("paris", "france"); After setting up the above query and its internal transformations, the generated dataflow topology then looks as follows: -![graphviz output](../../assets/rs-query1.svg) +![graphviz output](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/rs-query1.svg) - The blue nodes are `TripleStore`-internal index stream sources, emitting changes when new triples are added @@ -174,7 +174,8 @@ Btw. The diagram has been generated using [@thi.ng/rstream-dot](https://github.com/thi-ng/umbrella/tree/master/packages/rstream-dot) and can be recreated by calling `store.toDot()` (for the above example) -The source code for the above example is [here](./test/example.ts) +The source code for the above example is +[here](https://github.com/thi-ng/umbrella/tree/master/packages/rstream-query/test/example.ts) (Many) more features forthcoming... diff --git a/packages/rstream-query/package.json b/packages/rstream-query/package.json index 33e2d6a79f..57c762f4f4 100644 --- a/packages/rstream-query/package.json +++ b/packages/rstream-query/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/rstream-query", - "version": "0.3.35", + "version": "0.3.37", "description": "@thi.ng/rstream based triple store & reactive query engine", "main": "./index.js", "typings": "./index.d.ts", @@ -29,13 +29,13 @@ }, "dependencies": { "@thi.ng/api": "^4.1.0", - "@thi.ng/associative": "^0.6.0", + "@thi.ng/associative": "^0.6.1", "@thi.ng/checks": "^1.5.7", "@thi.ng/equiv": "^0.1.7", "@thi.ng/errors": "^0.1.6", - "@thi.ng/rstream": "^1.11.3", - "@thi.ng/rstream-dot": "^0.2.36", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/rstream": "^1.11.5", + "@thi.ng/rstream-dot": "^0.2.38", + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "dataflow", diff --git a/packages/rstream/CHANGELOG.md b/packages/rstream/CHANGELOG.md index fc7355b6f0..d8899af456 100644 --- a/packages/rstream/CHANGELOG.md +++ b/packages/rstream/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [1.11.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream@1.11.4...@thi.ng/rstream@1.11.5) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/rstream + + +## [1.11.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream@1.11.3...@thi.ng/rstream@1.11.4) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/rstream + ## [1.11.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream@1.11.2...@thi.ng/rstream@1.11.3) (2018-08-24) diff --git a/packages/rstream/package.json b/packages/rstream/package.json index 00335485bf..8e4a029ae7 100644 --- a/packages/rstream/package.json +++ b/packages/rstream/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/rstream", - "version": "1.11.3", + "version": "1.11.5", "description": "Reactive multi-tap streams, dataflow & transformation pipeline constructs", "main": "./index.js", "typings": "./index.d.ts", @@ -29,12 +29,12 @@ }, "dependencies": { "@thi.ng/api": "^4.1.0", - "@thi.ng/associative": "^0.6.0", - "@thi.ng/atom": "^1.4.7", + "@thi.ng/associative": "^0.6.1", + "@thi.ng/atom": "^1.5.0", "@thi.ng/checks": "^1.5.7", "@thi.ng/errors": "^0.1.6", "@thi.ng/paths": "^1.5.2", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "datastructure", diff --git a/packages/rstream/src/stream-merge.ts b/packages/rstream/src/stream-merge.ts index 3e5f7a24d8..feb2415c2a 100644 --- a/packages/rstream/src/stream-merge.ts +++ b/packages/rstream/src/stream-merge.ts @@ -47,6 +47,24 @@ export interface StreamMergeOpts extends IID { * // 20 * // 30 * ``` + * + * Use the `labeled()` transducer for each input to create a stream of + * labeled values and track their provenance: + * + * ``` + * merge({ + * src: [ + * fromIterable([1,2,3]).transform(labeled("a")), + * fromIterable([10,20,30]).transform(labeled("b")), + * ] + * }).subscribe(trace()); + * // ["a", 1] + * // ["b", 10] + * // ["a", 2] + * // ["b", 20] + * // ["a", 3] + * // ["b", 30] + * ``` */ export function merge(opts?: Partial>) { return new StreamMerge(opts); diff --git a/packages/sax/CHANGELOG.md b/packages/sax/CHANGELOG.md index 1bd0161ab5..b77a2251b6 100644 --- a/packages/sax/CHANGELOG.md +++ b/packages/sax/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.3.15](https://github.com/thi-ng/umbrella/compare/@thi.ng/sax@0.3.14...@thi.ng/sax@0.3.15) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/sax + ## [0.3.14](https://github.com/thi-ng/umbrella/compare/@thi.ng/sax@0.3.13...@thi.ng/sax@0.3.14) (2018-08-24) diff --git a/packages/sax/package.json b/packages/sax/package.json index 0766781cac..52d927ee86 100644 --- a/packages/sax/package.json +++ b/packages/sax/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/sax", - "version": "0.3.14", + "version": "0.3.15", "description": "Transducer-based, SAX-like, non-validating, speedy & tiny XML parser", "main": "./index.js", "typings": "./index.d.ts", @@ -29,8 +29,8 @@ }, "dependencies": { "@thi.ng/api": "^4.1.0", - "@thi.ng/transducers": "^2.0.0", - "@thi.ng/transducers-fsm": "^0.2.13" + "@thi.ng/transducers": "^2.0.1", + "@thi.ng/transducers-fsm": "^0.2.14" }, "keywords": [ "ES6", diff --git a/packages/transducers-fsm/CHANGELOG.md b/packages/transducers-fsm/CHANGELOG.md index f792a5617b..7e2fcde8ef 100644 --- a/packages/transducers-fsm/CHANGELOG.md +++ b/packages/transducers-fsm/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.14](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-fsm@0.2.13...@thi.ng/transducers-fsm@0.2.14) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/transducers-fsm + ## [0.2.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-fsm@0.2.12...@thi.ng/transducers-fsm@0.2.13) (2018-08-24) diff --git a/packages/transducers-fsm/package.json b/packages/transducers-fsm/package.json index b14c8a38cc..d676a73f32 100644 --- a/packages/transducers-fsm/package.json +++ b/packages/transducers-fsm/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/transducers-fsm", - "version": "0.2.13", + "version": "0.2.14", "description": "Transducer-based Finite State Machine transformer", "main": "./index.js", "typings": "./index.d.ts", @@ -29,7 +29,7 @@ }, "dependencies": { "@thi.ng/api": "^4.1.0", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "ES6", diff --git a/packages/transducers-hdom/CHANGELOG.md b/packages/transducers-hdom/CHANGELOG.md index cb87b83d10..37c2809d1b 100644 --- a/packages/transducers-hdom/CHANGELOG.md +++ b/packages/transducers-hdom/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-hdom@0.1.4...@thi.ng/transducers-hdom@0.1.5) (2018-08-27) + + + + +**Note:** Version bump only for package @thi.ng/transducers-hdom + + +## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-hdom@0.1.3...@thi.ng/transducers-hdom@0.1.4) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/transducers-hdom + ## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-hdom@0.1.2...@thi.ng/transducers-hdom@0.1.3) (2018-08-24) diff --git a/packages/transducers-hdom/package.json b/packages/transducers-hdom/package.json index 4be9217b4b..a5544d104a 100644 --- a/packages/transducers-hdom/package.json +++ b/packages/transducers-hdom/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/transducers-hdom", - "version": "0.1.3", + "version": "0.1.5", "description": "Transducer based UI updater for @thi.ng/hdom", "main": "./index.js", "typings": "./index.d.ts", @@ -29,8 +29,8 @@ }, "dependencies": { "@thi.ng/checks": "^1.5.7", - "@thi.ng/hdom": "^3.0.33", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/hdom": "^3.0.35", + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "diff", diff --git a/packages/transducers-stats/CHANGELOG.md b/packages/transducers-stats/CHANGELOG.md index f1775eb0ff..1033c6651d 100644 --- a/packages/transducers-stats/CHANGELOG.md +++ b/packages/transducers-stats/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.4.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-stats@0.4.0...@thi.ng/transducers-stats@0.4.1) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/transducers-stats + # [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-stats@0.3.4...@thi.ng/transducers-stats@0.4.0) (2018-08-24) diff --git a/packages/transducers-stats/README.md b/packages/transducers-stats/README.md index f0bd784ef3..f2adeefb6a 100644 --- a/packages/transducers-stats/README.md +++ b/packages/transducers-stats/README.md @@ -33,19 +33,19 @@ transforming ES6 iterator (generator) instead of a transducer. ## Supported indicators -- [Bollinger Bands](./src/bollinger.ts) -- [Donchian Channel](./src/donchian.ts) -- [EMA (Exponential Moving Average)](./src/ema.ts) -- [HMA (Hull Moving Average)](./src/hma.ts) -- [MACD (Moving Average Convergence/Divergence)](./src/macd.ts) -- [Momentum](./src/momentum.ts) -- [ROC (Rate of change)](./src/roc.ts) -- [RSI (Relative Strength Index)](./src/rsi.ts) -- [SD (Standard Deviation)](./src/sd.ts) -- [SMA (Simple Moving Average)](./src/sma.ts) -- [Stochastic oscillator](./src/stochastic.ts) -- [TRIX (Triple smoothed EMA)](./src/trix.ts) -- [WMA (Weighted Moving Average)](./src/wma.ts) +- [Bollinger Bands](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/bollinger.ts) +- [Donchian Channel](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/donchian.ts) +- [EMA (Exponential Moving Average)](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/ema.ts) +- [HMA (Hull Moving Average)](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/hma.ts) +- [MACD (Moving Average Convergence/Divergence)](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/macd.ts) +- [Momentum](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/momentum.ts) +- [ROC (Rate of change)](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/roc.ts) +- [RSI (Relative Strength Index)](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/rsi.ts) +- [SD (Standard Deviation)](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/sd.ts) +- [SMA (Simple Moving Average)](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/sma.ts) +- [Stochastic oscillator](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/stochastic.ts) +- [TRIX (Triple smoothed EMA)](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/trix.ts) +- [WMA (Weighted Moving Average)](https://github.com/thi-ng/umbrella/tree/master/packages/transducers-stats/src/wma.ts) ## Installation @@ -59,7 +59,7 @@ For some realworld use, please see the [crypto chart](https://github.com/thi-ng/umbrella/tree/master/examples/crypto-chart) example. -![screenshot](https://github.com/thi-ng/umbrella/tree/master/assets/crypto-chart.png) +![screenshot](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/crypto-chart.png) ```ts import * as tx from "@thi.ng/transducers"; diff --git a/packages/transducers-stats/package.json b/packages/transducers-stats/package.json index 2a907ca967..e3a5cb865a 100644 --- a/packages/transducers-stats/package.json +++ b/packages/transducers-stats/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/transducers-stats", - "version": "0.4.0", + "version": "0.4.1", "description": "Transducers for statistical / technical analysis", "main": "./index.js", "typings": "./index.d.ts", @@ -28,9 +28,9 @@ "typescript": "^3.0.1" }, "dependencies": { - "@thi.ng/dcons": "^1.1.0", + "@thi.ng/dcons": "^1.1.1", "@thi.ng/errors": "^0.1.6", - "@thi.ng/transducers": "^2.0.0" + "@thi.ng/transducers": "^2.0.1" }, "keywords": [ "ES6", diff --git a/packages/transducers/CHANGELOG.md b/packages/transducers/CHANGELOG.md index dd2d1c5729..7dc8879d0c 100644 --- a/packages/transducers/CHANGELOG.md +++ b/packages/transducers/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers@2.0.0...@thi.ng/transducers@2.0.1) (2018-08-24) + + + + +**Note:** Version bump only for package @thi.ng/transducers + # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers@1.16.0...@thi.ng/transducers@2.0.0) (2018-08-24) diff --git a/packages/transducers/README.md b/packages/transducers/README.md index d82510fc60..cd070a5012 100644 --- a/packages/transducers/README.md +++ b/packages/transducers/README.md @@ -589,7 +589,7 @@ provided via implementations of the `IReducible` interface in the source collection type. Examples can be found here: - [DCons](https://github.com/thi-ng/umbrella/tree/master/packages/dcons/src/index.ts#L123) -- [SortedMap](https://github.com/thi-ng/umbrella/tree/master/packages/associative/src/index.ts#L261) +- [SortedMap](https://github.com/thi-ng/umbrella/tree/master/packages/associative/src/sorted-map.ts#L261) **Note:** The `IReducible` interface is only used by `reduce()`, `transduce()` and `run()`. @@ -688,95 +688,95 @@ tx.transduce(tx.map((x) => x*10), tx.push(), tx.range(4)) // [ 0, 10, 20, 30 ] ``` -- [base64Decode](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/base64.ts) -- [base64Encode](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/base64.ts) -- [benchmark](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/benchmark.ts) -- [bits](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/bits.ts) -- [cat](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/cat.ts) -- [convolve2d](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/convolve.ts) -- [dedupe](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/dedupe.ts) -- [delayed](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/delayed.ts) -- [distinct](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/distinct.ts) -- [dropNth](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/drop-nth.ts) -- [dropWhile](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/drop-while.ts) -- [drop](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/drop.ts) -- [duplicate](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/duplicate.ts) -- [filterFuzzy](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/filter-fuzzy.ts) -- [filter](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/filter.ts) -- [flattenWith](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/flatten-with.ts) -- [flatten](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/flatten.ts) -- [hexDump](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/hex-dump.ts) -- [indexed](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/indexed.ts) -- [interleave](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/interleave.ts) -- [interpose](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/interpose.ts) -- [keep](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/keep.ts) -- [labeled](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/labeled.ts) -- [mapDeep](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/map-deep.ts) -- [mapIndexed](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/map-indexed.ts) -- [mapKeys](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/map-keys.ts) -- [mapNth](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/map-nth.ts) -- [mapVals](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/map-vals.ts) -- [map](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/map.ts) -- [mapcat](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/mapcat.ts) -- [matchFirst](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/match-first.ts) -- [matchLast](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/match-last.ts) -- [movingAverage](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/moving-average.ts) -- [movingMedian](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/moving-median.ts) -- [multiplexObj](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/multiplex-obj.ts) -- [multiplex](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/multiplex.ts) -- [noop](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/noop.ts) -- [padLast](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/pad-last.ts) -- [page](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/page.ts) -- [partitionBits](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/partition-bits.ts) -- [partitionBy](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/partition-by.ts) -- [partitionOf](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/partition-of.ts) -- [partitionSort](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/partition-sort.ts) -- [partitionSync](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/partition-sync.ts) -- [partition](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/partition.ts) -- [pluck](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/pluck.ts) -- [rename](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/rename.ts) -- [sample](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/sample.ts) -- [scan](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/scan.ts) -- [selectKeys](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/select-keys.ts) -- [sideEffect](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/side-effect.ts) -- [streamShuffle](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/stream-shuffle.ts) -- [streamSort](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/stream-sort.ts) -- [struct](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/struct.ts) -- [swizzle](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/swizzle.ts) -- [takeLast](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/take-last.ts) -- [takeNth](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/take-nth.ts) -- [takeWhile](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/take-while.ts) -- [take](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/take.ts) -- [throttleTime](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/throttle-time.ts) -- [throttle](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/throttle.ts) -- [trace](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/trace.ts) -- [utf8Decode](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/utf8.ts) -- [utf8Encode](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/utf8.ts) -- [wordWrap](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/xform/word-wrap.ts) +- [base64Decode](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/base64.ts) +- [base64Encode](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/base64.ts) +- [benchmark](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/benchmark.ts) +- [bits](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/bits.ts) +- [cat](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/cat.ts) +- [convolve2d](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/convolve.ts) +- [dedupe](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/dedupe.ts) +- [delayed](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/delayed.ts) +- [distinct](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/distinct.ts) +- [dropNth](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/drop-nth.ts) +- [dropWhile](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/drop-while.ts) +- [drop](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/drop.ts) +- [duplicate](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/duplicate.ts) +- [filterFuzzy](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/filter-fuzzy.ts) +- [filter](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/filter.ts) +- [flattenWith](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/flatten-with.ts) +- [flatten](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/flatten.ts) +- [hexDump](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/hex-dump.ts) +- [indexed](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/indexed.ts) +- [interleave](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/interleave.ts) +- [interpose](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/interpose.ts) +- [keep](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/keep.ts) +- [labeled](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/labeled.ts) +- [mapDeep](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/map-deep.ts) +- [mapIndexed](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/map-indexed.ts) +- [mapKeys](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/map-keys.ts) +- [mapNth](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/map-nth.ts) +- [mapVals](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/map-vals.ts) +- [map](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/map.ts) +- [mapcat](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/mapcat.ts) +- [matchFirst](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/match-first.ts) +- [matchLast](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/match-last.ts) +- [movingAverage](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/moving-average.ts) +- [movingMedian](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/moving-median.ts) +- [multiplexObj](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/multiplex-obj.ts) +- [multiplex](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/multiplex.ts) +- [noop](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/noop.ts) +- [padLast](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/pad-last.ts) +- [page](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/page.ts) +- [partitionBits](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/partition-bits.ts) +- [partitionBy](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/partition-by.ts) +- [partitionOf](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/partition-of.ts) +- [partitionSort](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/partition-sort.ts) +- [partitionSync](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/partition-sync.ts) +- [partition](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/partition.ts) +- [pluck](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/pluck.ts) +- [rename](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/rename.ts) +- [sample](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/sample.ts) +- [scan](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/scan.ts) +- [selectKeys](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/select-keys.ts) +- [sideEffect](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/side-effect.ts) +- [streamShuffle](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/stream-shuffle.ts) +- [streamSort](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/stream-sort.ts) +- [struct](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/struct.ts) +- [swizzle](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/swizzle.ts) +- [takeLast](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/take-last.ts) +- [takeNth](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/take-nth.ts) +- [takeWhile](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/take-while.ts) +- [take](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/take.ts) +- [throttleTime](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/throttle-time.ts) +- [throttle](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/throttle.ts) +- [trace](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/trace.ts) +- [utf8Decode](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/utf8.ts) +- [utf8Encode](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/utf8.ts) +- [wordWrap](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/xform/word-wrap.ts) ### Generators / Iterators -- [choices](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/choices.ts) -- [concat](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/concat.ts) -- [cycle](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/cycle.ts) -- [iterate](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/iterate.ts) -- [keys](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/keys.ts) -- [normRange](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/normRange.ts) -- [pairs](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/pairs.ts) -- [permutations](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/permutations.ts) -- [permutationsN](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/permutationsN.ts) -- [range](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/range.ts) -- [range2d](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/range2d.ts) -- [range3d](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/range3d.ts) -- [repeat](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/repeat.ts) -- [repeatedly](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/repeatedly.ts) -- [reverse](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/reverse.ts) -- [tuples](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/tuples.ts) -- [vals](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/vals.ts) -- [wrapBoth](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/wrapBoth.ts) -- [wrapLeft](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/wrapLeft.ts) -- [wrapRight](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/wrapRight.ts) -- [wrap](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/iter/wrap.ts) +- [choices](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/choices.ts) +- [concat](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/concat.ts) +- [cycle](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/cycle.ts) +- [iterate](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/iterate.ts) +- [keys](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/keys.ts) +- [normRange](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/normRange.ts) +- [pairs](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/pairs.ts) +- [permutations](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/permutations.ts) +- [permutationsN](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/permutationsN.ts) +- [range](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/range.ts) +- [range2d](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/range2d.ts) +- [range3d](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/range3d.ts) +- [repeat](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/repeat.ts) +- [repeatedly](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/repeatedly.ts) +- [reverse](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/reverse.ts) +- [tuples](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/tuples.ts) +- [vals](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/vals.ts) +- [wrapBoth](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/wrapBoth.ts) +- [wrapLeft](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/wrapLeft.ts) +- [wrapRight](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/wrapRight.ts) +- [wrap](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/iter/wrap.ts) ### Reducers @@ -784,31 +784,31 @@ As with transducer functions, reducer functions can also given an optional input iterable. If done so, the function will consume the input and return a reduced result (as if it would be called via `reduce()`). -- [add](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/add) -- [assocMap](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/assoc-map) -- [assocObj](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/assoc-obj) -- [conj](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/conj) -- [count](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/count) -- [div](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/div) -- [every](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/every) -- [fill](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/fill) -- [frequencies](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/frequencies) -- [groupBinary](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/group-binary) -- [groupByMap](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/group-by-map) -- [groupByObj](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/group-by-obj) -- [last](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/last) -- [maxCompare](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/max-compare) -- [max](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/max) -- [mean](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/mean) -- [minCompare](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/min-compare) -- [min](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/min) -- [mul](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/mul) -- [pushCopy](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/push-copy) -- [push](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/push) -- [reductions](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/reductions) -- [some](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/some) -- [str](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/str) -- [sub](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/rfn/sub) +- [add](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/add) +- [assocMap](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/assoc-map) +- [assocObj](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/assoc-obj) +- [conj](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/conj) +- [count](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/count) +- [div](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/div) +- [every](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/every) +- [fill](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/fill) +- [frequencies](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/frequencies) +- [groupBinary](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/group-binary) +- [groupByMap](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/group-by-map) +- [groupByObj](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/group-by-obj) +- [last](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/last) +- [maxCompare](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/max-compare) +- [max](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/max) +- [mean](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/mean) +- [minCompare](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/min-compare) +- [min](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/min) +- [mul](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/mul) +- [pushCopy](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/push-copy) +- [push](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/push) +- [reductions](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/reductions) +- [some](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/some) +- [str](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/str) +- [sub](https://github.com/thi-ng/umbrella/tree/master/packages/transducers/src/rfn/sub) ## Authors diff --git a/packages/transducers/package.json b/packages/transducers/package.json index eb23621818..f517d30984 100644 --- a/packages/transducers/package.json +++ b/packages/transducers/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/transducers", - "version": "2.0.0", + "version": "2.0.1", "description": "Lightweight transducer implementations for ES6 / TypeScript", "main": "./index.js", "typings": "./index.d.ts", diff --git a/packages/vectors/CHANGELOG.md b/packages/vectors/CHANGELOG.md index db644ea934..c2b4bad8bf 100644 --- a/packages/vectors/CHANGELOG.md +++ b/packages/vectors/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/vectors@0.2.1...@thi.ng/vectors@0.3.0) (2018-08-27) + + +### Features + +* **vectors:** add mix1(), minor cleanups ([cfb2b74](https://github.com/thi-ng/umbrella/commit/cfb2b74)) + + + + ## [0.2.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/vectors@0.2.0...@thi.ng/vectors@0.2.1) (2018-08-24) diff --git a/packages/vectors/package.json b/packages/vectors/package.json index 6320e44fb6..4786bed2e9 100644 --- a/packages/vectors/package.json +++ b/packages/vectors/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/vectors", - "version": "0.2.1", + "version": "0.3.0", "description": "Vector algebra for fixed & variable sizes, memory mapped, flexible layouts", "main": "./index.js", "typings": "./index.d.ts", diff --git a/packages/vectors/src/math.ts b/packages/vectors/src/math.ts index 9f8d9fb182..c14330be94 100644 --- a/packages/vectors/src/math.ts +++ b/packages/vectors/src/math.ts @@ -48,7 +48,8 @@ export const eqDelta1 = (a: number, b: number, eps = EPS) => { * @param a * @param b */ -export const fmod1 = (a: number, b: number) => a - b * Math.floor(a / b); +export const fmod1 = (a: number, b: number) => + a - b * Math.floor(a / b); /** * Step/threshold function. @@ -57,7 +58,8 @@ export const fmod1 = (a: number, b: number) => a - b * Math.floor(a / b); * @param x test value * @returns 0, if `x < e`, else 1 */ -export const step1 = (edge: number, x: number) => x < edge ? 0 : 1; +export const step1 = (edge: number, x: number) => + x < edge ? 0 : 1; /** * GLSL-style smoothStep threshold function. @@ -72,7 +74,8 @@ export const smoothStep1 = (edge: number, edge2: number, x: number) => { return (3 - 2 * t) * t * t; }; -export const min2id = (a, b) => a <= b ? 0 : 1; +export const min2id = (a, b) => + a <= b ? 0 : 1; export const min3id = (a, b, c) => (a <= b) ? @@ -88,7 +91,8 @@ export const min4id = (a, b, c, d) => (b <= d ? 1 : 3) : (c <= d ? 2 : 3)); -export const max2id = (a, b) => a >= b ? 0 : 1; +export const max2id = (a, b) => + a >= b ? 0 : 1; export const max3id = (a, b, c) => (a >= b) ? @@ -114,6 +118,9 @@ export const max4id = (a, b, c, d) => export const clamp1 = (x: number, min: number, max: number) => x < min ? min : x > max ? max : x; +export const mix1 = (a: number, b: number, t: number) => + a + (b - a) * t; + export const fit1 = (x: number, a: number, b: number, c: number, d: number) => c + (d - c) * (x - a) / (b - a); diff --git a/scripts/make-module b/scripts/make-module index 9ce8e70bf2..431659b7db 100755 --- a/scripts/make-module +++ b/scripts/make-module @@ -55,7 +55,7 @@ cat << EOF > $MODULE/package.json "typescript": "^3.0.1" }, "dependencies": { - "@thi.ng/api": "^4.0.6" + "@thi.ng/api": "^4.1.0" }, "keywords": [ "ES6",