Skip to content

Commit

Permalink
chore: complet prod and dev build script
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Nov 20, 2021
1 parent d9daa0d commit e61d56f
Show file tree
Hide file tree
Showing 166 changed files with 635 additions and 719 deletions.
2 changes: 1 addition & 1 deletion examples/next-ts/components/state-visualizer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Machine } from "@ui-machines/core"
import { isDom } from "tiny-guard"
import { isDom } from "@ui-machines/utils"

type StateVisualizerProps = {
state: Record<string, any>
Expand Down
2 changes: 1 addition & 1 deletion examples/solid-ts/src/components/state-visualizer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isDom } from "tiny-guard"
import { isDom } from "@ui-machines/utils"
import { Machine } from "@ui-machines/core"

type StateVisualizerProps = {
Expand Down
3 changes: 1 addition & 2 deletions examples/vue-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@
"tiny-dom-query/scrollable",
"tiny-dom-query/tabbable",
"tiny-fn",
"tiny-guard",
"tiny-nodelist",
"@ui-machines/point-utils/distance",
"@ui-machines/point-utils/dom",
"@ui-machines/rect-utils",
"@ui-machines/point-utils/within",
"@ui-machines/rect-utils",
"@ui-machines/rect-utils/from-element",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue-ts/src/components/state-visualizer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isDom } from "tiny-guard"
import { isDom } from "@ui-machines/utils"
import { h, SetupContext } from "vue"

export function StateVisualizer(props: { state: Record<string, any> }, { attrs }: SetupContext) {
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "Segun Adebayo <[email protected]>",
"license": "MIT",
"scripts": {
"bundle": "esr scripts/build.ts --watch",
"bundle": "esr scripts/build.ts",
"build": "parcel build",
"start:react": "cd examples/next-ts && yarn dev",
"start:vue": "cd examples/vue-ts && yarn dev",
Expand Down Expand Up @@ -59,6 +59,7 @@
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"axe-core": "^4.3.3",
"chalk": "^4.1.2",
"commitlint": "^12.1.4",
"cypress": "^8.5.0",
"cypress-axe": "^0.13.0",
Expand Down Expand Up @@ -90,15 +91,15 @@
"rimraf": "^3.0.2",
"shelljs": "^0.8.4",
"start-server-and-test": "^1.14.0",
"ts-node": "^9.1.1",
"typescript": "4.4.3"
},
"workspaces": {
"packages": [
"packages/core",
"packages/machines/*",
"packages/frameworks/*",
"packages/utilities",
"packages/types",
"packages/utilities/*",
"examples/*"
]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "src/index.ts",
"types": "dist/index.d.ts",
"repository": "https://github.com/chakra-ui/core/tree/main/packages/machine",
"sideEffects": false,
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/action-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject, isString } from "../../utils/guard"
import { isObject, isString } from "@ui-machines/utils"
import { Dict, StateMachine as S } from "./types"

export function choose<TContext, TState extends S.StateSchema, TEvent extends S.EventObject = S.AnyEventObject>(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/create-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { proxy } from "valtio"
import { cast } from "../../utils/functions"
import { cast } from "@ui-machines/utils"
import { ActionTypes, Dict, StateMachine as S } from "./types"

export function createProxy<TContext, TState extends S.StateSchema, TEvent extends S.EventObject>(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/delay-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isFunction, isNumber, isString } from "../../utils/guard"
import { isFunction, isNumber, isString } from "@ui-machines/utils"
import { StateMachine as S } from "./types"

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/guard-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isFunction, isObject, isString } from "../../utils/guard"
import { isFunction, isObject, isString } from "@ui-machines/utils"
import { Dict, StateMachine as S } from "./types"

function or<TContext, TEvent extends S.EventObject>(
Expand Down
7 changes: 3 additions & 4 deletions packages/core/src/machine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { klona } from "klona"
import { cast, invariant, noop, runIfFn, warn } from "../../utils/functions"
import { isArray, isObject, isString } from "../../utils/guard"
import { cast, invariant, noop, runIfFn, warn, isArray, isObject, isString, uuid } from "@ui-machines/utils"
import { derive, subscribeKey, underive } from "valtio/utils"
import { ref, snapshot, subscribe } from "valtio/vanilla"
import { determineActionsFn } from "./action-utils"
Expand All @@ -9,7 +8,7 @@ import { determineDelayFn } from "./delay-utils"
import { determineGuardFn } from "./guard-utils"
import { determineTransitionFn, toTransition } from "./transition-utils"
import { ActionTypes, Dict, MachineStatus, MachineType, StateMachine as S, VoidFunction } from "./types"
import { toArray, toEvent, uniqueId } from "./utils"
import { toArray, toEvent } from "./utils"

export class Machine<
TContext extends Dict,
Expand Down Expand Up @@ -51,7 +50,7 @@ export class Machine<
public config: S.MachineConfig<TContext, TState, TEvent>,
public options?: S.MachineOptions<TContext, TState, TEvent>,
) {
this.id = config.id ?? `machine-${uniqueId()}`
this.id = config.id ?? `machine-${uuid()}`
this.state = createProxy(config)
this.guardMap = options?.guards ?? {}
this.actionMap = options?.actions ?? {}
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/transition-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cast } from "../../utils/functions"
import { isArray, isObject, isString } from "../../utils/guard"
import { cast, isArray, isObject, isString } from "@ui-machines/utils"
import { determineGuardFn } from "./guard-utils"
import type { StateMachine as S } from "./types"
import { toArray } from "./utils"
Expand Down
10 changes: 1 addition & 9 deletions packages/core/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArray, isString } from "../../utils/guard"
import { isArray, isString } from "@ui-machines/utils"
import type { StateMachine as S } from "./types"

