@creact-labs/creact 0.2.1 → 0.2.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/README.md +41 -81
- package/dist/cli.js +25 -20
- package/dist/index.d.ts +4 -12
- package/dist/index.js +3 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,100 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Build complex workflows with JSX. Describe *what* you want — CReact figures out *how*.
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @creact-labs/creact
|
|
11
|
-
```
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://img.shields.io/npm/v/@creact-labs/creact" alt="npm version" />
|
|
3
|
+
<img src="https://img.shields.io/npm/l/@creact-labs/creact" alt="license" />
|
|
4
|
+
</p>
|
|
12
5
|
|
|
13
|
-
|
|
6
|
+
# CReact
|
|
14
7
|
|
|
15
|
-
|
|
8
|
+
What if you could generate SEO-optimized product pages by researching competitors automatically?
|
|
16
9
|
|
|
17
10
|
```tsx
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// 💬 Notify your team
|
|
43
|
-
function SlackNotify({ channel, message }) {
|
|
44
|
-
return useInstance(SlackMessage, { channel, text: message });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// 🔗 Compose the pipeline
|
|
48
|
-
function ContentPipeline({ topic }) {
|
|
49
|
-
return (
|
|
50
|
-
<AIWriter topic={topic}>
|
|
51
|
-
{(content) => (
|
|
52
|
-
<>
|
|
53
|
-
<BlogPost title={content.title()} content={content.body()} />
|
|
54
|
-
<Tweet content={content} />
|
|
55
|
-
<SlackNotify
|
|
56
|
-
channel="#content"
|
|
57
|
-
message={`✨ New post published: ${content.title()}`}
|
|
58
|
-
/>
|
|
59
|
-
</>
|
|
11
|
+
<FormTrigger fields={['productTitle']}>
|
|
12
|
+
{(form) => (
|
|
13
|
+
<GoogleSearch query={`intitle:"${form.productTitle()}" pricing OR features`}>
|
|
14
|
+
{(results) => (
|
|
15
|
+
<ExtractText items={results.items()} fields={['title', 'snippet']}>
|
|
16
|
+
{(extracted) => (
|
|
17
|
+
<GeminiCompletion prompt={`Generate SEO meta and product description:\n${extracted.text()}`}>
|
|
18
|
+
{(content) => (
|
|
19
|
+
<>
|
|
20
|
+
<ParseSections text={content.output()} format="seo,product">
|
|
21
|
+
{(parsed) => (
|
|
22
|
+
<GoogleSheetAppend doc="catalog" row={parsed.fields()} />
|
|
23
|
+
)}
|
|
24
|
+
</ParseSections>
|
|
25
|
+
|
|
26
|
+
<SlackMessage channel="#products" text={`New: ${form.productTitle()}`} />
|
|
27
|
+
</>
|
|
28
|
+
)}
|
|
29
|
+
</GeminiCompletion>
|
|
30
|
+
)}
|
|
31
|
+
</ExtractText>
|
|
60
32
|
)}
|
|
61
|
-
</
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// Run it
|
|
66
|
-
await renderCloudDOM(<ContentPipeline topic="Why CReact changes everything" />);
|
|
33
|
+
</GoogleSearch>
|
|
34
|
+
)}
|
|
35
|
+
</FormTrigger>
|
|
67
36
|
```
|
|
68
37
|
|
|
69
|
-
|
|
38
|
+
Form → Search → Extract → AI → branches to Sheets and Slack. Each construct is one action.
|
|
70
39
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|---------------------|--------|
|
|
75
|
-
| Imperative scripts that break | Declarative specs that reconcile |
|
|
76
|
-
| Manual dependency tracking | Automatic reactive updates |
|
|
77
|
-
| Scattered state across files | Single source of truth |
|
|
78
|
-
| Hard to test and reason about | Composable, testable components |
|
|
40
|
+
```bash
|
|
41
|
+
npm install @creact-labs/creact
|
|
42
|
+
```
|
|
79
43
|
|
|
80
|
-
##
|
|
44
|
+
## How it works
|
|
81
45
|
|
|
82
|
-
**
|
|
46
|
+
**Constructs** define what you want (props) and what you get (outputs).
|
|
83
47
|
|
|
84
|
-
**
|
|
48
|
+
**Components** compose constructs with JSX. Dependencies flow through render props.
|
|
85
49
|
|
|
86
|
-
**
|
|
50
|
+
**Providers** execute constructs against real infrastructure (AWS, Terraform, APIs).
|
|
87
51
|
|
|
88
|
-
**
|
|
52
|
+
**Backends** persist state for crash recovery and incremental updates.
|
|
89
53
|
|
|
90
54
|
## Documentation
|
|
91
55
|
|
|
92
|
-
- [Tutorial
|
|
93
|
-
- [
|
|
94
|
-
- [Constructs](./docs/concepts/constructs.md)
|
|
95
|
-
- [Components](./docs/concepts/components.md)
|
|
96
|
-
- [Reactivity](./docs/concepts/reactivity.md)
|
|
97
|
-
- [Providers](./docs/concepts/providers.md)
|
|
56
|
+
- [Tutorial](./docs/getting-started/1-setup.md) — Build an AI agent with Wikipedia search
|
|
57
|
+
- [Concepts](./docs/concepts/index.md) — Core mental model
|
|
98
58
|
|
|
99
59
|
## License
|
|
100
60
|
|
package/dist/cli.js
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
* Runs a CReact application with the configured provider.
|
|
9
9
|
* Uses tsx under the hood to execute TypeScript/TSX files.
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { tsImport } from 'tsx/esm/api';
|
|
12
|
+
import { watch } from 'node:fs/promises';
|
|
13
|
+
import { dirname, resolve } from 'node:path';
|
|
14
|
+
import { pathToFileURL } from 'node:url';
|
|
13
15
|
function showHelp() {
|
|
14
16
|
console.log(`
|
|
15
17
|
CReact CLI
|
|
@@ -41,6 +43,12 @@ Example entrypoint:
|
|
|
41
43
|
}
|
|
42
44
|
`);
|
|
43
45
|
}
|
|
46
|
+
async function runEntrypoint(entrypoint) {
|
|
47
|
+
const module = await tsImport(pathToFileURL(entrypoint).href, import.meta.url);
|
|
48
|
+
if (typeof module.default === 'function') {
|
|
49
|
+
await module.default();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
44
52
|
async function main() {
|
|
45
53
|
const args = process.argv.slice(2);
|
|
46
54
|
if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
|
|
@@ -48,11 +56,11 @@ async function main() {
|
|
|
48
56
|
process.exit(0);
|
|
49
57
|
}
|
|
50
58
|
// Parse --watch / -w flag and get entrypoint
|
|
51
|
-
let
|
|
59
|
+
let watchMode = false;
|
|
52
60
|
let entrypointArg;
|
|
53
61
|
const firstArg = args[0];
|
|
54
62
|
if (firstArg === '--watch' || firstArg === '-w') {
|
|
55
|
-
|
|
63
|
+
watchMode = true;
|
|
56
64
|
const arg = args[1];
|
|
57
65
|
if (!arg) {
|
|
58
66
|
console.error('Error: --watch requires an entrypoint');
|
|
@@ -68,21 +76,18 @@ async function main() {
|
|
|
68
76
|
process.exit(0);
|
|
69
77
|
}
|
|
70
78
|
const entrypoint = resolve(process.cwd(), entrypointArg);
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
child.on('exit', (code) => {
|
|
85
|
-
process.exit(code ?? 0);
|
|
86
|
-
});
|
|
79
|
+
// Initial run
|
|
80
|
+
await runEntrypoint(entrypoint);
|
|
81
|
+
// Watch mode: async iterator keeps process alive
|
|
82
|
+
if (watchMode) {
|
|
83
|
+
console.log('Watching for changes...');
|
|
84
|
+
const watcher = watch(dirname(entrypoint), { recursive: true });
|
|
85
|
+
for await (const event of watcher) {
|
|
86
|
+
if (event.filename?.match(/\.(tsx?|jsx?)$/)) {
|
|
87
|
+
console.log(`\nRestarting...`);
|
|
88
|
+
await runEntrypoint(entrypoint);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
87
92
|
}
|
|
88
93
|
main();
|
package/dist/index.d.ts
CHANGED
|
@@ -5,17 +5,9 @@ export { createElement, Fragment, jsx, jsxs } from './jsx/jsx-runtime';
|
|
|
5
5
|
export { createContext, useContext } from './primitives/context';
|
|
6
6
|
export { useInstance } from './primitives/instance';
|
|
7
7
|
export { createStore } from './primitives/store';
|
|
8
|
-
export
|
|
9
|
-
export {
|
|
8
|
+
export { createEffect } from './reactive/effect';
|
|
9
|
+
export { CReact, renderCloudDOM } from './runtime/run';
|
|
10
|
+
export type { AuditLogEntry, Backend, DeploymentState } from './provider/backend';
|
|
10
11
|
export type { OutputChangeEvent, Provider } from './provider/interface';
|
|
11
12
|
export { createMockProvider } from './provider/interface';
|
|
12
|
-
export {
|
|
13
|
-
export { createSignal } from './reactive/signal';
|
|
14
|
-
export { batch, untrack } from './reactive/tracking';
|
|
15
|
-
export type { DependencyGraph } from './runtime/reconcile';
|
|
16
|
-
export { buildDependencyGraph, computeParallelBatches, hasNewNodes, reconcile, topologicalSort, } from './runtime/reconcile';
|
|
17
|
-
export type { CReactOptions } from './runtime/run';
|
|
18
|
-
export { CReact, renderCloudDOM, resetRuntime, run, runWithBackend } from './runtime/run';
|
|
19
|
-
export type { StateMachineOptions } from './runtime/state-machine';
|
|
20
|
-
export { StateMachine } from './runtime/state-machine';
|
|
21
|
-
export type { Accessor, Context, Fiber, InstanceNode, JSXElement, OutputAccessors, SetStoreFunction, Setter, } from './types';
|
|
13
|
+
export type { Context, InstanceNode, JSXElement, OutputAccessors, SetStoreFunction, } from './types';
|
package/dist/index.js
CHANGED
|
@@ -7,16 +7,7 @@ export { createContext, useContext } from './primitives/context';
|
|
|
7
7
|
// Primitives
|
|
8
8
|
export { useInstance } from './primitives/instance';
|
|
9
9
|
export { createStore } from './primitives/store';
|
|
10
|
-
|
|
11
|
-
export { serializeNode, serializeNodes } from './provider/backend';
|
|
12
|
-
// Provider
|
|
13
|
-
export { createMockProvider } from './provider/interface';
|
|
14
|
-
// Reactive
|
|
15
|
-
export { createEffect, onCleanup } from './reactive/effect';
|
|
16
|
-
export { createSignal } from './reactive/signal';
|
|
17
|
-
export { batch, untrack } from './reactive/tracking';
|
|
18
|
-
// Reconciler
|
|
19
|
-
export { buildDependencyGraph, computeParallelBatches, hasNewNodes, reconcile, topologicalSort, } from './runtime/reconcile';
|
|
10
|
+
export { createEffect } from './reactive/effect';
|
|
20
11
|
// Runtime
|
|
21
|
-
export { CReact, renderCloudDOM
|
|
22
|
-
export {
|
|
12
|
+
export { CReact, renderCloudDOM } from './runtime/run';
|
|
13
|
+
export { createMockProvider } from './provider/interface';
|