react-obsidian 1.0.0 → 1.2.0

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.
Files changed (157) hide show
  1. package/dist/src/Obsidian.d.ts +2 -2
  2. package/dist/src/Obsidian.d.ts.map +1 -1
  3. package/dist/src/Obsidian.js.map +1 -1
  4. package/dist/src/graph/registry/GraphRegistry.d.ts +1 -0
  5. package/dist/src/graph/registry/GraphRegistry.d.ts.map +1 -1
  6. package/dist/src/graph/registry/GraphRegistry.js +8 -1
  7. package/dist/src/graph/registry/GraphRegistry.js.map +1 -1
  8. package/dist/src/graph/registry/NullProps.d.ts +4 -0
  9. package/dist/src/graph/registry/NullProps.d.ts.map +1 -0
  10. package/dist/src/graph/registry/NullProps.js +25 -0
  11. package/dist/src/graph/registry/NullProps.js.map +1 -0
  12. package/dist/src/index.d.ts +1 -0
  13. package/dist/src/index.d.ts.map +1 -1
  14. package/dist/src/index.js +4 -1
  15. package/dist/src/index.js.map +1 -1
  16. package/dist/src/utils/isDev.d.ts +2 -0
  17. package/dist/src/utils/isDev.d.ts.map +1 -0
  18. package/dist/src/utils/isDev.js +17 -0
  19. package/dist/src/utils/isDev.js.map +1 -0
  20. package/dist/test/fixtures/LifecycleBoundGraph.d.ts +3 -2
  21. package/dist/test/fixtures/LifecycleBoundGraph.d.ts.map +1 -1
  22. package/dist/test/fixtures/LifecycleBoundGraph.js +9 -0
  23. package/dist/test/fixtures/LifecycleBoundGraph.js.map +1 -1
  24. package/dist/testkit/index.d.ts +6 -1
  25. package/dist/testkit/index.d.ts.map +1 -1
  26. package/dist/testkit/index.js +11 -17
  27. package/dist/testkit/index.js.map +1 -1
  28. package/dist/testkit/mockGraphs.d.ts +4 -0
  29. package/dist/testkit/mockGraphs.d.ts.map +1 -0
  30. package/dist/testkit/mockGraphs.js +23 -0
  31. package/dist/testkit/mockGraphs.js.map +1 -0
  32. package/dist/testkit/mockModel.d.ts +3 -0
  33. package/dist/testkit/mockModel.d.ts.map +1 -0
  34. package/dist/testkit/mockModel.js +14 -0
  35. package/dist/testkit/mockModel.js.map +1 -0
  36. package/package.json +1 -1
  37. package/src/Obsidian.ts +3 -3
  38. package/src/graph/registry/GraphRegistry.ts +9 -1
  39. package/src/graph/registry/NullProps.ts +23 -0
  40. package/src/index.ts +1 -0
  41. package/src/utils/isDev.ts +12 -0
  42. package/testkit/index.ts +11 -14
  43. package/testkit/mockGraphs.ts +20 -0
  44. package/testkit/mockModel.ts +10 -0
  45. package/.buildkite/pipeline.yml +0 -10
  46. package/.eslintignore +0 -1
  47. package/.eslintrc.json +0 -104
  48. package/.vscode/settings.json +0 -5
  49. package/babel.config.js +0 -13
  50. package/documentation/README.md +0 -41
  51. package/documentation/babel.config.js +0 -3
  52. package/documentation/blog/2019-05-28-first-blog-post.md +0 -12
  53. package/documentation/blog/2019-05-29-long-blog-post.md +0 -44
  54. package/documentation/blog/2021-08-01-mdx-blog-post.mdx +0 -20
  55. package/documentation/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg +0 -0
  56. package/documentation/blog/2021-08-26-welcome/index.md +0 -25
  57. package/documentation/blog/authors.yml +0 -17
  58. package/documentation/docs/documentation/documentation.mdx +0 -190
  59. package/documentation/docs/documentation/installation.mdx +0 -56
  60. package/documentation/docs/documentation/meta/clearingGraphs.mdx +0 -13
  61. package/documentation/docs/documentation/meta/middlewares.mdx +0 -27
  62. package/documentation/docs/documentation/usage/ClassComponents.mdx +0 -18
  63. package/documentation/docs/documentation/usage/Classes.mdx +0 -41
  64. package/documentation/docs/documentation/usage/FunctionalComponents.mdx +0 -57
  65. package/documentation/docs/documentation/usage/Graphs.mdx +0 -154
  66. package/documentation/docs/documentation/usage/Hooks.mdx +0 -85
  67. package/documentation/docs/documentation/usage/Reactivity.mdx +0 -116
  68. package/documentation/docs/documentation/usage/ServiceLocator.mdx +0 -38
  69. package/documentation/docs/documentation/usage/_category_.json +0 -9
  70. package/documentation/docs/guides/configurableApplications.mdx +0 -205
  71. package/documentation/docs/guides/mockDependencies.mdx +0 -141
  72. package/documentation/docusaurus.config.js +0 -151
  73. package/documentation/package-lock.json +0 -22975
  74. package/documentation/package.json +0 -47
  75. package/documentation/sidebars.js +0 -34
  76. package/documentation/src/components/HomepageFeatures/index.tsx +0 -71
  77. package/documentation/src/components/HomepageFeatures/styles.module.css +0 -11
  78. package/documentation/src/css/custom.css +0 -30
  79. package/documentation/src/pages/index.module.css +0 -23
  80. package/documentation/src/pages/index.tsx +0 -41
  81. package/documentation/src/pages/playground/index.mdx +0 -21
  82. package/documentation/src/theme/SearchBar.js +0 -19
  83. package/documentation/static/.nojekyll +0 -0
  84. package/documentation/static/img/api.svg +0 -101
  85. package/documentation/static/img/favicon.ico +0 -0
  86. package/documentation/static/img/logo.svg +0 -265
  87. package/documentation/static/img/obsidian.png +0 -0
  88. package/documentation/static/img/prototype.svg +0 -1
  89. package/documentation/static/img/stethoscope.svg +0 -37
  90. package/documentation/tsconfig.json +0 -7
  91. package/documentation/yarn.lock +0 -8167
  92. package/example/.buckconfig +0 -6
  93. package/example/.editorconfig +0 -3
  94. package/example/.eslintrc.js +0 -4
  95. package/example/.flowconfig +0 -65
  96. package/example/.gitattributes +0 -3
  97. package/example/.prettierrc.js +0 -7
  98. package/example/.watchmanconfig +0 -1
  99. package/example/App.tsx +0 -31
  100. package/example/MyInjectedComponent.tsx +0 -37
  101. package/example/__tests__/App-test.js +0 -14
  102. package/example/android/app/BUCK +0 -55
  103. package/example/android/app/build.gradle +0 -227
  104. package/example/android/app/build_defs.bzl +0 -19
  105. package/example/android/app/debug.keystore +0 -0
  106. package/example/android/app/proguard-rules.pro +0 -10
  107. package/example/android/app/src/debug/AndroidManifest.xml +0 -13
  108. package/example/android/app/src/debug/java/com/example/ReactNativeFlipper.java +0 -72
  109. package/example/android/app/src/main/AndroidManifest.xml +0 -25
  110. package/example/android/app/src/main/java/com/example/MainActivity.java +0 -15
  111. package/example/android/app/src/main/java/com/example/MainApplication.java +0 -80
  112. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  113. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  114. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  115. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  116. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  117. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  118. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  119. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  120. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  121. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  122. package/example/android/app/src/main/res/values/strings.xml +0 -3
  123. package/example/android/app/src/main/res/values/styles.xml +0 -8
  124. package/example/android/build.gradle +0 -38
  125. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  126. package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  127. package/example/android/gradle.properties +0 -28
  128. package/example/android/gradlew +0 -185
  129. package/example/android/gradlew.bat +0 -89
  130. package/example/android/settings.gradle +0 -3
  131. package/example/app.json +0 -4
  132. package/example/babel.config.js +0 -8
  133. package/example/index.js +0 -9
  134. package/example/ios/Podfile +0 -30
  135. package/example/ios/Podfile.lock +0 -526
  136. package/example/ios/example/AppDelegate.h +0 -8
  137. package/example/ios/example/AppDelegate.m +0 -62
  138. package/example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json +0 -38
  139. package/example/ios/example/Images.xcassets/Contents.json +0 -6
  140. package/example/ios/example/Info.plist +0 -55
  141. package/example/ios/example/LaunchScreen.storyboard +0 -47
  142. package/example/ios/example/main.m +0 -9
  143. package/example/ios/example.xcodeproj/project.pbxproj +0 -689
  144. package/example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme +0 -88
  145. package/example/ios/example.xcworkspace/contents.xcworkspacedata +0 -10
  146. package/example/ios/example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  147. package/example/ios/exampleTests/Info.plist +0 -24
  148. package/example/ios/exampleTests/exampleTests.m +0 -65
  149. package/example/metro.config.js +0 -44
  150. package/example/package.json +0 -35
  151. package/example/tsconfig.json +0 -42
  152. package/global.d.ts +0 -1
  153. package/jest.config.js +0 -17
  154. package/jest.setup-after-env.js +0 -4
  155. package/tsconfig.base.json +0 -42
  156. package/tsconfig.json +0 -3
  157. package/tsconfig.prod.json +0 -7