export function toEvent<T extends S.EventObject>(event: S.Event<T>): T {
Expand All @@ -10,11 +10,3 @@ export function toArray<T>(value: T | T[] | undefined): T[] {
if (!value) return []
return isArray(value) ? value : [value]
}

export const uniqueId = (() => {
let id = 0
return () => {
id++
return id.toString(16)
}
})()
5 changes: 2 additions & 3 deletions packages/frameworks/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"repository": "https://github.com/chakra-ui/ui-machines/tree/main/packages/frameworks/react",
"sideEffects": false,
"files": [
Expand All @@ -35,7 +36,5 @@
},
"peerDependencies": {
"react": ">=16.8.6"
},
"types": "dist/index.d.ts",
"source": "src/index.ts"
}
}
6 changes: 2 additions & 4 deletions packages/frameworks/solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"repository": "https://github.com/chakra-ui/ui-machines/tree/main/packages/frameworks/solid",
"sideEffects": false,
"files": [
Expand All @@ -28,15 +29,12 @@
"dependencies": {
"@ui-machines/core": "0.0.0",
"hyphenate-style-name": "^1.0.4",
"tiny-guard": "^0.0.3",
"valtio": "^1.2.5"
},
"devDependencies": {
"solid-js": "^1.1.3"
},
"peerDependencies": {
"solid-js": ">=1.1.3"
},
"types": "dist/index.d.ts",
"source": "src/index.ts"
}
}
2 changes: 1 addition & 1 deletion packages/frameworks/solid/src/cssify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hyphenate from "hyphenate-style-name"
import { isNumber, isString } from "tiny-guard"
import { isNumber, isString } from "@ui-machines/utils"

const format = (v: string) => (v.startsWith("--") ? v : hyphenate(v))

Expand Down
4 changes: 2 additions & 2 deletions packages/frameworks/solid/src/normalize-props.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createNormalizer } from "@ui-machines/utils"
import { isObject, isString } from "tiny-guard"
import { createNormalizer } from "@ui-machines/types"
import { isObject, isString } from "@ui-machines/utils"
import { cssify } from "./cssify"

const eventMap = {
Expand Down
5 changes: 2 additions & 3 deletions packages/frameworks/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"repository": "https://github.com/chakra-ui/ui-machines/tree/main/packages/core/svelte",
"sideEffects": false,
"files": [
Expand All @@ -33,7 +34,5 @@
},
"peerDependencies": {
"svelte": "^3.38.2"
},
"types": "dist/index.d.ts",
"source": "src/index.ts"
}
}
8 changes: 4 additions & 4 deletions packages/frameworks/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"repository": "https://github.com/chakra-ui/ui-machines/tree/main/packages/frameworks/vue",
"sideEffects": false,
"files": [
Expand All @@ -33,8 +34,7 @@
"vue": "^3.0.5"
},
"peerDependencies": {
"vue": ">=3.0.5"
},
"types": "dist/index.d.ts",
"source": "src/index.ts"
"vue": ">=3.0.0",
"@vue/runtime-dom": ">=3.2.0"
}
}
2 changes: 1 addition & 1 deletion packages/frameworks/vue/src/normalize-props.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createNormalizer } from "@ui-machines/utils"
import { createNormalizer } from "@ui-machines/types"

