@hops-ops/distributed 0.0.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 (242) hide show
  1. package/README.md +454 -0
  2. package/dist/auth-headers.d.ts +8 -0
  3. package/dist/auth-headers.js +35 -0
  4. package/dist/diagnostics.d.ts +2 -0
  5. package/dist/diagnostics.js +1 -0
  6. package/dist/document.d.ts +8 -0
  7. package/dist/document.js +6 -0
  8. package/dist/identity.d.ts +23 -0
  9. package/dist/identity.js +73 -0
  10. package/dist/index.d.ts +7 -0
  11. package/dist/index.js +6 -0
  12. package/dist/internal/cache-engine/create.d.ts +5 -0
  13. package/dist/internal/cache-engine/create.js +7 -0
  14. package/dist/internal/cache-engine/engine.d.ts +32 -0
  15. package/dist/internal/cache-engine/engine.js +1287 -0
  16. package/dist/internal/cache-engine/errors.d.ts +5 -0
  17. package/dist/internal/cache-engine/errors.js +10 -0
  18. package/dist/internal/cache-engine/helpers.d.ts +55 -0
  19. package/dist/internal/cache-engine/helpers.js +545 -0
  20. package/dist/internal/cache-engine/index.d.ts +3 -0
  21. package/dist/internal/cache-engine/index.js +2 -0
  22. package/dist/internal/cache-engine/types.d.ts +300 -0
  23. package/dist/internal/cache-engine/types.js +1 -0
  24. package/dist/internal/cache-engine.d.ts +3 -0
  25. package/dist/internal/cache-engine.js +2 -0
  26. package/dist/lib/assert-name.d.ts +2 -0
  27. package/dist/lib/assert-name.js +6 -0
  28. package/dist/lib/compare-code-units.d.ts +2 -0
  29. package/dist/lib/compare-code-units.js +4 -0
  30. package/dist/lib/deep-equal.d.ts +2 -0
  31. package/dist/lib/deep-equal.js +24 -0
  32. package/dist/lib/freeze-record.d.ts +2 -0
  33. package/dist/lib/freeze-record.js +13 -0
  34. package/dist/lib/index.d.ts +6 -0
  35. package/dist/lib/index.js +6 -0
  36. package/dist/lib/is-plain-record.d.ts +2 -0
  37. package/dist/lib/is-plain-record.js +8 -0
  38. package/dist/lib/report.d.ts +7 -0
  39. package/dist/lib/report.js +26 -0
  40. package/dist/protocol.d.ts +179 -0
  41. package/dist/protocol.js +558 -0
  42. package/dist/react/context.d.ts +20 -0
  43. package/dist/react/context.js +24 -0
  44. package/dist/react/index.d.ts +2 -0
  45. package/dist/react/index.js +3 -0
  46. package/dist/react/query.d.ts +20 -0
  47. package/dist/react/query.js +99 -0
  48. package/dist/replica/command-id.d.ts +2 -0
  49. package/dist/replica/command-id.js +19 -0
  50. package/dist/replica/command-runtime/constants.d.ts +5 -0
  51. package/dist/replica/command-runtime/constants.js +5 -0
  52. package/dist/replica/command-runtime/create.d.ts +2 -0
  53. package/dist/replica/command-runtime/create.js +644 -0
  54. package/dist/replica/command-runtime/errors.d.ts +16 -0
  55. package/dist/replica/command-runtime/errors.js +41 -0
  56. package/dist/replica/command-runtime/index.d.ts +5 -0
  57. package/dist/replica/command-runtime/index.js +4 -0
  58. package/dist/replica/command-runtime/lib/binding.d.ts +4 -0
  59. package/dist/replica/command-runtime/lib/binding.js +64 -0
  60. package/dist/replica/command-runtime/lib/effects.d.ts +11 -0
  61. package/dist/replica/command-runtime/lib/effects.js +89 -0
  62. package/dist/replica/command-runtime/lib/index.d.ts +9 -0
  63. package/dist/replica/command-runtime/lib/index.js +9 -0
  64. package/dist/replica/command-runtime/lib/inventory.d.ts +10 -0
  65. package/dist/replica/command-runtime/lib/inventory.js +141 -0
  66. package/dist/replica/command-runtime/lib/output.d.ts +13 -0
  67. package/dist/replica/command-runtime/lib/output.js +190 -0
  68. package/dist/replica/command-runtime/lib/projection.d.ts +20 -0
  69. package/dist/replica/command-runtime/lib/projection.js +255 -0
  70. package/dist/replica/command-runtime/lib/status.d.ts +7 -0
  71. package/dist/replica/command-runtime/lib/status.js +127 -0
  72. package/dist/replica/command-runtime/lib/transport.d.ts +16 -0
  73. package/dist/replica/command-runtime/lib/transport.js +112 -0
  74. package/dist/replica/command-runtime/lib/util.d.ts +16 -0
  75. package/dist/replica/command-runtime/lib/util.js +127 -0
  76. package/dist/replica/command-runtime/lifecycle.d.ts +11 -0
  77. package/dist/replica/command-runtime/lifecycle.js +13 -0
  78. package/dist/replica/command-runtime/symbols.d.ts +30 -0
  79. package/dist/replica/command-runtime/symbols.js +30 -0
  80. package/dist/replica/command-runtime/types.d.ts +222 -0
  81. package/dist/replica/command-runtime/types.js +1 -0
  82. package/dist/replica/command-runtime.d.ts +3 -0
  83. package/dist/replica/command-runtime.js +2 -0
  84. package/dist/replica/commands/clone.d.ts +12 -0
  85. package/dist/replica/commands/clone.js +187 -0
  86. package/dist/replica/commands/constants.d.ts +6 -0
  87. package/dist/replica/commands/constants.js +6 -0
  88. package/dist/replica/commands/errors.d.ts +7 -0
  89. package/dist/replica/commands/errors.js +22 -0
  90. package/dist/replica/commands/implementation.d.ts +8 -0
  91. package/dist/replica/commands/implementation.js +8 -0
  92. package/dist/replica/commands/index.d.ts +5 -0
  93. package/dist/replica/commands/index.js +4 -0
  94. package/dist/replica/commands/prepare.d.ts +27 -0
  95. package/dist/replica/commands/prepare.js +77 -0
  96. package/dist/replica/commands/presets.d.ts +12 -0
  97. package/dist/replica/commands/presets.js +84 -0
  98. package/dist/replica/commands/receipt.d.ts +3 -0
  99. package/dist/replica/commands/receipt.js +36 -0
  100. package/dist/replica/commands/resolve.d.ts +11 -0
  101. package/dist/replica/commands/resolve.js +165 -0
  102. package/dist/replica/commands/types.d.ts +278 -0
  103. package/dist/replica/commands/types.js +2 -0
  104. package/dist/replica/commands/util.d.ts +21 -0
  105. package/dist/replica/commands/util.js +96 -0
  106. package/dist/replica/commands/validate.d.ts +18 -0
  107. package/dist/replica/commands/validate.js +477 -0
  108. package/dist/replica/commands.d.ts +3 -0
  109. package/dist/replica/commands.js +2 -0
  110. package/dist/replica/diagnostics/event-log.d.ts +4 -0
  111. package/dist/replica/diagnostics/event-log.js +463 -0
  112. package/dist/replica/diagnostics/implementation.d.ts +4 -0
  113. package/dist/replica/diagnostics/implementation.js +4 -0
  114. package/dist/replica/diagnostics/index.d.ts +2 -0
  115. package/dist/replica/diagnostics/index.js +1 -0
  116. package/dist/replica/diagnostics/inspect.d.ts +6 -0
  117. package/dist/replica/diagnostics/inspect.js +170 -0
  118. package/dist/replica/diagnostics/types.d.ts +295 -0
  119. package/dist/replica/diagnostics/types.js +2 -0
  120. package/dist/replica/diagnostics.d.ts +3 -0
  121. package/dist/replica/diagnostics.js +2 -0
  122. package/dist/replica/distributed-replica/clocks.d.ts +23 -0
  123. package/dist/replica/distributed-replica/clocks.js +156 -0
  124. package/dist/replica/distributed-replica/constants.d.ts +12 -0
  125. package/dist/replica/distributed-replica/constants.js +10 -0
  126. package/dist/replica/distributed-replica/helpers.d.ts +48 -0
  127. package/dist/replica/distributed-replica/helpers.js +445 -0
  128. package/dist/replica/distributed-replica/hydration.d.ts +19 -0
  129. package/dist/replica/distributed-replica/hydration.js +380 -0
  130. package/dist/replica/distributed-replica/impl-diagnostics.d.ts +22 -0
  131. package/dist/replica/distributed-replica/impl-diagnostics.js +189 -0
  132. package/dist/replica/distributed-replica/impl-fetch-live.d.ts +39 -0
  133. package/dist/replica/distributed-replica/impl-fetch-live.js +395 -0
  134. package/dist/replica/distributed-replica/impl-hydration-orchestrate.d.ts +56 -0
  135. package/dist/replica/distributed-replica/impl-hydration-orchestrate.js +299 -0
  136. package/dist/replica/distributed-replica/impl-optimistic.d.ts +31 -0
  137. package/dist/replica/distributed-replica/impl-optimistic.js +172 -0
  138. package/dist/replica/distributed-replica/impl-protocol.d.ts +53 -0
  139. package/dist/replica/distributed-replica/impl-protocol.js +108 -0
  140. package/dist/replica/distributed-replica/impl.d.ts +44 -0
  141. package/dist/replica/distributed-replica/impl.js +1776 -0
  142. package/dist/replica/distributed-replica/index.d.ts +2 -0
  143. package/dist/replica/distributed-replica/index.js +4 -0
  144. package/dist/replica/distributed-replica/optimistic.d.ts +30 -0
  145. package/dist/replica/distributed-replica/optimistic.js +221 -0
  146. package/dist/replica/distributed-replica/types.d.ts +147 -0
  147. package/dist/replica/distributed-replica/types.js +1 -0
  148. package/dist/replica/distributed-replica/watch.d.ts +19 -0
  149. package/dist/replica/distributed-replica/watch.js +95 -0
  150. package/dist/replica/distributed-replica.d.ts +2 -0
  151. package/dist/replica/distributed-replica.js +2 -0
  152. package/dist/replica/graphql-transport.d.ts +24 -0
  153. package/dist/replica/graphql-transport.js +122 -0
  154. package/dist/replica/identity/clone.d.ts +6 -0
  155. package/dist/replica/identity/clone.js +54 -0
  156. package/dist/replica/identity/codec.d.ts +48 -0
  157. package/dist/replica/identity/codec.js +789 -0
  158. package/dist/replica/identity/constants.d.ts +3 -0
  159. package/dist/replica/identity/constants.js +18 -0
  160. package/dist/replica/identity/implementation.d.ts +5 -0
  161. package/dist/replica/identity/implementation.js +5 -0
  162. package/dist/replica/identity/index.d.ts +3 -0
  163. package/dist/replica/identity/index.js +3 -0
  164. package/dist/replica/identity/keys.d.ts +29 -0
  165. package/dist/replica/identity/keys.js +173 -0
  166. package/dist/replica/identity.d.ts +2 -0
  167. package/dist/replica/identity.js +2 -0
  168. package/dist/replica/index-maintenance/engine.d.ts +84 -0
  169. package/dist/replica/index-maintenance/engine.js +677 -0
  170. package/dist/replica/index-maintenance/implementation.d.ts +4 -0
  171. package/dist/replica/index-maintenance/implementation.js +4 -0
  172. package/dist/replica/index-maintenance/index.d.ts +2 -0
  173. package/dist/replica/index-maintenance/index.js +1 -0
  174. package/dist/replica/index-maintenance/registry.d.ts +2 -0
  175. package/dist/replica/index-maintenance/registry.js +49 -0
  176. package/dist/replica/index-maintenance/types.d.ts +58 -0
  177. package/dist/replica/index-maintenance/types.js +1 -0
  178. package/dist/replica/index-maintenance.d.ts +3 -0
  179. package/dist/replica/index-maintenance.js +2 -0
  180. package/dist/replica/index.d.ts +17 -0
  181. package/dist/replica/index.js +9 -0
  182. package/dist/replica/materialize.d.ts +10 -0
  183. package/dist/replica/materialize.js +163 -0
  184. package/dist/replica/normalize.d.ts +27 -0
  185. package/dist/replica/normalize.js +298 -0
  186. package/dist/replica/operation-binding.d.ts +14 -0
  187. package/dist/replica/operation-binding.js +76 -0
  188. package/dist/replica/persistence/idb.d.ts +20 -0
  189. package/dist/replica/persistence/idb.js +193 -0
  190. package/dist/replica/persistence/implementation.d.ts +4 -0
  191. package/dist/replica/persistence/implementation.js +4 -0
  192. package/dist/replica/persistence/index.d.ts +2 -0
  193. package/dist/replica/persistence/index.js +1 -0
  194. package/dist/replica/persistence/state.d.ts +104 -0
  195. package/dist/replica/persistence/state.js +734 -0
  196. package/dist/replica/persistence/types.d.ts +54 -0
  197. package/dist/replica/persistence/types.js +1 -0
  198. package/dist/replica/persistence.d.ts +3 -0
  199. package/dist/replica/persistence.js +2 -0
  200. package/dist/replica/query-plan/constants.d.ts +13 -0
  201. package/dist/replica/query-plan/constants.js +7 -0
  202. package/dist/replica/query-plan/filter.d.ts +39 -0
  203. package/dist/replica/query-plan/filter.js +544 -0
  204. package/dist/replica/query-plan/index.d.ts +4 -0
  205. package/dist/replica/query-plan/index.js +3 -0
  206. package/dist/replica/query-plan/order.d.ts +11 -0
  207. package/dist/replica/query-plan/order.js +158 -0
  208. package/dist/replica/query-plan/pagination.d.ts +6 -0
  209. package/dist/replica/query-plan/pagination.js +90 -0
  210. package/dist/replica/query-plan/resolve.d.ts +14 -0
  211. package/dist/replica/query-plan/resolve.js +163 -0
  212. package/dist/replica/query-plan/types.d.ts +89 -0
  213. package/dist/replica/query-plan/types.js +1 -0
  214. package/dist/replica/query-plan/util.d.ts +13 -0
  215. package/dist/replica/query-plan/util.js +62 -0
  216. package/dist/replica/query-plan.d.ts +3 -0
  217. package/dist/replica/query-plan.js +2 -0
  218. package/dist/replica/revalidation.d.ts +9 -0
  219. package/dist/replica/revalidation.js +86 -0
  220. package/dist/replica/selection.d.ts +20 -0
  221. package/dist/replica/selection.js +109 -0
  222. package/dist/replica/types.d.ts +657 -0
  223. package/dist/replica/types.js +1 -0
  224. package/dist/request.d.ts +17 -0
  225. package/dist/request.js +123 -0
  226. package/dist/sveltekit/auth.d.ts +18 -0
  227. package/dist/sveltekit/auth.js +9 -0
  228. package/dist/sveltekit/context.d.ts +28 -0
  229. package/dist/sveltekit/context.js +58 -0
  230. package/dist/sveltekit/index.d.ts +4 -0
  231. package/dist/sveltekit/index.js +4 -0
  232. package/dist/sveltekit/replica.d.ts +145 -0
  233. package/dist/sveltekit/replica.js +491 -0
  234. package/dist/sveltekit/server-replica.d.ts +52 -0
  235. package/dist/sveltekit/server-replica.js +176 -0
  236. package/dist/sveltekit/vite.d.ts +103 -0
  237. package/dist/sveltekit/vite.js +878 -0
  238. package/dist/types.d.ts +33 -0
  239. package/dist/types.js +1 -0
  240. package/dist/websocket.d.ts +41 -0
  241. package/dist/websocket.js +187 -0
  242. package/package.json +95 -0
