diff --git a/.gitignore b/.gitignore index 79429d4..fc06fbb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ dist .npmrc package-lock.json **/package-lock.json +**/pnpm-lock.yaml +pnpm-lock.yaml diff --git a/package.json b/package.json index 53ae059..74b5a6d 100644 --- a/package.json +++ b/package.json @@ -47,13 +47,13 @@ "@tanstack/react-query": "^5.32.0", "@thinairthings/use-immer": "^0.9.1", "openai": "^4.38.3", - "uuid": "^9.0.1" - }, - "peerDependencies": { + "uuid": "^9.0.1", "neo4j-driver": "^5.19.0", "next": "^14.2.0-canary.62", "zod": "^3.22.5", - "zustand": "^4.5.2", + "zustand": "^4.5.2" + }, + "peerDependencies": { "react": "^18" }, "devDependencies": { @@ -79,4 +79,4 @@ "tsx": "^4.7.2", "typescript": "^5.4.5" } -} +} \ No newline at end of file diff --git a/src/layers/ReactCache/defineReactCacheLayer.ts b/src/layers/ReactCache/defineReactCacheLayer.ts index 00fadfc..42bba74 100644 --- a/src/layers/ReactCache/defineReactCacheLayer.ts +++ b/src/layers/ReactCache/defineReactCacheLayer.ts @@ -2,7 +2,7 @@ import { NodeDefinition, defineNode } from "@/src/base/defineNode"; import { TypeOf, ZodObject } from "zod"; import { GraphLayer } from "@/src/types/GraphLayer"; import { Ok } from "@/src/types/Result"; -import { createStore, useStore } from "zustand"; +import { create, createStore, useStore } from "zustand"; import { UixNode } from "@/src/types/UixNode"; import { enableMapSet, Draft, produce } from 'immer' import { immer } from "zustand/middleware/immer"; @@ -51,31 +51,7 @@ export const defineReactCacheLayer = < GraphLayer, 'createNode' | 'updateNode' > - // const nodeStore = createStore()( - // immer( - // (set) => ({ - // nodeMap: new Map(), - // createNode: async (nodeType, initialState) => { - // const createNodeResult = await graph.createNode(nodeType, initialState) - // if (!createNodeResult.ok) return createNodeResult - // const node = createNodeResult.val - // set((state) => { - // state.nodeMap.set(node.nodeId, node) - // }) - // return Ok(node) - // }, - // updateNode: async (nodeKey, state) => { - // set((state) => { - // state.nodeMap.set(nodeKey.nodeId, { - // ...state.nodeMap.get(nodeKey.nodeId)!, - // ...state - // }) - // }) - // return await graph.updateNode(nodeKey, state) - // }, - // }) - // ) - // ) + // const useNodeStore = create()() return { ...graph, useNodeState: (nodeType, node, updater) => { @@ -83,6 +59,7 @@ export const defineReactCacheLayer = < useEffect(() => { return () => { (async () => { + console.log("RUNNING") await updater?.(node, nodeState) })() }