[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-82112":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":15,"stars30d":16,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":17,"rankGlobal":9,"rankLanguage":9,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":9,"pushedAt":9,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":14,"starSnapshotCount":14,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},82112,"solidjs-state","slevisp\u002Fsolidjs-state","slevisp","A tiny SolidJS state helper that unifies createSignal and createStore behind one createState API with typed selectors.",null,"TypeScript",107,5,3,0,28,85,2.33,"MIT License",false,"main",true,[],"2026-06-12 02:04:23","# solidjs-state\n\nA tiny SolidJS state helper that chooses `createSignal` or `createStore` from the\ninitial value and gives both branches the same read shape: `state()`.\n\n## Install\n\n```sh\nnpm install solidjs-state\n```\n\n```sh\nyarn add solidjs-state\n```\n\n```sh\npnpm add solidjs-state\n```\n\n```sh\nbun add solidjs-state\n```\n\n`solid-js` is a peer dependency. This package does not add any runtime\ndependencies beyond Solid itself.\n\n## Usage\n\n```ts\nimport { createState } from 'solidjs-state';\n\nconst [count, setCount] = createState(0);\n\ncount(); \u002F\u002F 0\nsetCount(1);\ncount(); \u002F\u002F 1\n```\n\nPlain objects and arrays use Solid stores internally, but are still read through\n`state()`:\n\n```ts\nconst [state, setState] = createState({\n  user: { name: 'Suuu' },\n  todos: [{ title: 'Write docs', done: false }],\n});\n\nstate().user.name; \u002F\u002F \"Suuu\"\nconst s = state();\ns.user.name; \u002F\u002F \"Suuu\"\n\nconst userName = state((current) => current.user.name);\nconst openTodos = state((current) =>\n  current.todos.filter((todo) => !todo.done)\n);\nconst summary = state((current) => ({\n  name: current.user.name,\n  todoCount: current.todos.length,\n}));\n\nuserName(); \u002F\u002F \"Suuu\"\nopenTodos(); \u002F\u002F [{ title: \"Write docs\", done: false }]\nsummary(); \u002F\u002F { name: \"Suuu\", todoCount: 1 }\n\nsetState('user', 'name', 'Solid');\nuserName(); \u002F\u002F \"Solid\"\n```\n\nSelectors are for expressive reads, filtering, and composing derived values.\nThey return Solid accessors, so values stay reactive after store updates:\n\n```ts\nconst visibleTodos = state((current) =>\n  current.todos.filter((todo) => !todo.done)\n);\n\nvisibleTodos();\n```\n\nSelector accessors do not cache by themselves. For expensive derived values,\nwrap the accessor with Solid's `createMemo`.\n\n## State Selection\n\n`createState` uses `createSignal` for primitive values and common whole-value\nobjects:\n\n- `string`\n- `number`\n- `boolean`\n- `bigint`\n- `symbol`\n- `null`\n- `undefined`\n- `Date`\n- `Map`\n- `Set`\n- known non-plain objects such as `RegExp`, `URL`, `Error`, `Promise`,\n  `WeakMap`, and `WeakSet`\n\nIt uses `createStore` for:\n\n- arrays\n- plain objects\n- class instances and other object values not listed above\n\nFunction initial values are intentionally not part of the public TypeScript API.\nIf a function is passed by bypassing TypeScript, it is stored as a value and is\nnot executed.\n\n## API\n\n```ts\nfunction createState\u003CT extends SupportedSignalState>(\n  initialValue: T\n): [state: () => T, setState: Setter\u003CT>];\n\nfunction createState\u003CT extends object>(\n  initialValue: T\n): [\n  state: {\n    (): T;\n    \u003CR>(selector: (state: T) => R): Accessor\u003CR>;\n  },\n  setState: SetStoreFunction\u003CT>\n];\n```\n","solidjs-state 是一个轻量级的 SolidJS 状态管理辅助库，通过统一的 createState API 封装了 createSignal 和 createStore，并支持类型化的选择器。其核心功能在于根据初始值自动选择使用信号或存储来创建状态，并提供一致的状态读取方式 `state()`，同时允许开发者定义选择器以实现更复杂的派生状态计算。此项目特别适用于需要简化状态管理和提高代码可维护性的 SolidJS 项目中。它不引入额外的运行时依赖，仅作为 solid-js 的对等依赖存在，确保了应用性能和包体积控制。",2,"2026-06-11 04:07:46","CREATED_QUERY"]