@@ -0,0 +1,176 @@
1
+ import { createDistributedReplica, createReplicaGraphqlTransport } from '../replica/index.js';
2
+ import { authFromPageData } from './auth.js';
3
+ /**
4
+ * One app-level root layout loader for every compiler-discovered `@load`
5
+ * operation. Each invocation creates a fresh replica and never shares SSR data
6
+ * across requests.
7
+ */
8
+ export function createDistributedSvelteKitServer(options) {
9
+ const routes = validateRoutes(options.routes);
10
+ return Object.freeze({
11
+ async load(event) {
12
+ const session = await options.getSession(event);
13
+ const accessToken = session?.accessToken ?? null;
14
+ const engineRole = options.getRole(session, event) ?? null;
15
+ const pageData = {
16
+ session,
17
+ accessToken,
18
+ engineRole
19
+ };
20
+ const auth = options.getAuth?.(pageData, event) ?? authFromPageData(pageData);
21
+ const routeId = routeIdentity(event);
22
+ const selected = routes.filter(({ plan }) => plan.route === routeId);
23
+ if (selected.length === 0) {
24
+ return {
25
+ ...pageData,
26
+ gqlError: null
27
+ };
28
+ }
29
+ const fetchImpl = event.fetch;
30
+ const transport = createReplicaGraphqlTransport({
31
+ getUrl: () => options.getUrl?.(event) ?? '/graphql',
32
+ getAuth: () => auth,
33
+ ...(fetchImpl === undefined ? {} : { fetch: fetchImpl })
34
+ });
35
+ const replica = createDistributedReplica({ transport });
36
+ const watches = [];
37
+ try {
38
+ for (const binding of selected) {
39
+ let variables;
40
+ try {
41
+ variables =
42
+ (await options.variables?.[binding.plan.operation]?.(event)) ??
43
+ {};
44
+ const watch = replica.watch(binding.artifact, variables, { live: false });
45
+ watches.push({
46
+ operation: binding.plan.operation,
47
+ artifact: binding.artifact,
48
+ variables,
49
+ watch
50
+ });
51
+ }
52
+ catch (error) {
53
+ if (options.variables?.[binding.plan.operation] === undefined) {
54
+ throw new Error(`Distributed @load operation \`${binding.plan.operation}\` needs route variables; configure variables.${binding.plan.operation}(event) in createDistributedSvelteKitServer`, { cause: error });
55
+ }
56
+ throw error;
57
+ }
58
+ }
59
+ await Promise.all(watches.map(({ watch }) => watch.refresh()));
60
+ const errors = watches.flatMap(({ watch }) => watch.get().errors);
61
+ for (const { artifact, variables, watch } of watches) {
62
+ // Preserve exact rendered-operation reachability after the
63
+ // temporary watch is released.
64
+ replica.read(artifact, variables);
65
+ watch.destroy();
66
+ }
67
+ const transfer = replica.scope === undefined
68
+ ? undefined
69
+ : hydrationTransfer(replica.dehydrate(), selected.map(({ plan }) => plan.operation));
70
+ return {
71
+ ...pageData,
72
+ ...(transfer === undefined
73
+ ? {}
74
+ : {
75
+ distributed: transfer.hydration,
76
+ distributedAuthority: transfer.authority
77
+ }),
78
+ gqlError: errors[0]?.message ??
79
+ (transfer === undefined
80
+ ? 'Distributed GraphQL response did not establish an authoritative cache scope'
81
+ : null)
82
+ };
83
+ }
84
+ finally {
85
+ for (const { watch } of watches)
86
+ watch.destroy();
87
+ }
88
+ }
89
+ });
90
+ }
91
+ /**
92
+ * Explicit one-line fallback when the compiler cannot discover route ownership.
93
+ *
94
+ * Prefer co-locating `+page.graphql`; the compiler diagnostic includes the
95
+ * equivalent `--route Operation=/route-id` registration.
96
+ */
97
+ export function registerDistributedRoute(route, operation, artifact) {
98
+ return Object.freeze({
99
+ plan: Object.freeze({
100
+ operation: nonEmpty(operation, 'operation'),
101
+ route: normalizeRoute(route),
102
+ discovery: 'explicit'
103
+ }),
104
+ artifact: artifact
105
+ });
106
+ }
107
+ function hydrationTransfer(state, operations) {
108
+ return Object.freeze({
109
+ hydration: Object.freeze({
110
+ version: 1,
111
+ state,
112
+ operations: Object.freeze([...operations])
113
+ }),
114
+ authority: Object.freeze({
115
+ version: 1,
116
+ scope: state.scope
117
+ })
118
+ });
119
+ }
120
+ function validateRoutes(value) {
121
+ if (!Array.isArray(value)) {
122
+ throw new TypeError('createDistributedSvelteKitServer requires generated DISTRIBUTED_ROUTE_OPERATIONS');
123
+ }
124
+ const identities = new Set();
125
+ return Object.freeze(value.map((binding, index) => {
126
+ if (binding === null ||
127
+ typeof binding !== 'object' ||
128
+ binding.plan === null ||
129
+ typeof binding.plan !== 'object' ||
130
+ binding.artifact === null ||
131
+ typeof binding.artifact !== 'object') {
132
+ throw new TypeError(`invalid Distributed route binding at index ${index}`);
133
+ }
134
+ const operation = nonEmpty(binding.plan.operation, 'route operation');
135
+ const route = normalizeRoute(binding.plan.route);
136
+ if (binding.artifact.id.length === 0) {
137
+ throw new TypeError(`invalid Distributed route artifact for ${operation}`);
138
+ }
139
+ const identity = `${route}\u0000${operation}`;
140
+ if (identities.has(identity)) {
141
+ throw new TypeError(`duplicate Distributed route operation ${operation} at ${route}`);
142
+ }
143
+ identities.add(identity);
144
+ return Object.freeze({
145
+ plan: Object.freeze({
146
+ ...binding.plan,
147
+ operation,
148
+ route
149
+ }),
150
+ artifact: binding.artifact
151
+ });
152
+ }));
153
+ }
154
+ function routeIdentity(event) {
155
+ const route = event.route?.id;
156
+ if (typeof route === 'string' && route.length > 0)
157
+ return normalizeRoute(route);
158
+ if (event.url !== undefined)
159
+ return normalizeRoute(event.url.pathname);
160
+ throw new Error('Distributed SvelteKit route loading requires event.route.id or event.url.pathname');
161
+ }
162
+ function normalizeRoute(value) {
163
+ const route = nonEmpty(value, 'route');
164
+ if (!route.startsWith('/')) {
165
+ throw new TypeError('Distributed route must start with /');
166
+ }
167
+ if (route.length === 1)
168
+ return route;
169
+ return route.replace(/\/+$/, '');
170
+ }
171
+ function nonEmpty(value, label) {
172
+ if (typeof value !== 'string' || value.trim().length === 0) {
173
+ throw new TypeError(`Distributed ${label} must be a non-empty string`);
174
+ }
175
+ return value.trim();
176
+ }
@@ -0,0 +1,103 @@
1
+ export type DistributedGraphqlProxyOptions = {
2
+ /** Absolute Distributed API origin, for example `http://127.0.0.1:8791`. */
3
+ target: string;
4
+ /** Proxy key. Defaults to `/graphql` and includes its `/ws` child. */
5
+ path?: string;
6
+ };
7
+ /** Vite proxy config for GraphQL HTTP and WebSocket traffic. */
8
+ export declare function distributedGraphqlProxy(options: DistributedGraphqlProxyOptions | string): Record<string, {
9
+ target: string;
10
+ changeOrigin: true;
11
+ ws: true;
12
+ }>;
13
+ export type DistributedSvelteKitManifestSource = string | Readonly<{
14
+ /**
15
+ * Arguments passed to the configured dctl command. The first value
16
+ * must be `client-manifest`; stdout becomes ephemeral compiler input.
17
+ */
18
+ args: readonly string[];
19
+ }>;
20
+ export type DistributedSvelteKitClientCompiler = Readonly<{
21
+ /** `$distributed` or an explicit elevated entrypoint such as `$distributed/admin`. */
22
+ module: string;
23
+ /** Existing manifest path, or canonical `dctl client-manifest` argv. */
24
+ manifest: DistributedSvelteKitManifestSource;
25
+ /** Verify exactly one concrete role. Mutually exclusive with `surface`. */
26
+ role?: string;
27
+ /** Verify exactly one Rust-declared application surface. */
28
+ surface?: string;
29
+ /** GraphQL globs passed verbatim as repeated `dctl client --documents`. */
30
+ documents: readonly string[];
31
+ /** Explicit `OPERATION=/route` fallbacks. */
32
+ routes?: readonly string[];
33
+ /** Compiler-owned artifact directory, relative to `cwd` by default. */
34
+ out: string;
35
+ }>;
36
+ export type DistributedSvelteKitViteOptions = Readonly<{
37
+ /** Project root used for dctl cwd, document globs, and output containment. */
38
+ cwd?: string;
39
+ /** Executable invoked without a shell. Defaults to `dctl`. */
40
+ command?: string;
41
+ /** Prefix argv, e.g. `cargo run ... --`; never interpreted by a shell. */
42
+ commandArgs?: readonly string[];
43
+ clients: readonly DistributedSvelteKitClientCompiler[];
44
+ }>;
45
+ type ViteWebSocketLike = Readonly<{
46
+ send(payload: unknown): void;
47
+ }>;
48
+ type ViteModuleGraphLike = Readonly<{
49
+ getModuleById(id: string): unknown;
50
+ invalidateModule(module: unknown): void;
51
+ }>;
52
+ type ViteServerLike = Readonly<{
53
+ watcher: Readonly<{
54
+ add(paths: string | readonly string[]): void;
55
+ }>;
56
+ ws: ViteWebSocketLike;
57
+ moduleGraph: ViteModuleGraphLike;
58
+ httpServer?: Readonly<{
59
+ once(event: 'close', listener: () => void): void;
60
+ }> | null;
61
+ }>;
62
+ type ViteHotContextLike = Readonly<{
63
+ file: string;
64
+ server: ViteServerLike;
65
+ }>;
66
+ type RollupWatchContextLike = Readonly<{
67
+ addWatchFile(path: string): void;
68
+ }>;
69
+ /** Minimal structural Vite plugin type; avoids making Vite a runtime dependency. */
70
+ export type DistributedSvelteKitVitePlugin = Readonly<{
71
+ name: string;
72
+ enforce: 'pre';
73
+ configResolved(config: Readonly<{
74
+ root: string;
75
+ }>): Promise<void>;
76
+ configureServer(server: ViteServerLike): void;
77
+ buildStart(this: RollupWatchContextLike): void;
78
+ resolveId(source: string): string | undefined;
79
+ load(id: string): string | undefined;
80
+ handleHotUpdate(context: ViteHotContextLike): Promise<never[] | undefined>;
81
+ watchChange(id: string): Promise<void>;
82
+ closeBundle(): Promise<void>;
83
+ }>;
84
+ /** Generate every configured surface through the same transaction used by Vite. */
85
+ export declare function generateDistributedSvelteKit(options: DistributedSvelteKitViteOptions): Promise<void>;
86
+ /** Check every configured surface through canonical `dctl client --check`; never write. */
87
+ export declare function checkDistributedSvelteKit(options: DistributedSvelteKitViteOptions): Promise<void>;
88
+ /**
89
+ * Compiler-watching Vite integration for one or more authorization surfaces.
90
+ *
91
+ * Every run stages every surface first, then swaps the complete generated
92
+ * trees as one rollback-capable transaction. Child processes are serialized,
93
+ * coalesced, abortable, and always invoked without a shell.
94
+ */
95
+ export declare function distributedSvelteKit(options: DistributedSvelteKitViteOptions): DistributedSvelteKitVitePlugin;
96
+ /**
97
+ * SvelteKit language-tool aliases for the exact files used by Vite resolution.
98
+ *
99
+ * Keep this alongside the Vite plugin in the Node-only export. It performs no
100
+ * generation and is safe to call from `svelte.config.js`.
101
+ */
102
+ export declare function distributedSvelteKitAliases(options: Pick<DistributedSvelteKitViteOptions, 'cwd' | 'clients'>): Readonly<Record<string, string>>;
103
+ export {};