@fragno-dev/core 0.1.7 → 0.1.9

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 (183) hide show
  1. package/.turbo/turbo-build.log +131 -64
  2. package/CHANGELOG.md +19 -0
  3. package/dist/api/api.d.ts +38 -2
  4. package/dist/api/api.d.ts.map +1 -0
  5. package/dist/api/api.js +9 -2
  6. package/dist/api/api.js.map +1 -0
  7. package/dist/api/bind-services.d.ts +6 -0
  8. package/dist/api/bind-services.d.ts.map +1 -0
  9. package/dist/api/bind-services.js +20 -0
  10. package/dist/api/bind-services.js.map +1 -0
  11. package/dist/api/error.d.ts +26 -0
  12. package/dist/api/error.d.ts.map +1 -0
  13. package/dist/{api-DngJDcmO.js → api/error.js} +2 -8
  14. package/dist/api/error.js.map +1 -0
  15. package/dist/api/fragment-definition-builder.d.ts +313 -0
  16. package/dist/api/fragment-definition-builder.d.ts.map +1 -0
  17. package/dist/api/fragment-definition-builder.js +326 -0
  18. package/dist/api/fragment-definition-builder.js.map +1 -0
  19. package/dist/api/fragment-instantiator.d.ts +216 -0
  20. package/dist/api/fragment-instantiator.d.ts.map +1 -0
  21. package/dist/api/fragment-instantiator.js +487 -0
  22. package/dist/api/fragment-instantiator.js.map +1 -0
  23. package/dist/api/fragno-response.d.ts +30 -0
  24. package/dist/api/fragno-response.d.ts.map +1 -0
  25. package/dist/api/fragno-response.js +73 -0
  26. package/dist/api/fragno-response.js.map +1 -0
  27. package/dist/api/internal/path.d.ts +50 -0
  28. package/dist/api/internal/path.d.ts.map +1 -0
  29. package/dist/api/internal/path.js +76 -0
  30. package/dist/api/internal/path.js.map +1 -0
  31. package/dist/api/internal/response-stream.d.ts +43 -0
  32. package/dist/api/internal/response-stream.d.ts.map +1 -0
  33. package/dist/api/internal/response-stream.js +81 -0
  34. package/dist/api/internal/response-stream.js.map +1 -0
  35. package/dist/api/internal/route.js +10 -0
  36. package/dist/api/internal/route.js.map +1 -0
  37. package/dist/api/mutable-request-state.d.ts +82 -0
  38. package/dist/api/mutable-request-state.d.ts.map +1 -0
  39. package/dist/api/mutable-request-state.js +97 -0
  40. package/dist/api/mutable-request-state.js.map +1 -0
  41. package/dist/api/request-context-storage.d.ts +42 -0
  42. package/dist/api/request-context-storage.d.ts.map +1 -0
  43. package/dist/api/request-context-storage.js +43 -0
  44. package/dist/api/request-context-storage.js.map +1 -0
  45. package/dist/api/request-input-context.d.ts +89 -0
  46. package/dist/api/request-input-context.d.ts.map +1 -0
  47. package/dist/api/request-input-context.js +118 -0
  48. package/dist/api/request-input-context.js.map +1 -0
  49. package/dist/api/request-middleware.d.ts +50 -0
  50. package/dist/api/request-middleware.d.ts.map +1 -0
  51. package/dist/api/request-middleware.js +83 -0
  52. package/dist/api/request-middleware.js.map +1 -0
  53. package/dist/api/request-output-context.d.ts +41 -0
  54. package/dist/api/request-output-context.d.ts.map +1 -0
  55. package/dist/api/request-output-context.js +119 -0
  56. package/dist/api/request-output-context.js.map +1 -0
  57. package/dist/api/route-handler-input-options.d.ts +21 -0
  58. package/dist/api/route-handler-input-options.d.ts.map +1 -0
  59. package/dist/api/route.d.ts +54 -3
  60. package/dist/api/route.d.ts.map +1 -0
  61. package/dist/api/route.js +29 -2
  62. package/dist/api/route.js.map +1 -0
  63. package/dist/api/shared-types.d.ts +47 -0
  64. package/dist/api/shared-types.d.ts.map +1 -0
  65. package/dist/api/shared-types.js +1 -0
  66. package/dist/client/client-error.d.ts +60 -0
  67. package/dist/client/client-error.d.ts.map +1 -0
  68. package/dist/client/client-error.js +92 -0
  69. package/dist/client/client-error.js.map +1 -0
  70. package/dist/client/client.d.ts +210 -4
  71. package/dist/client/client.d.ts.map +1 -0
  72. package/dist/client/client.js +397 -6
  73. package/dist/client/client.js.map +1 -0
  74. package/dist/client/client.svelte.d.ts +5 -3
  75. package/dist/client/client.svelte.d.ts.map +1 -1
  76. package/dist/client/client.svelte.js +1 -5
  77. package/dist/client/client.svelte.js.map +1 -1
  78. package/dist/client/internal/fetcher-merge.js +36 -0
  79. package/dist/client/internal/fetcher-merge.js.map +1 -0
  80. package/dist/client/internal/ndjson-streaming.js +139 -0
  81. package/dist/client/internal/ndjson-streaming.js.map +1 -0
  82. package/dist/client/react.d.ts +5 -3
  83. package/dist/client/react.d.ts.map +1 -1
  84. package/dist/client/react.js +3 -5
  85. package/dist/client/react.js.map +1 -1
  86. package/dist/client/solid.d.ts +5 -3
  87. package/dist/client/solid.d.ts.map +1 -1
  88. package/dist/client/solid.js +2 -5
  89. package/dist/client/solid.js.map +1 -1
  90. package/dist/client/vanilla.d.ts +5 -3
  91. package/dist/client/vanilla.d.ts.map +1 -1
  92. package/dist/client/vanilla.js +2 -43
  93. package/dist/client/vanilla.js.map +1 -1
  94. package/dist/client/vue.d.ts +5 -3
  95. package/dist/client/vue.d.ts.map +1 -1
  96. package/dist/client/vue.js +1 -5
  97. package/dist/client/vue.js.map +1 -1
  98. package/dist/http/http-status.d.ts +26 -0
  99. package/dist/http/http-status.d.ts.map +1 -0
  100. package/dist/integrations/react-ssr.js +1 -1
  101. package/dist/internal/symbols.d.ts +9 -0
  102. package/dist/internal/symbols.d.ts.map +1 -0
  103. package/dist/internal/symbols.js +10 -0
  104. package/dist/internal/symbols.js.map +1 -0
  105. package/dist/mod-client.d.ts +36 -0
  106. package/dist/mod-client.d.ts.map +1 -0
  107. package/dist/mod-client.js +21 -0
  108. package/dist/mod-client.js.map +1 -0
  109. package/dist/mod.d.ts +7 -4
  110. package/dist/mod.js +4 -6
  111. package/dist/request/request.d.ts +4 -0
  112. package/dist/request/request.js +5 -0
  113. package/dist/test/test.d.ts +62 -35
  114. package/dist/test/test.d.ts.map +1 -1
  115. package/dist/test/test.js +75 -40
  116. package/dist/test/test.js.map +1 -1
  117. package/dist/util/async.js +40 -0
  118. package/dist/util/async.js.map +1 -0
  119. package/dist/util/content-type.js +49 -0
  120. package/dist/util/content-type.js.map +1 -0
  121. package/dist/util/nanostores.js +31 -0
  122. package/dist/util/nanostores.js.map +1 -0
  123. package/dist/{ssr-BByDVfFD.js → util/ssr.js} +2 -2
  124. package/dist/util/ssr.js.map +1 -0
  125. package/dist/util/types-util.d.ts +8 -0
  126. package/dist/util/types-util.d.ts.map +1 -0
  127. package/package.json +19 -12
  128. package/src/api/api.ts +41 -6
  129. package/src/api/bind-services.ts +42 -0
  130. package/src/api/fragment-definition-builder.extend.test.ts +810 -0
  131. package/src/api/fragment-definition-builder.test.ts +499 -0
  132. package/src/api/fragment-definition-builder.ts +1088 -0
  133. package/src/api/fragment-instantiator.test.ts +1488 -0
  134. package/src/api/fragment-instantiator.ts +1053 -0
  135. package/src/api/fragment-services.test.ts +727 -0
  136. package/src/api/request-context-storage.ts +64 -0
  137. package/src/api/request-middleware.test.ts +301 -225
  138. package/src/api/route.test.ts +87 -1
  139. package/src/api/route.ts +345 -24
  140. package/src/api/shared-types.ts +43 -0
  141. package/src/client/client-builder.test.ts +23 -23
  142. package/src/client/client.ssr.test.ts +3 -3
  143. package/src/client/client.svelte.test.ts +15 -15
  144. package/src/client/client.test.ts +22 -22
  145. package/src/client/client.ts +72 -12
  146. package/src/client/internal/fetcher-merge.ts +1 -1
  147. package/src/client/react.test.ts +2 -2
  148. package/src/client/solid.test.ts +2 -2
  149. package/src/client/vanilla.test.ts +2 -2
  150. package/src/client/vue.test.ts +2 -2
  151. package/src/internal/symbols.ts +5 -0
  152. package/src/mod-client.ts +59 -0
  153. package/src/mod.ts +26 -9
  154. package/src/request/request.ts +8 -0
  155. package/src/test/test.test.ts +200 -381
  156. package/src/test/test.ts +190 -117
  157. package/tsdown.config.ts +8 -5
  158. package/dist/api/fragment-builder.d.ts +0 -4
  159. package/dist/api/fragment-builder.js +0 -3
  160. package/dist/api/fragment-instantiation.d.ts +0 -4
  161. package/dist/api/fragment-instantiation.js +0 -6
  162. package/dist/api-BWN97TOr.d.ts +0 -377
  163. package/dist/api-BWN97TOr.d.ts.map +0 -1
  164. package/dist/api-DngJDcmO.js.map +0 -1
  165. package/dist/client-C5LsYHEI.js +0 -782
  166. package/dist/client-C5LsYHEI.js.map +0 -1
  167. package/dist/fragment-builder-DOnCVBqc.js +0 -47
  168. package/dist/fragment-builder-DOnCVBqc.js.map +0 -1
  169. package/dist/fragment-builder-MGr68GNb.d.ts +0 -409
  170. package/dist/fragment-builder-MGr68GNb.d.ts.map +0 -1
  171. package/dist/fragment-instantiation-C4wvwl6V.js +0 -446
  172. package/dist/fragment-instantiation-C4wvwl6V.js.map +0 -1
  173. package/dist/request-output-context-CdIjwmEN.js +0 -320
  174. package/dist/request-output-context-CdIjwmEN.js.map +0 -1
  175. package/dist/route-Bl9Zr1Yv.d.ts +0 -26
  176. package/dist/route-Bl9Zr1Yv.d.ts.map +0 -1
  177. package/dist/route-C5Uryylh.js +0 -21
  178. package/dist/route-C5Uryylh.js.map +0 -1
  179. package/dist/ssr-BByDVfFD.js.map +0 -1
  180. package/src/api/fragment-builder.ts +0 -80
  181. package/src/api/fragment-instantiation.test.ts +0 -460
  182. package/src/api/fragment-instantiation.ts +0 -499
  183. package/src/api/fragment.test.ts +0 -537
