Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gez/class-state

Package Overview
Dependencies
Maintainers
0
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gez/class-state - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

6

dist/connect.d.ts

@@ -78,4 +78,8 @@ import { type State, type StateContext } from './create';

/**
* 连接外部的 store,如果没有,则实例化 Store 类作为默认值返回
* @deprecated 请使用 ffiStore
*/
export declare function foreignStore<T extends StoreConstructor>(Store: T, name: string, cacheKey?: string): InstanceType<T> | null;
/**
* 查找一个外部的 Store
*/
export declare function ffiStore<T extends {}>(name: string, cacheKey?: string): T | null;

2

dist/index.d.ts
export { createState, type State } from './create';
export { connectState, foreignStore, type StoreConstructor, type StoreContext, type StoreInstance, type StoreParams, LIFE_CYCLE_CREATED, LIFE_CYCLE_DISPOSE } from './connect';
export { connectState, foreignStore, ffiStore, type StoreConstructor, type StoreContext, type StoreInstance, type StoreParams, LIFE_CYCLE_CREATED, LIFE_CYCLE_DISPOSE } from './connect';

@@ -16,3 +16,3 @@ {

"devDependencies": {
"@gez/lint": "0.0.14",
"@gez/lint": "0.0.15",
"@types/node": "20.12.12",

@@ -28,3 +28,3 @@ "@vitest/coverage-v8": "1.6.0",

},
"version": "0.0.14",
"version": "0.0.15",
"type": "module",

@@ -47,3 +47,3 @@ "private": false,

],
"gitHead": "f77f560628d49db5cc1fed46d181682ada9d3419"
"gitHead": "b2f4fbfc059bb57b451e3afdd4676d00a842d965"
}
import { assert, test } from 'vitest';
import { connectState, foreignStore } from './connect';
import { connectState, ffiStore } from './connect';
import { createState } from './create';

@@ -233,3 +233,3 @@

public get blog() {
return foreignStore(Blog, 'blog');
return ffiStore<Blog>('blog')!;
}

@@ -236,0 +236,0 @@

@@ -215,3 +215,3 @@ /* eslint-disable @typescript-eslint/no-this-alias */

const prevState = connectContext.state;
let result;
let result: unknown;
const nextState = produce(prevState, (draft) => {

@@ -255,3 +255,3 @@ connectContext._drafting = true;

);
let storeState;
let storeState: Record<string, any>;
if (fullPath in state.value) {

@@ -274,3 +274,3 @@ storeState = { ...store, ...state.value[fullPath] };

/**
* 连接外部的 store,如果没有,则实例化 Store 类作为默认值返回
* @deprecated 请使用 ffiStore
*/

@@ -282,2 +282,11 @@ export function foreignStore<T extends StoreConstructor>(

): InstanceType<T> | null {
return ffiStore<InstanceType<T>>(name, cacheKey);
}
/**
* 查找一个外部的 Store
*/
export function ffiStore<T extends {}>(
name: string,
cacheKey?: string
): T | null {
if (!currentStateContext) {

@@ -287,3 +296,3 @@ throw new Error('No state context found');

const fullPath = getFullPath(name, cacheKey);
const storeContext: StoreContext<InstanceType<T>> | null =
const storeContext: StoreContext<T> | null =
currentStateContext.get(fullPath);

@@ -290,0 +299,0 @@ if (storeContext) {

@@ -5,2 +5,3 @@ export { createState, type State } from './create';

foreignStore,
ffiStore,
type StoreConstructor,

@@ -7,0 +8,0 @@ type StoreContext,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc