[
  {
    "path": ".changeset/README.md",
    "content": "# Changesets\n\nHello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works\nwith multi-package repos, or single-package repos to help you version and publish your code. You can\nfind the full documentation for it [in our repository](https://github.com/changesets/changesets)\n\nWe have a quick list of common questions to get you started engaging with this project in\n[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)\n"
  },
  {
    "path": ".changeset/config.json",
    "content": "{\n  \"$schema\": \"https://unpkg.com/@changesets/config@3.1.2/schema.json\",\n  \"changelog\": \"@changesets/cli/changelog\",\n  \"commit\": false,\n  \"fixed\": [],\n  \"linked\": [],\n  \"access\": \"public\",\n  \"baseBranch\": \"main\",\n  \"updateInternalDependencies\": \"patch\",\n  \"ignore\": []\n}\n"
  },
  {
    "path": ".editorconfig",
    "content": "# editorconfig.org\nroot = true\n\n[*]\nindent_style = space\nindent_size = 2\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: CI\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  test:\n    runs-on: ${{ matrix.os }}\n    strategy:\n      matrix:\n        node: [22.x]\n        os: [ubuntu-latest, windows-latest, macos-latest]\n      fail-fast: false\n\n    steps:\n      - name: Checkout Repo\n        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1\n        with:\n          fetch-depth: 0\n      - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0\n        with:\n          version: 10.25.0\n\n      - name: Set up Node.js ${{ matrix.node }}\n        uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0\n        with:\n          node-version: ${{ matrix.node }}\n          cache: pnpm\n\n      - name: Install dependencies\n        run: pnpm install --frozen-lockfile\n\n      - name: Lint\n        run: pnpm lint\n\n      - name: Typecheck\n        run: pnpm typecheck\n\n      - name: Build\n        run: pnpm build\n\n      - name: Test\n        run: pnpm test\n  provenance:\n    name: Provenance\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout Repo\n        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1\n        with:\n          fetch-depth: 0\n      - name: Check Provenance\n        uses: danielroe/provenance-action@41bcc969e579d9e29af08ba44fcbfdf95cee6e6c # v0.1.1\n        with:\n          fail-on-downgrade: true\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "name: Release\n\non:\n  push:\n    branches:\n      - main\n\nconcurrency: ${{ github.workflow }}-${{ github.ref }}\n\njobs:\n  release:\n    permissions:\n      contents: write # to create release (changesets/action)\n      pull-requests: write # to create pull request (changesets/action)\n      id-token: write # allows GitHub Actions to generate OIDC tokens\n    name: Release\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout Repo\n        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1\n        with:\n          # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits\n          fetch-depth: 0\n      - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0\n        with:\n          version: 10.25.0\n\n      - name: Setup Node.js\n        uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0\n        with:\n          node-version: '24'\n          cache: pnpm\n          registry-url: https://registry.npmjs.org\n\n      - name: Install dependencies\n        run: pnpm install\n\n      - name: Create Release Pull Request or Publish to npm\n        id: changesets\n        uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3\n        with:\n          publish: pnpm release\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\n.DS_Store\ndist\n*.local\n.vscode"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\n## 2.0.0\n\n### Major Changes\n\n- 9d58ece: ## Breaking Changes\n\n  ### New Unified API\n\n  The library now uses a unified `create` function with subpath exports instead of separate `createWithSignal` and `createWithStore` functions.\n\n  **Before:**\n\n  ```ts\n  import { createWithSignal } from \"solid-zustand\"; // signal-based\n  import { createWithStore } from \"solid-zustand\"; // store-based\n  ```\n\n  **After:**\n\n  ```ts\n  import { create } from \"solid-zustand\"; // signal-based (default)\n  import { create } from \"solid-zustand/store\"; // store-based\n  ```\n\n  ### Requirements\n\n  ⚠️ **Requires zustand v5** or higher.\n\n  ## Migration Guide\n\n  ### Using `createWithSignal`:\n\n  ```diff\n  - import { createWithSignal } from 'solid-zustand'\n  + import { create } from 'solid-zustand'\n\n  - const useStore = createWithSignal((set) => ({ ... }))\n  + const useStore = create((set) => ({ ... }))\n  ```\n\n  ### Using `createWithStore`:\n\n  ```diff\n  - import { createWithStore } from 'solid-zustand'\n  + import { create } from 'solid-zustand/store'\n\n  - const useStore = createWithStore((set) => ({ ... }))\n  + const useStore = create((set) => ({ ... }))\n  ```\n\n  ### Using default export:\n\n  ```diff\n  - import create from 'solid-zustand'\n  + import { create } from 'solid-zustand'\n\n  - const useStore = create((set) => ({ ... }))\n  + const useStore = create((set) => ({ ... }))\n  ```\n\n  ## Deprecated APIs\n\n  The following exports are deprecated but still work:\n\n  - `createWithSignal` → Use `import { create } from 'solid-zustand'`\n  - `createWithStore` → Use `import { create } from 'solid-zustand/store'`\n\n  These will be removed in a future major version.\n\n## v1.7.0\n\n[compare changes](https://github.com/wobsoriano/solid-zustand/compare/v1.5.1...v1.7.0)\n\n### 🏡 Chore\n\n- **release:** V2.0.0 ([8d55674](https://github.com/wobsoriano/solid-zustand/commit/8d55674))\n- **release:** V1.6.0 ([f78d98b](https://github.com/wobsoriano/solid-zustand/commit/f78d98b))\n\n### ❤️ Contributors\n\n- Wobsoriano ([@wobsoriano](http://github.com/wobsoriano))\n\n## v1.6.0\n\n[compare changes](https://github.com/wobsoriano/solid-zustand/compare/v1.5.1...v1.6.0)\n\n### 🏡 Chore\n\n- **release:** V2.0.0 ([8d55674](https://github.com/wobsoriano/solid-zustand/commit/8d55674))\n\n### ❤️ Contributors\n\n- Wobsoriano ([@wobsoriano](http://github.com/wobsoriano))\n\n## v2.0.0\n\n[compare changes](https://github.com/wobsoriano/solid-zustand/compare/v1.5.1...v2.0.0)\n\n## v1.5.1\n\n[compare changes](https://github.com/wobsoriano/solid-zustand/compare/v1.5.0...v1.5.1)\n\n### 🩹 Fixes\n\n- Update import statements due to deprecation of default exports ([bcc848e](https://github.com/wobsoriano/solid-zustand/commit/bcc848e))\n\n### 🏡 Chore\n\n- Update deps ([d27db70](https://github.com/wobsoriano/solid-zustand/commit/d27db70))\n- Update deps ([f2f0dbf](https://github.com/wobsoriano/solid-zustand/commit/f2f0dbf))\n- Update zustand ([b949c4e](https://github.com/wobsoriano/solid-zustand/commit/b949c4e))\n\n### ❤️ Contributors\n\n- Jcha0713 ([@jcha0713](http://github.com/jcha0713))\n- Wobsoriano ([@wobsoriano](http://github.com/wobsoriano))\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2022 Robert Soriano\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
  },
  {
    "path": "README.md",
    "content": "<p>\n  <img width=\"100%\" src=\"https://assets.solidjs.com/banner?type=solid-zustand&background=tiles&project=%20\" alt=\"solid-zustand\">\n</p>\n\n# solid-zustand\n\n🐻 State management in Solid using [zustand](https://github.com/pmndrs/zustand).\n\n## Install\n\n```sh\npnpm add zustand solid-zustand\n```\n\nDemo: https://stackblitz.com/edit/vitejs-vite-tcofpc\n\n## Usage\n\nFirst create a zustand store (default uses signals)\n\n```tsx\nimport { create } from 'solid-zustand'\n\ninterface BearState {\n  bears: number\n  increase: () => void\n}\n\nconst useStore = create<BearState>(set => ({\n  bears: 0,\n  increase: () => set(state => ({ bears: state.bears + 1 })),\n}))\n```\n\nThen bind your components, and that's it!\n\n```tsx\nfunction BearCounter() {\n  const bears = useStore(state => state.bears)\n  return (\n    <h1>\n      {bears()}\n      {' '}\n      around here ...\n    </h1>\n  )\n}\n\nfunction Controls() {\n  const increase = useStore(state => state.increase)\n  return <button onClick={increase}>one up</button>\n}\n```\n\nIf you prefer the underlying reactivity to use Solid [stores](https://docs.solidjs.com/references/api-reference/stores/using-stores) instead of [signals](https://www.solidjs.com/docs/latest#createsignal), use the `/store` subpath export:\n\n```tsx\nimport { create } from 'solid-zustand/store'\n\nconst useStore = create<BearState>(set => ({\n  bears: {\n    count: 0,\n  },\n  increase: () => set(state => ({ bears: state.bears.count + 1 })),\n}))\n\nfunction BearCounter() {\n  const bears = useStore(state => state.bears)\n  return (\n    <h1>\n      {bears.count}\n      {' '}\n      around here ...\n    </h1>\n  )\n}\n```\n\n## Recipes\n\n### Fetching everything\n\n```ts\nconst state = useStore()\n```\n\n### Selecting multiple state slices\n\nIt detects changes with strict-equality (old === new) by default, this is efficient for atomic state picks.\n\n```ts\nconst nuts = useStore(state => state.nuts) // nuts()\nconst honey = useStore(state => state.honey) // honey()\n```\n\nIf you want to construct a single object with multiple state-picks inside, similar to redux's mapStateToProps, you can tell zustand that you want the object to be diffed shallowly by passing the `shallow` equality function. That function will then be passed to the [`equals`](https://www.solidjs.com/docs/latest/api#options) option of `createSignal` (if using `create`):\n\n```ts\nimport shallow from 'zustand/shallow'\n\n// Object pick, either state.nuts or state.honey change\nconst state = useStore(state => ({ nuts: state.nuts, honey: state.honey }), shallow) // state().nuts, state().honey\n\n// Array pick, either state.nuts or state.honey change\nconst state = useStore(state => [state.nuts, state.honey], shallow) // state()[0], state()[1]\n```\n\n## License\n\nMIT\n"
  },
  {
    "path": "dev/App.tsx",
    "content": "import type { Component } from 'solid-js'\nimport { useStore } from './store'\n\nconst App: Component = () => {\n  return (\n    <div>\n      <BearCounter />\n      <Controls />\n    </div>\n  )\n}\n\nfunction BearCounter() {\n  const bears = useStore(state => state.bears)\n  return (\n    <h1>\n      {bears()}\n      {' '}\n      around here ...\n    </h1>\n  )\n}\n\nfunction Controls() {\n  const increase = useStore(state => state.increase)\n  return <button onClick={increase}>one up</button>\n}\n\nexport default App\n"
  },
  {
    "path": "dev/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n  <meta charset=\"utf-8\" />\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n  <meta name=\"theme-color\" content=\"#000000\" />\n  <title>Solid App</title>\n</head>\n\n<body>\n  <noscript>You need to enable JavaScript to run this app.</noscript>\n  <div id=\"root\"></div>\n\n  <script src=\"./index.tsx\" type=\"module\"></script>\n</body>\n\n</html>\n"
  },
  {
    "path": "dev/index.tsx",
    "content": "import { render } from 'solid-js/web'\nimport App from './App'\n\nimport './styles.css'\n\nrender(() => <App />, document.getElementById('root')!)\n"
  },
  {
    "path": "dev/store.ts",
    "content": "import { createWithSignal } from '../src'\n\ninterface BearState {\n  bears: number\n  increase: () => void\n}\n\nexport const useStore = createWithSignal<BearState>(set => ({\n  bears: 0,\n  increase: () => set(state => ({ bears: state.bears + 1 })),\n}))\n"
  },
  {
    "path": "dev/styles.css",
    "content": "body {\n  margin: 0;\n  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n    'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;\n}\n"
  },
  {
    "path": "dev/tsconfig.json",
    "content": "{\n  \"extends\": \"../tsconfig.json\",\n  \"compilerOptions\": {\n    \"types\": [\"vite/client\"]\n  },\n  \"exclude\": [\"node_modules\", \"dist\"]\n}\n"
  },
  {
    "path": "dev/vite.config.ts",
    "content": "import { defineConfig } from 'vite'\nimport solidPlugin from 'vite-plugin-solid'\n\nexport default defineConfig({\n  resolve: {\n    alias: {\n      src: '/src',\n    },\n  },\n  plugins: [\n    solidPlugin(),\n    {\n      name: 'Reaplace env variables',\n      transform(code, id) {\n        if (id.includes('node_modules')) {\n          return code\n        }\n        return code\n          .replace(/process\\.env\\.SSR/g, 'false')\n          .replace(/process\\.env\\.DEV/g, 'true')\n          .replace(/process\\.env\\.PROD/g, 'false')\n          .replace(/process\\.env\\.NODE_ENV/g, '\"development\"')\n          .replace(/import\\.meta\\.env\\.SSR/g, 'false')\n          .replace(/import\\.meta\\.env\\.DEV/g, 'true')\n          .replace(/import\\.meta\\.env\\.PROD/g, 'false')\n          .replace(/import\\.meta\\.env\\.NODE_ENV/g, '\"development\"')\n      },\n    },\n  ],\n  server: {\n    port: 3000,\n  },\n  build: {\n    target: 'esnext',\n  },\n})\n"
  },
  {
    "path": "env.d.ts",
    "content": "declare global {\n  interface ImportMeta {\n    env: {\n      NODE_ENV: 'production' | 'development'\n      PROD: boolean\n      DEV: boolean\n    }\n  }\n  namespace NodeJS {\n    interface ProcessEnv {\n      NODE_ENV: 'production' | 'development'\n      PROD: boolean\n      DEV: boolean\n    }\n  }\n}\n\nexport {}\n"
  },
  {
    "path": "eslint.config.js",
    "content": "import antfu from '@antfu/eslint-config'\n\nexport default antfu({\n  solid: true,\n  ignores: ['README.md'],\n})\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"solid-zustand\",\n  \"type\": \"module\",\n  \"version\": \"2.0.0\",\n  \"packageManager\": \"pnpm@10.25.0\",\n  \"description\": \"🐻 State management in Solid using zustand.\",\n  \"license\": \"MIT\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/wobsoriano/solid-zustand.git\"\n  },\n  \"keywords\": [\n    \"solid\",\n    \"state\",\n    \"management\",\n    \"store\",\n    \"zustand\"\n  ],\n  \"exports\": {\n    \".\": {\n      \"types\": \"./dist/index.d.ts\",\n      \"import\": \"./dist/index.js\"\n    },\n    \"./store\": {\n      \"types\": \"./dist/store.d.ts\",\n      \"import\": \"./dist/store.js\"\n    }\n  },\n  \"files\": [\n    \"dist\"\n  ],\n  \"scripts\": {\n    \"dev\": \"vite serve dev\",\n    \"build\": \"tsdown\",\n    \"test\": \"vitest run\",\n    \"typecheck\": \"tsc --noEmit\",\n    \"release\": \"pnpm build && changeset publish\",\n    \"prepublishOnly\": \"pnpm build\",\n    \"lint\": \"eslint\",\n    \"lint:fix\": \"eslint --fix\"\n  },\n  \"peerDependencies\": {\n    \"solid-js\": \"^1.6.0\",\n    \"zustand\": \"^5.0.0\"\n  },\n  \"devDependencies\": {\n    \"@antfu/eslint-config\": \"^6.5.1\",\n    \"@changesets/cli\": \"^2.29.8\",\n    \"eslint\": \"^9.39.1\",\n    \"eslint-plugin-solid\": \"^0.14.5\",\n    \"jsdom\": \"^24.1.3\",\n    \"solid-js\": \"^1.9.10\",\n    \"tsdown\": \"^0.17.2\",\n    \"typescript\": \"^5.9.3\",\n    \"vite\": \"^7.2.7\",\n    \"vite-plugin-solid\": \"^2.11.10\",\n    \"vitest\": \"^3.2.4\",\n    \"zustand\": \"^5.0.9\"\n  }\n}\n"
  },
  {
    "path": "src/index.ts",
    "content": "import { create } from './signal'\nimport { create as createStore } from './store'\n\nexport { create }\n\n/**\n * @deprecated Use `import { create } from 'solid-zustand'` instead\n */\nconst createWithSignal = create\nexport { createWithSignal }\n\n/**\n * @deprecated Use `import { create } from 'solid-zustand/store'` instead\n */\nconst createWithStore = createStore\nexport { createWithStore }\n"
  },
  {
    "path": "src/shared.ts",
    "content": "import type { Accessor } from 'solid-js'\nimport type { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from 'zustand/vanilla'\nimport { createStore as createZustandStore } from 'zustand/vanilla'\n\nexport type ExtractState<S> = S extends { getState: () => infer T } ? T : never\n\nexport type IsFunction<T> = T extends (...args: any[]) => any ? T : never\n\nexport type UseBoundStore<S extends StoreApi<unknown>, P extends 'store' | 'signal'> = {\n  (): P extends 'store'\n    ? ExtractState<S>\n    : ExtractState<S> extends IsFunction<ExtractState<S>>\n      ? ExtractState<S>\n      : Accessor<ExtractState<S>>\n  <U>(\n    selector: (state: ExtractState<S>) => U,\n    equals?: (a: U, b: U) => boolean,\n  ): P extends 'store' ? U : U extends IsFunction<U> ? U : Accessor<U>\n} & S\n\nexport interface Create<P extends 'store' | 'signal'> {\n  <T extends object, Mos extends [StoreMutatorIdentifier, unknown][] = []>(\n    initializer: StateCreator<T, [], Mos>,\n  ): UseBoundStore<Mutate<StoreApi<T>, Mos>, P>\n  <T extends object>(): <Mos extends [StoreMutatorIdentifier, unknown][] = []>(\n    initializer: StateCreator<T, [], Mos>,\n  ) => UseBoundStore<Mutate<StoreApi<T>, Mos>, P>\n  <S extends StoreApi<unknown>>(store: S): UseBoundStore<S, P>\n}\n\nexport function createFactory<P extends 'store' | 'signal'>(\n  useStore: (api: StoreApi<any>, selector?: any, equalityFn?: any) => any,\n): Create<P> {\n  function createImpl<T extends object>(createState: StateCreator<T, [], []>) {\n    const api = typeof createState === 'function' ? createZustandStore(createState) : createState\n\n    const useBoundStore: any = (selector?: any, equalityFn?: any) =>\n      useStore(api, selector, equalityFn)\n\n    Object.assign(useBoundStore, api)\n\n    return useBoundStore\n  }\n\n  return (<T extends object>(createState: StateCreator<T, [], []> | undefined) =>\n    createState ? createImpl(createState) : createImpl) as Create<P>\n}\n"
  },
  {
    "path": "src/signal.ts",
    "content": "import type { Accessor } from 'solid-js'\nimport type { StoreApi } from 'zustand/vanilla'\nimport type { ExtractState, IsFunction } from './shared'\nimport { createSignal, onCleanup } from 'solid-js'\nimport { createFactory } from './shared'\n\nexport function useStore<S extends StoreApi<unknown>>(\n  api: S,\n): ExtractState<S> extends IsFunction<ExtractState<S>> ? ExtractState<S> : Accessor<ExtractState<S>>\n\nexport function useStore<S extends StoreApi<unknown>, U>(\n  api: S,\n  selector: (state: ExtractState<S>) => U,\n  equalityFn?: (a: U, b: U) => boolean,\n): U extends IsFunction<U> ? U : Accessor<U>\n\nexport function useStore<TState extends object, StateSlice>(\n  api: StoreApi<TState>,\n  selector: (state: TState) => StateSlice = api.getState as any,\n  equalityFn?: (a: StateSlice, b: StateSlice) => boolean,\n) {\n  const initialValue = selector(api.getState())\n\n  if (typeof initialValue === 'function')\n    return initialValue\n\n  const options: Parameters<typeof createSignal>[1] = {}\n  if (equalityFn)\n    options.equals = equalityFn as any\n\n  const [signal, setSignal] = createSignal(initialValue, options)\n\n  const unsubscribe = api.subscribe((payload) => {\n    const nextStateSlice = selector(payload) as any\n    setSignal(nextStateSlice)\n  })\n\n  onCleanup(() => unsubscribe())\n\n  return signal\n}\n\nconst create = createFactory<'signal'>(useStore)\n\nexport {\n  create,\n}\n"
  },
  {
    "path": "src/store.ts",
    "content": "import type { StoreApi } from 'zustand/vanilla'\nimport type { ExtractState } from './shared'\nimport { onCleanup } from 'solid-js'\nimport { createStore, reconcile } from 'solid-js/store'\nimport { createFactory } from './shared'\n\nexport function useStore<S extends StoreApi<unknown>>(api: S): ExtractState<S>\n\nexport function useStore<S extends StoreApi<unknown>, U>(\n  api: S,\n  selector: (state: ExtractState<S>) => U,\n  equalityFn?: (a: U, b: U) => boolean,\n): U\n\nexport function useStore<TState extends object, StateSlice>(\n  api: StoreApi<TState>,\n  selector: (state: TState) => StateSlice = api.getState as any,\n  equalityFn?: (a: StateSlice, b: StateSlice) => boolean,\n) {\n  const initialValue = selector(api.getState()) as any\n  const [state, setState] = createStore(initialValue)\n\n  const listener = (nextState: TState, previousState: TState) => {\n    const prevStateSlice = selector(previousState)\n    const nextStateSlice = selector(nextState)\n\n    if (equalityFn !== undefined) {\n      if (!equalityFn(prevStateSlice, nextStateSlice))\n        setState(reconcile(nextStateSlice))\n    }\n    else {\n      setState(reconcile(nextStateSlice))\n    }\n  }\n\n  const unsubscribe = api.subscribe(listener)\n  onCleanup(() => unsubscribe())\n  return state\n}\n\nconst create = createFactory<'store'>(useStore)\n\nexport {\n  create,\n}\n"
  },
  {
    "path": "tests/index.spec.tsx",
    "content": "import { render } from 'solid-js/web'\nimport { beforeEach, describe, expect, it } from 'vitest'\nimport { create } from '../src'\nimport { create as createWithStore } from '../src/store'\n\ninterface BearState {\n  bears: number\n  bulls: number\n  increase: () => void\n}\n\nconst useSignalStore = create<BearState>(set => ({\n  bears: 0,\n  bulls: 0,\n  increase: () => set(state => ({ bears: state.bears + 1 })),\n}))\n\ndescribe('create', () => {\n  beforeEach(() => {\n    useSignalStore.setState({ bears: 0, bulls: 0 })\n  })\n\n  it('should return default zustand properties', () => {\n    expect(typeof useSignalStore.setState).toBe('function')\n    expect(typeof useSignalStore.getState).toBe('function')\n    expect(typeof useSignalStore.subscribe).toBe('function')\n  })\n\n  it('should function correct when rendering in Solid', () => {\n    const div = document.createElement('div')\n    render(() => {\n      const state = useSignalStore()\n      const increase = useSignalStore(state => state.increase)\n      expect(state().bears).toBe(0)\n      increase()\n      increase()\n      increase()\n      return <span>{state().bears}</span>\n    }, div)\n    expect(div.innerHTML).toBe('<span>3</span>')\n  })\n\n  it('should allow multiple state slices', () => {\n    const div = document.createElement('div')\n    render(() => {\n      const state = useSignalStore(state => ({ bears: state.bears, bulls: state.bulls }))\n      useSignalStore.setState({ bears: 6, bulls: 9 })\n      return (\n        <span>\n          Bears:\n          {state().bears}\n          {' '}\n          | Bulls:\n          {state().bulls}\n        </span>\n      )\n    }, div)\n    expect(div.textContent).toBe('Bears:6 | Bulls:9')\n  })\n})\n\nconst useStore = createWithStore<BearState>(set => ({\n  bears: 0,\n  bulls: 0,\n  increase: () => set(state => ({ bears: state.bears + 1 })),\n}))\n\ndescribe('create from /store', () => {\n  beforeEach(() => {\n    useStore.setState({ bears: 0, bulls: 0 })\n  })\n\n  it('should return default zustand properties', () => {\n    expect(typeof useStore.setState).toBe('function')\n    expect(typeof useStore.getState).toBe('function')\n    expect(typeof useStore.subscribe).toBe('function')\n  })\n\n  it('should function correct when rendering in Solid', () => {\n    const div = document.createElement('div')\n    render(() => {\n      const state = useStore()\n      const increase = useStore(state => state.increase)\n      expect(state.bears).toBe(0)\n      increase()\n      increase()\n      increase()\n      return <span>{state.bears}</span>\n    }, div)\n    expect(div.innerHTML).toBe('<span>3</span>')\n  })\n\n  it('should allow multiple state slices', () => {\n    const div = document.createElement('div')\n    render(() => {\n      const state = useStore(state => ({ bears: state.bears, bulls: state.bulls }))\n      useStore.setState({ bears: 6, bulls: 9 })\n      return (\n        <span>\n          Bears:\n          {state.bears}\n          {' '}\n          | Bulls:\n          {state.bulls}\n        </span>\n      )\n    }, div)\n    expect(div.textContent).toBe('Bears:6 | Bulls:9')\n  })\n})\n\ndescribe('new API - create (signal)', () => {\n  const useNewStore = create<BearState>(set => ({\n    bears: 0,\n    bulls: 0,\n    increase: () => set(state => ({ bears: state.bears + 1 })),\n  }))\n\n  beforeEach(() => {\n    useNewStore.setState({ bears: 0, bulls: 0 })\n  })\n\n  it('should work with new create API', () => {\n    const div = document.createElement('div')\n    render(() => {\n      const state = useNewStore()\n      const increase = useNewStore(state => state.increase)\n      expect(state().bears).toBe(0)\n      increase()\n      return <span>{state().bears}</span>\n    }, div)\n    expect(div.innerHTML).toBe('<span>1</span>')\n  })\n})\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"ES2022\",\n    \"jsx\": \"preserve\",\n    \"jsxImportSource\": \"solid-js\",\n    \"lib\": [\"ES2022\", \"DOM\", \"DOM.Iterable\"],\n    \"module\": \"ESNext\",\n    \"moduleResolution\": \"bundler\",\n    \"resolveJsonModule\": true,\n    \"allowImportingTsExtensions\": false,\n    \"strict\": true,\n    \"noFallthroughCasesInSwitch\": true,\n    \"noUnusedLocals\": true,\n    \"noUnusedParameters\": true,\n    \"declaration\": true,\n    \"declarationMap\": true,\n    \"inlineSources\": true,\n    \"noEmit\": false,\n    \"outDir\": \"./dist\",\n    \"sourceMap\": true,\n    \"allowSyntheticDefaultImports\": true,\n    \"esModuleInterop\": true,\n    \"isolatedModules\": true,\n    \"verbatimModuleSyntax\": true,\n    \"skipLibCheck\": true\n  },\n  \"include\": [\"src/**/*\", \"tests/**/*\"],\n  \"exclude\": [\"dist\", \"node_modules\", \"./dev\"]\n}\n"
  },
  {
    "path": "tsdown.config.ts",
    "content": "import { defineConfig } from 'tsdown'\nimport solid from 'vite-plugin-solid'\n\nexport default defineConfig({\n  entry: ['src/index.ts', 'src/store.ts'],\n  format: 'esm',\n  platform: 'browser',\n  target: 'es2022',\n  plugins: [solid()],\n  clean: true,\n  external: ['solid-js'],\n  dts: {\n    build: true,\n  },\n})\n"
  },
  {
    "path": "vitest.config.ts",
    "content": "import solid from 'vite-plugin-solid'\nimport { defineConfig } from 'vitest/config'\n\nexport default defineConfig({\n  plugins: [solid()],\n})\n"
  }
]