diff --git a/extensions/actions/package.json b/extensions/actions/package.json index 2edd4326..c3b7e927 100644 --- a/extensions/actions/package.json +++ b/extensions/actions/package.json @@ -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" } } diff --git a/extensions/lazy/package.json b/extensions/lazy/package.json index 1999fd12..d8dd56d1 100644 --- a/extensions/lazy/package.json +++ b/extensions/lazy/package.json @@ -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" } } \ No newline at end of file diff --git a/extensions/lazy/src/index.ts b/extensions/lazy/src/index.ts index be95ce4c..dfb3a171 100644 --- a/extensions/lazy/src/index.ts +++ b/extensions/lazy/src/index.ts @@ -16,6 +16,8 @@ import type { LazyBody, } from './types'; +export * from './types'; + export default function lazyExtension() { function computedAsync(callback: ComputedAsyncCallback): ComputedAsyncResult; diff --git a/extensions/reset/src/types.ts b/extensions/reset/src/types.ts deleted file mode 100644 index 1be14698..00000000 --- a/extensions/reset/src/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { - WriteState, - BaseState, -} from '@harlem/core'; - -export type BranchCallback = ((state: WriteState) => BaseState) | undefined; \ No newline at end of file diff --git a/extensions/snapshot/src/index.ts b/extensions/snapshot/src/index.ts index 978edde9..6109e816 100644 --- a/extensions/snapshot/src/index.ts +++ b/extensions/snapshot/src/index.ts @@ -14,6 +14,8 @@ import type { BranchCallback, } from './types'; +export * from './types'; + interface MutationPayload { snapshotBranch: TBranchState; branchCallback: BranchCallback; @@ -30,7 +32,7 @@ export default function snapshotExtension(options?: Pa return (store: InternalStore) => { const _apply = store.mutation(mutationName, (state, { snapshotBranch, branchCallback }: MutationPayload) => { const stateBranch = branchCallback(state); - overwrite(stateBranch, snapshotBranch); + overwrite(stateBranch, clone(snapshotBranch)); }); function snapshot(branchCallback: BranchCallback = ((state: TState) => state) as any): Snapshot { diff --git a/extensions/storage/src/index.ts b/extensions/storage/src/index.ts index 3f1df59c..2a8851ac 100644 --- a/extensions/storage/src/index.ts +++ b/extensions/storage/src/index.ts @@ -52,14 +52,13 @@ export default function storageExtension(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 {}; }; diff --git a/extensions/trace/src/index.ts b/extensions/trace/src/index.ts index da2c084f..73c6d0f7 100644 --- a/extensions/trace/src/index.ts +++ b/extensions/trace/src/index.ts @@ -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); @@ -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;