@@ -1,8 +1,8 @@
1
1
  import { ObjectGraph } from './graph/ObjectGraph';
2
- import { Constructable, GraphInternals, ServiceLocator } from './types';
2
+ import { GraphInternals, ServiceLocator } from './types';
3
3
  import { GraphMiddleware } from './graph/registry/GraphMiddleware';
4
4
  export default class Obsidian {
5
- obtain<T extends ObjectGraph<P>, P = any>(Graph: Constructable<T>, props?: P): ServiceLocator<Omit<T, GraphInternals>>;
5
+ obtain<T extends ObjectGraph<P>, P>(Graph: new (...args: P[]) => T, props?: P): ServiceLocator<Omit<T, GraphInternals>>;
6
6
  inject<T extends object>(target: T, graph?: ObjectGraph): object;
7
7
  addGraphMiddleware(middleware: GraphMiddleware): void;
8
8
  clearGraphMiddlewares(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"Obsidian.d.ts","sourceRoot":"","sources":["../../src/Obsidian.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAInE,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,MAAM,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EACtC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,KAAK,CAAC,EAAE,CAAC,GACR,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAI1C,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,WAAW;IAIvD,kBAAkB,CAAC,UAAU,EAAE,eAAe;IAI9C,qBAAqB;IAIrB,WAAW;CAIZ"}
1
+ {"version":3,"file":"Obsidian.d.ts","sourceRoot":"","sources":["../../src/Obsidian.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAInE,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,MAAM,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAChC,KAAK,EAAE,KAAI,GAAG,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAC7B,KAAK,CAAC,EAAE,CAAC,GACR,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAI1C,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,WAAW;IAIvD,kBAAkB,CAAC,UAAU,EAAE,eAAe;IAI9C,qBAAqB;IAIrB,WAAW;CAIZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"Obsidian.js","sourceRoot":"","sources":["../../src/Obsidian.ts"],"names":[],"mappings":";;;;;AAAA,mFAA2D;AAI3D,kFAA0D;AAC1D,0FAAkE;AAElE,MAAqB,QAAQ;IAC3B,MAAM,CACJ,KAAuB,EACvB,KAAS;QAET,OAAO,+BAAqB,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,CAAmB,MAAS,EAAE,KAAmB;QACrD,OAAO,sBAAY,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,kBAAkB,CAAC,UAA2B;QAC5C,uBAAa,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,qBAAqB;QACnB,uBAAa,CAAC,qBAAqB,EAAE,CAAC;IACxC,CAAC;IAED,WAAW;QACT,uBAAa,CAAC,qBAAqB,EAAE,CAAC;QACtC,uBAAa,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACF;AAxBD,2BAwBC"}
1
+ {"version":3,"file":"Obsidian.js","sourceRoot":"","sources":["../../src/Obsidian.ts"],"names":[],"mappings":";;;;;AAAA,mFAA2D;AAI3D,kFAA0D;AAC1D,0FAAkE;AAElE,MAAqB,QAAQ;IAC3B,MAAM,CACJ,KAA6B,EAC7B,KAAS;QAET,OAAO,+BAAqB,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,CAAmB,MAAS,EAAE,KAAmB;QACrD,OAAO,sBAAY,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,kBAAkB,CAAC,UAA2B;QAC5C,uBAAa,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,qBAAqB;QACnB,uBAAa,CAAC,qBAAqB,EAAE,CAAC;IACxC,CAAC;IAED,WAAW;QACT,uBAAa,CAAC,qBAAqB,EAAE,CAAC;QACtC,uBAAa,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACF;AAxBD,2BAwBC"}
@@ -12,6 +12,7 @@ export declare class GraphRegistry {
12
12
  getSubgraphs(graph: Graph): Graph[];
13
13
  getGraphInstance(name: string): Graph;
14
14
  resolve<T extends Graph>(Graph: Constructable<T>, props?: any): T;
15
+ private ensurePropsIfLifecycleBoundGraph;
15
16
  private has;
16
17
  private getFirst;
17
18
  private set;
@@ -1 +1 @@
1
- {"version":3,"file":"GraphRegistry.d.ts","sourceRoot":"","sources":["../../../../src/graph/registry/GraphRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA+C;IACrF,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA0C;IAChF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4B;IAC3D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA8D;IAC/F,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA8B;IAE/D,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,GAAE,aAAa,CAAC,KAAK,CAAC,EAAO;IAIlF,gBAAgB,CAAC,KAAK,EAAE,KAAK;IAK7B,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE;IAMnC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAIrC,OAAO,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,CAAC;IASjE,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,GAAG;IAQX,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,uBAAuB;IAI/B,KAAK,CAAC,KAAK,EAAE,KAAK;IAQlB,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC;IAIhD,qBAAqB;IAIrB,QAAQ;CAKT;;AAED,wBAAmC"}
1
+ {"version":3,"file":"GraphRegistry.d.ts","sourceRoot":"","sources":["../../../../src/graph/registry/GraphRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA+C;IACrF,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA0C;IAChF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4B;IAC3D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA8D;IAC/F,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA8B;IAE/D,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,GAAE,aAAa,CAAC,KAAK,CAAC,EAAO;IAIlF,gBAAgB,CAAC,KAAK,EAAE,KAAK;IAK7B,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE;IAMnC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAIrC,OAAO,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,CAAC;IASjE,OAAO,CAAC,gCAAgC;IAOxC,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,GAAG;IAQX,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,uBAAuB;IAI/B,KAAK,CAAC,KAAK,EAAE,KAAK;IAQlB,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC;IAIhD,qBAAqB;IAIrB,QAAQ;CAKT;;AAED,wBAAmC"}
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GraphRegistry = void 0;
7
7
  const GraphMiddlewareChain_1 = __importDefault(require("./GraphMiddlewareChain"));
8
+ const NullProps_1 = require("./NullProps");
8
9
  class GraphRegistry {
9
10
  constructor() {
10
11
  this.constructorToInstance = new Map();
@@ -34,10 +35,16 @@ class GraphRegistry {
34
35
  if ((this.isSingleton(Graph) || this.isBoundToReactLifecycle(Graph)) && this.has(Graph)) {
35
36
  return this.getFirst(Graph);
36
37
  }
37
- const graph = this.graphMiddlewares.resolve(Graph, props);
38
+ const graph = this.graphMiddlewares.resolve(Graph, this.ensurePropsIfLifecycleBoundGraph(Graph, props));
38
39
  this.set(Graph, graph);
39
40
  return graph;
40
41
  }
42
+ ensurePropsIfLifecycleBoundGraph(Graph, props) {
43
+ if (this.isBoundToReactLifecycle(Graph)) {
44
+ return props !== null && props !== void 0 ? props : (0, NullProps_1.NullProps)(Graph);
45
+ }
46
+ return props;
47
+ }
41
48
  has(Graph) {
42
49
  var _a, _b;
43
50
  return ((_b = (_a = this.constructorToInstance.get(Graph)) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : 0) > 0;
@@ -1 +1 @@
1
- {"version":3,"file":"GraphRegistry.js","sourceRoot":"","sources":["../../../../src/graph/registry/GraphRegistry.ts"],"names":[],"mappings":";;;;;;AAGA,kFAA0D;AAE1D,MAAa,aAAa;IAA1B;QACmB,0BAAqB,GAAG,IAAI,GAAG,EAAoC,CAAC;QACpE,0BAAqB,GAAG,IAAI,GAAG,EAA+B,CAAC;QAC/D,mBAAc,GAAG,IAAI,GAAG,EAAiB,CAAC;QAC1C,qBAAgB,GAAG,IAAI,GAAG,EAAmD,CAAC;QAC9E,qBAAgB,GAAG,IAAI,8BAAoB,EAAE,CAAC;IA2EjE,CAAC;IAzEC,QAAQ,CAAC,WAAiC,EAAE,YAAoC,EAAE;QAChF,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,gBAAgB,CAAC,KAA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AAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrD,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,kBAAkB,CAAC,UAA6B;QAC9C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,qBAAqB;QACnB,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF;AAvFD,sCAuFC;AAED,kBAAe,IAAI,aAAa,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Constructable } from '../../types';
2
+ import type { Graph } from '../Graph';
3
+ export declare function NullProps(Graph: Constructable<Graph>): {};
4
+ //# sourceMappingURL=NullProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NullProps.d.ts","sourceRoot":"","sources":["../../../../src/graph/registry/NullProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,MAEpD"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NullProps = void 0;
4
+ const isDev_1 = require("../../utils/isDev");
5
+ function NullProps(Graph) {
6
+ return new Proxy({}, new NullPropsProxyHandler(Graph));
7
+ }
8
+ exports.NullProps = NullProps;
9
+ class NullPropsProxyHandler {
10
+ constructor(graph) {
11
+ this.graph = graph;
12
+ }
13
+ get(target, property, receiver) {
14
+ if (property in target)
15
+ return Reflect.get(target, property, receiver);
16
+ throw new Error(this.createErrorMessage(this.graph, property));
17
+ }
18
+ createErrorMessage(graph, property) {
19
+ const graphName = (0, isDev_1.isDev)() ? graph.name : '';
20
+ return `Tried to get prop ${property} in a @LifecycleBound graph ${graphName}, but props were undefined. `
21
+ + `If you're using Obsidian.obtain(${graphName}) - then you should pass props to it explicitly: `
22
+ + `Obsidian.obtain(${graphName}, { ${property}: 'value' });`;
23
+ }
24
+ }
25
+ //# sourceMappingURL=NullProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NullProps.js","sourceRoot":"","sources":["../../../../src/graph/registry/NullProps.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAG1C,SAAgB,SAAS,CAAC,KAA2B;IACnD,OAAO,IAAI,KAAK,CAAC,EAAE,EAAE,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;AACzD,CAAC;AAFD,8BAEC;AAED,MAAM,qBAAqB;IACzB,YAAoB,KAA2B;QAA3B,UAAK,GAAL,KAAK,CAAsB;IAAG,CAAC;IAEnD,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAE,QAAa;QACjD,IAAI,QAAQ,IAAI,MAAM;YAAE,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IACjE,CAAC;IAEO,kBAAkB,CAAC,KAA2B,EAAE,QAAgB;QACtE,MAAM,SAAS,GAAG,IAAA,aAAK,GAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,OAAO,qBAAqB,QAAQ,+BAA+B,SAAS,8BAA8B;cACxG,mCAAmC,SAAS,mDAAmD;cAC/F,mBAAmB,SAAS,OAAO,QAAQ,eAAe,CAAC;IAC/D,CAAC;CACF"}
@@ -21,4 +21,5 @@ export { MediatorObservable } from './observable/mediator/MediatorObservable';
21
21
  export { OnNext, Unsubscribe } from './observable/types';
22
22
  export { Model } from './model/Model';
23
23
  export { testKit } from '../testkit';
24
+ export { mockModel, mockGraphs } from '../testkit/index';
24
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,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,gCAAgC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEvF,eAAO,MAAM,QAAQ,WAAkB,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2B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MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/src/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.testKit = exports.Model = exports.MediatorObservable = exports.Observable = exports.useObservers = exports.useObserver = exports.injectHookWithArguments = exports.injectHook = exports.injectComponent = exports.Obsidian = exports.GraphMiddleware = exports.LifecycleBound = exports.LateInject = exports.Inject = exports.Injectable = exports.Provides = exports.ObjectGraph = exports.Singleton = exports.Graph = void 0;
20
+ exports.mockGraphs = exports.mockModel = exports.testKit = exports.Model = exports.MediatorObservable = exports.Observable = exports.useObservers = exports.useObserver = exports.injectHookWithArguments = exports.injectHook = exports.injectComponent = exports.Obsidian = exports.GraphMiddleware = exports.LifecycleBound = exports.LateInject = exports.Inject = exports.Injectable = exports.Provides = exports.ObjectGraph = exports.Singleton = exports.Graph = void 0;
21
21
  const Obsidian_1 = __importDefault(require("./Obsidian"));
22
22
  __exportStar(require("./types"), exports);
23
23
  var Graph_1 = require("./decorators/Graph");
@@ -56,4 +56,7 @@ var Model_1 = require("./model/Model");
56
56
  Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return Model_1.Model; } });
57
57
  var testkit_1 = require("../testkit");
58
58
  Object.defineProperty(exports, "testKit", { enumerable: true, get: function () { return testkit_1.testKit; } });
59
+ var index_1 = require("../testkit/index");
60
+ Object.defineProperty(exports, "mockModel", { enumerable: true, get: function () { return index_1.mockModel; } });
61
+ Object.defineProperty(exports, "mockGraphs", { enumerable: true, get: function () { return index_1.mockGraphs; } });
59
62
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AAEnC,0CAAwB;AAExB,4CAA2C;AAAlC,8FAAA,KAAK,OAAA;AACd,oDAAmD;AAA1C,sGAAA,SAAS,OAAA;AAClB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB,2DAA0D;AAAjD,oGAAA,QAAQ,OAAA;AACjB,6DAA4D;AAAnD,wGAAA,UAAU,OAAA;AACnB,qDAAoD;AAA3C,gGAAA,MAAM,OAAA;AACf,6DAA4D;AAAnD,wGAAA,UAAU,OAAA;AACnB,8DAA6D;AAApD,gHAAA,cAAc,OAAA;AACvB,oEAAmE;AAA1D,kHAAA,eAAe,OAAA;AAGX,QAAA,QAAQ,GAAG,IAAI,kBAAS,EAAE,CAAC;AAExC,0EAAyE;AAAhE,kHAAA,eAAe,OAAA;AACxB,2DAAmF;AAA1E,wGAAA,UAAU,OAAA;AAAE,qHAAA,uBAAuB,OAAA;AAE5C,wDAAuD;AAA9C,0GAAA,WAAW,OAAA;AACpB,0DAAyD;AAAhD,4GAAA,YAAY,OAAA;AACrB,sDAAqD;AAA5C,wGAAA,UAAU,OAAA;AACnB,+EAA8E;AAArE,wHAAA,kBAAkB,OAAA;AAG3B,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AAEd,sCAAqC;AAA5B,kGAAA,OAAO,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AAEnC,0CAAwB;AAExB,4CAA2C;AAAlC,8FAAA,KAAK,OAAA;AACd,oDAAmD;AAA1C,sGAAA,SAAS,OAAA;AAClB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB,2DAA0D;AAAjD,oGAAA,QAAQ,OAAA;AACjB,6DAA4D;AAAnD,wGAAA,UAAU,OAAA;AACnB,qDAAoD;AAA3C,gGAAA,MAAM,OAAA;AACf,6DAA4D;AAAnD,wGAAA,UAAU,OAAA;AACnB,8DAA6D;AAApD,gHAAA,cAAc,OAAA;AACvB,oEAAmE;AAA1D,kHAAA,eAAe,OAAA;AAGX,QAAA,QAAQ,GAAG,IAAI,kBAAS,EAAE,CAAC;AAExC,0EAAyE;AAAhE,kHAAA,eAAe,OAAA;AACxB,2DAAmF;AAA1E,wGAAA,UAAU,OAAA;AAAE,qHAAA,uBAAuB,OAAA;AAE5C,wDAAuD;AAA9C,0GAAA,WAAW,OAAA;AACpB,0DAAyD;AAAhD,4GAAA,YAAY,OAAA;AACrB,sDAAqD;AAA5C,wGAAA,UAAU,OAAA;AACnB,+EAA8E;AAArE,wHAAA,kBAAkB,OAAA;AAG3B,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AAEd,sCAAqC;AAA5B,kGAAA,OAAO,OAAA;AAChB,0CAAyD;AAAhD,kGAAA,SAAS,OAAA;AAAE,mGAAA,UAAU,OAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function isDev(): boolean;
2
+ //# sourceMappingURL=isDev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isDev.d.ts","sourceRoot":"","sources":["../../../src/utils/isDev.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,IAAI,OAAO,CAE/B"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDev = void 0;
4
+ function isDev() {
5
+ return isNodeDev() || isReactNativeDev();
6
+ }
7
+ exports.isDev = isDev;
8
+ function isNodeDev() {
9
+ var _a;
10
+ return ['test', 'development'].includes((_a = process.env['NODE_ENV']) !== null && _a !== void 0 ? _a : '');
11
+ }
12
+ function isReactNativeDev() {
13
+ var _a;
14
+ // @ts-ignore
15
+ return (_a = __DEV__) !== null && _a !== void 0 ? _a : false;
16
+ }
17
+ //# sourceMappingURL=isDev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isDev.js","sourceRoot":"","sources":["../../../src/utils/isDev.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK;IACnB,OAAO,SAAS,EAAE,IAAI,gBAAgB,EAAE,CAAC;AAC3C,CAAC;AAFD,sBAEC;AAED,SAAS,SAAS;;IAChB,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,gBAAgB;;IACvB,aAAa;IACb,OAAO,MAAA,OAAkB,mCAAI,KAAK,CAAC;AACrC,CAAC"}
@@ -2,10 +2,11 @@ import { ObjectGraph } from '../../src';
2
2
  export type Props = Record<string, any> & {
3
3
  stringFromProps: string;
4
4
  };
5
- export declare class LifecycleBoundGraph<P = {}> extends ObjectGraph<P & Props> {
5
+ export declare class LifecycleBoundGraph extends ObjectGraph<Props> {
6
6
  static timesCreated: number;
7
7
  private props;
8
- constructor(props: P & Props);
8
+ constructor(props: Props);
9
9
  computedFromProps(): string;
10
+ doesNotRequireProps(): string;
10
11
  }
11
12
  //# sourceMappingURL=LifecycleBoundGraph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LifecycleBoundGraph.d.ts","sourceRoot":"","sources":["../../../test/fixtures/LifecycleBoundGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,WAAW,EAAY,MAAM,WAAW,CAAC;AAGzD,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE,qBACa,mBAAmB,CAAC,CAAC,GAAG,EAAE,CAAE,SAAQ,WAAW,CAAC,CAAC,GAAG,KAAK,CAAC;IACrE,MAAM,CAAC,YAAY,SAAK;IACxB,OAAO,CAAC,KAAK,CAAY;gBAEb,KAAK,EAAE,CAAC,GAAG,KAAK;IAO5B,iBAAiB,IAAI,MAAM;CAK5B"}
1
+ {"version":3,"file":"LifecycleBoundGraph.d.ts","sourceRoot":"","sources":["../../../test/fixtures/LifecycleBoundGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,WAAW,EAAY,MAAM,WAAW,CAAC;AAGzD,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE,qBACa,mBAAoB,SAAQ,WAAW,CAAC,KAAK,CAAC;IACzD,MAAM,CAAC,YAAY,SAAK;IACxB,OAAO,CAAC,KAAK,CAAQ;gBAET,KAAK,EAAE,KAAK;IAOxB,iBAAiB,IAAI,MAAM;IAO3B,mBAAmB,IAAI,MAAM;CAG9B"}
@@ -24,6 +24,9 @@ let LifecycleBoundGraph = LifecycleBoundGraph_1 = class LifecycleBoundGraph exte
24
24
  ? `A string passed via props: ${this.props.stringFromProps}`
25
25
  : 'stringFromProps does not exist';
26
26
  }
27
+ doesNotRequireProps() {
28
+ return 'A string that does not require props';
29
+ }
27
30
  };
28
31
  LifecycleBoundGraph.timesCreated = 0;
29
32
  __decorate([
@@ -32,6 +35,12 @@ __decorate([
32
35
  __metadata("design:paramtypes", []),
33
36
  __metadata("design:returntype", String)
34
37
  ], LifecycleBoundGraph.prototype, "computedFromProps", null);
38
+ __decorate([
39
+ (0, src_1.Provides)(),
40
+ __metadata("design:type", Function),
41
+ __metadata("design:paramtypes", []),
42
+ __metadata("design:returntype", String)
43
+ ], LifecycleBoundGraph.prototype, "doesNotRequireProps", null);
35
44
  LifecycleBoundGraph = LifecycleBoundGraph_1 = __decorate([
36
45
  (0, LifecycleBound_1.LifecycleBound)(),
37
46
  (0, src_1.Graph)(),
@@ -1 +1 @@
1
- {"version":3,"file":"LifecycleBoundGraph.js","sourceRoot":"","sources":["../../../test/fixtures/LifecycleBoundGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mCAAyD;AACzD,wEAAqE;AAK9D,IAAM,mBAAmB,2BAAzB,MAAM,mBAA4B,SAAQ,iBAAsB;IAIrE,YAAY,KAAgB;QAC1B,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,qBAAmB,CAAC,YAAY,EAAE,CAAC;IACrC,CAAC;IAGD,iBAAiB;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe;YAC/B,CAAC,CAAC,8BAA8B,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE;YAC5D,CAAC,CAAC,gCAAgC,CAAC;IACvC,CAAC;;AAdM,gCAAY,GAAG,CAAC,CAAC;AASxB;IAAC,IAAA,cAAQ,GAAE;;;;4DAKV;AAfU,mBAAmB;IAD/B,IAAA,+BAAc,GAAE;IAAE,IAAA,WAAK,GAAE;;GACb,mBAAmB,CAgB/B;AAhBY,kDAAmB"}
1
+ {"version":3,"file":"LifecycleBoundGraph.js","sourceRoot":"","sources":["../../../test/fixtures/LifecycleBoundGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mCAAyD;AACzD,wEAAqE;AAK9D,IAAM,mBAAmB,2BAAzB,MAAM,mBAAoB,SAAQ,iBAAkB;IAIzD,YAAY,KAAY;QACtB,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,qBAAmB,CAAC,YAAY,EAAE,CAAC;IACrC,CAAC;IAGD,iBAAiB;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe;YAC/B,CAAC,CAAC,8BAA8B,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE;YAC5D,CAAC,CAAC,gCAAgC,CAAC;IACvC,CAAC;IAGD,mBAAmB;QACjB,OAAO,sCAAsC,CAAC;IAChD,CAAC;;AAnBM,gCAAY,GAAG,CAAC,CAAC;AASxB;IAAC,IAAA,cAAQ,GAAE;;;;4DAKV;AAED;IAAC,IAAA,cAAQ,GAAE;;;;8DAGV;AApBU,mBAAmB;IAD/B,IAAA,+BAAc,GAAE;IAAE,IAAA,WAAK,GAAE;;GACb,mBAAmB,CAqB/B;AArBY,kDAAmB"}
@@ -1,8 +1,13 @@
1
1
  import { ObjectGraph } from '../src/graph/ObjectGraph';
2
2
  import { Constructable } from '../src/types';
3
+ import { mockGraphs } from './mockGraphs';
3
4
  declare class TestKit {
5
+ /**
6
+ * @deprecated testKit.mockGraphs is deprecated, use mockGraphs instead
7
+ */
4
8
  mockGraphs(graphNameToGraph: Record<string, Constructable<ObjectGraph> | ((props: any) => ObjectGraph)>): void;
5
9
  }
10
+ export { mockModel } from './mockModel';
11
+ export { mockGraphs };
6
12
  export declare const testKit: TestKit;
7
- export {};
8
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../testkit/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,cAAM,OAAO;IACJ,UAAU,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC;CAY/G;AAED,eAAO,MAAM,OAAO,SAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../testkit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAM,OAAO;IACX;;OAEG;IACI,UAAU,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC;CAK/G;AAED,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,eAAO,MAAM,OAAO,SAAgB,CAAC"}
@@ -1,25 +1,19 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.testKit = void 0;
7
- const ObjectGraph_1 = require("../src/graph/ObjectGraph");
8
- const GraphMiddleware_1 = require("../src/graph/registry/GraphMiddleware");
9
- const GraphRegistry_1 = __importDefault(require("../src/graph/registry/GraphRegistry"));
3
+ exports.testKit = exports.mockGraphs = exports.mockModel = void 0;
4
+ const mockGraphs_1 = require("./mockGraphs");
5
+ Object.defineProperty(exports, "mockGraphs", { enumerable: true, get: function () { return mockGraphs_1.mockGraphs; } });
10
6
  class TestKit {
7
+ /**
8
+ * @deprecated testKit.mockGraphs is deprecated, use mockGraphs instead
9
+ */
11
10
  mockGraphs(graphNameToGraph) {
12
- const graphMiddleware = new class extends GraphMiddleware_1.GraphMiddleware {
13
- resolve(resolveChain, Graph, props) {
14
- if (graphNameToGraph[Graph.name]) {
15
- const GraphOrGenerator = graphNameToGraph[Graph.name];
16
- return (0, ObjectGraph_1.isGraph)(GraphOrGenerator) ? new GraphOrGenerator(props) : GraphOrGenerator(props);
17
- }
18
- return resolveChain.proceed(Graph, props);
19
- }
20
- }();
21
- GraphRegistry_1.default.addGraphMiddleware(graphMiddleware);
11
+ // eslint-disable-next-line no-console
12
+ console.warn('testKit.mockGraphs is deprecated, use mockGraphs instead');
13
+ return (0, mockGraphs_1.mockGraphs)(graphNameToGraph);
22
14
  }
23
15
  }
16
+ var mockModel_1 = require("./mockModel");
17
+ Object.defineProperty(exports, "mockModel", { enumerable: true, get: function () { return mockModel_1.mockModel; } });
24
18
  exports.testKit = new TestKit();
25
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../testkit/index.ts"],"names":[],"mappings":";;;;;;AACA,0DAAgE;AAChE,2EAAwE;AAExE,wFAAgE;AAEhE,MAAM,OAAO;IACJ,UAAU,CAAC,gBAA4F;QAC5G,MAAM,eAAe,GAAG,IAAI,KAAM,SAAQ,iCAAe;YACvD,OAAO,CAAQ,YAA+B,EAAE,KAAiC,EAAE,KAAa;gBAC9F,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;oBAChC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBACtD,OAAO,IAAA,qBAAO,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;iBAC1F;gBACD,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC5C,CAAC;SACF,EAAE,CAAC;QACJ,uBAAa,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACpD,CAAC;CACF;AAEY,QAAA,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../testkit/index.ts"],"names":[],"mappings":";;;AAEA,6CAA0C;AAcjC,2FAdA,uBAAU,OAcA;AAZnB,MAAM,OAAO;IACX;;OAEG;IACI,UAAU,CAAC,gBAA4F;QAC5G,sCAAsC;QACtC,OAAO,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;QACzE,OAAO,IAAA,uBAAU,EAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;CACF;AAED,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAGL,QAAA,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ObjectGraph } from '../src/graph/ObjectGraph';
2
+ import { Constructable } from '../src/types';
3
+ export declare function mockGraphs(graphNameToGraph: Record<string, Constructable<ObjectGraph> | ((props: any) => ObjectGraph)>): void;
4
+ //# sourceMappingURL=mockGraphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockGraphs.d.ts","sourceRoot":"","sources":["../../testkit/mockGraphs.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,wBAAgB,UAAU,CACxB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC,QAY7F"}
@@ -0,0 +1,23 @@
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.mockGraphs = void 0;
7
+ const ObjectGraph_1 = require("../src/graph/ObjectGraph");
8
+ const GraphMiddleware_1 = require("../src/graph/registry/GraphMiddleware");
9
+ const GraphRegistry_1 = __importDefault(require("../src/graph/registry/GraphRegistry"));
10
+ function mockGraphs(graphNameToGraph) {
11
+ const graphMiddleware = new class extends GraphMiddleware_1.GraphMiddleware {
12
+ resolve(resolveChain, Graph, props) {
13
+ if (graphNameToGraph[Graph.name]) {
14
+ const GraphOrGenerator = graphNameToGraph[Graph.name];
15
+ return (0, ObjectGraph_1.isGraph)(GraphOrGenerator) ? new GraphOrGenerator(props) : GraphOrGenerator(props);
16
+ }
17
+ return resolveChain.proceed(Graph, props);
18
+ }
19
+ }();
20
+ GraphRegistry_1.default.addGraphMiddleware(graphMiddleware);
21
+ }
22
+ exports.mockGraphs = mockGraphs;
23
+ //# sourceMappingURL=mockGraphs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockGraphs.js","sourceRoot":"","sources":["../../testkit/mockGraphs.ts"],"names":[],"mappings":";;;;;;AACA,0DAAgE;AAChE,2EAAwE;AAExE,wFAAgE;AAEhE,SAAgB,UAAU,CACxB,gBAA4F;IAE5F,MAAM,eAAe,GAAG,IAAI,KAAM,SAAQ,iCAAe;QACvD,OAAO,CAAQ,YAA+B,EAAE,KAAiC,EAAE,KAAa;YAC9F,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBAChC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACtD,OAAO,IAAA,qBAAO,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;aAC1F;YACD,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC5C,CAAC;KACF,EAAE,CAAC;IACJ,uBAAa,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;AACpD,CAAC;AAbD,gCAaC"}
@@ -0,0 +1,3 @@
1
+ import { Model } from '../src/model/Model';
2
+ export declare function mockModel<T extends Model, S extends Partial<T>>(mock: S): T;
3
+ //# sourceMappingURL=mockModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockModel.d.ts","sourceRoot":"","sources":["../../testkit/mockModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,wBAAgB,SAAS,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAO3E"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockModel = void 0;
4
+ const Model_1 = require("../src/model/Model");
5
+ function mockModel(mock) {
6
+ return new class extends Model_1.Model {
7
+ constructor() {
8
+ super();
9
+ Object.assign(this, mock);
10
+ }
11
+ }();
12
+ }
13
+ exports.mockModel = mockModel;
14
+ //# sourceMappingURL=mockModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockModel.js","sourceRoot":"","sources":["../../testkit/mockModel.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAE3C,SAAgB,SAAS,CAAwC,IAAO;IACtE,OAAO,IAAI,KAAM,SAAQ,aAAK;QAC5B;YACE,KAAK,EAAE,CAAC;YACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC;KACF,EAAO,CAAC;AACX,CAAC;AAPD,8BAOC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-obsidian",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Dependency injection framework for React and React Native applications",
5
5
  "scripts": {
6
6
  "prepack": "npm run lint && tsc --project tsconfig.prod.json",
package/src/Obsidian.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import graphRegistry from './graph/registry/GraphRegistry';
2
2
  import { ObjectGraph } from './graph/ObjectGraph';
3
- import { Constructable, GraphInternals, ServiceLocator } from './types';
3
+ import { GraphInternals, ServiceLocator } from './types';
4
4
  import { GraphMiddleware } from './graph/registry/GraphMiddleware';
5
5
  import lateInjector from './injectors/class/LateInjector';
6
6
  import serviceLocatorFactory from './graph/ServiceLocatorFactory';
7
7
 
8
8
  export default class Obsidian {
9
- obtain<T extends ObjectGraph<P>, P = any>(
10
- Graph: Constructable<T>,
9
+ obtain<T extends ObjectGraph<P>, P>(
10
+ Graph: new(...args: P[]) => T,
11
11
  props?: P,
12
12
  ): ServiceLocator<Omit<T, GraphInternals>> {
13
13
  return serviceLocatorFactory.fromGraph(Graph, props);
@@ -2,6 +2,7 @@ import { Constructable } from '../../types';
2
2
  import { Graph } from '../Graph';
3
3
  import { Middleware } from './Middleware';
4
4
  import GraphMiddlewareChain from './GraphMiddlewareChain';
5
+ import { NullProps as createNullProps } from './NullProps';
5
6
 
6
7
  export class GraphRegistry {
7
8
  private readonly constructorToInstance = new Map<Constructable<Graph>, Set<Graph>>();
@@ -33,11 +34,18 @@ export class GraphRegistry {
33
34
  if ((this.isSingleton(Graph) || this.isBoundToReactLifecycle(Graph)) && this.has(Graph)) {
34
35
  return this.getFirst(Graph);
35
36
  }
36
- const graph = this.graphMiddlewares.resolve(Graph, props);
37
+ const graph = this.graphMiddlewares.resolve(Graph, this.ensurePropsIfLifecycleBoundGraph(Graph, props));
37
38
  this.set(Graph, graph);
38
39
  return graph as T;
39
40
  }
40
41
 
42
+ private ensurePropsIfLifecycleBoundGraph<T extends Graph>(Graph: Constructable<T>, props?: any): any {
43
+ if (this.isBoundToReactLifecycle(Graph)) {
44
+ return props ?? createNullProps(Graph);
45
+ }
46
+ return props;
47
+ }
48
+
41
49
  private has(Graph: Constructable<Graph>): boolean {
42
50
  return (this.constructorToInstance.get(Graph)?.size ?? 0) > 0;
43
51
  }
@@ -0,0 +1,23 @@
1
+ import type { Constructable } from '../../types';
2
+ import { isDev } from '../../utils/isDev';
3
+ import type { Graph } from '../Graph';
4
+
5
+ export function NullProps(Graph: Constructable<Graph>) {
6
+ return new Proxy({}, new NullPropsProxyHandler(Graph));
7
+ }
8
+
9
+ class NullPropsProxyHandler implements ProxyHandler<{}> {
10
+ constructor(private graph: Constructable<Graph>) {}
11
+
12
+ get(target: object, property: string, receiver: any) {
13
+ if (property in target) return Reflect.get(target, property, receiver);
14
+ throw new Error(this.createErrorMessage(this.graph, property));
15
+ }
16
+
17
+ private createErrorMessage(graph: Constructable<Graph>, property: string) {
18
+ const graphName = isDev() ? graph.name : '';
19
+ return `Tried to get prop ${property} in a @LifecycleBound graph ${graphName}, but props were undefined. `
20
+ + `If you're using Obsidian.obtain(${graphName}) - then you should pass props to it explicitly: `
21
+ + `Obsidian.obtain(${graphName}, { ${property}: 'value' });`;
22
+ }
23
+ }
package/src/index.ts CHANGED
@@ -28,3 +28,4 @@ export { OnNext, Unsubscribe } from './observable/types';
28
28
  export { Model } from './model/Model';
29
29
 
30
30
  export { testKit } from '../testkit';
31
+ export { mockModel, mockGraphs } from '../testkit/index';
@@ -0,0 +1,12 @@
1
+ export function isDev(): boolean {
2
+ return isNodeDev() || isReactNativeDev();
3
+ }
4
+
5
+ function isNodeDev(): boolean {
6
+ return ['test', 'development'].includes(process.env['NODE_ENV'] ?? '');
7
+ }
8
+
9
+ function isReactNativeDev(): boolean {
10
+ // @ts-ignore
11
+ return __DEV__ as boolean ?? false;
12
+ }
package/testkit/index.ts CHANGED
@@ -1,22 +1,19 @@
1
- import { GraphResolveChain } from '../src/graph/registry/GraphResolveChain';
2
- import { isGraph, ObjectGraph } from '../src/graph/ObjectGraph';
3
- import { GraphMiddleware } from '../src/graph/registry/GraphMiddleware';
1
+ import { ObjectGraph } from '../src/graph/ObjectGraph';
4
2
  import { Constructable } from '../src/types';
5
- import graphRegistry from '../src/graph/registry/GraphRegistry';
3
+ import { mockGraphs } from './mockGraphs';
6
4
 
7
5
  class TestKit {
6
+ /**
7
+ * @deprecated testKit.mockGraphs is deprecated, use mockGraphs instead
8
+ */
8
9
  public mockGraphs(graphNameToGraph: Record<string, Constructable<ObjectGraph> | ((props: any) => ObjectGraph)>) {
9
- const graphMiddleware = new class extends GraphMiddleware {
10
- resolve<Props>(resolveChain: GraphResolveChain, Graph: Constructable<ObjectGraph>, props?: Props) {
11
- if (graphNameToGraph[Graph.name]) {
12
- const GraphOrGenerator = graphNameToGraph[Graph.name];
13
- return isGraph(GraphOrGenerator) ? new GraphOrGenerator(props) : GraphOrGenerator(props);
14
- }
15
- return resolveChain.proceed(Graph, props);
16
- }
17
- }();
18
- graphRegistry.addGraphMiddleware(graphMiddleware);
10
+ // eslint-disable-next-line no-console
11
+ console.warn('testKit.mockGraphs is deprecated, use mockGraphs instead');
12
+ return mockGraphs(graphNameToGraph);
19
13
  }
20
14
  }
21
15
 
16
+ export { mockModel } from './mockModel';
17
+ export { mockGraphs };
18
+
22
19
  export const testKit = new TestKit();
@@ -0,0 +1,20 @@
1
+ import { GraphResolveChain } from '../src/graph/registry/GraphResolveChain';
2
+ import { isGraph, ObjectGraph } from '../src/graph/ObjectGraph';
3
+ import { GraphMiddleware } from '../src/graph/registry/GraphMiddleware';
4
+ import { Constructable } from '../src/types';
5
+ import graphRegistry from '../src/graph/registry/GraphRegistry';
6
+
7
+ export function mockGraphs(
8
+ graphNameToGraph: Record<string, Constructable<ObjectGraph> | ((props: any) => ObjectGraph)>,
9
+ ) {
10
+ const graphMiddleware = new class extends GraphMiddleware {
11
+ resolve<Props>(resolveChain: GraphResolveChain, Graph: Constructable<ObjectGraph>, props?: Props) {
12
+ if (graphNameToGraph[Graph.name]) {
13
+ const GraphOrGenerator = graphNameToGraph[Graph.name];
14
+ return isGraph(GraphOrGenerator) ? new GraphOrGenerator(props) : GraphOrGenerator(props);
15
+ }
16
+ return resolveChain.proceed(Graph, props);
17
+ }
18
+ }();
19
+ graphRegistry.addGraphMiddleware(graphMiddleware);
20
+ }
@@ -0,0 +1,10 @@
1
+ import { Model } from '../src/model/Model';
2
+
3
+ export function mockModel<T extends Model, S extends Partial<T>>(mock: S): T {
4
+ return new class extends Model {
5
+ constructor() {
6
+ super();
7
+ Object.assign(this, mock);
8
+ }
9
+ }() as T;
10
+ }
@@ -1,10 +0,0 @@
1
- steps:
2
- - label: ":crossed_swords: Build"
3
- command: |
4
- nvm install
5
- npm install
6
- npm run test
7
- if [[ $(echo $BUILDKITE_MESSAGE | tr '[:upper:]' '[:lower:]') =~ release ]];then
8
- cp .buildkite/.npmrc .
9
- npm publish
10
- fi
package/.eslintignore DELETED
@@ -1 +0,0 @@
1
- dist/*