@sigil-dev/grimoire 0.7.6 → 0.8.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 (41) hide show
  1. package/index.ts +35 -34
  2. package/package.json +8 -6
  3. package/preload.js +3 -2
  4. package/server.ts +13 -13
  5. package/src/client/head.ts +29 -29
  6. package/src/client/router.ts +120 -53
  7. package/src/dev/compile-module.ts +173 -0
  8. package/src/dev/effect-registry.ts +23 -0
  9. package/src/dev/graph.ts +114 -0
  10. package/src/dev/hmr-client.ts +158 -0
  11. package/src/dev/hmr-server.ts +187 -0
  12. package/src/dev/loader.ts +47 -0
  13. package/src/dev/paths.ts +14 -0
  14. package/src/dev/runtime-bundle.ts +49 -0
  15. package/src/dev/watcher.ts +44 -0
  16. package/src/integrations/vite.ts +73 -72
  17. package/src/rendering/hydrate.ts +102 -64
  18. package/src/rendering/index.ts +296 -199
  19. package/src/rendering/ssrPlugin.ts +67 -53
  20. package/src/routing/manifest-gen.ts +42 -39
  21. package/src/routing/router.ts +109 -106
  22. package/src/routing/scanner.ts +141 -135
  23. package/src/routing/transform-routes.ts +101 -101
  24. package/src/server/build.ts +239 -147
  25. package/src/server/coordinator.ts +306 -306
  26. package/src/server/index.ts +260 -50
  27. package/src/server/worker.ts +59 -59
  28. package/src/typegen/index.ts +356 -353
  29. package/src/types.ts +270 -269
  30. package/test/context.test.ts +52 -52
  31. package/test/hydration.test.ts +119 -119
  32. package/test/middleware.test.ts +223 -223
  33. package/test/rendering.test.ts +579 -425
  34. package/test/routing.test.ts +81 -83
  35. package/test/scanning.test.ts +200 -181
  36. package/test/scope.test.ts +24 -8
  37. package/test/server.test.ts +249 -229
  38. package/test/streaming.test.ts +125 -106
  39. package/test/transform-routes.test.ts +84 -84
  40. package/test/typegen.test.ts +35 -25
  41. package/tsconfig.json +1 -0
