@venizia/ardor-react 0.1.1-1 → 0.1.1-3
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/README.md +1 -1
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +1 -1
- package/dist/contexts/index.d.ts +1 -1
- package/dist/contexts/index.js +1 -1
- package/dist/hooks/index.d.ts +11 -10
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +11 -10
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/redux/index.d.ts +2 -2
- package/dist/hooks/redux/index.js +2 -2
- package/dist/hooks/redux/use-app-selector.js +1 -1
- package/dist/hooks/redux/use-app-selector.js.map +1 -1
- package/dist/hooks/use-application-context.js +1 -1
- package/dist/hooks/use-artifact.d.ts +21 -0
- package/dist/hooks/use-artifact.d.ts.map +1 -0
- package/dist/hooks/use-artifact.js +50 -0
- package/dist/hooks/use-artifact.js.map +1 -0
- package/dist/hooks/use-autosave.js +1 -1
- package/dist/hooks/use-injectable.d.ts +9 -0
- package/dist/hooks/use-injectable.d.ts.map +1 -1
- package/dist/hooks/use-injectable.js +14 -5
- package/dist/hooks/use-injectable.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/package.json +7 -10
package/README.md
CHANGED
package/dist/common/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './types';
|
|
1
|
+
export * from './types.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/common/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './types';
|
|
1
|
+
export * from './types.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/contexts/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './application';
|
|
1
|
+
export * from './application.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/contexts/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './application';
|
|
1
|
+
export * from './application.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export * from './redux';
|
|
2
|
-
export * from './use-application-context';
|
|
3
|
-
export * from './use-
|
|
4
|
-
export * from './use-
|
|
5
|
-
export * from './use-
|
|
6
|
-
export * from './use-
|
|
7
|
-
export * from './use-
|
|
8
|
-
export * from './use-
|
|
9
|
-
export * from './use-
|
|
10
|
-
export * from './use-
|
|
1
|
+
export * from './redux/index.js';
|
|
2
|
+
export * from './use-application-context.js';
|
|
3
|
+
export * from './use-artifact.js';
|
|
4
|
+
export * from './use-autosave.js';
|
|
5
|
+
export * from './use-before-unload.js';
|
|
6
|
+
export * from './use-confirm.js';
|
|
7
|
+
export * from './use-copy-to-clipboard.js';
|
|
8
|
+
export * from './use-debounce.js';
|
|
9
|
+
export * from './use-injectable.js';
|
|
10
|
+
export * from './use-sizer.js';
|
|
11
|
+
export * from './use-window-dimensions.js';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export * from './redux';
|
|
2
|
-
export * from './use-application-context';
|
|
3
|
-
export * from './use-
|
|
4
|
-
export * from './use-
|
|
5
|
-
export * from './use-
|
|
6
|
-
export * from './use-
|
|
7
|
-
export * from './use-
|
|
8
|
-
export * from './use-
|
|
9
|
-
export * from './use-
|
|
10
|
-
export * from './use-
|
|
1
|
+
export * from './redux/index.js';
|
|
2
|
+
export * from './use-application-context.js';
|
|
3
|
+
export * from './use-artifact.js';
|
|
4
|
+
export * from './use-autosave.js';
|
|
5
|
+
export * from './use-before-unload.js';
|
|
6
|
+
export * from './use-confirm.js';
|
|
7
|
+
export * from './use-copy-to-clipboard.js';
|
|
8
|
+
export * from './use-debounce.js';
|
|
9
|
+
export * from './use-injectable.js';
|
|
10
|
+
export * from './use-sizer.js';
|
|
11
|
+
export * from './use-window-dimensions.js';
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './use-app-dispatch';
|
|
2
|
-
export * from './use-app-selector';
|
|
1
|
+
export * from './use-app-dispatch.js';
|
|
2
|
+
export * from './use-app-selector.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './use-app-dispatch';
|
|
2
|
-
export * from './use-app-selector';
|
|
1
|
+
export * from './use-app-dispatch.js';
|
|
2
|
+
export * from './use-app-selector.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-app-selector.js","sourceRoot":"","sources":["../../../src/hooks/redux/use-app-selector.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"use-app-selector.js","sourceRoot":"","sources":["../../../src/hooks/redux/use-app-selector.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAM,EAAE;IACxC,MAAM,cAAc,GAAG,WAAW,CAAC,SAAS,EAAK,CAAC;IAElD,MAAM,uBAAuB,GAAG,CAAI,QAAyB,EAAE,EAAE;QAC/D,OAAO,cAAc,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC,CAAC;IAEF,MAAM,oBAAoB,GAAG,CAAI,QAAyB,EAAE,EAAE;QAC5D,OAAO,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC,CAAC;IAEF,OAAO;QACL,cAAc;QACd,uBAAuB;QACvB,oBAAoB;KACrB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { getError } from '@venizia/ignis-inversion';
|
|
3
|
-
import { ApplicationContext } from '../contexts/application';
|
|
3
|
+
import { ApplicationContext } from '../contexts/application.js';
|
|
4
4
|
export const useApplicationContext = () => {
|
|
5
5
|
const rs = React.useContext(ApplicationContext);
|
|
6
6
|
if (!rs?.container) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type AnyType } from '@venizia/ardor-kernel';
|
|
2
|
+
import { Container, type TClass } from '@venizia/ignis-inversion';
|
|
3
|
+
import { type TUseInjectableKeys } from './use-injectable.js';
|
|
4
|
+
/** By class: the return type is inferred from the target. */
|
|
5
|
+
export interface IUseArtifactByTarget<T> {
|
|
6
|
+
container?: Container;
|
|
7
|
+
target: TClass<T>;
|
|
8
|
+
key?: never;
|
|
9
|
+
}
|
|
10
|
+
/** By key: the caller supplies the type. */
|
|
11
|
+
export interface IUseArtifactByKey {
|
|
12
|
+
container?: Container;
|
|
13
|
+
key: TUseInjectableKeys;
|
|
14
|
+
target?: never;
|
|
15
|
+
}
|
|
16
|
+
export declare const useService: <T = AnyType>(opts: IUseArtifactByTarget<T> | IUseArtifactByKey) => T;
|
|
17
|
+
export declare const useProvider: <T = AnyType>(opts: IUseArtifactByTarget<T> | IUseArtifactByKey) => T;
|
|
18
|
+
export declare const useComponent: <T = AnyType>(opts: IUseArtifactByTarget<T> | IUseArtifactByKey) => T;
|
|
19
|
+
export declare const useConfiguration: <T = AnyType>(opts: IUseArtifactByTarget<T> | IUseArtifactByKey) => T;
|
|
20
|
+
export declare const useRepository: <T = AnyType>(opts: IUseArtifactByTarget<T> | IUseArtifactByKey) => T;
|
|
21
|
+
//# sourceMappingURL=use-artifact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-artifact.d.ts","sourceRoot":"","sources":["../../src/hooks/use-artifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAqB,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAY,KAAK,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAGL,KAAK,kBAAkB,EAExB,MAAM,kBAAkB,CAAC;AAE1B,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAClB,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,GAAG,EAAE,kBAAkB,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB;AAgCD,eAAO,MAAM,UAAU,GAAI,CAAC,GAAG,OAAO,EAAE,MAAM,oBAAoB,CAAC,CAAC,CAAC,GAAG,iBAAiB,KAAG,CAKxF,CAAC;AAEL,eAAO,MAAM,WAAW,GAAI,CAAC,GAAG,OAAO,EAAE,MAAM,oBAAoB,CAAC,CAAC,CAAC,GAAG,iBAAiB,KAAG,CAKzF,CAAC;AAEL,eAAO,MAAM,YAAY,GAAI,CAAC,GAAG,OAAO,EAAE,MAAM,oBAAoB,CAAC,CAAC,CAAC,GAAG,iBAAiB,KAAG,CAK1F,CAAC;AAEL,eAAO,MAAM,gBAAgB,GAAI,CAAC,GAAG,OAAO,EAC1C,MAAM,oBAAoB,CAAC,CAAC,CAAC,GAAG,iBAAiB,KAChD,CAKC,CAAC;AAEL,eAAO,MAAM,aAAa,GAAI,CAAC,GAAG,OAAO,EAAE,MAAM,oBAAoB,CAAC,CAAC,CAAC,GAAG,iBAAiB,KAAG,CAK3F,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BindingNamespaces } from '@venizia/ardor-kernel';
|
|
2
|
+
import { getError } from '@venizia/ignis-inversion';
|
|
3
|
+
import { useInjectable, useInjectableContainer, } from './use-injectable.js';
|
|
4
|
+
/**
|
|
5
|
+
* `useService`, `useRepository`, `useProvider`, `useComponent`, `useConfiguration`. Unlike
|
|
6
|
+
* `useInjectable`, a `{ target }` must be bound under the hook's namespace, or it throws.
|
|
7
|
+
*/
|
|
8
|
+
const resolveInNamespace = (opts) => {
|
|
9
|
+
const { options, namespace, hook } = opts;
|
|
10
|
+
// Same inputs as `useInjectable`, so the check and the resolve read one container.
|
|
11
|
+
const container = useInjectableContainer({ container: options.container });
|
|
12
|
+
// A `key` carries its namespace in the string; only a `target` is checked.
|
|
13
|
+
if (options.target) {
|
|
14
|
+
const key = container.getMetadataRegistry().getBindingKey({ target: options.target });
|
|
15
|
+
// `String(...)`: a key may be a symbol, which a template literal throws on.
|
|
16
|
+
const bound = key === undefined ? undefined : String(key);
|
|
17
|
+
if (bound && !bound.startsWith(`${namespace}.`)) {
|
|
18
|
+
throw getError({
|
|
19
|
+
message: `[${hook}] ${options.target.name} is bound as "${bound}", not under "${namespace}". Use the hook for that namespace, or change the stereotype on the class.`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return useInjectable(options);
|
|
24
|
+
};
|
|
25
|
+
export const useService = (opts) => resolveInNamespace({
|
|
26
|
+
options: opts,
|
|
27
|
+
namespace: BindingNamespaces.SERVICE,
|
|
28
|
+
hook: 'useService',
|
|
29
|
+
});
|
|
30
|
+
export const useProvider = (opts) => resolveInNamespace({
|
|
31
|
+
options: opts,
|
|
32
|
+
namespace: BindingNamespaces.PROVIDER,
|
|
33
|
+
hook: 'useProvider',
|
|
34
|
+
});
|
|
35
|
+
export const useComponent = (opts) => resolveInNamespace({
|
|
36
|
+
options: opts,
|
|
37
|
+
namespace: BindingNamespaces.COMPONENT,
|
|
38
|
+
hook: 'useComponent',
|
|
39
|
+
});
|
|
40
|
+
export const useConfiguration = (opts) => resolveInNamespace({
|
|
41
|
+
options: opts,
|
|
42
|
+
namespace: BindingNamespaces.CONFIGURATION,
|
|
43
|
+
hook: 'useConfiguration',
|
|
44
|
+
});
|
|
45
|
+
export const useRepository = (opts) => resolveInNamespace({
|
|
46
|
+
options: opts,
|
|
47
|
+
namespace: BindingNamespaces.REPOSITORY,
|
|
48
|
+
hook: 'useRepository',
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=use-artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-artifact.js","sourceRoot":"","sources":["../../src/hooks/use-artifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAa,QAAQ,EAAe,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EACL,aAAa,EACb,sBAAsB,GAGvB,MAAM,kBAAkB,CAAC;AAgB1B;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAI,IAI9B,EAAK,EAAE;IACN,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAE1C,mFAAmF;IACnF,MAAM,SAAS,GAAG,sBAAsB,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAE3E,2EAA2E;IAC3E,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,GAAG,GAAG,SAAS,CAAC,mBAAmB,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QACtF,4EAA4E;QAC5E,MAAM,KAAK,GAAG,GAAG,KAAK,SAAS,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AAO,EAAE,IAAI;IACb,SAAS,EAAE,iBAAiB,CAAC,UAAU;IACvC,IAAI,EAAE,eAAe;CACtB,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useDebounce } from './use-debounce';
|
|
2
|
+
import { useDebounce } from './use-debounce.js';
|
|
3
3
|
export const useAutosave = (params) => {
|
|
4
4
|
const { data, onSave, interval = 2000, enableSaveOnUnmount, disabled } = params;
|
|
5
5
|
const valueOnCleanup = React.useRef(data);
|
|
@@ -13,5 +13,14 @@ export type TUseInjectableOptions = {
|
|
|
13
13
|
key?: never;
|
|
14
14
|
target: TClass<AnyType>;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* The container an injectable hook resolves from: the one passed in, else the one the application
|
|
18
|
+
* context holds. Shared so that every hook built on `useInjectable` reads the SAME container it
|
|
19
|
+
* resolves from - a hook that re-derived it would be checking one container and resolving from
|
|
20
|
+
* another, and the check would pass by accident.
|
|
21
|
+
*/
|
|
22
|
+
export declare const useInjectableContainer: (opts?: {
|
|
23
|
+
container?: Container;
|
|
24
|
+
}) => Container;
|
|
16
25
|
export declare const useInjectable: <T>(opts: TUseInjectableOptions) => T;
|
|
17
26
|
//# sourceMappingURL=use-injectable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-injectable.d.ts","sourceRoot":"","sources":["../../src/hooks/use-injectable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAY,KAAK,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,KAAK,OAAO,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAGjF,MAAM,WAAW,2BAA2B;CAAG;AAE/C,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC;AAEtF,MAAM,MAAM,kBAAkB,G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EF,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,MAAM,qBAAqB,MAuB3D,CAAC"}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { getError } from '@venizia/ignis-inversion';
|
|
3
|
-
import { ApplicationContext } from '../contexts/application';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { ApplicationContext } from '../contexts/application.js';
|
|
4
|
+
/**
|
|
5
|
+
* The container an injectable hook resolves from: the one passed in, else the one the application
|
|
6
|
+
* context holds. Shared so that every hook built on `useInjectable` reads the SAME container it
|
|
7
|
+
* resolves from - a hook that re-derived it would be checking one container and resolving from
|
|
8
|
+
* another, and the check would pass by accident.
|
|
9
|
+
*/
|
|
10
|
+
export const useInjectableContainer = (opts) => {
|
|
6
11
|
const applicationContext = React.useContext(ApplicationContext);
|
|
7
|
-
const container =
|
|
12
|
+
const container = opts?.container ?? applicationContext.container;
|
|
8
13
|
if (!container) {
|
|
9
14
|
throw getError({
|
|
10
15
|
message: '[useInjectable] Failed to determine injectable container!',
|
|
11
16
|
});
|
|
12
17
|
}
|
|
18
|
+
return container;
|
|
19
|
+
};
|
|
20
|
+
export const useInjectable = (opts) => {
|
|
21
|
+
const container = useInjectableContainer({ container: opts?.container });
|
|
13
22
|
const { key, target } = opts;
|
|
14
23
|
if (key) {
|
|
15
24
|
return container.get({ key });
|
|
@@ -22,7 +31,7 @@ export const useInjectable = (opts) => {
|
|
|
22
31
|
const resolved = container.getMetadataRegistry().getBindingKey({ target });
|
|
23
32
|
if (!resolved) {
|
|
24
33
|
throw getError({
|
|
25
|
-
message: `[useInjectable]
|
|
34
|
+
message: `[useInjectable] No binding key is recorded on ${target.name} | Register it by stereotype (@service() and the rest) or by hand (service(), repository(), dataSource(), component(), bindingList()), or resolve it by { key }`,
|
|
26
35
|
});
|
|
27
36
|
}
|
|
28
37
|
return container.get({ key: resolved });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-injectable.js","sourceRoot":"","sources":["../../src/hooks/use-injectable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAa,QAAQ,EAAe,MAAM,0BAA0B,CAAC;AAG5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAY7D,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"use-injectable.js","sourceRoot":"","sources":["../../src/hooks/use-injectable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAa,QAAQ,EAAe,MAAM,0BAA0B,CAAC;AAG5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAY7D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,IAAgC,EAAa,EAAE;IACpF,MAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,kBAAkB,CAAC,SAAS,CAAC;IAElE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,2DAA2D;SACrE,CAAC,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAI,IAA2B,EAAE,EAAE;IAC9D,MAAM,SAAS,GAAG,sBAAsB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAEzE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAE7B,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,SAAS,CAAC,GAAG,CAAI,EAAE,GAAG,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,+EAA+E;SACzF,CAAC,CAAC;IACL,CAAC;IAED,MAAM,QAAQ,GAAG,SAAS,CAAC,mBAAmB,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,iDAAiD,MAAM,CAAC,IAAI,iKAAiK;SACvO,CAAC,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC,GAAG,CAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC7C,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './common';
|
|
2
|
-
export * from './contexts';
|
|
3
|
-
export * from './hooks';
|
|
1
|
+
export * from './common/index.js';
|
|
2
|
+
export * from './contexts/index.js';
|
|
3
|
+
export * from './hooks/index.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './common';
|
|
2
|
-
export * from './contexts';
|
|
3
|
-
export * from './hooks';
|
|
1
|
+
export * from './common/index.js';
|
|
2
|
+
export * from './contexts/index.js';
|
|
3
|
+
export * from './hooks/index.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ardor-react",
|
|
3
|
-
"version": "0.1.1-
|
|
3
|
+
"version": "0.1.1-3",
|
|
4
4
|
"description": "ARDOR React bindings - the application context, the injectable and logger hooks that read it, typed Redux hook factories, and the framework-agnostic UI hooks (debounce, autosave, confirm, clipboard, sizer, window dimensions). No react-admin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ardor",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"engines": {
|
|
34
|
-
"bun": ">=1.
|
|
34
|
+
"bun": ">=1.4"
|
|
35
35
|
},
|
|
36
36
|
"type": "module",
|
|
37
37
|
"main": "./dist/index.js",
|
|
@@ -73,12 +73,12 @@
|
|
|
73
73
|
"size": "size-limit"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@venizia/ardor-kernel": "^0.1.1-
|
|
76
|
+
"@venizia/ardor-kernel": "^0.1.1-4",
|
|
77
77
|
"lodash": "^4.18.1"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
80
|
"@reduxjs/toolkit": ">=2.12.0",
|
|
81
|
-
"@venizia/ignis-inversion": "
|
|
81
|
+
"@venizia/ignis-inversion": "^0.2.0",
|
|
82
82
|
"react": ">=18.0",
|
|
83
83
|
"react-redux": ">=9.3.0"
|
|
84
84
|
},
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"@types/lodash": "^4.17.24",
|
|
93
93
|
"@types/react": "^19",
|
|
94
94
|
"@types/react-dom": "^19",
|
|
95
|
-
"@venizia/dev-configs": "^0.2.0
|
|
96
|
-
"@venizia/ignis-inversion": "^0.2.0
|
|
95
|
+
"@venizia/dev-configs": "^0.2.0",
|
|
96
|
+
"@venizia/ignis-inversion": "^0.2.0",
|
|
97
97
|
"eslint": "^9.36.0",
|
|
98
98
|
"prettier": "^3.8.4",
|
|
99
99
|
"react": "^19.2.7",
|
|
@@ -106,9 +106,6 @@
|
|
|
106
106
|
"peerDependenciesMeta": {
|
|
107
107
|
"@reduxjs/toolkit": {
|
|
108
108
|
"optional": true
|
|
109
|
-
},
|
|
110
|
-
"react-redux": {
|
|
111
|
-
"optional": true
|
|
112
109
|
}
|
|
113
110
|
},
|
|
114
111
|
"size-limit": [
|
|
@@ -123,7 +120,7 @@
|
|
|
123
120
|
"react",
|
|
124
121
|
"react-redux"
|
|
125
122
|
],
|
|
126
|
-
"limit": "2.
|
|
123
|
+
"limit": "2.5 KB"
|
|
127
124
|
}
|
|
128
125
|
]
|
|
129
126
|
}
|