type Dict = Record<string, string>

Expand Down
3 changes: 1 addition & 2 deletions packages/machines/accordion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@
},
"dependencies": {
"@ui-machines/core": "^0.0.0"
},
"source": "src/index.ts"
}
}
2 changes: 1 addition & 1 deletion packages/machines/accordion/src/accordion.connect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dataAttr, getEventKey, EventKeyMap } from "@ui-machines/dom-utils"
import { normalizeProp, PropTypes, ReactPropTypes } from "@ui-machines/utils"
import { normalizeProp, PropTypes, ReactPropTypes } from "@ui-machines/types"
import { dom } from "./accordion.dom"
import type { AccordionItemProps, AccordionSend, AccordionState } from "./accordion.types"

Expand Down
4 changes: 2 additions & 2 deletions packages/machines/accordion/src/accordion.dom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { queryElements, nextById, prevById } from "@ui-machines/dom-utils/nodelist"
import { first, last } from "../../../utils/array/dist"
import { nextById, prevById, queryElements } from "@ui-machines/dom-utils"
import { first, last } from "@ui-machines/utils"
import type { AccordionMachineContext as Ctx } from "./accordion.types"

export const dom = {
Expand Down
2 changes: 1 addition & 1 deletion packages/machines/accordion/src/accordion.machine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { add, remove, toArray } from "../../../utils/array/dist"
import { add, remove, toArray } from "@ui-machines/utils"
import { createMachine, guards, ref } from "@ui-machines/core"
import { dom } from "./accordion.dom"
import { AccordionMachineContext, AccordionMachineState } from "./accordion.types"
Expand Down
2 changes: 1 addition & 1 deletion packages/machines/accordion/src/accordion.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StateMachine as S } from "@ui-machines/core"
import type { Context } from "@ui-machines/utils"
import type { Context } from "@ui-machines/types"

