@fragno-dev/cloudflare-fragment 0.0.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/LICENSE.md +16 -0
- package/README.md +92 -0
- package/dist/browser/client/react.d.ts +290 -0
- package/dist/browser/client/react.d.ts.map +1 -0
- package/dist/browser/client/react.js +166 -0
- package/dist/browser/client/react.js.map +1 -0
- package/dist/browser/client/solid.d.ts +292 -0
- package/dist/browser/client/solid.d.ts.map +1 -0
- package/dist/browser/client/solid.js +136 -0
- package/dist/browser/client/solid.js.map +1 -0
- package/dist/browser/client/svelte.d.ts +287 -0
- package/dist/browser/client/svelte.d.ts.map +1 -0
- package/dist/browser/client/svelte.js +134 -0
- package/dist/browser/client/svelte.js.map +1 -0
- package/dist/browser/client/vanilla.d.ts +316 -0
- package/dist/browser/client/vanilla.d.ts.map +1 -0
- package/dist/browser/client/vanilla.js +160 -0
- package/dist/browser/client/vanilla.js.map +1 -0
- package/dist/browser/client/vue.d.ts +290 -0
- package/dist/browser/client/vue.d.ts.map +1 -0
- package/dist/browser/client/vue.js +133 -0
- package/dist/browser/client/vue.js.map +1 -0
- package/dist/browser/client-Bk-J98pf.d.ts +679 -0
- package/dist/browser/client-Bk-J98pf.d.ts.map +1 -0
- package/dist/browser/index.d.ts +2027 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +27 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/schema-Bt-h9kGf.js +2348 -0
- package/dist/browser/schema-Bt-h9kGf.js.map +1 -0
- package/dist/node/cloudflare-api.d.ts +106 -0
- package/dist/node/cloudflare-api.d.ts.map +1 -0
- package/dist/node/cloudflare-api.js +146 -0
- package/dist/node/cloudflare-api.js.map +1 -0
- package/dist/node/contracts.d.ts +288 -0
- package/dist/node/contracts.d.ts.map +1 -0
- package/dist/node/contracts.js +66 -0
- package/dist/node/contracts.js.map +1 -0
- package/dist/node/definition.d.ts +339 -0
- package/dist/node/definition.d.ts.map +1 -0
- package/dist/node/definition.js +417 -0
- package/dist/node/definition.js.map +1 -0
- package/dist/node/deployment-tag.d.ts +13 -0
- package/dist/node/deployment-tag.d.ts.map +1 -0
- package/dist/node/deployment-tag.js +73 -0
- package/dist/node/deployment-tag.js.map +1 -0
- package/dist/node/index.d.ts +786 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +35 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/routes.d.ts +520 -0
- package/dist/node/routes.d.ts.map +1 -0
- package/dist/node/routes.js +100 -0
- package/dist/node/routes.js.map +1 -0
- package/dist/node/schema.d.ts +11 -0
- package/dist/node/schema.d.ts.map +1 -0
- package/dist/node/schema.js +24 -0
- package/dist/node/schema.js.map +1 -0
- package/dist/node/script-name.d.ts +13 -0
- package/dist/node/script-name.d.ts.map +1 -0
- package/dist/node/script-name.js +35 -0
- package/dist/node/script-name.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +98 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Copyright 2025 - present "ReJot Nederland B.V.", and individual contributors.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
+
associated documentation files (the “Software”), to deal in the Software without restriction,
|
|
5
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
+
furnished to do so, subject to the following conditions:
|
|
8
|
+
|
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
10
|
+
portions of the Software.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
15
|
+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
16
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @fragno-dev/cloudflare-fragment
|
|
2
|
+
|
|
3
|
+
Fragno fragment for queueing and tracking Cloudflare Workers for Platforms deployments against an
|
|
4
|
+
existing dispatch namespace.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
|
|
8
|
+
- Queues a single ES module deployment for an app-facing ID
|
|
9
|
+
- Persists app and deployment state in the fragment database
|
|
10
|
+
- Reconciles remote deployments by tagging the live Worker with `<deploymentTagPrefix>-app-<appId>`
|
|
11
|
+
and `<deploymentTagPrefix>-dep-<deploymentId>`
|
|
12
|
+
- Runs the Cloudflare upload through a durable hook after the request transaction commits
|
|
13
|
+
- Builds the official `cloudflare` SDK client and exposes it through
|
|
14
|
+
`fragment.services.cloudflare.getClient()`
|
|
15
|
+
- Exposes typed routes and client hooks for queueing and status reads
|
|
16
|
+
|
|
17
|
+
## Server Setup
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { createCloudflareFragment } from "@fragno-dev/cloudflare-fragment";
|
|
21
|
+
|
|
22
|
+
const fragment = createCloudflareFragment(
|
|
23
|
+
{
|
|
24
|
+
accountId: process.env.CLOUDFLARE_ACCOUNT_ID!,
|
|
25
|
+
apiToken: process.env.CLOUDFLARE_API_TOKEN!,
|
|
26
|
+
dispatcher: {
|
|
27
|
+
binding: env.DISPATCHER,
|
|
28
|
+
namespace: "my-dispatch-namespace",
|
|
29
|
+
},
|
|
30
|
+
compatibilityDate: "2026-03-10",
|
|
31
|
+
compatibilityFlags: ["nodejs_compat"],
|
|
32
|
+
deploymentTagPrefix: "fragno",
|
|
33
|
+
scriptNamePrefix: "fragno",
|
|
34
|
+
scriptNameSuffix: "worker",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
databaseAdapter,
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Outside Cloudflare Workers, you can still pass `dispatchNamespace: "my-dispatch-namespace"` if you
|
|
43
|
+
do not have a bound dispatch namespace object available.
|
|
44
|
+
|
|
45
|
+
The fragment computes a deterministic `scriptName` from the app-facing ID and stores it in the `app`
|
|
46
|
+
table the first time that app is deployed.
|
|
47
|
+
|
|
48
|
+
If you already construct your own Cloudflare SDK client, pass it as `cloudflare` in fragment config
|
|
49
|
+
instead of `apiToken`.
|
|
50
|
+
|
|
51
|
+
For the detailed write path, see [APP_DEPLOYMENT_FLOW.md](./APP_DEPLOYMENT_FLOW.md).
|
|
52
|
+
|
|
53
|
+
## Routes
|
|
54
|
+
|
|
55
|
+
- `GET /apps` lists known workers and their latest deployment
|
|
56
|
+
- `POST /apps/:appId/deployments` queues a deployment request
|
|
57
|
+
- `GET /apps/:appId` returns the app summary plus the latest deployment
|
|
58
|
+
- `GET /apps/:appId/deployments` returns the deployment history for one app
|
|
59
|
+
- `GET /deployments/:deploymentId` returns a single deployment status record
|
|
60
|
+
|
|
61
|
+
Queued deployments stay `queued` until durable hooks are processed.
|
|
62
|
+
|
|
63
|
+
## Durable Hooks
|
|
64
|
+
|
|
65
|
+
This fragment will not upload to Cloudflare unless the host runtime runs a durable hooks processor.
|
|
66
|
+
Use the Fragno DB dispatchers in Node or Cloudflare and include this fragment in the processor.
|
|
67
|
+
|
|
68
|
+
The hook payload carries the immutable deployment snapshot so the hook can reconcile remote state
|
|
69
|
+
before a single local finalize transaction. If the deployment tag is already live in Cloudflare, the
|
|
70
|
+
hook marks the deployment `succeeded` locally without re-uploading. The configured prefix is capped
|
|
71
|
+
per tag so `<prefix>-app-...` and `<prefix>-dep-...` stay within Cloudflare's 63 character limit.
|
|
72
|
+
|
|
73
|
+
## Client Builders
|
|
74
|
+
|
|
75
|
+
`createCloudflareFragmentClients()` exposes:
|
|
76
|
+
|
|
77
|
+
- `useApps`
|
|
78
|
+
- `useApp`
|
|
79
|
+
- `useAppDeployments`
|
|
80
|
+
- `useDeployment`
|
|
81
|
+
- `useQueueDeployment`
|
|
82
|
+
|
|
83
|
+
Framework entrypoints are available at `@fragno-dev/cloudflare-fragment/react`, `./vue`, `./svelte`,
|
|
84
|
+
`./solid`, and `./vanilla`.
|
|
85
|
+
|
|
86
|
+
## Development
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pnpm exec turbo types:check --filter=./packages/cloudflare-fragment --output-logs=errors-only
|
|
90
|
+
pnpm exec turbo test --filter=./packages/cloudflare-fragment --output-logs=errors-only
|
|
91
|
+
pnpm exec turbo build --filter=./packages/cloudflare-fragment --output-logs=errors-only
|
|
92
|
+
```
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { a as FragnoClientError, c as InferOr, d as MaybeExtractPathParamsOrWiden, f as QueryParamsHint, i as ReadableAtom, l as ExtractPathParamsOrWiden, o as NonGetHTTPMethod, r as FetcherValue, s as FragnoPublicClientConfig, u as HasPathParams } from "../client-Bk-J98pf.js";
|
|
2
|
+
import * as zod from "zod";
|
|
3
|
+
import "react";
|
|
4
|
+
import * as zod_v4_core0 from "zod/v4/core";
|
|
5
|
+
import * as _standard_schema_spec0 from "@standard-schema/spec";
|
|
6
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
7
|
+
|
|
8
|
+
//#region ../fragno/dist/client/react.d.ts
|
|
9
|
+
//#region src/client/react.d.ts
|
|
10
|
+
type FragnoReactHook<_TMethod extends "GET", TPath$1 extends string, TOutputSchema$1 extends StandardSchemaV1, TErrorCode$1 extends string, TQueryParameters$1 extends string> = (args?: {
|
|
11
|
+
path?: MaybeExtractPathParamsOrWiden<TPath$1, string | ReadableAtom<string>>;
|
|
12
|
+
query?: QueryParamsHint<TQueryParameters$1, string | ReadableAtom<string>>;
|
|
13
|
+
}) => FetcherValue<StandardSchemaV1.InferOutput<TOutputSchema$1>, FragnoClientError<NonNullable<TErrorCode$1>>>;
|
|
14
|
+
type FragnoReactMutator<_TMethod extends NonGetHTTPMethod, TPath$1 extends string, TInputSchema extends StandardSchemaV1 | undefined, TOutputSchema$1 extends StandardSchemaV1 | undefined, TErrorCode$1 extends string, TQueryParameters$1 extends string> = () => {
|
|
15
|
+
mutate: ({
|
|
16
|
+
body,
|
|
17
|
+
path,
|
|
18
|
+
query
|
|
19
|
+
}: {
|
|
20
|
+
body?: InferOr<TInputSchema, undefined>;
|
|
21
|
+
path?: HasPathParams<TPath$1> extends true ? ExtractPathParamsOrWiden<TPath$1, string | ReadableAtom<string>> : undefined;
|
|
22
|
+
query?: QueryParamsHint<TQueryParameters$1, string | ReadableAtom<string>>;
|
|
23
|
+
}) => Promise<InferOr<TOutputSchema$1, undefined>>;
|
|
24
|
+
loading?: boolean | undefined;
|
|
25
|
+
error?: FragnoClientError<NonNullable<TErrorCode$1>[number]> | undefined;
|
|
26
|
+
data?: InferOr<TOutputSchema$1, undefined> | undefined;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Type helper that unwraps any Store fields of the object into StoreValues
|
|
30
|
+
*/
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/client/react.d.ts
|
|
33
|
+
declare function createCloudflareFragmentClient(config?: FragnoPublicClientConfig): {
|
|
34
|
+
useApps: FragnoReactHook<"GET", "/apps", zod.ZodObject<{
|
|
35
|
+
apps: zod.ZodArray<zod.ZodObject<{
|
|
36
|
+
id: zod.ZodString;
|
|
37
|
+
scriptName: zod.ZodString;
|
|
38
|
+
latestDeployment: zod.ZodNullable<zod.ZodObject<{
|
|
39
|
+
id: zod.ZodString;
|
|
40
|
+
appId: zod.ZodString;
|
|
41
|
+
scriptName: zod.ZodString;
|
|
42
|
+
status: zod.ZodEnum<{
|
|
43
|
+
queued: "queued";
|
|
44
|
+
deploying: "deploying";
|
|
45
|
+
succeeded: "succeeded";
|
|
46
|
+
failed: "failed";
|
|
47
|
+
}>;
|
|
48
|
+
format: zod.ZodLiteral<"esmodule">;
|
|
49
|
+
entrypoint: zod.ZodString;
|
|
50
|
+
sourceByteLength: zod.ZodNumber;
|
|
51
|
+
compatibilityDate: zod.ZodString;
|
|
52
|
+
compatibilityFlags: zod.ZodArray<zod.ZodString>;
|
|
53
|
+
attemptCount: zod.ZodNumber;
|
|
54
|
+
queuedAt: zod.ZodString;
|
|
55
|
+
startedAt: zod.ZodNullable<zod.ZodString>;
|
|
56
|
+
completedAt: zod.ZodNullable<zod.ZodString>;
|
|
57
|
+
errorCode: zod.ZodNullable<zod.ZodString>;
|
|
58
|
+
errorMessage: zod.ZodNullable<zod.ZodString>;
|
|
59
|
+
cloudflare: zod.ZodNullable<zod.ZodObject<{
|
|
60
|
+
etag: zod.ZodNullable<zod.ZodString>;
|
|
61
|
+
modifiedOn: zod.ZodNullable<zod.ZodString>;
|
|
62
|
+
}, zod_v4_core0.$strip>>;
|
|
63
|
+
createdAt: zod.ZodString;
|
|
64
|
+
updatedAt: zod.ZodString;
|
|
65
|
+
}, zod_v4_core0.$strip>>;
|
|
66
|
+
createdAt: zod.ZodString;
|
|
67
|
+
updatedAt: zod.ZodString;
|
|
68
|
+
}, zod_v4_core0.$strip>>;
|
|
69
|
+
}, zod_v4_core0.$strip>, string, string>;
|
|
70
|
+
useApp: FragnoReactHook<"GET", "/apps/:appId", zod.ZodObject<{
|
|
71
|
+
id: zod.ZodString;
|
|
72
|
+
scriptName: zod.ZodString;
|
|
73
|
+
latestDeployment: zod.ZodNullable<zod.ZodObject<{
|
|
74
|
+
id: zod.ZodString;
|
|
75
|
+
appId: zod.ZodString;
|
|
76
|
+
scriptName: zod.ZodString;
|
|
77
|
+
status: zod.ZodEnum<{
|
|
78
|
+
queued: "queued";
|
|
79
|
+
deploying: "deploying";
|
|
80
|
+
succeeded: "succeeded";
|
|
81
|
+
failed: "failed";
|
|
82
|
+
}>;
|
|
83
|
+
format: zod.ZodLiteral<"esmodule">;
|
|
84
|
+
entrypoint: zod.ZodString;
|
|
85
|
+
sourceByteLength: zod.ZodNumber;
|
|
86
|
+
compatibilityDate: zod.ZodString;
|
|
87
|
+
compatibilityFlags: zod.ZodArray<zod.ZodString>;
|
|
88
|
+
attemptCount: zod.ZodNumber;
|
|
89
|
+
queuedAt: zod.ZodString;
|
|
90
|
+
startedAt: zod.ZodNullable<zod.ZodString>;
|
|
91
|
+
completedAt: zod.ZodNullable<zod.ZodString>;
|
|
92
|
+
errorCode: zod.ZodNullable<zod.ZodString>;
|
|
93
|
+
errorMessage: zod.ZodNullable<zod.ZodString>;
|
|
94
|
+
cloudflare: zod.ZodNullable<zod.ZodObject<{
|
|
95
|
+
etag: zod.ZodNullable<zod.ZodString>;
|
|
96
|
+
modifiedOn: zod.ZodNullable<zod.ZodString>;
|
|
97
|
+
}, zod_v4_core0.$strip>>;
|
|
98
|
+
createdAt: zod.ZodString;
|
|
99
|
+
updatedAt: zod.ZodString;
|
|
100
|
+
}, zod_v4_core0.$strip>>;
|
|
101
|
+
createdAt: zod.ZodString;
|
|
102
|
+
updatedAt: zod.ZodString;
|
|
103
|
+
liveDeployment: zod.ZodNullable<zod.ZodObject<{
|
|
104
|
+
id: zod.ZodString;
|
|
105
|
+
appId: zod.ZodString;
|
|
106
|
+
scriptName: zod.ZodString;
|
|
107
|
+
status: zod.ZodEnum<{
|
|
108
|
+
queued: "queued";
|
|
109
|
+
deploying: "deploying";
|
|
110
|
+
succeeded: "succeeded";
|
|
111
|
+
failed: "failed";
|
|
112
|
+
}>;
|
|
113
|
+
format: zod.ZodLiteral<"esmodule">;
|
|
114
|
+
entrypoint: zod.ZodString;
|
|
115
|
+
sourceByteLength: zod.ZodNumber;
|
|
116
|
+
compatibilityDate: zod.ZodString;
|
|
117
|
+
compatibilityFlags: zod.ZodArray<zod.ZodString>;
|
|
118
|
+
attemptCount: zod.ZodNumber;
|
|
119
|
+
queuedAt: zod.ZodString;
|
|
120
|
+
startedAt: zod.ZodNullable<zod.ZodString>;
|
|
121
|
+
completedAt: zod.ZodNullable<zod.ZodString>;
|
|
122
|
+
errorCode: zod.ZodNullable<zod.ZodString>;
|
|
123
|
+
errorMessage: zod.ZodNullable<zod.ZodString>;
|
|
124
|
+
cloudflare: zod.ZodNullable<zod.ZodObject<{
|
|
125
|
+
etag: zod.ZodNullable<zod.ZodString>;
|
|
126
|
+
modifiedOn: zod.ZodNullable<zod.ZodString>;
|
|
127
|
+
}, zod_v4_core0.$strip>>;
|
|
128
|
+
createdAt: zod.ZodString;
|
|
129
|
+
updatedAt: zod.ZodString;
|
|
130
|
+
}, zod_v4_core0.$strip>>;
|
|
131
|
+
liveDeploymentError: zod.ZodNullable<zod.ZodString>;
|
|
132
|
+
deployments: zod.ZodArray<zod.ZodObject<{
|
|
133
|
+
id: zod.ZodString;
|
|
134
|
+
appId: zod.ZodString;
|
|
135
|
+
scriptName: zod.ZodString;
|
|
136
|
+
status: zod.ZodEnum<{
|
|
137
|
+
queued: "queued";
|
|
138
|
+
deploying: "deploying";
|
|
139
|
+
succeeded: "succeeded";
|
|
140
|
+
failed: "failed";
|
|
141
|
+
}>;
|
|
142
|
+
format: zod.ZodLiteral<"esmodule">;
|
|
143
|
+
entrypoint: zod.ZodString;
|
|
144
|
+
sourceByteLength: zod.ZodNumber;
|
|
145
|
+
compatibilityDate: zod.ZodString;
|
|
146
|
+
compatibilityFlags: zod.ZodArray<zod.ZodString>;
|
|
147
|
+
attemptCount: zod.ZodNumber;
|
|
148
|
+
queuedAt: zod.ZodString;
|
|
149
|
+
startedAt: zod.ZodNullable<zod.ZodString>;
|
|
150
|
+
completedAt: zod.ZodNullable<zod.ZodString>;
|
|
151
|
+
errorCode: zod.ZodNullable<zod.ZodString>;
|
|
152
|
+
errorMessage: zod.ZodNullable<zod.ZodString>;
|
|
153
|
+
cloudflare: zod.ZodNullable<zod.ZodObject<{
|
|
154
|
+
etag: zod.ZodNullable<zod.ZodString>;
|
|
155
|
+
modifiedOn: zod.ZodNullable<zod.ZodString>;
|
|
156
|
+
}, zod_v4_core0.$strip>>;
|
|
157
|
+
createdAt: zod.ZodString;
|
|
158
|
+
updatedAt: zod.ZodString;
|
|
159
|
+
}, zod_v4_core0.$strip>>;
|
|
160
|
+
}, zod_v4_core0.$strip>, "APP_NOT_FOUND", string>;
|
|
161
|
+
useAppDeployments: FragnoReactHook<"GET", "/apps/:appId/deployments", zod.ZodObject<{
|
|
162
|
+
deployments: zod.ZodArray<zod.ZodObject<{
|
|
163
|
+
id: zod.ZodString;
|
|
164
|
+
appId: zod.ZodString;
|
|
165
|
+
scriptName: zod.ZodString;
|
|
166
|
+
status: zod.ZodEnum<{
|
|
167
|
+
queued: "queued";
|
|
168
|
+
deploying: "deploying";
|
|
169
|
+
succeeded: "succeeded";
|
|
170
|
+
failed: "failed";
|
|
171
|
+
}>;
|
|
172
|
+
format: zod.ZodLiteral<"esmodule">;
|
|
173
|
+
entrypoint: zod.ZodString;
|
|
174
|
+
sourceByteLength: zod.ZodNumber;
|
|
175
|
+
compatibilityDate: zod.ZodString;
|
|
176
|
+
compatibilityFlags: zod.ZodArray<zod.ZodString>;
|
|
177
|
+
attemptCount: zod.ZodNumber;
|
|
178
|
+
queuedAt: zod.ZodString;
|
|
179
|
+
startedAt: zod.ZodNullable<zod.ZodString>;
|
|
180
|
+
completedAt: zod.ZodNullable<zod.ZodString>;
|
|
181
|
+
errorCode: zod.ZodNullable<zod.ZodString>;
|
|
182
|
+
errorMessage: zod.ZodNullable<zod.ZodString>;
|
|
183
|
+
cloudflare: zod.ZodNullable<zod.ZodObject<{
|
|
184
|
+
etag: zod.ZodNullable<zod.ZodString>;
|
|
185
|
+
modifiedOn: zod.ZodNullable<zod.ZodString>;
|
|
186
|
+
}, zod_v4_core0.$strip>>;
|
|
187
|
+
createdAt: zod.ZodString;
|
|
188
|
+
updatedAt: zod.ZodString;
|
|
189
|
+
}, zod_v4_core0.$strip>>;
|
|
190
|
+
}, zod_v4_core0.$strip>, "APP_NOT_FOUND", string>;
|
|
191
|
+
useDeployment: FragnoReactHook<"GET", "/deployments/:deploymentId", zod.ZodObject<{
|
|
192
|
+
id: zod.ZodString;
|
|
193
|
+
appId: zod.ZodString;
|
|
194
|
+
scriptName: zod.ZodString;
|
|
195
|
+
status: zod.ZodEnum<{
|
|
196
|
+
queued: "queued";
|
|
197
|
+
deploying: "deploying";
|
|
198
|
+
succeeded: "succeeded";
|
|
199
|
+
failed: "failed";
|
|
200
|
+
}>;
|
|
201
|
+
format: zod.ZodLiteral<"esmodule">;
|
|
202
|
+
entrypoint: zod.ZodString;
|
|
203
|
+
sourceByteLength: zod.ZodNumber;
|
|
204
|
+
compatibilityDate: zod.ZodString;
|
|
205
|
+
compatibilityFlags: zod.ZodArray<zod.ZodString>;
|
|
206
|
+
attemptCount: zod.ZodNumber;
|
|
207
|
+
queuedAt: zod.ZodString;
|
|
208
|
+
startedAt: zod.ZodNullable<zod.ZodString>;
|
|
209
|
+
completedAt: zod.ZodNullable<zod.ZodString>;
|
|
210
|
+
errorCode: zod.ZodNullable<zod.ZodString>;
|
|
211
|
+
errorMessage: zod.ZodNullable<zod.ZodString>;
|
|
212
|
+
cloudflare: zod.ZodNullable<zod.ZodObject<{
|
|
213
|
+
etag: zod.ZodNullable<zod.ZodString>;
|
|
214
|
+
modifiedOn: zod.ZodNullable<zod.ZodString>;
|
|
215
|
+
}, zod_v4_core0.$strip>>;
|
|
216
|
+
createdAt: zod.ZodString;
|
|
217
|
+
updatedAt: zod.ZodString;
|
|
218
|
+
sourceCode: zod.ZodString;
|
|
219
|
+
}, zod_v4_core0.$strip>, "DEPLOYMENT_NOT_FOUND", string>;
|
|
220
|
+
useQueueDeployment: FragnoReactMutator<NonGetHTTPMethod, "/apps/:appId/deployments", zod.ZodObject<{
|
|
221
|
+
script: zod.ZodObject<{
|
|
222
|
+
type: zod.ZodDefault<zod.ZodEnum<{
|
|
223
|
+
esmodule: "esmodule";
|
|
224
|
+
}>>;
|
|
225
|
+
entrypoint: zod.ZodDefault<zod.ZodString>;
|
|
226
|
+
content: zod.ZodString;
|
|
227
|
+
}, zod_v4_core0.$strip>;
|
|
228
|
+
compatibilityDate: zod.ZodOptional<zod.ZodString>;
|
|
229
|
+
compatibilityFlags: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
|
|
230
|
+
}, zod_v4_core0.$strip> | _standard_schema_spec0.StandardSchemaV1<unknown, unknown> | undefined, zod.ZodObject<{
|
|
231
|
+
id: zod.ZodString;
|
|
232
|
+
appId: zod.ZodString;
|
|
233
|
+
scriptName: zod.ZodString;
|
|
234
|
+
status: zod.ZodEnum<{
|
|
235
|
+
queued: "queued";
|
|
236
|
+
deploying: "deploying";
|
|
237
|
+
succeeded: "succeeded";
|
|
238
|
+
failed: "failed";
|
|
239
|
+
}>;
|
|
240
|
+
format: zod.ZodLiteral<"esmodule">;
|
|
241
|
+
entrypoint: zod.ZodString;
|
|
242
|
+
sourceByteLength: zod.ZodNumber;
|
|
243
|
+
compatibilityDate: zod.ZodString;
|
|
244
|
+
compatibilityFlags: zod.ZodArray<zod.ZodString>;
|
|
245
|
+
attemptCount: zod.ZodNumber;
|
|
246
|
+
queuedAt: zod.ZodString;
|
|
247
|
+
startedAt: zod.ZodNullable<zod.ZodString>;
|
|
248
|
+
completedAt: zod.ZodNullable<zod.ZodString>;
|
|
249
|
+
errorCode: zod.ZodNullable<zod.ZodString>;
|
|
250
|
+
errorMessage: zod.ZodNullable<zod.ZodString>;
|
|
251
|
+
cloudflare: zod.ZodNullable<zod.ZodObject<{
|
|
252
|
+
etag: zod.ZodNullable<zod.ZodString>;
|
|
253
|
+
modifiedOn: zod.ZodNullable<zod.ZodString>;
|
|
254
|
+
}, zod_v4_core0.$strip>>;
|
|
255
|
+
createdAt: zod.ZodString;
|
|
256
|
+
updatedAt: zod.ZodString;
|
|
257
|
+
}, zod_v4_core0.$strip> | zod.ZodObject<{
|
|
258
|
+
deployments: zod.ZodArray<zod.ZodObject<{
|
|
259
|
+
id: zod.ZodString;
|
|
260
|
+
appId: zod.ZodString;
|
|
261
|
+
scriptName: zod.ZodString;
|
|
262
|
+
status: zod.ZodEnum<{
|
|
263
|
+
queued: "queued";
|
|
264
|
+
deploying: "deploying";
|
|
265
|
+
succeeded: "succeeded";
|
|
266
|
+
failed: "failed";
|
|
267
|
+
}>;
|
|
268
|
+
format: zod.ZodLiteral<"esmodule">;
|
|
269
|
+
entrypoint: zod.ZodString;
|
|
270
|
+
sourceByteLength: zod.ZodNumber;
|
|
271
|
+
compatibilityDate: zod.ZodString;
|
|
272
|
+
compatibilityFlags: zod.ZodArray<zod.ZodString>;
|
|
273
|
+
attemptCount: zod.ZodNumber;
|
|
274
|
+
queuedAt: zod.ZodString;
|
|
275
|
+
startedAt: zod.ZodNullable<zod.ZodString>;
|
|
276
|
+
completedAt: zod.ZodNullable<zod.ZodString>;
|
|
277
|
+
errorCode: zod.ZodNullable<zod.ZodString>;
|
|
278
|
+
errorMessage: zod.ZodNullable<zod.ZodString>;
|
|
279
|
+
cloudflare: zod.ZodNullable<zod.ZodObject<{
|
|
280
|
+
etag: zod.ZodNullable<zod.ZodString>;
|
|
281
|
+
modifiedOn: zod.ZodNullable<zod.ZodString>;
|
|
282
|
+
}, zod_v4_core0.$strip>>;
|
|
283
|
+
createdAt: zod.ZodString;
|
|
284
|
+
updatedAt: zod.ZodString;
|
|
285
|
+
}, zod_v4_core0.$strip>>;
|
|
286
|
+
}, zod_v4_core0.$strip> | undefined, "INVALID_DEPLOY_INPUT" | "UNSUPPORTED_DEPLOY_REQUEST" | "APP_NOT_FOUND", string>;
|
|
287
|
+
};
|
|
288
|
+
//#endregion
|
|
289
|
+
export { createCloudflareFragmentClient };
|
|
290
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","names":["ExtractPathParamsOrWiden","HasPathParams","MaybeExtractPathParamsOrWiden","QueryParamsHint","InferOr","NonGetHTTPMethod","FragnoClientError","FragnoClientHookData","FragnoClientMutatorData","FragnoStoreFactoryData","FragnoStoreObjectData","ReadableAtom","Store","StoreValue","FetcherValue","react0","DependencyList","StandardSchemaV1","FragnoReactHook","_TMethod","TPath$1","TOutputSchema$1","TErrorCode$1","TQueryParameters$1","InferOutput","NonNullable","path","query","args","FragnoReactMutator","TInputSchema","body","Promise","mutate","loading","error","data","FragnoReactStoreValue","T","TStore","K","FragnoReactStore","TArgs","useFragno","Record","TPath","TOutputSchema","TErrorCode","TQueryParameters","TMethod","TInput","TOutput","TError","TStoreObj","TStoreArgs","clientObj","StoreKeys","setKey","k","v","UseStoreOptions","SomeStore","deps","keys","useStore","store","options","FragnoHydrator","children","React","ReactNode"],"sources":["../../../../fragno/dist/client/react.d.ts","../../../src/client/react.ts"],"mappings":";;;;;;;;;KAYKkB,eAAAA,yEAAwFD,gBAAAA,qEAAqFW,IAAAA;EAChLF,IAAAA,GAAOxB,6BAAAA,CAA8BkB,OAAAA,WAAkBT,YAAAA;EACvDgB,KAAAA,GAAQxB,eAAAA,CAAgBoB,kBAAAA,WAA6BZ,YAAAA;AAAAA,MACjDG,YAAAA,CAAaG,gBAAAA,CAAiBO,WAAAA,CAAYH,eAAAA,GAAkBf,iBAAAA,CAAkBmB,WAAAA,CAAYH,YAAAA;AAAAA,KAC3FO,kBAAAA,kBAAoCxB,gBAAAA,+CAA+DY,gBAAAA,sCAAsDA,gBAAAA;EAC5JgB,MAAAA;IACEF,IAAAA;IACAL,IAAAA;IACAC;EAAAA;IAEAI,IAAAA,GAAO3B,OAAAA,CAAQ0B,YAAAA;IACfJ,IAAAA,GAAOzB,aAAAA,CAAcmB,OAAAA,iBAAwBpB,wBAAAA,CAAyBoB,OAAAA,WAAkBT,YAAAA;IACxFgB,KAAAA,GAAQxB,eAAAA,CAAgBoB,kBAAAA,WAA6BZ,YAAAA;EAAAA,MACjDqB,OAAAA,CAAQ5B,OAAAA,CAAQiB,eAAAA;EACtBa,OAAAA;EACAC,KAAAA,GAAQ7B,iBAAAA,CAAkBmB,WAAAA,CAAYH,YAAAA;EACtCc,IAAAA,GAAOhC,OAAAA,CAAQiB,eAAAA;AAAAA;;;;;;iBCvBD,8BAAA,CAA+B,MAAA,GAAQ,wBAAA;;;UAA6B,GAAA,CAAA,SAAA"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { L as isGetHook, R as isMutatorHook, V as isReadableAtom, z as isStore } from "../schema-Bt-h9kGf.js";
|
|
2
|
+
import { createCloudflareFragmentClients } from "../index.js";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
4
|
+
|
|
5
|
+
//#region ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/listen-keys/index.js
|
|
6
|
+
function listenKeys($store, keys, listener) {
|
|
7
|
+
let keysSet = new Set(keys).add(void 0);
|
|
8
|
+
return $store.listen((value, oldValue, changed) => {
|
|
9
|
+
if (keysSet.has(changed)) listener(value, oldValue, changed);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region ../fragno/dist/client/react.js
|
|
15
|
+
function createReactHook(hook) {
|
|
16
|
+
return ({ path, query } = {}) => {
|
|
17
|
+
const pathParamValues = path ? Object.values(path) : [];
|
|
18
|
+
const queryParamValues = query ? Object.values(query) : [];
|
|
19
|
+
const store = useMemo(() => hook.store({
|
|
20
|
+
path,
|
|
21
|
+
query
|
|
22
|
+
}), [hook, ...[...pathParamValues, ...queryParamValues]]);
|
|
23
|
+
if (typeof window === "undefined") return store.get();
|
|
24
|
+
return useStore(store);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function createReactMutator(hook) {
|
|
28
|
+
return () => {
|
|
29
|
+
return useStore(useMemo(() => hook.mutatorStore, [hook]));
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const isPlainObject = (value) => {
|
|
33
|
+
if (!value || typeof value !== "object") return false;
|
|
34
|
+
const prototype = Object.getPrototypeOf(value);
|
|
35
|
+
return prototype === Object.prototype || prototype === null;
|
|
36
|
+
};
|
|
37
|
+
const areStoreFactoryValuesEqual = (left, right) => {
|
|
38
|
+
if (Object.is(left, right)) return true;
|
|
39
|
+
if (Array.isArray(left) && Array.isArray(right)) return left.length === right.length && left.every((value, index) => areStoreFactoryValuesEqual(value, right[index]));
|
|
40
|
+
if (left instanceof Date && right instanceof Date) return left.getTime() === right.getTime();
|
|
41
|
+
if (isReadableAtom(left) || isReadableAtom(right)) return left === right;
|
|
42
|
+
if (typeof left === "function" || typeof right === "function") return left === right;
|
|
43
|
+
if (isPlainObject(left) && isPlainObject(right)) {
|
|
44
|
+
const leftKeys = Object.keys(left).sort();
|
|
45
|
+
const rightKeys = Object.keys(right).sort();
|
|
46
|
+
return leftKeys.length === rightKeys.length && leftKeys.every((key, index) => key === rightKeys[index] && areStoreFactoryValuesEqual(left[key], right[key]));
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
};
|
|
50
|
+
const areStoreFactoryArgsEqual = (left, right) => left.length === right.length && left.every((value, index) => areStoreFactoryValuesEqual(value, right[index]));
|
|
51
|
+
const getStoreDisposer = (value) => {
|
|
52
|
+
const disposer = value[Symbol.dispose];
|
|
53
|
+
return typeof disposer === "function" ? disposer.bind(value) : void 0;
|
|
54
|
+
};
|
|
55
|
+
function unwrapReactStoreValueOnServer(value) {
|
|
56
|
+
if (isReadableAtom(value)) return value.get();
|
|
57
|
+
const result = {};
|
|
58
|
+
for (const key in value) {
|
|
59
|
+
if (!Object.prototype.hasOwnProperty.call(value, key)) continue;
|
|
60
|
+
const fieldValue = value[key];
|
|
61
|
+
if (isReadableAtom(fieldValue)) result[key] = fieldValue.get();
|
|
62
|
+
else result[key] = fieldValue;
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
function unwrapReactStoreValue(value) {
|
|
67
|
+
if (isReadableAtom(value)) return useStore(value);
|
|
68
|
+
const keys = Object.keys(value);
|
|
69
|
+
const atomEntries = keys.flatMap((key) => {
|
|
70
|
+
const fieldValue = value[key];
|
|
71
|
+
return isReadableAtom(fieldValue) ? [[key, fieldValue]] : [];
|
|
72
|
+
});
|
|
73
|
+
const snapshotRef = useRef(atomEntries.map(([, store]) => store.get()));
|
|
74
|
+
const getSnapshot = () => {
|
|
75
|
+
const nextSnapshot = atomEntries.map(([, store]) => store.get());
|
|
76
|
+
const previousSnapshot = snapshotRef.current;
|
|
77
|
+
if (previousSnapshot.length === nextSnapshot.length && previousSnapshot.every((entry, index) => Object.is(entry, nextSnapshot[index]))) return previousSnapshot;
|
|
78
|
+
snapshotRef.current = nextSnapshot;
|
|
79
|
+
return nextSnapshot;
|
|
80
|
+
};
|
|
81
|
+
const atomValues = useSyncExternalStore((onStoreChange) => {
|
|
82
|
+
const unsubscribes = atomEntries.map(([, store]) => store.listen(onStoreChange));
|
|
83
|
+
return () => {
|
|
84
|
+
for (const unsubscribe of unsubscribes) unsubscribe();
|
|
85
|
+
};
|
|
86
|
+
}, getSnapshot, getSnapshot);
|
|
87
|
+
const result = {};
|
|
88
|
+
let atomIndex = 0;
|
|
89
|
+
for (const key of keys) {
|
|
90
|
+
const fieldValue = value[key];
|
|
91
|
+
if (isReadableAtom(fieldValue)) {
|
|
92
|
+
result[key] = atomValues[atomIndex];
|
|
93
|
+
atomIndex += 1;
|
|
94
|
+
} else result[key] = fieldValue;
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
function createReactStore(hook) {
|
|
99
|
+
return (...args) => {
|
|
100
|
+
const stableArgsRef = useRef(args);
|
|
101
|
+
const pendingDisposalsRef = useRef(/* @__PURE__ */ new Map());
|
|
102
|
+
if (!areStoreFactoryArgsEqual(stableArgsRef.current, args)) stableArgsRef.current = args;
|
|
103
|
+
const value = useMemo(() => {
|
|
104
|
+
if ("factory" in hook) return hook.factory(...stableArgsRef.current);
|
|
105
|
+
return hook.obj;
|
|
106
|
+
}, [hook, stableArgsRef.current]);
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
const disposer = getStoreDisposer(value);
|
|
109
|
+
const pendingTimeout = pendingDisposalsRef.current.get(value);
|
|
110
|
+
if (pendingTimeout !== void 0) {
|
|
111
|
+
clearTimeout(pendingTimeout);
|
|
112
|
+
pendingDisposalsRef.current.delete(value);
|
|
113
|
+
}
|
|
114
|
+
return () => {
|
|
115
|
+
if (!disposer) return;
|
|
116
|
+
const timeoutId = setTimeout(() => {
|
|
117
|
+
pendingDisposalsRef.current.delete(value);
|
|
118
|
+
disposer();
|
|
119
|
+
}, 0);
|
|
120
|
+
pendingDisposalsRef.current.set(value, timeoutId);
|
|
121
|
+
};
|
|
122
|
+
}, [value]);
|
|
123
|
+
if (typeof window === "undefined") return unwrapReactStoreValueOnServer(value);
|
|
124
|
+
return unwrapReactStoreValue(value);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function useFragno(clientObj) {
|
|
128
|
+
const result = {};
|
|
129
|
+
for (const key in clientObj) {
|
|
130
|
+
if (!Object.prototype.hasOwnProperty.call(clientObj, key)) continue;
|
|
131
|
+
const hook = clientObj[key];
|
|
132
|
+
if (isGetHook(hook)) result[key] = createReactHook(hook);
|
|
133
|
+
else if (isMutatorHook(hook)) result[key] = createReactMutator(hook);
|
|
134
|
+
else if (isStore(hook)) result[key] = createReactStore(hook);
|
|
135
|
+
else result[key] = hook;
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
function useStore(store, options = {}) {
|
|
140
|
+
const snapshotRef = useRef(store.get());
|
|
141
|
+
const { keys, deps = [store, keys] } = options;
|
|
142
|
+
const subscribe = useCallback((onChange) => {
|
|
143
|
+
const emitChange = (value) => {
|
|
144
|
+
if (snapshotRef.current === value) return;
|
|
145
|
+
snapshotRef.current = value;
|
|
146
|
+
onChange();
|
|
147
|
+
};
|
|
148
|
+
emitChange(store.value);
|
|
149
|
+
if (keys?.length) return listenKeys(store, keys, emitChange);
|
|
150
|
+
return store.listen(emitChange);
|
|
151
|
+
}, deps);
|
|
152
|
+
const get = () => snapshotRef.current;
|
|
153
|
+
return useSyncExternalStore(subscribe, get, () => {
|
|
154
|
+
return get();
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/client/react.ts
|
|
160
|
+
function createCloudflareFragmentClient(config = {}) {
|
|
161
|
+
return useFragno(createCloudflareFragmentClients(config));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
export { createCloudflareFragmentClient };
|
|
166
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","names":["listenKeys","$store","keys","listener","keysSet","Set","add","undefined","listen","value","oldValue","changed","has","subscribeKeys","unbind","isReadableAtom","hydrateFromWindow","isGetHook","isMutatorHook","isStore","listenKeys","useCallback","useEffect","useMemo","useRef","useSyncExternalStore","createReactHook","hook","path","query","pathParamValues","Object","values","queryParamValues","store","window","get","useStore","createReactMutator","mutatorStore","isPlainObject","value","prototype","getPrototypeOf","areStoreFactoryValuesEqual","left","right","is","Array","isArray","length","every","index","Date","getTime","leftKeys","keys","sort","rightKeys","key","areStoreFactoryArgsEqual","getStoreDisposer","disposer","Symbol","dispose","bind","unwrapReactStoreValueOnServer","result","hasOwnProperty","call","fieldValue","unwrapReactStoreValue","atomEntries","flatMap","snapshotRef","map","getSnapshot","nextSnapshot","previousSnapshot","current","entry","atomValues","onStoreChange","unsubscribes","listen","unsubscribe","atomIndex","createReactStore","args","stableArgsRef","pendingDisposalsRef","Map","factory","obj","pendingTimeout","clearTimeout","delete","timeoutId","setTimeout","set","useFragno","clientObj","options","deps","subscribe","onChange","emitChange","FragnoHydrator","children","FragnoPublicClientConfig","useFragno","createCloudflareFragmentClients","createCloudflareFragmentClient","config"],"sources":["../../../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/listen-keys/index.js","../../../../fragno/dist/client/react.js","../../../src/client/react.ts"],"sourcesContent":["export function listenKeys($store, keys, listener) {\n let keysSet = new Set(keys).add(undefined)\n return $store.listen((value, oldValue, changed) => {\n if (keysSet.has(changed)) {\n listener(value, oldValue, changed)\n }\n })\n}\n\nexport function subscribeKeys($store, keys, listener) {\n let unbind = listenKeys($store, keys, listener)\n listener($store.value)\n return unbind\n}\n","import { isReadableAtom } from \"../util/nanostores.js\";\nimport { hydrateFromWindow } from \"../util/ssr.js\";\nimport { isGetHook, isMutatorHook, isStore } from \"./client.js\";\nimport { listenKeys } from \"nanostores\";\nimport { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from \"react\";\n\n//#region src/client/react.ts\nfunction createReactHook(hook) {\n\treturn ({ path, query } = {}) => {\n\t\tconst pathParamValues = path ? Object.values(path) : [];\n\t\tconst queryParamValues = query ? Object.values(query) : [];\n\t\tconst store = useMemo(() => hook.store({\n\t\t\tpath,\n\t\t\tquery\n\t\t}), [hook, ...[...pathParamValues, ...queryParamValues]]);\n\t\tif (typeof window === \"undefined\") return store.get();\n\t\treturn useStore(store);\n\t};\n}\nfunction createReactMutator(hook) {\n\treturn () => {\n\t\treturn useStore(useMemo(() => hook.mutatorStore, [hook]));\n\t};\n}\nconst isPlainObject = (value) => {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn prototype === Object.prototype || prototype === null;\n};\nconst areStoreFactoryValuesEqual = (left, right) => {\n\tif (Object.is(left, right)) return true;\n\tif (Array.isArray(left) && Array.isArray(right)) return left.length === right.length && left.every((value, index) => areStoreFactoryValuesEqual(value, right[index]));\n\tif (left instanceof Date && right instanceof Date) return left.getTime() === right.getTime();\n\tif (isReadableAtom(left) || isReadableAtom(right)) return left === right;\n\tif (typeof left === \"function\" || typeof right === \"function\") return left === right;\n\tif (isPlainObject(left) && isPlainObject(right)) {\n\t\tconst leftKeys = Object.keys(left).sort();\n\t\tconst rightKeys = Object.keys(right).sort();\n\t\treturn leftKeys.length === rightKeys.length && leftKeys.every((key, index) => key === rightKeys[index] && areStoreFactoryValuesEqual(left[key], right[key]));\n\t}\n\treturn false;\n};\nconst areStoreFactoryArgsEqual = (left, right) => left.length === right.length && left.every((value, index) => areStoreFactoryValuesEqual(value, right[index]));\nconst getStoreDisposer = (value) => {\n\tconst disposer = value[Symbol.dispose];\n\treturn typeof disposer === \"function\" ? disposer.bind(value) : void 0;\n};\nfunction unwrapReactStoreValueOnServer(value) {\n\tif (isReadableAtom(value)) return value.get();\n\tconst result = {};\n\tfor (const key in value) {\n\t\tif (!Object.prototype.hasOwnProperty.call(value, key)) continue;\n\t\tconst fieldValue = value[key];\n\t\tif (isReadableAtom(fieldValue)) result[key] = fieldValue.get();\n\t\telse result[key] = fieldValue;\n\t}\n\treturn result;\n}\nfunction unwrapReactStoreValue(value) {\n\tif (isReadableAtom(value)) return useStore(value);\n\tconst keys = Object.keys(value);\n\tconst atomEntries = keys.flatMap((key) => {\n\t\tconst fieldValue = value[key];\n\t\treturn isReadableAtom(fieldValue) ? [[key, fieldValue]] : [];\n\t});\n\tconst snapshotRef = useRef(atomEntries.map(([, store]) => store.get()));\n\tconst getSnapshot = () => {\n\t\tconst nextSnapshot = atomEntries.map(([, store]) => store.get());\n\t\tconst previousSnapshot = snapshotRef.current;\n\t\tif (previousSnapshot.length === nextSnapshot.length && previousSnapshot.every((entry, index) => Object.is(entry, nextSnapshot[index]))) return previousSnapshot;\n\t\tsnapshotRef.current = nextSnapshot;\n\t\treturn nextSnapshot;\n\t};\n\tconst atomValues = useSyncExternalStore((onStoreChange) => {\n\t\tconst unsubscribes = atomEntries.map(([, store]) => store.listen(onStoreChange));\n\t\treturn () => {\n\t\t\tfor (const unsubscribe of unsubscribes) unsubscribe();\n\t\t};\n\t}, getSnapshot, getSnapshot);\n\tconst result = {};\n\tlet atomIndex = 0;\n\tfor (const key of keys) {\n\t\tconst fieldValue = value[key];\n\t\tif (isReadableAtom(fieldValue)) {\n\t\t\tresult[key] = atomValues[atomIndex];\n\t\t\tatomIndex += 1;\n\t\t} else result[key] = fieldValue;\n\t}\n\treturn result;\n}\nfunction createReactStore(hook) {\n\treturn ((...args) => {\n\t\tconst stableArgsRef = useRef(args);\n\t\tconst pendingDisposalsRef = useRef(/* @__PURE__ */ new Map());\n\t\tif (!areStoreFactoryArgsEqual(stableArgsRef.current, args)) stableArgsRef.current = args;\n\t\tconst value = useMemo(() => {\n\t\t\tif (\"factory\" in hook) return hook.factory(...stableArgsRef.current);\n\t\t\treturn hook.obj;\n\t\t}, [hook, stableArgsRef.current]);\n\t\tuseEffect(() => {\n\t\t\tconst disposer = getStoreDisposer(value);\n\t\t\tconst pendingTimeout = pendingDisposalsRef.current.get(value);\n\t\t\tif (pendingTimeout !== void 0) {\n\t\t\t\tclearTimeout(pendingTimeout);\n\t\t\t\tpendingDisposalsRef.current.delete(value);\n\t\t\t}\n\t\t\treturn () => {\n\t\t\t\tif (!disposer) return;\n\t\t\t\tconst timeoutId = setTimeout(() => {\n\t\t\t\t\tpendingDisposalsRef.current.delete(value);\n\t\t\t\t\tdisposer();\n\t\t\t\t}, 0);\n\t\t\t\tpendingDisposalsRef.current.set(value, timeoutId);\n\t\t\t};\n\t\t}, [value]);\n\t\tif (typeof window === \"undefined\") return unwrapReactStoreValueOnServer(value);\n\t\treturn unwrapReactStoreValue(value);\n\t});\n}\nfunction useFragno(clientObj) {\n\tconst result = {};\n\tfor (const key in clientObj) {\n\t\tif (!Object.prototype.hasOwnProperty.call(clientObj, key)) continue;\n\t\tconst hook = clientObj[key];\n\t\tif (isGetHook(hook)) result[key] = createReactHook(hook);\n\t\telse if (isMutatorHook(hook)) result[key] = createReactMutator(hook);\n\t\telse if (isStore(hook)) result[key] = createReactStore(hook);\n\t\telse result[key] = hook;\n\t}\n\treturn result;\n}\nfunction useStore(store, options = {}) {\n\tconst snapshotRef = useRef(store.get());\n\tconst { keys, deps = [store, keys] } = options;\n\tconst subscribe = useCallback((onChange) => {\n\t\tconst emitChange = (value) => {\n\t\t\tif (snapshotRef.current === value) return;\n\t\t\tsnapshotRef.current = value;\n\t\t\tonChange();\n\t\t};\n\t\temitChange(store.value);\n\t\tif (keys?.length) return listenKeys(store, keys, emitChange);\n\t\treturn store.listen(emitChange);\n\t}, deps);\n\tconst get = () => snapshotRef.current;\n\treturn useSyncExternalStore(subscribe, get, () => {\n\t\treturn get();\n\t});\n}\nfunction FragnoHydrator({ children }) {\n\tuseMemo(() => {\n\t\thydrateFromWindow();\n\t}, []);\n\treturn children;\n}\n\n//#endregion\nexport { FragnoHydrator, useFragno, useStore };\n//# sourceMappingURL=react.js.map","import type { FragnoPublicClientConfig } from \"@fragno-dev/core/client\";\nimport { useFragno } from \"@fragno-dev/core/react\";\n\nimport { createCloudflareFragmentClients } from \"..\";\n\nexport function createCloudflareFragmentClient(config: FragnoPublicClientConfig = {}) {\n return useFragno(createCloudflareFragmentClients(config));\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAAA,SAAgBA,WAAWC,QAAQC,MAAMC,UAAU;CACjD,IAAIC,UAAU,IAAIC,IAAIH,KAAK,CAACI,IAAIC,OAAU;AAC1C,QAAON,OAAOO,QAAQC,OAAOC,UAAUC,YAAY;AACjD,MAAIP,QAAQQ,IAAID,QAAQ,CACtBR,UAASM,OAAOC,UAAUC,QAAQ;GAEpC;;;;;ACCJ,SAASe,gBAAgBC,MAAM;AAC9B,SAAQ,EAAEC,MAAMC,UAAU,EAAE,KAAK;EAChC,MAAMC,kBAAkBF,OAAOG,OAAOC,OAAOJ,KAAK,GAAG,EAAE;EACvD,MAAMK,mBAAmBJ,QAAQE,OAAOC,OAAOH,MAAM,GAAG,EAAE;EAC1D,MAAMK,QAAQX,cAAcI,KAAKO,MAAM;GACtCN;GACAC;GACA,CAAC,EAAE,CAACF,MAAM,GAAG,CAAC,GAAGG,iBAAiB,GAAGG,iBAAiB,CAAC,CA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