@slux/vue 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.
- package/CHANGELOG.md +24 -0
- package/LICENSE +21 -0
- package/README.md +214 -2
- package/dist/atom.cjs +2 -0
- package/dist/atom.cjs.map +1 -0
- package/dist/atom.d.cts +11 -0
- package/dist/atom.d.ts +11 -0
- package/dist/atom.js +2 -0
- package/dist/atom.js.map +1 -0
- package/dist/e~0.js +2 -0
- package/dist/e~0.js.map +1 -0
- package/dist/flux.cjs +2 -0
- package/dist/flux.cjs.map +1 -0
- package/dist/flux.d.cts +7 -0
- package/dist/flux.d.ts +7 -0
- package/dist/flux.js +2 -0
- package/dist/flux.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +50 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/proxy.cjs +2 -0
- package/dist/proxy.cjs.map +1 -0
- package/dist/proxy.d.cts +6 -0
- package/dist/proxy.d.ts +6 -0
- package/dist/proxy.js +2 -0
- package/dist/proxy.js.map +1 -0
- package/dist/rxjs.cjs +2 -0
- package/dist/rxjs.cjs.map +1 -0
- package/dist/rxjs.d.cts +6 -0
- package/dist/rxjs.d.ts +6 -0
- package/dist/rxjs.js +2 -0
- package/dist/rxjs.js.map +1 -0
- package/dist/state-machine.cjs +2 -0
- package/dist/state-machine.cjs.map +1 -0
- package/dist/state-machine.d.cts +9 -0
- package/dist/state-machine.d.ts +9 -0
- package/dist/state-machine.js +2 -0
- package/dist/state-machine.js.map +1 -0
- package/dist/store.cjs +2 -0
- package/dist/store.cjs.map +1 -0
- package/dist/store.d.cts +8 -0
- package/dist/store.d.ts +8 -0
- package/dist/store.js +2 -0
- package/dist/store.js.map +1 -0
- package/package.json +160 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @slux/vue
|
|
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,215 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @slux/vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
把 `@slux/core` 的响应式状态接入 Vue 3.5 组合式 API。核心绑定 `useSignal` 返回一个**只读 Ref**(`Readonly<Ref<T>>`,内部为 `shallowRef` + `shallowReadonly`),在模板里可自动解包;主入口另提供 core `Scope` 的 provide / inject 封装与 `createAutoImportApis`。六个范式各通过独立子入口提供同样返回只读 Ref 的绑定。
|
|
4
|
+
|
|
5
|
+
跨框架一致的子入口划分、Flux / 状态机 / RxJS 的写入与桥接生命周期、Scope 显式覆盖语义与 SSR 通用约束见仓库根 [README](../../README.md) 的「框架适配 · 通用约定」;仓库内构建与验证命令见「本地开发」,本文不再重复。
|
|
6
|
+
|
|
7
|
+
## 特性与适用场景
|
|
8
|
+
|
|
9
|
+
| 场景 | 是否适合 | 说明 |
|
|
10
|
+
| ------------------------------------------------------------------ | -------- | ----------------------------------------------------------------- |
|
|
11
|
+
| 在 `setup()` / `<script setup>` 里把 signal、computed 读成只读 Ref | 适合 | `useSignal` 返回 `Readonly<Ref<T>>`,值变化写入 ref,模板自动解包 |
|
|
12
|
+
| 在独立 `effectScope` 中桥接状态并手动 `stop()` | 适合 | 无组件实例时立即订阅,`scope.stop()` 触发清理 |
|
|
13
|
+
| 消费 atom、store、proxy、flux、state-machine、rxjs 六种范式 | 适合 | 六个 `/xxx` 子入口分别导出对应绑定 |
|
|
14
|
+
| 组件外 / 异步回调里调用读取函数,或期望自动套用 Scope 覆盖 | 不适合 | `useSignal` 必须在 setup / effectScope 中,且始终读全局来源 |
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pnpm add @slux/vue @slux/core vue
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
| 项 | 值 | 来源 |
|
|
23
|
+
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
24
|
+
| Vue peer | `^3.5.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` 是全部入口的必需依赖。SSR 用到的 `@vue/server-renderer` 由应用自行提供。
|
|
30
|
+
|
|
31
|
+
`package.json` 的 `exports` 子入口(每个都提供 ESM `import` 与 CJS `require`,并带 `.d.ts` / `.d.cts`):
|
|
32
|
+
|
|
33
|
+
| 子入口 | 说明 |
|
|
34
|
+
| ------------------------- | ------------------------------------------------------------------- |
|
|
35
|
+
| `@slux/vue` | 主入口:`useSignal`、`useStore`、Scope 封装、`createAutoImportApis` |
|
|
36
|
+
| `@slux/vue/atom` | atom 绑定 |
|
|
37
|
+
| `@slux/vue/store` | store 绑定 |
|
|
38
|
+
| `@slux/vue/proxy` | proxy 绑定 |
|
|
39
|
+
| `@slux/vue/flux` | flux 绑定 |
|
|
40
|
+
| `@slux/vue/state-machine` | 状态机绑定 |
|
|
41
|
+
| `@slux/vue/rxjs` | RxJS 桥接绑定 |
|
|
42
|
+
| `@slux/vue/package.json` | 包元信息 |
|
|
43
|
+
|
|
44
|
+
> 源码事实:主入口 `src/index.ts` 额外 `export { useStore } from "./store.js"`,与 `/store` 子入口是同一实现;`store.ts` 只 `import type { StoreApi }`,不引入 `@slux/store` 运行时依赖。
|
|
45
|
+
|
|
46
|
+
## 快速开始
|
|
47
|
+
|
|
48
|
+
```vue
|
|
49
|
+
<script setup lang="ts">
|
|
50
|
+
import { signal } from "@slux/core";
|
|
51
|
+
import { useSignal } from "@slux/vue";
|
|
52
|
+
|
|
53
|
+
const count = signal(0);
|
|
54
|
+
const value = useSignal(count); // Readonly<Ref<number>>
|
|
55
|
+
function increment() {
|
|
56
|
+
count.set((n) => n + 1);
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<button @click="increment">{{ value }}</button>
|
|
62
|
+
</template>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`useSignal` 只负责读取与订阅,写入用 core 的 `set`;返回的 ref 是**只读**的,不能 `value.value = ...`。
|
|
66
|
+
|
|
67
|
+
## 主入口 API
|
|
68
|
+
|
|
69
|
+
### `useSignal`
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>>;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
| 行为 | 说明 |
|
|
76
|
+
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| 返回形式 | `shallowReadonly(shallowRef(source.get()))`,浅层响应式、只读;`Ref` 来自 `vue` |
|
|
78
|
+
| 调用位置 | 必须在 `setup()` 或 `effectScope` 中;`getCurrentScope()` 为假时抛 `Error("useSignal 必须在 Vue setup 或 effectScope 中调用")` |
|
|
79
|
+
| 组件内启动 | `getCurrentInstance()` 为真时用 `onMounted` 启动订阅;SSR 不执行挂载钩子,只返回初始读取值、不留订阅 |
|
|
80
|
+
| 独立 effectScope | 无组件实例时立即 `start()` 订阅,由调用方 `scope.stop()` 清理 |
|
|
81
|
+
| `start()` | 订阅 `source.subscribe`(写入 `value.value`)、起 core `effect(() => source.get())` 刷新惰性 computed、补读 `value.value = source.get()`;清理函数同时退订与释放 effect |
|
|
82
|
+
| 清理 | `onScopeDispose(() => stop?.())`,组件卸载或 effectScope 停止时执行 |
|
|
83
|
+
| 函数值 | 用 `shallowRef` 保存,函数值按原引用返回,不被解包或执行 |
|
|
84
|
+
| **不读 Scope** | 源码未引用 `useScope()`,客户端与 SSR 都是全局 `source.get()` / `subscribe`;覆盖需显式 `useScope()?.get(source)` |
|
|
85
|
+
|
|
86
|
+
自定义来源只需满足 `Subscribable<T>`(`get()` + `subscribe(cb)`,后者返回取消函数)。
|
|
87
|
+
|
|
88
|
+
### Scope 封装
|
|
89
|
+
|
|
90
|
+
| 导出 | 签名 / 类型 | 说明 |
|
|
91
|
+
| ------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
92
|
+
| `provideScope` | `(scope: Scope) => void` | 在 setup 中 `provide` 当前 Scope |
|
|
93
|
+
| `useScope` | `() => Scope \| undefined` | `inject` 最近的 Scope,无提供者时 `undefined` |
|
|
94
|
+
| `ScopeProvider` | `defineComponent` | `props.scope` 必填(`Object as PropType<Scope>`),`setup` 内调用 `provideScope`,渲染默认插槽 |
|
|
95
|
+
| `sluxPlugin` | `Plugin<[SluxPluginOptions] \| []>` | `app.use(sluxPlugin, { scope })` 在应用级 `app.provide` Scope |
|
|
96
|
+
| `SluxPluginOptions` | `{ readonly scope?: Scope }` | 插件选项类型(公开类型导出) |
|
|
97
|
+
|
|
98
|
+
`SCOPE_KEY` 是模块内私有的 `InjectionKey<Scope>`,**不导出**。嵌套 Provider 取最近一层(内层覆盖外层);替换 Scope 需重新创建组件子树。用法见「快速开始」与根 README 的 SSR 通用约定。
|
|
99
|
+
|
|
100
|
+
## 子入口 API
|
|
101
|
+
|
|
102
|
+
六个子入口的绑定**全部委托 `useSignal`**(atom 的 `useAtomValue` 直接 `useSignal(atom)`,store / proxy 构造 `{ get, subscribe }` 再传入,flux / 状态机 / rxjs 直接 `useSignal(原实例)`),统一返回 `Readonly<Ref<...>>`,并继承主入口的 setup / effectScope 约束、订阅清理与 SSR 边界。写入仍走原实例,绑定不返回写入 tuple 或 selector。
|
|
103
|
+
|
|
104
|
+
| 子入口 | 导出 | 签名要点 | 返回值 | 写入方式 |
|
|
105
|
+
| ---------------- | --------------------------------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ----------------------------------- |
|
|
106
|
+
| `/atom` | `useAtomValue`、`useSetAtom`、`useAtom` | `<T>(atom)` | `Readonly<Ref<T>>`、`(value: T) => void`、`[Readonly<Ref<T>>, setter]` | `set(value)` 或 `atom.update(fn)` |
|
|
107
|
+
| `/store` | `useStore` | `(store, selector?, equals?)` | `Readonly<Ref<T \| U>>` | `store.setState(...)` |
|
|
108
|
+
| `/proxy` | `useSnapshot` | `<T extends object>(proxy: T)` | `Readonly<Ref<Snapshot<T>>>` | 直接修改原 proxy |
|
|
109
|
+
| `/flux` | `useFluxStore` | `<State, Action extends FluxAction>(store)` | `Readonly<Ref<State>>` | `store.dispatch(action)` |
|
|
110
|
+
| `/state-machine` | `useMachine` | `<Context, Event extends { type: string }, State extends string>(machine)` | `Readonly<Ref<MachineSnapshot<Context, State>>>` | `machine.send(event)` |
|
|
111
|
+
| `/rxjs` | `useObservable` | `<T>(source: ObservableState<T>)` | `Readonly<Ref<T>>` | 上游 Observable,创建者 `dispose()` |
|
|
112
|
+
|
|
113
|
+
### `/atom`
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
// 在 setup() 内
|
|
117
|
+
import { atom, derived } from "@slux/atom";
|
|
118
|
+
import { useAtom, useAtomValue } from "@slux/vue/atom";
|
|
119
|
+
|
|
120
|
+
const count = atom(0);
|
|
121
|
+
const doubled = derived((get) => get(count) * 2);
|
|
122
|
+
const [value, set] = useAtom(count); // [Readonly<Ref<number>>, (v: number) => void]
|
|
123
|
+
const double = useAtomValue(doubled); // Readonly<Ref<number>>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`useAtomValue` 可读基础、派生与 writable atom(`AnyReadableAtom<T>`);`useSetAtom` 返回 `(value) => atom.set(value)`,**只做替换、不订阅**,函数值直接保存;`useAtom` 组合前两者。派生 atom 不可传给 `useSetAtom`(类型上被禁止)。
|
|
127
|
+
|
|
128
|
+
### `/store`
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
import { createStore } from "@slux/store";
|
|
132
|
+
import { useStore } from "@slux/vue/store";
|
|
133
|
+
|
|
134
|
+
const store = createStore(() => ({ count: 0, other: 0 }));
|
|
135
|
+
const count = useStore(store, (state) => state.count); // Readonly<Ref<number>>
|
|
136
|
+
const whole = useStore(store); // Readonly<Ref<{ count: number; other: number }>>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`useStore(store)` 返回完整状态;带 `selector, equals?` 时返回选值,`equals` 默认 `Object.is`,判定相等时保留上次选值引用,抑制无关字段更新。快照读 `store.getState()` 当前值;组件卸载只退订,不销毁 store。
|
|
140
|
+
|
|
141
|
+
### `/proxy`
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { observable } from "@slux/proxy";
|
|
145
|
+
import { useSnapshot } from "@slux/vue/proxy";
|
|
146
|
+
|
|
147
|
+
const state = observable({ user: { name: "Alice" } });
|
|
148
|
+
const snap = useSnapshot(state); // Readonly<Ref<Snapshot<...>>>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`useSnapshot` 用 `@slux/proxy` 的 `snapshot` / `subscribe` 桥接;嵌套与深层变更都会发布新快照,快照深层只读,修改走原 proxy,订阅不按组件读取的属性筛选。
|
|
152
|
+
|
|
153
|
+
### `/flux`、`/state-machine`、`/rxjs`
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { createFluxStore } from "@slux/flux";
|
|
157
|
+
import { fromObservable } from "@slux/rxjs";
|
|
158
|
+
import { Subject } from "rxjs";
|
|
159
|
+
import { useFluxStore } from "@slux/vue/flux";
|
|
160
|
+
import { useObservable } from "@slux/vue/rxjs";
|
|
161
|
+
|
|
162
|
+
const flux = createFluxStore((state: number, action: { type: "add"; amount: number }) => state + action.amount, 0);
|
|
163
|
+
const observable = fromObservable(new Subject<number>(), 0);
|
|
164
|
+
// setup 内:
|
|
165
|
+
const fluxValue = useFluxStore(flux); // Readonly<Ref<number>>
|
|
166
|
+
const observableValue = useObservable(observable); // Readonly<Ref<number>>
|
|
167
|
+
// useMachine(machine) → Readonly<Ref<MachineSnapshot<Context, State>>>,含 value / context,写入 machine.send(event)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`useObservable` 只接收 `fromObservable(source, initialValue)` 产出的 `ObservableState<T>`,不接受原始 RxJS `Observable`;完成与错误读 `source.status` / `source.error`。组件卸载只解除自身绑定,桥接 `dispose()` 由创建者负责。
|
|
171
|
+
|
|
172
|
+
## 专属语义与边界
|
|
173
|
+
|
|
174
|
+
### SSR 与 hydration
|
|
175
|
+
|
|
176
|
+
- Vue SSR(`@vue/server-renderer`)不运行 `onMounted`,`useSignal` 只返回 `shallowRef(source.get())` 的**初始读取值**,不建立 `subscribe`、不留 core `effect`。
|
|
177
|
+
- 该初始值是**全局值**,不是 Scope 覆盖值:`useSignal` 不读取 `useScope()`。需要请求级覆盖时显式 `useScope()?.get(source)` 取值,并为客户端准备相同的初始数据。
|
|
178
|
+
- 全部子入口经 `useSignal` 桥接,SSR 行为一致:读各自来源当前值(store 用 `getState()`、proxy 用 `snapshot()`)、不创建消费订阅。独立 `effectScope` 不属于 SSR 组件生命周期,调用方需 `stop()`。
|
|
179
|
+
|
|
180
|
+
### 订阅与清理
|
|
181
|
+
|
|
182
|
+
- 组件内订阅在 `onMounted` 启动、`onScopeDispose` 在卸载时释放;独立 effectScope 立即启动、由 `scope.stop()` 释放。清理同时退订 `source.subscribe` 与 core `effect`,不销毁原状态实例。
|
|
183
|
+
- `shallowReadonly` 只做浅层只读:ref 本身不可赋值,快照对象是否冻结由来源决定。绑定不捕获异常,`source.get()` 抛错会在初始化或 `effect` 求值时向上传播,订阅与 `effect` 错误沿用 `@slux/core` 的同步执行与错误汇总语义。
|
|
184
|
+
|
|
185
|
+
### Scope 显式覆盖契约
|
|
186
|
+
|
|
187
|
+
`scope.set()` 不触发全局订阅,`runInScope()` 不改写全局 signal 读写,computed 不会在 Scope 内自动重算;这些沿用 core 契约,见根 README 通用约定。本包 Scope 封装只负责 provide / inject 上下文,绑定本身不自动应用覆盖值。
|
|
188
|
+
|
|
189
|
+
## 自动导入
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
import AutoImport from "unplugin-auto-import/vite";
|
|
193
|
+
import { createAutoImportApis } from "@slux/vue";
|
|
194
|
+
|
|
195
|
+
export default { plugins: [AutoImport({ imports: [createAutoImportApis()] })] };
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
`createAutoImportApis(prefix?)` 返回 `unplugin-auto-import` 的 `ImportsMap`,来源名 `@slux/vue`。`src/auto-import-api.ts` 当前登记:`ScopeProvider`、`provideScope`、`sluxPlugin`、`useScope`、`useSignal`、`useStore`(仅主入口 API,**不含** `createAutoImportApis` 自身与各子入口绑定)。传入前缀时按 `@slux/shared` 的 `createAutoImports` 规则生成别名。
|
|
199
|
+
|
|
200
|
+
## 类型导出
|
|
201
|
+
|
|
202
|
+
主入口只导出一个类型:`SluxPluginOptions`(`src/scope.ts`)=`{ readonly scope?: Scope }`。六个子入口只导出运行时函数,不额外导出类型。`Ref` 来自 `vue`,`Subscribable` / `Scope` 来自 `@slux/core`,`Snapshot` 来自 `@slux/proxy`,`FluxStore` / `MachineSnapshot` / `ObservableState` 来自各自范式包,均按包名从原包导入。
|
|
203
|
+
|
|
204
|
+
## 不适用的场景
|
|
205
|
+
|
|
206
|
+
- 在 Options API、`setup()` 之外,或事件处理器 / 异步回调中调用读取函数:会抛错,需在 setup 或 `effectScope.run()` 内调用。
|
|
207
|
+
- 期望绑定自动套用 Scope 覆盖值、把覆盖写回全局,或 SSR 自动序列化 / 恢复请求状态:绑定只读全局来源,需调用方自行准备客户端初始数据与 Scope,见根 README 通用约定。
|
|
208
|
+
- 需要脱离 Vue 生命周期的长期订阅:直接用 `@slux/core` 的 `effect`。
|
|
209
|
+
|
|
210
|
+
## 版本、许可与反馈
|
|
211
|
+
|
|
212
|
+
- 版本:`0.1.0`(`package.json`)。
|
|
213
|
+
- 许可:[MIT](../../LICENSE) © itmanyong。
|
|
214
|
+
- 仓库:`github.com/itmanyong/slux`(`packages/vue`)。
|
|
215
|
+
- 问题反馈:`https://github.com/itmanyong/slux/issues`。
|
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_vue_namespaceObject=require("vue"),core_namespaceObject=require("@slux/core");function useSignal(e){let _;if(!(0,external_vue_namespaceObject.getCurrentScope)())throw Error("useSignal 必须在 Vue setup 或 effectScope 中调用");let t=(0,external_vue_namespaceObject.shallowRef)(e.get()),r=()=>{let _=e.subscribe(e=>{t.value=e}),r=(0,core_namespaceObject.effect)(()=>{e.get()});return t.value=e.get(),()=>{_(),r()}};return(0,external_vue_namespaceObject.getCurrentInstance)()?(0,external_vue_namespaceObject.onMounted)(()=>{_=r()}):_=r(),(0,external_vue_namespaceObject.onScopeDispose)(()=>_?.()),(0,external_vue_namespaceObject.shallowReadonly)(t)}function useAtomValue(e){return useSignal(e)}function useSetAtom(e){return _=>e.set(_)}function useAtom(e){return[useAtomValue(e),useSetAtom(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/use-signal.ts","../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 { getCurrentInstance, getCurrentScope, onMounted, onScopeDispose, shallowReadonly, shallowRef } from \"vue\";\nimport type { Ref } from \"vue\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\n\nexport function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>> {\n if (!getCurrentScope()) throw new Error(\"useSignal 必须在 Vue setup 或 effectScope 中调用\");\n const value = shallowRef<T>(source.get());\n const start = () => {\n const unsubscribe = source.subscribe((next) => {\n value.value = next;\n });\n // computed 需要主动求值;真正的通知仍走 subscribe,兼容外部 Subscribable。\n const dispose = effect(() => {\n source.get();\n });\n value.value = source.get();\n return () => {\n unsubscribe();\n dispose();\n };\n };\n let stop: (() => void) | undefined;\n // SSR 不执行 mounted,避免为一次性服务端渲染留下订阅。\n if (getCurrentInstance())\n onMounted(() => {\n stop = start();\n });\n else stop = start();\n onScopeDispose(() => stop?.());\n return shallowReadonly(value);\n}\n","import type { Ref } from \"vue\";\nimport type { AnyReadableAtom, Atom } from \"@slux/atom\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useAtomValue<T>(atom: AnyReadableAtom<T>): Readonly<Ref<T>> {\n return useSignal(atom);\n}\nexport function useSetAtom<T>(atom: Atom<T>): (value: T) => void {\n return (value) => atom.set(value);\n}\nexport function useAtom<T>(atom: Atom<T>): [Readonly<Ref<T>>, (value: T) => void] {\n return [useAtomValue(atom), useSetAtom(atom)];\n}\n"],"names":["__webpack_require__","e","Object","Symbol","useSignal","source","stop","getCurrentScope","Error","value","shallowRef","start","unsubscribe","next","dispose","effect","getCurrentInstance","onMounted","onScopeDispose","shallowReadonly","useAtomValue","atom","useSetAtom","useAtom"],"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,4RCDO,SAASG,UAAaC,CAAuB,MAiB9CC,EAhBJ,GAAI,CAACC,AAAAA,GAAAA,6BAAAA,eAAAA,AAAAA,IAAmB,MAAM,AAAIC,MAAM,6CACxC,IAAMC,EAAQC,AAAAA,GAAAA,6BAAAA,UAAAA,AAAAA,EAAcL,EAAO,GAAG,IAChCM,EAAQ,KACZ,IAAMC,EAAcP,EAAO,SAAS,CAAC,AAACQ,IACpCJ,EAAM,KAAK,CAAGI,CAChB,GAEMC,EAAUC,AAAAA,GAAAA,qBAAAA,MAAAA,AAAAA,EAAO,KACrBV,EAAO,GAAG,EACZ,GAEA,OADAI,EAAM,KAAK,CAAGJ,EAAO,GAAG,GACjB,KACLO,IACAE,GACF,CACF,EASA,MANIE,AAAAA,GAAAA,6BAAAA,kBAAAA,AAAAA,IACFC,AAAAA,GAAAA,6BAAAA,SAAAA,AAAAA,EAAU,KACRX,EAAOK,GACT,GACGL,EAAOK,IACZO,AAAAA,GAAAA,6BAAAA,cAAAA,AAAAA,EAAe,IAAMZ,OACda,AAAAA,GAAAA,6BAAAA,eAAAA,AAAAA,EAAgBV,EACzB,CC3BO,SAASW,aAAgBC,CAAwB,EACtD,OAAOjB,UAAUiB,EACnB,CACO,SAASC,WAAcD,CAAa,EACzC,OAAO,AAACZ,GAAUY,EAAK,GAAG,CAACZ,EAC7B,CACO,SAASc,QAAWF,CAAa,EACtC,MAAO,CAACD,aAAaC,GAAOC,WAAWD,GAAM,AAC/C,C"}
|
package/dist/atom.d.cts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AnyReadableAtom } from '@slux/atom';
|
|
2
|
+
import type { Atom } from '@slux/atom';
|
|
3
|
+
import type { Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
export declare function useAtom<T>(atom: Atom<T>): [Readonly<Ref<T>>, (value: T) => void];
|
|
6
|
+
|
|
7
|
+
export declare function useAtomValue<T>(atom: AnyReadableAtom<T>): Readonly<Ref<T>>;
|
|
8
|
+
|
|
9
|
+
export declare function useSetAtom<T>(atom: Atom<T>): (value: T) => void;
|
|
10
|
+
|
|
11
|
+
export { }
|
package/dist/atom.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AnyReadableAtom } from '@slux/atom';
|
|
2
|
+
import type { Atom } from '@slux/atom';
|
|
3
|
+
import type { Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
export declare function useAtom<T>(atom: Atom<T>): [Readonly<Ref<T>>, (value: T) => void];
|
|
6
|
+
|
|
7
|
+
export declare function useAtomValue<T>(atom: AnyReadableAtom<T>): Readonly<Ref<T>>;
|
|
8
|
+
|
|
9
|
+
export declare function useSetAtom<T>(atom: Atom<T>): (value: T) => void;
|
|
10
|
+
|
|
11
|
+
export { }
|
package/dist/atom.js
ADDED
package/dist/atom.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atom.js","sources":["../src/atom.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport type { AnyReadableAtom, Atom } from \"@slux/atom\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useAtomValue<T>(atom: AnyReadableAtom<T>): Readonly<Ref<T>> {\n return useSignal(atom);\n}\nexport function useSetAtom<T>(atom: Atom<T>): (value: T) => void {\n return (value) => atom.set(value);\n}\nexport function useAtom<T>(atom: Atom<T>): [Readonly<Ref<T>>, (value: T) => void] {\n return [useAtomValue(atom), useSetAtom(atom)];\n}\n"],"names":["useAtomValue","atom","useSignal","useSetAtom","value","useAtom"],"mappings":"iDAIO,SAASA,EAAgBC,CAAwB,EACtD,OAAOC,EAAUD,EACnB,CACO,SAASE,EAAcF,CAAa,EACzC,OAAO,AAACG,GAAUH,EAAK,GAAG,CAACG,EAC7B,CACO,SAASC,EAAWJ,CAAa,EACtC,MAAO,CAACD,EAAaC,GAAOE,EAAWF,GAAM,AAC/C,Q"}
|
package/dist/e~0.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getCurrentInstance as e,getCurrentScope as r,onMounted as t,onScopeDispose as u,shallowReadonly as o,shallowRef as l}from"vue";import{effect as i}from"@slux/core";function f(f){let n;if(!r())throw Error("useSignal 必须在 Vue setup 或 effectScope 中调用");let s=l(f.get()),c=()=>{let e=f.subscribe(e=>{s.value=e}),r=i(()=>{f.get()});return s.value=f.get(),()=>{e(),r()}};return e()?t(()=>{n=c()}):n=c(),u(()=>n?.()),o(s)}export{f as useSignal};
|
|
2
|
+
//# sourceMappingURL=e~0.js.map
|
package/dist/e~0.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e~0.js","sources":["../src/use-signal.ts"],"sourcesContent":["import { getCurrentInstance, getCurrentScope, onMounted, onScopeDispose, shallowReadonly, shallowRef } from \"vue\";\nimport type { Ref } from \"vue\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\n\nexport function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>> {\n if (!getCurrentScope()) throw new Error(\"useSignal 必须在 Vue setup 或 effectScope 中调用\");\n const value = shallowRef<T>(source.get());\n const start = () => {\n const unsubscribe = source.subscribe((next) => {\n value.value = next;\n });\n // computed 需要主动求值;真正的通知仍走 subscribe,兼容外部 Subscribable。\n const dispose = effect(() => {\n source.get();\n });\n value.value = source.get();\n return () => {\n unsubscribe();\n dispose();\n };\n };\n let stop: (() => void) | undefined;\n // SSR 不执行 mounted,避免为一次性服务端渲染留下订阅。\n if (getCurrentInstance())\n onMounted(() => {\n stop = start();\n });\n else stop = start();\n onScopeDispose(() => stop?.());\n return shallowReadonly(value);\n}\n"],"names":["useSignal","source","stop","getCurrentScope","Error","value","shallowRef","start","unsubscribe","next","dispose","effect","getCurrentInstance","onMounted","onScopeDispose","shallowReadonly"],"mappings":"0KAKO,SAASA,EAAaC,CAAuB,MAiB9CC,EAhBJ,GAAI,CAACC,IAAmB,MAAM,AAAIC,MAAM,6CACxC,IAAMC,EAAQC,EAAcL,EAAO,GAAG,IAChCM,EAAQ,KACZ,IAAMC,EAAcP,EAAO,SAAS,CAAC,AAACQ,IACpCJ,EAAM,KAAK,CAAGI,CAChB,GAEMC,EAAUC,EAAO,KACrBV,EAAO,GAAG,EACZ,GAEA,OADAI,EAAM,KAAK,CAAGJ,EAAO,GAAG,GACjB,KACLO,IACAE,GACF,CACF,EASA,OANIE,IACFC,EAAU,KACRX,EAAOK,GACT,GACGL,EAAOK,IACZO,EAAe,IAAMZ,OACda,EAAgBV,EACzB,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 _)__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__,{useFluxStore:()=>useFluxStore});const external_vue_namespaceObject=require("vue"),core_namespaceObject=require("@slux/core");function useSignal(e){let _;if(!(0,external_vue_namespaceObject.getCurrentScope)())throw Error("useSignal 必须在 Vue setup 或 effectScope 中调用");let r=(0,external_vue_namespaceObject.shallowRef)(e.get()),t=()=>{let _=e.subscribe(e=>{r.value=e}),t=(0,core_namespaceObject.effect)(()=>{e.get()});return r.value=e.get(),()=>{_(),t()}};return(0,external_vue_namespaceObject.getCurrentInstance)()?(0,external_vue_namespaceObject.onMounted)(()=>{_=t()}):_=t(),(0,external_vue_namespaceObject.onScopeDispose)(()=>_?.()),(0,external_vue_namespaceObject.shallowReadonly)(r)}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/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 { getCurrentInstance, getCurrentScope, onMounted, onScopeDispose, shallowReadonly, shallowRef } from \"vue\";\nimport type { Ref } from \"vue\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\n\nexport function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>> {\n if (!getCurrentScope()) throw new Error(\"useSignal 必须在 Vue setup 或 effectScope 中调用\");\n const value = shallowRef<T>(source.get());\n const start = () => {\n const unsubscribe = source.subscribe((next) => {\n value.value = next;\n });\n // computed 需要主动求值;真正的通知仍走 subscribe,兼容外部 Subscribable。\n const dispose = effect(() => {\n source.get();\n });\n value.value = source.get();\n return () => {\n unsubscribe();\n dispose();\n };\n };\n let stop: (() => void) | undefined;\n // SSR 不执行 mounted,避免为一次性服务端渲染留下订阅。\n if (getCurrentInstance())\n onMounted(() => {\n stop = start();\n });\n else stop = start();\n onScopeDispose(() => stop?.());\n return shallowReadonly(value);\n}\n","import type { Ref } from \"vue\";\nimport type { FluxAction, FluxStore } from \"@slux/flux\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useFluxStore<State, Action extends FluxAction>(store: FluxStore<State, Action>): Readonly<Ref<State>> {\n return useSignal(store);\n}\n"],"names":["__webpack_require__","e","Object","Symbol","useSignal","source","stop","getCurrentScope","Error","value","shallowRef","start","unsubscribe","next","dispose","effect","getCurrentInstance","onMounted","onScopeDispose","shallowReadonly","useFluxStore","store"],"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,8OCDO,SAASG,UAAaC,CAAuB,MAiB9CC,EAhBJ,GAAI,CAACC,AAAAA,GAAAA,6BAAAA,eAAAA,AAAAA,IAAmB,MAAM,AAAIC,MAAM,6CACxC,IAAMC,EAAQC,AAAAA,GAAAA,6BAAAA,UAAAA,AAAAA,EAAcL,EAAO,GAAG,IAChCM,EAAQ,KACZ,IAAMC,EAAcP,EAAO,SAAS,CAAC,AAACQ,IACpCJ,EAAM,KAAK,CAAGI,CAChB,GAEMC,EAAUC,AAAAA,GAAAA,qBAAAA,MAAAA,AAAAA,EAAO,KACrBV,EAAO,GAAG,EACZ,GAEA,OADAI,EAAM,KAAK,CAAGJ,EAAO,GAAG,GACjB,KACLO,IACAE,GACF,CACF,EASA,MANIE,AAAAA,GAAAA,6BAAAA,kBAAAA,AAAAA,IACFC,AAAAA,GAAAA,6BAAAA,SAAAA,AAAAA,EAAU,KACRX,EAAOK,GACT,GACGL,EAAOK,IACZO,AAAAA,GAAAA,6BAAAA,cAAAA,AAAAA,EAAe,IAAMZ,OACda,AAAAA,GAAAA,6BAAAA,eAAAA,AAAAA,EAAgBV,EACzB,CC3BO,SAASW,aAA+CC,CAA+B,EAC5F,OAAOjB,UAAUiB,EACnB,C"}
|
package/dist/flux.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FluxAction } from '@slux/flux';
|
|
2
|
+
import type { FluxStore } from '@slux/flux';
|
|
3
|
+
import type { Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
export declare function useFluxStore<State, Action extends FluxAction>(store: FluxStore<State, Action>): Readonly<Ref<State>>;
|
|
6
|
+
|
|
7
|
+
export { }
|
package/dist/flux.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FluxAction } from '@slux/flux';
|
|
2
|
+
import type { FluxStore } from '@slux/flux';
|
|
3
|
+
import type { Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
export declare function useFluxStore<State, Action extends FluxAction>(store: FluxStore<State, Action>): Readonly<Ref<State>>;
|
|
6
|
+
|
|
7
|
+
export { }
|
package/dist/flux.js
ADDED
package/dist/flux.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flux.js","sources":["../src/flux.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport type { FluxAction, FluxStore } from \"@slux/flux\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useFluxStore<State, Action extends FluxAction>(store: FluxStore<State, Action>): Readonly<Ref<State>> {\n return useSignal(store);\n}\n"],"names":["useFluxStore","store","useSignal"],"mappings":"iDAIO,SAASA,EAA+CC,CAA+B,EAC5F,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_modules__={D(e,_,r){var o=r("o");r.d(_,{},{useStore:function(e,_,r=Object.is){let t=_??(e=>e),p=t(e.getState()),u=()=>{let _=t(e.getState());return r(p,_)||(p=_),p};return(0,o.U)({get:u,subscribe:_=>e.subscribe(()=>_(u()))})}})},o(e,_,r){var o=r("B"),t=r("g");r.d(_,{},{U:function(e){let _;if(!(0,o.getCurrentScope)())throw Error("useSignal 必须在 Vue setup 或 effectScope 中调用");let r=(0,o.shallowRef)(e.get()),p=()=>{let _=e.subscribe(e=>{r.value=e}),o=(0,t.effect)(()=>{e.get()});return r.value=e.get(),()=>{_(),o()}};return(0,o.getCurrentInstance)()?(0,o.onMounted)(()=>{_=p()}):_=p(),(0,o.onScopeDispose)(()=>_?.()),(0,o.shallowReadonly)(r)}})},g(e){e.exports=require("@slux/core")},B(e){e.exports=require("vue")}},__webpack_module_cache__={};function __webpack_require__(e){var _=__webpack_module_cache__[e];if(void 0!==_)return _.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var _=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(_,{a:_}),_},__webpack_require__.d=(e,_,r)=>{var o=(_,r)=>{for(var o in _)__webpack_require__.o(_,o)&&!__webpack_require__.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,[r]:_[o]})};o(_,"get"),o(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__={};for(var __rspack_i in(()=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ScopeProvider:()=>u,createAutoImportApis:()=>i,provideScope:()=>t,sluxPlugin:()=>c,useScope:()=>p,useSignal:()=>e.U,useStore:()=>_.useStore});var e=__webpack_require__("o"),_=__webpack_require__("D"),r=__webpack_require__("B");let o=Symbol("slux-scope");function t(e){(0,r.provide)(o,e)}function p(){return(0,r.inject)(o,void 0)}let u=(0,r.defineComponent)({name:"SluxScopeProvider",props:{scope:{type:Object,required:!0}},setup:(e,{slots:_})=>(t(e.scope),()=>_.default?.())}),c={install(e,_){_?.scope&&e.provide(o,_.scope)}},s=require("@slux/shared"),a=["ScopeProvider","provideScope","sluxPlugin","useScope","useSignal","useStore"],i=(e="")=>(0,s.generateBatchAutoImports)([{prefix:e,fromName:"@slux/vue",imports:a}])})(),exports.ScopeProvider=__webpack_exports__.ScopeProvider,exports.createAutoImportApis=__webpack_exports__.createAutoImportApis,exports.provideScope=__webpack_exports__.provideScope,exports.sluxPlugin=__webpack_exports__.sluxPlugin,exports.useScope=__webpack_exports__.useScope,exports.useSignal=__webpack_exports__.useSignal,exports.useStore=__webpack_exports__.useStore,__webpack_exports__)-1===["ScopeProvider","createAutoImportApis","provideScope","sluxPlugin","useScope","useSignal","useStore"].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":["../src/store.ts","../src/use-signal.ts","webpack://webpack/runtime/compat_get_default_export","webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/scope.ts","../src/auto-import-api.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport type { StoreApi } from \"@slux/store\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useStore<T>(store: StoreApi<T>): Readonly<Ref<T>>;\nexport function useStore<T, U>(store: StoreApi<T>, selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Readonly<Ref<U>>;\nexport function useStore<T, U = T>(\n store: StoreApi<T>,\n selector?: (state: T) => U,\n equals: (a: U, b: U) => boolean = Object.is,\n): Readonly<Ref<U>> {\n const select = selector ?? ((state: T) => state as unknown as U);\n let current = select(store.getState());\n const read = () => {\n const next = select(store.getState());\n if (!equals(current, next)) current = next;\n return current;\n };\n return useSignal({\n get: read,\n subscribe: (callback) => store.subscribe(() => callback(read())),\n });\n}\n","import { getCurrentInstance, getCurrentScope, onMounted, onScopeDispose, shallowReadonly, shallowRef } from \"vue\";\nimport type { Ref } from \"vue\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\n\nexport function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>> {\n if (!getCurrentScope()) throw new Error(\"useSignal 必须在 Vue setup 或 effectScope 中调用\");\n const value = shallowRef<T>(source.get());\n const start = () => {\n const unsubscribe = source.subscribe((next) => {\n value.value = next;\n });\n // computed 需要主动求值;真正的通知仍走 subscribe,兼容外部 Subscribable。\n const dispose = effect(() => {\n source.get();\n });\n value.value = source.get();\n return () => {\n unsubscribe();\n dispose();\n };\n };\n let stop: (() => void) | undefined;\n // SSR 不执行 mounted,避免为一次性服务端渲染留下订阅。\n if (getCurrentInstance())\n onMounted(() => {\n stop = start();\n });\n else stop = start();\n onScopeDispose(() => stop?.());\n return shallowReadonly(value);\n}\n","// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__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 { defineComponent, inject, provide } from \"vue\";\nimport type { InjectionKey, Plugin, PropType } from \"vue\";\nimport type { Scope } from \"@slux/core\";\n\nconst SCOPE_KEY: InjectionKey<Scope> = Symbol(\"slux-scope\");\nexport type SluxPluginOptions = { readonly scope?: Scope };\n\nexport function provideScope(scope: Scope): void {\n provide(SCOPE_KEY, scope);\n}\nexport function useScope(): Scope | undefined {\n return inject(SCOPE_KEY, undefined);\n}\nexport const ScopeProvider = defineComponent({\n name: \"SluxScopeProvider\",\n props: { scope: { type: Object as PropType<Scope>, required: true } },\n setup(props, { slots }) {\n provideScope(props.scope);\n return () => slots[\"default\"]?.();\n },\n});\nexport const sluxPlugin: Plugin<[SluxPluginOptions] | []> = {\n install(app, options) {\n if (options?.scope) app.provide(SCOPE_KEY, options.scope);\n },\n};\n","import { generateBatchAutoImports } from \"@slux/shared\";\n\nconst allImportApis: string[] = [\"ScopeProvider\", \"provideScope\", \"sluxPlugin\", \"useScope\", \"useSignal\", \"useStore\"];\n\nexport const createAutoImportApis = (prefix: string = \"\") => {\n return generateBatchAutoImports([\n {\n prefix,\n fromName: \"@slux/vue\",\n imports: allImportApis,\n },\n ]);\n};\n"],"names":["store","selector","equals","Object","select","state","current","read","next","useSignal","callback","source","stop","getCurrentScope","Error","value","shallowRef","start","unsubscribe","dispose","effect","getCurrentInstance","onMounted","onScopeDispose","shallowReadonly","__webpack_require__","e","Symbol","SCOPE_KEY","provideScope","scope","provide","useScope","inject","undefined","ScopeProvider","defineComponent","props","slots","sluxPlugin","app","options","allImportApis","createAutoImportApis","prefix","generateBatchAutoImports"],"mappings":"gSAMO,SACLA,CAAkB,CAClBC,CAA0B,CAC1BC,EAAkCC,OAAO,EAAE,EAE3C,IAAMC,EAASH,GAAc,CAAAI,GAAaA,CAAI,EAC1CC,EAAUF,EAAOJ,EAAM,QAAQ,IAC7BO,EAAO,KACX,IAAMC,EAAOJ,EAAOJ,EAAM,QAAQ,IAElC,OADI,AAACE,EAAOI,EAASE,IAAOF,CAAAA,EAAUE,CAAG,EAClCF,CACT,EACA,MAAOG,AAAAA,GAAAA,EAAAA,CAAAA,AAAAA,EAAU,CACf,IAAKF,EACL,UAAW,AAACG,GAAaV,EAAM,SAAS,CAAC,IAAMU,EAASH,KAC1D,EACF,C,+CCjBO,SAAsBI,CAAuB,MAiB9CC,EAhBJ,GAAI,CAACC,AAAAA,GAAAA,EAAAA,eAAAA,AAAAA,IAAmB,MAAM,AAAIC,MAAM,6CACxC,IAAMC,EAAQC,AAAAA,GAAAA,EAAAA,UAAAA,AAAAA,EAAcL,EAAO,GAAG,IAChCM,EAAQ,KACZ,IAAMC,EAAcP,EAAO,SAAS,CAAC,AAACH,IACpCO,EAAM,KAAK,CAAGP,CAChB,GAEMW,EAAUC,AAAAA,GAAAA,EAAAA,MAAAA,AAAAA,EAAO,KACrBT,EAAO,GAAG,EACZ,GAEA,OADAI,EAAM,KAAK,CAAGJ,EAAO,GAAG,GACjB,KACLO,IACAC,GACF,CACF,EASA,MANIE,AAAAA,GAAAA,EAAAA,kBAAAA,AAAAA,IACFC,AAAAA,GAAAA,EAAAA,SAAAA,AAAAA,EAAU,KACRV,EAAOK,GACT,GACGL,EAAOK,IACZM,AAAAA,GAAAA,EAAAA,cAAAA,AAAAA,EAAe,IAAMX,OACdY,AAAAA,GAAAA,EAAAA,eAAAA,AAAAA,EAAgBT,EACzB,C,+TC9BAU,oBAAoB,CAAC,CAAG,AAAC,IACxB,IAAI,EAAS,GAAU,EAAO,UAAU,CACvC,IAAO,EAAO,OAAU,CACxB,IAAO,EAER,OADAA,oBAAoB,CAAC,CAAC,EAAQ,CAAE,EAAG,CAAO,GACnC,CACR,ECPAA,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,IACtEvB,OAAO,cAAc,CAACuB,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,IAAUtB,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAK,GCClFsB,oBAAoB,CAAC,CAAG,AAACC,IACrB,AAAkB,IAAlB,OAAOC,QAA0BA,OAAO,WAAW,EACrDxB,OAAO,cAAc,CAACuB,EAASC,OAAO,WAAW,CAAE,CAAE,MAAO,QAAS,GAEtExB,OAAO,cAAc,CAACuB,EAAS,aAAc,CAAE,MAAO,EAAK,EAC5D,E,+WCFA,IAAME,EAAiCD,OAAO,cAGvC,SAASE,EAAaC,CAAY,EACvCC,AAAAA,GAAAA,EAAAA,OAAAA,AAAAA,EAAQH,EAAWE,EACrB,CACO,SAASE,IACd,MAAOC,AAAAA,GAAAA,EAAAA,MAAAA,AAAAA,EAAOL,EAAWM,OAC3B,CACO,IAAMC,EAAgBC,AAAAA,GAAAA,EAAAA,eAAAA,AAAAA,EAAgB,CAC3C,KAAM,oBACN,MAAO,CAAE,MAAO,CAAE,KAAMjC,OAA2B,SAAU,EAAK,CAAE,EACpE,OAAMkC,EAAO,CAAEC,MAAAA,CAAK,CAAE,IACpBT,EAAaQ,EAAM,KAAK,EACjB,IAAMC,EAAM,OAAU,KAEjC,GACaC,EAA+C,CAC1D,QAAQC,CAAG,CAAEC,CAAO,EACdA,GAAS,OAAOD,EAAI,OAAO,CAACZ,EAAWa,EAAQ,KAAK,CAC1D,CACF,E,0BCvBMC,EAA0B,CAAC,gBAAiB,eAAgB,aAAc,WAAY,YAAa,WAAW,CAEvGC,EAAuB,CAACC,EAAiB,EAAE,GAC/CC,AAAAA,GAAAA,EAAAA,wBAAAA,AAAAA,EAAyB,CAC9B,CACED,OAAAA,EACA,SAAU,YACV,QAASF,CACX,EACD,C"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
2
|
+
import { ComponentProvideOptions } from 'vue';
|
|
3
|
+
import { DefineComponent } from 'vue';
|
|
4
|
+
import { ExtractPropTypes } from 'vue';
|
|
5
|
+
import type { Plugin as Plugin_2 } from 'vue';
|
|
6
|
+
import type { PropType } from 'vue';
|
|
7
|
+
import { PublicProps } from 'vue';
|
|
8
|
+
import type { Ref } from 'vue';
|
|
9
|
+
import { RendererElement } from 'vue';
|
|
10
|
+
import { RendererNode } from 'vue';
|
|
11
|
+
import type { Scope } from '@slux/core';
|
|
12
|
+
import type { StoreApi } from '@slux/store';
|
|
13
|
+
import type { Subscribable } from '@slux/core';
|
|
14
|
+
import { VNode } from 'vue';
|
|
15
|
+
|
|
16
|
+
export declare const createAutoImportApis: (prefix?: string) => {
|
|
17
|
+
[x: string]: (string | [string, string])[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export declare function provideScope(scope: Scope): void;
|
|
21
|
+
|
|
22
|
+
export declare const ScopeProvider: DefineComponent<ExtractPropTypes< {
|
|
23
|
+
scope: {
|
|
24
|
+
type: PropType<Scope>;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
27
|
+
}>, () => VNode<RendererNode, RendererElement, {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}>[] | undefined, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
|
|
30
|
+
scope: {
|
|
31
|
+
type: PropType<Scope>;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
35
|
+
|
|
36
|
+
export declare const sluxPlugin: Plugin_2<[SluxPluginOptions] | []>;
|
|
37
|
+
|
|
38
|
+
export declare type SluxPluginOptions = {
|
|
39
|
+
readonly scope?: Scope;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export declare function useScope(): Scope | undefined;
|
|
43
|
+
|
|
44
|
+
export declare function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>>;
|
|
45
|
+
|
|
46
|
+
export declare function useStore<T>(store: StoreApi<T>): Readonly<Ref<T>>;
|
|
47
|
+
|
|
48
|
+
export declare function useStore<T, U>(store: StoreApi<T>, selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Readonly<Ref<U>>;
|
|
49
|
+
|
|
50
|
+
export { }
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
2
|
+
import { ComponentProvideOptions } from 'vue';
|
|
3
|
+
import { DefineComponent } from 'vue';
|
|
4
|
+
import { ExtractPropTypes } from 'vue';
|
|
5
|
+
import type { Plugin as Plugin_2 } from 'vue';
|
|
6
|
+
import type { PropType } from 'vue';
|
|
7
|
+
import { PublicProps } from 'vue';
|
|
8
|
+
import type { Ref } from 'vue';
|
|
9
|
+
import { RendererElement } from 'vue';
|
|
10
|
+
import { RendererNode } from 'vue';
|
|
11
|
+
import type { Scope } from '@slux/core';
|
|
12
|
+
import type { StoreApi } from '@slux/store';
|
|
13
|
+
import type { Subscribable } from '@slux/core';
|
|
14
|
+
import { VNode } from 'vue';
|
|
15
|
+
|
|
16
|
+
export declare const createAutoImportApis: (prefix?: string) => {
|
|
17
|
+
[x: string]: (string | [string, string])[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export declare function provideScope(scope: Scope): void;
|
|
21
|
+
|
|
22
|
+
export declare const ScopeProvider: DefineComponent<ExtractPropTypes< {
|
|
23
|
+
scope: {
|
|
24
|
+
type: PropType<Scope>;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
27
|
+
}>, () => VNode<RendererNode, RendererElement, {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}>[] | undefined, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
|
|
30
|
+
scope: {
|
|
31
|
+
type: PropType<Scope>;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
35
|
+
|
|
36
|
+
export declare const sluxPlugin: Plugin_2<[SluxPluginOptions] | []>;
|
|
37
|
+
|
|
38
|
+
export declare type SluxPluginOptions = {
|
|
39
|
+
readonly scope?: Scope;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export declare function useScope(): Scope | undefined;
|
|
43
|
+
|
|
44
|
+
export declare function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>>;
|
|
45
|
+
|
|
46
|
+
export declare function useStore<T>(store: StoreApi<T>): Readonly<Ref<T>>;
|
|
47
|
+
|
|
48
|
+
export declare function useStore<T, U>(store: StoreApi<T>, selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Readonly<Ref<U>>;
|
|
49
|
+
|
|
50
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{defineComponent as e,inject as o,provide as r}from"vue";import{generateBatchAutoImports as p}from"@slux/shared";let u=Symbol("slux-scope");function s(e){r(u,e)}function t(){return o(u,void 0)}let i=e({name:"SluxScopeProvider",props:{scope:{type:Object,required:!0}},setup:(e,{slots:o})=>(s(e.scope),()=>o.default?.())}),S={install(e,o){o?.scope&&e.provide(u,o.scope)}},c=["ScopeProvider","provideScope","sluxPlugin","useScope","useSignal","useStore"],l=(e="")=>p([{prefix:e,fromName:"@slux/vue",imports:c}]);export{useSignal}from"./e~0.js";export{useStore}from"./store.js";export{i as ScopeProvider,l as createAutoImportApis,s as provideScope,S as sluxPlugin,t as useScope};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/scope.ts","../src/auto-import-api.ts"],"sourcesContent":["import { defineComponent, inject, provide } from \"vue\";\nimport type { InjectionKey, Plugin, PropType } from \"vue\";\nimport type { Scope } from \"@slux/core\";\n\nconst SCOPE_KEY: InjectionKey<Scope> = Symbol(\"slux-scope\");\nexport type SluxPluginOptions = { readonly scope?: Scope };\n\nexport function provideScope(scope: Scope): void {\n provide(SCOPE_KEY, scope);\n}\nexport function useScope(): Scope | undefined {\n return inject(SCOPE_KEY, undefined);\n}\nexport const ScopeProvider = defineComponent({\n name: \"SluxScopeProvider\",\n props: { scope: { type: Object as PropType<Scope>, required: true } },\n setup(props, { slots }) {\n provideScope(props.scope);\n return () => slots[\"default\"]?.();\n },\n});\nexport const sluxPlugin: Plugin<[SluxPluginOptions] | []> = {\n install(app, options) {\n if (options?.scope) app.provide(SCOPE_KEY, options.scope);\n },\n};\n","import { generateBatchAutoImports } from \"@slux/shared\";\n\nconst allImportApis: string[] = [\"ScopeProvider\", \"provideScope\", \"sluxPlugin\", \"useScope\", \"useSignal\", \"useStore\"];\n\nexport const createAutoImportApis = (prefix: string = \"\") => {\n return generateBatchAutoImports([\n {\n prefix,\n fromName: \"@slux/vue\",\n imports: allImportApis,\n },\n ]);\n};\n"],"names":["SCOPE_KEY","Symbol","provideScope","scope","provide","useScope","inject","undefined","ScopeProvider","defineComponent","Object","props","slots","sluxPlugin","app","options","allImportApis","createAutoImportApis","prefix","generateBatchAutoImports"],"mappings":"uHAIA,IAAMA,EAAiCC,OAAO,cAGvC,SAASC,EAAaC,CAAY,EACvCC,EAAQJ,EAAWG,EACrB,CACO,SAASE,IACd,OAAOC,EAAON,EAAWO,OAC3B,CACO,IAAMC,EAAgBC,EAAgB,CAC3C,KAAM,oBACN,MAAO,CAAE,MAAO,CAAE,KAAMC,OAA2B,SAAU,EAAK,CAAE,EACpE,OAAMC,EAAO,CAAEC,MAAAA,CAAK,CAAE,IACpBV,EAAaS,EAAM,KAAK,EACjB,IAAMC,EAAM,OAAU,KAEjC,GACaC,EAA+C,CAC1D,QAAQC,CAAG,CAAEC,CAAO,EACdA,GAAS,OAAOD,EAAI,OAAO,CAACd,EAAWe,EAAQ,KAAK,CAC1D,CACF,ECvBMC,EAA0B,CAAC,gBAAiB,eAAgB,aAAc,WAAY,YAAa,WAAW,CAEvGC,EAAuB,CAACC,EAAiB,EAAE,GAC/CC,EAAyB,CAC9B,CACED,OAAAA,EACA,SAAU,YACV,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 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__,{useSnapshot:()=>useSnapshot});const proxy_namespaceObject=require("@slux/proxy"),external_vue_namespaceObject=require("vue"),core_namespaceObject=require("@slux/core");function useSignal(e){let _;if(!(0,external_vue_namespaceObject.getCurrentScope)())throw Error("useSignal 必须在 Vue setup 或 effectScope 中调用");let r=(0,external_vue_namespaceObject.shallowRef)(e.get()),t=()=>{let _=e.subscribe(e=>{r.value=e}),t=(0,core_namespaceObject.effect)(()=>{e.get()});return r.value=e.get(),()=>{_(),t()}};return(0,external_vue_namespaceObject.getCurrentInstance)()?(0,external_vue_namespaceObject.onMounted)(()=>{_=t()}):_=t(),(0,external_vue_namespaceObject.onScopeDispose)(()=>_?.()),(0,external_vue_namespaceObject.shallowReadonly)(r)}function useSnapshot(e){return useSignal({get:()=>(0,proxy_namespaceObject.snapshot)(e),subscribe:_=>(0,proxy_namespaceObject.subscribe)(e,()=>_((0,proxy_namespaceObject.snapshot)(e)))})}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/use-signal.ts","../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 { getCurrentInstance, getCurrentScope, onMounted, onScopeDispose, shallowReadonly, shallowRef } from \"vue\";\nimport type { Ref } from \"vue\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\n\nexport function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>> {\n if (!getCurrentScope()) throw new Error(\"useSignal 必须在 Vue setup 或 effectScope 中调用\");\n const value = shallowRef<T>(source.get());\n const start = () => {\n const unsubscribe = source.subscribe((next) => {\n value.value = next;\n });\n // computed 需要主动求值;真正的通知仍走 subscribe,兼容外部 Subscribable。\n const dispose = effect(() => {\n source.get();\n });\n value.value = source.get();\n return () => {\n unsubscribe();\n dispose();\n };\n };\n let stop: (() => void) | undefined;\n // SSR 不执行 mounted,避免为一次性服务端渲染留下订阅。\n if (getCurrentInstance())\n onMounted(() => {\n stop = start();\n });\n else stop = start();\n onScopeDispose(() => stop?.());\n return shallowReadonly(value);\n}\n","import type { Ref } from \"vue\";\nimport { snapshot, subscribe } from \"@slux/proxy\";\nimport type { Snapshot } from \"@slux/proxy\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useSnapshot<T extends object>(proxy: T): Readonly<Ref<Snapshot<T>>> {\n return useSignal({\n get: () => snapshot(proxy),\n subscribe: (callback) => subscribe(proxy, () => callback(snapshot(proxy))),\n });\n}\n"],"names":["__webpack_require__","e","Object","Symbol","useSignal","source","stop","getCurrentScope","Error","value","shallowRef","start","unsubscribe","next","dispose","effect","getCurrentInstance","onMounted","onScopeDispose","shallowReadonly","useSnapshot","proxy","snapshot","callback","subscribe"],"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,yRCDO,SAASG,UAAaC,CAAuB,MAiB9CC,EAhBJ,GAAI,CAACC,AAAAA,GAAAA,6BAAAA,eAAAA,AAAAA,IAAmB,MAAM,AAAIC,MAAM,6CACxC,IAAMC,EAAQC,AAAAA,GAAAA,6BAAAA,UAAAA,AAAAA,EAAcL,EAAO,GAAG,IAChCM,EAAQ,KACZ,IAAMC,EAAcP,EAAO,SAAS,CAAC,AAACQ,IACpCJ,EAAM,KAAK,CAAGI,CAChB,GAEMC,EAAUC,AAAAA,GAAAA,qBAAAA,MAAAA,AAAAA,EAAO,KACrBV,EAAO,GAAG,EACZ,GAEA,OADAI,EAAM,KAAK,CAAGJ,EAAO,GAAG,GACjB,KACLO,IACAE,GACF,CACF,EASA,MANIE,AAAAA,GAAAA,6BAAAA,kBAAAA,AAAAA,IACFC,AAAAA,GAAAA,6BAAAA,SAAAA,AAAAA,EAAU,KACRX,EAAOK,GACT,GACGL,EAAOK,IACZO,AAAAA,GAAAA,6BAAAA,cAAAA,AAAAA,EAAe,IAAMZ,OACda,AAAAA,GAAAA,6BAAAA,eAAAA,AAAAA,EAAgBV,EACzB,CC1BO,SAASW,YAA8BC,CAAQ,EACpD,OAAOjB,UAAU,CACf,IAAK,IAAMkB,AAAAA,GAAAA,sBAAAA,QAAAA,AAAAA,EAASD,GACpB,UAAW,AAACE,GAAaC,AAAAA,GAAAA,sBAAAA,SAAAA,AAAAA,EAAUH,EAAO,IAAME,EAASD,AAAAA,GAAAA,sBAAAA,QAAAA,AAAAA,EAASD,IACpE,EACF,C"}
|
package/dist/proxy.d.cts
ADDED
package/dist/proxy.d.ts
ADDED
package/dist/proxy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sources":["../src/proxy.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport { snapshot, subscribe } from \"@slux/proxy\";\nimport type { Snapshot } from \"@slux/proxy\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useSnapshot<T extends object>(proxy: T): Readonly<Ref<Snapshot<T>>> {\n return useSignal({\n get: () => snapshot(proxy),\n subscribe: (callback) => subscribe(proxy, () => callback(snapshot(proxy))),\n });\n}\n"],"names":["useSnapshot","proxy","useSignal","snapshot","callback","subscribe"],"mappings":"uGAKO,SAASA,EAA8BC,CAAQ,EACpD,OAAOC,EAAU,CACf,IAAK,IAAMC,EAASF,GACpB,UAAW,AAACG,GAAaC,EAAUJ,EAAO,IAAMG,EAASD,EAASF,IACpE,EACF,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 _)__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__,{useObservable:()=>useObservable});const external_vue_namespaceObject=require("vue"),core_namespaceObject=require("@slux/core");function useSignal(e){let _;if(!(0,external_vue_namespaceObject.getCurrentScope)())throw Error("useSignal 必须在 Vue setup 或 effectScope 中调用");let r=(0,external_vue_namespaceObject.shallowRef)(e.get()),t=()=>{let _=e.subscribe(e=>{r.value=e}),t=(0,core_namespaceObject.effect)(()=>{e.get()});return r.value=e.get(),()=>{_(),t()}};return(0,external_vue_namespaceObject.getCurrentInstance)()?(0,external_vue_namespaceObject.onMounted)(()=>{_=t()}):_=t(),(0,external_vue_namespaceObject.onScopeDispose)(()=>_?.()),(0,external_vue_namespaceObject.shallowReadonly)(r)}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/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 { getCurrentInstance, getCurrentScope, onMounted, onScopeDispose, shallowReadonly, shallowRef } from \"vue\";\nimport type { Ref } from \"vue\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\n\nexport function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>> {\n if (!getCurrentScope()) throw new Error(\"useSignal 必须在 Vue setup 或 effectScope 中调用\");\n const value = shallowRef<T>(source.get());\n const start = () => {\n const unsubscribe = source.subscribe((next) => {\n value.value = next;\n });\n // computed 需要主动求值;真正的通知仍走 subscribe,兼容外部 Subscribable。\n const dispose = effect(() => {\n source.get();\n });\n value.value = source.get();\n return () => {\n unsubscribe();\n dispose();\n };\n };\n let stop: (() => void) | undefined;\n // SSR 不执行 mounted,避免为一次性服务端渲染留下订阅。\n if (getCurrentInstance())\n onMounted(() => {\n stop = start();\n });\n else stop = start();\n onScopeDispose(() => stop?.());\n return shallowReadonly(value);\n}\n","import type { Ref } from \"vue\";\nimport type { ObservableState } from \"@slux/rxjs\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useObservable<T>(source: ObservableState<T>): Readonly<Ref<T>> {\n return useSignal(source);\n}\n"],"names":["__webpack_require__","e","Object","Symbol","useSignal","source","stop","getCurrentScope","Error","value","shallowRef","start","unsubscribe","next","dispose","effect","getCurrentInstance","onMounted","onScopeDispose","shallowReadonly","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,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,gPCDO,SAASG,UAAaC,CAAuB,MAiB9CC,EAhBJ,GAAI,CAACC,AAAAA,GAAAA,6BAAAA,eAAAA,AAAAA,IAAmB,MAAM,AAAIC,MAAM,6CACxC,IAAMC,EAAQC,AAAAA,GAAAA,6BAAAA,UAAAA,AAAAA,EAAcL,EAAO,GAAG,IAChCM,EAAQ,KACZ,IAAMC,EAAcP,EAAO,SAAS,CAAC,AAACQ,IACpCJ,EAAM,KAAK,CAAGI,CAChB,GAEMC,EAAUC,AAAAA,GAAAA,qBAAAA,MAAAA,AAAAA,EAAO,KACrBV,EAAO,GAAG,EACZ,GAEA,OADAI,EAAM,KAAK,CAAGJ,EAAO,GAAG,GACjB,KACLO,IACAE,GACF,CACF,EASA,MANIE,AAAAA,GAAAA,6BAAAA,kBAAAA,AAAAA,IACFC,AAAAA,GAAAA,6BAAAA,SAAAA,AAAAA,EAAU,KACRX,EAAOK,GACT,GACGL,EAAOK,IACZO,AAAAA,GAAAA,6BAAAA,cAAAA,AAAAA,EAAe,IAAMZ,OACda,AAAAA,GAAAA,6BAAAA,eAAAA,AAAAA,EAAgBV,EACzB,CC3BO,SAASW,cAAiBf,CAA0B,EACzD,OAAOD,UAAUC,EACnB,C"}
|
package/dist/rxjs.d.cts
ADDED
package/dist/rxjs.d.ts
ADDED
package/dist/rxjs.js
ADDED
package/dist/rxjs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rxjs.js","sources":["../src/rxjs.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport type { ObservableState } from \"@slux/rxjs\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useObservable<T>(source: ObservableState<T>): Readonly<Ref<T>> {\n return useSignal(source);\n}\n"],"names":["useObservable","source","useSignal"],"mappings":"iDAIO,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_vue_namespaceObject=require("vue"),core_namespaceObject=require("@slux/core");function useSignal(e){let _;if(!(0,external_vue_namespaceObject.getCurrentScope)())throw Error("useSignal 必须在 Vue setup 或 effectScope 中调用");let r=(0,external_vue_namespaceObject.shallowRef)(e.get()),t=()=>{let _=e.subscribe(e=>{r.value=e}),t=(0,core_namespaceObject.effect)(()=>{e.get()});return r.value=e.get(),()=>{_(),t()}};return(0,external_vue_namespaceObject.getCurrentInstance)()?(0,external_vue_namespaceObject.onMounted)(()=>{_=t()}):_=t(),(0,external_vue_namespaceObject.onScopeDispose)(()=>_?.()),(0,external_vue_namespaceObject.shallowReadonly)(r)}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/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 { getCurrentInstance, getCurrentScope, onMounted, onScopeDispose, shallowReadonly, shallowRef } from \"vue\";\nimport type { Ref } from \"vue\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\n\nexport function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>> {\n if (!getCurrentScope()) throw new Error(\"useSignal 必须在 Vue setup 或 effectScope 中调用\");\n const value = shallowRef<T>(source.get());\n const start = () => {\n const unsubscribe = source.subscribe((next) => {\n value.value = next;\n });\n // computed 需要主动求值;真正的通知仍走 subscribe,兼容外部 Subscribable。\n const dispose = effect(() => {\n source.get();\n });\n value.value = source.get();\n return () => {\n unsubscribe();\n dispose();\n };\n };\n let stop: (() => void) | undefined;\n // SSR 不执行 mounted,避免为一次性服务端渲染留下订阅。\n if (getCurrentInstance())\n onMounted(() => {\n stop = start();\n });\n else stop = start();\n onScopeDispose(() => stop?.());\n return shallowReadonly(value);\n}\n","import type { Ref } from \"vue\";\nimport type { MachineSnapshot, StateMachine } from \"@slux/state-machine\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useMachine<Context, Event extends { type: string }, State extends string>(\n machine: StateMachine<Context, Event, State>,\n): Readonly<Ref<MachineSnapshot<Context, State>>> {\n return useSignal(machine);\n}\n"],"names":["__webpack_require__","e","Object","Symbol","useSignal","source","stop","getCurrentScope","Error","value","shallowRef","start","unsubscribe","next","dispose","effect","getCurrentInstance","onMounted","onScopeDispose","shallowReadonly","useMachine","machine"],"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,0OCDO,SAASG,UAAaC,CAAuB,MAiB9CC,EAhBJ,GAAI,CAACC,AAAAA,GAAAA,6BAAAA,eAAAA,AAAAA,IAAmB,MAAM,AAAIC,MAAM,6CACxC,IAAMC,EAAQC,AAAAA,GAAAA,6BAAAA,UAAAA,AAAAA,EAAcL,EAAO,GAAG,IAChCM,EAAQ,KACZ,IAAMC,EAAcP,EAAO,SAAS,CAAC,AAACQ,IACpCJ,EAAM,KAAK,CAAGI,CAChB,GAEMC,EAAUC,AAAAA,GAAAA,qBAAAA,MAAAA,AAAAA,EAAO,KACrBV,EAAO,GAAG,EACZ,GAEA,OADAI,EAAM,KAAK,CAAGJ,EAAO,GAAG,GACjB,KACLO,IACAE,GACF,CACF,EASA,MANIE,AAAAA,GAAAA,6BAAAA,kBAAAA,AAAAA,IACFC,AAAAA,GAAAA,6BAAAA,SAAAA,AAAAA,EAAU,KACRX,EAAOK,GACT,GACGL,EAAOK,IACZO,AAAAA,GAAAA,6BAAAA,cAAAA,AAAAA,EAAe,IAAMZ,OACda,AAAAA,GAAAA,6BAAAA,eAAAA,AAAAA,EAAgBV,EACzB,CC3BO,SAASW,WACdC,CAA4C,EAE5C,OAAOjB,UAAUiB,EACnB,C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MachineSnapshot } from '@slux/state-machine';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
import type { StateMachine } from '@slux/state-machine';
|
|
4
|
+
|
|
5
|
+
export declare function useMachine<Context, Event extends {
|
|
6
|
+
type: string;
|
|
7
|
+
}, State extends string>(machine: StateMachine<Context, Event, State>): Readonly<Ref<MachineSnapshot<Context, State>>>;
|
|
8
|
+
|
|
9
|
+
export { }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MachineSnapshot } from '@slux/state-machine';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
import type { StateMachine } from '@slux/state-machine';
|
|
4
|
+
|
|
5
|
+
export declare function useMachine<Context, Event extends {
|
|
6
|
+
type: string;
|
|
7
|
+
}, State extends string>(machine: StateMachine<Context, Event, State>): Readonly<Ref<MachineSnapshot<Context, State>>>;
|
|
8
|
+
|
|
9
|
+
export { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-machine.js","sources":["../src/state-machine.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport type { MachineSnapshot, StateMachine } from \"@slux/state-machine\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useMachine<Context, Event extends { type: string }, State extends string>(\n machine: StateMachine<Context, Event, State>,\n): Readonly<Ref<MachineSnapshot<Context, State>>> {\n return useSignal(machine);\n}\n"],"names":["useMachine","machine","useSignal"],"mappings":"iDAIO,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_modules__={o(e,_,r){var t=r("B"),o=r("g");r.d(_,{},{U:function(e){let _;if(!(0,t.getCurrentScope)())throw Error("useSignal 必须在 Vue setup 或 effectScope 中调用");let r=(0,t.shallowRef)(e.get()),u=()=>{let _=e.subscribe(e=>{r.value=e}),t=(0,o.effect)(()=>{e.get()});return r.value=e.get(),()=>{_(),t()}};return(0,t.getCurrentInstance)()?(0,t.onMounted)(()=>{_=u()}):_=u(),(0,t.onScopeDispose)(()=>_?.()),(0,t.shallowReadonly)(r)}})},g(e){e.exports=require("@slux/core")},B(e){e.exports=require("vue")}},__webpack_module_cache__={};function __webpack_require__(e){var _=__webpack_module_cache__[e];if(void 0!==_)return _.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var _=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(_,{a:_}),_},__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__={};for(var __rspack_i in(()=>{__webpack_require__.r(__webpack_exports__);var e=__webpack_require__("o");__webpack_require__.d(__webpack_exports__,{},{useStore:function(_,r,t=Object.is){let o=r??(e=>e),u=o(_.getState()),a=()=>{let e=o(_.getState());return t(u,e)||(u=e),u};return(0,e.U)({get:a,subscribe:e=>_.subscribe(()=>e(a()))})}})})(),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":["../src/use-signal.ts","webpack://webpack/runtime/compat_get_default_export","webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/store.ts"],"sourcesContent":["import { getCurrentInstance, getCurrentScope, onMounted, onScopeDispose, shallowReadonly, shallowRef } from \"vue\";\nimport type { Ref } from \"vue\";\nimport { effect } from \"@slux/core\";\nimport type { Subscribable } from \"@slux/core\";\n\nexport function useSignal<T>(source: Subscribable<T>): Readonly<Ref<T>> {\n if (!getCurrentScope()) throw new Error(\"useSignal 必须在 Vue setup 或 effectScope 中调用\");\n const value = shallowRef<T>(source.get());\n const start = () => {\n const unsubscribe = source.subscribe((next) => {\n value.value = next;\n });\n // computed 需要主动求值;真正的通知仍走 subscribe,兼容外部 Subscribable。\n const dispose = effect(() => {\n source.get();\n });\n value.value = source.get();\n return () => {\n unsubscribe();\n dispose();\n };\n };\n let stop: (() => void) | undefined;\n // SSR 不执行 mounted,避免为一次性服务端渲染留下订阅。\n if (getCurrentInstance())\n onMounted(() => {\n stop = start();\n });\n else stop = start();\n onScopeDispose(() => stop?.());\n return shallowReadonly(value);\n}\n","// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__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 type { Ref } from \"vue\";\nimport type { StoreApi } from \"@slux/store\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useStore<T>(store: StoreApi<T>): Readonly<Ref<T>>;\nexport function useStore<T, U>(store: StoreApi<T>, selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Readonly<Ref<U>>;\nexport function useStore<T, U = T>(\n store: StoreApi<T>,\n selector?: (state: T) => U,\n equals: (a: U, b: U) => boolean = Object.is,\n): Readonly<Ref<U>> {\n const select = selector ?? ((state: T) => state as unknown as U);\n let current = select(store.getState());\n const read = () => {\n const next = select(store.getState());\n if (!equals(current, next)) current = next;\n return current;\n };\n return useSignal({\n get: read,\n subscribe: (callback) => store.subscribe(() => callback(read())),\n });\n}\n"],"names":["source","stop","getCurrentScope","Error","value","shallowRef","start","unsubscribe","next","dispose","effect","getCurrentInstance","onMounted","onScopeDispose","shallowReadonly","__webpack_require__","e","Object","Symbol","store","selector","equals","select","state","current","read","useSignal","callback"],"mappings":"kSAKO,SAAsBA,CAAuB,MAiB9CC,EAhBJ,GAAI,CAACC,AAAAA,GAAAA,EAAAA,eAAAA,AAAAA,IAAmB,MAAM,AAAIC,MAAM,6CACxC,IAAMC,EAAQC,AAAAA,GAAAA,EAAAA,UAAAA,AAAAA,EAAcL,EAAO,GAAG,IAChCM,EAAQ,KACZ,IAAMC,EAAcP,EAAO,SAAS,CAAC,AAACQ,IACpCJ,EAAM,KAAK,CAAGI,CAChB,GAEMC,EAAUC,AAAAA,GAAAA,EAAAA,MAAAA,AAAAA,EAAO,KACrBV,EAAO,GAAG,EACZ,GAEA,OADAI,EAAM,KAAK,CAAGJ,EAAO,GAAG,GACjB,KACLO,IACAE,GACF,CACF,EASA,MANIE,AAAAA,GAAAA,EAAAA,kBAAAA,AAAAA,IACFC,AAAAA,GAAAA,EAAAA,SAAAA,AAAAA,EAAU,KACRX,EAAOK,GACT,GACGL,EAAOK,IACZO,AAAAA,GAAAA,EAAAA,cAAAA,AAAAA,EAAe,IAAMZ,OACda,AAAAA,GAAAA,EAAAA,eAAAA,AAAAA,EAAgBV,EACzB,C,+TC9BAW,oBAAoB,CAAC,CAAG,AAAC,IACxB,IAAI,EAAS,GAAU,EAAO,UAAU,CACvC,IAAO,EAAO,OAAU,CACxB,IAAO,EAER,OADAA,oBAAoB,CAAC,CAAC,EAAQ,CAAE,EAAG,CAAO,GACnC,CACR,ECPAA,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,uLCAO,SACLG,CAAkB,CAClBC,CAA0B,CAC1BC,EAAkCJ,OAAO,EAAE,EAE3C,IAAMK,EAASF,GAAc,CAAAG,GAAaA,CAAI,EAC1CC,EAAUF,EAAOH,EAAM,QAAQ,IAC7BM,EAAO,KACX,IAAMjB,EAAOc,EAAOH,EAAM,QAAQ,IAElC,OADI,AAACE,EAAOG,EAAShB,IAAOgB,CAAAA,EAAUhB,CAAG,EAClCgB,CACT,EACA,MAAOE,AAAAA,GAAAA,EAAAA,CAAAA,AAAAA,EAAU,CACf,IAAKD,EACL,UAAW,AAACE,GAAaR,EAAM,SAAS,CAAC,IAAMQ,EAASF,KAC1D,EACF,C"}
|
package/dist/store.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { StoreApi } from '@slux/store';
|
|
3
|
+
|
|
4
|
+
export declare function useStore<T>(store: StoreApi<T>): Readonly<Ref<T>>;
|
|
5
|
+
|
|
6
|
+
export declare function useStore<T, U>(store: StoreApi<T>, selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Readonly<Ref<U>>;
|
|
7
|
+
|
|
8
|
+
export { }
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { StoreApi } from '@slux/store';
|
|
3
|
+
|
|
4
|
+
export declare function useStore<T>(store: StoreApi<T>): Readonly<Ref<T>>;
|
|
5
|
+
|
|
6
|
+
export declare function useStore<T, U>(store: StoreApi<T>, selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Readonly<Ref<U>>;
|
|
7
|
+
|
|
8
|
+
export { }
|
package/dist/store.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sources":["../src/store.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport type { StoreApi } from \"@slux/store\";\nimport { useSignal } from \"./use-signal.js\";\n\nexport function useStore<T>(store: StoreApi<T>): Readonly<Ref<T>>;\nexport function useStore<T, U>(store: StoreApi<T>, selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Readonly<Ref<U>>;\nexport function useStore<T, U = T>(\n store: StoreApi<T>,\n selector?: (state: T) => U,\n equals: (a: U, b: U) => boolean = Object.is,\n): Readonly<Ref<U>> {\n const select = selector ?? ((state: T) => state as unknown as U);\n let current = select(store.getState());\n const read = () => {\n const next = select(store.getState());\n if (!equals(current, next)) current = next;\n return current;\n };\n return useSignal({\n get: read,\n subscribe: (callback) => store.subscribe(() => callback(read())),\n });\n}\n"],"names":["useStore","store","selector","equals","Object","select","state","current","read","next","useSignal","callback"],"mappings":"iDAMO,SAASA,EACdC,CAAkB,CAClBC,CAA0B,CAC1BC,EAAkCC,OAAO,EAAE,EAE3C,IAAMC,EAASH,GAAc,CAAAI,GAAaA,CAAI,EAC1CC,EAAUF,EAAOJ,EAAM,QAAQ,IAC7BO,EAAO,KACX,IAAMC,EAAOJ,EAAOJ,EAAM,QAAQ,IAElC,OADI,AAACE,EAAOI,EAASE,IAAOF,CAAAA,EAAUE,CAAG,EAClCF,CACT,EACA,OAAOG,EAAU,CACf,IAAKF,EACL,UAAW,AAACG,GAAaV,EAAM,SAAS,CAAC,IAAMU,EAASH,KAC1D,EACF,Q"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,163 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slux/vue",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "slux vue bindings",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"slux",
|
|
7
|
+
"vue",
|
|
8
|
+
"composition-api",
|
|
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/vue"
|
|
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
|
+
"vue": ">=3.2.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
|
+
"jsdom": "30.1.3",
|
|
142
|
+
"rstack": "0.9.0",
|
|
143
|
+
"typescript": "7.1.0-beta",
|
|
144
|
+
"vue": "3.5.45",
|
|
145
|
+
"@vue/server-renderer": "3.5.45",
|
|
146
|
+
"@slux/flux": "0.1.0",
|
|
147
|
+
"@slux/state-machine": "0.1.0",
|
|
148
|
+
"@slux/rxjs": "0.1.0",
|
|
149
|
+
"rxjs": "7.8.2"
|
|
150
|
+
},
|
|
151
|
+
"dependencies": {
|
|
152
|
+
"@slux/shared": "0.1.0"
|
|
153
|
+
},
|
|
154
|
+
"scripts": {
|
|
155
|
+
"dev": "rs lib -w",
|
|
156
|
+
"build": "rs lib",
|
|
157
|
+
"test": "rs test",
|
|
158
|
+
"lint": "rs lint",
|
|
159
|
+
"fmt": "rs fmt",
|
|
160
|
+
"typecheck": "tsc --noEmit",
|
|
161
|
+
"clean": "rm -rf dist node_modules .turbo"
|
|
162
|
+
}
|
|
6
163
|
}
|