@@ -1,7 +1,12 @@
1
1
  import { nanoquery, type FetcherStore, type MutatorStore } from "@nanostores/query";
2
2
  import type { StandardSchemaV1 } from "@standard-schema/spec";
3
3
  import { computed, task, type ReadableAtom, type Store } from "nanostores";
4
- import type { FragnoRouteConfig, HTTPMethod, NonGetHTTPMethod } from "../api/api";
4
+ import type {
5
+ FragnoRouteConfig,
6
+ HTTPMethod,
7
+ NonGetHTTPMethod,
8
+ RequestThisContext,
9
+ } from "../api/api";
5
10
  import {
6
11
  buildPath,
7
12
  extractPathParams,
@@ -16,7 +21,8 @@ import type {
16
21
  FetcherConfig,
17
22
  FragnoFragmentSharedConfig,
18
23
  FragnoPublicClientConfig,
19
- } from "../api/fragment-instantiation";
24
+ FragnoPublicConfig,
25
+ } from "../api/shared-types";
20
26
  import { FragnoClientApiError, FragnoClientError, FragnoClientFetchError } from "./client-error";
21
27
  import type { InferOr } from "../util/types-util";
22
28
  import { parseContentType } from "../util/content-type";
@@ -26,7 +32,7 @@ import {
26
32
  } from "./internal/ndjson-streaming";
