@zag-js/core
Advanced tools
Comparing version 0.0.0-dev-20220919164136 to 0.0.0-dev-20220928123644
@@ -0,5 +1,37 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/index.ts | ||
import { proxy as proxy2, ref as ref2, snapshot as snapshot3, subscribe as subscribe3 } from "@zag-js/store"; | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
Machine: () => Machine, | ||
choose: () => choose, | ||
createMachine: () => createMachine, | ||
guards: () => guards, | ||
mergeProps: () => mergeProps, | ||
proxy: () => import_store4.proxy, | ||
ref: () => import_store4.ref, | ||
snapshot: () => import_store4.snapshot, | ||
subscribe: () => import_store4.subscribe | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var import_store4 = require("@zag-js/store"); | ||
// ../utilities/core/dist/index.js | ||
// ../utilities/core/dist/index.mjs | ||
function clear(v) { | ||
@@ -51,3 +83,3 @@ while (v.length > 0) | ||
// src/utils.ts | ||
import { snapshot, subscribe } from "@zag-js/store"; | ||
var import_store = require("@zag-js/store"); | ||
function toEvent(event) { | ||
@@ -66,7 +98,7 @@ const obj = isString(event) ? { type: event } : event; | ||
function subscribeKey(obj, key, fn, sync) { | ||
let prev = Reflect.get(snapshot(obj), key); | ||
return subscribe( | ||
let prev = Reflect.get((0, import_store.snapshot)(obj), key); | ||
return (0, import_store.subscribe)( | ||
obj, | ||
() => { | ||
const snap = snapshot(obj); | ||
const snap = (0, import_store.snapshot)(obj); | ||
if (!Object.is(prev, snap[key])) { | ||
@@ -150,11 +182,11 @@ fn(snap[key]); | ||
// src/machine.ts | ||
import { ref, snapshot as snapshot2, subscribe as subscribe2 } from "@zag-js/store"; | ||
import { klona } from "klona/json"; | ||
var import_store3 = require("@zag-js/store"); | ||
var import_json = require("klona/json"); | ||
// src/create-proxy.ts | ||
import { proxy, proxyWithComputed } from "@zag-js/store"; | ||
var import_store2 = require("@zag-js/store"); | ||
function createProxy(config) { | ||
const computedContext = config.computed ?? cast({}); | ||
const initialContext = config.context ?? cast({}); | ||
const state = proxy({ | ||
const state = (0, import_store2.proxy)({ | ||
value: "", | ||
@@ -164,3 +196,3 @@ previousValue: "", | ||
previousEvent: cast({}), | ||
context: proxyWithComputed(initialContext, computedContext), | ||
context: (0, import_store2.proxyWithComputed)(initialContext, computedContext), | ||
done: false, | ||
@@ -259,4 +291,4 @@ tags: [], | ||
var _a, _b, _c, _d, _e, _f; | ||
this.config = klona(config); | ||
this.options = klona(options ?? {}); | ||
this.config = (0, import_json.klona)(config); | ||
this.options = (0, import_json.klona)(options ?? {}); | ||
this.id = this.config.id ?? `machine-${uuid()}`; | ||
@@ -273,6 +305,6 @@ this.guardMap = ((_a = this.options) == null ? void 0 : _a.guards) ?? {}; | ||
get stateSnapshot() { | ||
return cast(snapshot2(this.state)); | ||
return cast((0, import_store3.snapshot)(this.state)); | ||
} | ||
getState() { | ||
return klona(this.stateSnapshot); | ||
return (0, import_json.klona)(this.stateSnapshot); | ||
} | ||
@@ -287,3 +319,3 @@ get contextSnapshot() { | ||
this.status = "Running" /* Running */; | ||
this.removeStateListener = subscribe2( | ||
this.removeStateListener = (0, import_store3.subscribe)( | ||
this.state, | ||
@@ -308,3 +340,3 @@ () => { | ||
); | ||
this.removeContextListener = subscribe2( | ||
this.removeContextListener = (0, import_store3.subscribe)( | ||
this.state.context, | ||
@@ -434,3 +466,3 @@ () => { | ||
}).start(); | ||
return cast(ref(actor)); | ||
return cast((0, import_store3.ref)(actor)); | ||
}; | ||
@@ -647,3 +679,3 @@ addActivityCleanup = (state, cleanup) => { | ||
this.state.previousEvent = this.state.event; | ||
this.state.event = ref(toEvent(event)); | ||
this.state.event = (0, import_store3.ref)(toEvent(event)); | ||
}; | ||
@@ -803,3 +835,4 @@ performExitEffects = (current, event) => { | ||
} | ||
export { | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
Machine, | ||
@@ -810,6 +843,6 @@ choose, | ||
mergeProps, | ||
proxy2 as proxy, | ||
ref2 as ref, | ||
snapshot3 as snapshot, | ||
subscribe3 as subscribe | ||
}; | ||
proxy, | ||
ref, | ||
snapshot, | ||
subscribe | ||
}); |
{ | ||
"type": "module", | ||
"name": "@zag-js/core", | ||
"version": "0.0.0-dev-20220919164136", | ||
"version": "0.0.0-dev-20220928123644", | ||
"description": "A minimal implementation of xstate fsm for UI machines", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"keywords": [ | ||
@@ -17,4 +19,2 @@ "ui-machines", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"repository": "https://github.com/chakra-ui/zag/tree/main/packages/machine", | ||
@@ -32,12 +32,12 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@zag-js/store": "0.0.0-dev-20220919164136", | ||
"@zag-js/store": "0.0.0-dev-20220928123644", | ||
"klona": "2.0.5" | ||
}, | ||
"devDependencies": { | ||
"@zag-js/utils": "0.0.0-dev-20220919164136" | ||
"@zag-js/utils": "0.0.0-dev-20220928123644" | ||
}, | ||
"scripts": { | ||
"build-fast": "tsup src/index.ts --format=esm", | ||
"build-fast": "tsup src/index.ts --format=esm,cjs", | ||
"start": "pnpm build --watch", | ||
"build": "tsup src/index.ts --format=esm --dts", | ||
"build": "tsup src/index.ts --format=esm,cjs --dts", | ||
"test": "jest --config ../../jest.config.js --rootDir . --passWithNoTests", | ||
@@ -44,0 +44,0 @@ "lint": "eslint src --ext .ts,.tsx", |
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
82825
6
2043
7
No
+ Added@zag-js/store@0.0.0-dev-20220928123644(transitive)
- Removed@zag-js/store@0.0.0-dev-20220919164136(transitive)