@slux/react 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +229 -2
  4. package/dist/5~0.js +2 -0
  5. package/dist/5~0.js.map +1 -0
  6. package/dist/atom.cjs +2 -0
  7. package/dist/atom.cjs.map +1 -0
  8. package/dist/atom.d.cts +10 -0
  9. package/dist/atom.d.ts +10 -0
  10. package/dist/atom.js +2 -0
  11. package/dist/atom.js.map +1 -0
  12. package/dist/flux.cjs +2 -0
  13. package/dist/flux.cjs.map +1 -0
  14. package/dist/flux.d.cts +7 -0
  15. package/dist/flux.d.ts +7 -0
  16. package/dist/flux.js +2 -0
  17. package/dist/flux.js.map +1 -0
  18. package/dist/index.cjs +2 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.cts +25 -0
  21. package/dist/index.d.ts +25 -0
  22. package/dist/index.js +2 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/proxy.cjs +2 -0
  25. package/dist/proxy.cjs.map +1 -0
  26. package/dist/proxy.d.cts +5 -0
  27. package/dist/proxy.d.ts +5 -0
  28. package/dist/proxy.js +2 -0
  29. package/dist/proxy.js.map +1 -0
  30. package/dist/rxjs.cjs +2 -0
  31. package/dist/rxjs.cjs.map +1 -0
  32. package/dist/rxjs.d.cts +5 -0
  33. package/dist/rxjs.d.ts +5 -0
  34. package/dist/rxjs.js +2 -0
  35. package/dist/rxjs.js.map +1 -0
  36. package/dist/state-machine.cjs +2 -0
  37. package/dist/state-machine.cjs.map +1 -0
  38. package/dist/state-machine.d.cts +8 -0
  39. package/dist/state-machine.d.ts +8 -0
  40. package/dist/state-machine.js +2 -0
  41. package/dist/state-machine.js.map +1 -0
  42. package/dist/store.cjs +2 -0
  43. package/dist/store.cjs.map +1 -0
  44. package/dist/store.d.cts +7 -0
  45. package/dist/store.d.ts +7 -0
  46. package/dist/store.js +2 -0
  47. package/dist/store.js.map +1 -0
  48. package/package.json +162 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # @slux/react
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 首次公开发布 slux 的 25 个包,统一版本为 0.1.0。
8
+
9
+ - 提供框架无关的响应式核心与共享工具,以及 Store、Atom、Proxy、Flux、状态机和 RxJS 六种状态组织方式。
10
+ - 提供持久化、历史记录、跨标签页同步、遥测和开发工具五类 Store 扩展。
11
+ - 提供 React、Vue、Solid、Svelte、Angular、Preact、Ripple、Inferno、Octane、Vitarx、ActView 和 Viewfly 绑定。
12
+ - 提供各包文档与对应示例,并接入发布检查和文档部署工作流。
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+ - @slux/atom@0.1.0
18
+ - @slux/core@0.1.0
19
+ - @slux/flux@0.1.0
20
+ - @slux/proxy@0.1.0
21
+ - @slux/rxjs@0.1.0
22
+ - @slux/shared@0.1.0
23
+ - @slux/state-machine@0.1.0
24
+ - @slux/store@0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 itmanyong
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,230 @@
1
- # Temporary Holding Version
1
+ # @slux/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 把 `@slux/core` 的响应式状态接入 React 18 / 19。核心绑定 `useSignal` 是基于 `useSyncExternalStore` 的 hook,读取任意 `Subscribable<T>` 并返回 `T`;主入口另提供 core `Scope` 的 Context 组件与 `createAutoImportApis`。六个范式各通过独立子入口提供只读 hook,写入仍走原实例。
4
+
5
+ 跨框架一致的子入口划分、Flux / 状态机 / RxJS 的写入与桥接生命周期、Scope 显式覆盖语义与 SSR 通用约束见仓库根 [README](../../README.md) 的「框架适配 · 通用约定」;仓库内构建与验证命令见「本地开发」,本文不再重复。
6
+
7
+ ## 特性与适用场景
8
+
9
+ | 场景 | 是否适合 | 说明 |
10
+ | ---------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------- |
11
+ | 在 React 18 / 19 函数组件里读 signal、computed 或自定义 `Subscribable` | 适合 | `useSignal` 返回 `T`,值变化时触发重渲染 |
12
+ | 用 Context 为渲染树提供请求级 `Scope` 覆盖 | 适合 | `ScopeProvider` / `useScopeContext`,服务端与 hydration 首次快照读取 scope |
13
+ | 消费 atom、store、proxy、flux、state-machine、rxjs 六种范式 | 适合 | 六个 `/xxx` 子入口分别导出对应 hook |
14
+ | 需要自动请求级隔离、把 Scope 写回全局,或脱离组件的长期订阅 | 不适合 | 绑定只读且随组件生命周期,脱离组件请用 `@slux/core` 的 `effect` |
15
+
16
+ ## 安装
17
+
18
+ ```sh
19
+ pnpm add @slux/react @slux/core react
20
+ ```
21
+
22
+ | 项 | 值 | 来源 |
23
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
24
+ | React peer | `^18.0.0 \|\| ^19.0.0` | `package.json` `peerDependencies` |
25
+ | 必需 peer | `@slux/core`(`workspace:^`) | 同上 |
26
+ | 可选 peer | `@slux/atom`、`@slux/store`、`@slux/proxy`、`@slux/flux`、`@slux/state-machine`、`@slux/rxjs`(均 `workspace:^` 且 `optional: true`) | `peerDependenciesMeta` |
27
+ | 运行时依赖 | `@slux/shared`(随包安装) | `dependencies` |
28
+
29
+ 范式包是**可选 peer,只安装实际使用的**:用哪个子入口就装哪个包;`@slux/core` 是全部入口的必需依赖。`react-dom` 与 `@types/react` 由应用自行提供。
30
+
31
+ `package.json` 的 `exports` 子入口(每个都提供 ESM `import` 与 CJS `require`,并带 `.d.ts` / `.d.cts`):
32
+
33
+ | 子入口 | 说明 |
34
+ | --------------------------- | ---------------------------------------------------------- |
35
+ | `@slux/react` | 主入口:`useSignal`、Scope Context、`createAutoImportApis` |
36
+ | `@slux/react/atom` | atom 绑定 |
37
+ | `@slux/react/store` | store 绑定 |
38
+ | `@slux/react/proxy` | proxy 绑定 |
39
+ | `@slux/react/flux` | flux 绑定 |
40
+ | `@slux/react/state-machine` | 状态机绑定 |
41
+ | `@slux/react/rxjs` | RxJS 桥接绑定 |
42
+ | `@slux/react/package.json` | 包元信息 |
43
+
44
+ ## 快速开始
45
+
46
+ ```tsx
47
+ import { computed, signal } from "@slux/core";
48
+ import { useSignal } from "@slux/react";
49
+
50
+ const count = signal(0);
51
+ const doubled = computed(() => count.get() * 2);
52
+
53
+ export function Counter() {
54
+ const value = useSignal(count); // 0
55
+ const double = useSignal(doubled); // 0
56
+ return (
57
+ <button onClick={() => count.set((current) => current + 1)}>
58
+ {value} × 2 = {double}
59
+ </button>
60
+ );
61
+ }
62
+ ```
63
+
64
+ ## 主入口 API
65
+
66
+ ### `useSignal`
67
+
68
+ ```ts
69
+ function useSignal<T>(source: Subscribable<T>): T;
70
+ ```
71
+
72
+ | 行为 | 说明 |
73
+ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
74
+ | 实现 | `useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)` |
75
+ | `subscribe` | `useCallback` 依赖 `[source]`;订阅 `source.subscribe`,同时起 core `effect(() => source.get())` 刷新惰性 computed;清理函数同时退订与释放 effect |
76
+ | `getSnapshot` | `() => source.get()`,客户端正常渲染读取全局值 |
77
+ | `getServerSnapshot` | `() => scope ? scope.get(source) : source.get()`,服务端与 hydration 首次快照读取最近的 `ScopeProvider` |
78
+ | 来源切换 | `source` 变化重建订阅,旧的 subscribe 与 effect 一并释放;相同来源引用保持稳定 |
79
+ | 函数值 / 对象值 | 快照直接来自 `source.get()`;函数值按原引用返回,对象不自动冻结(修改走 core 的 `set(recipe)`) |
80
+
81
+ 自定义来源只需满足 `Subscribable<T>`(`get()` + `subscribe(cb)`,后者返回取消函数);值未变化时 `get()` 应返回稳定快照。
82
+
83
+ ### Scope 相关
84
+
85
+ | 导出 | 签名 / 类型 | 说明 |
86
+ | -------------------- | --------------------------------------------------------- | ---------------------------------------------------------------------- |
87
+ | `ScopeContext` | `Context<Scope \| null>` | 默认值 `null`,可直接 `useContext(ScopeContext)` |
88
+ | `ScopeProvider` | `(props: ScopeProviderProps) => ReactElement` | 用 `createElement` 把 `scope` 放入 Provider;`children` 为 `ReactNode` |
89
+ | `useScopeContext` | `() => Scope \| null` | 返回最近的 Scope,无 Provider 时 `null` |
90
+ | `ScopeProviderProps` | `{ readonly scope: Scope; readonly children: ReactNode }` | Provider 属性类型(公开类型导出) |
91
+
92
+ 嵌套 Provider 取最近一层,替换 `scope` 同步更新到消费者;用法见「专属语义与边界」的 SSR 与 hydration。
93
+
94
+ ## 子入口 API
95
+
96
+ 六个子入口都**不返回写入 tuple 或 selector**:Flux / 状态机 / RxJS 的 hook 只读,写入通过原实例的 `dispatch`、`send` 或上游 Observable 完成(通用约定)。所有 hook 基于 `useSyncExternalStore`;服务端快照分两类:`/atom`、`/store`、`/proxy` 把 `getSnapshot` 直接作为 `getServerSnapshot`,SSR 用来源当前值、不读取 `ScopeProvider`;`/flux`、`/state-machine`、`/rxjs` 委托主入口 `useSignal`,服务端快照沿用其 Scope 覆盖语义。
97
+
98
+ | 子入口 | 导出 | 签名要点 | 返回值 | 写入方式 |
99
+ | ---------------- | --------------------------------------- | --------------------------------------------------------------------------- | ---------------------------------------------------- | ----------------------------------- |
100
+ | `/atom` | `useAtom`、`useAtomValue`、`useSetAtom` | `<T>(atom)` | `[T, (value: T) => void]`、`T`、`(value: T) => void` | `set(value)` 或 `atom.update(fn)` |
101
+ | `/store` | `useStore` | `(store, selector?, equalityFn?)` | `State` / `Selection` | `store.setState(...)` |
102
+ | `/proxy` | `useSnapshot` | `<T extends object>(proxy: T)` | `Snapshot<T>` | 直接修改原 proxy |
103
+ | `/flux` | `useFluxStore` | `<State, Action extends { type: string }>(store: FluxStore<State, Action>)` | `State` | `store.dispatch(action)` |
104
+ | `/state-machine` | `useMachine` | `<Context, Event extends { type: string }, State extends string>(machine)` | `MachineSnapshot<Context, State>` | `machine.send(event)` |
105
+ | `/rxjs` | `useObservable` | `<T>(source: ObservableState<T>)` | `T` | 上游 Observable,创建者 `dispose()` |
106
+
107
+ ### `/atom`
108
+
109
+ ```tsx
110
+ import { atom, derived } from "@slux/atom";
111
+ import { useAtom, useAtomValue } from "@slux/react/atom";
112
+
113
+ const count = atom(0);
114
+ const doubled = derived((get) => get(count) * 2);
115
+
116
+ function Counter() {
117
+ const [value, set] = useAtom(count);
118
+ const double = useAtomValue(doubled);
119
+ return (
120
+ <button onClick={() => set(value + 1)}>
121
+ {value} × 2 = {double}
122
+ </button>
123
+ );
124
+ }
125
+ ```
126
+
127
+ `useAtomValue` 可读基础、派生与 writable atom(`AnyReadableAtom<T>`),atom 包已主动刷新派生值,绑定无需再起 core `effect`;`useSetAtom` 只返回 setter、不订阅,调用 `atom.set(value)`(**替换值**,函数值直接保存,函数式更新用 `atom.update(fn)`);`useAtom` 组合前两者。
128
+
129
+ ### `/store`
130
+
131
+ ```tsx
132
+ import { createStore } from "@slux/store";
133
+ import { useStore } from "@slux/react/store";
134
+
135
+ const store = createStore(() => ({ count: 0, label: "Counter" }));
136
+ function Counter() {
137
+ const count = useStore(store, (state) => state.count);
138
+ return <button onClick={() => store.setState({ count: count + 1 })}>{count}</button>;
139
+ }
140
+ ```
141
+
142
+ `useStore(store)` 返回完整状态,带 `selector, equalityFn?` 时返回选值(默认 `Object.is`)。选值缓存用 `useMemo` 随 `[store, selector, equalityFn]` 重建:状态引用未变直接复用,`equalityFn` 判定相等时保留上次选值引用,避免对象 selector 导致循环渲染。组件卸载只退订、**不销毁** store;SSR 读 `getState()` 当前值(不是 `getInitialState()`)。
143
+
144
+ ### `/proxy`
145
+
146
+ ```tsx
147
+ import { observable } from "@slux/proxy";
148
+ import { useSnapshot } from "@slux/react/proxy";
149
+
150
+ const state = observable({ user: { name: "Alice" } });
151
+ function Profile() {
152
+ const snap = useSnapshot(state);
153
+ return (
154
+ <button
155
+ onClick={() => {
156
+ state.user.name = "Bob";
157
+ }}
158
+ >
159
+ {snap.user.name}
160
+ </button>
161
+ );
162
+ }
163
+ ```
164
+
165
+ `useSnapshot` 返回 `Snapshot<T>`,缓存、冻结与结构共享沿用 `@slux/proxy` 的 `snapshot`;订阅范围是**整个 proxy 及嵌套变更**,不按读取属性筛选,快照深层只读,修改走原 proxy。
166
+
167
+ ### `/flux`、`/state-machine`、`/rxjs`
168
+
169
+ 三个 hook 都直接 `return useSignal(source)`,继承主入口的订阅、SSR 与 Scope 边界:
170
+
171
+ ```tsx
172
+ import { createFluxStore } from "@slux/flux";
173
+ import { useFluxStore } from "@slux/react/flux";
174
+ import { useMachine } from "@slux/react/state-machine";
175
+ import { useObservable } from "@slux/react/rxjs";
176
+
177
+ const flux = createFluxStore((state: number, action: { type: "add"; amount: number }) => state + action.amount, 0);
178
+ function Total() {
179
+ const value = useFluxStore(flux); // number
180
+ return <button onClick={() => flux.dispatch({ type: "add", amount: 1 })}>{value}</button>;
181
+ }
182
+ // useMachine(machine) → MachineSnapshot<Context, State>(含 value / context),写入 machine.send(event)
183
+ // useObservable(observable) → T,写入走上游 Observable,创建者调用 dispose()
184
+ ```
185
+
186
+ `useObservable` 只接收 `fromObservable(source, initialValue)` 产出的 `ObservableState<T>`,不接受原始 RxJS `Observable`;完成与错误读 `source.status` / `source.error`。组件卸载只解除自身绑定,桥接 `dispose()` 由创建者负责。
187
+
188
+ ## 专属语义与边界
189
+
190
+ ### SSR 与 hydration
191
+
192
+ - 服务端 `getServerSnapshot` 读取 `scope.get(source)`;无 Provider 或缺少覆盖值时回退 `source.get()`(含沿父 Scope 的继承)。不同请求用独立 Scope,互不影响。
193
+ - 服务端**不建立** `subscribe` 或 core `effect`:`useSyncExternalStore` 在服务端只调用 `getServerSnapshot`。
194
+ - computed 保留全局依赖语义:Scope 只覆盖信号取值,不隔离 computed 依赖或缓存。全局 `count = 1`、Scope 覆盖 `10` 时,`useSignal(count)` 为 `10`,`useSignal(computed(() => count.get() * 2))` 仍为 `2`。
195
+ - hydration 首次客户端快照也读 Scope:调用方需把服务端数据传给客户端、用相同数据初始化客户端 Scope 才能匹配;hydration 完成后正常渲染读取并订阅**全局**来源。Scope 值与全局值不同时页面切到全局值,`ScopeProvider` 不把作用域值写回全局信号。
196
+ - `/atom`、`/store`、`/proxy` 的 SSR 用各自来源当前值,不接入 `ScopeProvider`,也不自动使用 `createAtomScope()`;`/flux`、`/state-machine`、`/rxjs` 因委托 `useSignal`,服务端快照读 Scope。
197
+
198
+ ### 订阅与清理
199
+
200
+ - `subscribe` 引用由 `useCallback([source])` 保持稳定;来源切换、组件卸载时同时释放 `source.subscribe` 与 core `effect`,卸载不销毁原状态实例。
201
+ - 值由 `useSyncExternalStore` 按 `Object.is` 比较 `getSnapshot()` 判定是否重渲染;来源返回稳定快照时相同值不触发更新。绑定不捕获异常,订阅回调与 `effect` 中的错误沿用 `@slux/core` 的同步执行与错误汇总语义。
202
+
203
+ ### Scope 显式覆盖契约
204
+
205
+ `scope.set()` 不触发全局订阅,`runInScope()` 不改写全局 signal 读写;客户端正常渲染仍读全局值。这部分沿用 core 的 Scope 契约,见根 README 通用约定。
206
+
207
+ ## 自动导入
208
+
209
+ ```ts
210
+ import AutoImport from "unplugin-auto-import/vite";
211
+ import { createAutoImportApis } from "@slux/react";
212
+
213
+ export default { plugins: [AutoImport({ imports: [createAutoImportApis()] })] };
214
+ ```
215
+
216
+ `createAutoImportApis(prefix?)` 返回 `unplugin-auto-import` 的 `ImportsMap`,来源名 `@slux/react`。`src/auto-import-api.ts` 当前登记:`ScopeContext`、`ScopeProvider`、`useScopeContext`、`useSignal`(仅主入口 API,**不含** `createAutoImportApis` 自身与各子入口 hook,需手动 import)。传入前缀时按 `@slux/shared` 的 `createAutoImports` 规则生成别名(前缀以小写字母结尾时把标识符首字母大写后拼接)。
217
+
218
+ ## 类型导出
219
+
220
+ 主入口只导出一个类型:`ScopeProviderProps`(`src/types/index.ts`)=`{ readonly scope: Scope; readonly children: ReactNode }`。六个子入口只导出运行时函数,不额外导出类型;`Subscribable` / `Scope` 来自 `@slux/core`,`Snapshot` 来自 `@slux/proxy`,`FluxStore` / `MachineSnapshot` / `ObservableState` 来自各自范式包,均按包名从原包导入。
221
+
222
+ ## 不适用的场景
223
+
224
+ - 需要脱离 React 组件生命周期的长期订阅,或在 Node / 非 React 环境使用:直接用 `@slux/core`。
225
+ - 期望绑定返回写入 tuple、selector、自动把 Scope 写回全局,或 SSR 自动序列化 / 恢复请求状态:绑定只读,需调用方自行准备客户端初始数据与 Scope,见根 README 通用约定。
226
+
227
+ ## 版本、许可与反馈
228
+
229
+ - 版本 `0.1.0`(`package.json`)· 许可 [MIT](../../LICENSE) © itmanyong · 仓库 `github.com/itmanyong/slux`(`packages/react`)。
230
+ - 问题反馈:`https://github.com/itmanyong/slux/issues`。
package/dist/5~0.js ADDED
@@ -0,0 +1,2 @@
1
+ import{createContext as e,createElement as t,useCallback as r,useContext as o,useSyncExternalStore as n}from"react";import{effect as u}from"@slux/core";let c=e(null);function i({scope:e,children:r}){return t(c.Provider,{value:e},r)}function l(){return o(c)}function p(e){let t=l();return n(r(t=>{let r=e.subscribe(()=>t()),o=u(()=>{e.get()});return()=>{r(),o()}},[e]),r(()=>e.get(),[e]),r(()=>t?t.get(e):e.get(),[t,e]))}export{c as ScopeContext,i as ScopeProvider,l as useScopeContext,p as useSignal};
2
+ //# sourceMappingURL=5~0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"5~0.js","sources":["../src/scope/scope-context.ts","../src/hooks/use-signal.ts"],"sourcesContent":["import { createContext, createElement, useContext } from \"react\";\nimport type { Scope } from \"@slux/core\";\nimport type { ScopeProviderProps } from \"../types/index.js\";\n\nexport const ScopeContext = createContext<Scope | null>(null);\n\nexport function ScopeProvider({ scope, children }: ScopeProviderProps) {\n return createElement(ScopeContext.Provider, { value: scope }, children);\n}\n\nexport function useScopeContext(): Scope | null {\n return useContext(ScopeContext);\n}\n","import { useCallback, useSyncExternalStore } from \"react\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\nimport { useScopeContext } from \"../scope/scope-context.js\";\n\nexport function useSignal<T>(source: Subscribable<T>): T {\n const scope = useScopeContext();\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n const unsubscribe = source.subscribe(() => onStoreChange());\n // computed 只有读取时才刷新并通知;effect 将依赖变化接入外部订阅。\n const dispose = effect(() => {\n source.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n },\n [source],\n );\n const getSnapshot = useCallback(() => source.get(), [source]);\n // 对齐 core 的显式作用域契约:客户端正常渲染仍读取全局值。\n const getServerSnapshot = useCallback(() => (scope ? scope.get(source) : source.get()), [scope, source]);\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"],"names":["ScopeContext","createContext","ScopeProvider","scope","children","createElement","useScopeContext","useContext","useSignal","source","useSyncExternalStore","useCallback","onStoreChange","unsubscribe","dispose","effect"],"mappings":"wJAIO,IAAMA,EAAeC,EAA4B,MAEjD,SAASC,EAAc,CAAEC,MAAAA,CAAK,CAAEC,SAAAA,CAAQ,CAAsB,EACnE,OAAOC,EAAcL,EAAa,QAAQ,CAAE,CAAE,MAAOG,CAAM,EAAGC,EAChE,CAEO,SAASE,IACd,OAAOC,EAAWP,EACpB,CCPO,SAASQ,EAAaC,CAAuB,EAClD,IAAMN,EAAQG,IAkBd,OAAOI,EAjBWC,EAChB,AAACC,IACC,IAAMC,EAAcJ,EAAO,SAAS,CAAC,IAAMG,KAErCE,EAAUC,EAAO,KACrBN,EAAO,GAAG,EACZ,GACA,MAAO,KACLI,IACAC,GACF,CACF,EACA,CAACL,EAAO,EAEUE,EAAY,IAAMF,EAAO,GAAG,GAAI,CAACA,EAAO,EAElCE,EAAY,IAAOR,EAAQA,EAAM,GAAG,CAACM,GAAUA,EAAO,GAAG,GAAK,CAACN,EAAOM,EAAO,EAEzG,Q"}
package/dist/atom.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,_,t)=>{var r=(_,t)=>{for(var r in _)__webpack_require__.o(_,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,[t]:_[r]})};r(_,"get"),r(t,"value")},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{useAtom:()=>useAtom,useAtomValue:()=>useAtomValue,useSetAtom:()=>useSetAtom});const external_react_namespaceObject=require("react");function useAtom(e){return[useAtomValue(e),useSetAtom(e)]}function useAtomValue(e){let _=(0,external_react_namespaceObject.useCallback)(_=>e.subscribe(_),[e]),t=(0,external_react_namespaceObject.useCallback)(()=>e.get(),[e]);return(0,external_react_namespaceObject.useSyncExternalStore)(_,t,t)}function useSetAtom(e){return(0,external_react_namespaceObject.useCallback)(_=>e.set(_),[e])}for(var __rspack_i in exports.useAtom=__webpack_exports__.useAtom,exports.useAtomValue=__webpack_exports__.useAtomValue,exports.useSetAtom=__webpack_exports__.useSetAtom,__webpack_exports__)-1===["useAtom","useAtomValue","useSetAtom"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=atom.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/atom.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { useCallback, useSyncExternalStore } from \"react\";\nimport type { Atom, AnyReadableAtom } from \"@slux/atom\";\n\nexport function useAtom<T>(atom: Atom<T>): [T, (value: T) => void] {\n return [useAtomValue(atom), useSetAtom(atom)];\n}\n\nexport function useAtomValue<T>(atom: AnyReadableAtom<T>): T {\n // atom 包已主动刷新派生值,无需额外创建 core effect。\n const subscribe = useCallback((onStoreChange: () => void) => atom.subscribe(onStoreChange), [atom]);\n const getSnapshot = useCallback(() => atom.get(), [atom]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport function useSetAtom<T>(atom: Atom<T>): (value: T) => void {\n return useCallback((value: T) => atom.set(value), [atom]);\n}\n"],"names":["__webpack_require__","e","Object","Symbol","useAtom","atom","useAtomValue","useSetAtom","subscribe","useCallback","onStoreChange","getSnapshot","useSyncExternalStore","value"],"mappings":"wPAAAA,CAAAA,oBAAoB,CAAC,CAAG,CAACC,EAAS,EAAS,KAC1C,IAAI,EAAS,CAAC,EAAM,KACnB,IAAI,IAAI,KAAO,EACXD,oBAAoB,CAAC,CAAC,EAAM,IAAQ,CAACA,oBAAoB,CAAC,CAACC,EAAS,IACtEC,OAAO,cAAc,CAACD,EAAS,EAAK,CAAE,WAAY,GAAM,CAAC,EAAK,CAAE,CAAI,CAAC,EAAI,AAAC,EAG7E,EACA,EAAO,EAAS,OAChB,EAAO,EAAQ,QAChB,ECVAD,oBAAoB,CAAC,CAAG,CAAC,EAAK,IAAUE,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAK,GCClFF,oBAAoB,CAAC,CAAG,AAACC,IACrB,AAAkB,IAAlB,OAAOE,QAA0BA,OAAO,WAAW,EACrDD,OAAO,cAAc,CAACD,EAASE,OAAO,WAAW,CAAE,CAAE,MAAO,QAAS,GAEtED,OAAO,cAAc,CAACD,EAAS,aAAc,CAAE,MAAO,EAAK,EAC5D,E,qPCHO,SAASG,QAAWC,CAAa,EACtC,MAAO,CAACC,aAAaD,GAAOE,WAAWF,GAAM,AAC/C,CAEO,SAASC,aAAgBD,CAAwB,EAEtD,IAAMG,EAAYC,AAAAA,GAAAA,+BAAAA,WAAAA,AAAAA,EAAY,AAACC,GAA8BL,EAAK,SAAS,CAACK,GAAgB,CAACL,EAAK,EAC5FM,EAAcF,AAAAA,GAAAA,+BAAAA,WAAAA,AAAAA,EAAY,IAAMJ,EAAK,GAAG,GAAI,CAACA,EAAK,EACxD,MAAOO,AAAAA,GAAAA,+BAAAA,oBAAAA,AAAAA,EAAqBJ,EAAWG,EAAaA,EACtD,CAEO,SAASJ,WAAcF,CAAa,EACzC,MAAOI,AAAAA,GAAAA,+BAAAA,WAAAA,AAAAA,EAAY,AAACI,GAAaR,EAAK,GAAG,CAACQ,GAAQ,CAACR,EAAK,CAC1D,C"}
@@ -0,0 +1,10 @@
1
+ import type { AnyReadableAtom } from '@slux/atom';
2
+ import type { Atom } from '@slux/atom';
3
+
4
+ export declare function useAtom<T>(atom: Atom<T>): [T, (value: T) => void];
5
+
6
+ export declare function useAtomValue<T>(atom: AnyReadableAtom<T>): T;
7
+
8
+ export declare function useSetAtom<T>(atom: Atom<T>): (value: T) => void;
9
+
10
+ export { }
package/dist/atom.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { AnyReadableAtom } from '@slux/atom';
2
+ import type { Atom } from '@slux/atom';
3
+
4
+ export declare function useAtom<T>(atom: Atom<T>): [T, (value: T) => void];
5
+
6
+ export declare function useAtomValue<T>(atom: AnyReadableAtom<T>): T;
7
+
8
+ export declare function useSetAtom<T>(atom: Atom<T>): (value: T) => void;
9
+
10
+ export { }
package/dist/atom.js ADDED
@@ -0,0 +1,2 @@
1
+ import{useCallback as t,useSyncExternalStore as e}from"react";function r(t){return[u(t),n(t)]}function u(r){let u=t(t=>r.subscribe(t),[r]),n=t(()=>r.get(),[r]);return e(u,n,n)}function n(e){return t(t=>e.set(t),[e])}export{r as useAtom,u as useAtomValue,n as useSetAtom};
2
+ //# sourceMappingURL=atom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom.js","sources":["../src/atom.ts"],"sourcesContent":["import { useCallback, useSyncExternalStore } from \"react\";\nimport type { Atom, AnyReadableAtom } from \"@slux/atom\";\n\nexport function useAtom<T>(atom: Atom<T>): [T, (value: T) => void] {\n return [useAtomValue(atom), useSetAtom(atom)];\n}\n\nexport function useAtomValue<T>(atom: AnyReadableAtom<T>): T {\n // atom 包已主动刷新派生值,无需额外创建 core effect。\n const subscribe = useCallback((onStoreChange: () => void) => atom.subscribe(onStoreChange), [atom]);\n const getSnapshot = useCallback(() => atom.get(), [atom]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport function useSetAtom<T>(atom: Atom<T>): (value: T) => void {\n return useCallback((value: T) => atom.set(value), [atom]);\n}\n"],"names":["useAtom","atom","useAtomValue","useSetAtom","subscribe","useCallback","onStoreChange","getSnapshot","useSyncExternalStore","value"],"mappings":"8DAGO,SAASA,EAAWC,CAAa,EACtC,MAAO,CAACC,EAAaD,GAAOE,EAAWF,GAAM,AAC/C,CAEO,SAASC,EAAgBD,CAAwB,EAEtD,IAAMG,EAAYC,EAAY,AAACC,GAA8BL,EAAK,SAAS,CAACK,GAAgB,CAACL,EAAK,EAC5FM,EAAcF,EAAY,IAAMJ,EAAK,GAAG,GAAI,CAACA,EAAK,EACxD,OAAOO,EAAqBJ,EAAWG,EAAaA,EACtD,CAEO,SAASJ,EAAcF,CAAa,EACzC,OAAOI,EAAY,AAACI,GAAaR,EAAK,GAAG,CAACQ,GAAQ,CAACR,EAAK,CAC1D,Q"}
package/dist/flux.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r,_)=>{var t=(r,_)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[_]:r[t]})};t(r,"get"),t(_,"value")},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{useFluxStore:()=>useFluxStore});const external_react_namespaceObject=require("react"),core_namespaceObject=require("@slux/core"),ScopeContext=(0,external_react_namespaceObject.createContext)(null);function ScopeProvider({scope:e,children:r}){return createElement(ScopeContext.Provider,{value:e},r)}function useScopeContext(){return(0,external_react_namespaceObject.useContext)(ScopeContext)}function useSignal(e){let r=useScopeContext(),_=(0,external_react_namespaceObject.useCallback)(r=>{let _=e.subscribe(()=>r()),t=(0,core_namespaceObject.effect)(()=>{e.get()});return()=>{_(),t()}},[e]),t=(0,external_react_namespaceObject.useCallback)(()=>e.get(),[e]),c=(0,external_react_namespaceObject.useCallback)(()=>r?r.get(e):e.get(),[r,e]);return(0,external_react_namespaceObject.useSyncExternalStore)(_,t,c)}function useFluxStore(e){return useSignal(e)}for(var __rspack_i in exports.useFluxStore=__webpack_exports__.useFluxStore,__webpack_exports__)-1===["useFluxStore"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=flux.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flux.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/scope/scope-context.ts","../src/hooks/use-signal.ts","../src/flux.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { createContext, createElement, useContext } from \"react\";\nimport type { Scope } from \"@slux/core\";\nimport type { ScopeProviderProps } from \"../types/index.js\";\n\nexport const ScopeContext = createContext<Scope | null>(null);\n\nexport function ScopeProvider({ scope, children }: ScopeProviderProps) {\n return createElement(ScopeContext.Provider, { value: scope }, children);\n}\n\nexport function useScopeContext(): Scope | null {\n return useContext(ScopeContext);\n}\n","import { useCallback, useSyncExternalStore } from \"react\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\nimport { useScopeContext } from \"../scope/scope-context.js\";\n\nexport function useSignal<T>(source: Subscribable<T>): T {\n const scope = useScopeContext();\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n const unsubscribe = source.subscribe(() => onStoreChange());\n // computed 只有读取时才刷新并通知;effect 将依赖变化接入外部订阅。\n const dispose = effect(() => {\n source.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n },\n [source],\n );\n const getSnapshot = useCallback(() => source.get(), [source]);\n // 对齐 core 的显式作用域契约:客户端正常渲染仍读取全局值。\n const getServerSnapshot = useCallback(() => (scope ? scope.get(source) : source.get()), [scope, source]);\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n","import type { FluxStore } from \"@slux/flux\";\nimport { useSignal } from \"./hooks/use-signal.js\";\n\nexport function useFluxStore<State, Action extends { type: string }>(store: FluxStore<State, Action>): State {\n return useSignal(store);\n}\n"],"names":["__webpack_require__","e","Object","Symbol","ScopeContext","createContext","ScopeProvider","scope","children","createElement","useScopeContext","useContext","useSignal","source","subscribe","useCallback","onStoreChange","unsubscribe","dispose","effect","getSnapshot","getServerSnapshot","useSyncExternalStore","useFluxStore","store"],"mappings":"wPAAAA,CAAAA,oBAAoB,CAAC,CAAG,CAACC,EAAS,EAAS,KAC1C,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EAAO,EAEtDQ,EAAoBN,AAAAA,GAAAA,+BAAAA,WAAAA,AAAAA,EAAY,IAAOR,EAAQA,EAAM,GAAG,CAACM,GAAUA,EAAO,GAAG,GAAK,CAACN,EAAOM,EAAO,EACvG,MAAOS,AAAAA,GAAAA,+BAAAA,oBAAAA,AAAAA,EAAqBR,EAAWM,EAAaC,EACtD,CCtBO,SAASE,aAAqDC,CAA+B,EAClG,OAAOZ,UAAUY,EACnB,C"}
@@ -0,0 +1,7 @@
1
+ import type { FluxStore } from '@slux/flux';
2
+
3
+ export declare function useFluxStore<State, Action extends {
4
+ type: string;
5
+ }>(store: FluxStore<State, Action>): State;
6
+
7
+ export { }
package/dist/flux.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { FluxStore } from '@slux/flux';
2
+
3
+ export declare function useFluxStore<State, Action extends {
4
+ type: string;
5
+ }>(store: FluxStore<State, Action>): State;
6
+
7
+ export { }
package/dist/flux.js ADDED
@@ -0,0 +1,2 @@
1
+ import{useSignal as r}from"./5~0.js";function o(o){return r(o)}export{o as useFluxStore};
2
+ //# sourceMappingURL=flux.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flux.js","sources":["../src/flux.ts"],"sourcesContent":["import type { FluxStore } from \"@slux/flux\";\nimport { useSignal } from \"./hooks/use-signal.js\";\n\nexport function useFluxStore<State, Action extends { type: string }>(store: FluxStore<State, Action>): State {\n return useSignal(store);\n}\n"],"names":["useFluxStore","store","useSignal"],"mappings":"iDAGO,SAASA,EAAqDC,CAA+B,EAClG,OAAOC,EAAUD,EACnB,Q"}
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t,r)=>{var _=(t,r)=>{for(var _ in t)__webpack_require__.o(t,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,[r]:t[_]})};_(t,"get"),_(r,"value")},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ScopeContext:()=>ScopeContext,ScopeProvider:()=>ScopeProvider,createAutoImportApis:()=>createAutoImportApis,useScopeContext:()=>useScopeContext,useSignal:()=>useSignal});const external_react_namespaceObject=require("react"),core_namespaceObject=require("@slux/core"),ScopeContext=(0,external_react_namespaceObject.createContext)(null);function ScopeProvider({scope:e,children:t}){return(0,external_react_namespaceObject.createElement)(ScopeContext.Provider,{value:e},t)}function useScopeContext(){return(0,external_react_namespaceObject.useContext)(ScopeContext)}function useSignal(e){let t=useScopeContext(),r=(0,external_react_namespaceObject.useCallback)(t=>{let r=e.subscribe(()=>t()),_=(0,core_namespaceObject.effect)(()=>{e.get()});return()=>{r(),_()}},[e]),_=(0,external_react_namespaceObject.useCallback)(()=>e.get(),[e]),o=(0,external_react_namespaceObject.useCallback)(()=>t?t.get(e):e.get(),[t,e]);return(0,external_react_namespaceObject.useSyncExternalStore)(r,_,o)}const shared_namespaceObject=require("@slux/shared"),allImportApis=["ScopeContext","ScopeProvider","useScopeContext","useSignal"],createAutoImportApis=(e="")=>(0,shared_namespaceObject.generateBatchAutoImports)([{prefix:e,fromName:"@slux/react",imports:allImportApis}]);for(var __rspack_i in exports.ScopeContext=__webpack_exports__.ScopeContext,exports.ScopeProvider=__webpack_exports__.ScopeProvider,exports.createAutoImportApis=__webpack_exports__.createAutoImportApis,exports.useScopeContext=__webpack_exports__.useScopeContext,exports.useSignal=__webpack_exports__.useSignal,__webpack_exports__)-1===["ScopeContext","ScopeProvider","createAutoImportApis","useScopeContext","useSignal"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/scope/scope-context.ts","../src/hooks/use-signal.ts","../src/auto-import-api.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { createContext, createElement, useContext } from \"react\";\nimport type { Scope } from \"@slux/core\";\nimport type { ScopeProviderProps } from \"../types/index.js\";\n\nexport const ScopeContext = createContext<Scope | null>(null);\n\nexport function ScopeProvider({ scope, children }: ScopeProviderProps) {\n return createElement(ScopeContext.Provider, { value: scope }, children);\n}\n\nexport function useScopeContext(): Scope | null {\n return useContext(ScopeContext);\n}\n","import { useCallback, useSyncExternalStore } from \"react\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\nimport { useScopeContext } from \"../scope/scope-context.js\";\n\nexport function useSignal<T>(source: Subscribable<T>): T {\n const scope = useScopeContext();\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n const unsubscribe = source.subscribe(() => onStoreChange());\n // computed 只有读取时才刷新并通知;effect 将依赖变化接入外部订阅。\n const dispose = effect(() => {\n source.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n },\n [source],\n );\n const getSnapshot = useCallback(() => source.get(), [source]);\n // 对齐 core 的显式作用域契约:客户端正常渲染仍读取全局值。\n const getServerSnapshot = useCallback(() => (scope ? scope.get(source) : source.get()), [scope, source]);\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n","import { generateBatchAutoImports } from \"@slux/shared\";\n\nconst allImportApis: string[] = [\"ScopeContext\", \"ScopeProvider\", \"useScopeContext\", \"useSignal\"];\n\nexport const createAutoImportApis = (prefix: string = \"\") => {\n return generateBatchAutoImports([\n {\n prefix,\n fromName: \"@slux/react\",\n imports: allImportApis,\n },\n ]);\n};\n"],"names":["__webpack_require__","e","Object","Symbol","ScopeContext","createContext","ScopeProvider","scope","children","createElement","useScopeContext","useContext","useSignal","source","subscribe","useCallback","onStoreChange","unsubscribe","dispose","effect","getSnapshot","getServerSnapshot","useSyncExternalStore","allImportApis","createAutoImportApis","prefix","generateBatchAutoImports"],"mappings":"wPAAAA,CAAAA,oBAAoB,CAAC,CAAG,CAACC,EAAS,EAAS,KAC1C,IAAI,EAAS,CAAC,EAAM,KACnB,IAAI,IAAI,KAAO,EACXD,oBAAoB,CAAC,CAAC,EAAM,IAAQ,CAACA,oBAAoB,CAAC,CAACC,EAAS,IACtEC,OAAO,cAAc,CAACD,EAAS,EAAK,CAAE,WAAY,GAAM,CAAC,EAAK,CAAE,CAAI,CAAC,EAAI,AAAC,EAG7E,EACA,EAAO,EAAS,OAChB,EAAO,EAAQ,QAChB,ECVAD,oBAAoB,CAAC,CAAG,CAAC,EAAK,IAAUE,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAK,GCClFF,oBAAoB,CAAC,CAAG,AAACC,IACrB,AAAkB,IAAlB,OAAOE,QAA0BA,OAAO,WAAW,EACrDD,OAAO,cAAc,CAACD,EAASE,OAAO,WAAW,CAAE,CAAE,MAAO,QAAS,GAEtED,OAAO,cAAc,CAACD,EAAS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from 'react';
4
+ import type { ReactNode } from 'react';
5
+ import type { Scope } from '@slux/core';
6
+ import type { Subscribable } from '@slux/core';
7
+
8
+ export declare const createAutoImportApis: (prefix?: string) => {
9
+ [x: string]: (string | [string, string])[];
10
+ };
11
+
12
+ export declare const ScopeContext: Context<Scope | null>;
13
+
14
+ export declare function ScopeProvider({ scope, children }: ScopeProviderProps): FunctionComponentElement<ProviderProps<Scope | null>>;
15
+
16
+ export declare type ScopeProviderProps = {
17
+ readonly scope: Scope;
18
+ readonly children: ReactNode;
19
+ };
20
+
21
+ export declare function useScopeContext(): Scope | null;
22
+
23
+ export declare function useSignal<T>(source: Subscribable<T>): T;
24
+
25
+ export { }
@@ -0,0 +1,25 @@
1
+ import { Context } from 'react';
2
+ import { FunctionComponentElement } from 'react';
3
+ import { ProviderProps } from 'react';
4
+ import type { ReactNode } from 'react';
5
+ import type { Scope } from '@slux/core';
6
+ import type { Subscribable } from '@slux/core';
7
+
8
+ export declare const createAutoImportApis: (prefix?: string) => {
9
+ [x: string]: (string | [string, string])[];
10
+ };
11
+
12
+ export declare const ScopeContext: Context<Scope | null>;
13
+
14
+ export declare function ScopeProvider({ scope, children }: ScopeProviderProps): FunctionComponentElement<ProviderProps<Scope | null>>;
15
+
16
+ export declare type ScopeProviderProps = {
17
+ readonly scope: Scope;
18
+ readonly children: ReactNode;
19
+ };
20
+
21
+ export declare function useScopeContext(): Scope | null;
22
+
23
+ export declare function useSignal<T>(source: Subscribable<T>): T;
24
+
25
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import{generateBatchAutoImports as e}from"@slux/shared";let o=["ScopeContext","ScopeProvider","useScopeContext","useSignal"],t=(t="")=>e([{prefix:t,fromName:"@slux/react",imports:o}]);export{ScopeContext,ScopeProvider,useScopeContext,useSignal}from"./5~0.js";export{t as createAutoImportApis};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/auto-import-api.ts"],"sourcesContent":["import { generateBatchAutoImports } from \"@slux/shared\";\n\nconst allImportApis: string[] = [\"ScopeContext\", \"ScopeProvider\", \"useScopeContext\", \"useSignal\"];\n\nexport const createAutoImportApis = (prefix: string = \"\") => {\n return generateBatchAutoImports([\n {\n prefix,\n fromName: \"@slux/react\",\n imports: allImportApis,\n },\n ]);\n};\n"],"names":["allImportApis","createAutoImportApis","prefix","generateBatchAutoImports"],"mappings":"wDAEA,IAAMA,EAA0B,CAAC,eAAgB,gBAAiB,kBAAmB,YAAY,CAEpFC,EAAuB,CAACC,EAAiB,EAAE,GAC/CC,EAAyB,CAC9B,CACED,OAAAA,EACA,SAAU,cACV,QAASF,CACX,EACD,C"}
package/dist/proxy.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,_,r)=>{var a=(_,r)=>{for(var a in _)__webpack_require__.o(_,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,[r]:_[a]})};a(_,"get"),a(r,"value")},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{useSnapshot:()=>useSnapshot});const external_react_namespaceObject=require("react"),proxy_namespaceObject=require("@slux/proxy");function useSnapshot(e){let _=(0,external_react_namespaceObject.useCallback)(_=>(0,proxy_namespaceObject.subscribe)(e,_),[e]),r=(0,external_react_namespaceObject.useCallback)(()=>(0,proxy_namespaceObject.snapshot)(e),[e]);return(0,external_react_namespaceObject.useSyncExternalStore)(_,r,r)}for(var __rspack_i in exports.useSnapshot=__webpack_exports__.useSnapshot,__webpack_exports__)-1===["useSnapshot"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=proxy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/proxy.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { useCallback, useSyncExternalStore } from \"react\";\nimport { snapshot, subscribe } from \"@slux/proxy\";\nimport type { Snapshot } from \"@slux/proxy\";\n\nexport function useSnapshot<T extends object>(proxy: T): Snapshot<T> {\n const sub = useCallback((onStoreChange: () => void) => subscribe(proxy, onStoreChange), [proxy]);\n const getSnapshot = useCallback(() => snapshot(proxy), [proxy]);\n return useSyncExternalStore(sub, getSnapshot, getSnapshot);\n}\n"],"names":["__webpack_require__","e","Object","Symbol","useSnapshot","proxy","sub","useCallback","onStoreChange","subscribe","getSnapshot","snapshot","useSyncExternalStore"],"mappings":"wPAAAA,CAAAA,oBAAoB,CAAC,CAAG,CAACC,EAAS,EAAS,KAC1C,IAAI,EAAS,CAAC,EAAM,KACnB,IAAI,IAAI,KAAO,EACXD,oBAAoB,CAAC,CAAC,EAAM,IAAQ,CAACA,oBAAoB,CAAC,CAACC,EAAS,IACtEC,OAAO,cAAc,CAACD,EAAS,EAAK,CAAE,WAAY,GAAM,CAAC,EAAK,CAAE,CAAI,CAAC,EAAI,AAAC,EAG7E,EACA,EAAO,EAAS,OAChB,EAAO,EAAQ,QAChB,ECVAD,oBAAoB,CAAC,CAAG,CAAC,EAAK,IAAUE,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAK,GCClFF,oBAAoB,CAAC,CAAG,AAACC,IACrB,AAAkB,IAAlB,OAAOE,QAA0BA,OAAO,WAAW,EACrDD,OAAO,cAAc,CAACD,EAASE,OAAO,WAAW,CAAE,CAAE,MAAO,QAAS,GAEtED,OAAO,cAAc,CAACD,EAAS,aAAc,CAAE,MAAO,EAAK,EAC5D,E,kPCFO,SAASG,YAA8BC,CAAQ,EACpD,IAAMC,EAAMC,AAAAA,GAAAA,+BAAAA,WAAAA,AAAAA,EAAY,AAACC,GAA8BC,AAAAA,GAAAA,sBAAAA,SAAAA,AAAAA,EAAUJ,EAAOG,GAAgB,CAACH,EAAM,EACzFK,EAAcH,AAAAA,GAAAA,+BAAAA,WAAAA,AAAAA,EAAY,IAAMI,AAAAA,GAAAA,sBAAAA,QAAAA,AAAAA,EAASN,GAAQ,CAACA,EAAM,EAC9D,MAAOO,AAAAA,GAAAA,+BAAAA,oBAAAA,AAAAA,EAAqBN,EAAKI,EAAaA,EAChD,C"}
@@ -0,0 +1,5 @@
1
+ import type { Snapshot } from '@slux/proxy';
2
+
3
+ export declare function useSnapshot<T extends object>(proxy: T): Snapshot<T>;
4
+
5
+ export { }
@@ -0,0 +1,5 @@
1
+ import type { Snapshot } from '@slux/proxy';
2
+
3
+ export declare function useSnapshot<T extends object>(proxy: T): Snapshot<T>;
4
+
5
+ export { }
package/dist/proxy.js ADDED
@@ -0,0 +1,2 @@
1
+ import{useCallback as r,useSyncExternalStore as o}from"react";import{snapshot as t,subscribe as e}from"@slux/proxy";function p(p){let m=r(r=>e(p,r),[p]),n=r(()=>t(p),[p]);return o(m,n,n)}export{p as useSnapshot};
2
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.js","sources":["../src/proxy.ts"],"sourcesContent":["import { useCallback, useSyncExternalStore } from \"react\";\nimport { snapshot, subscribe } from \"@slux/proxy\";\nimport type { Snapshot } from \"@slux/proxy\";\n\nexport function useSnapshot<T extends object>(proxy: T): Snapshot<T> {\n const sub = useCallback((onStoreChange: () => void) => subscribe(proxy, onStoreChange), [proxy]);\n const getSnapshot = useCallback(() => snapshot(proxy), [proxy]);\n return useSyncExternalStore(sub, getSnapshot, getSnapshot);\n}\n"],"names":["useSnapshot","proxy","sub","useCallback","onStoreChange","subscribe","getSnapshot","snapshot","useSyncExternalStore"],"mappings":"oHAIO,SAASA,EAA8BC,CAAQ,EACpD,IAAMC,EAAMC,EAAY,AAACC,GAA8BC,EAAUJ,EAAOG,GAAgB,CAACH,EAAM,EACzFK,EAAcH,EAAY,IAAMI,EAASN,GAAQ,CAACA,EAAM,EAC9D,OAAOO,EAAqBN,EAAKI,EAAaA,EAChD,Q"}
package/dist/rxjs.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r,_)=>{var t=(r,_)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[_]:r[t]})};t(r,"get"),t(_,"value")},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{useObservable:()=>useObservable});const external_react_namespaceObject=require("react"),core_namespaceObject=require("@slux/core"),ScopeContext=(0,external_react_namespaceObject.createContext)(null);function ScopeProvider({scope:e,children:r}){return createElement(ScopeContext.Provider,{value:e},r)}function useScopeContext(){return(0,external_react_namespaceObject.useContext)(ScopeContext)}function useSignal(e){let r=useScopeContext(),_=(0,external_react_namespaceObject.useCallback)(r=>{let _=e.subscribe(()=>r()),t=(0,core_namespaceObject.effect)(()=>{e.get()});return()=>{_(),t()}},[e]),t=(0,external_react_namespaceObject.useCallback)(()=>e.get(),[e]),a=(0,external_react_namespaceObject.useCallback)(()=>r?r.get(e):e.get(),[r,e]);return(0,external_react_namespaceObject.useSyncExternalStore)(_,t,a)}function useObservable(e){return useSignal(e)}for(var __rspack_i in exports.useObservable=__webpack_exports__.useObservable,__webpack_exports__)-1===["useObservable"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=rxjs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rxjs.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/scope/scope-context.ts","../src/hooks/use-signal.ts","../src/rxjs.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { createContext, createElement, useContext } from \"react\";\nimport type { Scope } from \"@slux/core\";\nimport type { ScopeProviderProps } from \"../types/index.js\";\n\nexport const ScopeContext = createContext<Scope | null>(null);\n\nexport function ScopeProvider({ scope, children }: ScopeProviderProps) {\n return createElement(ScopeContext.Provider, { value: scope }, children);\n}\n\nexport function useScopeContext(): Scope | null {\n return useContext(ScopeContext);\n}\n","import { useCallback, useSyncExternalStore } from \"react\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\nimport { useScopeContext } from \"../scope/scope-context.js\";\n\nexport function useSignal<T>(source: Subscribable<T>): T {\n const scope = useScopeContext();\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n const unsubscribe = source.subscribe(() => onStoreChange());\n // computed 只有读取时才刷新并通知;effect 将依赖变化接入外部订阅。\n const dispose = effect(() => {\n source.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n },\n [source],\n );\n const getSnapshot = useCallback(() => source.get(), [source]);\n // 对齐 core 的显式作用域契约:客户端正常渲染仍读取全局值。\n const getServerSnapshot = useCallback(() => (scope ? scope.get(source) : source.get()), [scope, source]);\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n","import type { ObservableState } from \"@slux/rxjs\";\nimport { useSignal } from \"./hooks/use-signal.js\";\n\nexport function useObservable<T>(source: ObservableState<T>): T {\n return useSignal(source);\n}\n"],"names":["__webpack_require__","e","Object","Symbol","ScopeContext","createContext","ScopeProvider","scope","children","createElement","useScopeContext","useContext","useSignal","source","subscribe","useCallback","onStoreChange","unsubscribe","dispose","effect","getSnapshot","getServerSnapshot","useSyncExternalStore","useObservable"],"mappings":"wPAAAA,CAAAA,oBAAoB,CAAC,CAAG,CAACC,EAAS,EAAS,KAC1C,IAAI,EAAS,CAAC,EAAM,KACnB,IAAI,IAAI,KAAO,EACXD,oBAAoB,CAAC,CAAC,EAAM,IAAQ,CAACA,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CAACM,GAAUA,EAAO,GAAG,GAAK,CAACN,EAAOM,EAAO,EACvG,MAAOS,AAAAA,GAAAA,+BAAAA,oBAAAA,AAAAA,EAAqBR,EAAWM,EAAaC,EACtD,CCtBO,SAASE,cAAiBV,CAA0B,EACzD,OAAOD,UAAUC,EACnB,C"}
@@ -0,0 +1,5 @@
1
+ import type { ObservableState } from '@slux/rxjs';
2
+
3
+ export declare function useObservable<T>(source: ObservableState<T>): T;
4
+
5
+ export { }
package/dist/rxjs.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { ObservableState } from '@slux/rxjs';
2
+
3
+ export declare function useObservable<T>(source: ObservableState<T>): T;
4
+
5
+ export { }
package/dist/rxjs.js ADDED
@@ -0,0 +1,2 @@
1
+ import{useSignal as r}from"./5~0.js";function e(e){return r(e)}export{e as useObservable};
2
+ //# sourceMappingURL=rxjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rxjs.js","sources":["../src/rxjs.ts"],"sourcesContent":["import type { ObservableState } from \"@slux/rxjs\";\nimport { useSignal } from \"./hooks/use-signal.js\";\n\nexport function useObservable<T>(source: ObservableState<T>): T {\n return useSignal(source);\n}\n"],"names":["useObservable","source","useSignal"],"mappings":"iDAGO,SAASA,EAAiBC,CAA0B,EACzD,OAAOC,EAAUD,EACnB,Q"}
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,_,r)=>{var t=(_,r)=>{for(var t in _)__webpack_require__.o(_,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[r]:_[t]})};t(_,"get"),t(r,"value")},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{useMachine:()=>useMachine});const external_react_namespaceObject=require("react"),core_namespaceObject=require("@slux/core"),ScopeContext=(0,external_react_namespaceObject.createContext)(null);function ScopeProvider({scope:e,children:_}){return createElement(ScopeContext.Provider,{value:e},_)}function useScopeContext(){return(0,external_react_namespaceObject.useContext)(ScopeContext)}function useSignal(e){let _=useScopeContext(),r=(0,external_react_namespaceObject.useCallback)(_=>{let r=e.subscribe(()=>_()),t=(0,core_namespaceObject.effect)(()=>{e.get()});return()=>{r(),t()}},[e]),t=(0,external_react_namespaceObject.useCallback)(()=>e.get(),[e]),c=(0,external_react_namespaceObject.useCallback)(()=>_?_.get(e):e.get(),[_,e]);return(0,external_react_namespaceObject.useSyncExternalStore)(r,t,c)}function useMachine(e){return useSignal(e)}for(var __rspack_i in exports.useMachine=__webpack_exports__.useMachine,__webpack_exports__)-1===["useMachine"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=state-machine.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/scope/scope-context.ts","../src/hooks/use-signal.ts","../src/state-machine.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { createContext, createElement, useContext } from \"react\";\nimport type { Scope } from \"@slux/core\";\nimport type { ScopeProviderProps } from \"../types/index.js\";\n\nexport const ScopeContext = createContext<Scope | null>(null);\n\nexport function ScopeProvider({ scope, children }: ScopeProviderProps) {\n return createElement(ScopeContext.Provider, { value: scope }, children);\n}\n\nexport function useScopeContext(): Scope | null {\n return useContext(ScopeContext);\n}\n","import { useCallback, useSyncExternalStore } from \"react\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\nimport { useScopeContext } from \"../scope/scope-context.js\";\n\nexport function useSignal<T>(source: Subscribable<T>): T {\n const scope = useScopeContext();\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n const unsubscribe = source.subscribe(() => onStoreChange());\n // computed 只有读取时才刷新并通知;effect 将依赖变化接入外部订阅。\n const dispose = effect(() => {\n source.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n },\n [source],\n );\n const getSnapshot = useCallback(() => source.get(), [source]);\n // 对齐 core 的显式作用域契约:客户端正常渲染仍读取全局值。\n const getServerSnapshot = useCallback(() => (scope ? scope.get(source) : source.get()), [scope, source]);\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n","import type { MachineSnapshot, StateMachine } from \"@slux/state-machine\";\nimport { useSignal } from \"./hooks/use-signal.js\";\n\nexport function useMachine<Context, Event extends { type: string }, State extends string>(\n machine: StateMachine<Context, Event, State>,\n): MachineSnapshot<Context, State> {\n return useSignal(machine);\n}\n"],"names":["__webpack_require__","e","Object","Symbol","ScopeContext","createContext","ScopeProvider","scope","children","createElement","useScopeContext","useContext","useSignal","source","subscribe","useCallback","onStoreChange","unsubscribe","dispose","effect","getSnapshot","getServerSnapshot","useSyncExternalStore","useMachine","machine"],"mappings":"wPAAAA,CAAAA,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,AAAAA,EAAY,IAAMF,EAAO,GAAG,GAAI,CAACA,EAAO,EAEtDQ,EAAoBN,AAAAA,GAAAA,+BAAAA,WAAAA,AAAAA,EAAY,IAAOR,EAAQA,EAAM,GAAG,CAACM,GAAUA,EAAO,GAAG,GAAK,CAACN,EAAOM,EAAO,EACvG,MAAOS,AAAAA,GAAAA,+BAAAA,oBAAAA,AAAAA,EAAqBR,EAAWM,EAAaC,EACtD,CCtBO,SAASE,WACdC,CAA4C,EAE5C,OAAOZ,UAAUY,EACnB,C"}
@@ -0,0 +1,8 @@
1
+ import type { MachineSnapshot } from '@slux/state-machine';
2
+ import type { StateMachine } from '@slux/state-machine';
3
+
4
+ export declare function useMachine<Context, Event extends {
5
+ type: string;
6
+ }, State extends string>(machine: StateMachine<Context, Event, State>): MachineSnapshot<Context, State>;
7
+
8
+ export { }
@@ -0,0 +1,8 @@
1
+ import type { MachineSnapshot } from '@slux/state-machine';
2
+ import type { StateMachine } from '@slux/state-machine';
3
+
4
+ export declare function useMachine<Context, Event extends {
5
+ type: string;
6
+ }, State extends string>(machine: StateMachine<Context, Event, State>): MachineSnapshot<Context, State>;
7
+
8
+ export { }
@@ -0,0 +1,2 @@
1
+ import{useSignal as r}from"./5~0.js";function _(_){return r(_)}export{_ as useMachine};
2
+ //# sourceMappingURL=state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.js","sources":["../src/state-machine.ts"],"sourcesContent":["import type { MachineSnapshot, StateMachine } from \"@slux/state-machine\";\nimport { useSignal } from \"./hooks/use-signal.js\";\n\nexport function useMachine<Context, Event extends { type: string }, State extends string>(\n machine: StateMachine<Context, Event, State>,\n): MachineSnapshot<Context, State> {\n return useSignal(machine);\n}\n"],"names":["useMachine","machine","useSignal"],"mappings":"iDAGO,SAASA,EACdC,CAA4C,EAE5C,OAAOC,EAAUD,EACnB,Q"}
package/dist/store.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,_,r)=>{var t=(_,r)=>{for(var t in _)__webpack_require__.o(_,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[r]:_[t]})};t(_,"get"),t(r,"value")},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{useStore:()=>useStore});const external_react_namespaceObject=require("react");function useStore(e,_,r=Object.is){let t=(0,external_react_namespaceObject.useCallback)(_=>e.subscribe(_),[e]),a=(0,external_react_namespaceObject.useMemo)(()=>{let t;return _?()=>{let a=e.getState();if(t&&Object.is(t.state,a))return t.selection;let c=_(a),o=t&&r(t.selection,c)?t.selection:c;return t={state:a,selection:o},o}:()=>e.getState()},[e,_,r]);return(0,external_react_namespaceObject.useSyncExternalStore)(t,a,a)}for(var __rspack_i in exports.useStore=__webpack_exports__.useStore,__webpack_exports__)-1===["useStore"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=store.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/store.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { useCallback, useMemo, useSyncExternalStore } from \"react\";\nimport type { StoreApi } from \"@slux/store\";\n\nexport function useStore<State extends object>(store: StoreApi<State>): State;\nexport function useStore<State extends object, Selection>(\n store: StoreApi<State>,\n selector: (state: State) => Selection,\n equalityFn?: (previous: Selection, next: Selection) => boolean,\n): Selection;\nexport function useStore<State extends object, Selection>(\n store: StoreApi<State>,\n selector?: (state: State) => Selection,\n equalityFn: (previous: Selection, next: Selection) => boolean = Object.is,\n): State | Selection {\n const subscribe = useCallback((onStoreChange: () => void) => store.subscribe(onStoreChange), [store]);\n const getSnapshot = useMemo(() => {\n if (!selector) return () => store.getState();\n\n // 缓存随 store、selector 和比较器更换而重建,不在并发渲染间共享可写 ref。\n let cache: { state: State; selection: Selection } | undefined;\n return () => {\n const state = store.getState();\n if (cache && Object.is(cache.state, state)) return cache.selection;\n const next = selector(state);\n const selection = cache && equalityFn(cache.selection, next) ? cache.selection : next;\n cache = { state, selection };\n return selection;\n };\n }, [store, selector, equalityFn]);\n\n return useSyncExternalStore<State | Selection>(subscribe, getSnapshot, getSnapshot);\n}\n"],"names":["__webpack_require__","e","Object","Symbol","useStore","store","selector","equalityFn","subscribe","useCallback","onStoreChange","getSnapshot","useMemo","cache","state","next","selection","useSyncExternalStore"],"mappings":"wPAAAA,CAAAA,oBAAoB,CAAC,CAAG,CAACC,EAAS,EAAS,KAC1C,IAAI,EAAS,CAAC,EAAM,KACnB,IAAI,IAAI,KAAO,EACXD,oBAAoB,CAAC,CAAC,EAAM,IAAQ,CAACA,oBAAoB,CAAC,CAACC,EAAS,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ore<State extends object>(store: StoreApi<State>): State;
4
+
5
+ export declare function useStore<State extends object, Selection>(store: StoreApi<State>, selector: (state: State) => Selection, equalityFn?: (previous: Selection, next: Selection) => boolean): Selection;
6
+
7
+ export { }
@@ -0,0 +1,7 @@
1
+ import type { StoreApi } from '@slux/store';
2
+
3
+ export declare function useStore<State extends object>(store: StoreApi<State>): State;
4
+
5
+ export declare function useStore<State extends object, Selection>(store: StoreApi<State>, selector: (state: State) => Selection, equalityFn?: (previous: Selection, next: Selection) => boolean): Selection;
6
+
7
+ export { }
package/dist/store.js ADDED
@@ -0,0 +1,2 @@
1
+ import{useCallback as e,useMemo as t,useSyncExternalStore as r}from"react";function i(n,s,c=Object.is){let o=e(e=>n.subscribe(e),[n]),l=t(()=>{let e;return s?()=>{let t=n.getState();if(e&&Object.is(e.state,t))return e.selection;let r=s(t),i=e&&c(e.selection,r)?e.selection:r;return e={state:t,selection:i},i}:()=>n.getState()},[n,s,c]);return r(o,l,l)}export{i as useStore};
2
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sources":["../src/store.ts"],"sourcesContent":["import { useCallback, useMemo, useSyncExternalStore } from \"react\";\nimport type { StoreApi } from \"@slux/store\";\n\nexport function useStore<State extends object>(store: StoreApi<State>): State;\nexport function useStore<State extends object, Selection>(\n store: StoreApi<State>,\n selector: (state: State) => Selection,\n equalityFn?: (previous: Selection, next: Selection) => boolean,\n): Selection;\nexport function useStore<State extends object, Selection>(\n store: StoreApi<State>,\n selector?: (state: State) => Selection,\n equalityFn: (previous: Selection, next: Selection) => boolean = Object.is,\n): State | Selection {\n const subscribe = useCallback((onStoreChange: () => void) => store.subscribe(onStoreChange), [store]);\n const getSnapshot = useMemo(() => {\n if (!selector) return () => store.getState();\n\n // 缓存随 store、selector 和比较器更换而重建,不在并发渲染间共享可写 ref。\n let cache: { state: State; selection: Selection } | undefined;\n return () => {\n const state = store.getState();\n if (cache && Object.is(cache.state, state)) return cache.selection;\n const next = selector(state);\n const selection = cache && equalityFn(cache.selection, next) ? cache.selection : next;\n cache = { state, selection };\n return selection;\n };\n }, [store, selector, equalityFn]);\n\n return useSyncExternalStore<State | Selection>(subscribe, getSnapshot, getSnapshot);\n}\n"],"names":["useStore","store","selector","equalityFn","Object","subscribe","useCallback","onStoreChange","getSnapshot","useMemo","cache","state","next","selection","useSyncExternalStore"],"mappings":"2EASO,SAASA,EACdC,CAAsB,CACtBC,CAAsC,CACtCC,EAAgEC,OAAO,EAAE,EAEzE,IAAMC,EAAYC,EAAY,AAACC,GAA8BN,EAAM,SAAS,CAACM,GAAgB,CAACN,EAAM,EAC9FO,EAAcC,EAAQ,SAItBC,SAHJ,AAAKR,EAIE,KACL,IAAMS,EAAQV,EAAM,QAAQ,GAC5B,GAAIS,GAASN,OAAO,EAAE,CAACM,EAAM,KAAK,CAAEC,GAAQ,OAAOD,EAAM,SAAS,CAClE,IAAME,EAAOV,EAASS,GAChBE,EAAYH,GAASP,EAAWO,EAAM,SAAS,CAAEE,GAAQF,EAAM,SAAS,CAAGE,EAEjF,OADAF,EAAQ,CAAEC,MAAAA,EAAOE,UAAAA,CAAU,EACpBA,CACT,EAXsB,IAAMZ,EAAM,QAAQ,EAY5C,EAAG,CAACA,EAAOC,EAAUC,EAAW,EAEhC,OAAOW,EAAwCT,EAAWG,EAAaA,EACzE,Q"}
package/package.json CHANGED
@@ -1,6 +1,165 @@
1
1
  {
2
2
  "name": "@slux/react",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "slux React bindings",
5
+ "keywords": [
6
+ "slux",
7
+ "react",
8
+ "hooks",
9
+ "bindings",
10
+ "state-management"
11
+ ],
12
+ "type": "module",
13
+ "sideEffects": false,
14
+ "license": "MIT",
15
+ "author": "itmanyong <itmanyong@gmail.com>",
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/itmanyong/slux.git",
22
+ "directory": "packages/react"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "README.md",
27
+ "CHANGELOG.md",
28
+ "package.json"
29
+ ],
30
+ "main": "./dist/index.cjs",
31
+ "module": "./dist/index.js",
32
+ "types": "./dist/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "import": {
36
+ "types": "./dist/index.d.ts",
37
+ "default": "./dist/index.js"
38
+ },
39
+ "require": {
40
+ "types": "./dist/index.d.cts",
41
+ "default": "./dist/index.cjs"
42
+ }
43
+ },
44
+ "./atom": {
45
+ "import": {
46
+ "types": "./dist/atom.d.ts",
47
+ "default": "./dist/atom.js"
48
+ },
49
+ "require": {
50
+ "types": "./dist/atom.d.cts",
51
+ "default": "./dist/atom.cjs"
52
+ }
53
+ },
54
+ "./store": {
55
+ "import": {
56
+ "types": "./dist/store.d.ts",
57
+ "default": "./dist/store.js"
58
+ },
59
+ "require": {
60
+ "types": "./dist/store.d.cts",
61
+ "default": "./dist/store.cjs"
62
+ }
63
+ },
64
+ "./proxy": {
65
+ "import": {
66
+ "types": "./dist/proxy.d.ts",
67
+ "default": "./dist/proxy.js"
68
+ },
69
+ "require": {
70
+ "types": "./dist/proxy.d.cts",
71
+ "default": "./dist/proxy.cjs"
72
+ }
73
+ },
74
+ "./package.json": "./package.json",
75
+ "./flux": {
76
+ "import": {
77
+ "types": "./dist/flux.d.ts",
78
+ "default": "./dist/flux.js"
79
+ },
80
+ "require": {
81
+ "types": "./dist/flux.d.cts",
82
+ "default": "./dist/flux.cjs"
83
+ }
84
+ },
85
+ "./state-machine": {
86
+ "import": {
87
+ "types": "./dist/state-machine.d.ts",
88
+ "default": "./dist/state-machine.js"
89
+ },
90
+ "require": {
91
+ "types": "./dist/state-machine.d.cts",
92
+ "default": "./dist/state-machine.cjs"
93
+ }
94
+ },
95
+ "./rxjs": {
96
+ "import": {
97
+ "types": "./dist/rxjs.d.ts",
98
+ "default": "./dist/rxjs.js"
99
+ },
100
+ "require": {
101
+ "types": "./dist/rxjs.d.cts",
102
+ "default": "./dist/rxjs.cjs"
103
+ }
104
+ }
105
+ },
106
+ "peerDependencies": {
107
+ "@slux/atom": "^0.1.0",
108
+ "@slux/core": "^0.1.0",
109
+ "@slux/proxy": "^0.1.0",
110
+ "@slux/store": "^0.1.0",
111
+ "react": "^18.0.0 || ^19.0.0",
112
+ "@slux/flux": "^0.1.0",
113
+ "@slux/state-machine": "^0.1.0",
114
+ "@slux/rxjs": "^0.1.0"
115
+ },
116
+ "peerDependenciesMeta": {
117
+ "@slux/atom": {
118
+ "optional": true
119
+ },
120
+ "@slux/proxy": {
121
+ "optional": true
122
+ },
123
+ "@slux/store": {
124
+ "optional": true
125
+ },
126
+ "@slux/flux": {
127
+ "optional": true
128
+ },
129
+ "@slux/state-machine": {
130
+ "optional": true
131
+ },
132
+ "@slux/rxjs": {
133
+ "optional": true
134
+ }
135
+ },
136
+ "devDependencies": {
137
+ "@slux/atom": "0.1.0",
138
+ "@slux/core": "0.1.0",
139
+ "@slux/proxy": "0.1.0",
140
+ "@slux/store": "0.1.0",
141
+ "@types/react": "19.3.0",
142
+ "@types/react-dom": "19.3.0",
143
+ "jsdom": "30.1.3",
144
+ "react": "19.3.1",
145
+ "react-dom": "19.3.1",
146
+ "rstack": "0.9.0",
147
+ "typescript": "7.1.0-beta",
148
+ "@slux/flux": "0.1.0",
149
+ "@slux/state-machine": "0.1.0",
150
+ "@slux/rxjs": "0.1.0",
151
+ "rxjs": "7.8.2"
152
+ },
153
+ "dependencies": {
154
+ "@slux/shared": "0.1.0"
155
+ },
156
+ "scripts": {
157
+ "dev": "rs lib -w",
158
+ "build": "rs lib",
159
+ "test": "rs test",
160
+ "lint": "rs lint",
161
+ "fmt": "rs fmt",
162
+ "typecheck": "tsc --noEmit",
163
+ "clean": "rm -rf dist node_modules .turbo"
164
+ }
6
165
  }