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

@zag-js/core

Package Overview
Dependencies
Maintainers
1
Versions
1024
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/core - npm Package Compare versions

Comparing version
1.37.0
to
1.38.0
+9
-1
dist/state.js

@@ -46,2 +46,5 @@ "use strict";

}
function isChildTarget(value) {
return value.startsWith(STATE_DELIMITER);
}
function stripAbsolutePrefix(value) {

@@ -145,5 +148,9 @@ return isExplicitAbsoluteStatePath(value) ? value.slice(ABSOLUTE_PREFIX.length) : value;

}
if (isChildTarget(stateValue) && source) {
const childPath = appendStatePath(source, stateValue.slice(1));
return resolveAbsoluteStateValue(machine, childPath);
}
if (!isAbsoluteStatePath(stateValue) && source) {
const sourceSegments = toSegments(source);
for (let index = sourceSegments.length; index >= 1; index--) {
for (let index = sourceSegments.length - 1; index >= 1; index--) {
const base = sourceSegments.slice(0, index).join(STATE_DELIMITER);

@@ -153,2 +160,3 @@ const candidate = appendStatePath(base, stateValue);

}
if (hasStatePath(machine, stateValue)) return resolveAbsoluteStateValue(machine, stateValue);
}

@@ -155,0 +163,0 @@ return resolveAbsoluteStateValue(machine, stateValue);

@@ -15,2 +15,5 @@ // src/state.ts

}
function isChildTarget(value) {
return value.startsWith(STATE_DELIMITER);
}
function stripAbsolutePrefix(value) {

@@ -114,5 +117,9 @@ return isExplicitAbsoluteStatePath(value) ? value.slice(ABSOLUTE_PREFIX.length) : value;

}
if (isChildTarget(stateValue) && source) {
const childPath = appendStatePath(source, stateValue.slice(1));
return resolveAbsoluteStateValue(machine, childPath);
}
if (!isAbsoluteStatePath(stateValue) && source) {
const sourceSegments = toSegments(source);
for (let index = sourceSegments.length; index >= 1; index--) {
for (let index = sourceSegments.length - 1; index >= 1; index--) {
const base = sourceSegments.slice(0, index).join(STATE_DELIMITER);

@@ -122,2 +129,3 @@ const candidate = appendStatePath(base, stateValue);

}
if (hasStatePath(machine, stateValue)) return resolveAbsoluteStateValue(machine, stateValue);
}

@@ -124,0 +132,0 @@ return resolveAbsoluteStateValue(machine, stateValue);

+3
-2

@@ -111,6 +111,7 @@ type Dict = Record<string, any>;

type AncestorPaths<S extends string> = S | (ParentPath<S> extends never ? never : AncestorPaths<ParentPath<S>>);
type RelativeStateTarget<S extends string, Source extends string> = ChildStateKey<S, AncestorPaths<Source>>;
type StateIdTarget = `#${string}`;
type SiblingStateTarget<S extends string, Source extends string> = TopLevelState<S> | ChildStateKey<S, Exclude<AncestorPaths<Source>, Source>>;
type ChildStateTarget<S extends string, Source extends string> = `.${ChildStateKey<S, Source>}`;
interface Transition<T extends Dict, Source extends string | undefined = string | undefined> {
target?: T["state"] | StateIdTarget | (Source extends string ? RelativeStateTarget<T["state"], Source> : never) | undefined;
target?: T["state"] | StateIdTarget | (Source extends string ? SiblingStateTarget<T["state"], Source> : never) | (Source extends string ? ChildStateTarget<T["state"], Source> : never) | undefined;
actions?: T["action"][] | undefined;

@@ -117,0 +118,0 @@ guard?: T["guard"] | GuardFn<T> | undefined;

@@ -111,6 +111,7 @@ type Dict = Record<string, any>;

type AncestorPaths<S extends string> = S | (ParentPath<S> extends never ? never : AncestorPaths<ParentPath<S>>);
type RelativeStateTarget<S extends string, Source extends string> = ChildStateKey<S, AncestorPaths<Source>>;
type StateIdTarget = `#${string}`;
type SiblingStateTarget<S extends string, Source extends string> = TopLevelState<S> | ChildStateKey<S, Exclude<AncestorPaths<Source>, Source>>;
type ChildStateTarget<S extends string, Source extends string> = `.${ChildStateKey<S, Source>}`;
interface Transition<T extends Dict, Source extends string | undefined = string | undefined> {
target?: T["state"] | StateIdTarget | (Source extends string ? RelativeStateTarget<T["state"], Source> : never) | undefined;
target?: T["state"] | StateIdTarget | (Source extends string ? SiblingStateTarget<T["state"], Source> : never) | (Source extends string ? ChildStateTarget<T["state"], Source> : never) | undefined;
actions?: T["action"][] | undefined;

@@ -117,0 +118,0 @@ guard?: T["guard"] | GuardFn<T> | undefined;

{
"name": "@zag-js/core",
"version": "1.37.0",
"version": "1.38.0",
"description": "A minimal implementation of xstate fsm for UI machines",

@@ -28,4 +28,4 @@ "keywords": [

"dependencies": {
"@zag-js/utils": "1.37.0",
"@zag-js/dom-query": "1.37.0"
"@zag-js/utils": "1.38.0",
"@zag-js/dom-query": "1.38.0"
},

@@ -32,0 +32,0 @@ "devDependencies": {