Skip to content

Commit

Permalink
fix(extensions): fixed type exports
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcourtice committed Aug 4, 2021
1 parent d70a241 commit 2b02242
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions extensions/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"peerDependencies": {
"@harlem/core": "^1.1.2",
"@harlem/utilities": "^1.1.2",
"vue": "^3.0.0"
"vue": "^3.2.0-beta.7"
},
"devDependencies": {
"@harlem/core": "^1.3.2",
"@harlem/testing": "^1.3.2",
"vue": "^3.0.0"
"vue": "^3.2.0-beta.7"
}
}
4 changes: 2 additions & 2 deletions extensions/lazy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
},
"peerDependencies": {
"@harlem/core": "^1.1.2",
"vue": "^3.0.0"
"vue": "^3.2.0-beta.7"
},
"devDependencies": {
"@harlem/core": "^1.3.2",
"@harlem/testing": "^1.3.2",
"vue": "^3.0.0"
"vue": "^3.2.0-beta.7"
}
}
2 changes: 2 additions & 0 deletions extensions/lazy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import type {
LazyBody,
} from './types';

export * from './types';

export default function lazyExtension<TState extends BaseState>() {

function computedAsync<TResult>(callback: ComputedAsyncCallback<TResult>): ComputedAsyncResult<TResult | undefined>;
Expand Down
6 changes: 0 additions & 6 deletions extensions/reset/src/types.ts

This file was deleted.

4 changes: 3 additions & 1 deletion extensions/snapshot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type {
BranchCallback,
} from './types';

export * from './types';

interface MutationPayload<TState extends BaseState, TBranchState extends BaseState> {
snapshotBranch: TBranchState;
branchCallback: BranchCallback<TState, TBranchState>;
Expand All @@ -30,7 +32,7 @@ export default function snapshotExtension<TState extends BaseState>(options?: Pa
return (store: InternalStore<TState>) => {
const _apply = store.mutation(mutationName, (state, { snapshotBranch, branchCallback }: MutationPayload<TState, BaseState>) => {
const stateBranch = branchCallback(state);
overwrite(stateBranch, snapshotBranch);
overwrite(stateBranch, clone(snapshotBranch));
});

function snapshot<TBranchState extends BaseState = TState>(branchCallback: BranchCallback<TState, TBranchState> = ((state: TState) => state) as any): Snapshot<TBranchState> {
Expand Down
3 changes: 1 addition & 2 deletions extensions/storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ export default function storageExtension<TState extends BaseState>(options?: Par
const write = store.mutation('$storage', (state, value: string) => Object.assign(state, parser(value)));

const listener = ({ key, storageArea, newValue }: StorageEvent) => {
console.log(key, newValue);
if (storageArea === storage && key === storageKey && newValue) {
write(newValue);
}
};

window.addEventListener('storage', listener);
store.on(EVENTS.store.destroyed, () => window.removeEventListener('storage', listener));
store.once(EVENTS.store.destroyed, () => window.removeEventListener('storage', listener));

return {};
};
Expand Down
14 changes: 9 additions & 5 deletions extensions/trace/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import type {
TraceOptions,
} from './types';

export * from './types';

const GATE_MAP = {
get: (callback, { hasGetGate, gates, paths }) => (target, prop, receiver) => {
const value = Reflect.get(target, prop, receiver);
get: (callback, { hasGetGate, gates, paths }) => (target, prop) => {
const value = target[prop];

if (hasGetGate) {
defaultCallback(callback, 'get', paths, prop, value, value);
Expand All @@ -33,13 +35,15 @@ const GATE_MAP = {
paths: paths.concat(prop),
});
},
set: (callback, { paths }) => (target, prop, value, receiver) => {
set: (callback, { paths }) => (target, prop, value) => {
defaultCallback(callback, 'set', paths, prop, target[prop], value);
return Reflect.set(target, prop, value, receiver);
target[prop] = value;
return true;
},
deleteProperty: (callback, { paths }) => (target, prop) => {
defaultCallback(callback, 'deleteProperty', paths, prop, target[prop]);
return Reflect.deleteProperty(target, prop);
delete target[prop];
return true;
},
} as GateMap;

Expand Down

0 comments on commit 2b02242

Please sign in to comment.