@reach/machine
Advanced tools
Comparing version 0.11.2 to 0.12.0
@@ -1,4 +0,5 @@ | ||
/// <reference types="react" /> | ||
import { assign, createMachine, EventObject as MachineEvent, interpret, InterpreterStatus, StateMachine, Typestate } from "@xstate/fsm"; | ||
import { DistributiveOmit } from "@reach/utils"; | ||
import * as React from "react"; | ||
import { assign, createMachine, interpret, InterpreterStatus } from "@xstate/fsm"; | ||
import type { DistributiveOmit } from "@reach/utils"; | ||
import type { EventObject as MachineEvent, StateMachine, Typestate } from "@xstate/fsm"; | ||
/** | ||
@@ -68,3 +69,3 @@ * This `useMachine` works very similiarly to what you get from `@xstate/react` | ||
export declare type MachineService<TC extends object, TE extends MachineEventWithRefs = MachineEventWithRefs> = StateMachine.Service<TC, TE>; | ||
export { InterpreterStatus, MachineEvent, StateMachine }; | ||
export { createMachine, assign, interpret }; | ||
export type { MachineEvent, StateMachine }; | ||
export { InterpreterStatus, createMachine, assign, interpret }; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var react = require('react'); | ||
var React = require('react'); | ||
var fsm = require('@xstate/fsm'); | ||
@@ -61,13 +61,13 @@ var utils = require('@reach/utils'); | ||
// dynamic initial state values based on props. | ||
var machineRef = react.useRef(initialMachine); | ||
var machineRef = React.useRef(initialMachine); | ||
var service = utils.useConstant(function () { | ||
return fsm.interpret(machineRef.current).start(); | ||
}); | ||
var lastEventType = react.useRef(null); | ||
var lastEventType = React.useRef(null); | ||
var _useState = react.useState(function () { | ||
var _React$useState = React.useState(function () { | ||
return getServiceState(service); | ||
}), | ||
state = _useState[0], | ||
setState = _useState[1]; // This function reference will change on every render if we just pass on | ||
state = _React$useState[0], | ||
setState = _React$useState[1]; // This function reference will change on every render if we just pass on | ||
// current.matches, but it shouldn't change unless the current value is | ||
@@ -81,3 +81,3 @@ // updated. This was causing some lagginess when profiling in Listbox but | ||
var send = react.useCallback(function (rawEvent) { | ||
var send = React.useCallback(function (rawEvent) { | ||
var event = utils.isString(rawEvent) ? { | ||
@@ -105,3 +105,3 @@ type: rawEvent | ||
[DEBUG]); | ||
react.useEffect(function () { | ||
React.useEffect(function () { | ||
service.subscribe(function setStateIfChanged(newState) { | ||
@@ -116,3 +116,3 @@ if (newState.changed) { | ||
}, [service]); | ||
react.useEffect(function () { | ||
React.useEffect(function () { | ||
{ | ||
@@ -129,3 +129,3 @@ if (DEBUG && state.changed) { | ||
var memoizedState = react.useMemo(function () { | ||
var memoizedState = React.useMemo(function () { | ||
return _extends({}, state, { | ||
@@ -173,3 +173,3 @@ matches: function matches(value) { | ||
}); | ||
} // Export types and functions from xstate/fsm | ||
} | ||
@@ -176,0 +176,0 @@ Object.defineProperty(exports, 'InterpreterStatus', { |
@@ -63,7 +63,7 @@ import { useRef, useState, useCallback, useEffect, useMemo } from 'react'; | ||
var _useState = useState(function () { | ||
var _React$useState = useState(function () { | ||
return getServiceState(service); | ||
}), | ||
state = _useState[0], | ||
setState = _useState[1]; // This function reference will change on every render if we just pass on | ||
state = _React$useState[0], | ||
setState = _React$useState[1]; // This function reference will change on every render if we just pass on | ||
// current.matches, but it shouldn't change unless the current value is | ||
@@ -165,5 +165,5 @@ // updated. This was causing some lagginess when profiling in Listbox but | ||
}); | ||
} // Export types and functions from xstate/fsm | ||
} | ||
export { unwrapRefs, useCreateMachine, useMachine }; | ||
//# sourceMappingURL=machine.esm.js.map |
{ | ||
"name": "@reach/machine", | ||
"version": "0.11.2", | ||
"version": "0.12.0", | ||
"description": "State machine utilities for the Reach UI library.", | ||
@@ -16,3 +16,3 @@ "author": "React Training <hello@reacttraining.com>", | ||
"dependencies": { | ||
"@reach/utils": "0.11.2", | ||
"@reach/utils": "0.12.0", | ||
"@xstate/fsm": "1.4.0", | ||
@@ -32,3 +32,3 @@ "tslib": "^2.0.0" | ||
], | ||
"gitHead": "2aa6f03c5eed8c2b7525a29db1c69fe6bc540e5d" | ||
"gitHead": "09eeccda6e4597d21545982c53db5c42beddce6b" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50669
414
+ Added@reach/utils@0.12.0(transitive)
- Removed@reach/utils@0.11.2(transitive)
Updated@reach/utils@0.12.0