27
33
  import { addStore, getInitialData, SSR_ENABLED } from "../util/ssr";
28
34
  import { unwrapObject } from "../util/nanostores";
29
- import type { FragmentDefinition } from "../api/fragment-builder";
35
+ import type { FragmentDefinition } from "../api/fragment-definition-builder";
30
36
  import {
31
37
  type AnyRouteOrFactory,
32
38
  type FlattenRouteFactories,
@@ -43,6 +49,7 @@ const STORE_SYMBOL = Symbol("fragno-store");
43
49
 
44
50
  /**
45
51
  * Extract only GET routes from a library config's routes array
52
+ * @internal
46
53
  */
47
54
  export type ExtractGetRoutes<
48
55
  T extends readonly FragnoRouteConfig<
@@ -70,6 +77,7 @@ export type ExtractGetRoutes<
70
77
 
71
78
  /**
72
79
  * Extract the path from a route configuration for a given method
80
+ * @internal
73
81
  */
74
82
  export type ExtractRoutePath<
75
83
  T extends readonly FragnoRouteConfig<
@@ -96,6 +104,9 @@ export type ExtractRoutePath<
96
104
  : never;
97
105
  }[number];
98
106
 
107
+ /**
108
+ * @internal
109
+ */
99
110
  export type ExtractGetRoutePaths<