@@ -1,306 +1,306 @@
1
- import { type Subprocess, spawn } from "bun";
2
- import { join } from "path";
3
- import { matchRoute } from "../routing/router";
4
- import { type RouteFile, type RouteTree, scanRoutes } from "../routing/scanner";
5
- import type {
6
- CoordinatorContext,
7
- GrimoireConfig,
8
- GrimoirePlugin,
9
- Route,
10
- WorkerDescriptor,
11
- WorkerMode,
12
- } from "../types";
13
- import { buildProject } from "./build";
14
- import {
15
- runHook,
16
- runRouteRequest,
17
- runSerializeLocals,
18
- runWorkerSpawn,
19
- } from "./plugins";
20
-
21
- async function waitForWorkers(
22
- workers: LiveWorker[],
23
- timeoutMs = 10_000,
24
- ): Promise<void> {
25
- const ready = new Set<number>();
26
- const start = Date.now();
27
-
28
- while (ready.size < workers.length) {
29
- if (Date.now() - start > timeoutMs) {
30
- const pending = workers
31
- .filter((w) => !ready.has(w.descriptor.globalIndex))
32
- .map(
33
- (w) =>
34
- w.descriptor.name ?? `${w.descriptor.mode}-${w.descriptor.index}`,
35
- )
36
- .join(", ");
37
- throw new Error(
38
- `Grimoire: workers timed out waiting to become ready: ${pending}`,
39
- );
40
- }
41
- for (const w of workers) {
42
- if (ready.has(w.descriptor.globalIndex)) continue;
43
- if (w.descriptor.pid != null) {
44
- ready.add(w.descriptor.globalIndex);
45
- }
46
- }
47
- await Bun.sleep(50);
48
- }
49
- }
50
-
51
- function roundRobin(workers: WorkerDescriptor[]): WorkerDescriptor {
52
- const idx = roundRobinCounter++ % workers.length;
53
- return workers[idx];
54
- }
55
- let roundRobinCounter = 0;
56
-
57
- function consistentHash(
58
- req: Request,
59
- workers: WorkerDescriptor[],
60
- ): WorkerDescriptor {
61
- const key = req.headers.get("cookie") ?? req.url;
62
- let hash = 0;
63
- for (let i = 0; i < key.length; i++) {
64
- hash = (hash * 31 + key.charCodeAt(i)) >>> 0;
65
- }
66
- return workers[hash % workers.length];
67
- }
68
-
69
- function defaultRoute(
70
- req: Request,
71
- workers: WorkerDescriptor[],
72
- tree: RouteTree,
73
- ): WorkerDescriptor {
74
- const isWs = req.headers.get("upgrade")?.toLowerCase() === "websocket";
75
-
76
- if (isWs) {
77
- const wsWorkers = workers.filter(
78
- (w) => w.mode === "ws" || w.mode === "full",
79
- );
80
- if (wsWorkers.length) return consistentHash(req, wsWorkers);
81
- }
82
-
83
- const url = new URL(req.url);
84
- const matched = matchRoute(tree, url);
85
-
86
- if (matched?.route.type === "server") {
87
- const apiWorkers = workers.filter(
88
- (w) => w.mode === "api" || w.mode === "full",
89
- );
90
- if (apiWorkers.length) return roundRobin(apiWorkers);
91
- }
92
-
93
- const frontendWorkers = workers.filter(
94
- (w) => w.mode === "frontend" || w.mode === "full",
95
- );
96
- if (frontendWorkers.length) return roundRobin(frontendWorkers);
97
-
98
- // fallback — should not happen if scale spec is valid
99
- return workers[0];
100
- }
101
-
102
- export interface ScaleSpec {
103
- api?: number;
104
- frontend?: number;
105
- ws?: number;
106
- [mode: string]: number | undefined;
107
- }
108
-
109
- export interface CoordinatorOptions {
110
- config: GrimoireConfig;
111
- plugins: GrimoirePlugin[];
112
- scale: ScaleSpec;
113
- noBuild: boolean;
114
- }
115
-
116
- interface LiveWorker {
117
- descriptor: WorkerDescriptor;
118
- process: Subprocess;
119
- port: number;
120
- }
121
-
122
- export async function startCoordinator(options: CoordinatorOptions) {
123
- const { config, plugins, scale, noBuild } = options;
124
- const { port = 3000, host = "localhost", routes = "src/routes" } = config;
125
- let stopping = false;
126
-
127
- // 1. build if needed
128
- if (!noBuild) {
129
- const { result } = await buildProject(config, plugins);
130
- if (!result.success) throw new Error("Grimoire: build failed");
131
- }
132
-
133
- // 2. generate ephemeral secret
134
- const secret = crypto.randomUUID() + crypto.randomUUID(); // 72 hex chars
135
-
136
- // 3. scan routes once — coordinator owns the route tree
137
- const routesDir = /* resolve */ routes;
138
- const tree = await scanRoutes(routesDir, process.cwd());
139
-
140
- // 4. derive route slices per mode
141
- const slices: Record<string, RouteFile[]> = {
142
- api: tree.routes.filter((r) => r.type === "server"),
143
- ws: tree.routes.filter((r) => r.type === "server"),
144
- frontend: tree.routes.filter(
145
- (r) => r.type === "page" || r.type === "simple",
146
- ),
147
- full: [...tree.routes],
148
- };
149
-
150
- // 5. spawn workers
151
- const liveWorkers: LiveWorker[] = [];
152
- let globalIndex = 0;
153
- let nextPort = port + 1;
154
-
155
- for (const [mode, count = 0] of Object.entries(scale)) {
156
- for (let i = 0; i < count; i++) {
157
- const workerPort = nextPort++;
158
- const descriptor: WorkerDescriptor = {
159
- mode: mode as WorkerMode,
160
- index: i + 1,
161
- globalIndex: globalIndex++,
162
- internalUrl: `http://127.0.0.1:${workerPort}`,
163
- routes: slices[mode] ?? slices.full,
164
- };
165
-
166
- // let plugins inject env and name
167
- const workerEnv = await runWorkerSpawn(plugins, descriptor);
168
- const workerEntry = join(import.meta.dir, "./worker.ts");
169
- if (workerEnv.name) descriptor.name = workerEnv.name;
170
-
171
- // Inject env vars prefixed with PUBLIC_ so they're available to client bundles
172
- const publicEnvVars: Record<string, string> = {};
173
- for (const [key, value] of Object.entries(process.env)) {
174
- if (key.startsWith("PUBLIC_") && value !== undefined) {
175
- publicEnvVars[key] = value;
176
- }
177
- }
178
-
179
- const proc = spawn(["bun", "run", workerEntry], {
180
- env: {
181
- ...process.env,
182
- ...workerEnv.env,
183
- ...publicEnvVars,
184
- GRIMOIRE_MODE: mode,
185
- GRIMOIRE_WORKER_INDEX: String(i),
186
- GRIMOIRE_WORKER_PORT: String(workerPort),
187
- GRIMOIRE_INTERNAL_SECRET: secret,
188
- GRIMOIRE_WORKER_NAME: descriptor.name ?? `${mode}-${i}`,
189
- },
190
- ipc(message) {
191
- // worker sends { ready: true } when Bun.serve is up
192
- if (message?.ready) {
193
- descriptor.pid = proc.pid;
194
- runHook(plugins, "onWorkerReady", descriptor);
195
- }
196
- },
197
- onExit(proc, exitCode) {
198
- const intentional = stopping;
199
- runHook(
200
- plugins,
201
- "onWorkerDeath",
202
- descriptor,
203
- intentional ? "intentional" : "crash",
204
- );
205
- if (!intentional) {
206
- console.error(
207
- `[grimoire] worker ${descriptor.name ?? descriptor.mode + "-" + descriptor.index} crashed (exit ${exitCode}), respawning...`,
208
- );
209
- // respawn: same descriptor, same port
210
- // (simplified — plugin-scale can override this behavior)
211
- }
212
- },
213
- });
214
-
215
- liveWorkers.push({ descriptor, process: proc, port: workerPort });
216
- }
217
- }
218
-
219
- // 6. wait for all workers ready (with timeout)
220
- // workers send IPC { ready: true } — coordinator waits up to 10s
221
- await waitForWorkers(liveWorkers);
222
-
223
- // 7. fire onCoordinatorStart
224
- const ctx: CoordinatorContext = {
225
- workers: liveWorkers.map((w) => w.descriptor),
226
- port,
227
- secret,
228
- routes: tree,
229
- };
230
- await runHook(plugins, "onCoordinatorStart", ctx);
231
-
232
- // 8. start coordinator Bun.serve
233
-
234
- const server = Bun.serve({
235
- port,
236
- hostname: host,
237
- fetch: async (req) => {
238
- // run hooks.server.ts to populate locals
239
- const locals: App.Locals = {};
240
- // ... same handle() chain as createServer but resolve() just
241
- // forwards instead of rendering
242
-
243
- // pick worker
244
- const descriptors = liveWorkers.map((w) => w.descriptor);
245
- const chosen =
246
- (await runRouteRequest(plugins, req, descriptors, tree)) ??
247
- defaultRoute(req, descriptors, tree);
248
-
249
- // serialize locals
250
- const serialized =
251
- (await runSerializeLocals(plugins, locals)) ??
252
- defaultSerialize(locals, secret);
253
-
254
- // forward
255
- return fetch(chosen.internalUrl + new URL(req.url).pathname, {
256
- method: req.method,
257
- headers: {
258
- //@ts-expect-error shut Up
259
- ...Object.fromEntries(req.headers),
260
- "X-Grimoire-Locals": serialized,
261
- "X-Grimoire-Internal": secret,
262
- },
263
- body: req.body,
264
- });
265
- },
266
- });
267
-
268
- // 9. shutdown
269
- const handleShutdown = async () => {
270
- if (stopping) return;
271
- stopping = true;
272
- await runHook(plugins, "onStop", "shutdown");
273
- for (const w of liveWorkers) w.process.kill();
274
- server.stop();
275
- process.exit(0);
276
- };
277
- process.on("SIGINT", handleShutdown);
278
- process.on("SIGTERM", handleShutdown);
279
-
280
- return {
281
- server,
282
- workers: liveWorkers.map((w) => ({
283
- name: w.descriptor.name,
284
- mode: w.descriptor.mode,
285
- port: w.port,
286
- index: w.descriptor.index,
287
- })),
288
- };
289
- }
290
-
291
- function defaultSerialize(locals: App.Locals, secret: string): string {
292
- const payload = JSON.stringify(locals);
293
- const sig = new Bun.CryptoHasher("sha256")
294
- .update(secret + payload)
295
- .digest("hex");
296
- return Buffer.from(JSON.stringify({ payload, sig })).toString("base64");
297
- }
298
-
299
- function defaultDeserialize(raw: string, secret: string): App.Locals {
300
- const { payload, sig } = JSON.parse(Buffer.from(raw, "base64").toString());
301
- const expected = new Bun.CryptoHasher("sha256")
302
- .update(secret + payload)
303
- .digest("hex");
304
- if (sig !== expected) throw new Error("Grimoire: locals signature invalid");
305
- return JSON.parse(payload);
306
- }
1
+ import { type Subprocess, spawn } from "bun";
2
+ import { join } from "path";
3
+ import { matchRoute } from "../routing/router";
4
+ import { type RouteFile, type RouteTree, scanRoutes } from "../routing/scanner";
5
+ import type {
6
+ CoordinatorContext,
7
+ GrimoireConfig,
8
+ GrimoirePlugin,
9
+ Route,
10
+ WorkerDescriptor,
11
+ WorkerMode,
12
+ } from "../types";
13
+ import { buildProject } from "./build";
14
+ import {
15
+ runHook,
16
+ runRouteRequest,
17
+ runSerializeLocals,
18
+ runWorkerSpawn,
19
+ } from "./plugins";
20
+
21
+ async function waitForWorkers(
22
+ workers: LiveWorker[],
23
+ timeoutMs = 10_000,
24
+ ): Promise<void> {
25
+ const ready = new Set<number>();
26
+ const start = Date.now();
27
+
28
+ while (ready.size < workers.length) {
29
+ if (Date.now() - start > timeoutMs) {
30
+ const pending = workers
31
+ .filter((w) => !ready.has(w.descriptor.globalIndex))
32
+ .map(
33
+ (w) =>
34
+ w.descriptor.name ?? `${w.descriptor.mode}-${w.descriptor.index}`,
35
+ )
36
+ .join(", ");
37
+ throw new Error(
38
+ `Grimoire: workers timed out waiting to become ready: ${pending}`,
39
+ );
40
+ }
41
+ for (const w of workers) {
42
+ if (ready.has(w.descriptor.globalIndex)) continue;
43
+ if (w.descriptor.pid != null) {
44
+ ready.add(w.descriptor.globalIndex);
45
+ }
46
+ }
47
+ await Bun.sleep(50);
48
+ }
49
+ }
50
+
51
+ function roundRobin(workers: WorkerDescriptor[]): WorkerDescriptor {
52
+ const idx = roundRobinCounter++ % workers.length;
53
+ return workers[idx];
54
+ }
55
+ let roundRobinCounter = 0;
56
+
57
+ function consistentHash(
58
+ req: Request,
59
+ workers: WorkerDescriptor[],
60
+ ): WorkerDescriptor {
61
+ const key = req.headers.get("cookie") ?? req.url;
62
+ let hash = 0;
63
+ for (let i = 0; i < key.length; i++) {
64
+ hash = (hash * 31 + key.charCodeAt(i)) >>> 0;
65
+ }
66
+ return workers[hash % workers.length];
67
+ }
68
+
69
+ function defaultRoute(
70
+ req: Request,
71
+ workers: WorkerDescriptor[],
72
+ tree: RouteTree,
73
+ ): WorkerDescriptor {
74
+ const isWs = req.headers.get("upgrade")?.toLowerCase() === "websocket";
75
+
76
+ if (isWs) {
77
+ const wsWorkers = workers.filter(
78
+ (w) => w.mode === "ws" || w.mode === "full",
79
+ );
80
+ if (wsWorkers.length) return consistentHash(req, wsWorkers);
81
+ }
82
+
83
+ const url = new URL(req.url);
84
+ const matched = matchRoute(tree, url);
85
+
86
+ if (matched?.route.type === "server") {
87
+ const apiWorkers = workers.filter(
88
+ (w) => w.mode === "api" || w.mode === "full",
89
+ );
90
+ if (apiWorkers.length) return roundRobin(apiWorkers);
91
+ }
92
+
93
+ const frontendWorkers = workers.filter(
94
+ (w) => w.mode === "frontend" || w.mode === "full",
95
+ );
96
+ if (frontendWorkers.length) return roundRobin(frontendWorkers);
97
+
98
+ // fallback — should not happen if scale spec is valid
99
+ return workers[0];
100
+ }
101
+
102
+ export interface ScaleSpec {
103
+ api?: number;
104
+ frontend?: number;
105
+ ws?: number;
106
+ [mode: string]: number | undefined;
107
+ }
108
+
109
+ export interface CoordinatorOptions {
110
+ config: GrimoireConfig;
111
+ plugins: GrimoirePlugin[];
112
+ scale: ScaleSpec;
113
+ noBuild: boolean;
114
+ }
115
+
116
+ interface LiveWorker {
117
+ descriptor: WorkerDescriptor;
118
+ process: Subprocess;
119
+ port: number;
120
+ }
121
+
122
+ export async function startCoordinator(options: CoordinatorOptions) {
123
+ const { config, plugins, scale, noBuild } = options;
124
+ const { port = 3000, host = "localhost", routes = "src/routes" } = config;
125
+ let stopping = false;
126
+
127
+ // 1. build if needed
128
+ if (!noBuild) {
129
+ const { result } = await buildProject(config, plugins);
130
+ if (!result.success) throw new Error("Grimoire: build failed");
131
+ }
132
+
133
+ // 2. generate ephemeral secret
134
+ const secret = crypto.randomUUID() + crypto.randomUUID(); // 72 hex chars
135
+
136
+ // 3. scan routes once — coordinator owns the route tree
137
+ const routesDir = /* resolve */ routes;
138
+ const tree = await scanRoutes(routesDir, process.cwd());
139
+
140
+ // 4. derive route slices per mode
141
+ const slices: Record<string, RouteFile[]> = {
142
+ api: tree.routes.filter((r) => r.type === "server"),
143
+ ws: tree.routes.filter((r) => r.type === "server"),
144
+ frontend: tree.routes.filter(
145
+ (r) => r.type === "page" || r.type === "simple",
146
+ ),
147
+ full: [...tree.routes],
148
+ };
149
+
150
+ // 5. spawn workers
151
+ const liveWorkers: LiveWorker[] = [];
152
+ let globalIndex = 0;
153
+ let nextPort = port + 1;
154
+
155
+ for (const [mode, count = 0] of Object.entries(scale)) {
156
+ for (let i = 0; i < count; i++) {
157
+ const workerPort = nextPort++;
158
+ const descriptor: WorkerDescriptor = {
159
+ mode: mode as WorkerMode,
160
+ index: i + 1,
161
+ globalIndex: globalIndex++,
162
+ internalUrl: `http://127.0.0.1:${workerPort}`,
163
+ routes: slices[mode] ?? slices.full,
164
+ };
165
+
166
+ // let plugins inject env and name
167
+ const workerEnv = await runWorkerSpawn(plugins, descriptor);
168
+ const workerEntry = join(import.meta.dir, "./worker.ts");
169
+ if (workerEnv.name) descriptor.name = workerEnv.name;
170
+
171
+ // Inject env vars prefixed with PUBLIC_ so they're available to client bundles
172
+ const publicEnvVars: Record<string, string> = {};
173
+ for (const [key, value] of Object.entries(process.env)) {
174
+ if (key.startsWith("PUBLIC_") && value !== undefined) {
175
+ publicEnvVars[key] = value;
176
+ }
177
+ }
178
+
179
+ const proc = spawn(["bun", "run", workerEntry], {
180
+ env: {
181
+ ...process.env,
182
+ ...workerEnv.env,
183
+ ...publicEnvVars,
184
+ GRIMOIRE_MODE: mode,
185
+ GRIMOIRE_WORKER_INDEX: String(i),
186
+ GRIMOIRE_WORKER_PORT: String(workerPort),
187
+ GRIMOIRE_INTERNAL_SECRET: secret,
188
+ GRIMOIRE_WORKER_NAME: descriptor.name ?? `${mode}-${i}`,
189
+ },
190
+ ipc(message) {
191
+ // worker sends { ready: true } when Bun.serve is up
192
+ if (message?.ready) {
193
+ descriptor.pid = proc.pid;
194
+ runHook(plugins, "onWorkerReady", descriptor);
195
+ }
196
+ },
197
+ onExit(proc, exitCode) {
198
+ const intentional = stopping;
199
+ runHook(
200
+ plugins,
201
+ "onWorkerDeath",
202
+ descriptor,
203
+ intentional ? "intentional" : "crash",
204
+ );
205
+ if (!intentional) {
206
+ console.error(
207
+ `[grimoire] worker ${descriptor.name ?? descriptor.mode + "-" + descriptor.index} crashed (exit ${exitCode}), respawning...`,
208
+ );
209
+ // respawn: same descriptor, same port
210
+ // (simplified — plugin-scale can override this behavior)
211
+ }
212
+ },
213
+ });
214
+
215
+ liveWorkers.push({ descriptor, process: proc, port: workerPort });
216
+ }
217
+ }
218
+
219
+ // 6. wait for all workers ready (with timeout)
220
+ // workers send IPC { ready: true } — coordinator waits up to 10s
221
+ await waitForWorkers(liveWorkers);
222
+
223
+ // 7. fire onCoordinatorStart
224
+ const ctx: CoordinatorContext = {
225
+ workers: liveWorkers.map((w) => w.descriptor),
226
+ port,
227
+ secret,
228
+ routes: tree,
229
+ };
230
+ await runHook(plugins, "onCoordinatorStart", ctx);
231
+
232
+ // 8. start coordinator Bun.serve
233
+
234
+ const server = Bun.serve({
235
+ port,
236
+ hostname: host,
237
+ fetch: async (req) => {
238
+ // run hooks.server.ts to populate locals
239
+ const locals: App.Locals = {};
240
+ // ... same handle() chain as createServer but resolve() just
241
+ // forwards instead of rendering
242
+
243
+ // pick worker
244
+ const descriptors = liveWorkers.map((w) => w.descriptor);
245
+ const chosen =
246
+ (await runRouteRequest(plugins, req, descriptors, tree)) ??
247
+ defaultRoute(req, descriptors, tree);
248
+
249
+ // serialize locals
250
+ const serialized =
251
+ (await runSerializeLocals(plugins, locals)) ??
252
+ defaultSerialize(locals, secret);
253
+
254
+ // forward
255
+ return fetch(chosen.internalUrl + new URL(req.url).pathname, {
256
+ method: req.method,
257
+ headers: {
258
+ //@ts-expect-error shut Up
259
+ ...Object.fromEntries(req.headers),
260
+ "X-Grimoire-Locals": serialized,
261
+ "X-Grimoire-Internal": secret,
262
+ },
263
+ body: req.body,
264
+ });
265
+ },
266
+ });
267
+
268
+ // 9. shutdown
269
+ const handleShutdown = async () => {
270
+ if (stopping) return;
271
+ stopping = true;
272
+ await runHook(plugins, "onStop", "shutdown");
273
+ for (const w of liveWorkers) w.process.kill();
274
+ server.stop();
275
+ process.exit(0);
276
+ };
277
+ process.on("SIGINT", handleShutdown);
278
+ process.on("SIGTERM", handleShutdown);
279
+
280
+ return {
281
+ server,
282
+ workers: liveWorkers.map((w) => ({
283
+ name: w.descriptor.name,
284
+ mode: w.descriptor.mode,
285
+ port: w.port,
286
+ index: w.descriptor.index,
287
+ })),
288
+ };
289
+ }
290
+
291
+ function defaultSerialize(locals: App.Locals, secret: string): string {
292
+ const payload = JSON.stringify(locals);
293
+ const sig = new Bun.CryptoHasher("sha256")
294
+ .update(secret + payload)
295
+ .digest("hex");
296
+ return Buffer.from(JSON.stringify({ payload, sig })).toString("base64");
297
+ }
298
+
299
+ function defaultDeserialize(raw: string, secret: string): App.Locals {
300
+ const { payload, sig } = JSON.parse(Buffer.from(raw, "base64").toString());
301
+ const expected = new Bun.CryptoHasher("sha256")
302
+ .update(secret + payload)
303
+ .digest("hex");
304
+ if (sig !== expected) throw new Error("Grimoire: locals signature invalid");
305
+ return JSON.parse(payload);
306
+ }