Skip to content

Commit

Permalink
build: prep api, atom, bench, binary, checks, equiv, errors, paths fo…
Browse files Browse the repository at this point in the history
…r multi outputs

- update tsconfig files for ES6 module output
- update build scripts in these 8 modules
- update atom: Cursor/View NEXT_ID, replace w/ nextID() helper fn
- update various tests
- update .*ignore files
  • Loading branch information
postspectacular committed Jan 7, 2019
1 parent d1e275b commit 4be67c5
Show file tree
Hide file tree
Showing 48 changed files with 476 additions and 312 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.cache
.nyc_output
coverage
build
Expand Down
9 changes: 6 additions & 3 deletions packages/api/.npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
.cache
.nyc_output
*.gz
*.html
*.tgz
build
coverage
dev
doc
src*
test
.nyc_output
*.tgz
*.html
tsconfig.json
22 changes: 17 additions & 5 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "@thi.ng/api",
"version": "4.2.4",
"description": "Common, generic types & interfaces for thi.ng projects",
"main": "./index.js",
"main": "./lib/index.js",
"module": "./index.js",
"typings": "./index.d.ts",
"repository": {
"type": "git",
Expand All @@ -12,12 +13,16 @@
"author": "Karsten Schmidt <[email protected]>",
"license": "Apache-2.0",
"scripts": {
"build": "yarn clean && tsc --declaration",
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc decorators mixins",
"build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min",
"build:es6": "tsc --declaration",
"build:parcel:min": "parcel build --global thing_api -o index.min.js -d lib --experimental-scope-hoisting src/index.ts",
"build:parcel": "parcel build --global thing_api -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js",
"build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz",
"clean": "rimraf *.js *.d.ts .cache .nyc_output build coverage doc lib",
"test": "rimraf build && parcel build -d build --no-cache --no-minify --no-source-maps test/index.ts && nyc mocha build/index.js",
"cover": "yarn test && nyc report --reporter=lcov",
"doc": "node_modules/.bin/typedoc --mode modules --out doc src",
"pub": "yarn build && yarn publish --access public",
"test": "rimraf build && tsc -p test && nyc mocha build/test/*.js"
"pub": "yarn build && yarn publish --access public"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
Expand All @@ -42,5 +47,12 @@
],
"publishConfig": {
"access": "public"
},
"browserslist": [
"since 2018-07"
],
"browser": {
"process": false,
"setTimeout": false
}
}
2 changes: 1 addition & 1 deletion packages/api/src/decorators/deprecated.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { illegalArgs } from "@thi.ng/errors";
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";

