Skip to content

Commit

Permalink
chore: pub 4.1.3 see change log
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasticsoul committed Jan 11, 2024
1 parent 54c22b5 commit 53d5964
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": true,
"fixed": [["helux", "@helux/core", "@helux/hooks", "@helux/hooks-impl", "@helux/types", "@helux/utils"]],
"fixed": [["helux", "@helux/core", "@helux/openinula", "@helux/hooks", "@helux/hooks-impl", "@helux/types", "@helux/utils"]],
"linked": [],
"access": "restricted",
"baseBranch": "master",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "helux",
"version": "4.0.3",
"version": "4.1.2",
"description": "A state engine integrates atom, signal, derive, watch and dep tracking, supports fine-grained responsive updates, it is compatible with all react like libs (including React 18).",
"keywords": [],
"author": {
Expand Down
2 changes: 1 addition & 1 deletion packages/helux-core/src/consts/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { VER as limuVer } from 'limu';

export const VER = '4.1.0';
export const VER = '4.1.2';

export const LIMU_VER = limuVer;

Expand Down
6 changes: 3 additions & 3 deletions packages/helux-core/src/types/api.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
|------------------------------------------------------------------------------------------------
| [email protected].0
| [email protected].2
| A state library core that integrates atom, signal, collection dep, derive and watch,
| it supports all react like frameworks ( including react 18 ).
|------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -68,7 +68,7 @@ import type {
} from './base';

export declare const cst: {
VER: '4.1.0';
VER: '4.1.2';
LIMU_VER: string;
EVENT_NAME: {
ON_DATA_CHANGED: 'ON_DATA_CHANGED';
Expand Down Expand Up @@ -261,7 +261,7 @@ export function watchEffect(
* });
* ```
*/
export function useAtom<T = any>(
export function useAtom<T extends SharedState = any>(
sharedState: T,
options?: IUseSharedStateOptions<T>,
): [
Expand Down
4 changes: 1 addition & 3 deletions packages/helux-openinula/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## desc

[helux](https://heluxjs.github.io/helux),集原子,信号、依赖追踪为一体,支持细粒度响应式更新的状态引擎(兼容所有类react库,包括react18
[helux](https://heluxjs.github.io/helux),集原子,信号、依赖追踪为一体,支持细粒度响应式更新的状态引擎(兼容所有类 react 库,包括 react18

### install

Expand All @@ -15,5 +15,3 @@ npm i @helux/openinula
### online demo

https://codesandbox.io/p/devbox/helux-openinula-66gfj2


6 changes: 3 additions & 3 deletions packages/helux-openinula/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { initHeluxContext } from "@helux/core";
import * as React from "openinula";
import { initHeluxContext } from '@helux/core';
import * as React from 'openinula';

console.log(React);

const api = initHeluxContext({
heluxCtxKey: "__HELUX_openinula__",
heluxCtxKey: '__HELUX_openinula__',
reactLib: React,
});

Expand Down
20 changes: 14 additions & 6 deletions packages/helux/__tests__/helux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ window.alert = () => {};
// Learn more at https://reactjs.org/link/wrap-tests-with-act
const api = initHeluxContext({ heluxCtxKey: '__HELUX__', reactLib: React, act });

// 导出 core 所有方法,类型由 index.d.ts 提供(见 package.json的 types 配置)
// 导出 core 所有方法,类型由 index.d.ts 提供(见 package.json的 types 配置)
export const {
atom,
Expand All @@ -20,15 +19,21 @@ export const {
// derive api
derive,
deriveDict,
defineDeriveTask,
defineDeriveFnItem,
runDerive,
runDeriveTask,
// watch api
watch,
watchEffect,
// hooks api
useAtom,
useAtomX,
useReactive,
useReactiveX,
useDerived,
useWatch,
useWatchEffect,
useGlobalId,
useService,
useOnEvent,
Expand All @@ -40,7 +45,7 @@ export const {
useStable,
useObject,
useLocalForceUpdate,
useAtomForceUpdate,
useGlobalForceUpdate,
// action api
action,
// signal api
Expand All @@ -53,6 +58,7 @@ export const {
mutateDict,
runMutate,
runMutateTask,
defineMutateFnItem,
// sync api
sync,
syncer,
Expand All @@ -62,13 +68,18 @@ export const {
// emit api
emit,
on,
// init api
init,
// util api
reactiveDesc,
flush,
isAtom,
isSharedState,
isDerivedAtom,
isDerivedResult,
storeSrv,
shallowCompare,
markRaw,
isDiff,
produce,
getMutateLoading,
Expand All @@ -79,10 +90,7 @@ export const {
getAtom,
addMiddleware,
addPlugin,
EVENT_NAME,
RECORD_LOADING,
VER,
LIMU_VER,
cst,
} = api;

export const useShared = useAtom;
Expand Down
15 changes: 11 additions & 4 deletions packages/helux/__tests__/hook-options/deps.make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ interface IOptions {
const getRootValDep = (rootValKey) => [rootValKey];

const getArrAndIndexDep = (rootValKey) => [
getDepKey(rootValKey, 'extra.list'),
getDepKey(rootValKey, 'extra.list.length'),
getDepKey(rootValKey, 'extra.list.0'),
getDepKey(rootValKey, 'extra.list.1'),
];

const getArrAndIndexDepNoLen = (rootValKey) => [
getDepKey(rootValKey, 'extra.list'),
getDepKey(rootValKey, 'extra.list.0'),
getDepKey(rootValKey, 'extra.list.1'),
Expand All @@ -28,8 +35,8 @@ const getAgeNameDep = (rootValKey) => [getDepKey(rootValKey, 'info.age'), getDep

const getDescDep = (rootValKey) => [getDepKey(rootValKey, 'desc')];

export function makeTest(options: { label: string; atom: typeof atom; useAtom: typeof useAtom }) {
const { label, atom, useAtom } = options;
export function makeTest(options: { label: string; atom: typeof atom }) {
const { label, atom } = options;

async function testNotRead(options: IOptions) {
const { getMatchObj, deps } = options;
Expand Down Expand Up @@ -115,7 +122,7 @@ export function makeTest(options: { label: string; atom: typeof atom; useAtom: t

test('read list item by index', async () => {
await testReadListItem({
getMatchObj: getArrAndIndexDep,
getMatchObj: getArrAndIndexDepNoLen,
readArr: (state) => {
const { list } = state.extra;
noop(list[0], list[1]);
Expand Down Expand Up @@ -177,7 +184,7 @@ export function makeTest(options: { label: string; atom: typeof atom; useAtom: t

test('read list item by index', async () => {
await testReadListItem({
getMatchObj: (rootValKey) => getArrAndIndexDep(rootValKey).concat(getDescDep(rootValKey)),
getMatchObj: (rootValKey) => getArrAndIndexDepNoLen(rootValKey).concat(getDescDep(rootValKey)),
deps: (state) => [state.desc],
readArr: (state) => {
const { list } = state.extra;
Expand Down
6 changes: 2 additions & 4 deletions packages/helux/__tests__/hook-options/deps.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { atom, share, useAtom, useShared } from '../helux';
import { atom } from '../helux';
import { makeTest } from './deps.make';

makeTest({ label: 'useAtom', atom, useAtom });

makeTest({ label: 'useShared', atom: share as any, useAtom: useShared as any });
makeTest({ label: 'useAtom', atom });
9 changes: 4 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 53d5964

Please sign in to comment.