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

@xstate/react

Package Overview
Dependencies
Maintainers
3
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xstate/react - npm Package Compare versions

Comparing version 4.0.0-beta.5 to 4.0.0-beta.6

12

dist/declarations/src/createActorContext.d.ts
import * as React from 'react';
import { ActorRefFrom, AnyStateMachine, SnapshotFrom, InterpreterOptions, Observer, StateFrom, AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, StateMachine } from 'xstate';
import { ActorRefFrom, AnyStateMachine, SnapshotFrom, InterpreterOptions, Observer, AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, StateMachine, AnyActorLogic } from 'xstate';
type ToMachinesWithProvidedImplementations<TMachine extends AnyStateMachine> = TMachine extends StateMachine<infer TContext, infer TEvent, infer TAction, infer TActorMap, infer TResolvedTypesMeta> ? StateMachine<TContext, TEvent, TAction, TActorMap, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta> : never;
export declare function createActorContext<TMachine extends AnyStateMachine>(machine: TMachine, interpreterOptions?: InterpreterOptions<TMachine>, observerOrListener?: Observer<StateFrom<TMachine>> | ((value: StateFrom<TMachine>) => void)): {
export declare function createActorContext<TMachine extends AnyActorLogic>(actorLogic: TMachine, interpreterOptions?: InterpreterOptions<TMachine>, observerOrListener?: Observer<SnapshotFrom<TMachine>> | ((value: SnapshotFrom<TMachine>) => void)): {
useSelector: <T>(selector: (snapshot: SnapshotFrom<TMachine>) => T, compare?: (a: T, b: T) => boolean) => T;

@@ -9,8 +9,10 @@ useActorRef: () => ActorRefFrom<TMachine>;

children: React.ReactNode;
} & (AreAllImplementationsAssumedToBeProvided<TMachine['__TResolvedTypesMeta']> extends true ? {
machine?: TMachine;
} & (TMachine extends AnyStateMachine ? AreAllImplementationsAssumedToBeProvided<TMachine['__TResolvedTypesMeta']> extends true ? {
logic?: TMachine;
} : {
machine: ToMachinesWithProvidedImplementations<TMachine>;
logic: ToMachinesWithProvidedImplementations<TMachine>;
} : {
logic?: TMachine;
})) => React.ReactElement<any, any>;
};
export {};

@@ -1,6 +0,2 @@

import { ActorRefFrom, AnyActorBehavior, InterpreterOptions, SnapshotFrom } from 'xstate';
export declare function useActor<TBehavior extends AnyActorBehavior>(behavior: TBehavior, options?: InterpreterOptions<TBehavior>): [
SnapshotFrom<TBehavior>,
ActorRefFrom<TBehavior>['send'],
ActorRefFrom<TBehavior>
];
import { ActorRefFrom, AnyActorLogic, InterpreterOptions, SnapshotFrom } from 'xstate';
export declare function useActor<TLogic extends AnyActorLogic>(logic: TLogic, options?: InterpreterOptions<TLogic>): [SnapshotFrom<TLogic>, ActorRefFrom<TLogic>['send'], ActorRefFrom<TLogic>];

@@ -1,14 +0,14 @@

