@fragno-dev/core 0.0.7 → 0.1.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 (59) hide show
  1. package/.turbo/turbo-build.log +53 -46
  2. package/.turbo/turbo-test.log +45 -45
  3. package/CHANGELOG.md +6 -0
  4. package/dist/api/api.d.ts +1 -1
  5. package/dist/api/api.js +1 -1
  6. package/dist/api/fragment-builder.d.ts +3 -0
  7. package/dist/api/fragment-builder.js +3 -0
  8. package/dist/api/fragment-instantiation.d.ts +3 -0
  9. package/dist/api/fragment-instantiation.js +5 -0
  10. package/dist/{api-CAPyac52.d.ts → api-Dcr4_-3g.d.ts} +1 -1
  11. package/dist/{api-CAPyac52.d.ts.map → api-Dcr4_-3g.d.ts.map} +1 -1
  12. package/dist/{api-DuzjjCT4.js → api-DngJDcmO.js} +1 -1
  13. package/dist/{api-DuzjjCT4.js.map → api-DngJDcmO.js.map} +1 -1
  14. package/dist/client/client.d.ts +2 -2
  15. package/dist/client/client.js +4 -4
  16. package/dist/client/client.svelte.d.ts +2 -2
  17. package/dist/client/client.svelte.js +4 -4
  18. package/dist/client/react.d.ts +2 -2
  19. package/dist/client/react.js +4 -4
  20. package/dist/client/solid.d.ts +2 -2
  21. package/dist/client/solid.js +4 -4
  22. package/dist/client/vanilla.d.ts +2 -2
  23. package/dist/client/vanilla.js +4 -4
  24. package/dist/client/vue.d.ts +2 -2
  25. package/dist/client/vue.js +4 -4
  26. package/dist/{client-C_Oc8hpD.js → client-CZCasGGB.js} +3 -3
  27. package/dist/client-CZCasGGB.js.map +1 -0
  28. package/dist/fragment-builder-DOnCVBqc.js +47 -0
  29. package/dist/fragment-builder-DOnCVBqc.js.map +1 -0
  30. package/dist/{client-DdpPMlXL.d.ts → fragment-builder-Dcdsms1l.d.ts} +136 -118
  31. package/dist/fragment-builder-Dcdsms1l.d.ts.map +1 -0
  32. package/dist/fragment-instantiation-f4AhwQss.js +197 -0
  33. package/dist/fragment-instantiation-f4AhwQss.js.map +1 -0
  34. package/dist/integrations/react-ssr.js +1 -1
  35. package/dist/mod.d.ts +3 -3
  36. package/dist/mod.js +5 -214
  37. package/dist/{route-Dq62lXqB.js → route-B4RbOWjd.js} +2 -2
  38. package/dist/{route-Dq62lXqB.js.map → route-B4RbOWjd.js.map} +1 -1
  39. package/dist/{ssr-BAhbA_3q.js → ssr-CamRrMc0.js} +1 -1
  40. package/dist/{ssr-BAhbA_3q.js.map → ssr-CamRrMc0.js.map} +1 -1
  41. package/package.json +13 -1
  42. package/src/api/fragment-builder.ts +81 -0
  43. package/src/api/{fragment.ts → fragment-instantiation.ts} +36 -56
  44. package/src/api/fragment.test.ts +44 -16
  45. package/src/api/request-middleware.test.ts +3 -2
  46. package/src/client/client-builder.test.ts +2 -2
  47. package/src/client/client.ssr.test.ts +1 -1
  48. package/src/client/client.svelte.test.ts +1 -1
  49. package/src/client/client.test.ts +1 -1
  50. package/src/client/client.ts +5 -2
  51. package/src/client/react.test.ts +1 -1
  52. package/src/client/solid.test.ts +1 -1
  53. package/src/client/vanilla.test.ts +1 -1
  54. package/src/client/vue.test.ts +1 -1
  55. package/src/mod.ts +3 -3
  56. package/tsdown.config.ts +2 -0
  57. package/dist/client-C_Oc8hpD.js.map +0 -1
  58. package/dist/client-DdpPMlXL.d.ts.map +0 -1
  59. package/dist/mod.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fragno-dev/core",