/**
* Method property decorator factory. Augments original method with
Expand Down
1 change: 1 addition & 0 deletions packages/api/test/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./mixins";
4 changes: 3 additions & 1 deletion packages/api/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "../build"
"outDir": "../build",
"module": "es6",
"target": "es6"
},
"include": [
"./**/*.ts",
Expand Down
4 changes: 3 additions & 1 deletion packages/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "."
"outDir": ".",
"module": "es6",
"target": "es6"
},
"include": [
"./src/**/*.ts"
Expand Down
8 changes: 5 additions & 3 deletions packages/atom/.npmignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.cache
.nyc_output
*.gz
*.html
*.tgz
build
coverage
dev
doc
src*
test
.nyc_output
tsconfig.json
*.tgz
*.html
28 changes: 21 additions & 7 deletions packages/atom/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "@thi.ng/atom",
"version": "1.5.8",
"description": "Mutable wrapper for immutable values",
"main": "./index.js",
"description": "Mutable wrappers for nested immutable values w/ optional undo/redo history",
"module": "./index.js",
"main": "./lib/index.js",
"typings": "./index.d.ts",
"repository": {
"type": "git",
Expand All @@ -12,12 +13,16 @@
"author": "Karsten Schmidt <[email protected]>",
"license": "Apache-2.0",
"scripts": {
"build": "yarn clean && tsc --declaration",
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc",
"build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min",
"build:es6": "tsc --declaration",
"build:parcel:min": "parcel build --global thing_atom -o index.min.js -d lib --experimental-scope-hoisting src/index.ts",
"build:parcel": "parcel build --global thing_atom -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js",
"build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz",
"clean": "rimraf *.js *.d.ts .cache .nyc_output build coverage doc lib",
"test": "rimraf build && parcel build -d build --no-cache --no-minify --no-source-maps test/index.ts && nyc mocha build/index.js",
"cover": "yarn test && nyc report --reporter=lcov",
"doc": "typedoc --mode modules --out doc src",
"pub": "yarn build && yarn publish --access public",
"test": "rimraf build && tsc -p test && nyc mocha build/test/*.js"
"pub": "yarn build && yarn publish --access public"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
Expand All @@ -35,15 +40,24 @@
"@thi.ng/paths": "^1.6.6"
},
"keywords": [
"derived views",
"cursor",
"datastructure",
"data structure",
"ES6",
"history",
"immutable",
"redo",
"typescript",
"undo"
],
"publishConfig": {
"access": "public"
},
"browserslist": [
"since 2018-07"
],
"browser": {
"process": false,
"setTimeout": false
}
}
6 changes: 3 additions & 3 deletions packages/atom/src/atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ export class Atom<T> implements

// mixin stub
/* istanbul ignore next */
addWatch(id: string, fn: Watch<T>) {
addWatch(_: string, __: Watch<T>) {
return false;
}

// mixin stub
/* istanbul ignore next */
removeWatch(id: string) {
removeWatch(_: string) {
return false;
}

// mixin stub
/* istanbul ignore next */
notifyWatches(oldState: T, newState: T) { }
notifyWatches(_: T, __: T) { }

addView<V>(path: Path, tx?: ViewTransform<V>, lazy = true): IView<V> {
return new View<V>(this, path, tx, lazy);
Expand Down
7 changes: 2 additions & 5 deletions packages/atom/src/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { isFunction } from "@thi.ng/checks/is-function";
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
import { illegalArity } from "@thi.ng/errors/illegal-arity";
import { getter, Path, setter } from "@thi.ng/paths";

import {
CursorOpts,
IAtom,
Expand All @@ -13,9 +12,9 @@ import {
ViewTransform
} from "./api";
import { Atom } from "./atom";
import { nextID } from "./idgen";
import { View } from "./view";


/**
* A cursor provides read/write access to a path location within a
* nested parent state (Atom or another Cursor). Cursors behave like
Expand Down Expand Up @@ -46,8 +45,6 @@ export class Cursor<T> implements
IID<string>,
IRelease {

static NEXT_ID = 0;

readonly id: string;
parent: IAtom<any>;

Expand Down Expand Up @@ -89,7 +86,7 @@ export class Cursor<T> implements
illegalArity(args.length);
}
this.parent = parent;
this.id = id || `cursor-${Cursor.NEXT_ID++}`;
this.id = id || `cursor-${nextID()}`;
this.selfUpdate = false;
if (!lookup || !update) {
illegalArgs();
Expand Down
6 changes: 3 additions & 3 deletions packages/atom/src/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ export class History<T> implements
return true;
}

addListener(id: string, fn: (e: Event) => void, scope?: any): boolean {
addListener(_: string, __: (e: Event) => void, ___?: any): boolean {
return false;
}

removeListener(id: string, fn: (e: Event) => void, scope?: any): boolean {
removeListener(_: string, __: (e: Event) => void, ___?: any): boolean {
return false;
}

notify(event: Event): void {
notify(_: Event): void {
}
}
3 changes: 3 additions & 0 deletions packages/atom/src/idgen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let NEXT_ID = 0;

export const nextID = () => NEXT_ID++;
6 changes: 2 additions & 4 deletions packages/atom/src/view.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { equiv as _equiv } from "@thi.ng/equiv";
import { getter, Path, toPath } from "@thi.ng/paths";

import { IView, ReadonlyAtom, ViewTransform } from "./api";
import { nextID } from "./idgen";

/**
* This class implements readonly access to a deeply nested value with
Expand Down Expand Up @@ -47,8 +47,6 @@ import { IView, ReadonlyAtom, ViewTransform } from "./api";
export class View<T> implements
IView<T> {

protected static NEXT_ID = 0;

readonly id: string;

readonly parent: ReadonlyAtom<any>;
Expand All @@ -62,7 +60,7 @@ export class View<T> implements

constructor(parent: ReadonlyAtom<any>, path: Path, tx?: ViewTransform<T>, lazy = true, equiv = _equiv) {
this.parent = parent;
this.id = `view-${View.NEXT_ID++}`;
this.id = `view-${nextID()}`;
this.tx = tx || ((x: any) => x);
this.path = toPath(path);
this.isDirty = true;
Expand Down
12 changes: 6 additions & 6 deletions packages/atom/test/atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe("atom", function () {
});

it("can be equiv'd", () => {
assert(a.equiv(a));
assert(!a.equiv(new Atom(23)));
assert.ok(a.equiv(a));
assert.ok(!a.equiv(new Atom(23)));
});

it("can be reset", () => {
Expand All @@ -30,10 +30,10 @@ describe("atom", function () {
});

it("can add & remove watch", () => {
assert(a.addWatch("foo", () => { }), "can't add watch");
assert((<any>a)._watches && (<any>a)._watches.foo, "watch missing");
assert(a.removeWatch("foo"), "can't remove watch");
assert(!a.removeWatch("foo"), "should fail to remove invalid watch id");
assert.ok(a.addWatch("foo", () => { }), "can't add watch");
assert.ok((<any>a)._watches && (<any>a)._watches.foo, "watch missing");
assert.ok(a.removeWatch("foo"), "can't remove watch");
assert.ok(!a.removeWatch("foo"), "should fail to remove invalid watch id");
});

it("can be watched", () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/atom/test/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,17 @@ describe("cursor", function () {
c = new Cursor(a, "a");
let id = c.id;
assert.notEqual((<any>a)._watches[id], null);
assert(c.release());
assert.ok(c.release());
assert.strictEqual(c.parent, undefined);
assert.strictEqual((<any>a)._watches[id], undefined);
});

it("can add & remove watch", () => {
c = new Cursor(a, "a.b.c");
assert(c.addWatch("foo", () => { }), "can't add watch");
assert((<any>c).local._watches && (<any>c).local._watches.foo, "watch missing");
assert(c.removeWatch("foo"), "can't remove watch");
assert(!c.removeWatch("foo"), "should fail to remove invalid watch id");
assert.ok(c.addWatch("foo", () => { }), "can't add watch");
assert.ok((<any>c).local._watches && (<any>c).local._watches.foo, "watch missing");
assert.ok(c.removeWatch("foo"), "can't remove watch");
assert.ok(!c.removeWatch("foo"), "should fail to remove invalid watch id");
});

it("can be watched", () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/atom/test/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./atom";
export * from "./cursor";
export * from "./history";
export * from "./view";
3 changes: 2 additions & 1 deletion packages/atom/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "../build",
"noUnusedParameters": false
"module": "es6",
"target": "es6"
},
"include": [
"./**/*.ts",
Expand Down
Loading

0 comments on commit 4be67c5

Please sign in to comment.