import { AnyActorBehavior, AnyInterpreter, AnyStateMachine, AreAllImplementationsAssumedToBeProvided, InternalMachineImplementations, ActorRefFrom, InterpreterOptions, Observer, StateFrom, SnapshotFrom } from 'xstate';
export declare function useIdleInterpreter(machine: AnyActorBehavior, options: Partial<InterpreterOptions<AnyActorBehavior>>): AnyInterpreter;
type RestParams<TBehavior extends AnyActorBehavior> = TBehavior extends AnyStateMachine ? AreAllImplementationsAssumedToBeProvided<TBehavior['__TResolvedTypesMeta']> extends false ? [
options: InterpreterOptions<TBehavior> & InternalMachineImplementations<TBehavior['__TContext'], TBehavior['__TEvent'], TBehavior['__TResolvedTypesMeta'], true>,
observerOrListener?: Observer<StateFrom<TBehavior>> | ((value: StateFrom<TBehavior>) => void)
import { AnyActorLogic, AnyInterpreter, AnyStateMachine, AreAllImplementationsAssumedToBeProvided, InternalMachineImplementations, ActorRefFrom, InterpreterOptions, Observer, StateFrom, SnapshotFrom } from 'xstate';
export declare function useIdleInterpreter(machine: AnyActorLogic, options: Partial<InterpreterOptions<AnyActorLogic>>): AnyInterpreter;
type RestParams<TLogic extends AnyActorLogic> = TLogic extends AnyStateMachine ? AreAllImplementationsAssumedToBeProvided<TLogic['__TResolvedTypesMeta']> extends false ? [
options: InterpreterOptions<TLogic> & InternalMachineImplementations<TLogic['__TContext'], TLogic['__TEvent'], TLogic['__TResolvedTypesMeta'], true>,
observerOrListener?: Observer<StateFrom<TLogic>> | ((value: StateFrom<TLogic>) => void)
] : [
options?: InterpreterOptions<TBehavior> & InternalMachineImplementations<TBehavior['__TContext'], TBehavior['__TEvent'], TBehavior['__TResolvedTypesMeta']>,
observerOrListener?: Observer<StateFrom<TBehavior>> | ((value: StateFrom<TBehavior>) => void)
options?: InterpreterOptions<TLogic> & InternalMachineImplementations<TLogic['__TContext'], TLogic['__TEvent'], TLogic['__TResolvedTypesMeta']>,
observerOrListener?: Observer<StateFrom<TLogic>> | ((value: StateFrom<TLogic>) => void)
] : [
options?: InterpreterOptions<TBehavior>,
observerOrListener?: Observer<SnapshotFrom<TBehavior>> | ((value: SnapshotFrom<TBehavior>) => void)
options?: InterpreterOptions<TLogic>,
observerOrListener?: Observer<SnapshotFrom<TLogic>> | ((value: SnapshotFrom<TLogic>) => void)
];
export declare function useActorRef<TBehavior extends AnyActorBehavior>(machine: TBehavior, ...[options, observerOrListener]: RestParams<TBehavior>): ActorRefFrom<TBehavior>;
export declare function useActorRef<TLogic extends AnyActorLogic>(machine: TLogic, ...[options, observerOrListener]: RestParams<TLogic>): ActorRefFrom<TLogic>;
export {};

@@ -42,3 +42,3 @@ 'use strict';

useIsomorphicLayoutEffect__default["default"](() => {
actorRef.behavior.options = machine.options;
actorRef.logic.options = machine.options;
});

@@ -75,4 +75,4 @@ return actorRef;

};
function useActor(behavior, options = {}) {
const actorRef = useIdleInterpreter(behavior, options);
function useActor(logic, options = {}) {
const actorRef = useIdleInterpreter(logic, options);
const getSnapshot = React.useCallback(() => {

@@ -138,3 +138,3 @@ return actorRef.getSnapshot();

function createActorContext(machine, interpreterOptions, observerOrListener) {
function createActorContext(actorLogic, interpreterOptions, observerOrListener) {
const ReactContext = /*#__PURE__*/React__namespace.createContext(null);

@@ -144,5 +144,9 @@ const OriginalProvider = ReactContext.Provider;

children,
machine: providedMachine = machine
logic: providedLogic = actorLogic,
machine
}) {
const actor = useActorRef(providedMachine, interpreterOptions, observerOrListener);
if (machine) {
throw new Error(`The "machine" prop has been deprecated. Please use "logic" instead.`);
}
const actor = useActorRef(providedLogic, interpreterOptions, observerOrListener);
return /*#__PURE__*/React__namespace.createElement(OriginalProvider, {

@@ -153,3 +157,5 @@ value: actor,

}
Provider.displayName = `ActorProvider(${machine.id})`;
// TODO: add properties to actor ref to make more descriptive
Provider.displayName = `ActorProvider`;
function useContext() {

@@ -156,0 +162,0 @@ const actor = React__namespace.useContext(ReactContext);

@@ -48,3 +48,3 @@ 'use strict';

useIsomorphicLayoutEffect__default["default"](() => {
actorRef.behavior.options = machine.options;
actorRef.logic.options = machine.options;
});

@@ -81,7 +81,7 @@ return actorRef;

};
function useActor(behavior, options = {}) {
if (actors.isActorRef(behavior)) {
function useActor(logic, options = {}) {
if (actors.isActorRef(logic)) {
throw new Error(`useActor() expects actor logic (e.g. a machine), but received an ActorRef. Use the useSelector(actorRef, ...) hook instead to read the ActorRef's snapshot.`);
}
const actorRef = useIdleInterpreter(behavior, options);
const actorRef = useIdleInterpreter(logic, options);
const getSnapshot = React.useCallback(() => {

@@ -147,3 +147,3 @@ return actorRef.getSnapshot();

function createActorContext(machine, interpreterOptions, observerOrListener) {
function createActorContext(actorLogic, interpreterOptions, observerOrListener) {
const ReactContext = /*#__PURE__*/React__namespace.createContext(null);

@@ -153,5 +153,9 @@ const OriginalProvider = ReactContext.Provider;

children,
machine: providedMachine = machine
logic: providedLogic = actorLogic,
machine
}) {
const actor = useActorRef(providedMachine, interpreterOptions, observerOrListener);
if (machine) {
throw new Error(`The "machine" prop has been deprecated. Please use "logic" instead.`);
}
const actor = useActorRef(providedLogic, interpreterOptions, observerOrListener);
return /*#__PURE__*/React__namespace.createElement(OriginalProvider, {

@@ -162,3 +166,5 @@ value: actor,

}
Provider.displayName = `ActorProvider(${machine.id})`;
// TODO: add properties to actor ref to make more descriptive
Provider.displayName = `ActorProvider`;
function useContext() {

@@ -165,0 +171,0 @@ const actor = React__namespace.useContext(ReactContext);

@@ -22,3 +22,3 @@ import * as React from 'react';

useIsomorphicLayoutEffect(() => {
actorRef.behavior.options = machine.options;
actorRef.logic.options = machine.options;
});

@@ -55,7 +55,7 @@ return actorRef;

};
function useActor(behavior, options = {}) {
if (isActorRef(behavior)) {
function useActor(logic, options = {}) {
if (isActorRef(logic)) {
throw new Error(`useActor() expects actor logic (e.g. a machine), but received an ActorRef. Use the useSelector(actorRef, ...) hook instead to read the ActorRef's snapshot.`);
}
const actorRef = useIdleInterpreter(behavior, options);
const actorRef = useIdleInterpreter(logic, options);
const getSnapshot = useCallback(() => {

@@ -121,3 +121,3 @@ return actorRef.getSnapshot();

function createActorContext(machine, interpreterOptions, observerOrListener) {
function createActorContext(actorLogic, interpreterOptions, observerOrListener) {
const ReactContext = /*#__PURE__*/React.createContext(null);

@@ -127,5 +127,9 @@ const OriginalProvider = ReactContext.Provider;

children,
machine: providedMachine = machine
logic: providedLogic = actorLogic,
machine
}) {
const actor = useActorRef(providedMachine, interpreterOptions, observerOrListener);
if (machine) {
throw new Error(`The "machine" prop has been deprecated. Please use "logic" instead.`);
}
const actor = useActorRef(providedLogic, interpreterOptions, observerOrListener);
return /*#__PURE__*/React.createElement(OriginalProvider, {

@@ -136,3 +140,5 @@ value: actor,

}
Provider.displayName = `ActorProvider(${machine.id})`;
// TODO: add properties to actor ref to make more descriptive
Provider.displayName = `ActorProvider`;
function useContext() {

@@ -139,0 +145,0 @@ const actor = React.useContext(ReactContext);

@@ -16,3 +16,3 @@ import * as React from 'react';

useIsomorphicLayoutEffect(() => {
actorRef.behavior.options = machine.options;
actorRef.logic.options = machine.options;
});

@@ -49,4 +49,4 @@ return actorRef;

};
function useActor(behavior, options = {}) {
const actorRef = useIdleInterpreter(behavior, options);
function useActor(logic, options = {}) {
const actorRef = useIdleInterpreter(logic, options);
const getSnapshot = useCallback(() => {

@@ -112,3 +112,3 @@ return actorRef.getSnapshot();

function createActorContext(machine, interpreterOptions, observerOrListener) {
function createActorContext(actorLogic, interpreterOptions, observerOrListener) {
const ReactContext = /*#__PURE__*/React.createContext(null);

@@ -118,5 +118,9 @@ const OriginalProvider = ReactContext.Provider;

children,
machine: providedMachine = machine
logic: providedLogic = actorLogic,
machine
}) {
const actor = useActorRef(providedMachine, interpreterOptions, observerOrListener);
if (machine) {
throw new Error(`The "machine" prop has been deprecated. Please use "logic" instead.`);
}
const actor = useActorRef(providedLogic, interpreterOptions, observerOrListener);
return /*#__PURE__*/React.createElement(OriginalProvider, {

@@ -127,3 +131,5 @@ value: actor,

}
Provider.displayName = `ActorProvider(${machine.id})`;
// TODO: add properties to actor ref to make more descriptive
Provider.displayName = `ActorProvider`;
function useContext() {

@@ -130,0 +136,0 @@ const actor = React.useContext(ReactContext);

{
"name": "@xstate/react",
"version": "4.0.0-beta.5",
"version": "4.0.0-beta.6",
"description": "XState tools for React",

@@ -74,3 +74,3 @@ "keywords": [

"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"xstate": "^5.0.0-beta.13"
"xstate": "^5.0.0-beta.14"
},

@@ -100,3 +100,3 @@ "peerDependenciesMeta": {

"react-dom": "^18.0.0",
"xstate": "5.0.0-beta.13"
"xstate": "5.0.0-beta.14"
},

@@ -103,0 +103,0 @@ "preconstruct": {

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