react-obsidian 0.0.11 → 0.0.12

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.
@@ -2,5 +2,6 @@ export default class GraphProperties {
2
2
  private unmangledToMangledPropKeys;
3
3
  add(mangledPropertyKey: string, unmangledPropertyKey: string): void;
4
4
  getMangledProperty(unmangledProperty: string): string | undefined;
5
+ getMangledProperties(): string[];
5
6
  }
6
7
  //# sourceMappingURL=GraphProperties.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GraphProperties.d.ts","sourceRoot":"","sources":["../../src/GraphProperties.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,OAAO,CAAC,0BAA0B,CAA6B;IAE/D,GAAG,CAAC,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM;IAI5D,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGlE"}
1
+ {"version":3,"file":"GraphProperties.d.ts","sourceRoot":"","sources":["../../src/GraphProperties.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,OAAO,CAAC,0BAA0B,CAA6B;IAE/D,GAAG,CAAC,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM;IAI5D,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIjE,oBAAoB,IAAI,MAAM,EAAE;CAGjC"}
@@ -10,6 +10,9 @@ var GraphProperties = /** @class */ (function () {
10
10
  GraphProperties.prototype.getMangledProperty = function (unmangledProperty) {
11
11
  return this.unmangledToMangledPropKeys.get(unmangledProperty);
12
12
  };
13
+ GraphProperties.prototype.getMangledProperties = function () {
14
+ return Array.from(this.unmangledToMangledPropKeys.values());
15
+ };
13
16
  return GraphProperties;
14
17
  }());
15
18
  exports.default = GraphProperties;
@@ -1 +1 @@
1
- {"version":3,"file":"GraphProperties.js","sourceRoot":"","sources":["../../src/GraphProperties.ts"],"names":[],"mappings":";;AAAA;IAAA;QACU,+BAA0B,GAAG,IAAI,GAAG,EAAkB,CAAC;IASjE,CAAC;IAPC,6BAAG,GAAH,UAAI,kBAA0B,EAAE,oBAA4B;QAC1D,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;IAChF,CAAC;IAED,4CAAkB,GAAlB,UAAmB,iBAAyB;QAC1C,OAAO,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAChE,CAAC;IACH,sBAAC;AAAD,CAAC,AAVD,IAUC"}
1
+ {"version":3,"file":"GraphProperties.js","sourceRoot":"","sources":["../../src/GraphProperties.ts"],"names":[],"mappings":";;AAAA;IAAA;QACU,+BAA0B,GAAG,IAAI,GAAG,EAAkB,CAAC;IAajE,CAAC;IAXC,6BAAG,GAAH,UAAI,kBAA0B,EAAE,oBAA4B;QAC1D,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;IAChF,CAAC;IAED,4CAAkB,GAAlB,UAAmB,iBAAyB;QAC1C,OAAO,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAChE,CAAC;IAED,8CAAoB,GAApB;QACE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9D,CAAC;IACH,sBAAC;AAAD,CAAC,AAdD,IAcC"}
@@ -3,6 +3,7 @@ declare class ProvidedPropertiesStore {
3
3
  private readonly providedPropertiesForGraph;
4
4
  getMangledProperty(graph: Graph, unmangledProp: string): string | undefined;
5
5
  set(graph: Graph, mangledProperty: string, unmangledProperty: string): void;
6
+ getMangledProperties(graph: Graph): string[];
6
7
  clear(graph: Graph): void;
7
8
  }
8
9
  declare const _default: ProvidedPropertiesStore;
@@ -1 +1 @@
1
- {"version":3,"file":"ProvidedPropertiesStore.d.ts","sourceRoot":"","sources":["../../src/ProvidedPropertiesStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,cAAM,uBAAuB;IAC3B,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAA2C;IAEtF,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI3E,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;IAMpE,KAAK,CAAC,KAAK,EAAE,KAAK;CAGnB;;AAED,wBAA6C"}
1
+ {"version":3,"file":"ProvidedPropertiesStore.d.ts","sourceRoot":"","sources":["../../src/ProvidedPropertiesStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,cAAM,uBAAuB;IAC3B,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAA2C;IAEtF,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI3E,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;IAMpE,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE;IAI5C,KAAK,CAAC,KAAK,EAAE,KAAK;CAGnB;;AAED,wBAA6C"}
@@ -18,6 +18,10 @@ var ProvidedPropertiesStore = /** @class */ (function () {
18
18
  graphProperties.add(mangledProperty, unmangledProperty);
19
19
  this.providedPropertiesForGraph.set(graph.name, graphProperties);
20
20
  };
21
+ ProvidedPropertiesStore.prototype.getMangledProperties = function (graph) {
22
+ var _a, _b;
23
+ return (_b = (_a = this.providedPropertiesForGraph.get(graph.name)) === null || _a === void 0 ? void 0 : _a.getMangledProperties()) !== null && _b !== void 0 ? _b : [];
24
+ };
21
25
  ProvidedPropertiesStore.prototype.clear = function (graph) {
22
26
  this.providedPropertiesForGraph.delete(graph.name);
23
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ProvidedPropertiesStore.js","sourceRoot":"","sources":["../../src/ProvidedPropertiesStore.ts"],"names":[],"mappings":";;;;;AAAA,sEAAgD;AAGhD;IAAA;QACmB,+BAA0B,GAAiC,IAAI,GAAG,EAAE,CAAC;IAexF,CAAC;IAbC,oDAAkB,GAAlB,UAAmB,KAAY,EAAE,aAAqB;;QACpD,OAAO,MAAA,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,0CAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAC5F,CAAC;IAED,qCAAG,GAAH,UAAI,KAAY,EAAE,eAAuB,EAAE,iBAAyB;;QAClE,IAAM,eAAe,GAAG,MAAA,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAI,IAAI,yBAAe,EAAE,CAAC;QACjG,eAAe,CAAC,GAAG,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;QACxD,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACnE,CAAC;IAED,uCAAK,GAAL,UAAM,KAAY;QAChB,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IACH,8BAAC;AAAD,CAAC,AAhBD,IAgBC;AAED,kBAAe,IAAI,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"ProvidedPropertiesStore.js","sourceRoot":"","sources":["../../src/ProvidedPropertiesStore.ts"],"names":[],"mappings":";;;;;AAAA,sEAAgD;AAGhD;IAAA;QACmB,+BAA0B,GAAiC,IAAI,GAAG,EAAE,CAAC;IAmBxF,CAAC;IAjBC,oDAAkB,GAAlB,UAAmB,KAAY,EAAE,aAAqB;;QACpD,OAAO,MAAA,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,0CAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAC5F,CAAC;IAED,qCAAG,GAAH,UAAI,KAAY,EAAE,eAAuB,EAAE,iBAAyB;;QAClE,IAAM,eAAe,GAAG,MAAA,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAI,IAAI,yBAAe,EAAE,CAAC;QACjG,eAAe,CAAC,GAAG,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;QACxD,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACnE,CAAC;IAED,sDAAoB,GAApB,UAAqB,KAAY;;QAC/B,OAAO,MAAA,MAAA,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,0CAAE,oBAAoB,EAAE,mCAAI,EAAE,CAAC;IACvF,CAAC;IAED,uCAAK,GAAL,UAAM,KAAY;QAChB,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IACH,8BAAC;AAAD,CAAC,AApBD,IAoBC;AAED,kBAAe,IAAI,uBAAuB,EAAE,CAAC"}
@@ -15,13 +15,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ObjectGraph = void 0;
16
16
  var lodash_1 = require("lodash");
17
17
  var Memoize_1 = __importDefault(require("../decorators/Memoize"));
18
- var autobind_1 = require("../utils/autobind");
18
+ var ProviderBinder_1 = require("./ProviderBinder");
19
19
  var PropertyRetriever_1 = __importDefault(require("./PropertyRetriever"));
20
20
  var ObjectGraph = /** @class */ (function () {
21
21
  function ObjectGraph(_props) {
22
22
  this._props = _props;
23
23
  this.propertyRetriever = new PropertyRetriever_1.default(this);
24
- (0, autobind_1.autobind)(this);
24
+ (0, ProviderBinder_1.bindProviders)(this);
25
25
  }
26
26
  Object.defineProperty(ObjectGraph.prototype, "name", {
27
27
  get: function () {
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectGraph.js","sourceRoot":"","sources":["../../../src/graph/ObjectGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAAkC;AAClC,kEAA4C;AAE5C,8CAA6C;AAE7C,0EAAoD;AAEpD;IAUE,qBAAsB,MAAU;QAAV,WAAM,GAAN,MAAM,CAAI;QAPxB,sBAAiB,GAAG,IAAI,2BAAiB,CAAC,IAAI,CAAC,CAAC;QAQtD,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAND,sBAAI,6BAAI;aAAR;YACE,OAAO,IAAA,iBAAQ,EAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;;;OAAA;IAMD,8BAAQ,GAAR,UAAqB,QAAgB,EAAE,QAAkB;QACvD,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAA2B,CAAC;IACvF,CAAC;IAVD;QADC,IAAA,iBAAO,GAAE;;;2CAGT;IASH,kBAAC;CAAA,AAjBD,IAiBC;AAjBqB,kCAAW"}
1
+ {"version":3,"file":"ObjectGraph.js","sourceRoot":"","sources":["../../../src/graph/ObjectGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAAkC;AAClC,kEAA4C;AAE5C,mDAAiD;AAEjD,0EAAoD;AAEpD;IAUE,qBAAsB,MAAU;QAAV,WAAM,GAAN,MAAM,CAAI;QAPxB,sBAAiB,GAAG,IAAI,2BAAiB,CAAC,IAAI,CAAC,CAAC;QAQtD,IAAA,8BAAa,EAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAND,sBAAI,6BAAI;aAAR;YACE,OAAO,IAAA,iBAAQ,EAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;;;OAAA;IAMD,8BAAQ,GAAR,UAAqB,QAAgB,EAAE,QAAkB;QACvD,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAA2B,CAAC;IACvF,CAAC;IAVD;QADC,IAAA,iBAAO,GAAE;;;2CAGT;IASH,kBAAC;CAAA,AAjBD,IAiBC;AAjBqB,kCAAW"}
@@ -0,0 +1,3 @@
1
+ import { Graph } from './Graph';
2
+ export declare function bindProviders(graph: Graph & Record<string, any>): void;
3
+ //# sourceMappingURL=ProviderBinder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderBinder.d.ts","sourceRoot":"","sources":["../../../src/graph/ProviderBinder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAO/D"}
@@ -0,0 +1,18 @@
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.bindProviders = void 0;
7
+ /* eslint-disable no-param-reassign */
8
+ var ProvidedPropertiesStore_1 = __importDefault(require("../ProvidedPropertiesStore"));
9
+ function bindProviders(graph) {
10
+ ProvidedPropertiesStore_1.default.getMangledProperties(graph)
11
+ .forEach(function (method) {
12
+ if (graph[method] !== undefined) {
13
+ graph[method] = graph[method].bind(graph);
14
+ }
15
+ });
16
+ }
17
+ exports.bindProviders = bindProviders;
18
+ //# sourceMappingURL=ProviderBinder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderBinder.js","sourceRoot":"","sources":["../../../src/graph/ProviderBinder.ts"],"names":[],"mappings":";;;;;;AAAA,sCAAsC;AACtC,uFAAiE;AAGjE,SAAgB,aAAa,CAAC,KAAkC;IAC9D,iCAAuB,CAAC,oBAAoB,CAAC,KAAK,CAAC;SAChD,OAAO,CAAC,UAAC,MAAM;QACd,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE;YAC/B,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC3C;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAPD,sCAOC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-obsidian",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Dependency injection framework for React and React Native applications",
5
5
  "main": "src/index.ts",
6
6
  "directories": {
@@ -8,4 +8,8 @@ export default class GraphProperties {
8
8
  getMangledProperty(unmangledProperty: string): string | undefined {
9
9
  return this.unmangledToMangledPropKeys.get(unmangledProperty);
10
10
  }
11
+
12
+ getMangledProperties(): string[] {
13
+ return Array.from(this.unmangledToMangledPropKeys.values());
14
+ }
11
15
  }
@@ -14,6 +14,10 @@ class ProvidedPropertiesStore {
14
14
  this.providedPropertiesForGraph.set(graph.name, graphProperties);
15
15
  }
16
16
 
17
+ getMangledProperties(graph: Graph): string[] {
18
+ return this.providedPropertiesForGraph.get(graph.name)?.getMangledProperties() ?? [];
19
+ }
20
+
17
21
  clear(graph: Graph) {
18
22
  this.providedPropertiesForGraph.delete(graph.name);
19
23
  }
@@ -1,7 +1,7 @@
1
1
  import { uniqueId } from 'lodash';
2
2
  import Memoize from '../decorators/Memoize';
3
3
  import { Scope } from '../types';
4
- import { autobind } from '../utils/autobind';
4
+ import { bindProviders } from './ProviderBinder';
5
5
  import { Graph } from './Graph';
6
6
  import PropertyRetriever from './PropertyRetriever';
7
7
 
@@ -16,7 +16,7 @@ export abstract class ObjectGraph<T = unknown> implements Graph {
16
16
  }
17
17
 
18
18
  constructor(protected _props?: T) {
19
- autobind(this);
19
+ bindProviders(this);
20
20
  }
21
21
 
22
22
  retrieve<Dependency>(property: string, receiver?: unknown): Dependency | undefined {
@@ -0,0 +1,12 @@
1
+ /* eslint-disable no-param-reassign */
2
+ import providedPropertiesStore from '../ProvidedPropertiesStore';
3
+ import { Graph } from './Graph';
4
+
5
+ export function bindProviders(graph: Graph & Record<string, any>) {
6
+ providedPropertiesStore.getMangledProperties(graph)
7
+ .forEach((method) => {
8
+ if (graph[method] !== undefined) {
9
+ graph[method] = graph[method].bind(graph);
10
+ }
11
+ });
12
+ }
@@ -1,2 +0,0 @@
1
- export declare function autobind(target: Record<string, any>): void;
2
- //# sourceMappingURL=autobind.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,19 +0,0 @@
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
@@ -1 +0,0 @@
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,12 +0,0 @@
1
- import _ from 'lodash';
2
-
3
- /* eslint-disable no-param-reassign */
4
- export function autobind(target: Record<string, any>) {
5
- const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(target));
6
- methods
7
- .filter((method) => (method !== 'constructor'))
8
- .filter((method) => _.isFunction(target[method]))
9
- .forEach((method) => {
10
- target[method] = target[method].bind(target);
11
- });
12
- }