100
111
  T extends readonly FragnoRouteConfig<
101
112
  HTTPMethod,
@@ -107,6 +118,9 @@ export type ExtractGetRoutePaths<
107
118
  >[],
108
119
  > = ExtractRoutePath<T, "GET">;
109
120
 
121
+ /**
122
+ * @internal
123
+ */
110
124
  export type ExtractNonGetRoutePaths<
111
125
  T extends readonly FragnoRouteConfig<
112
126
  HTTPMethod,
@@ -124,6 +138,7 @@ export type ExtractNonGetRoutePaths<
124
138
  *
125
139
  * Defaults to extracting all methods for the matching path, producing a union
126
140
  * if multiple methods exist for the same path.
141
+ * @internal
127
142
  */
128
143
  export type ExtractRouteByPath<
129
144
  TRoutes extends readonly FragnoRouteConfig<
@@ -153,6 +168,7 @@ export type ExtractRouteByPath<
153
168
 
154
169
  /**
155
170
  * Extract the output schema type for a specific route path from a routes array
171
+ * @internal
156
172
  */
157
173
  export type ExtractOutputSchemaForPath<
158
174
  TRoutes extends readonly FragnoRouteConfig<
@@ -177,6 +193,7 @@ export type ExtractOutputSchemaForPath<
177
193
 
178
194
  /**
179
195
  * Check if a path exists as a GET route in the routes array
196
+ * @internal
180
197
  */
181
198
  export type IsValidGetRoutePath<
182
199
  TRoutes extends readonly FragnoRouteConfig<
@@ -192,6 +209,7 @@ export type IsValidGetRoutePath<
192
209
 
193
210
  /**
194
211
  * Utility type to ensure only valid GET route paths can be used
212
+ * @internal
195
213
  */
196
214
  export type ValidateGetRoutePath<
197
215
  TRoutes extends readonly FragnoRouteConfig<
@@ -210,6 +228,7 @@ export type ValidateGetRoutePath<
210
228
 
211
229
  /**
212
230
  * Helper type to check if a routes array has any GET routes
231
+ * @internal
213
232
  */
214
233
  export type HasGetRoutes<
215
234
  T extends readonly FragnoRouteConfig<
@@ -222,6 +241,9 @@ export type HasGetRoutes<
222
241
  >[],
223
242
  > = ExtractGetRoutePaths<T> extends never ? false : true;
224
243
 
244
+ /**
245
+ * @internal
246
+ */
225
247
  export type ObjectContainingStoreField<T extends object> = T extends Store
226
248
  ? T
