react-obsidian 0.0.6 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +3 -2
- package/README.md +7 -0
- package/dist/src/Obsidian.d.ts +2 -2
- package/dist/src/Obsidian.d.ts.map +1 -1
- package/dist/src/ProvidedPropertiesStore.d.ts +1 -1
- package/dist/src/ProvidedPropertiesStore.d.ts.map +1 -1
- package/dist/src/decorators/Graph.d.ts +2 -2
- package/dist/src/decorators/Graph.d.ts.map +1 -1
- package/dist/src/decorators/Graph.js +2 -1
- package/dist/src/decorators/Graph.js.map +1 -1
- package/dist/src/decorators/Memoize.d.ts +3 -0
- package/dist/src/decorators/Memoize.d.ts.map +1 -0
- package/dist/src/decorators/Memoize.js +21 -0
- package/dist/src/decorators/Memoize.js.map +1 -0
- package/dist/src/decorators/injectClass.d.ts +1 -1
- package/dist/src/decorators/injectClass.d.ts.map +1 -1
- package/dist/src/decorators/provides/MemoizeDescriptor.d.ts +2 -0
- package/dist/src/decorators/provides/MemoizeDescriptor.d.ts.map +1 -0
- package/dist/src/decorators/provides/MemoizeDescriptor.js +23 -0
- package/dist/src/decorators/provides/MemoizeDescriptor.js.map +1 -0
- package/dist/src/decorators/provides/Provides.d.ts +3 -3
- package/dist/src/decorators/provides/Provides.d.ts.map +1 -1
- package/dist/src/decorators/provides/Provides.js +4 -3
- package/dist/src/decorators/provides/Provides.js.map +1 -1
- package/dist/src/graph/Graph.d.ts +1 -2
- package/dist/src/graph/Graph.d.ts.map +1 -1
- package/dist/src/graph/ObjectGraph.d.ts +4 -4
- package/dist/src/graph/ObjectGraph.d.ts.map +1 -1
- package/dist/src/graph/ObjectGraph.js +23 -5
- package/dist/src/graph/ObjectGraph.js.map +1 -1
- package/dist/src/graph/PropertyRetriever.d.ts +1 -1
- package/dist/src/graph/PropertyRetriever.d.ts.map +1 -1
- package/dist/src/graph/registry/DefaultGraphResolver.d.ts +5 -4
- package/dist/src/graph/registry/DefaultGraphResolver.d.ts.map +1 -1
- package/dist/src/graph/registry/DefaultGraphResolver.js +2 -2
- package/dist/src/graph/registry/DefaultGraphResolver.js.map +1 -1
- package/dist/src/graph/registry/GraphMiddleware.d.ts +4 -10
- package/dist/src/graph/registry/GraphMiddleware.d.ts.map +1 -1
- package/dist/src/graph/registry/GraphMiddleware.js +20 -17
- package/dist/src/graph/registry/GraphMiddleware.js.map +1 -1
- package/dist/src/graph/registry/GraphMiddlewareChain.d.ts +6 -6
- package/dist/src/graph/registry/GraphMiddlewareChain.d.ts.map +1 -1
- package/dist/src/graph/registry/GraphMiddlewareChain.js.map +1 -1
- package/dist/src/graph/registry/GraphRegistry.d.ts +3 -3
- package/dist/src/graph/registry/GraphRegistry.d.ts.map +1 -1
- package/dist/src/graph/registry/GraphRegistry.js.map +1 -1
- package/dist/src/graph/registry/GraphResolveChain.d.ts +4 -0
- package/dist/src/graph/registry/GraphResolveChain.d.ts.map +1 -0
- package/dist/src/graph/registry/GraphResolveChain.js +3 -0
- package/dist/src/graph/registry/GraphResolveChain.js.map +1 -0
- package/dist/src/graph/registry/Middleware.d.ts +10 -0
- package/dist/src/graph/registry/Middleware.d.ts.map +1 -0
- package/dist/src/graph/registry/Middleware.js +25 -0
- package/dist/src/graph/registry/Middleware.js.map +1 -0
- package/dist/src/graph/registry/ResolveChain.d.ts +5 -0
- package/dist/src/graph/registry/ResolveChain.d.ts.map +1 -0
- package/dist/src/graph/registry/ResolveChain.js +3 -0
- package/dist/src/graph/registry/ResolveChain.js.map +1 -0
- package/dist/src/index.d.ts +13 -13
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +15 -12
- package/dist/src/index.js.map +1 -1
- package/dist/src/injectors/components/ComponentInjector.d.ts +1 -1
- package/dist/src/injectors/components/ComponentInjector.d.ts.map +1 -1
- package/dist/src/injectors/components/PropsInjector.d.ts +1 -1
- package/dist/src/injectors/components/PropsInjector.d.ts.map +1 -1
- package/dist/src/injectors/components/useGraph.d.ts +1 -1
- package/dist/src/injectors/components/useGraph.d.ts.map +1 -1
- package/dist/src/injectors/hooks/HookInjector.d.ts +1 -1
- package/dist/src/injectors/hooks/HookInjector.d.ts.map +1 -1
- package/dist/src/utils/autobind.d.ts +2 -0
- package/dist/src/utils/autobind.d.ts.map +1 -0
- package/dist/src/utils/autobind.js +19 -0
- package/dist/src/utils/autobind.js.map +1 -0
- package/dist/test/integration/fixtures/Subgraph.d.ts +1 -0
- package/dist/test/integration/fixtures/Subgraph.d.ts.map +1 -1
- package/dist/test/integration/fixtures/Subgraph.js +11 -1
- package/dist/test/integration/fixtures/Subgraph.js.map +1 -1
- package/dist/testkit/index.d.ts +1 -2
- package/dist/testkit/index.d.ts.map +1 -1
- package/dist/testkit/index.js +1 -2
- package/dist/testkit/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Obsidian.ts +2 -2
- package/src/ProvidedPropertiesStore.ts +1 -1
- package/src/decorators/Graph.ts +2 -2
- package/src/decorators/Memoize.ts +18 -0
- package/src/decorators/injectClass.ts +1 -1
- package/src/decorators/provides/MemoizeDescriptor.ts +14 -0
- package/src/decorators/provides/Provides.ts +4 -5
- package/src/graph/Graph.ts +1 -3
- package/src/graph/ObjectGraph.ts +11 -5
- package/src/graph/PropertyRetriever.ts +1 -1
- package/src/graph/registry/DefaultGraphResolver.ts +5 -4
- package/src/graph/registry/GraphMiddleware.ts +4 -23
- package/src/graph/registry/GraphMiddlewareChain.ts +7 -7
- package/src/graph/registry/GraphRegistry.ts +4 -4
- package/src/graph/registry/GraphResolveChain.ts +4 -0
- package/src/graph/registry/Middleware.ts +21 -0
- package/src/graph/registry/ResolveChain.ts +5 -0
- package/src/index.ts +16 -16
- package/src/injectors/components/ComponentInjector.tsx +1 -1
- package/src/injectors/components/PropsInjector.ts +1 -1
- package/src/injectors/components/useGraph.ts +1 -1
- package/src/injectors/hooks/HookInjector.ts +2 -2
- package/src/utils/autobind.ts +12 -0
- package/testkit/index.ts +9 -5
- package/dist/src/decorators/provides/PropertyDescriptorToSingleton.d.ts +0 -2
- package/dist/src/decorators/provides/PropertyDescriptorToSingleton.d.ts.map +0 -1
- package/dist/src/decorators/provides/PropertyDescriptorToSingleton.js +0 -20
- package/dist/src/decorators/provides/PropertyDescriptorToSingleton.js.map +0 -1
- package/src/decorators/provides/PropertyDescriptorToSingleton.ts +0 -11
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Middleware = void 0;
|
|
4
|
+
var Middleware = /** @class */ (function () {
|
|
5
|
+
function Middleware() {
|
|
6
|
+
}
|
|
7
|
+
Middleware.prototype.setNext = function (next) {
|
|
8
|
+
this.next = next;
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(Middleware.prototype, "resolveChain", {
|
|
11
|
+
get: function () {
|
|
12
|
+
var _this = this;
|
|
13
|
+
return {
|
|
14
|
+
proceed: function (Graph, props) {
|
|
15
|
+
return _this.next.resolve(_this.next.resolveChain, Graph, props);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
enumerable: false,
|
|
20
|
+
configurable: true
|
|
21
|
+
});
|
|
22
|
+
return Middleware;
|
|
23
|
+
}());
|
|
24
|
+
exports.Middleware = Middleware;
|
|
25
|
+
//# sourceMappingURL=Middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Middleware.js","sourceRoot":"","sources":["../../../../src/graph/registry/Middleware.ts"],"names":[],"mappings":";;;AAIA;IAAA;IAgBA,CAAC;IAbQ,4BAAO,GAAd,UAAe,IAAoC;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,sBAAW,oCAAY;aAAvB;YAAA,iBAMC;YALC,OAAO;gBACL,OAAO,EAAE,UAAQ,KAAuB,EAAE,KAAa;oBACrD,OAAO,KAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAI,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBACjE,CAAC;aACF,CAAC;QACJ,CAAC;;;OAAA;IAGH,iBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBqB,gCAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolveChain.d.ts","sourceRoot":"","sources":["../../../../src/graph/registry/ResolveChain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,OAAO,CAAC,KAAK,GAAG,GAAG,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC;CACjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolveChain.js","sourceRoot":"","sources":["../../../../src/graph/registry/ResolveChain.ts"],"names":[],"mappings":""}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import _Provides from './decorators/provides/Provides';
|
|
5
|
-
import { Inject as _Inject, Injectable as _Injectable } from './decorators/injectClass';
|
|
6
|
-
import _obsidian from './Obsidian';
|
|
2
|
+
import { ObjectGraph as _ObjectGraph } from './graph/ObjectGraph';
|
|
3
|
+
import _Obsidian from './Obsidian';
|
|
7
4
|
import { Constructable } from './types';
|
|
8
5
|
export * from './types';
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
6
|
+
export { Graph } from './decorators/Graph';
|
|
7
|
+
export { ObjectGraph } from './graph/ObjectGraph';
|
|
8
|
+
export { Graph as IGraph } from './graph/Graph';
|
|
9
|
+
export { Provides } from './decorators/provides/Provides';
|
|
10
|
+
export { Injectable } from './decorators/injectClass';
|
|
11
|
+
export { Inject } from './decorators/injectClass';
|
|
12
|
+
export { GraphMiddleware } from './graph/registry/GraphMiddleware';
|
|
13
|
+
export { GraphResolveChain as ResolveChain } from './graph/registry/GraphResolveChain';
|
|
14
|
+
export declare const Obsidian: _Obsidian;
|
|
15
|
+
export declare const injectComponent: <P>(Target: React.FunctionComponent<P>, Graph: Constructable<_ObjectGraph>) => React.FunctionComponent<Partial<P>>;
|
|
16
|
+
export declare const injectHook: <Args, Result>(hook: (args: Args) => Result, Graph: Constructable<_ObjectGraph>) => (args?: Partial<Args> | undefined) => Result;
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvF,eAAO,MAAM,QAAQ,WAAkB,CAAC;AAGxC,eAAO,MAAM,eAAe,iDAEnB,cAAc,YAAY,CAAC,wCACQ,CAAC;AAG7C,eAAO,MAAM,UAAU,sDAEd,cAAc,YAAY,CAAC,iDACC,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -13,25 +13,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.injectHook = exports.injectComponent = exports.Obsidian = exports.Inject = exports.Injectable = exports.Provides = exports.ObjectGraph = exports.Graph = void 0;
|
|
17
|
-
var Graph_1 = __importDefault(require("./decorators/Graph"));
|
|
18
|
-
var ObjectGraph_1 = __importDefault(require("./graph/ObjectGraph"));
|
|
16
|
+
exports.injectHook = exports.injectComponent = exports.Obsidian = exports.GraphMiddleware = exports.Inject = exports.Injectable = exports.Provides = exports.ObjectGraph = exports.Graph = void 0;
|
|
19
17
|
var ComponentInjector_1 = __importDefault(require("./injectors/components/ComponentInjector"));
|
|
20
|
-
var Provides_1 = __importDefault(require("./decorators/provides/Provides"));
|
|
21
|
-
var injectClass_1 = require("./decorators/injectClass");
|
|
22
18
|
var Obsidian_1 = __importDefault(require("./Obsidian"));
|
|
23
19
|
var HookInjector_1 = __importDefault(require("./injectors/hooks/HookInjector"));
|
|
24
20
|
__exportStar(require("./types"), exports);
|
|
25
|
-
|
|
26
|
-
exports
|
|
27
|
-
|
|
28
|
-
exports
|
|
29
|
-
|
|
21
|
+
var Graph_1 = require("./decorators/Graph");
|
|
22
|
+
Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return Graph_1.Graph; } });
|
|
23
|
+
var ObjectGraph_1 = require("./graph/ObjectGraph");
|
|
24
|
+
Object.defineProperty(exports, "ObjectGraph", { enumerable: true, get: function () { return ObjectGraph_1.ObjectGraph; } });
|
|
25
|
+
var Provides_1 = require("./decorators/provides/Provides");
|
|
26
|
+
Object.defineProperty(exports, "Provides", { enumerable: true, get: function () { return Provides_1.Provides; } });
|
|
27
|
+
var injectClass_1 = require("./decorators/injectClass");
|
|
28
|
+
Object.defineProperty(exports, "Injectable", { enumerable: true, get: function () { return injectClass_1.Injectable; } });
|
|
29
|
+
var injectClass_2 = require("./decorators/injectClass");
|
|
30
|
+
Object.defineProperty(exports, "Inject", { enumerable: true, get: function () { return injectClass_2.Inject; } });
|
|
31
|
+
var GraphMiddleware_1 = require("./graph/registry/GraphMiddleware");
|
|
32
|
+
Object.defineProperty(exports, "GraphMiddleware", { enumerable: true, get: function () { return GraphMiddleware_1.GraphMiddleware; } });
|
|
30
33
|
exports.Obsidian = new Obsidian_1.default();
|
|
31
34
|
var componentInjector = new ComponentInjector_1.default();
|
|
32
|
-
var injectComponent = function (
|
|
35
|
+
var injectComponent = function (Target, Graph) { return componentInjector.inject(Target, Graph); };
|
|
33
36
|
exports.injectComponent = injectComponent;
|
|
34
37
|
var hookInjector = new HookInjector_1.default();
|
|
35
|
-
var injectHook = function (hook,
|
|
38
|
+
var injectHook = function (hook, Graph) { return hookInjector.inject(hook, Graph); };
|
|
36
39
|
exports.injectHook = injectHook;
|
|
37
40
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,+FAAyE;AACzE,wDAAmC;AACnC,gFAA0D;AAG1D,0CAAwB;AAExB,4CAA2C;AAAlC,8FAAA,KAAK,OAAA;AACd,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB,2DAA0D;AAAjD,oGAAA,QAAQ,OAAA;AACjB,wDAAsD;AAA7C,yGAAA,UAAU,OAAA;AACnB,wDAAkD;AAAzC,qGAAA,MAAM,OAAA;AACf,oEAAmE;AAA1D,kHAAA,eAAe,OAAA;AAEX,QAAA,QAAQ,GAAG,IAAI,kBAAS,EAAE,CAAC;AAExC,IAAM,iBAAiB,GAAG,IAAI,2BAAiB,EAAE,CAAC;AAC3C,IAAM,eAAe,GAAG,UAC7B,MAAkC,EAClC,KAAkC,IAC/B,OAAA,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAvC,CAAuC,CAAC;AAHhC,QAAA,eAAe,mBAGiB;AAE7C,IAAM,YAAY,GAAG,IAAI,sBAAY,EAAE,CAAC;AACjC,IAAM,UAAU,GAAG,UACxB,IAA4B,EAC5B,KAAkC,IAC/B,OAAA,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EAAhC,CAAgC,CAAC;AAHzB,QAAA,UAAU,cAGe"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
import ObjectGraph from '../../graph/ObjectGraph';
|
|
3
|
+
import { ObjectGraph } from '../../graph/ObjectGraph';
|
|
4
4
|
import { Constructable } from '../../types';
|
|
5
5
|
export default class ComponentInjector {
|
|
6
6
|
inject<P>(Target: React.FunctionComponent<P>, Graph: Constructable<ObjectGraph>): React.FunctionComponent<Partial<P>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentInjector.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/ComponentInjector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,WAAW,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"ComponentInjector.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/ComponentInjector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,MAAM,CAAC,CAAC,EACN,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAClC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,GAChC,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAMtC,OAAO,CAAC,aAAa;CAUtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropsInjector.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/PropsInjector.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"PropsInjector.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/PropsInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,aAAa,CAAC,KAAK;IAC1B,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,WAAW;IAEtC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;CAQ3C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Constructable } from '../../types';
|
|
2
|
-
import ObjectGraph from '../../graph/ObjectGraph';
|
|
2
|
+
import { ObjectGraph } from '../../graph/ObjectGraph';
|
|
3
3
|
declare const _default: <P>(Graph: Constructable<ObjectGraph>, props?: Partial<P> | undefined) => ObjectGraph<unknown>;
|
|
4
4
|
export default _default;
|
|
5
5
|
//# sourceMappingURL=useGraph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGraph.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/useGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,WAAW,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"useGraph.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/useGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;mCAI5B,cAAc,WAAW,CAAC;AAApD,wBAOE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ObjectGraph from '../../graph/ObjectGraph';
|
|
1
|
+
import { ObjectGraph } from '../../graph/ObjectGraph';
|
|
2
2
|
import { Constructable } from '../../types';
|
|
3
3
|
export default class HookInjector {
|
|
4
4
|
inject<Args, Result>(hook: (args: Args) => Result, Graph: Constructable<ObjectGraph>): (args?: Partial<Args>) => Result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HookInjector.d.ts","sourceRoot":"","sources":["../../../../src/injectors/hooks/HookInjector.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"HookInjector.d.ts","sourceRoot":"","sources":["../../../../src/injectors/hooks/HookInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,MAAM,CAAC,IAAI,EAAE,MAAM,EACjB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,EAC5B,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,GAChC,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,MAAM;CAMpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autobind.d.ts","sourceRoot":"","sources":["../../../src/utils/autobind.ts"],"names":[],"mappings":"AAGA,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAQnD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.autobind = void 0;
|
|
7
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
/* eslint-disable no-param-reassign */
|
|
9
|
+
function autobind(target) {
|
|
10
|
+
var methods = Object.getOwnPropertyNames(Object.getPrototypeOf(target));
|
|
11
|
+
methods
|
|
12
|
+
.filter(function (method) { return (method !== 'constructor'); })
|
|
13
|
+
.filter(function (method) { return lodash_1.default.isFunction(target[method]); })
|
|
14
|
+
.forEach(function (method) {
|
|
15
|
+
target[method] = target[method].bind(target);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.autobind = autobind;
|
|
19
|
+
//# sourceMappingURL=autobind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autobind.js","sourceRoot":"","sources":["../../../src/utils/autobind.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAuB;AAEvB,sCAAsC;AACtC,SAAgB,QAAQ,CAAC,MAA2B;IAClD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1E,OAAO;SACJ,MAAM,CAAC,UAAC,MAAM,IAAK,OAAA,CAAC,MAAM,KAAK,aAAa,CAAC,EAA1B,CAA0B,CAAC;SAC9C,MAAM,CAAC,UAAC,MAAM,IAAK,OAAA,gBAAC,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAA5B,CAA4B,CAAC;SAChD,OAAO,CAAC,UAAC,MAAM;QACd,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACP,CAAC;AARD,4BAQC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Subgraph.d.ts","sourceRoot":"","sources":["../../../../test/integration/fixtures/Subgraph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Subgraph.d.ts","sourceRoot":"","sources":["../../../../test/integration/fixtures/Subgraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,WAAW,EAAY,MAAM,cAAc,CAAC;AAE5D,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAG9C,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,WAAW;IAE/C,cAAc,IAAI,cAAc;IAKhC,kBAAkB,IAAI,MAAM;IAK5B,gBAAgB,IAAI,MAAM;IAK1B,UAAU,IAAI,MAAM;CAGrB"}
|
|
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
var lodash_1 = require("lodash");
|
|
30
31
|
var src_1 = require("../../../src");
|
|
31
32
|
var injectedValues_1 = __importDefault(require("./injectedValues"));
|
|
32
33
|
var StringProvider_1 = __importDefault(require("./StringProvider"));
|
|
@@ -42,7 +43,10 @@ var Subgraph = /** @class */ (function (_super) {
|
|
|
42
43
|
return injectedValues_1.default.fromSubgraph;
|
|
43
44
|
};
|
|
44
45
|
Subgraph.prototype.unusedDependency = function () {
|
|
45
|
-
throw Error('This dependency should not have been resolved since it not required by anyone.');
|
|
46
|
+
throw Error('This dependency should not have been resolved since it is not required by anyone.');
|
|
47
|
+
};
|
|
48
|
+
Subgraph.prototype.instanceId = function () {
|
|
49
|
+
return (0, lodash_1.uniqueId)('graph');
|
|
46
50
|
};
|
|
47
51
|
__decorate([
|
|
48
52
|
(0, src_1.Provides)(),
|
|
@@ -62,6 +66,12 @@ var Subgraph = /** @class */ (function (_super) {
|
|
|
62
66
|
__metadata("design:paramtypes", []),
|
|
63
67
|
__metadata("design:returntype", String)
|
|
64
68
|
], Subgraph.prototype, "unusedDependency", null);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, src_1.Provides)(),
|
|
71
|
+
__metadata("design:type", Function),
|
|
72
|
+
__metadata("design:paramtypes", []),
|
|
73
|
+
__metadata("design:returntype", String)
|
|
74
|
+
], Subgraph.prototype, "instanceId", null);
|
|
65
75
|
Subgraph = __decorate([
|
|
66
76
|
(0, src_1.Graph)()
|
|
67
77
|
], Subgraph);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Subgraph.js","sourceRoot":"","sources":["../../../../test/integration/fixtures/Subgraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAA4D;AAC5D,oEAA8C;AAC9C,oEAA8C;AAG9C;IAAsC,4BAAW;IAAjD;;
|
|
1
|
+
{"version":3,"file":"Subgraph.js","sourceRoot":"","sources":["../../../../test/integration/fixtures/Subgraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAkC;AAClC,oCAA4D;AAC5D,oEAA8C;AAC9C,oEAA8C;AAG9C;IAAsC,4BAAW;IAAjD;;IAoBA,CAAC;IAlBC,iCAAc,GAAd;QACE,OAAO,IAAI,wBAAc,EAAE,CAAC;IAC9B,CAAC;IAGD,qCAAkB,GAAlB;QACE,OAAO,wBAAc,CAAC,YAAY,CAAC;IACrC,CAAC;IAGD,mCAAgB,GAAhB;QACE,MAAM,KAAK,CAAC,mFAAmF,CAAC,CAAC;IACnG,CAAC;IAGD,6BAAU,GAAV;QACE,OAAO,IAAA,iBAAQ,EAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAjBD;QADC,IAAA,cAAQ,GAAE;;;wCACO,wBAAc;kDAE/B;IAGD;QADC,IAAA,cAAQ,GAAE;;;;sDAGV;IAGD;QADC,IAAA,cAAQ,GAAE;;;;oDAGV;IAGD;QADC,IAAA,cAAQ,GAAE;;;;8CAGV;IAnBkB,QAAQ;QAD5B,IAAA,WAAK,GAAE;OACa,QAAQ,CAoB5B;IAAD,eAAC;CAAA,AApBD,CAAsC,iBAAW,GAoBhD;kBApBoB,QAAQ"}
|
package/dist/testkit/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../testkit/index.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../testkit/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,EAGd,MAAM,QAAQ,CAAC;AAMhB,cAAM,KAAK;IACT,UAAU,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CAYxE;;AAED,wBAA2B"}
|
package/dist/testkit/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
var GraphMiddleware_1 = require("../src/graph/registry/GraphMiddleware");
|
|
19
18
|
var src_1 = require("../src");
|
|
20
19
|
beforeEach(function () {
|
|
21
20
|
src_1.Obsidian.clearGraphMiddlewares();
|
|
@@ -37,7 +36,7 @@ var Index = /** @class */ (function () {
|
|
|
37
36
|
return resolveChain.proceed(Graph, props);
|
|
38
37
|
};
|
|
39
38
|
return class_1;
|
|
40
|
-
}(
|
|
39
|
+
}(src_1.GraphMiddleware))();
|
|
41
40
|
src_1.Obsidian.addGraphMiddleware(graphMiddleware);
|
|
42
41
|
};
|
|
43
42
|
return Index;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../testkit/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../testkit/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,8BAKgB;AAEhB,UAAU,CAAC;IACT,cAAQ,CAAC,qBAAqB,EAAE,CAAC;AACnC,CAAC,CAAC,CAAC;AAEH;IAAA;IAaA,CAAC;IAZC,0BAAU,GAAV,UAAW,gBAA4D;QACrE,IAAM,eAAe,GAAG;YAAkB,2BAAe;YAA7B;;YAQ5B,CAAC;YAPC,yBAAO,GAAP,UAAe,YAA+B,EAAE,KAAiC,EAAE,KAAa;gBAC9F,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;oBAChC,IAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAC9C,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;iBAC5B;gBACD,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC5C,CAAC;YACH,cAAC;QAAD,CAAC,AAR2B,CAAc,qBAAe,IAQtD,CAAC;QACJ,cAAQ,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IACH,YAAC;AAAD,CAAC,AAbD,IAaC;AAED,kBAAe,IAAI,KAAK,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/Obsidian.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import graphRegistry from './graph/registry/GraphRegistry';
|
|
2
|
-
import ObjectGraph from './graph/ObjectGraph';
|
|
3
|
-
import { GraphMiddleware } from './graph/registry/GraphMiddleware';
|
|
2
|
+
import { ObjectGraph } from './graph/ObjectGraph';
|
|
4
3
|
import { Constructable, GraphInternals, ServiceLocator } from './types';
|
|
4
|
+
import { GraphMiddleware } from './graph/registry/GraphMiddleware';
|
|
5
5
|
|
|
6
6
|
export default class Obsidian {
|
|
7
7
|
obtain<T extends ObjectGraph<P>, P = any>(
|
package/src/decorators/Graph.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Constructable, Scope } from '../types';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import graphRegistry from '../graph/registry/GraphRegistry';
|
|
4
|
-
import ObjectGraph from '../graph/ObjectGraph';
|
|
4
|
+
import { ObjectGraph } from '../graph/ObjectGraph';
|
|
5
5
|
|
|
6
6
|
interface GraphParams {
|
|
7
7
|
scope: Scope | undefined;
|
|
8
8
|
subgraphs: Constructable<ObjectGraph>[];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export function Graph({
|
|
12
12
|
scope,
|
|
13
13
|
subgraphs = [],
|
|
14
14
|
}: Partial<GraphParams> = {}) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
import 'reflect-metadata';
|
|
3
|
+
|
|
4
|
+
export default function Memoize() {
|
|
5
|
+
return function provide(_Clazz: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
6
|
+
const originalGet = descriptor.get!;
|
|
7
|
+
descriptor.get = function get() {
|
|
8
|
+
const key = `memoized${propertyKey}`;
|
|
9
|
+
if (Reflect.hasMetadata(key, this)) {
|
|
10
|
+
return Reflect.getMetadata(key, this);
|
|
11
|
+
}
|
|
12
|
+
const value = originalGet.call(this);
|
|
13
|
+
Reflect.defineMetadata(key, value, this);
|
|
14
|
+
return value;
|
|
15
|
+
};
|
|
16
|
+
return descriptor;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
export function memoizeDescriptor(propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {
|
|
3
|
+
const originalValue = descriptor.value;
|
|
4
|
+
descriptor.value = function value(...args: any[]) {
|
|
5
|
+
const key = `memoized${propertyKey}`;
|
|
6
|
+
if (Reflect.hasMetadata(key, this)) {
|
|
7
|
+
return Reflect.getMetadata(key, this);
|
|
8
|
+
}
|
|
9
|
+
const result = originalValue.apply(this, args);
|
|
10
|
+
Reflect.defineMetadata(key, result, this);
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
return descriptor;
|
|
14
|
+
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { Scope } from '../../types';
|
|
2
|
-
import Graph from '../../graph/Graph';
|
|
2
|
+
import { Graph } from '../../graph/Graph';
|
|
3
3
|
import providedPropertiesStore from '../../ProvidedPropertiesStore';
|
|
4
|
-
import
|
|
4
|
+
import { memoizeDescriptor } from './MemoizeDescriptor';
|
|
5
5
|
|
|
6
6
|
interface ProvidesParams {
|
|
7
7
|
scope?: Scope;
|
|
8
8
|
name: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function Provides({ name }: Partial<ProvidesParams> = {}) {
|
|
11
|
+
export function Provides({ name }: Partial<ProvidesParams> = {}) {
|
|
12
12
|
return function provide(graph: Graph, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
13
13
|
providedPropertiesStore.set(graph, propertyKey, name!);
|
|
14
|
-
return
|
|
14
|
+
return memoizeDescriptor(propertyKey, descriptor);
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
export default Provides;
|
package/src/graph/Graph.ts
CHANGED
package/src/graph/ObjectGraph.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
import { uniqueId } from 'lodash';
|
|
2
|
+
import Memoize from '../decorators/Memoize';
|
|
1
3
|
import { Scope } from '../types';
|
|
2
|
-
import
|
|
4
|
+
import { autobind } from '../utils/autobind';
|
|
5
|
+
import { Graph } from './Graph';
|
|
3
6
|
import PropertyRetriever from './PropertyRetriever';
|
|
4
7
|
|
|
5
|
-
export
|
|
8
|
+
export abstract class ObjectGraph<T = unknown> implements Graph {
|
|
6
9
|
// TODO? rename scope to singleInstance
|
|
7
10
|
public scope!: Scope;
|
|
8
11
|
private propertyRetriever = new PropertyRetriever(this);
|
|
12
|
+
|
|
13
|
+
@Memoize()
|
|
9
14
|
get name(): string {
|
|
10
|
-
return this.constructor.name;
|
|
15
|
+
return uniqueId(this.constructor.name);
|
|
11
16
|
}
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
constructor(protected _props?: T) {
|
|
19
|
+
autobind(this);
|
|
20
|
+
}
|
|
15
21
|
|
|
16
22
|
retrieve<Dependency>(property: string, receiver?: unknown): Dependency | undefined {
|
|
17
23
|
return this.propertyRetriever.retrieve(property, receiver) as Dependency | undefined;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Constructable } from '../../types';
|
|
2
|
-
import Graph from '../Graph';
|
|
3
|
-
import {
|
|
2
|
+
import { Graph } from '../Graph';
|
|
3
|
+
import { Middleware } from './Middleware';
|
|
4
|
+
import { ResolveChain } from './ResolveChain';
|
|
4
5
|
|
|
5
|
-
export default class DefaultGraphMiddleware extends
|
|
6
|
-
resolve
|
|
6
|
+
export default class DefaultGraphMiddleware<T extends Graph> extends Middleware<T> {
|
|
7
|
+
resolve(_resolveChain: ResolveChain<T>, Graph: Constructable<T>, props?: any): T {
|
|
7
8
|
return new Graph(props);
|
|
8
9
|
}
|
|
9
10
|
}
|
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ObjectGraph } from '../ObjectGraph';
|
|
2
|
+
import { GraphResolveChain } from './GraphResolveChain';
|
|
3
|
+
import { Middleware } from './Middleware';
|
|
3
4
|
|
|
4
|
-
export abstract class GraphMiddleware {
|
|
5
|
-
private next!: GraphMiddleware;
|
|
6
|
-
|
|
7
|
-
public setNext(next: GraphMiddleware) {
|
|
8
|
-
this.next = next;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
public get resolveChain(): ResolveChain {
|
|
12
|
-
return {
|
|
13
|
-
proceed: <T extends Graph, Props>(Graph: Constructable<T>, props?: Props): T => {
|
|
14
|
-
return this.next.resolve(this.next.resolveChain, Graph, props);
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
abstract resolve<T extends Graph, Props>(resolveChain: ResolveChain, Graph: Constructable<T>, props?: Props): T;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ResolveChain {
|
|
23
|
-
proceed<T extends Graph, Props>(Graph: Constructable<T>, props?: Props): T;
|
|
24
|
-
}
|
|
5
|
+
export abstract class GraphMiddleware extends Middleware<ObjectGraph, GraphResolveChain> { }
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Constructable } from '../../types';
|
|
2
|
-
import Graph from '../Graph';
|
|
2
|
+
import { Graph } from '../Graph';
|
|
3
3
|
import DefaultGraphMiddleware from './DefaultGraphResolver';
|
|
4
|
-
import {
|
|
4
|
+
import { Middleware } from './Middleware';
|
|
5
5
|
|
|
6
|
-
export default class GraphMiddlewareChain {
|
|
7
|
-
private middlewares:
|
|
6
|
+
export default class GraphMiddlewareChain<T extends Graph> {
|
|
7
|
+
private middlewares: Middleware<T>[];
|
|
8
8
|
|
|
9
|
-
constructor(defaultMiddleware:
|
|
9
|
+
constructor(defaultMiddleware: Middleware<T> = new DefaultGraphMiddleware()) {
|
|
10
10
|
this.middlewares = [defaultMiddleware];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
resolve
|
|
13
|
+
resolve(Graph: Constructable<T>, props?: any): T {
|
|
14
14
|
return this.middlewares[0].resolve(this.middlewares[0].resolveChain, Graph, props);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
add(middleware:
|
|
17
|
+
add(middleware: Middleware<T>) {
|
|
18
18
|
this.middlewares.unshift(middleware);
|
|
19
19
|
this.updateResolveChain();
|
|
20
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Constructable, Scope } from '../../types';
|
|
2
|
-
import Graph from '../Graph';
|
|
3
|
-
import {
|
|
2
|
+
import { Graph } from '../Graph';
|
|
3
|
+
import { Middleware } from './Middleware';
|
|
4
4
|
import GraphMiddlewareChain from './GraphMiddlewareChain';
|
|
5
5
|
|
|
6
6
|
class GraphRegistry {
|
|
@@ -49,7 +49,7 @@ class GraphRegistry {
|
|
|
49
49
|
}
|
|
50
50
|
const graph = this.graphMiddlewares.resolve(Graph, props);
|
|
51
51
|
this.set(Graph, graph);
|
|
52
|
-
return graph;
|
|
52
|
+
return graph as T;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
clear(graph: Graph) {
|
|
@@ -58,7 +58,7 @@ class GraphRegistry {
|
|
|
58
58
|
this.constructorToInstance.delete(Graph);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
addGraphMiddleware(middleware:
|
|
61
|
+
addGraphMiddleware(middleware: Middleware<Graph>) {
|
|
62
62
|
this.graphMiddlewares.add(middleware);
|
|
63
63
|
}
|
|
64
64
|
|