export type AccordionMachineContext = Context<{
/**
Expand Down
3 changes: 1 addition & 2 deletions packages/machines/combobox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@
"dependencies": {
"@ui-machines/core": "^0.0.0",
"scroll-into-view-if-needed": "^2.2.28"
},
"source": "src/index.ts"
}
}
5 changes: 2 additions & 3 deletions packages/machines/combobox/src/combobox.connect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { dataAttr, EventKeyMap, getEventKey, srOnlyStyle } from "@ui-machines/dom-utils"
import { validateBlur } from "@ui-machines/dom-utils/focus-event"
import { normalizeProp, PropTypes, ReactPropTypes } from "@ui-machines/utils"
import { dataAttr, EventKeyMap, getEventKey, srOnlyStyle, validateBlur } from "@ui-machines/dom-utils"
import { normalizeProp, PropTypes, ReactPropTypes } from "@ui-machines/types"
import { dom } from "./combobox.dom"
import { ComboboxOptionProps, ComboboxSend, ComboboxState } from "./combobox.types"

Expand Down
4 changes: 2 additions & 2 deletions packages/machines/combobox/src/combobox.dom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { first, last } from "../../../utils/array/dist"
import { nextById, prevById, queryElements } from "@ui-machines/dom-utils/nodelist"
import { nextById, prevById, queryElements } from "@ui-machines/dom-utils"
import { first, last } from "@ui-machines/utils"
import type { ComboboxMachineContext as Ctx } from "./combobox.types"

export const dom = {
Expand Down
7 changes: 2 additions & 5 deletions packages/machines/combobox/src/combobox.machine.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { createMachine, guards, ref } from "@ui-machines/core"
import { nextTick } from "@ui-machines/dom-utils"
import { LiveRegion } from "@ui-machines/dom-utils/live-region"
import { observeAttributes } from "@ui-machines/dom-utils/mutation-observer"
import { trackPointerDown } from "@ui-machines/dom-utils/pointer-event"
import { isApple, isFunction } from "@ui-machines/utils/guard"
import { LiveRegion, nextTick, observeAttributes, trackPointerDown } from "@ui-machines/dom-utils"
import { isApple, isFunction } from "@ui-machines/utils"
import scrollIntoView from "scroll-into-view-if-needed"
import { dom } from "./combobox.dom"
import { ComboboxMachineContext, ComboboxMachineState } from "./combobox.types"
Expand Down
4 changes: 2 additions & 2 deletions packages/machines/combobox/src/combobox.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { StateMachine as S } from "@ui-machines/core"
import type { LiveRegion } from "@ui-machines/dom-utils/live-region"
import type { Context } from "@ui-machines/utils"
import type { LiveRegion } from "@ui-machines/dom-utils"
import type { Context } from "@ui-machines/types"

export type ComboboxMachineState = {
value: "unknown" | "idle" | "focused" | "suggesting" | "navigating" | "interacting"
Expand Down
3 changes: 1 addition & 2 deletions packages/machines/dialog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@
"aria-hidden": "^1.1.3",
"focus-trap": "^6.7.1",
"scroll-into-view-if-needed": "^2.2.28"
},
"source": "src/index.ts"
}
}
2 changes: 1 addition & 1 deletion packages/machines/dialog/src/dialog.connect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StateMachine as S } from "@ui-machines/core"
import { ariaAttr } from "@ui-machines/dom-utils"
import { normalizeProp, PropTypes, ReactPropTypes } from "@ui-machines/utils"
import { normalizeProp, PropTypes, ReactPropTypes } from "@ui-machines/types"
import { dom } from "./dialog.dom"
import { DialogMachineContext, DialogMachineState } from "./dialog.machine"

Expand Down
6 changes: 2 additions & 4 deletions packages/machines/dialog/src/dialog.machine.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { createMachine, ref, subscribe } from "@ui-machines/core"
import { nextTick } from "@ui-machines/dom-utils"
import { addDomEvent } from "@ui-machines/dom-utils/listener"
import { preventBodyScroll } from "@ui-machines/dom-utils/body-scroll-lock"
import { Context } from "@ui-machines/utils"
import { addDomEvent, nextTick, preventBodyScroll } from "@ui-machines/dom-utils"
import { Context } from "@ui-machines/types"
import { hideOthers } from "aria-hidden"
import { createFocusTrap, FocusTrap } from "focus-trap"
import { dom } from "./dialog.dom"
Expand Down
3 changes: 1 addition & 2 deletions packages/machines/editable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@
},
"dependencies": {
"@ui-machines/core": "^0.0.0"
},
"source": "src/index.ts"
}
}
5 changes: 2 additions & 3 deletions packages/machines/editable/src/editable.connect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ariaAttr, EventKeyMap } from "@ui-machines/dom-utils"
import { validateBlur } from "@ui-machines/dom-utils/focus-event"
import { normalizeProp, PropTypes, ReactPropTypes } from "@ui-machines/utils"
import { ariaAttr, EventKeyMap, validateBlur } from "@ui-machines/dom-utils"
import { normalizeProp, PropTypes, ReactPropTypes } from "@ui-machines/types"
import { dom } from "./editable.dom"
import { EditableSend, EditableState } from "./editable.types"

Expand Down
3 changes: 1 addition & 2 deletions packages/machines/editable/src/editable.machine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { choose, createMachine, guards, ref } from "@ui-machines/core"
import { nextTick } from "@ui-machines/dom-utils"
import { trackPointerDown } from "@ui-machines/dom-utils/pointer-event"
import { nextTick, trackPointerDown } from "@ui-machines/dom-utils"
import { dom } from "./editable.dom"
import { EditableMachineContext, EditableMachineState } from "./editable.types"

Expand Down
2 changes: 1 addition & 1 deletion packages/machines/editable/src/editable.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StateMachine as S } from "@ui-machines/core"
import type { Context } from "@ui-machines/utils"
import type { Context } from "@ui-machines/types"

export type ActivationMode = "focus" | "dblclick" | "none"

Expand Down
3 changes: 1 addition & 2 deletions packages/machines/menu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@
},
"dependencies": {
"@ui-machines/core": "^0.0.0"
},
"source": "src/index.ts"
}
}
Loading

0 comments on commit e61d56f

Please sign in to comment.