@migration-planner-ui/ioc 0.0.32 → 0.0.35

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.
@@ -0,0 +1,8 @@
1
+ /** A naive, singleton-scoped dependency injection container */
2
+ export declare class Container {
3
+ #private;
4
+ constructor();
5
+ get<T>(registeredInterfaceSymbol: symbol): T;
6
+ register<T = unknown>(registeredInterfaceSymbol: symbol, value: T): Container;
7
+ }
8
+ //# sourceMappingURL=Container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../src/Container.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,qBAAa,SAAS;;;IAOpB,GAAG,CAAC,CAAC,EAAE,yBAAyB,EAAE,MAAM,GAAG,CAAC;IAK5C,QAAQ,CAAC,CAAC,GAAG,OAAO,EAClB,yBAAyB,EAAE,MAAM,EACjC,KAAK,EAAE,CAAC,GACP,SAAS;CAKb"}
@@ -0,0 +1,28 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _Container_registry;
13
+ /** A naive, singleton-scoped dependency injection container */
14
+ export class Container {
15
+ constructor() {
16
+ _Container_registry.set(this, void 0);
17
+ __classPrivateFieldSet(this, _Container_registry, {}, "f");
18
+ }
19
+ get(registeredInterfaceSymbol) {
20
+ const value = __classPrivateFieldGet(this, _Container_registry, "f")[registeredInterfaceSymbol];
21
+ return value;
22
+ }
23
+ register(registeredInterfaceSymbol, value) {
24
+ __classPrivateFieldGet(this, _Container_registry, "f")[registeredInterfaceSymbol] = value;
25
+ return this;
26
+ }
27
+ }
28
+ _Container_registry = new WeakMap();
@@ -0,0 +1,3 @@
1
+ import type { Container } from "./Container.js";
2
+ export declare const Context: import("react").Context<Container>;
3
+ //# sourceMappingURL=Context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../src/Context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,OAAO,oCAAwC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { createContext } from "react";
2
+ export const Context = createContext(null);
@@ -0,0 +1,5 @@
1
+ import type { Container } from "./Container.js";
2
+ export declare const Provider: React.FC<React.PropsWithChildren<{
3
+ container: Container;
4
+ }>>;
5
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../src/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAC7B,KAAK,CAAC,iBAAiB,CAAC;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC,CAIlD,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Context } from "./Context.js";
3
+ export const Provider = (props) => {
4
+ const { container, children } = props;
5
+ return _jsx(Context.Provider, { value: container, children: children });
6
+ };
@@ -0,0 +1,2 @@
1
+ export declare function useInjection<T>(registeredInterfaceSymbol: symbol): T;
2
+ //# sourceMappingURL=UseInjection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseInjection.d.ts","sourceRoot":"","sources":["../../src/hooks/UseInjection.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAAC,CAAC,EAAE,yBAAyB,EAAE,MAAM,GAAG,CAAC,CAOpE"}
@@ -0,0 +1,9 @@
1
+ import { useContext } from "react";
2
+ import { Context } from "../Context.js";
3
+ export function useInjection(registeredInterfaceSymbol) {
4
+ const container = useContext(Context);
5
+ if (!container) {
6
+ throw new ReferenceError("useInjection must be used inside its Provider");
7
+ }
8
+ return container.get(registeredInterfaceSymbol);
9
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./Container.js";
2
+ export * from "./Context.js";
3
+ export * from "./hooks/UseInjection.js";
4
+ export * from "./Provider.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@migration-planner-ui/ioc",
3
- "version": "0.0.32",
3
+ "version": "0.0.35",
4
4
  "description": "A basic IoC solution for React apps (inspired by InversifyJs)",
5
5
  "author": "Jonathan Kilzi <jkilzi@redhat.com>",
6
+ "license": "Apache-2.0",
6
7
  "repository": {
7
8
  "type": "git",
8
9
  "url": "https://github.com/kubev2v/migration-planner-ui.git",
@@ -45,5 +46,7 @@
45
46
  "react-dom": "^18.3.1",
46
47
  "react-router-dom": "^6.26.0"
47
48
  },
48
- "stableVersion": "1.1.1"
49
+ "files": [
50
+ "dist"
51
+ ]
49
52
  }
package/biome.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
3
- "extends": "//",
4
- "linter": {
5
- "enabled": true,
6
- "domains": {
7
- "react": "recommended"
8
- }
9
- }
10
- }
package/src/Container.ts DELETED
@@ -1,22 +0,0 @@
1
- /** A naive, singleton-scoped dependency injection container */
2
- export class Container {
3
- readonly #registry: Record<symbol, unknown>;
4
-
5
- constructor() {
6
- this.#registry = {};
7
- }
8
-
9
- get<T>(registeredInterfaceSymbol: symbol): T {
10
- const value = this.#registry[registeredInterfaceSymbol] as T;
11
- return value;
12
- }
13
-
14
- register<T = unknown>(
15
- registeredInterfaceSymbol: symbol,
16
- value: T,
17
- ): Container {
18
- this.#registry[registeredInterfaceSymbol] = value;
19
-
20
- return this;
21
- }
22
- }
package/src/Context.tsx DELETED
@@ -1,4 +0,0 @@
1
- import { createContext } from "react";
2
- import type { Container } from "./Container.ts";
3
-
4
- export const Context = createContext<Container | null>(null);
package/src/Provider.tsx DELETED
@@ -1,11 +0,0 @@
1
- import type React from "react";
2
- import type { PropsWithChildren } from "react";
3
- import type { Container } from "./Container.js";
4
- import { Context } from "./Context.js";
5
-
6
- export const Provider: React.FC<PropsWithChildren<{ container: Container }>> = (
7
- props,
8
- ) => {
9
- const { container, children } = props;
10
- return <Context.Provider value={container}>{children}</Context.Provider>;
11
- };
@@ -1,11 +0,0 @@
1
- import { useContext } from "react";
2
- import { Context } from "../Context.js";
3
-
4
- export function useInjection<T>(registeredInterfaceSymbol: symbol): T {
5
- const container = useContext(Context);
6
- if (!container) {
7
- throw new ReferenceError("useInjection must be used inside its Provider");
8
- }
9
-
10
- return container.get<T>(registeredInterfaceSymbol);
11
- }
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": ".tmp/tsconfig.tsbuildinfo",
4
- "composite": true,
5
- "declaration": true,
6
- "declarationMap": true,
7
- "outDir": "dist",
8
- "rootDir": "src",
9
- "target": "es6",
10
- "module": "nodenext",
11
- "moduleResolution": "nodenext",
12
- "jsx": "react-jsx"
13
- }
14
- }
File without changes