@creact-labs/creact 0.1.8 → 0.2.0

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 (146) hide show
  1. package/README.md +73 -22
  2. package/dist/cli.d.ts +11 -0
  3. package/dist/cli.js +88 -0
  4. package/dist/index.d.ts +19 -44
  5. package/dist/index.js +20 -68
  6. package/dist/jsx/index.d.ts +2 -0
  7. package/dist/jsx/index.js +1 -0
  8. package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
  9. package/dist/jsx/jsx-dev-runtime.js +4 -0
  10. package/dist/jsx/jsx-runtime.d.ts +38 -0
  11. package/dist/jsx/jsx-runtime.js +38 -0
  12. package/dist/jsx/types.d.ts +12 -0
  13. package/dist/jsx/types.js +4 -0
  14. package/dist/primitives/context.d.ts +34 -0
  15. package/dist/primitives/context.js +63 -0
  16. package/dist/primitives/index.d.ts +3 -0
  17. package/dist/primitives/index.js +3 -0
  18. package/dist/primitives/instance.d.ts +72 -0
  19. package/dist/primitives/instance.js +235 -0
  20. package/dist/primitives/store.d.ts +22 -0
  21. package/dist/primitives/store.js +97 -0
  22. package/dist/provider/backend.d.ts +110 -0
  23. package/dist/provider/backend.js +37 -0
  24. package/dist/provider/interface.d.ts +48 -0
  25. package/dist/provider/interface.js +39 -0
  26. package/dist/reactive/effect.d.ts +11 -0
  27. package/dist/reactive/effect.js +42 -0
  28. package/dist/reactive/index.d.ts +3 -0
  29. package/dist/reactive/index.js +3 -0
  30. package/dist/reactive/signal.d.ts +32 -0
  31. package/dist/reactive/signal.js +60 -0
  32. package/dist/reactive/tracking.d.ts +41 -0
  33. package/dist/reactive/tracking.js +161 -0
  34. package/dist/runtime/fiber.d.ts +21 -0
  35. package/dist/runtime/fiber.js +16 -0
  36. package/dist/runtime/index.d.ts +4 -0
  37. package/dist/runtime/index.js +4 -0
  38. package/dist/runtime/reconcile.d.ts +66 -0
  39. package/dist/runtime/reconcile.js +210 -0
  40. package/dist/runtime/render.d.ts +42 -0
  41. package/dist/runtime/render.js +231 -0
  42. package/dist/runtime/run.d.ts +119 -0
  43. package/dist/runtime/run.js +334 -0
  44. package/dist/runtime/state-machine.d.ts +95 -0
  45. package/dist/runtime/state-machine.js +209 -0
  46. package/dist/types.d.ts +13 -0
  47. package/dist/types.js +4 -0
  48. package/package.json +11 -24
  49. package/dist/cli/commands/BuildCommand.d.ts +0 -40
  50. package/dist/cli/commands/BuildCommand.js +0 -151
  51. package/dist/cli/commands/DeployCommand.d.ts +0 -38
  52. package/dist/cli/commands/DeployCommand.js +0 -194
  53. package/dist/cli/commands/DevCommand.d.ts +0 -52
  54. package/dist/cli/commands/DevCommand.js +0 -394
  55. package/dist/cli/commands/PlanCommand.d.ts +0 -39
  56. package/dist/cli/commands/PlanCommand.js +0 -164
  57. package/dist/cli/commands/index.d.ts +0 -36
  58. package/dist/cli/commands/index.js +0 -43
  59. package/dist/cli/core/ArgumentParser.d.ts +0 -46
  60. package/dist/cli/core/ArgumentParser.js +0 -127
  61. package/dist/cli/core/BaseCommand.d.ts +0 -75
  62. package/dist/cli/core/BaseCommand.js +0 -95
  63. package/dist/cli/core/CLIContext.d.ts +0 -68
  64. package/dist/cli/core/CLIContext.js +0 -183
  65. package/dist/cli/core/CommandRegistry.d.ts +0 -64
  66. package/dist/cli/core/CommandRegistry.js +0 -89
  67. package/dist/cli/core/index.d.ts +0 -36
  68. package/dist/cli/core/index.js +0 -43
  69. package/dist/cli/index.d.ts +0 -35
  70. package/dist/cli/index.js +0 -100
  71. package/dist/cli/output.d.ts +0 -204
  72. package/dist/cli/output.js +0 -437
  73. package/dist/cli/utils.d.ts +0 -59
  74. package/dist/cli/utils.js +0 -76
  75. package/dist/context/createContext.d.ts +0 -90
  76. package/dist/context/createContext.js +0 -113
  77. package/dist/context/index.d.ts +0 -30
  78. package/dist/context/index.js +0 -35
  79. package/dist/core/CReact.d.ts +0 -409
  80. package/dist/core/CReact.js +0 -1151
  81. package/dist/core/CloudDOMBuilder.d.ts +0 -447
  82. package/dist/core/CloudDOMBuilder.js +0 -1234
  83. package/dist/core/ContextDependencyTracker.d.ts +0 -165
  84. package/dist/core/ContextDependencyTracker.js +0 -448
  85. package/dist/core/ErrorRecoveryManager.d.ts +0 -145
  86. package/dist/core/ErrorRecoveryManager.js +0 -443
  87. package/dist/core/EventBus.d.ts +0 -91
  88. package/dist/core/EventBus.js +0 -185
  89. package/dist/core/ProviderOutputTracker.d.ts +0 -211
  90. package/dist/core/ProviderOutputTracker.js +0 -476
  91. package/dist/core/ReactiveUpdateQueue.d.ts +0 -76
  92. package/dist/core/ReactiveUpdateQueue.js +0 -121
  93. package/dist/core/Reconciler.d.ts +0 -415
  94. package/dist/core/Reconciler.js +0 -1044
  95. package/dist/core/RenderScheduler.d.ts +0 -153
  96. package/dist/core/RenderScheduler.js +0 -519
  97. package/dist/core/Renderer.d.ts +0 -336
  98. package/dist/core/Renderer.js +0 -944
  99. package/dist/core/Runtime.d.ts +0 -246
  100. package/dist/core/Runtime.js +0 -640
  101. package/dist/core/StateBindingManager.d.ts +0 -121
  102. package/dist/core/StateBindingManager.js +0 -309
  103. package/dist/core/StateMachine.d.ts +0 -441
  104. package/dist/core/StateMachine.js +0 -883
  105. package/dist/core/StructuralChangeDetector.d.ts +0 -140
  106. package/dist/core/StructuralChangeDetector.js +0 -363
  107. package/dist/core/Validator.d.ts +0 -127
  108. package/dist/core/Validator.js +0 -279
  109. package/dist/core/errors.d.ts +0 -153
  110. package/dist/core/errors.js +0 -202
  111. package/dist/core/index.d.ts +0 -38
  112. package/dist/core/index.js +0 -64
  113. package/dist/core/types.d.ts +0 -265
  114. package/dist/core/types.js +0 -48
  115. package/dist/hooks/context.d.ts +0 -147
  116. package/dist/hooks/context.js +0 -334
  117. package/dist/hooks/useContext.d.ts +0 -113
  118. package/dist/hooks/useContext.js +0 -169
  119. package/dist/hooks/useEffect.d.ts +0 -105
  120. package/dist/hooks/useEffect.js +0 -540
  121. package/dist/hooks/useInstance.d.ts +0 -139
  122. package/dist/hooks/useInstance.js +0 -455
  123. package/dist/hooks/useState.d.ts +0 -120
  124. package/dist/hooks/useState.js +0 -298
  125. package/dist/jsx.d.ts +0 -143
  126. package/dist/jsx.js +0 -76
  127. package/dist/providers/DummyBackendProvider.d.ts +0 -193
  128. package/dist/providers/DummyBackendProvider.js +0 -189
  129. package/dist/providers/DummyCloudProvider.d.ts +0 -128
  130. package/dist/providers/DummyCloudProvider.js +0 -157
  131. package/dist/providers/IBackendProvider.d.ts +0 -177
  132. package/dist/providers/IBackendProvider.js +0 -31
  133. package/dist/providers/ICloudProvider.d.ts +0 -230
  134. package/dist/providers/ICloudProvider.js +0 -31
  135. package/dist/providers/index.d.ts +0 -31
  136. package/dist/providers/index.js +0 -31
  137. package/dist/test-event-callbacks.d.ts +0 -0
  138. package/dist/test-event-callbacks.js +0 -1
  139. package/dist/utils/Logger.d.ts +0 -144
  140. package/dist/utils/Logger.js +0 -220
  141. package/dist/utils/Output.d.ts +0 -161
  142. package/dist/utils/Output.js +0 -401
  143. package/dist/utils/deepEqual.d.ts +0 -71
  144. package/dist/utils/deepEqual.js +0 -276
  145. package/dist/utils/naming.d.ts +0 -241
  146. package/dist/utils/naming.js +0 -376
