Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

machinate

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

machinate - npm Package Compare versions

Comparing version
1.1.0
to
1.1.1
+9
src/components/IsActive.js
import React from "react";
import withState from "./withState";
const IsActive = ({ state, children }) => {
const Comp = withState(state, () => children(true), () => children(false));
return <Comp />;
};
export default IsActive;
+1
-1
{
"name": "machinate",
"version": "1.1.0",
"version": "1.1.1",
"description": "practical state management",

@@ -5,0 +5,0 @@ "main": "build/lib.js",

@@ -15,2 +15,6 @@ import React from "react";

if (props.configure) {
props.configure(machine);
}
machine.addListener("force-state", () => {

@@ -48,3 +52,4 @@ this.forced = true;

scheme: PropTypes.object.isRequired,
initial: PropTypes.object.isRequired
initial: PropTypes.object.isRequired,
configure: PropTypes.func
};

@@ -51,0 +56,0 @@

@@ -53,5 +53,7 @@ import React, { Component } from "react";

const { machine: { external } } = this.context;
const ifInactive =
(this.props.ifInactive && this.props.ifInactive()) || null;
const stateInfo = this.getActiveState();
if (!stateInfo) return null;
if (!stateInfo) return ifInactive;

@@ -58,0 +60,0 @@ return (

@@ -6,3 +6,3 @@ import React from "react";

const withState = (stateName, Component) => {
const withState = (stateName, Component, ifInactive) => {
const C = props => {

@@ -13,2 +13,3 @@ const { wrappedComponentRef, ...remainingProps } = props;

of={stateName}
ifInactive={ifInactive}
children={stateComponentProps => (

@@ -15,0 +16,0 @@ <Component

@@ -7,2 +7,3 @@ import Machinate from "./components/Machinate";

import Submachine from "./components/Submachine";
import IsActive from "./components/IsActive";

@@ -16,2 +17,3 @@ import { isTransitionable, createMachine } from "./machine";

Submachine,
IsActive,
isTransitionable,

@@ -18,0 +20,0 @@ createMachine,

@@ -184,3 +184,10 @@ import React from "react";

const fullName = _componentFullName(comp);
return fullName === resolvedDomainName;
return (
fullName ===
resolvedDomainName /*&&
(comp.props.of !== schematicFromName ||
comp.props.of === schematicToName ||
(comp.props.ifInactive && comp.props.of === schematicFromName))
*/
);
});

@@ -291,2 +298,9 @@ comps.forEach(comp => comp.forceUpdate());

const invariant = (condition, message) => {
if (!condition) {
console.error(message);
}
};
const isFunction = v => typeof v === "function";
const createdMachine = {

@@ -310,4 +324,15 @@ getState,

external: fnArgs => (name, promise, fallback = () => {}) =>
isTriggerBlacklisted(name) ? fallback(fnArgs) : promise(fnArgs),
external: fnArgs =>
function(name, promise) {
const fallback = arguments.length === 3 ? arguments[2] : () => {};
invariant(
!!promise && isFunction(promise),
`The argument provided to the external '${name}' must be a function.`
);
invariant(
isFunction(fallback),
`The fallback provided to the external '${name}' must be a function. You may have accidentally triggered the fallback.`
);
return isTriggerBlacklisted(name) ? fallback(fnArgs) : promise(fnArgs);
},
setBlacklist: newBlacklist => {

@@ -314,0 +339,0 @@ blacklist = newBlacklist;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display