Skip to content

Commit

Permalink
qa
Browse files Browse the repository at this point in the history
  • Loading branch information
steveswork committed Jun 1, 2024
1 parent c861c2c commit 2e34bd3
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@
"test:watch": "eslint --fix && jest --updateSnapshot --watchAll"
},
"types": "dist/index.d.ts",
"version": "5.0.0"
"version": "5.0.0-rc.0"
}
27 changes: 20 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import type {
ComponentType,
Context,
ForwardRefExoticComponent,
ForwardRefExoticComponent,
MemoExoticComponent,
NamedExoticComponent,
ReactNode,
PropsWithoutRef,
RefAttributes
} from 'react';

import type {
Changes as BaseChanges,
Connection,
Immutable,
Value as State,
Value,
} from '@webkrafters/auto-immutable';

import { FULL_STATE_SELECTOR } from './constants';
Expand All @@ -27,11 +30,12 @@ export type {
TagCommand,
TagType,
UpdateStats,
Value as State,
UpdatePayload,
UpdatePayloadArray
} from '@webkrafters/auto-immutable';

export type State = Value;

export type ObservableContext<T extends State> = IObservableContext<T> | PublicObservableContext<T>;

export type PublicObservableContext<T extends State> = WithObservableProvider<Context<Store<T>>, T>;
Expand Down Expand Up @@ -61,15 +65,24 @@ export type ConnectProps<
SELECTOR_MAP extends SelectorMap = SelectorMap
> = { [K in keyof Store<STATE, SELECTOR_MAP>]: Store<STATE, SELECTOR_MAP>[K] }
& Omit<OWNPROPS, "ref">
& React.RefAttributes<OWNPROPS["ref"]>;
& RefAttributes<OWNPROPS["ref"]>;

export type ConnectedComponent<P extends OwnProps = IProps> = MemoExoticComponent<
React.ForwardRefExoticComponent<
React.PropsWithoutRef<Omit<P, "ref">>
& React.RefAttributes<P["ref"]>
ForwardRefExoticComponent<
PropsWithoutRef<Omit<P, "ref">>
& RefAttributes<P["ref"]>
>
>;

export type PropsExtract<C, STATE extends State, SELECTOR_MAP extends SelectorMap> =
C extends ComponentType<ConnectProps<infer U, STATE, SELECTOR_MAP>>
? U extends OwnProps ? U : IProps
: C extends NamedExoticComponent<ConnectProps<infer U, STATE, SELECTOR_MAP>>
? U extends OwnProps ? U : IProps
: IProps;

export type InjectedProps<P extends IProps = IProps> = {[K in keyof P]: P[K]};

export interface IProps { ref?: unknown }

export type OwnProps = IProps & Record<any, any>;
Expand Down
1 change: 1 addition & 0 deletions src/main/hooks/use-render-key-provider/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useRenderKeyProvider from '.';
import { renderHook } from '@testing-library/react';

import '../../../test-artifacts/suppress-render-compat';

import { ObjectSelector } from '../../..';

describe( 'useRenderKeyProvider', () => {
Expand Down
18 changes: 15 additions & 3 deletions src/main/hooks/use-store/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import type { PropertyInfo, Transform } from '@webkrafters/data-distillery';
import type { Connection, UpdatePayload } from '@webkrafters/auto-immutable';
import type {
PropertyInfo,
Transform
} from '@webkrafters/data-distillery';

import type {
Connection,
UpdatePayload
} from '@webkrafters/auto-immutable';

import type {
Changes,
Expand All @@ -11,7 +18,12 @@ import type {
StoreInternal
} from '../../..';

import { useCallback, useEffect, useRef, useState } from 'react';
import {
useCallback,
useEffect,
useRef,
useState
} from 'react';

import isBoolean from 'lodash.isboolean';
import isEmpty from 'lodash.isempty';
Expand Down
12 changes: 2 additions & 10 deletions src/main/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
type PropsExtract<C, STATE extends State, SELECTOR_MAP extends SelectorMap> =
C extends ComponentType<ConnectProps<infer U, STATE, SELECTOR_MAP>>
? U extends OwnProps ? U : IProps
: C extends NamedExoticComponent<ConnectProps<infer U, STATE, SELECTOR_MAP>>
? U extends OwnProps ? U : IProps
: IProps;

type InjectedProps<P extends IProps = IProps> = {[K in keyof P]: P[K]};

import type {
ComponentType,
Context,
Expand All @@ -21,15 +12,16 @@ import type {
ConnectedComponent,
ConnectProps,
Data,
InjectedProps,
IObservableContext,
IStore,
NonReactUsageReport,
IProps,
ObservableContext,
ObservableProvider,
OwnProps,
PartialState,
Prehooks,
PropsExtract,
ProviderProps,
SelectorMap,
State,
Expand Down
14 changes: 8 additions & 6 deletions src/model/storage/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import Storage from '.';

const data = { name: { first: 'test', last: 'data' }, isTest: true };
const data = {
isTest: true,
name: {
first: 'test',
last: 'data'
}
};

describe( 'Storage class', () => {
const mockImpls = {} as {
getItem: jest.Mock<any, any, any>,
removeItem: jest.Mock<any, any, any>,
setItem: jest.Mock<any, any, any>
};
const mockImpls = {} as {[K in "getItem" | "removeItem" | "setItem"]: jest.Mock<any, any, any>};
let origWinStorage;
beforeAll(() => {
if( typeof globalThis.sessionStorage?.setItem !== 'undefined' ) {
Expand Down

0 comments on commit 2e34bd3

Please sign in to comment.