package/README.md CHANGED
@@ -1,38 +1,89 @@
1
+ # CReact
1
2
 
2
- NOTE: !!! THIS IS A EXPERIMENT OF THOUGHT NOT A PRODUCTION READY PRODUCT !!!
3
+ **Declarative universal reactive runtime.**
3
4
 
4
- # CReact
5
+ ## Install
5
6
 
6
- ![creact](https://i.postimg.cc/8P66GnT3/banner.jpg)
7
+ ```bash
8
+ npm install creact
9
+ ```
10
+
11
+ ## Quick Example
7
12
 
8
13
  ```tsx
9
- function App() {
14
+ // tsconfig.json: "jsxImportSource": "creact"
15
+
16
+ import { CReact, renderCloudDOM, useInstance } from 'creact';
17
+
18
+ // Define constructs
19
+ class ChatModel {
20
+ constructor(public props: { model: string }) {}
21
+ }
22
+
23
+ class Memory {
24
+ constructor(public props: {}) {}
25
+ }
26
+
27
+ // Define components
28
+ function Model({ model, children }) {
29
+ const out = useInstance(ChatModel, { model });
30
+ return children(out);
31
+ }
32
+
33
+ function Mem({ children }) {
34
+ const out = useInstance(Memory, {});
35
+ return children(out);
36
+ }
37
+
38
+ function App({ prompt }) {
10
39
  return (
11
- <VPC name="prod-vpc">
12
- <Database name="users-db">
13
- <API name="users-api">
14
- <Monitoring />
15
- </API>
16
- </Database>
17
- </VPC>
40
+ <Model model="gpt-4">
41
+ {(model) => (
42
+ <Mem>
43
+ {(memory) => (
44
+ <Agent
45
+ prompt={prompt}
46
+ modelId={model.id()}
47
+ messages={memory.messages()}
48
+ />
49
+ )}
50
+ </Mem>
51
+ )}
52
+ </Model>
18
53
  );
19
54
  }
55
+
56
+ // Run
57
+ CReact.provider = new AgentProvider();
58
+ CReact.backend = new FileBackend({ directory: '.state' });
59
+
60
+ await renderCloudDOM(<App prompt="Hello" />, 'agent');
20
61
  ```
21
62
 
22
- ## Demos
63
+ ## The Four Pillars
23
64
 
24
- Multi env Landing page -> https://github.com/creact-labs/creact-app-demo-multi-env-web-server
65
+ **Declarative** Describe what you want, not how to get it.
25
66
 
26
- ## Installation & Usage
67
+ **Universal** Works for AI agents, cloud infrastructure, APIs, anything.
27
68
 
28
- ```bash
29
- # Deploy your infrastructure
30
- creact deploy --entry my-app.tsx
69
+ **Reactive** — Automatically responds when things change.
31
70
 
32
- # Development mode with hot reload
33
- creact dev --entry my-app.tsx --auto-approve
71
+ **Runtime** Keeps running continuously, handles events, recovers from crashes.
34
72
 
35
- # Preview changes
36
- creact plan --entry my-app.tsx
37
- ```
73
+ ## Documentation
74
+
75
+ ### Getting Started
76
+
77
+ - [Tutorial: Build an AI Agent](./docs/getting-started/1-setup.md)
78
+
79
+ ### Concepts
80
+
81
+ - [Thinking in CReact](./docs/concepts/thinking-in-creact.md) — The mental model
82
+ - [Constructs](./docs/concepts/constructs.md) — Your building blocks
83
+ - [Components](./docs/concepts/components.md) — Composing with JSX
84
+ - [Reactivity](./docs/concepts/reactivity.md) — When things change
85
+ - [Providers](./docs/concepts/providers.md) — Connecting to the real world
86
+
87
+ ## License
38
88
 
89
+ Apache-2.0
package/dist/cli.d.ts ADDED
@@ -0,0 +1,11 @@
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
+ export {};
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 { CReact, JSXElement } from './jsx';
31
- export type { FC, PropsWithChildren, ComponentProps } from './jsx';
32
- import { CReact as CReactClass } from './core/CReact';
33
- export { CReact as CReactCore, CReactConfig } from './core/CReact';
34
- export declare const renderCloudDOM: typeof CReactClass.renderCloudDOM;
35
- export { Renderer } from './core/Renderer';
36
- export { Validator } from './core/Validator';
37
- export { CloudDOMBuilder } from './core/CloudDOMBuilder';
38
- export { FiberNode, CloudDOMNode } from './core/types';
39
- export { ICloudProvider, DriftDetectionResult, OutputChangeEvent } from './providers/ICloudProvider';
40
- export { IBackendProvider } from './providers/IBackendProvider';
41
- export { useInstance } from './hooks/useInstance';
42
- export { useState } from './hooks/useState';
43
- export { useContext } from './hooks/useContext';
44
- export { useEffect } from './hooks/useEffect';
45
- export { createContext, Context } from './context';
46
- export { generateResourceId, toKebabCase, getNodeName, validateIdUniqueness, normalizePathSegment, normalizePath, formatPath, parseResourceId, } from './utils/naming';
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
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.parseResourceId = exports.formatPath = exports.normalizePath = exports.normalizePathSegment = exports.validateIdUniqueness = exports.getNodeName = exports.toKebabCase = exports.generateResourceId = exports.createContext = exports.useEffect = exports.useContext = exports.useState = exports.useInstance = exports.CloudDOMBuilder = exports.Validator = exports.Renderer = exports.renderCloudDOM = exports.CReactCore = exports.CReact = void 0;
33
- // CReact - Infrastructure as Code with JSX
34
- // Main entry point for the library
35
- // JSX support
36
- var jsx_1 = require("./jsx");
37
- Object.defineProperty(exports, "CReact", { enumerable: true, get: function () { return jsx_1.CReact; } });
38
- // Core classes
39
- const CReact_1 = require("./core/CReact");
40
- var CReact_2 = require("./core/CReact");
41
- Object.defineProperty(exports, "CReactCore", { enumerable: true, get: function () { return CReact_2.CReact; } });
42
- exports.renderCloudDOM = CReact_1.CReact.renderCloudDOM;
43
- var Renderer_1 = require("./core/Renderer");
44
- Object.defineProperty(exports, "Renderer", { enumerable: true, get: function () { return Renderer_1.Renderer; } });
45
- var Validator_1 = require("./core/Validator");
46
- Object.defineProperty(exports, "Validator", { enumerable: true, get: function () { return Validator_1.Validator; } });
47
- var CloudDOMBuilder_1 = require("./core/CloudDOMBuilder");
48
- Object.defineProperty(exports, "CloudDOMBuilder", { enumerable: true, get: function () { return CloudDOMBuilder_1.CloudDOMBuilder; } });
49
- // Hooks
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,2 @@
1
+ export { createElement, Fragment, type JSXElement, jsx, jsxDEV, jsxs } from './jsx-runtime';
2
+ export type { JSX } from './types';
@@ -0,0 +1 @@
1
+ export { createElement, Fragment, jsx, jsxDEV, jsxs } from './jsx-runtime';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * JSX Dev Runtime - re-exports from jsx-runtime for development mode
3
+ */
4
+ export { Fragment, jsx, jsx as jsxDEV, jsxs } from './jsx-runtime';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * JSX Dev Runtime - re-exports from jsx-runtime for development mode
3
+ */
4
+ export { Fragment, jsx, jsx as 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,12 @@
1
+ /**
2
+ * JSX Type Definitions
3
+ */
4
+ export declare namespace JSX {
5
+ type Element = import('./jsx-runtime').JSXElement;
6
+ interface IntrinsicElements {
7
+ [key: string]: any;
8
+ }
9
+ interface ElementChildrenAttribute {
10
+ children: {};
11
+ }
12
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * JSX Type Definitions
3
+ */
4
+ export {};
@@ -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';
@@ -0,0 +1,3 @@
1
+ export { createContext, useContext } from './context';
2
+ export { clearNodeRegistry, fillInstanceOutputs, getAllNodes, getNodeById, useInstance, } from './instance';
3
+ export { createStore } from './store';
@@ -0,0 +1,72 @@
1
+ /**
2
+ * useInstance - bind to a provider and get reactive outputs
3
+ */
4
+ import { type Accessor, type Setter } from '../reactive/signal';
5
+ /**
6
+ * Instance node - represents something materialized by provider
7
+ */
8
+ export interface InstanceNode {
9
+ id: string;
10
+ path: string[];
11
+ construct: any;
12
+ constructType: string;
13
+ props: Record<string, any>;
14
+ outputSignals: Map<string, [Accessor<any>, Setter<any>]>;
15
+ children: InstanceNode[];
16
+ store?: any;
17
+ outputs?: Record<string, any>;
18
+ /** Update outputs reactively - triggers dependent re-renders via signals */
19
+ setOutputs(outputs: Record<string, any>): void;
20
+ }
21
+ /**
22
+ * Serialized node shape (from backend.ts) - only what we need for hydration
23
+ */
24
+ interface SerializedNodeForHydration {
25
+ id: string;
26
+ outputs?: Record<string, any>;
27
+ }
28
+ /**
29
+ * Prepare output hydration from serialized nodes
30
+ * Called by runtime BEFORE rendering to restore outputs
31
+ */
32
+ export declare function prepareOutputHydration(serializedNodes: SerializedNodeForHydration[]): void;
33
+ /**
34
+ * Clear output hydration map
35
+ */
36
+ export declare function clearOutputHydration(): void;
37
+ /**
38
+ * Output accessor type - each property is a signal accessor
39
+ */
40
+ export type OutputAccessors<O> = {
41
+ [K in keyof O]: () => O[K] | undefined;
42
+ };
43
+ /**
44
+ * Create an instance bound to a provider
45
+ */
46
+ export declare function useInstance<O extends Record<string, any> = Record<string, any>>(construct: any, props: Record<string, any>): OutputAccessors<O>;
47
+ /**
48
+ * Fill instance outputs (called by runtime after provider returns)
49
+ * @internal
50
+ */
51
+ export declare function fillInstanceOutputs(nodeId: string, outputs: Record<string, any>): void;
52
+ /**
53
+ * Get a node by ID
54
+ * @internal
55
+ */
56
+ export declare function getNodeById(nodeId: string): InstanceNode | undefined;
57
+ /**
58
+ * Get all registered nodes
59
+ * @internal
60
+ */
61
+ export declare function getAllNodes(): InstanceNode[];
62
+ /**
63
+ * Clear node registry (for testing)
64
+ * @internal
65
+ */
66
+ export declare function clearNodeRegistry(): void;
67
+ /**
68
+ * Clear node ownership (call at start of each render pass)
69
+ * @internal
70
+ */
71
+ export declare function clearNodeOwnership(): void;
72
+ export {};