@triggery/core 0.1.0 → 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.
Files changed (3) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +188 -10
  3. package/package.json +10 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
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
+
25
+ ## 0.1.1
26
+
27
+ ### Patch Changes
28
+
29
+ - 35936d1: Polished package metadata for framework-agnostic positioning.
30
+
31
+ - `@triggery/core` description corrected: it is **framework-agnostic** (React, Solid, Vue, or any binding you write), not React-only. Keywords now include `solid`, `vue`, `framework-agnostic`, `zero-dependencies`. README expanded to spell out what runs where.
32
+ - `@triggery/testing` README + description now mention **zero runtime dependencies** and that the kit works under Vitest, Jest, and `node:test` alike (no `vi.useFakeTimers` coupling).
33
+ - `@triggery/devtools-bridge`, `@triggery/devtools-redux`, `@triggery/vite` descriptions clarified as framework-agnostic / runtime-pure.
34
+ - `@triggery/react / solid / vue` descriptions now explicitly say **zero runtime dependencies** — the binding is a thin lifecycle adapter, nothing else.
35
+
36
+ No API or behaviour changes.
37
+
3
38
  ## 0.1.0
4
39
 
5
40
  First public preview release.
package/README.md CHANGED
@@ -1,23 +1,201 @@
1
1
  # @triggery/core
2
2
 
3
- Core runtime for [Triggery](https://github.com/triggeryjs/triggery) — a declarative orchestration layer for React business logic.
3
+ The runtime that powers [Triggery](https://github.com/triggeryjs/triggery) — a declarative `event conditions actions` orchestration layer.
4
4
 
5
- This package contains:
6
-
7
- - `createTrigger<Schema>(config)` — define a trigger.
8
- - `createRuntime()` — isolated runtime (registry + scheduler + inspector).
9
- - `getDefaultRuntime()` / `setDefaultRuntime()` — global singleton.
10
- - Lifecycle middleware chain.
11
- - Public types and helpers.
12
-
13
- You usually do not consume this package directly — use [`@triggery/react`](../react).
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.
14
6
 
15
7
  ## Install
16
8
 
17
9
  ```bash
18
10
  pnpm add @triggery/core
11
+ # plus your framework binding of choice (see below)
12
+ ```
13
+
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');
19
165
  ```
20
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
170
+
171
+ - `createTrigger<Schema>(config)` — declare a scenario in one file (events, conditions, required gate, handler).
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.
173
+ - `getDefaultRuntime()` / `setDefaultRuntime()` — global singleton for apps that don't want explicit provider wiring.
174
+ - Concurrency strategies for async handlers (`take-latest` / `take-every` / `take-first` / `queue` / `exhaust` / `sync`) with `AbortSignal`.
175
+ - `actions.debounce / throttle / defer / queue` chainable action wrappers.
176
+ - Last-mount-wins ownership with DEV warn-once.
177
+
178
+ ## Why "framework-agnostic"
179
+
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:
181
+
182
+ - a worker / service worker
183
+ - a Node.js process (CLI, server, edge)
184
+ - React Native (no DOM adapters needed for the runtime itself)
185
+ - a vanilla JS page
186
+
187
+ The same `createTrigger({...})` declaration runs unchanged across all of those. Bindings only wire `useEvent` / `useCondition` / `useAction` to the host framework's lifecycle.
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
+
21
199
  ## License
22
200
 
23
201
  MIT &copy; Aleksey Skhomenko
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@triggery/core",
3
- "version": "0.1.0",
4
- "description": "Declarative business-logic orchestration for React core runtime",
3
+ "version": "0.1.2",
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",
7
7
  "homepage": "https://triggeryjs.github.io/triggery",
@@ -22,13 +22,17 @@
22
22
  }
23
23
  ],
24
24
  "keywords": [
25
- "react",
26
25
  "triggers",
27
26
  "events",
28
27
  "orchestration",
29
28
  "business-logic",
30
29
  "rule-engine",
31
- "side-effects"
30
+ "side-effects",
31
+ "framework-agnostic",
32
+ "react",
33
+ "solid",
34
+ "vue",
35
+ "zero-dependencies"
32
36
  ],
33
37
  "type": "module",
34
38
  "main": "./dist/index.js",
@@ -51,7 +55,8 @@
51
55
  ],
52
56
  "sideEffects": false,
53
57
  "publishConfig": {
54
- "access": "public"
58
+ "access": "public",
59
+ "provenance": true
55
60
  },
56
61
  "devDependencies": {
57
62
  "tsup": "^8.5.1",