@creact-labs/creact 0.1.8 → 0.2.1
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 +85 -22
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +88 -0
- package/dist/index.d.ts +19 -44
- package/dist/index.js +20 -68
- package/dist/jsx/index.d.ts +2 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
- package/dist/jsx/jsx-dev-runtime.js +4 -0
- package/dist/jsx/jsx-runtime.d.ts +38 -0
- package/dist/jsx/jsx-runtime.js +38 -0
- package/dist/jsx/types.d.ts +12 -0
- package/dist/jsx/types.js +4 -0
- package/dist/primitives/context.d.ts +34 -0
- package/dist/primitives/context.js +63 -0
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.js +3 -0
- package/dist/primitives/instance.d.ts +72 -0
- package/dist/primitives/instance.js +235 -0
- package/dist/primitives/store.d.ts +22 -0
- package/dist/primitives/store.js +97 -0
- package/dist/provider/backend.d.ts +110 -0
- package/dist/provider/backend.js +37 -0
- package/dist/provider/interface.d.ts +48 -0
- package/dist/provider/interface.js +39 -0
- package/dist/reactive/effect.d.ts +11 -0
- package/dist/reactive/effect.js +42 -0
- package/dist/reactive/index.d.ts +3 -0
- package/dist/reactive/index.js +3 -0
- package/dist/reactive/signal.d.ts +32 -0
- package/dist/reactive/signal.js +60 -0
- package/dist/reactive/tracking.d.ts +41 -0
- package/dist/reactive/tracking.js +161 -0
- package/dist/runtime/fiber.d.ts +21 -0
- package/dist/runtime/fiber.js +16 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/reconcile.d.ts +66 -0
- package/dist/runtime/reconcile.js +210 -0
- package/dist/runtime/render.d.ts +42 -0
- package/dist/runtime/render.js +231 -0
- package/dist/runtime/run.d.ts +119 -0
- package/dist/runtime/run.js +334 -0
- package/dist/runtime/state-machine.d.ts +95 -0
- package/dist/runtime/state-machine.js +209 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.js +4 -0
- package/package.json +29 -24
- package/dist/cli/commands/BuildCommand.d.ts +0 -40
- package/dist/cli/commands/BuildCommand.js +0 -151
- package/dist/cli/commands/DeployCommand.d.ts +0 -38
- package/dist/cli/commands/DeployCommand.js +0 -194
- package/dist/cli/commands/DevCommand.d.ts +0 -52
- package/dist/cli/commands/DevCommand.js +0 -394
- package/dist/cli/commands/PlanCommand.d.ts +0 -39
- package/dist/cli/commands/PlanCommand.js +0 -164
- package/dist/cli/commands/index.d.ts +0 -36
- package/dist/cli/commands/index.js +0 -43
- package/dist/cli/core/ArgumentParser.d.ts +0 -46
- package/dist/cli/core/ArgumentParser.js +0 -127
- package/dist/cli/core/BaseCommand.d.ts +0 -75
- package/dist/cli/core/BaseCommand.js +0 -95
- package/dist/cli/core/CLIContext.d.ts +0 -68
- package/dist/cli/core/CLIContext.js +0 -183
- package/dist/cli/core/CommandRegistry.d.ts +0 -64
- package/dist/cli/core/CommandRegistry.js +0 -89
- package/dist/cli/core/index.d.ts +0 -36
- package/dist/cli/core/index.js +0 -43
- package/dist/cli/index.d.ts +0 -35
- package/dist/cli/index.js +0 -100
- package/dist/cli/output.d.ts +0 -204
- package/dist/cli/output.js +0 -437
- package/dist/cli/utils.d.ts +0 -59
- package/dist/cli/utils.js +0 -76
- package/dist/context/createContext.d.ts +0 -90
- package/dist/context/createContext.js +0 -113
- package/dist/context/index.d.ts +0 -30
- package/dist/context/index.js +0 -35
- package/dist/core/CReact.d.ts +0 -409
- package/dist/core/CReact.js +0 -1151
- package/dist/core/CloudDOMBuilder.d.ts +0 -447
- package/dist/core/CloudDOMBuilder.js +0 -1234
- package/dist/core/ContextDependencyTracker.d.ts +0 -165
- package/dist/core/ContextDependencyTracker.js +0 -448
- package/dist/core/ErrorRecoveryManager.d.ts +0 -145
- package/dist/core/ErrorRecoveryManager.js +0 -443
- package/dist/core/EventBus.d.ts +0 -91
- package/dist/core/EventBus.js +0 -185
- package/dist/core/ProviderOutputTracker.d.ts +0 -211
- package/dist/core/ProviderOutputTracker.js +0 -476
- package/dist/core/ReactiveUpdateQueue.d.ts +0 -76
- package/dist/core/ReactiveUpdateQueue.js +0 -121
- package/dist/core/Reconciler.d.ts +0 -415
- package/dist/core/Reconciler.js +0 -1044
- package/dist/core/RenderScheduler.d.ts +0 -153
- package/dist/core/RenderScheduler.js +0 -519
- package/dist/core/Renderer.d.ts +0 -336
- package/dist/core/Renderer.js +0 -944
- package/dist/core/Runtime.d.ts +0 -246
- package/dist/core/Runtime.js +0 -640
- package/dist/core/StateBindingManager.d.ts +0 -121
- package/dist/core/StateBindingManager.js +0 -309
- package/dist/core/StateMachine.d.ts +0 -441
- package/dist/core/StateMachine.js +0 -883
- package/dist/core/StructuralChangeDetector.d.ts +0 -140
- package/dist/core/StructuralChangeDetector.js +0 -363
- package/dist/core/Validator.d.ts +0 -127
- package/dist/core/Validator.js +0 -279
- package/dist/core/errors.d.ts +0 -153
- package/dist/core/errors.js +0 -202
- package/dist/core/index.d.ts +0 -38
- package/dist/core/index.js +0 -64
- package/dist/core/types.d.ts +0 -265
- package/dist/core/types.js +0 -48
- package/dist/hooks/context.d.ts +0 -147
- package/dist/hooks/context.js +0 -334
- package/dist/hooks/useContext.d.ts +0 -113
- package/dist/hooks/useContext.js +0 -169
- package/dist/hooks/useEffect.d.ts +0 -105
- package/dist/hooks/useEffect.js +0 -540
- package/dist/hooks/useInstance.d.ts +0 -139
- package/dist/hooks/useInstance.js +0 -455
- package/dist/hooks/useState.d.ts +0 -120
- package/dist/hooks/useState.js +0 -298
- package/dist/jsx.d.ts +0 -143
- package/dist/jsx.js +0 -76
- package/dist/providers/DummyBackendProvider.d.ts +0 -193
- package/dist/providers/DummyBackendProvider.js +0 -189
- package/dist/providers/DummyCloudProvider.d.ts +0 -128
- package/dist/providers/DummyCloudProvider.js +0 -157
- package/dist/providers/IBackendProvider.d.ts +0 -177
- package/dist/providers/IBackendProvider.js +0 -31
- package/dist/providers/ICloudProvider.d.ts +0 -230
- package/dist/providers/ICloudProvider.js +0 -31
- package/dist/providers/index.d.ts +0 -31
- package/dist/providers/index.js +0 -31
- package/dist/test-event-callbacks.d.ts +0 -0
- package/dist/test-event-callbacks.js +0 -1
- package/dist/utils/Logger.d.ts +0 -144
- package/dist/utils/Logger.js +0 -220
- package/dist/utils/Output.d.ts +0 -161
- package/dist/utils/Output.js +0 -401
- package/dist/utils/deepEqual.d.ts +0 -71
- package/dist/utils/deepEqual.js +0 -276
- package/dist/utils/naming.d.ts +0 -241
- package/dist/utils/naming.js +0 -376
package/README.md
CHANGED
|
@@ -1,38 +1,101 @@
|
|
|
1
|
+
# CReact
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
**Declarative reactive runtime for AI agents, cloud infrastructure, and automation.**
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
Build complex workflows with JSX. Describe *what* you want — CReact figures out *how*.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @creact-labs/creact
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Example: AI Content Pipeline
|
|
14
|
+
|
|
15
|
+
A workflow that generates blog posts and publishes to multiple channels — all reactive and declarative:
|
|
7
16
|
|
|
8
17
|
```tsx
|
|
9
|
-
|
|
18
|
+
import { CReact, renderCloudDOM, useInstance, createSignal } from '@creact-labs/creact';
|
|
19
|
+
|
|
20
|
+
// 🤖 AI generates content from a topic
|
|
21
|
+
function AIWriter({ topic, children }) {
|
|
22
|
+
const content = useInstance(OpenAICompletion, {
|
|
23
|
+
model: 'gpt-4',
|
|
24
|
+
prompt: `Write a blog post about: ${topic}`,
|
|
25
|
+
});
|
|
26
|
+
return children(content);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 📝 Publish to your blog
|
|
30
|
+
function BlogPost({ title, content }) {
|
|
31
|
+
return useInstance(WordPressPost, { title, content, status: 'published' });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 🐦 Share on social
|
|
35
|
+
function Tweet({ content }) {
|
|
36
|
+
return useInstance(TwitterPost, {
|
|
37
|
+
text: content.summary(),
|
|
38
|
+
thread: true,
|
|
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 }) {
|
|
10
49
|
return (
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
</>
|
|
60
|
+
)}
|
|
61
|
+
</AIWriter>
|
|
18
62
|
);
|
|
19
63
|
}
|
|
64
|
+
|
|
65
|
+
// Run it
|
|
66
|
+
await renderCloudDOM(<ContentPipeline topic="Why CReact changes everything" />);
|
|
20
67
|
```
|
|
21
68
|
|
|
22
|
-
|
|
69
|
+
**Change the topic → everything updates.** The blog post regenerates, tweet updates, Slack notifies.
|
|
23
70
|
|
|
24
|
-
|
|
71
|
+
## Why CReact?
|
|
25
72
|
|
|
26
|
-
|
|
73
|
+
| Traditional Approach | CReact |
|
|
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 |
|
|
27
79
|
|
|
28
|
-
|
|
29
|
-
# Deploy your infrastructure
|
|
30
|
-
creact deploy --entry my-app.tsx
|
|
80
|
+
## The Four Pillars
|
|
31
81
|
|
|
32
|
-
|
|
33
|
-
creact dev --entry my-app.tsx --auto-approve
|
|
82
|
+
**Declarative** — Describe what you want, not how to get it.
|
|
34
83
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
84
|
+
**Universal** — Works for AI agents, cloud infrastructure, APIs, anything.
|
|
85
|
+
|
|
86
|
+
**Reactive** — Automatically responds when things change.
|
|
87
|
+
|
|
88
|
+
**Runtime** — Keeps running continuously, handles events, recovers from crashes.
|
|
89
|
+
|
|
90
|
+
## Documentation
|
|
91
|
+
|
|
92
|
+
- [Tutorial: Build an AI Agent](./docs/getting-started/1-setup.md)
|
|
93
|
+
- [Thinking in CReact](./docs/concepts/thinking-in-creact.md)
|
|
94
|
+
- [Constructs](./docs/concepts/constructs.md)
|
|
95
|
+
- [Components](./docs/concepts/components.md)
|
|
96
|
+
- [Reactivity](./docs/concepts/reactivity.md)
|
|
97
|
+
- [Providers](./docs/concepts/providers.md)
|
|
98
|
+
|
|
99
|
+
## License
|
|
38
100
|
|
|
101
|
+
Apache-2.0
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CReact CLI
|
|
4
|
+
*
|
|
5
|
+
* Usage: creact ./app.tsx
|
|
6
|
+
* creact --watch ./app.tsx
|
|
7
|
+
*
|
|
8
|
+
* Runs a CReact application with the configured provider.
|
|
9
|
+
* Uses tsx under the hood to execute TypeScript/TSX files.
|
|
10
|
+
*/
|
|
11
|
+
import { spawn } from 'node:child_process';
|
|
12
|
+
import { resolve } from 'node:path';
|
|
13
|
+
function showHelp() {
|
|
14
|
+
console.log(`
|
|
15
|
+
CReact CLI
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
creact <entrypoint> Run a CReact application
|
|
19
|
+
creact --watch <entrypoint> Run with hot reload on file changes
|
|
20
|
+
creact -w <entrypoint> Short form of --watch
|
|
21
|
+
creact --help Show this help message
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
creact ./app.tsx Run app.tsx
|
|
25
|
+
creact -w ./app.tsx Run with hot reload
|
|
26
|
+
creact --watch src/index.tsx Run src/index.tsx with hot reload
|
|
27
|
+
|
|
28
|
+
The entrypoint file should:
|
|
29
|
+
1. Set CReact.provider to your provider
|
|
30
|
+
2. Export a default async function that calls renderCloudDOM()
|
|
31
|
+
|
|
32
|
+
Example entrypoint:
|
|
33
|
+
import { CReact, renderCloudDOM } from 'creact';
|
|
34
|
+
import { App } from './components/App.js';
|
|
35
|
+
import { MyProvider } from './providers/MyProvider.js';
|
|
36
|
+
|
|
37
|
+
CReact.provider = await MyProvider.create();
|
|
38
|
+
|
|
39
|
+
export default async function() {
|
|
40
|
+
return await renderCloudDOM(<App />, 'my-stack');
|
|
41
|
+
}
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
async function main() {
|
|
45
|
+
const args = process.argv.slice(2);
|
|
46
|
+
if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
|
|
47
|
+
showHelp();
|
|
48
|
+
process.exit(0);
|
|
49
|
+
}
|
|
50
|
+
// Parse --watch / -w flag and get entrypoint
|
|
51
|
+
let watch = false;
|
|
52
|
+
let entrypointArg;
|
|
53
|
+
const firstArg = args[0];
|
|
54
|
+
if (firstArg === '--watch' || firstArg === '-w') {
|
|
55
|
+
watch = true;
|
|
56
|
+
const arg = args[1];
|
|
57
|
+
if (!arg) {
|
|
58
|
+
console.error('Error: --watch requires an entrypoint');
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
entrypointArg = arg;
|
|
62
|
+
}
|
|
63
|
+
else if (firstArg) {
|
|
64
|
+
entrypointArg = firstArg;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
showHelp();
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
const entrypoint = resolve(process.cwd(), entrypointArg);
|
|
71
|
+
// Build tsx command
|
|
72
|
+
const tsxArgs = watch ? ['tsx', 'watch', entrypoint] : ['tsx', entrypoint];
|
|
73
|
+
// Spawn tsx to run the entrypoint
|
|
74
|
+
const child = spawn('npx', tsxArgs, {
|
|
75
|
+
stdio: 'inherit',
|
|
76
|
+
cwd: process.cwd(),
|
|
77
|
+
shell: true,
|
|
78
|
+
});
|
|
79
|
+
child.on('error', (error) => {
|
|
80
|
+
console.error('Error running CReact application:');
|
|
81
|
+
console.error(error.message);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
});
|
|
84
|
+
child.on('exit', (code) => {
|
|
85
|
+
process.exit(code ?? 0);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
main();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
|
|
23
|
-
* limitations under the License.
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
* Copyright 2025 Daniel Coutinho Ribeiro
|
|
28
|
-
|
|
2
|
+
* CReact - Universal Reactive Runtime
|
|
29
3
|
*/
|
|
30
|
-
export {
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
export
|
|
35
|
-
export {
|
|
36
|
-
export {
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
39
|
-
export {
|
|
40
|
-
export {
|
|
41
|
-
export {
|
|
42
|
-
export {
|
|
43
|
-
export {
|
|
44
|
-
export {
|
|
45
|
-
export {
|
|
46
|
-
export {
|
|
4
|
+
export { createElement, Fragment, jsx, jsxs } from './jsx/jsx-runtime';
|
|
5
|
+
export { createContext, useContext } from './primitives/context';
|
|
6
|
+
export { useInstance } from './primitives/instance';
|
|
7
|
+
export { createStore } from './primitives/store';
|
|
8
|
+
export type { AuditLogEntry, Backend, ChangeSet, DeploymentState, DeploymentStatus, ResourceState, SerializedNode, } from './provider/backend';
|
|
9
|
+
export { serializeNode, serializeNodes } from './provider/backend';
|
|
10
|
+
export type { OutputChangeEvent, Provider } from './provider/interface';
|
|
11
|
+
export { createMockProvider } from './provider/interface';
|
|
12
|
+
export { createEffect, onCleanup } from './reactive/effect';
|
|
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';
|
package/dist/index.js
CHANGED
|
@@ -1,70 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
|
-
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
|
|
20
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
|
|
22
|
-
* See the License for the specific language governing permissions and
|
|
23
|
-
|
|
24
|
-
* limitations under the License.
|
|
25
|
-
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
* Copyright 2025 Daniel Coutinho Ribeiro
|
|
29
|
-
|
|
2
|
+
* CReact - Universal Reactive Runtime
|
|
30
3
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var useInstance_1 = require("./hooks/useInstance");
|
|
51
|
-
Object.defineProperty(exports, "useInstance", { enumerable: true, get: function () { return useInstance_1.useInstance; } });
|
|
52
|
-
var useState_1 = require("./hooks/useState");
|
|
53
|
-
Object.defineProperty(exports, "useState", { enumerable: true, get: function () { return useState_1.useState; } });
|
|
54
|
-
var useContext_1 = require("./hooks/useContext");
|
|
55
|
-
Object.defineProperty(exports, "useContext", { enumerable: true, get: function () { return useContext_1.useContext; } });
|
|
56
|
-
var useEffect_1 = require("./hooks/useEffect");
|
|
57
|
-
Object.defineProperty(exports, "useEffect", { enumerable: true, get: function () { return useEffect_1.useEffect; } });
|
|
58
|
-
// Context API
|
|
59
|
-
var context_1 = require("./context");
|
|
60
|
-
Object.defineProperty(exports, "createContext", { enumerable: true, get: function () { return context_1.createContext; } });
|
|
61
|
-
// Utilities
|
|
62
|
-
var naming_1 = require("./utils/naming");
|
|
63
|
-
Object.defineProperty(exports, "generateResourceId", { enumerable: true, get: function () { return naming_1.generateResourceId; } });
|
|
64
|
-
Object.defineProperty(exports, "toKebabCase", { enumerable: true, get: function () { return naming_1.toKebabCase; } });
|
|
65
|
-
Object.defineProperty(exports, "getNodeName", { enumerable: true, get: function () { return naming_1.getNodeName; } });
|
|
66
|
-
Object.defineProperty(exports, "validateIdUniqueness", { enumerable: true, get: function () { return naming_1.validateIdUniqueness; } });
|
|
67
|
-
Object.defineProperty(exports, "normalizePathSegment", { enumerable: true, get: function () { return naming_1.normalizePathSegment; } });
|
|
68
|
-
Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return naming_1.normalizePath; } });
|
|
69
|
-
Object.defineProperty(exports, "formatPath", { enumerable: true, get: function () { return naming_1.formatPath; } });
|
|
70
|
-
Object.defineProperty(exports, "parseResourceId", { enumerable: true, get: function () { return naming_1.parseResourceId; } });
|
|
4
|
+
// JSX
|
|
5
|
+
export { createElement, Fragment, jsx, jsxs } from './jsx/jsx-runtime';
|
|
6
|
+
export { createContext, useContext } from './primitives/context';
|
|
7
|
+
// Primitives
|
|
8
|
+
export { useInstance } from './primitives/instance';
|
|
9
|
+
export { createStore } from './primitives/store';
|
|
10
|
+
// Backend
|
|
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';
|
|
20
|
+
// Runtime
|
|
21
|
+
export { CReact, renderCloudDOM, resetRuntime, run, runWithBackend } from './runtime/run';
|
|
22
|
+
export { StateMachine } from './runtime/state-machine';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createElement, Fragment, jsx, jsxDEV, jsxs } from './jsx-runtime';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSX Runtime - createElement and Fragment
|
|
3
|
+
*/
|
|
4
|
+
export interface JSXElement {
|
|
5
|
+
type: any;
|
|
6
|
+
props: Record<string, any>;
|
|
7
|
+
key?: string | number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* JSX namespace for TypeScript
|
|
11
|
+
* Handles key and children automatically - no need to declare in component props
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace JSX {
|
|
14
|
+
type Element = JSXElement;
|
|
15
|
+
interface IntrinsicElements {
|
|
16
|
+
[elemName: string]: any;
|
|
17
|
+
}
|
|
18
|
+
interface IntrinsicAttributes {
|
|
19
|
+
key?: string | number;
|
|
20
|
+
}
|
|
21
|
+
interface ElementChildrenAttribute {
|
|
22
|
+
children: {};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a JSX element
|
|
27
|
+
*/
|
|
28
|
+
export declare function createElement(type: any, props: Record<string, any> | null, ...children: any[]): JSXElement;
|
|
29
|
+
/**
|
|
30
|
+
* Fragment - renders children without wrapper
|
|
31
|
+
*/
|
|
32
|
+
export declare const Fragment: unique symbol;
|
|
33
|
+
/**
|
|
34
|
+
* JSX runtime functions (for automatic JSX transform)
|
|
35
|
+
*/
|
|
36
|
+
export declare function jsx(type: any, props: Record<string, any>, key?: string | number): JSXElement;
|
|
37
|
+
export declare function jsxs(type: any, props: Record<string, any>, key?: string | number): JSXElement;
|
|
38
|
+
export { jsx as jsxDEV };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSX Runtime - createElement and Fragment
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create a JSX element
|
|
6
|
+
*/
|
|
7
|
+
export function createElement(type, props, ...children) {
|
|
8
|
+
const normalizedProps = { ...props };
|
|
9
|
+
// Handle children
|
|
10
|
+
if (children.length === 1) {
|
|
11
|
+
normalizedProps.children = children[0];
|
|
12
|
+
}
|
|
13
|
+
else if (children.length > 1) {
|
|
14
|
+
normalizedProps.children = children;
|
|
15
|
+
}
|
|
16
|
+
// Extract key
|
|
17
|
+
const key = normalizedProps.key;
|
|
18
|
+
delete normalizedProps.key;
|
|
19
|
+
return {
|
|
20
|
+
type,
|
|
21
|
+
props: normalizedProps,
|
|
22
|
+
key,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fragment - renders children without wrapper
|
|
27
|
+
*/
|
|
28
|
+
export const Fragment = Symbol.for('creact.fragment');
|
|
29
|
+
/**
|
|
30
|
+
* JSX runtime functions (for automatic JSX transform)
|
|
31
|
+
*/
|
|
32
|
+
export function jsx(type, props, key) {
|
|
33
|
+
return { type, props, key };
|
|
34
|
+
}
|
|
35
|
+
export function jsxs(type, props, key) {
|
|
36
|
+
return { type, props, key };
|
|
37
|
+
}
|
|
38
|
+
export { jsx as jsxDEV };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context - pass values down the component tree (non-reactive)
|
|
3
|
+
*/
|
|
4
|
+
export interface Context<T> {
|
|
5
|
+
id: symbol;
|
|
6
|
+
defaultValue: T | undefined;
|
|
7
|
+
Provider: (props: {
|
|
8
|
+
value: T;
|
|
9
|
+
children: any;
|
|
10
|
+
}) => any;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a context for passing values down the tree
|
|
14
|
+
*/
|
|
15
|
+
export declare function createContext<T>(defaultValue?: T): Context<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Read a context value
|
|
18
|
+
*/
|
|
19
|
+
export declare function useContext<T>(context: Context<T>): T;
|
|
20
|
+
/**
|
|
21
|
+
* Push a context value (called by renderer)
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare function pushContext<T>(contextId: symbol, value: T): void;
|
|
25
|
+
/**
|
|
26
|
+
* Pop a context value (called by renderer)
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function popContext(contextId: symbol): void;
|
|
30
|
+
/**
|
|
31
|
+
* Clear all context stacks (for testing)
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export declare function clearContextStacks(): void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context - pass values down the component tree (non-reactive)
|
|
3
|
+
*/
|
|
4
|
+
// Stack of values per context ID
|
|
5
|
+
// biome-ignore lint/suspicious/noExplicitAny: context values can be any type
|
|
6
|
+
const contextStacks = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* Create a context for passing values down the tree
|
|
9
|
+
*/
|
|
10
|
+
export function createContext(defaultValue) {
|
|
11
|
+
const id = Symbol('context');
|
|
12
|
+
// biome-ignore lint/suspicious/noExplicitAny: Provider accepts any JSX children
|
|
13
|
+
const Provider = (props) => {
|
|
14
|
+
return {
|
|
15
|
+
type: Provider,
|
|
16
|
+
props,
|
|
17
|
+
__context: id,
|
|
18
|
+
__isProvider: true,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
id,
|
|
23
|
+
defaultValue,
|
|
24
|
+
Provider,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Read a context value
|
|
29
|
+
*/
|
|
30
|
+
export function useContext(context) {
|
|
31
|
+
const stack = contextStacks.get(context.id);
|
|
32
|
+
if (stack?.length) {
|
|
33
|
+
return stack[stack.length - 1];
|
|
34
|
+
}
|
|
35
|
+
return context.defaultValue;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Push a context value (called by renderer)
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export function pushContext(contextId, value) {
|
|
42
|
+
let stack = contextStacks.get(contextId);
|
|
43
|
+
if (!stack) {
|
|
44
|
+
stack = [];
|
|
45
|
+
contextStacks.set(contextId, stack);
|
|
46
|
+
}
|
|
47
|
+
stack.push(value);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Pop a context value (called by renderer)
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export function popContext(contextId) {
|
|
54
|
+
const stack = contextStacks.get(contextId);
|
|
55
|
+
stack?.pop();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Clear all context stacks (for testing)
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export function clearContextStacks() {
|
|
62
|
+
contextStacks.clear();
|
|
63
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type Context, createContext, useContext } from './context';
|
|
2
|
+
export { clearNodeRegistry, fillInstanceOutputs, getAllNodes, getNodeById, type InstanceNode, type OutputAccessors, useInstance, } from './instance';
|
|
3
|
+
export { createStore, type SetStoreFunction } from './store';
|