Skip to content

Commit

Permalink
Add inspectors to templates
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Jan 17, 2024
1 parent c11e4c2 commit b4b46f2
Show file tree
Hide file tree
Showing 12 changed files with 200 additions and 4 deletions.
1 change: 1 addition & 0 deletions templates/react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"@statelyai/inspect": "^0.2.0",
"@xstate/react": "4.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
42 changes: 42 additions & 0 deletions templates/react-ts/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion templates/react-ts/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import './App.css';
import { feedbackMachine } from './feedbackMachine';
import { useMachine } from '@xstate/react';
import { createBrowserInspector } from '@statelyai/inspect';

const { inspect } = createBrowserInspector();

function Feedback() {
const [state, send] = useMachine(feedbackMachine);
const [state, send] = useMachine(feedbackMachine, {
// Uncomment the line below to start the inspector
// inspect
});

if (state.matches('closed')) {
return (
Expand Down
1 change: 1 addition & 0 deletions templates/svelte-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"vite": "^5.0.11"
},
"dependencies": {
"@statelyai/inspect": "^0.2.0",
"@xstate/svelte": "^3.0.2",
"xstate": "^5.4.1"
}
Expand Down
42 changes: 42 additions & 0 deletions templates/svelte-ts/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion templates/svelte-ts/src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<script lang="ts">
import { feedbackMachine } from './feedbackMachine';
import { useMachine } from '@xstate/svelte';
import { createBrowserInspector } from '@statelyai/inspect';
const { snapshot, send } = useMachine(feedbackMachine);
const { inspect } = createBrowserInspector();
const { snapshot, send } = useMachine(feedbackMachine, {
// Uncomment the line below to start the inspector
// inspect
});
</script>

{#if $snapshot.matches('closed')}
Expand Down
1 change: 1 addition & 0 deletions templates/vanilla-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"vite": "^5.0.11"
},
"dependencies": {
"@statelyai/inspect": "^0.2.0",
"xstate": "5.4.1"
}
}
42 changes: 42 additions & 0 deletions templates/vanilla-ts/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion templates/vanilla-ts/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {
__unsafe_getAllOwnEventDescriptors,
createActor
} from 'xstate';
import { createBrowserInspector } from '@statelyai/inspect';

const { inspect } = createBrowserInspector();

document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
<div>
Expand All @@ -26,7 +29,10 @@ function getNextTransitions(state: AnyMachineSnapshot) {
return state._nodes.flatMap((node) => [...node.transitions.values()]).flat(1);
}

const actor = createActor(feedbackMachine);
const actor = createActor(feedbackMachine, {
// Uncomment the line below to start the inspector
// inspect
});

(window as any).feedbackActor = actor;

Expand Down
1 change: 1 addition & 0 deletions templates/vue-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"@statelyai/inspect": "^0.2.0",
"@xstate/vue": "^3.0.3",
"vue": "^3.4.7",
"xstate": "^5.4.1"
Expand Down
42 changes: 42 additions & 0 deletions templates/vue-ts/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b4b46f2

Please sign in to comment.