227
249
  : {
@@ -230,6 +252,9 @@ export type ObjectContainingStoreField<T extends object> = T extends Store
230
252
  ? never
231
253
  : T;
232
254
 
255
+ /**
256
+ * @internal
257
+ */
233
258
  export type FragnoStoreData<T extends object> = {
234
259
  obj: T;
235
260
  [STORE_SYMBOL]: true;
@@ -305,6 +330,9 @@ export type FragnoClientMutatorData<
305
330
  readonly _outputSchema?: TOutputSchema;
306
331
  };
307
332
 
333
+ /**
334
+ * @internal
335
+ */
308
336
  export function buildUrl<TPath extends string>(
309
337
  config: {
310
338
  baseUrl?: string;
@@ -342,6 +370,7 @@ export function buildUrl<TPath extends string>(
342
370
  * @param path
343
371
  * @param params
344
372
  * @returns
373
+ * @internal
345
374
  */
346
375
  export function getCacheKey<TMethod extends HTTPMethod, TPath extends string>(
347
376
  method: TMethod,
@@ -404,6 +433,9 @@ function isStreamingResponse(response: Response): false | "ndjson" | "octet-stre
404
433
  }
405
434
 
406
435
  // Type guard to check if a hook is a GET hook
436
+ /**
437
+ * @internal
438
+ */
407
439
  export function isGetHook<
408
440
  TPath extends string,
409
441
  TOutputSchema extends StandardSchemaV1,
@@ -421,6 +453,9 @@ export function isGetHook<
421
453
  }
422
454
 
423
455
  // Type guard to check if a hook is a mutator
456
+ /**
457
+ * @internal
458
+ */
424
459
  export function isMutatorHook<
425
460
  TMethod extends NonGetHTTPMethod,
426
461
  TPath extends string,
@@ -446,6 +481,9 @@ export function isMutatorHook<
446
481
  );
447
482
  }
448
483
 
484
+ /**
485
+ * @internal
486
+ */
449
487
  export function isStore<TStore extends Store>(obj: unknown): obj is FragnoStoreData<TStore> {
450
488
  return (
451
489
  typeof obj === "object" && obj !== null && STORE_SYMBOL in obj && obj[STORE_SYMBOL] === true
@@ -482,6 +520,9 @@ type OnInvalidateFn<TPath extends string> = (
482
520
  },
483
521
  ) => void;
484
522
 
523
+ /**
524
+ * @internal
525
+ */
485
526
  export type CacheLine = {
486
527
  data: unknown;
487
528
  error: unknown;
@@ -1073,16 +1114,35 @@ export class ClientBuilder<
1073
1114
  }
1074
1115
  }
1075
1116
 
1117
+ /**
1118
+ * Create a client builder for fragments using the new fragment definition API.
1119
+ * This is the same as createClientBuilder but works with FragmentDefinition.
1120
+ */
1076
1121
  export function createClientBuilder<
1077
1122
  TConfig,
1123
+ TOptions extends FragnoPublicConfig,
1078
1124
  TDeps,
1079
- TServices extends Record<string, unknown>,
1125
+ TBaseServices,
1126
+ TServices,
1127
+ TServiceDependencies,
1128
+ TPrivateServices,
1129
+ TServiceThisContext extends RequestThisContext,
1130
+ THandlerThisContext extends RequestThisContext,
1131
+ TRequestStorage,
1080
1132
  const TRoutesOrFactories extends readonly AnyRouteOrFactory[],
1081
- const TAdditionalContext extends Record<string, unknown>,
1082
1133
  >(
1083
- fragmentBuilder: {
1084
- definition: FragmentDefinition<TConfig, TDeps, TServices, TAdditionalContext>;
1085
- },
1134
+ definition: FragmentDefinition<
1135
+ TConfig,
1136
+ TOptions,
1137
+ TDeps,
1138
+ TBaseServices,
1139
+ TServices,
1140
+ TServiceDependencies,
1141
+ TPrivateServices,
1142
+ TServiceThisContext,
1143
+ THandlerThisContext,
1144
+ TRequestStorage
1145
+ >,
1086
1146
  publicConfig: FragnoPublicClientConfig,
1087
1147
  routesOrFactories: TRoutesOrFactories,
1088
1148
  authorFetcherConfig?: FetcherConfig,
@@ -1090,14 +1150,13 @@ export function createClientBuilder<
1090
1150
  FlattenRouteFactories<TRoutesOrFactories>,
1091
1151
  FragnoFragmentSharedConfig<FlattenRouteFactories<TRoutesOrFactories>>
1092
1152
  > {
1093
- const definition = fragmentBuilder.definition;
1094
-
1095
1153
  // For client-side, we resolve route factories with dummy context
1096
1154
  // This will be removed by the bundle plugin anyway
1097
1155
  const dummyContext = {
1098
1156
  config: {} as TConfig,
1099
1157
  deps: {} as TDeps,
1100
- services: {} as TServices,
1158
+ services: {} as TBaseServices & TServices,
1159
+ serviceDeps: {},
1101
1160
  };
1102
1161
 
1103
1162
  const routes = resolveRouteFactories(dummyContext, routesOrFactories);
@@ -1119,4 +1178,5 @@ export function createClientBuilder<
1119
1178
  }
1120
1179
 
1121
1180
  export * from "./client-error";
1122
- export type { FetcherConfig };
1181
+ export type { FetcherConfig, FragnoPublicClientConfig } from "../api/shared-types";
1182
+ export type { FragnoFragmentSharedConfig } from "../api/fragment-instantiator";
@@ -1,4 +1,4 @@
1
- import type { FetcherConfig } from "../../api/fragment-instantiation";
1
+ import type { FetcherConfig } from "../../api/shared-types";
2
2
 
3
3
  /**
4
4
  * Merge two fetcher configurations, with user config taking precedence.
@@ -5,8 +5,8 @@ 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-builder";
9
- import type { FragnoPublicClientConfig } from "../mod";
8
+ import { defineFragment } from "../api/fragment-definition-builder";
9
+ import type { FragnoPublicClientConfig } from "./client";
10
10
  import { FragnoClientFetchNetworkError, type FragnoClientError } from "./client-error";
11
11
  import { RequestOutputContext } from "../api/request-output-context";
12
12
  import type { FetcherStore } from "@nanostores/query";
@@ -4,8 +4,8 @@ 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-builder";
8
- import type { FragnoPublicClientConfig } from "../mod";
7
+ import { defineFragment } from "../api/fragment-definition-builder";
8
+ import type { FragnoPublicClientConfig } from "./client";
9
9
  import { FragnoClientUnknownApiError } from "./client-error";
10
10
  import { createSignal, createRoot } from "solid-js";
11
11
 
@@ -4,8 +4,8 @@ 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-builder";
8
- import type { FragnoPublicClientConfig } from "../mod";
7
+ import { defineFragment } from "../api/fragment-definition-builder";
8
+ import type { FragnoPublicClientConfig } from "./client";
9
9
  import { FragnoClientFetchNetworkError } from "./client-error";
10
10
  import { waitForAsyncIterator } from "../util/async";
11
11
 
@@ -1,8 +1,8 @@
1
1
  import { test, expect, describe, vi, beforeEach, afterEach, assert } from "vitest";
2
- import { type FragnoPublicClientConfig } from "../mod";
2
+ import { type FragnoPublicClientConfig } from "./client";
3
3
  import { createClientBuilder } from "./client";
4
4
  import { defineRoute } from "../api/route";
5
- import { defineFragment } from "../api/fragment-builder";
5
+ import { defineFragment } from "../api/fragment-definition-builder";
6
6
  import { z } from "zod";
7
7
  import { refToAtom, useFragno } from "./vue";
8
8
  import { waitFor } from "@testing-library/vue";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Not actually a symbol, since we might be dealing with multiple instances of this code.
3
+ * @internal
4
+ */
5
+ export const instantiatedFragmentFakeSymbol = "$fragno-instantiated-fragment" as const;
@@ -0,0 +1,59 @@
1
+ // ============================================================================
2
+ // Client-side entry point for @fragno-dev/core
3
+ // This file mirrors mod.ts but provides stub implementations for server-side
4
+ // APIs that are stripped by unplugin-fragno during browser builds.
5
+ // ============================================================================
6
+
7
+ // ============================================================================
8
+ // Fragment Definition and Instantiation
9
+ // ============================================================================
10
+
11
+ // Re-export types only
12
+ export type {
13
+ FragmentDefinition,
14
+ ServiceContext,
15
+ ServiceConstructorFn,
16
+ } from "./api/fragment-definition-builder";
17
+
18
+ export type {
19
+ FragmentInstantiationBuilder,
20
+ FragnoInstantiatedFragment,
21
+ BoundServices,
22
+ } from "./api/fragment-instantiator";
23
+
24
+ // Stub implementation for defineFragment
25
+ // This is stripped by unplugin-fragno in browser builds
26
+ export function defineFragment(_name: string) {
27
+ return {
28
+ withDependencies: () => ({ withDependencies: () => ({}) }),
29
+ providesBaseService: () => ({ providesBaseService: () => ({}) }),
30
+ providesService: () => ({ providesService: () => ({}) }),
31
+ withRequestStorage: () => ({ withRequestStorage: () => ({}) }),
32
+ withExternalRequestStorage: () => ({ withExternalRequestStorage: () => ({}) }),
33
+ withRequestThisContext: () => ({ withRequestThisContext: () => ({}) }),
34
+ extend: () => ({ extend: () => ({}) }),
35
+ build: () => ({}),
36
+ };
37
+ }
38
+
39
+ // Re-export the builder class (for type compatibility)
40
+ export { FragmentDefinitionBuilder } from "./api/fragment-definition-builder";
41
+
42
+ // ============================================================================
43
+ // Core Configuration
44
+ // ============================================================================
45
+ export type { FragnoPublicConfig } from "./api/shared-types";
46
+
47
+ // ============================================================================
48
+ // Route Definition
49
+ // ============================================================================
50
+ export {
51
+ defineRoute,
52
+ defineRoutes,
53
+ type RouteFactory,
54
+ type RouteFactoryContext,
55
+ } from "./api/route";
56
+
57
+ export type { FragnoRouteConfig, RequestThisContext } from "./api/api";
58
+
59
+ export { instantiatedFragmentFakeSymbol } from "./internal/symbols";
package/src/mod.ts CHANGED
@@ -1,20 +1,37 @@
1
- export { defineFragment, FragmentBuilder, type FragmentDefinition } from "./api/fragment-builder";
1
+ // ============================================================================
2
+ // Fragment Definition and Instantiation
3
+ // ============================================================================
4
+ export {
5
+ defineFragment,
6
+ FragmentDefinitionBuilder,
7
+ type FragmentDefinition,
8
+ type ServiceContext,
9
+ type ServiceConstructorFn,
10
+ type LinkedFragmentCallback,
11
+ type ExtractLinkedServices,
12
+ } from "./api/fragment-definition-builder";
2
13
 
3
14
  export {
4
- createFragment,
5
- type FragnoFragmentSharedConfig,
6
- type FragnoPublicConfig,
7
- type FragnoPublicClientConfig,
15
+ instantiate,
16
+ type FragmentInstantiationBuilder,
8
17
  type FragnoInstantiatedFragment,
9
- } from "./api/fragment-instantiation";
18
+ type AnyFragnoInstantiatedFragment,
19
+ type BoundServices,
20
+ } from "./api/fragment-instantiator";
10
21
 
11
- export { type FragnoRouteConfig } from "./api/api";
22
+ // ============================================================================
23
+ // Core Configuration
24
+ // ============================================================================
25
+ export type { FragnoPublicConfig } from "./api/shared-types";
12
26
 
27
+ // ============================================================================
28
+ // Route Definition
29
+ // ============================================================================
13
30
  export {
14
31
  defineRoute,
15
32
  defineRoutes,
16
33
  type RouteFactory,
17
34
  type RouteFactoryContext,
18
- type AnyRouteOrFactory,
19
- type FlattenRouteFactories,
20
35
  } from "./api/route";
36
+
37
+ export { type FragnoRouteConfig, type RequestThisContext } from "./api/api";
@@ -0,0 +1,8 @@
1
+ export { RequestInputContext } from "../api/request-input-context";
2
+ export { RequestOutputContext } from "../api/request-output-context";
3
+ export {
4
+ RequestMiddlewareInputContext,
5
+ RequestMiddlewareOutputContext,
6
+ type FragnoMiddlewareCallback,
7
+ type RequestMiddlewareOptions,
8
+ } from "../api/request-middleware";