Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to decorators #6

Merged
merged 13 commits into from
Jul 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
},
"rules": {
"callback-return": "off",
"global-require": "off"
"global-require": "off",
"no-unused-vars": ["error", {
"args": "all",
"argsIgnorePattern": "^_[a-zA-Z]*$",
"caughtErrors": "all",
"caughtErrorsIgnorePattern": "^_[a-zA-Z]*$",
"vars": "all",
"varsIgnorePattern": "^_[a-zA-Z]*$"
}],
}
}
32,066 changes: 16,166 additions & 15,900 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"ts-loader": "^4.4.1",
"tslint": "^5.10.0",
"tslint-config-poetez": "^1.1.1",
"typescript": "^2.9.2",
"typescript": "^3.0.0-rc",
"universal-router": "^6.0.0",
"uuid": "^3.2.1",
"webpack": "^4.12.0"
Expand Down
45 changes: 30 additions & 15 deletions packages/context/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ describe("@corpuscule/context", () => {
providingValue,
} = createContext();

class TestProvider extends provider(BasicProvider) {
@provider
class TestProvider extends BasicProvider {
public static readonly is: string = `x-${uuid()}`;

protected [providingValue]: number = 2;
}

class TestConsumer extends consumer(BasicConsumer) {
@consumer
class TestConsumer extends BasicConsumer {
public static readonly is: string = `x-${uuid()}`;

protected [contextValue]?: number;
Expand All @@ -43,19 +45,22 @@ describe("@corpuscule/context", () => {
providingValue,
} = createContext();

class TestProvider extends provider(BasicProvider) {
@provider
class TestProvider extends BasicProvider {
public static readonly is: string = `x-${uuid()}`;

protected [providingValue]: number = 2;
}

class TestConsumer1 extends consumer(BasicConsumer) {
@consumer
class TestConsumer1 extends BasicConsumer {
public static readonly is: string = `x-${uuid()}`;

protected [contextValue]?: number;
}

class TestConsumer2 extends consumer(BasicConsumer) {
@consumer
class TestConsumer2 extends BasicConsumer {
public static readonly is: string = `x-${uuid()}`;

protected [contextValue]?: number;
Expand All @@ -74,11 +79,13 @@ describe("@corpuscule/context", () => {
provider,
} = createContext(5);

class TestProvider extends provider(BasicProvider) {
@provider
class TestProvider extends BasicProvider {
public static readonly is: string = `x-${uuid()}`;
}

class TestConsumer extends consumer(BasicConsumer) {
@consumer
class TestConsumer extends BasicConsumer {
public static readonly is: string = `x-${uuid()}`;

protected [contextValue]?: number;
Expand All @@ -97,13 +104,15 @@ describe("@corpuscule/context", () => {
providingValue,
} = createContext();

class TestProvider extends provider(BasicProvider) {
@provider
class TestProvider extends BasicProvider {
public static readonly is: string = `x-${uuid()}`;

protected [providingValue]: number = 2;
}

class TestConsumer extends consumer(BasicConsumer) {
@consumer
class TestConsumer extends BasicConsumer {
public static readonly is: string = `x-${uuid()}`;

protected [contextValue]?: number;
Expand All @@ -128,7 +137,8 @@ describe("@corpuscule/context", () => {
providingValue,
} = createContext();

class TestProvider extends provider(BasicProvider) {
@provider
class TestProvider extends BasicProvider {
public static readonly is: string = `x-${uuid()}`;

protected [providingValue]: number = 2;
Expand All @@ -143,7 +153,8 @@ describe("@corpuscule/context", () => {
}
}

class TestConsumer extends consumer(BasicConsumer) {
@consumer
class TestConsumer extends BasicConsumer {
public static readonly is: string = `x-${uuid()}`;

protected [contextValue]?: number;
Expand Down Expand Up @@ -173,19 +184,22 @@ describe("@corpuscule/context", () => {
providingValue,
} = createContext();

class TestProvider extends provider(BasicProvider) {
@provider
class TestProvider extends BasicProvider {
public static readonly is: string = `x-${uuid()}`;

protected [providingValue]: number = 2;
}

class TestConsumer1 extends consumer(BasicConsumer) {
@consumer
class TestConsumer1 extends BasicConsumer {
public static readonly is: string = `x-${uuid()}`;

protected [contextValue]?: number;
}

class TestConsumer2 extends consumer(BasicConsumer) {
@consumer
class TestConsumer2 extends BasicConsumer {
public static readonly is: string = `x-${uuid()}`;

protected [contextValue]?: number;
Expand All @@ -208,7 +222,8 @@ describe("@corpuscule/context", () => {
// contextValue,
// } = createContext();
//
// class TestConsumer extends consumer(HTMLElement) {
// @consumer
// class TestConsumer extends HTMLElement {
// public static readonly is: string = `x-${uuid()}`;
//
// public [contextValue]?: number;
Expand Down
5 changes: 1 addition & 4 deletions packages/context/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@corpuscule/context",
"version": "0.3.1",
"version": "0.4.0",
"description": "DOM-dependent context for Corpuscule",
"main": "lib/index.js",
"module": "lib/index.js",
Expand All @@ -14,8 +14,5 @@
"repository": {
"type": "git",
"url": "git+https://github.com/corpusculejs/corpuscule.git"
},
"dependencies": {
"@corpuscule/typings": "^0.2.0"
}
}
6 changes: 2 additions & 4 deletions packages/context/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {CustomElementClass, UncertainCustomElementClass} from "@corpuscule/typings";

declare const createContext: <T>(defaultValue?: T) => {
readonly consumer: <T = {}>(target: UncertainCustomElementClass<T>) => CustomElementClass<T>;
readonly consumer: ClassDecorator;
readonly contextValue: "contextValue"; // hack to resolve unique symbol widening
readonly provider: <T = {}>(target: UncertainCustomElementClass<T>) => CustomElementClass<T>;
readonly provider: ClassDecorator;
readonly providingValue: "providingValue"; // hack to resolve unique symbol widening
};

Expand Down