@slux/inferno 0.0.0-stage → 0.1.1
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 +45 -0
- package/LICENSE +21 -0
- package/README.md +280 -2
- package/dist/atom.cjs +2 -0
- package/dist/atom.cjs.map +1 -0
- package/dist/atom.d.cts +33 -0
- package/dist/atom.d.ts +33 -0
- package/dist/atom.js +2 -0
- package/dist/atom.js.map +1 -0
- package/dist/flux.cjs +2 -0
- package/dist/flux.cjs.map +1 -0
- package/dist/flux.d.cts +45 -0
- package/dist/flux.d.ts +45 -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 +53 -0
- package/dist/index.d.ts +53 -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 +30 -0
- package/dist/proxy.d.ts +30 -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 +41 -0
- package/dist/rxjs.d.ts +41 -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 +46 -0
- package/dist/state-machine.d.ts +46 -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 +36 -0
- package/dist/store.d.ts +36 -0
- package/dist/store.js +2 -0
- package/dist/store.js.map +1 -0
- package/dist/z~0.js +2 -0
- package/dist/z~0.js.map +1 -0
- package/package.json +161 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @slux/inferno
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 207e315: 基于 `v0.1.0` 之后的改动,完善包文档、交互示例和发布流程。
|
|
8
|
+
|
|
9
|
+
- 为 25 个包的 README 补充统一导航;文档站增加各包更新日志、版本发行说明和可在站内体验的示例入口。
|
|
10
|
+
- 整理示例应用的共享外壳与主题交互,并将示例图标替换为透明背景的 SVG。
|
|
11
|
+
- 修正自动导入 API 清单生成规则,排除需要显式调用的 `createAutoImportApis` 工厂函数,并统一 Viewfly 清单顺序。
|
|
12
|
+
- 发布工作流改为 GitHub OIDC 授信发布:预先打包各包、独立执行发布任务,并在发布成功后创建 GitHub Release 草稿。
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [207e315]
|
|
15
|
+
- @slux/atom@0.1.1
|
|
16
|
+
- @slux/core@0.1.1
|
|
17
|
+
- @slux/flux@0.1.1
|
|
18
|
+
- @slux/proxy@0.1.1
|
|
19
|
+
- @slux/rxjs@0.1.1
|
|
20
|
+
- @slux/shared@0.1.1
|
|
21
|
+
- @slux/state-machine@0.1.1
|
|
22
|
+
- @slux/store@0.1.1
|
|
23
|
+
|
|
24
|
+
## 0.1.0
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- 首次公开发布 slux 的 25 个包,统一版本为 0.1.0。
|
|
29
|
+
|
|
30
|
+
- 提供框架无关的响应式核心与共享工具,以及 Store、Atom、Proxy、Flux、状态机和 RxJS 六种状态组织方式。
|
|
31
|
+
- 提供持久化、历史记录、跨标签页同步、遥测和开发工具五类 Store 扩展。
|
|
32
|
+
- 提供 React、Vue、Solid、Svelte、Angular、Preact、Ripple、Inferno、Octane、Vitarx、ActView 和 Viewfly 绑定。
|
|
33
|
+
- 提供各包文档与对应示例,并接入发布检查和文档部署工作流。
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies
|
|
38
|
+
- @slux/atom@0.1.0
|
|
39
|
+
- @slux/core@0.1.0
|
|
40
|
+
- @slux/flux@0.1.0
|
|
41
|
+
- @slux/proxy@0.1.0
|
|
42
|
+
- @slux/rxjs@0.1.0
|
|
43
|
+
- @slux/shared@0.1.0
|
|
44
|
+
- @slux/state-machine@0.1.0
|
|
45
|
+
- @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,281 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @slux/inferno
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Inferno 10(`inferno@^10.0.0`)的 slux 绑定,基于 `@slux/core` 的 `Subscribable<T>` 订阅模型。原生绑定形式是 **原生 class 组件生命周期管理订阅 + render prop 输出值**:所有读取组件都接受 `children: (value) => InfernoNode`,由内部 `Observer` 基类在挂载、更新、卸载时管理订阅。所有写入仍走原实例,绑定只读。
|
|
4
|
+
|
|
5
|
+
## 特性与适用场景
|
|
6
|
+
|
|
7
|
+
| 项 | 说明 |
|
|
8
|
+
| -------- | -------------------------------------------------------------------------------------- |
|
|
9
|
+
| 绑定形式 | class 组件 + `children: (value) => InfernoNode` render prop |
|
|
10
|
+
| 框架依赖 | `inferno` 的 `Component` / `InfernoNode`,以及原生 legacy context(`getChildContext`) |
|
|
11
|
+
| 范式覆盖 | core 主入口 + atom / store / proxy / flux / state-machine / rxjs 六个子入口 |
|
|
12
|
+
| SSR | `renderToString` 不挂载、不订阅;`ScopeProvider` 提供覆盖首屏值,支持 hydration |
|
|
13
|
+
|
|
14
|
+
| 场景 | 是否适合 | 说明 |
|
|
15
|
+
| --------------------------------------------------------------------- | -------- | ----------------------------------------------- |
|
|
16
|
+
| 用 Inferno class 组件 / `createElement` 读 core `signal` / `computed` | 适合 | `SignalValue` 在挂载时建立订阅并驱动 computed |
|
|
17
|
+
| 用 atom / store / proxy 或新增三种范式 | 适合 | 各子入口提供对应 render-prop 组件 |
|
|
18
|
+
| SSR 首屏 + hydration | 适合 | SSR 读 Scope 覆盖值,hydration 复用 DOM |
|
|
19
|
+
| 需要函数组件 / hooks 写法 | 不适合 | 本包以 class 组件暴露,源码不使用 Inferno hooks |
|
|
20
|
+
| 需要绑定替你写入状态 | 不适合 | 只读,写入走 `set` / `dispatch` / `send` |
|
|
21
|
+
|
|
22
|
+
## 安装
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add @slux/core @slux/inferno inferno@^10
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- **必需 peer**:`@slux/core`(`workspace:^`)、`inferno@^10.0.0`。
|
|
29
|
+
- **可选 peer(范式包)**:`@slux/atom`、`@slux/store`、`@slux/proxy`、`@slux/flux`、`@slux/state-machine`、`@slux/rxjs` 均为 `optional`,**只装实际使用的子入口**。
|
|
30
|
+
- `@slux/shared` 是本包运行时依赖,安装时自动带入。
|
|
31
|
+
- 主入口与每个子入口都通过 `exports` 同时提供 ESM(`import`)、CJS(`require`)与 `.d.ts` / `.d.cts` 类型声明。
|
|
32
|
+
- 本包**不依赖** `inferno-create-element`;下例用它创建 VNode,也可改用项目自身的 Inferno JSX 编译配置。
|
|
33
|
+
|
|
34
|
+
`package.json` 的 `exports` 子入口(逐个列出):
|
|
35
|
+
|
|
36
|
+
| 子路径 | 导出内容 |
|
|
37
|
+
| ----------------------------- | ------------------------------------------------------------------------------------- |
|
|
38
|
+
| `@slux/inferno` | 主入口:`SignalValue`、`ScopeProvider`、`getScope`、`createAutoImportApis` 及三个类型 |
|
|
39
|
+
| `@slux/inferno/atom` | `AtomValue`、`setAtom`、`AtomValueProps` |
|
|
40
|
+
| `@slux/inferno/store` | `StoreValue`、`StoreValueProps` |
|
|
41
|
+
| `@slux/inferno/proxy` | `ProxyValue`、`ProxyValueProps` |
|
|
42
|
+
| `@slux/inferno/flux` | `FluxValue`、`FluxValueProps` |
|
|
43
|
+
| `@slux/inferno/state-machine` | `MachineValue`、`MachineValueProps` |
|
|
44
|
+
| `@slux/inferno/rxjs` | `ObservableValue`、`ObservableValueProps` |
|
|
45
|
+
| `@slux/inferno/package.json` | 包元数据(非 API) |
|
|
46
|
+
|
|
47
|
+
## 快速开始
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { createElement as h } from "inferno-create-element";
|
|
51
|
+
import { signal } from "@slux/core";
|
|
52
|
+
import { SignalValue } from "@slux/inferno";
|
|
53
|
+
|
|
54
|
+
const count = signal(0);
|
|
55
|
+
|
|
56
|
+
const view = h(SignalValue<number>, {
|
|
57
|
+
source: count,
|
|
58
|
+
children: (value) => h("span", null, String(value)),
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`SignalValue` 的 `source` 是 `Subscribable<T>`,`children` 是 render prop;`count.set(...)` 写入后组件重新渲染并输出新值。
|
|
63
|
+
|
|
64
|
+
## 主入口 API
|
|
65
|
+
|
|
66
|
+
主入口导出 `ScopeProvider`、`getScope`、`SignalValue`、`createAutoImportApis`,以及类型 `ScopeContext`、`ScopeProviderProps`、`SignalValueProps`。
|
|
67
|
+
|
|
68
|
+
| 成员 | 签名 | 行为 |
|
|
69
|
+
| ---------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
70
|
+
| `ScopeProvider` | `class extends Component<ScopeProviderProps>` | 通过 Inferno `getChildContext()` 提供 `{ sluxScope: scope }`;`render()` 返回 `children` |
|
|
71
|
+
| `getScope` | `(context: ScopeContext) => Scope \| undefined` | 从 legacy context 读 `sluxScope`;class 组件用 `getScope(this.context as ScopeContext)` |
|
|
72
|
+
| `SignalValue` | `class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T>` | `source` 为 `Subscribable<T>`;`children` render prop 输出 `T` |
|
|
73
|
+
| `createAutoImportApis` | `(prefix?: string) => ImportsMap` | 生成 `unplugin-auto-import` 配置,见「自动导入」 |
|
|
74
|
+
|
|
75
|
+
`SignalValue` 的三处关键实现:
|
|
76
|
+
|
|
77
|
+
| 环节 | 实现 |
|
|
78
|
+
| ------------------- | -------------------------------------------------------------------------------------- |
|
|
79
|
+
| `read()` | 未挂载且存在 scope 时 `scope.get(source)`,否则 `source.get()` |
|
|
80
|
+
| `subscribe(notify)` | `source.subscribe(notify)` + `effect(() => { source.get(); })`,返回同时释放二者的函数 |
|
|
81
|
+
| `componentDidMount` | 先置 `#mounted = true`,再调用 `super.componentDidMount()` 建立订阅 |
|
|
82
|
+
|
|
83
|
+
内部 `Observer` 基类(`src/observer.ts`,**未从任何入口导出**)统一负责订阅生命周期:`componentDidMount` 建立订阅并立即 check 一次;`componentDidUpdate` 在 `source(prevProps) !== source(props)` 时释放旧订阅、重新连接;`componentWillUnmount` 释放订阅;`render()` 用 `read()` 交给 `view(value)`(即 `children`);`equal` 默认 `Object.is`,值不等时 `forceUpdate()`。
|
|
84
|
+
|
|
85
|
+
Scope 与 context 用法:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { Component } from "inferno";
|
|
89
|
+
import type { InfernoNode } from "inferno";
|
|
90
|
+
import { createElement as h } from "inferno-create-element";
|
|
91
|
+
import { createScope, signal } from "@slux/core";
|
|
92
|
+
import { ScopeProvider, getScope, type ScopeContext } from "@slux/inferno";
|
|
93
|
+
|
|
94
|
+
const source = signal(1);
|
|
95
|
+
const scope = createScope();
|
|
96
|
+
scope.set(source, 20);
|
|
97
|
+
|
|
98
|
+
class Scoped extends Component {
|
|
99
|
+
override render(): InfernoNode {
|
|
100
|
+
return h("span", null, String(getScope(this.context as ScopeContext)?.get(source)));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const view = h(ScopeProvider, { scope }, h(Scoped));
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 子入口 API
|
|
108
|
+
|
|
109
|
+
所有读取组件都是 class 组件,`children` 为 `(value) => InfernoNode`;**不返回写入 tuple,也不创建副本**。
|
|
110
|
+
|
|
111
|
+
### `@slux/inferno/atom`
|
|
112
|
+
|
|
113
|
+
`AtomValueProps<T> = { atom: AnyReadableAtom<T>; children: (value: T) => InfernoNode }`。
|
|
114
|
+
|
|
115
|
+
| 导出 | 签名 | 说明 |
|
|
116
|
+
| ----------- | ----------------------------------------------------------- | -------------------------------------------- |
|
|
117
|
+
| `AtomValue` | `class AtomValue<T> extends Observer<AtomValueProps<T>, T>` | 来源 prop 为 `atom`,支持只读派生 atom |
|
|
118
|
+
| `setAtom` | `<T>(atom: Atom<T>, value: T) => void` | 按替换契约写值;也可直接用业务 atom 的 `set` |
|
|
119
|
+
|
|
120
|
+
### `@slux/inferno/store`
|
|
121
|
+
|
|
122
|
+
`StoreValueProps<State, Selection = State>` 含 `store: StoreApi<State>`、`children: (value: Selection) => InfernoNode`、可选 `equalityFn`,以及 `selector` 的联合约束:提供 selector 得到 `Selection`;不提供时 `Selection` 必须可容纳 `State`(返回完整状态)。
|
|
123
|
+
|
|
124
|
+
| 导出 | 签名 | 说明 |
|
|
125
|
+
| ------------ | --------------------------------------------------------------------------------- | ---------------------------------------------------------- |
|
|
126
|
+
| `StoreValue` | `class StoreValue<State extends object, Selection = State> extends Observer<...>` | 来源 prop 为 `store`;`equal` 用 `equalityFn ?? Object.is` |
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { createElement as h } from "inferno-create-element";
|
|
130
|
+
import { createStore } from "@slux/store";
|
|
131
|
+
import { StoreValue } from "@slux/inferno/store";
|
|
132
|
+
|
|
133
|
+
type State = { count: number };
|
|
134
|
+
const store = createStore<State>(() => ({ count: 1 }));
|
|
135
|
+
|
|
136
|
+
const view = h(StoreValue<State, number>, {
|
|
137
|
+
store,
|
|
138
|
+
selector: (state) => state.count,
|
|
139
|
+
children: (count) => h("span", null, String(count)),
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
selector / `equalityFn` 变化不触发重新订阅(`source` 仍是同一 store),但在下一次渲染的 `read()` / `equal()` 中立即生效。写入仍用 `store.setState(...)`。
|
|
144
|
+
|
|
145
|
+
### `@slux/inferno/proxy`
|
|
146
|
+
|
|
147
|
+
`ProxyValueProps<T extends object> = { proxy: T; children: (value: Snapshot<T>) => InfernoNode }`。
|
|
148
|
+
|
|
149
|
+
| 导出 | 签名 | 说明 |
|
|
150
|
+
| ------------ | -------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
151
|
+
| `ProxyValue` | `class ProxyValue<T extends object> extends Observer<ProxyValueProps<T>, Snapshot<T>>` | 来源 prop 为 `proxy`;返回整个对象的深只读快照,无字段访问追踪 |
|
|
152
|
+
|
|
153
|
+
### 新增三种范式(只读)
|
|
154
|
+
|
|
155
|
+
三个组件都 `extends SignalValue`,统一使用 `source` prop,`children` 均为 `(value) => InfernoNode`。
|
|
156
|
+
|
|
157
|
+
| 子路径 | 组件与 props | children 值类型 | 写入方式 |
|
|
158
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------- | ------------------------ |
|
|
159
|
+
| `@slux/inferno/flux` | `FluxValue<State, Action extends { type: string }>`、`FluxValueProps<State, Action>` | `State` | `store.dispatch(action)` |
|
|
160
|
+
| `@slux/inferno/state-machine` | `MachineValue<Context, Event extends { type: string }, State extends string>`、`MachineValueProps<...>` | `MachineSnapshot<Context, State>` | `machine.send(event)` |
|
|
161
|
+
| `@slux/inferno/rxjs` | `ObservableValue<T>`、`ObservableValueProps<T>` | `T` | 桥接创建者持有上游 |
|
|
162
|
+
|
|
163
|
+
## 专属语义与边界
|
|
164
|
+
|
|
165
|
+
- **SSR / hydration**:`renderToString` 不触发 `componentDidMount`,因此**不建立订阅、不启动 core `effect`**;`SignalValue.read()` 在未挂载时读 `scope.get(source)` 覆盖值,无 scope 则读全局值。hydration 复用 DOM 后 `componentDidMount` 置 `#mounted = true` 并切到全局来源读取。Inferno 在生命周期中排队的更新会在**微任务**提交,因此挂载后需等待一个微任务才读到全局值。
|
|
166
|
+
- **Scope 边界**:`ScopeProvider` 用 Inferno 原生 legacy context(`getChildContext()`)传递 `{ sluxScope }`,class 组件用 `getScope(this.context as ScopeContext)` 显式读取。只有 `SignalValue` 在服务端 / 首次挂载前应用 scope 覆盖值;`AtomValue` / `StoreValue` / `ProxyValue` 及三个新增范式组件读取各自实例,**不应用 core scope**。`scope.set()` 不触发全局订阅(通用约定见仓库根 README)。
|
|
167
|
+
- **订阅与清理**:`Observer` 在挂载时 `subscribe(check)` 并立即 check;`componentDidUpdate` 比较 `source(prevProps)` 与 `source(props)`,来源切换时释放旧订阅并重建;`componentWillUnmount` 释放订阅。`SignalValue`、`AtomValue` 的订阅内额外建立 core `effect` 驱动惰性 computed;`StoreValue` / `ProxyValue` 直接订阅各自 store / proxy。组件卸载**不销毁**业务 store / flux / machine / observable,桥接创建者负责 `dispose()`。
|
|
168
|
+
- **快照相等判定**:`Observer.equal` 默认 `Object.is`,值相等时跳过 `forceUpdate()`;`StoreValue` 用 `equalityFn ?? Object.is`。`@slux/proxy` 的 `snapshot` 为冻结、结构共享的深只读快照,未变分支保持引用。
|
|
169
|
+
- **错误处理**:绑定层不新增错误包装;写入、通知与 `effect` 的错误行为遵循 `@slux/core`。RxJS 桥接的完成 / 错误状态由 `@slux/rxjs` 的 `status` / `error` 只读信号读取。
|
|
170
|
+
- **通用约定**:跨框架的写入形式、Scope、SSR 与桥接生命周期约定见 [仓库根 README](../../README.md) 的「框架适配 · 通用约定」;仓库内验证命令见「本地开发」,本文不重复。
|
|
171
|
+
|
|
172
|
+
## 自动导入
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import AutoImport from "unplugin-auto-import/vite";
|
|
176
|
+
import { createAutoImportApis } from "@slux/inferno";
|
|
177
|
+
|
|
178
|
+
export default {
|
|
179
|
+
plugins: [AutoImport({ imports: [createAutoImportApis()] })],
|
|
180
|
+
};
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`createAutoImportApis(prefix = "")` 的登记清单以 `src/auto-import-api.ts` 的 `allImportApis` 为准,当前为 **`ScopeProvider`、`SignalValue`、`getScope`** 三项,来源名 `@slux/inferno`。传入前缀可生成别名,大写规则由 `@slux/shared` 的 `generateBatchAutoImports` 决定。清单**只含主入口运行时导出**,不含 `createAutoImportApis` 自身、三个类型,也不含任何子入口组件。
|
|
184
|
+
|
|
185
|
+
## 类型导出
|
|
186
|
+
|
|
187
|
+
| 类型 | 导出位置 |
|
|
188
|
+
| ------------------------------------------ | -------------------------------------------------------------------------- |
|
|
189
|
+
| `ScopeContext` | 主入口:`{ sluxScope?: Scope }` |
|
|
190
|
+
| `ScopeProviderProps` | 主入口:`{ scope: Scope; children?: InfernoNode }` |
|
|
191
|
+
| `SignalValueProps<T>` | 主入口:`{ source: Subscribable<T>; children: (value: T) => InfernoNode }` |
|
|
192
|
+
| `AtomValueProps<T>` | `/atom` |
|
|
193
|
+
| `StoreValueProps<State, Selection>` | `/store` |
|
|
194
|
+
| `ProxyValueProps<T>` | `/proxy` |
|
|
195
|
+
| `FluxValueProps<State, Action>` | `/flux` |
|
|
196
|
+
| `MachineValueProps<Context, Event, State>` | `/state-machine` |
|
|
197
|
+
| `ObservableValueProps<T>` | `/rxjs` |
|
|
198
|
+
|
|
199
|
+
`Scope` / `Subscribable<T>` 来自 `@slux/core`,`InfernoNode` 来自 `inferno`,`AnyReadableAtom` / `Atom`、`StoreApi`、`Snapshot`、`FluxStore`、`MachineSnapshot` / `StateMachine`、`ObservableState` 等从各自范式包导入。`Observer` 基类未从任何入口导出,不属于公开类型。
|
|
200
|
+
|
|
201
|
+
## 不适用的场景
|
|
202
|
+
|
|
203
|
+
- 需要函数组件 / hooks 写法:本包以 class 组件与 render prop 暴露。
|
|
204
|
+
- 需要绑定返回写入 tuple、selector 之外的写入接口或状态副本:只读原实例。
|
|
205
|
+
- 需要在同一组件实例内切换来源后仍保持旧来源订阅:`Observer` 在来源切换时会释放旧订阅;如需并存请渲染多个组件。
|
|
206
|
+
- 需要自动的请求级状态隔离或自动序列化 / 恢复:见仓库根 README 的通用约定,需调用方按请求建实例。
|
|
207
|
+
|
|
208
|
+
## 版本、许可与反馈
|
|
209
|
+
|
|
210
|
+
- 版本:`0.1.0`(`package.json`);许可:[MIT](../../LICENSE) © itmanyong。
|
|
211
|
+
- 问题反馈:[GitHub Issues](https://github.com/itmanyong/slux/issues)。
|
|
212
|
+
- 通用约定与本地开发命令见 [仓库根 README](../../README.md)。
|
|
213
|
+
|
|
214
|
+
<!-- package-navigation:start -->
|
|
215
|
+
|
|
216
|
+
## 包导航
|
|
217
|
+
|
|
218
|
+
### 核心层
|
|
219
|
+
|
|
220
|
+
响应式运行时与零依赖工具,其余各层都建立在 core 之上。
|
|
221
|
+
|
|
222
|
+
| 包名 | 版本 | 在线文档 | 功能 |
|
|
223
|
+
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | ---------------------- |
|
|
224
|
+
| [`@slux/core`](https://github.com/itmanyong/slux/tree/main/packages/core) | [](https://www.npmjs.com/package/@slux/core) [](https://npmx.dev/package/@slux/core) | [在线文档](https://itmanyong.github.io/slux/packages/core) | 框架无关的响应式运行时 |
|
|
225
|
+
| [`@slux/shared`](https://github.com/itmanyong/slux/tree/main/packages/shared) | [](https://www.npmjs.com/package/@slux/shared) [](https://npmx.dev/package/@slux/shared) | [在线文档](https://itmanyong.github.io/slux/packages/shared) | 零依赖的共享工具 |
|
|
226
|
+
|
|
227
|
+
### 范式层
|
|
228
|
+
|
|
229
|
+
六种组织状态的方式,共享 core 的运行时,可在同一个依赖图中混用。
|
|
230
|
+
|
|
231
|
+
| 包名 | 版本 | 在线文档 | 功能 |
|
|
232
|
+
| ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | ---------------------------------- |
|
|
233
|
+
| [`@slux/store`](https://github.com/itmanyong/slux/tree/main/packages/store) | [](https://www.npmjs.com/package/@slux/store) [](https://npmx.dev/package/@slux/store) | [在线文档](https://itmanyong.github.io/slux/packages/store) | 状态与 action 集中管理,支持中间件 |
|
|
234
|
+
| [`@slux/atom`](https://github.com/itmanyong/slux/tree/main/packages/atom) | [](https://www.npmjs.com/package/@slux/atom) [](https://npmx.dev/package/@slux/atom) | [在线文档](https://itmanyong.github.io/slux/packages/atom) | 细粒度原子状态与派生 |
|
|
235
|
+
| [`@slux/proxy`](https://github.com/itmanyong/slux/tree/main/packages/proxy) | [](https://www.npmjs.com/package/@slux/proxy) [](https://npmx.dev/package/@slux/proxy) | [在线文档](https://itmanyong.github.io/slux/packages/proxy) | 可变代理写入与只读快照 |
|
|
236
|
+
| [`@slux/flux`](https://github.com/itmanyong/slux/tree/main/packages/flux) | [](https://www.npmjs.com/package/@slux/flux) [](https://npmx.dev/package/@slux/flux) | [在线文档](https://itmanyong.github.io/slux/packages/flux) | reducer + dispatch 范式 |
|
|
237
|
+
| [`@slux/state-machine`](https://github.com/itmanyong/slux/tree/main/packages/state-machine) | [](https://www.npmjs.com/package/@slux/state-machine) [](https://npmx.dev/package/@slux/state-machine) | [在线文档](https://itmanyong.github.io/slux/packages/state-machine) | 平面有限状态机 |
|
|
238
|
+
| [`@slux/rxjs`](https://github.com/itmanyong/slux/tree/main/packages/rxjs) | [](https://www.npmjs.com/package/@slux/rxjs) [](https://npmx.dev/package/@slux/rxjs) | [在线文档](https://itmanyong.github.io/slux/packages/rxjs) | Observable 与状态双向桥接 |
|
|
239
|
+
|
|
240
|
+
### 中间件层
|
|
241
|
+
|
|
242
|
+
挂载到 Store 的横切能力,五个包共用同一套契约。
|
|
243
|
+
|
|
244
|
+
| 包名 | 版本 | 在线文档 | 功能 |
|
|
245
|
+
| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | -------------------- |
|
|
246
|
+
| [`@slux/storage`](https://github.com/itmanyong/slux/tree/main/packages/storage) | [](https://www.npmjs.com/package/@slux/storage) [](https://npmx.dev/package/@slux/storage) | [在线文档](https://itmanyong.github.io/slux/packages/storage) | 状态持久化与恢复 |
|
|
247
|
+
| [`@slux/history`](https://github.com/itmanyong/slux/tree/main/packages/history) | [](https://www.npmjs.com/package/@slux/history) [](https://npmx.dev/package/@slux/history) | [在线文档](https://itmanyong.github.io/slux/packages/history) | 撤销与重做 |
|
|
248
|
+
| [`@slux/tab-sync`](https://github.com/itmanyong/slux/tree/main/packages/tab-sync) | [](https://www.npmjs.com/package/@slux/tab-sync) [](https://npmx.dev/package/@slux/tab-sync) | [在线文档](https://itmanyong.github.io/slux/packages/tab-sync) | 跨标签页状态同步 |
|
|
249
|
+
| [`@slux/telemetry`](https://github.com/itmanyong/slux/tree/main/packages/telemetry) | [](https://www.npmjs.com/package/@slux/telemetry) [](https://npmx.dev/package/@slux/telemetry) | [在线文档](https://itmanyong.github.io/slux/packages/telemetry) | 状态变化与订阅遥测 |
|
|
250
|
+
| [`@slux/devtools`](https://github.com/itmanyong/slux/tree/main/packages/devtools) | [](https://www.npmjs.com/package/@slux/devtools) [](https://npmx.dev/package/@slux/devtools) | [在线文档](https://itmanyong.github.io/slux/packages/devtools) | 调试工具、日志与检查 |
|
|
251
|
+
|
|
252
|
+
### 框架层
|
|
253
|
+
|
|
254
|
+
十二个绑定包都提供 core 主入口与六个范式子入口,使用框架原生响应式与生命周期。范式包是**可选** peer,只装实际使用的;`@slux/core` 与框架本身是**必需** peer。
|
|
255
|
+
|
|
256
|
+
| 包名 | 版本 | 在线文档 | 适配框架 | 适配版本 | 功能 |
|
|
257
|
+
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | ----------------------------------------------- | ------------------------------------------ | ---------------------- |
|
|
258
|
+
| [`@slux/react`](https://github.com/itmanyong/slux/tree/main/packages/react) | [](https://www.npmjs.com/package/@slux/react) [](https://npmx.dev/package/@slux/react) | [在线文档](https://itmanyong.github.io/slux/packages/react) | [React](https://github.com/react/react) | `^18.0.0 ‖ ^19.0.0` | React 组件状态绑定 |
|
|
259
|
+
| [`@slux/vue`](https://github.com/itmanyong/slux/tree/main/packages/vue) | [](https://www.npmjs.com/package/@slux/vue) [](https://npmx.dev/package/@slux/vue) | [在线文档](https://itmanyong.github.io/slux/packages/vue) | [Vue](https://github.com/vuejs/core) | `>= 3.2.0` | Vue 组合式 API 绑定 |
|
|
260
|
+
| [`@slux/solid`](https://github.com/itmanyong/slux/tree/main/packages/solid) | [](https://www.npmjs.com/package/@slux/solid) [](https://npmx.dev/package/@slux/solid) | [在线文档](https://itmanyong.github.io/slux/packages/solid) | [Solid](https://github.com/solidjs/solid) | `>= 1.0.0` | Solid 细粒度响应式绑定 |
|
|
261
|
+
| [`@slux/svelte`](https://github.com/itmanyong/slux/tree/main/packages/svelte) | [](https://www.npmjs.com/package/@slux/svelte) [](https://npmx.dev/package/@slux/svelte) | [在线文档](https://itmanyong.github.io/slux/packages/svelte) | [Svelte](https://github.com/sveltejs/svelte) | `>= 4.0.0` | Svelte 原生 store 绑定 |
|
|
262
|
+
| [`@slux/angular`](https://github.com/itmanyong/slux/tree/main/packages/angular) | [](https://www.npmjs.com/package/@slux/angular) [](https://npmx.dev/package/@slux/angular) | [在线文档](https://itmanyong.github.io/slux/packages/angular) | [Angular](https://github.com/angular/angular) | `@angular/core >= 16.0.0`、`rxjs >= 7.8.0` | Angular 注入上下文绑定 |
|
|
263
|
+
| [`@slux/preact`](https://github.com/itmanyong/slux/tree/main/packages/preact) | [](https://www.npmjs.com/package/@slux/preact) [](https://npmx.dev/package/@slux/preact) | [在线文档](https://itmanyong.github.io/slux/packages/preact) | [Preact](https://github.com/preactjs/preact) | `>= 10.5.0` | Preact 组件状态绑定 |
|
|
264
|
+
| [`@slux/ripple`](https://github.com/itmanyong/slux/tree/main/packages/ripple) | [](https://www.npmjs.com/package/@slux/ripple) [](https://npmx.dev/package/@slux/ripple) | [在线文档](https://itmanyong.github.io/slux/packages/ripple) | [Ripple](https://github.com/Ripple-TS/ripple) | `>= 0.6.0` | Ripple 组件状态绑定 |
|
|
265
|
+
| [`@slux/inferno`](https://github.com/itmanyong/slux/tree/main/packages/inferno) | [](https://www.npmjs.com/package/@slux/inferno) [](https://npmx.dev/package/@slux/inferno) | [在线文档](https://itmanyong.github.io/slux/packages/inferno) | [Inferno](https://github.com/infernojs/inferno) | `>= 7.0.0` | Inferno 组件状态绑定 |
|
|
266
|
+
| [`@slux/octane`](https://github.com/itmanyong/slux/tree/main/packages/octane) | [](https://www.npmjs.com/package/@slux/octane) [](https://npmx.dev/package/@slux/octane) | [在线文档](https://itmanyong.github.io/slux/packages/octane) | [Octane](https://github.com/octanejs/octane) | `>= 0.16.0` | Octane 编译器绑定 |
|
|
267
|
+
| [`@slux/vitarx`](https://github.com/itmanyong/slux/tree/main/packages/vitarx) | [](https://www.npmjs.com/package/@slux/vitarx) [](https://npmx.dev/package/@slux/vitarx) | [在线文档](https://itmanyong.github.io/slux/packages/vitarx) | [Vitarx](https://github.com/vitarx-lib/core) | `>= 4.0.0` | Vitarx 组件状态绑定 |
|
|
268
|
+
| [`@slux/actview`](https://github.com/itmanyong/slux/tree/main/packages/actview) | [](https://www.npmjs.com/package/@slux/actview) [](https://npmx.dev/package/@slux/actview) | [在线文档](https://itmanyong.github.io/slux/packages/actview) | [ActView](https://github.com/actview/actview) | `>= 1.0.0` | ActView 组件状态绑定 |
|
|
269
|
+
| [`@slux/viewfly`](https://github.com/itmanyong/slux/tree/main/packages/viewfly) | [](https://www.npmjs.com/package/@slux/viewfly) [](https://npmx.dev/package/@slux/viewfly) | [在线文档](https://itmanyong.github.io/slux/packages/viewfly) | [Viewfly](https://github.com/viewfly/viewfly) | `>= 3.0.0` | Viewfly 组件状态绑定 |
|
|
270
|
+
|
|
271
|
+
格式差异:**Octane** 的公开入口是 TypeScript 源码,需消费端 Octane 编译器处理且不提供 CJS;**Ripple** 只发布 ESM,另有 `./server` 服务端入口。其余边界见各包文档。
|
|
272
|
+
|
|
273
|
+
### 插件层
|
|
274
|
+
|
|
275
|
+
**规划中**
|
|
276
|
+
|
|
277
|
+
| 包名 | 版本 | 在线文档 | 功能 |
|
|
278
|
+
| ---- | ---- | -------- | ---- |
|
|
279
|
+
| — | — | — | — |
|
|
280
|
+
|
|
281
|
+
<!-- package-navigation:end -->
|
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,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__,{AtomValue:()=>AtomValue,setAtom:()=>setAtom});const core_namespaceObject=require("@slux/core"),external_inferno_namespaceObject=require("inferno");class Observer extends external_inferno_namespaceObject.Component{#e;#t;equal(e,t){return Object.is(e,t)}#r=()=>{let e=this.read();this.equal(this.#t,e)||(this.#t=e,this.forceUpdate())};#_(){this.#e=this.subscribe(this.#r),this.#r()}componentDidMount(){this.#_()}componentDidUpdate(e){this.source(e)!==this.source(this.props)&&(this.#e?.(),this.#_())}componentWillUnmount(){this.#e?.()}render(){return this.#t=this.read(),this.view(this.#t)}}class AtomValue extends Observer{source(e){return e.atom}read(){return this.props.atom.get()}view(e){return this.props.children(e)}subscribe(e){let t=this.props.atom,r=t.subscribe(e),_=(0,core_namespaceObject.effect)(()=>{t.get()});return()=>{r(),_()}}}function setAtom(e,t){e.set(t)}for(var __rspack_i in exports.AtomValue=__webpack_exports__.AtomValue,exports.setAtom=__webpack_exports__.setAtom,__webpack_exports__)-1===["AtomValue","setAtom"].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/observer.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 { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\n\nexport abstract class Observer<Props, Value> extends Component<Props> {\n #unsubscribe: (() => void) | undefined;\n #value!: Value;\n protected abstract read(): Value;\n protected abstract subscribe(notify: () => void): () => void;\n protected abstract source(props: Props): unknown;\n protected abstract view(value: Value): InfernoNode;\n protected equal(previous: Value, next: Value): boolean {\n return Object.is(previous, next);\n }\n #check = () => {\n const next = this.read();\n if (!this.equal(this.#value, next)) {\n this.#value = next;\n this.forceUpdate();\n }\n };\n #connect() {\n this.#unsubscribe = this.subscribe(this.#check);\n this.#check();\n }\n override componentDidMount() {\n this.#connect();\n }\n override componentDidUpdate(previous: Props) {\n if (this.source(previous) !== this.source(this.props)) {\n this.#unsubscribe?.();\n this.#connect();\n }\n }\n override componentWillUnmount() {\n this.#unsubscribe?.();\n }\n override render(): InfernoNode {\n this.#value = this.read();\n return this.view(this.#value);\n }\n}\n","import type { InfernoNode } from \"inferno\";\nimport type { Atom, AnyReadableAtom } from \"@slux/atom\";\nimport { effect } from \"@slux/core\";\nimport { Observer } from \"./observer.js\";\n\nexport type AtomValueProps<T> = {\n atom: AnyReadableAtom<T>;\n children: (value: T) => InfernoNode;\n};\nexport class AtomValue<T> extends Observer<AtomValueProps<T>, T> {\n protected override source(props: AtomValueProps<T>) {\n return props.atom;\n }\n protected override read(): T {\n return this.props.atom.get();\n }\n protected override view(value: T): InfernoNode {\n return this.props.children(value);\n }\n protected override subscribe(notify: () => void): () => void {\n const atom = this.props.atom;\n const unsubscribe = atom.subscribe(notify);\n const dispose = effect(() => {\n atom.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n }\n}\nexport function setAtom<T>(atom: Atom<T>, value: T): void {\n atom.set(value);\n}\n"],"names":["__webpack_require__","e","Object","Symbol","Observer","Component","previous","next","AtomValue","props","value","notify","atom","unsubscribe","dispose","effect","setAtom"],"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,mQCHO,OAAeG,iBAA+BC,iCAAAA,SAASA,CAC5D,EAAY,AAA2B,AACvC,GAAM,AAAS,AAKL,OAAMC,CAAe,CAAEC,CAAW,CAAW,CACrD,OAAOL,OAAO,EAAE,CAACI,EAAUC,EAC7B,CACA,EAAM,CAAG,KACP,IAAMA,EAAO,IAAI,CAAC,IAAI,GACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAM,CAAEA,KAC3B,IAAI,CAAC,EAAM,CAAGA,EACd,IAAI,CAAC,WAAW,GAEpB,CAAE,AACF,GAAQ,GACN,IAAI,CAAC,EAAY,CAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAM,EAC9C,IAAI,CAAC,EAAM,EACb,CACS,mBAAoB,CAC3B,IAAI,CAAC,EAAQ,EACf,CACS,mBAAmBD,CAAe,CAAE,CACvC,IAAI,CAAC,MAAM,CAACA,KAAc,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAClD,IAAI,CAAC,EAAY,KACjB,IAAI,CAAC,EAAQ,GAEjB,CACS,sBAAuB,CAC9B,IAAI,CAAC,EAAY,IACnB,CACS,QAAsB,CAE7B,OADA,IAAI,CAAC,EAAM,CAAG,IAAI,CAAC,IAAI,GAChB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAM,CAC9B,CACF,CC/BO,MAAME,kBAAqBJ,SACb,OAAOK,CAAwB,CAAE,CAClD,OAAOA,EAAM,IAAI,AACnB,CACmB,MAAU,CAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAC5B,CACmB,KAAKC,CAAQ,CAAe,CAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA,EAC7B,CACmB,UAAUC,CAAkB,CAAc,CAC3D,IAAMC,EAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CACtBC,EAAcD,EAAK,SAAS,CAACD,GAC7BG,EAAUC,AAAAA,GAAAA,qBAAAA,MAAAA,AAAAA,EAAO,KACrBH,EAAK,GAAG,EACV,GACA,MAAO,KACLC,IACAC,GACF,CACF,CACF,CACO,SAASE,QAAWJ,CAAa,CAAEF,CAAQ,EAChDE,EAAK,GAAG,CAACF,EACX,C"}
|
package/dist/atom.d.cts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AnyReadableAtom } from '@slux/atom';
|
|
2
|
+
import type { Atom } from '@slux/atom';
|
|
3
|
+
import { Component } from 'inferno';
|
|
4
|
+
import type { InfernoNode } from 'inferno';
|
|
5
|
+
|
|
6
|
+
export declare class AtomValue<T> extends Observer<AtomValueProps<T>, T> {
|
|
7
|
+
protected source(props: AtomValueProps<T>): AnyReadableAtom<T>;
|
|
8
|
+
protected read(): T;
|
|
9
|
+
protected view(value: T): InfernoNode;
|
|
10
|
+
protected subscribe(notify: () => void): () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare type AtomValueProps<T> = {
|
|
14
|
+
atom: AnyReadableAtom<T>;
|
|
15
|
+
children: (value: T) => InfernoNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare abstract class Observer<Props, Value> extends Component<Props> {
|
|
19
|
+
#private;
|
|
20
|
+
protected abstract read(): Value;
|
|
21
|
+
protected abstract subscribe(notify: () => void): () => void;
|
|
22
|
+
protected abstract source(props: Props): unknown;
|
|
23
|
+
protected abstract view(value: Value): InfernoNode;
|
|
24
|
+
protected equal(previous: Value, next: Value): boolean;
|
|
25
|
+
componentDidMount(): void;
|
|
26
|
+
componentDidUpdate(previous: Props): void;
|
|
27
|
+
componentWillUnmount(): void;
|
|
28
|
+
render(): InfernoNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare function setAtom<T>(atom: Atom<T>, value: T): void;
|
|
32
|
+
|
|
33
|
+
export { }
|
package/dist/atom.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AnyReadableAtom } from '@slux/atom';
|
|
2
|
+
import type { Atom } from '@slux/atom';
|
|
3
|
+
import { Component } from 'inferno';
|
|
4
|
+
import type { InfernoNode } from 'inferno';
|
|
5
|
+
|
|
6
|
+
export declare class AtomValue<T> extends Observer<AtomValueProps<T>, T> {
|
|
7
|
+
protected source(props: AtomValueProps<T>): AnyReadableAtom<T>;
|
|
8
|
+
protected read(): T;
|
|
9
|
+
protected view(value: T): InfernoNode;
|
|
10
|
+
protected subscribe(notify: () => void): () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare type AtomValueProps<T> = {
|
|
14
|
+
atom: AnyReadableAtom<T>;
|
|
15
|
+
children: (value: T) => InfernoNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare abstract class Observer<Props, Value> extends Component<Props> {
|
|
19
|
+
#private;
|
|
20
|
+
protected abstract read(): Value;
|
|
21
|
+
protected abstract subscribe(notify: () => void): () => void;
|
|
22
|
+
protected abstract source(props: Props): unknown;
|
|
23
|
+
protected abstract view(value: Value): InfernoNode;
|
|
24
|
+
protected equal(previous: Value, next: Value): boolean;
|
|
25
|
+
componentDidMount(): void;
|
|
26
|
+
componentDidUpdate(previous: Props): void;
|
|
27
|
+
componentWillUnmount(): void;
|
|
28
|
+
render(): InfernoNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare function setAtom<T>(atom: Atom<T>, value: T): void;
|
|
32
|
+
|
|
33
|
+
export { }
|
package/dist/atom.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{effect as r}from"@slux/core";import{Observer as t}from"./z~0.js";class e extends t{source(r){return r.atom}read(){return this.props.atom.get()}view(r){return this.props.children(r)}subscribe(t){let e=this.props.atom,s=e.subscribe(t),o=r(()=>{e.get()});return()=>{s(),o()}}}function s(r,t){r.set(t)}export{e as AtomValue,s as setAtom};
|
|
2
|
+
//# sourceMappingURL=atom.js.map
|
package/dist/atom.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atom.js","sources":["../src/atom.ts"],"sourcesContent":["import type { InfernoNode } from \"inferno\";\nimport type { Atom, AnyReadableAtom } from \"@slux/atom\";\nimport { effect } from \"@slux/core\";\nimport { Observer } from \"./observer.js\";\n\nexport type AtomValueProps<T> = {\n atom: AnyReadableAtom<T>;\n children: (value: T) => InfernoNode;\n};\nexport class AtomValue<T> extends Observer<AtomValueProps<T>, T> {\n protected override source(props: AtomValueProps<T>) {\n return props.atom;\n }\n protected override read(): T {\n return this.props.atom.get();\n }\n protected override view(value: T): InfernoNode {\n return this.props.children(value);\n }\n protected override subscribe(notify: () => void): () => void {\n const atom = this.props.atom;\n const unsubscribe = atom.subscribe(notify);\n const dispose = effect(() => {\n atom.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n }\n}\nexport function setAtom<T>(atom: Atom<T>, value: T): void {\n atom.set(value);\n}\n"],"names":["AtomValue","Observer","props","value","notify","atom","unsubscribe","dispose","effect","setAtom"],"mappings":"mFASO,OAAMA,UAAqBC,EACb,OAAOC,CAAwB,CAAE,CAClD,OAAOA,EAAM,IAAI,AACnB,CACmB,MAAU,CAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAC5B,CACmB,KAAKC,CAAQ,CAAe,CAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA,EAC7B,CACmB,UAAUC,CAAkB,CAAc,CAC3D,IAAMC,EAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CACtBC,EAAcD,EAAK,SAAS,CAACD,GAC7BG,EAAUC,EAAO,KACrBH,EAAK,GAAG,EACV,GACA,MAAO,KACLC,IACAC,GACF,CACF,CACF,CACO,SAASE,EAAWJ,CAAa,CAAEF,CAAQ,EAChDE,EAAK,GAAG,CAACF,EACX,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_modules__={q(e,_,r){r.d(_,{SignalValue:()=>u});let t=require("inferno"),s=require("@slux/core");class c extends t.Component{#e;#_;equal(e,_){return Object.is(e,_)}#r=()=>{let e=this.read();this.equal(this.#_,e)||(this.#_=e,this.forceUpdate())};#t(){this.#e=this.subscribe(this.#r),this.#r()}componentDidMount(){this.#t()}componentDidUpdate(e){this.source(e)!==this.source(this.props)&&(this.#e?.(),this.#t())}componentWillUnmount(){this.#e?.()}render(){return this.#_=this.read(),this.view(this.#_)}}class u extends c{#s=!1;componentDidMount(){this.#s=!0,super.componentDidMount()}source(e){return e.source}read(){let e=this.context.sluxScope;return!this.#s&&e?e.get(this.props.source):this.props.source.get()}view(e){return this.props.children(e)}subscribe(e){let _=this.props.source,r=_.subscribe(e),t=(0,s.effect)(()=>{_.get()});return()=>{r(),t()}}}}},__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__.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__("q");class _ extends e.SignalValue{}__webpack_require__.d(__webpack_exports__,{},{FluxValue:_})})(),exports.FluxValue=__webpack_exports__.FluxValue,__webpack_exports__)-1===["FluxValue"].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":["../src/observer.ts","../src/index.ts","webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/flux.ts"],"sourcesContent":["import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\n\nexport abstract class Observer<Props, Value> extends Component<Props> {\n #unsubscribe: (() => void) | undefined;\n #value!: Value;\n protected abstract read(): Value;\n protected abstract subscribe(notify: () => void): () => void;\n protected abstract source(props: Props): unknown;\n protected abstract view(value: Value): InfernoNode;\n protected equal(previous: Value, next: Value): boolean {\n return Object.is(previous, next);\n }\n #check = () => {\n const next = this.read();\n if (!this.equal(this.#value, next)) {\n this.#value = next;\n this.forceUpdate();\n }\n };\n #connect() {\n this.#unsubscribe = this.subscribe(this.#check);\n this.#check();\n }\n override componentDidMount() {\n this.#connect();\n }\n override componentDidUpdate(previous: Props) {\n if (this.source(previous) !== this.source(this.props)) {\n this.#unsubscribe?.();\n this.#connect();\n }\n }\n override componentWillUnmount() {\n this.#unsubscribe?.();\n }\n override render(): InfernoNode {\n this.#value = this.read();\n return this.view(this.#value);\n }\n}\n","import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\nimport { effect } from \"@slux/core\";\nimport type { Scope, Subscribable } from \"@slux/core\";\nimport { Observer } from \"./observer.js\";\n\nexport type ScopeContext = { sluxScope?: Scope };\nexport type ScopeProviderProps = { scope: Scope; children?: InfernoNode };\nexport class ScopeProvider extends Component<ScopeProviderProps> {\n override getChildContext(): ScopeContext {\n return { sluxScope: this.props.scope };\n }\n override render(): InfernoNode {\n return this.props.children;\n }\n}\nexport function getScope(context: ScopeContext): Scope | undefined {\n return context.sluxScope;\n}\nexport type SignalValueProps<T> = {\n source: Subscribable<T>;\n children: (value: T) => InfernoNode;\n};\nexport class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {\n #mounted = false;\n override componentDidMount() {\n this.#mounted = true;\n super.componentDidMount();\n }\n protected override source(props: Props) {\n return props.source;\n }\n protected override read(): T {\n const scope = getScope(this.context as ScopeContext);\n return !this.#mounted && scope ? scope.get(this.props.source) : this.props.source.get();\n }\n protected override view(value: T): InfernoNode {\n return (this.props.children as (value: T) => InfernoNode)(value);\n }\n protected override subscribe(notify: () => void): () => void {\n const source = this.props.source;\n const unsubscribe = source.subscribe(notify);\n const dispose = effect(() => {\n source.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n }\n}\nexport { createAutoImportApis } from \"./auto-import-api.js\";\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 { FluxStore } from \"@slux/flux\";\nimport type { InfernoNode } from \"inferno\";\nimport { SignalValue } from \"./index.js\";\n\nexport type FluxValueProps<State, Action extends { type: string }> = {\n source: FluxStore<State, Action>;\n children: (value: State) => InfernoNode;\n};\n\nexport class FluxValue<State, Action extends { type: string }> extends SignalValue<State, FluxValueProps<State, Action>> {}\n"],"names":["Observer","Component","previous","next","Object","SignalValue","props","scope","context","value","notify","source","unsubscribe","dispose","effect","__webpack_require__","e","Symbol","FluxValue"],"mappings":"2UAGO,OAAeA,UAA+BC,EAAAA,SAASA,CAC5D,EAAY,AAA2B,AACvC,GAAM,AAAS,AAKL,OAAMC,CAAe,CAAEC,CAAW,CAAW,CACrD,OAAOC,OAAO,EAAE,CAACF,EAAUC,EAC7B,CACA,EAAM,CAAG,KACP,IAAMA,EAAO,IAAI,CAAC,IAAI,GACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAM,CAAEA,KAC3B,IAAI,CAAC,EAAM,CAAGA,EACd,IAAI,CAAC,WAAW,GAEpB,CAAE,AACF,GAAQ,GACN,IAAI,CAAC,EAAY,CAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAM,EAC9C,IAAI,CAAC,EAAM,EACb,CACS,mBAAoB,CAC3B,IAAI,CAAC,EAAQ,EACf,CACS,mBAAmBD,CAAe,CAAE,CACvC,IAAI,CAAC,MAAM,CAACA,KAAc,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAClD,IAAI,CAAC,EAAY,KACjB,IAAI,CAAC,EAAQ,GAEjB,CACS,sBAAuB,CAC9B,IAAI,CAAC,EAAY,IACnB,CACS,QAAsB,CAE7B,OADA,IAAI,CAAC,EAAM,CAAG,IAAI,CAAC,IAAI,GAChB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAM,CAC9B,CACF,CCjBO,MAAMG,UAAgFL,EAC3F,EAAQ,CAAG,EAAM,AACR,oBAAoB,CAC3B,IAAI,CAAC,EAAQ,CAAG,GAChB,KAAK,CAAC,mBACR,CACmB,OAAOM,CAAY,CAAE,CACtC,OAAOA,EAAM,MAAM,AACrB,CACmB,MAAU,CAC3B,IAAMC,EAhBDC,AAgBkB,IAAI,CAAC,OAAO,CAhBtB,SAAS,CAiBtB,MAAO,CAAC,IAAI,CAAC,EAAQ,EAAID,EAAQA,EAAM,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EACvF,CACmB,KAAKE,CAAQ,CAAe,CAC7C,OAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAA+BA,EAC5D,CACmB,UAAUC,CAAkB,CAAc,CAC3D,IAAMC,EAAS,IAAI,CAAC,KAAK,CAAC,MAAM,CAC1BC,EAAcD,EAAO,SAAS,CAACD,GAC/BG,EAAUC,AAAAA,GAAAA,EAAAA,MAAAA,AAAAA,EAAO,KACrBH,EAAO,GAAG,EACZ,GACA,MAAO,KACLC,IACAC,GACF,CACF,CACF,C,wPClDAE,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,IACtEZ,OAAO,cAAc,CAACY,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,IAAUX,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAK,GCClFW,oBAAoB,CAAC,CAAG,AAACC,IACrB,AAAkB,IAAlB,OAAOC,QAA0BA,OAAO,WAAW,EACrDb,OAAO,cAAc,CAACY,EAASC,OAAO,WAAW,CAAE,CAAE,MAAO,QAAS,GAEtEb,OAAO,cAAc,CAACY,EAAS,aAAc,CAAE,MAAO,EAAK,EAC5D,E,+HCGO,OAAME,UAA0Db,EAAAA,WAAWA,CAAwC,C"}
|
package/dist/flux.d.cts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Component } from 'inferno';
|
|
2
|
+
import type { FluxStore } from '@slux/flux';
|
|
3
|
+
import type { InfernoNode } from 'inferno';
|
|
4
|
+
import type { Subscribable } from '@slux/core';
|
|
5
|
+
|
|
6
|
+
export declare class FluxValue<State, Action extends {
|
|
7
|
+
type: string;
|
|
8
|
+
}> extends SignalValue<State, FluxValueProps<State, Action>> {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export declare type FluxValueProps<State, Action extends {
|
|
12
|
+
type: string;
|
|
13
|
+
}> = {
|
|
14
|
+
source: FluxStore<State, Action>;
|
|
15
|
+
children: (value: State) => InfernoNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare abstract class Observer<Props, Value> extends Component<Props> {
|
|
19
|
+
#private;
|
|
20
|
+
protected abstract read(): Value;
|
|
21
|
+
protected abstract subscribe(notify: () => void): () => void;
|
|
22
|
+
protected abstract source(props: Props): unknown;
|
|
23
|
+
protected abstract view(value: Value): InfernoNode;
|
|
24
|
+
protected equal(previous: Value, next: Value): boolean;
|
|
25
|
+
componentDidMount(): void;
|
|
26
|
+
componentDidUpdate(previous: Props): void;
|
|
27
|
+
componentWillUnmount(): void;
|
|
28
|
+
render(): InfernoNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {
|
|
32
|
+
#private;
|
|
33
|
+
componentDidMount(): void;
|
|
34
|
+
protected source(props: Props): Subscribable<T>;
|
|
35
|
+
protected read(): T;
|
|
36
|
+
protected view(value: T): InfernoNode;
|
|
37
|
+
protected subscribe(notify: () => void): () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare type SignalValueProps<T> = {
|
|
41
|
+
source: Subscribable<T>;
|
|
42
|
+
children: (value: T) => InfernoNode;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { }
|
package/dist/flux.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Component } from 'inferno';
|
|
2
|
+
import type { FluxStore } from '@slux/flux';
|
|
3
|
+
import type { InfernoNode } from 'inferno';
|
|
4
|
+
import type { Subscribable } from '@slux/core';
|
|
5
|
+
|
|
6
|
+
export declare class FluxValue<State, Action extends {
|
|
7
|
+
type: string;
|
|
8
|
+
}> extends SignalValue<State, FluxValueProps<State, Action>> {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export declare type FluxValueProps<State, Action extends {
|
|
12
|
+
type: string;
|
|
13
|
+
}> = {
|
|
14
|
+
source: FluxStore<State, Action>;
|
|
15
|
+
children: (value: State) => InfernoNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare abstract class Observer<Props, Value> extends Component<Props> {
|
|
19
|
+
#private;
|
|
20
|
+
protected abstract read(): Value;
|
|
21
|
+
protected abstract subscribe(notify: () => void): () => void;
|
|
22
|
+
protected abstract source(props: Props): unknown;
|
|
23
|
+
protected abstract view(value: Value): InfernoNode;
|
|
24
|
+
protected equal(previous: Value, next: Value): boolean;
|
|
25
|
+
componentDidMount(): void;
|
|
26
|
+
componentDidUpdate(previous: Props): void;
|
|
27
|
+
componentWillUnmount(): void;
|
|
28
|
+
render(): InfernoNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {
|
|
32
|
+
#private;
|
|
33
|
+
componentDidMount(): void;
|
|
34
|
+
protected source(props: Props): Subscribable<T>;
|
|
35
|
+
protected read(): T;
|
|
36
|
+
protected view(value: T): InfernoNode;
|
|
37
|
+
protected subscribe(notify: () => void): () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare type SignalValueProps<T> = {
|
|
41
|
+
source: Subscribable<T>;
|
|
42
|
+
children: (value: T) => InfernoNode;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
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 { FluxStore } from \"@slux/flux\";\nimport type { InfernoNode } from \"inferno\";\nimport { SignalValue } from \"./index.js\";\n\nexport type FluxValueProps<State, Action extends { type: string }> = {\n source: FluxStore<State, Action>;\n children: (value: State) => InfernoNode;\n};\n\nexport class FluxValue<State, Action extends { type: string }> extends SignalValue<State, FluxValueProps<State, Action>> {}\n"],"names":["FluxValue","SignalValue"],"mappings":"kDASO,OAAMA,UAA0DC,EAAmD,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__={u(e,r,t){t.d(r,{Y:()=>s});let _=require("@slux/shared"),o=["ScopeProvider","SignalValue","getScope"],s=(e="")=>(0,_.generateBatchAutoImports)([{prefix:e,fromName:"@slux/inferno",imports:o}])}},__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];if(void 0!==r)return r.exports;var t=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](t,t.exports,__webpack_require__),t.exports}__webpack_require__.d=(e,r,t)=>{var _=(r,t)=>{for(var _ in r)__webpack_require__.o(r,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,[t]:r[_]})};_(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__={};for(var __rspack_i in(()=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ScopeProvider:()=>o,SignalValue:()=>c,createAutoImportApis:()=>_.Y,getScope:()=>s});let e=require("inferno"),r=require("@slux/core");class t extends e.Component{#e;#r;equal(e,r){return Object.is(e,r)}#t=()=>{let e=this.read();this.equal(this.#r,e)||(this.#r=e,this.forceUpdate())};#_(){this.#e=this.subscribe(this.#t),this.#t()}componentDidMount(){this.#_()}componentDidUpdate(e){this.source(e)!==this.source(this.props)&&(this.#e?.(),this.#_())}componentWillUnmount(){this.#e?.()}render(){return this.#r=this.read(),this.view(this.#r)}}var _=__webpack_require__("u");class o extends e.Component{getChildContext(){return{sluxScope:this.props.scope}}render(){return this.props.children}}function s(e){return e.sluxScope}class c extends t{#o=!1;componentDidMount(){this.#o=!0,super.componentDidMount()}source(e){return e.source}read(){let e=s(this.context);return!this.#o&&e?e.get(this.props.source):this.props.source.get()}view(e){return this.props.children(e)}subscribe(e){let t=this.props.source,_=t.subscribe(e),o=(0,r.effect)(()=>{t.get()});return()=>{_(),o()}}}})(),exports.ScopeProvider=__webpack_exports__.ScopeProvider,exports.SignalValue=__webpack_exports__.SignalValue,exports.createAutoImportApis=__webpack_exports__.createAutoImportApis,exports.getScope=__webpack_exports__.getScope,__webpack_exports__)-1===["ScopeProvider","SignalValue","createAutoImportApis","getScope"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|