3
- "version": "0.0.7",
3
+ "version": "0.1.0",
4
4
  "exports": {
5
5
  ".": {
6
6
  "bun": "./src/mod.ts",
@@ -14,6 +14,18 @@
14
14
  "types": "./dist/api/api.d.ts",
15
15
  "default": "./dist/api/api.js"
16
16
  },
17
+ "./api/fragment-builder": {
18
+ "bun": "./src/api/fragment-builder.ts",
19
+ "development": "./src/api/fragment-builder.ts",
20
+ "types": "./dist/api/fragment-builder.d.ts",
21
+ "default": "./dist/api/fragment-builder.js"
22
+ },
23
+ "./api/fragment-instantiation": {
24
+ "bun": "./src/api/fragment-instantiation.ts",
25
+ "development": "./src/api/fragment-instantiation.ts",
26
+ "types": "./dist/api/fragment-instantiation.d.ts",
27
+ "default": "./dist/api/fragment-instantiation.js"
28
+ },
17
29
  "./client": {
18
30
  "bun": "./src/client/client.ts",
19
31
  "development": "./src/client/client.ts",
@@ -0,0 +1,81 @@
1
+ import type { FragnoPublicConfig } from "./fragment-instantiation";
2
+
3
+ export interface FragmentDefinition<
4
+ TConfig,
5
+ TDeps = {},
6
+ TServices extends Record<string, unknown> = {},
7
+ TAdditionalContext extends Record<string, unknown> = {},
8
+ > {
9
+ name: string;
10
+ dependencies?: (config: TConfig, options: FragnoPublicConfig) => TDeps;
11
+ services?: (config: TConfig, options: FragnoPublicConfig, deps: TDeps) => TServices;
12
+ additionalContext?: TAdditionalContext;
13
+ }
14
+
15
+ export class FragmentBuilder<
16
+ const TConfig,
17
+ const TDeps = {},
18
+ const TServices extends Record<string, unknown> = {},
19
+ const TAdditionalContext extends Record<string, unknown> = {},
20
+ > {
21
+ #definition: FragmentDefinition<TConfig, TDeps, TServices, TAdditionalContext>;
22
+
23
+ constructor(definition: FragmentDefinition<TConfig, TDeps, TServices, TAdditionalContext>) {
24
+ this.#definition = definition;
25
+ }
26
+
27
+ get definition() {
28
+ return this.#definition;
29
+ }
30
+
31
+ get $requiredOptions(): FragnoPublicConfig {
32
+ throw new Error("Type only method. Do not call.");
33
+ }
34
+
35
+ withDependencies<TNewDeps>(
36
+ fn: (
37
+ context: { config: TConfig; fragnoConfig: FragnoPublicConfig } & TAdditionalContext,
38
+ ) => TNewDeps,
39
+ ): FragmentBuilder<TConfig, TNewDeps, {}, TAdditionalContext> {
40
+ return new FragmentBuilder<TConfig, TNewDeps, {}, TAdditionalContext>({
41
+ name: this.#definition.name,
42
+ dependencies: (config: TConfig, options: FragnoPublicConfig) => {
43
+ return fn({ config, fragnoConfig: options } as {
44
+ config: TConfig;
45
+ fragnoConfig: FragnoPublicConfig;
46
+ } & TAdditionalContext);
47
+ },
48
+ services: undefined,
49
+ additionalContext: this.#definition.additionalContext,
50
+ });
51
+ }
52
+
53
+ withServices<TNewServices extends Record<string, unknown>>(
54
+ fn: (
55
+ context: {
56
+ config: TConfig;
57
+ fragnoConfig: FragnoPublicConfig;
58
+ deps: TDeps;
59
+ } & TAdditionalContext,
60
+ ) => TNewServices,
61
+ ): FragmentBuilder<TConfig, TDeps, TNewServices, TAdditionalContext> {
62
+ return new FragmentBuilder<TConfig, TDeps, TNewServices, TAdditionalContext>({
63
+ name: this.#definition.name,
64
+ dependencies: this.#definition.dependencies,
65
+ services: (config: TConfig, options: FragnoPublicConfig, deps: TDeps) => {
66
+ return fn({ config, fragnoConfig: options, deps } as {
67
+ config: TConfig;
68
+ fragnoConfig: FragnoPublicConfig;
69
+ deps: TDeps;
70
+ } & TAdditionalContext);
71
+ },
72
+ additionalContext: this.#definition.additionalContext,
73
+ });
74
+ }
75
+ }
76
+
77
+ export function defineFragment<TConfig = {}>(name: string): FragmentBuilder<TConfig, {}, {}, {}> {
78
+ return new FragmentBuilder({
79
+ name,
80
+ });
81
+ }
@@ -17,6 +17,7 @@ import {
17
17
  RequestMiddlewareOutputContext,
18
18
  type FragnoMiddlewareCallback,
19
19
  } from "./request-middleware";
20
+ import type { FragmentDefinition } from "./fragment-builder";
20
21
 
21
22
  export interface FragnoPublicConfig {
22
23
  mountRoute?: string;
@@ -64,22 +65,29 @@ type HandlersByFramework = {
64
65
  "solid-start": SolidStartHandlers;
65
66
  };
66
67
 
68
+ // Not actually a symbol, since we might be dealing with multiple instances of this code.
69
+ export const instantiatedFragmentFakeSymbol = "$fragno-instantiated-fragment" as const;
70
+
67
71
  type FullstackFrameworks = keyof HandlersByFramework;
68
72
 
69
73
  export interface FragnoInstantiatedFragment<
70
74
  TRoutes extends readonly AnyFragnoRouteConfig[] = [],
71
75
  TDeps = {},
72
76
  TServices extends Record<string, unknown> = Record<string, unknown>,
77
+ TAdditionalContext extends Record<string, unknown> = {},
73
78
  > {
79
+ [instantiatedFragmentFakeSymbol]: typeof instantiatedFragmentFakeSymbol;
80
+
74
81
  config: FragnoFragmentSharedConfig<TRoutes>;
75
82
  deps: TDeps;
76
83
  services: TServices;
84
+ additionalContext?: TAdditionalContext;
77
85
  handlersFor: <T extends FullstackFrameworks>(framework: T) => HandlersByFramework[T];
78
86
  handler: (req: Request) => Promise<Response>;
79
87
  mountRoute: string;
80
88
  withMiddleware: (
81
89
  handler: FragnoMiddlewareCallback<TRoutes, TDeps, TServices>,
82
- ) => FragnoInstantiatedFragment<TRoutes, TDeps, TServices>;
90
+ ) => FragnoInstantiatedFragment<TRoutes, TDeps, TServices, TAdditionalContext>;
83
91
  }
84
92
 
85
93
  export interface FragnoFragmentSharedConfig<
@@ -100,72 +108,38 @@ export type AnyFragnoFragmentSharedConfig = FragnoFragmentSharedConfig<
100
108
  readonly AnyFragnoRouteConfig[]
101
109
  >;
102
110
 
103
- interface FragmentDefinition<TConfig, TDeps = {}, TServices extends Record<string, unknown> = {}> {
104
- name: string;
105
- dependencies?: (config: TConfig) => TDeps;
106
- services?: (config: TConfig, deps: TDeps) => TServices;
107
- }
108
-
109
- export class FragmentBuilder<TConfig, TDeps = {}, TServices extends Record<string, unknown> = {}> {
110
- #definition: FragmentDefinition<TConfig, TDeps, TServices>;
111
-
112
- constructor(definition: FragmentDefinition<TConfig, TDeps, TServices>) {
113
- this.#definition = definition;
114
- }
115
-
116
- get definition() {
117
- return this.#definition;
118
- }
119
-
120
- withDependencies<TNewDeps>(
121
- fn: (config: TConfig) => TNewDeps,
122
- ): FragmentBuilder<TConfig, TNewDeps, TServices> {
123
- return new FragmentBuilder<TConfig, TNewDeps, TServices>({
124
- ...this.#definition,
125
- dependencies: fn,
126
- } as FragmentDefinition<TConfig, TNewDeps, TServices>);
127
- }
128
-
129
- withServices<TNewServices extends Record<string, unknown>>(
130
- fn: (config: TConfig, deps: TDeps) => TNewServices,
131
- ): FragmentBuilder<TConfig, TDeps, TNewServices> {
132
- return new FragmentBuilder<TConfig, TDeps, TNewServices>({
133
- ...this.#definition,
134
- services: fn,
135
- } as FragmentDefinition<TConfig, TDeps, TNewServices>);
136
- }
137
- }
138
-
139
- export function defineFragment<TConfig = {}>(name: string): FragmentBuilder<TConfig> {
140
- return new FragmentBuilder({
141
- name,
142
- });
143
- }
144
-
145
111
  export function createFragment<
146
- TConfig,
147
- TDeps,
148
- TServices extends Record<string, unknown>,
112
+ const TConfig,
113
+ const TDeps,
114
+ const TServices extends Record<string, unknown>,
149
115
  const TRoutesOrFactories extends readonly AnyRouteOrFactory[],
116
+ const TAdditionalContext extends Record<string, unknown>,
117
+ const TOptions extends FragnoPublicConfig,
150
118
  >(
151
- fragmentDefinition: FragmentBuilder<TConfig, TDeps, TServices>,
119
+ fragmentBuilder: {
120
+ definition: FragmentDefinition<TConfig, TDeps, TServices, TAdditionalContext>;
121
+ $requiredOptions: TOptions;
122
+ },
152
123
  config: TConfig,
153
124
  routesOrFactories: TRoutesOrFactories,
154
- fragnoConfig: FragnoPublicConfig = {},
155
- ): FragnoInstantiatedFragment<FlattenRouteFactories<TRoutesOrFactories>, TDeps, TServices> {
156
- const definition = fragmentDefinition.definition;
125
+ options: TOptions,
126
+ ): FragnoInstantiatedFragment<
127
+ FlattenRouteFactories<TRoutesOrFactories>,
128
+ TDeps,
129
+ TServices,
130
+ TAdditionalContext
131
+ > {
132
+ const definition = fragmentBuilder.definition;
157
133
 
158
- const dependencies = definition.dependencies ? definition.dependencies(config) : ({} as TDeps);
159
- const services = definition.services
160
- ? definition.services(config, dependencies)
161
- : ({} as TServices);
134
+ const dependencies = definition.dependencies?.(config, options) ?? ({} as TDeps);
135
+ const services = definition.services?.(config, options, dependencies) ?? ({} as TServices);
162
136
 
163
137
  const context = { config, deps: dependencies, services };
164
138
  const routes = resolveRouteFactories(context, routesOrFactories);
165
139
 
166
140
  const mountRoute = getMountRoute({
167
141
  name: definition.name,
168
- mountRoute: fragnoConfig.mountRoute,
142
+ mountRoute: options.mountRoute,
169
143
  });
170
144
 
171
145
  const router =
@@ -191,8 +165,10 @@ export function createFragment<
191
165
  const fragment: FragnoInstantiatedFragment<
192
166
  FlattenRouteFactories<TRoutesOrFactories>,
193
167
  TDeps,
194
- TServices
168
+ TServices,
169
+ TAdditionalContext & TOptions
195
170
  > = {
171
+ [instantiatedFragmentFakeSymbol]: instantiatedFragmentFakeSymbol,
196
172
  mountRoute,
197
173
  config: {
198
174
  name: definition.name,
@@ -200,6 +176,10 @@ export function createFragment<
200
176
  },
201
177
  services,
202
178
  deps: dependencies,
179
+ additionalContext: {
180
+ ...definition.additionalContext,
181
+ ...options,
182
+ } as TAdditionalContext & TOptions,
203
183
  withMiddleware: (handler) => {
204
184
  if (middlewareHandler) {
205
185
  throw new Error("Middleware already set");
@@ -1,5 +1,6 @@
1
1
  import { test, expect, describe, expectTypeOf } from "vitest";
2
- import { defineFragment, createFragment, type FragmentBuilder } from "./fragment";
2
+ import { defineFragment, type FragmentBuilder } from "./fragment-builder";
3
+ import { createFragment } from "./fragment-instantiation";
3
4
  import { defineRoute, defineRoutes, type RouteFactory, resolveRouteFactories } from "./route";
4
5
  import { z } from "zod";
5
6
  import type { InferOr } from "../util/types-util";
@@ -25,6 +26,7 @@ describe("new-fragment API", () => {
25
26
  debug: boolean;
26
27
  },
27
28
  Empty,
29
+ Empty,
28
30
  Empty
29
31
  >
30
32
  >();
@@ -35,8 +37,8 @@ describe("new-fragment API", () => {
35
37
  apiKey: "test-key",
36
38
  };
37
39
 
38
- const _fragment = defineFragment<typeof _config>("test").withDependencies((cfg) => {
39
- expectTypeOf(cfg).toEqualTypeOf<typeof _config>();
40
+ const _fragment = defineFragment<typeof _config>("test").withDependencies(({ config }) => {
41
+ expectTypeOf(config).toEqualTypeOf<typeof _config>();
40
42
  return {
41
43
  httpClient: { fetch: () => Promise.resolve(new Response()) },
42
44
  logger: { log: (msg: string) => console.log(msg) },
@@ -50,6 +52,7 @@ describe("new-fragment API", () => {
50
52
  httpClient: { fetch: () => Promise<Response> };
51
53
  logger: { log: (msg: string) => void };
52
54
  },
55
+ Empty,
53
56
  Empty
54
57
  >
55
58
  >();
@@ -62,16 +65,16 @@ describe("new-fragment API", () => {
62
65
  };
63
66
 
64
67
  const _fragment = defineFragment<typeof _config>("test")
65
- .withDependencies((cfg) => {
66
- expectTypeOf(cfg).toEqualTypeOf<{
68
+ .withDependencies(({ config }) => {
69
+ expectTypeOf(config).toEqualTypeOf<{
67
70
  apiKey: string;
68
71
  baseUrl: string;
69
72
  }>();
70
73
 
71
- return { httpClient: { baseUrl: cfg.baseUrl } };
74
+ return { httpClient: { baseUrl: config.baseUrl } };
72
75
  })
73
- .withServices((cfg, deps) => {
74
- expectTypeOf(cfg).toEqualTypeOf<typeof _config>();
76
+ .withServices(({ config, deps }) => {
77
+ expectTypeOf(config).toEqualTypeOf<typeof _config>();
75
78
  expectTypeOf(deps).toEqualTypeOf<{ httpClient: { baseUrl: string } }>();
76
79
 
77
80
  return {
@@ -97,7 +100,8 @@ describe("new-fragment API", () => {
97
100
  get: (key: string) => string;
98
101
  set: (key: string, value: string) => void;
99
102
  };
100
- }
103
+ },
104
+ Empty
101
105
  >
102
106
  >();
103
107
  });
@@ -155,13 +159,15 @@ describe("new-fragment API", () => {
155
159
  const _config = { test: true };
156
160
 
157
161
  const lib1 = defineFragment<typeof _config>("test");
158
- expectTypeOf(lib1).toEqualTypeOf<FragmentBuilder<typeof _config, Empty, Empty>>();
162
+ expectTypeOf(lib1).toEqualTypeOf<FragmentBuilder<typeof _config, Empty, Empty, Empty>>();
159
163
 
160
164
  const lib2 = lib1.withDependencies(() => ({ dep1: "value1" }));
161
- expectTypeOf(lib2).toEqualTypeOf<FragmentBuilder<typeof _config, { dep1: string }, Empty>>();
165
+ expectTypeOf(lib2).toEqualTypeOf<
166
+ FragmentBuilder<typeof _config, { dep1: string }, Empty, Empty>
167
+ >();
162
168
  const lib3 = lib2.withServices(() => ({ service1: "value1" }));
163
169
  expectTypeOf(lib3).toEqualTypeOf<
164
- FragmentBuilder<typeof _config, { dep1: string }, { service1: string }>
170
+ FragmentBuilder<typeof _config, { dep1: string }, { service1: string }, Empty>
165
171
  >();
166
172
 
167
173
  expect(lib1).not.toBe(lib2);
@@ -173,10 +179,10 @@ describe("new-fragment API", () => {
173
179
  const _config = { apiKey: "test" };
174
180
 
175
181
  const fragment = defineFragment<typeof _config>("my-lib")
176
- .withDependencies((_cfg) => ({
177
- client: `Client for ${_cfg.apiKey}`,
182
+ .withDependencies(({ config }) => ({
183
+ client: `Client for ${config.apiKey}`,
178
184
  }))
179
- .withServices((_cfg, deps) => ({
185
+ .withServices(({ deps }) => ({
180
186
  service: `Service using ${deps.client}`,
181
187
  }));
182
188
 
@@ -211,7 +217,7 @@ describe("new-fragment API", () => {
211
217
  ]);
212
218
 
213
219
  const fragmentDef = defineFragment("greeting")
214
- .withDependencies((_config) => ({
220
+ .withDependencies(() => ({
215
221
  formatter: (s: string) => s.toUpperCase(),
216
222
  }))
217
223
  .withServices(() => ({
@@ -506,4 +512,26 @@ describe("new-fragment API", () => {
506
512
  expectTypeOf(routes[1].path).toEqualTypeOf<"/status">();
507
513
  });
508
514
  });
515
+
516
+ describe("Database Integration", () => {
517
+ test("createFragment without database works without adapter", () => {
518
+ const fragmentDef = defineFragment("test").withDependencies(() => ({
519
+ service: { data: "test" },
520
+ }));
521
+
522
+ const fragment = createFragment(fragmentDef, {}, [], {});
523
+
524
+ expect(fragment.deps.service.data).toBe("test");
525
+ });
526
+
527
+ test("createFragment accepts options parameter", () => {
528
+ const fragmentDef = defineFragment("test").withDependencies(() => ({
529
+ service: { data: "test" },
530
+ }));
531
+
532
+ const fragment = createFragment(fragmentDef, {}, [], { mountRoute: "/custom" });
533
+
534
+ expect(fragment.mountRoute).toBe("/custom");
535
+ });
536
+ });
509
537
  });
@@ -1,5 +1,6 @@
1
1
  import { test, expect, describe, expectTypeOf } from "vitest";
2
- import { defineFragment, createFragment } from "./fragment";
2
+ import { defineFragment } from "./fragment-builder";
3
+ import { createFragment } from "./fragment-instantiation";
3
4
  import { defineRoute } from "./route";
4
5
  import { z } from "zod";
5
6
  import { FragnoApiValidationError } from "./error";
@@ -273,7 +274,7 @@ describe("Request Middleware", () => {
273
274
  }),
274
275
  ] as const;
275
276
 
276
- const instance = createFragment(fragment, config, routes);
277
+ const instance = createFragment(fragment, config, routes, {});
277
278
 
278
279
  const withMiddleware = instance.withMiddleware(async () => {
279
280
  return undefined;
@@ -2,8 +2,8 @@ import { test, expect, expectTypeOf, describe } from "vitest";
2
2
  import { z } from "zod";
3
3
  import { createClientBuilder } from "./client";
4
4
  import { addRoute } from "../api/api";
5
- import { defineFragment } from "../api/fragment";
6
- import type { FragnoPublicClientConfig } from "../api/fragment";
5
+ import { defineFragment } from "../api/fragment-builder";
6
+ import type { FragnoPublicClientConfig } from "../api/fragment-instantiation";
7
7
 
8
8
  // Test route configurations
9
9
  const testFragment = defineFragment("test-fragment");
@@ -10,7 +10,7 @@ import { describe, expect, test } from "vitest";
10
10
  import { type FragnoPublicClientConfig } from "../mod";
11
11
  import { createClientBuilder } from "./client";
12
12
  import { defineRoute } from "../api/route";
13
- import { defineFragment } from "../api/fragment";
13
+ import { defineFragment } from "../api/fragment-builder";
14
14
  import { z } from "zod";
15
15
  import { createAsyncIteratorFromCallback, waitForAsyncIterator } from "../util/async";
16
16
 
@@ -3,7 +3,7 @@ import { type FragnoPublicClientConfig } from "../mod";
3
3
  import { createClientBuilder } from "./client";
4
4
  import { render } from "@testing-library/svelte";
5
5
  import { defineRoute } from "../api/route";
6
- import { defineFragment } from "../api/fragment";
6
+ import { defineFragment } from "../api/fragment-builder";
7
7
  import { z } from "zod";
8
8
  import { readableToAtom, useFragno } from "./client.svelte";
9
9
  import { writable, readable, get, derived } from "svelte/store";
@@ -6,7 +6,7 @@ import { useFragno } from "./vanilla";
6
6
  import { createAsyncIteratorFromCallback, waitForAsyncIterator } from "../util/async";
7
7
  import type { FragnoPublicClientConfig } from "../mod";
8
8
  import { atom, computed, effect } from "nanostores";
9
- import { defineFragment } from "../api/fragment";
9
+ import { defineFragment } from "../api/fragment-builder";
10
10
  import { RequestOutputContext } from "../api/request-output-context";
11
11
  import { FragnoClientUnknownApiError } from "./client-error";
12
12
 
@@ -12,7 +12,10 @@ import {
12
12
  import { getMountRoute } from "../api/internal/route";
13
13
  import { RequestInputContext } from "../api/request-input-context";
14
14
  import { RequestOutputContext } from "../api/request-output-context";
15
- import type { FragnoFragmentSharedConfig, FragnoPublicClientConfig } from "../api/fragment";
15
+ import type {
16
+ FragnoFragmentSharedConfig,
17
+ FragnoPublicClientConfig,
18
+ } from "../api/fragment-instantiation";
16
19
  import { FragnoClientApiError, FragnoClientError, FragnoClientFetchError } from "./client-error";
17
20
  import type { InferOr } from "../util/types-util";
18
21
  import { parseContentType } from "../util/content-type";
@@ -22,7 +25,7 @@ import {
22
25
  } from "./internal/ndjson-streaming";
23
26
  import { addStore, getInitialData, SSR_ENABLED } from "../util/ssr";
24
27
  import { unwrapObject } from "../util/nanostores";
25
- import type { FragmentBuilder } from "../api/fragment";
28
+ import type { FragmentBuilder } from "../api/fragment-builder";
26
29
  import {
27
30
  type AnyRouteOrFactory,
28
31
  type FlattenRouteFactories,
@@ -5,7 +5,7 @@ import { z } from "zod";
5
5
  import { createClientBuilder } from "./client";
6
6
  import { useFragno, useStore, type FragnoReactStore } from "./react";
7
7
  import { defineRoute } from "../api/route";
8
- import { defineFragment } from "../api/fragment";
8
+ import { defineFragment } from "../api/fragment-builder";
9
9
  import type { FragnoPublicClientConfig } from "../mod";
10
10
  import { FragnoClientFetchNetworkError, type FragnoClientError } from "./client-error";
11
11
  import { RequestOutputContext } from "../api/request-output-context";
@@ -4,7 +4,7 @@ import { z } from "zod";
4
4
  import { createClientBuilder } from "./client";
5
5
  import { useFragno, accessorToAtom, isAccessor } from "./solid";
6
6
  import { defineRoute } from "../api/route";
7
- import { defineFragment } from "../api/fragment";
7
+ import { defineFragment } from "../api/fragment-builder";
8
8
  import type { FragnoPublicClientConfig } from "../mod";
9
9
  import { FragnoClientUnknownApiError } from "./client-error";
10
10
  import { createSignal, createRoot } from "solid-js";
@@ -4,7 +4,7 @@ import { z } from "zod";
4
4
  import { createClientBuilder } from "./client";
5
5
  import { useFragno } from "./vanilla";
6
6
  import { defineRoute } from "../api/route";
7
- import { defineFragment } from "../api/fragment";
7
+ import { defineFragment } from "../api/fragment-builder";
8
8
  import type { FragnoPublicClientConfig } from "../mod";
9
9
  import { FragnoClientFetchNetworkError } from "./client-error";
10
10
  import { waitForAsyncIterator } from "../util/async";
@@ -2,7 +2,7 @@ import { test, expect, describe, vi, beforeEach, afterEach, assert } from "vites
2
2
  import { type FragnoPublicClientConfig } from "../mod";
3
3
  import { createClientBuilder } from "./client";
4
4
  import { defineRoute } from "../api/route";
5
- import { defineFragment } from "../api/fragment";
5
+ import { defineFragment } from "../api/fragment-builder";
6
6
  import { z } from "zod";
7
7
  import { refToAtom, useFragno } from "./vue";
8
8
  import { waitFor } from "@testing-library/vue";
package/src/mod.ts CHANGED
@@ -1,12 +1,12 @@
1
+ export { defineFragment, FragmentBuilder, type FragmentDefinition } from "./api/fragment-builder";
2
+
1
3
  export {
2
- defineFragment,
3
4
  createFragment,
4
- FragmentBuilder,
5
5
  type FragnoFragmentSharedConfig,
6
6
  type FragnoPublicConfig,
7
7
  type FragnoPublicClientConfig,
8
8
  type FragnoInstantiatedFragment,
9
- } from "./api/fragment";
9
+ } from "./api/fragment-instantiation";
10
10
 
11
11
  export { type FragnoRouteConfig } from "./api/api";
12
12
 
package/tsdown.config.ts CHANGED
@@ -4,6 +4,8 @@ export default defineConfig({
4
4
  entry: [
5
5
  "./src/mod.ts",
6
6
  "./src/api/api.ts",
7
+ "./src/api/fragment-builder.ts",
8
+ "./src/api/fragment-instantiation.ts",
7
9
  "./src/client/client.ts",
8
10
  "./src/client/vanilla.ts",
9
11
  "./src/client/client.svelte.ts",