@triggery/core 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +169 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @triggery/core
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f23e155: Filled out the quick-start sections in the npm package READMEs that adopters land on first.
|
|
8
|
+
|
|
9
|
+
- `@triggery/core` README now contains a three-tab quick-start (React / Solid / Vue) with concrete `pnpm add` commands and runnable code, plus pointers to the per-binding README for the full walkthrough.
|
|
10
|
+
- `@triggery/react` README — was a stub. Now has the full four-file scenario (trigger + provider + Chat + Toast) ready to copy-paste, exactly mirroring the Solid and Vue examples.
|
|
11
|
+
|
|
12
|
+
Linked-bundle bump so the binding READMEs stay aligned with the core release; no code or API changes.
|
|
13
|
+
|
|
14
|
+
- 3385f5b: Every package README now ends with a tailored **Related packages** section and a consistent `## License` footer.
|
|
15
|
+
|
|
16
|
+
- Adapter packages (`zustand`, `redux`, `jotai`, `mobx`, `reatom`, `signals`, `query`) link to `core` + `react` (required peers) plus 2-3 alternative adapters so adopters can swap them out without re-reading the whole repo.
|
|
17
|
+
- Event-source packages (`dom`, `socket`) cross-link.
|
|
18
|
+
- DevTools packages (`devtools-redux`, `devtools-panel`, `devtools-bridge`) cross-link.
|
|
19
|
+
- Tooling packages (`eslint-plugin`, `codemod`, `cli`) cross-link.
|
|
20
|
+
- Bindings (`react`, `solid`, `vue`) link to each other so users mid-migration know there's a sibling with the same hook API.
|
|
21
|
+
- `@triggery/core/src/index.ts` JSDoc header had stale wording ("orchestration runtime for React business logic") — replaced with framework-agnostic phrasing matching the README.
|
|
22
|
+
|
|
23
|
+
No code or API changes. Drop-in patch.
|
|
24
|
+
|
|
3
25
|
## 0.1.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,17 +2,171 @@
|
|
|
2
2
|
|
|
3
3
|
The runtime that powers [Triggery](https://github.com/triggeryjs/triggery) — a declarative `event → conditions → actions` orchestration layer.
|
|
4
4
|
|
|
5
|
-
**Framework-agnostic.** `@triggery/core`
|
|
5
|
+
**Framework-agnostic.** `@triggery/core` has **zero runtime dependencies** and knows nothing about React, Solid or Vue. The framework bindings (`@triggery/react`, `@triggery/solid`, `@triggery/vue`) and the state adapters are thin layers on top of this runtime — and they can be replaced by anything you author yourself in ~50 lines.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
pnpm add @triggery/core
|
|
11
|
-
# plus your framework binding of choice
|
|
12
|
-
pnpm add @triggery/react # or @triggery/solid, @triggery/vue
|
|
11
|
+
# plus your framework binding of choice (see below)
|
|
13
12
|
```
|
|
14
13
|
|
|
15
|
-
##
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
The trigger definition is the same regardless of framework — only the wiring differs. Start by defining a scenario:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// src/triggers/message.trigger.ts
|
|
20
|
+
import { createTrigger } from '@triggery/core';
|
|
21
|
+
|
|
22
|
+
type Settings = { sound: boolean; notifications: boolean };
|
|
23
|
+
|
|
24
|
+
export const messageTrigger = createTrigger<{
|
|
25
|
+
events: { 'new-message': { text: string; author: string } };
|
|
26
|
+
conditions: { settings: Settings };
|
|
27
|
+
actions: { showToast: { title: string; body: string } };
|
|
28
|
+
}>({
|
|
29
|
+
id: 'message-received',
|
|
30
|
+
events: ['new-message'],
|
|
31
|
+
required: ['settings'],
|
|
32
|
+
handler({ event, conditions, actions }) {
|
|
33
|
+
if (!conditions.settings.notifications) return;
|
|
34
|
+
actions.showToast?.({
|
|
35
|
+
title: event.payload.author,
|
|
36
|
+
body: event.payload.text,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then wire it to your framework — pick one.
|
|
43
|
+
|
|
44
|
+
### React
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm add @triggery/core @triggery/react
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
// src/main.tsx
|
|
52
|
+
import { createRuntime } from '@triggery/core';
|
|
53
|
+
import { TriggerRuntimeProvider, useAction, useCondition, useEvent } from '@triggery/react';
|
|
54
|
+
import { useState } from 'react';
|
|
55
|
+
import { createRoot } from 'react-dom/client';
|
|
56
|
+
import { messageTrigger } from './triggers/message.trigger.ts';
|
|
57
|
+
|
|
58
|
+
const runtime = createRuntime();
|
|
59
|
+
|
|
60
|
+
function SettingsProvider() {
|
|
61
|
+
const [settings] = useState({ sound: true, notifications: true });
|
|
62
|
+
useCondition(messageTrigger, 'settings', () => settings, [settings]);
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
function Chat() {
|
|
66
|
+
const fire = useEvent(messageTrigger, 'new-message');
|
|
67
|
+
return <button onClick={() => fire({ text: 'hi', author: 'Alice' })}>send</button>;
|
|
68
|
+
}
|
|
69
|
+
function Toast() {
|
|
70
|
+
useAction(messageTrigger, 'showToast', ({ title, body }) => console.log(`[${title}] ${body}`));
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
createRoot(document.getElementById('root')!).render(
|
|
75
|
+
<TriggerRuntimeProvider runtime={runtime}>
|
|
76
|
+
<SettingsProvider /><Chat /><Toast />
|
|
77
|
+
</TriggerRuntimeProvider>,
|
|
78
|
+
);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Full walkthrough: [`@triggery/react` README](https://github.com/triggeryjs/triggery/blob/main/packages/react/README.md). Runnable example: [`examples/vite-react-counter`](https://github.com/triggeryjs/triggery/tree/main/examples/vite-react-counter).
|
|
82
|
+
|
|
83
|
+
### Solid
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pnpm add @triggery/core @triggery/solid solid-js
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
// src/index.tsx
|
|
91
|
+
import { createRuntime } from '@triggery/core';
|
|
92
|
+
import { TriggerRuntimeProvider, useAction, useCondition, useEvent } from '@triggery/solid';
|
|
93
|
+
import { createSignal } from 'solid-js';
|
|
94
|
+
import { render } from 'solid-js/web';
|
|
95
|
+
import { messageTrigger } from './triggers/message.trigger.ts';
|
|
96
|
+
|
|
97
|
+
const runtime = createRuntime();
|
|
98
|
+
|
|
99
|
+
const SettingsProvider = () => {
|
|
100
|
+
const [settings] = createSignal({ sound: true, notifications: true });
|
|
101
|
+
useCondition(messageTrigger, 'settings', () => settings());
|
|
102
|
+
return null;
|
|
103
|
+
};
|
|
104
|
+
const Chat = () => {
|
|
105
|
+
const fire = useEvent(messageTrigger, 'new-message');
|
|
106
|
+
return <button onClick={() => fire({ text: 'hi', author: 'Alice' })}>send</button>;
|
|
107
|
+
};
|
|
108
|
+
const Toast = () => {
|
|
109
|
+
useAction(messageTrigger, 'showToast', ({ title, body }) => console.log(`[${title}] ${body}`));
|
|
110
|
+
return null;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
render(
|
|
114
|
+
() => (
|
|
115
|
+
<TriggerRuntimeProvider runtime={runtime}>
|
|
116
|
+
<SettingsProvider /><Chat /><Toast />
|
|
117
|
+
</TriggerRuntimeProvider>
|
|
118
|
+
),
|
|
119
|
+
document.getElementById('root')!,
|
|
120
|
+
);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Full walkthrough: [`@triggery/solid` README](https://github.com/triggeryjs/triggery/blob/main/packages/solid/README.md).
|
|
124
|
+
|
|
125
|
+
### Vue 3
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
pnpm add @triggery/core @triggery/vue vue
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
// src/main.ts
|
|
133
|
+
import { createRuntime } from '@triggery/core';
|
|
134
|
+
import { TriggerRuntimeProvider } from '@triggery/vue';
|
|
135
|
+
import { createApp, defineComponent, h, ref } from 'vue';
|
|
136
|
+
import { useAction, useCondition, useEvent } from '@triggery/vue';
|
|
137
|
+
import { messageTrigger } from './triggers/message.trigger';
|
|
138
|
+
|
|
139
|
+
const runtime = createRuntime();
|
|
140
|
+
|
|
141
|
+
const SettingsProvider = defineComponent({
|
|
142
|
+
setup() {
|
|
143
|
+
const settings = ref({ sound: true, notifications: true });
|
|
144
|
+
useCondition(messageTrigger, 'settings', () => settings.value);
|
|
145
|
+
return () => null;
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
const Chat = defineComponent({
|
|
149
|
+
setup() {
|
|
150
|
+
const fire = useEvent(messageTrigger, 'new-message');
|
|
151
|
+
return () => h('button', { onClick: () => fire({ text: 'hi', author: 'Alice' }) }, 'send');
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
const Toast = defineComponent({
|
|
155
|
+
setup() {
|
|
156
|
+
useAction(messageTrigger, 'showToast', ({ title, body }) => console.log(`[${title}] ${body}`));
|
|
157
|
+
return () => null;
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
createApp({
|
|
162
|
+
setup: () => () =>
|
|
163
|
+
h(TriggerRuntimeProvider, { runtime }, () => [h(SettingsProvider), h(Chat), h(Toast)]),
|
|
164
|
+
}).mount('#app');
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Full walkthrough (with `<script setup>` SFC style): [`@triggery/vue` README](https://github.com/triggeryjs/triggery/blob/main/packages/vue/README.md).
|
|
168
|
+
|
|
169
|
+
## What's in this package
|
|
16
170
|
|
|
17
171
|
- `createTrigger<Schema>(config)` — declare a scenario in one file (events, conditions, required gate, handler).
|
|
18
172
|
- `createRuntime(options)` — instantiate an isolated runtime: indexed dispatch (`Map<eventKey, RuntimeTrigger[]>`), microtask + sync schedulers, middleware chain (`onFire` / `onBeforeMatch` / `onSkip` / `onActionStart` / `onActionEnd` / `onError` / `onCascade`), cascade safety (depth limit + cycle detection), inspector ring buffer with DEV/PROD auto-detection.
|
|
@@ -21,23 +175,27 @@ pnpm add @triggery/react # or @triggery/solid, @triggery/vue
|
|
|
21
175
|
- `actions.debounce / throttle / defer / queue` chainable action wrappers.
|
|
22
176
|
- Last-mount-wins ownership with DEV warn-once.
|
|
23
177
|
|
|
24
|
-
You normally don't consume this package directly — pick a binding:
|
|
25
|
-
|
|
26
|
-
- [`@triggery/react`](https://www.npmjs.com/package/@triggery/react)
|
|
27
|
-
- [`@triggery/solid`](https://www.npmjs.com/package/@triggery/solid)
|
|
28
|
-
- [`@triggery/vue`](https://www.npmjs.com/package/@triggery/vue)
|
|
29
|
-
|
|
30
178
|
## Why "framework-agnostic"
|
|
31
179
|
|
|
32
180
|
The runtime is a plain object with a `Map`-based registry. It does not import React. It does not import a vDOM. It can be embedded in:
|
|
33
181
|
|
|
34
182
|
- a worker / service worker
|
|
35
183
|
- a Node.js process (CLI, server, edge)
|
|
36
|
-
- React Native (
|
|
184
|
+
- React Native (no DOM adapters needed for the runtime itself)
|
|
37
185
|
- a vanilla JS page
|
|
38
186
|
|
|
39
187
|
The same `createTrigger({...})` declaration runs unchanged across all of those. Bindings only wire `useEvent` / `useCondition` / `useAction` to the host framework's lifecycle.
|
|
40
188
|
|
|
189
|
+
## Related packages
|
|
190
|
+
|
|
191
|
+
- [`@triggery/react`](https://www.npmjs.com/package/@triggery/react) — React bindings (`useEvent` / `useCondition` / `useAction`).
|
|
192
|
+
- [`@triggery/solid`](https://www.npmjs.com/package/@triggery/solid) — SolidJS bindings — same hook API.
|
|
193
|
+
- [`@triggery/vue`](https://www.npmjs.com/package/@triggery/vue) — Vue 3 bindings — same hook API.
|
|
194
|
+
- [`@triggery/testing`](https://www.npmjs.com/package/@triggery/testing) — Test utilities (`createTestRuntime`, `fakeScheduler`).
|
|
195
|
+
- [`@triggery/vite`](https://www.npmjs.com/package/@triggery/vite) — Vite plugin for auto-discovery of `*.trigger.ts`.
|
|
196
|
+
|
|
197
|
+
See the [full package list](https://github.com/triggeryjs/triggery#packages) in the repo README.
|
|
198
|
+
|
|
41
199
|
## License
|
|
42
200
|
|
|
43
201
|
MIT © Aleksey Skhomenko
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@triggery/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Declarative business-logic orchestration — framework-agnostic runtime (React, Solid, Vue, or any binding you write). Zero runtime dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Aleksey Skhomenko",
|