raktajs 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 (172) hide show
  1. package/README.md +90 -0
  2. package/dist/auto-import/generator.d.ts +4 -0
  3. package/dist/auto-import/generator.d.ts.map +1 -0
  4. package/dist/auto-import/index.d.ts +5 -0
  5. package/dist/auto-import/index.d.ts.map +1 -0
  6. package/dist/auto-import/index.js +153 -0
  7. package/dist/auto-import/index.js.map +11 -0
  8. package/dist/auto-import/scanner.d.ts +9 -0
  9. package/dist/auto-import/scanner.d.ts.map +1 -0
  10. package/dist/auto-import/types.d.ts +20 -0
  11. package/dist/auto-import/types.d.ts.map +1 -0
  12. package/dist/cli/build.d.ts +2 -0
  13. package/dist/cli/build.d.ts.map +1 -0
  14. package/dist/cli/dev.d.ts +2 -0
  15. package/dist/cli/dev.d.ts.map +1 -0
  16. package/dist/cli/doctor.d.ts +2 -0
  17. package/dist/cli/doctor.d.ts.map +1 -0
  18. package/dist/cli/imports.d.ts +2 -0
  19. package/dist/cli/imports.d.ts.map +1 -0
  20. package/dist/cli/index.d.ts +3 -0
  21. package/dist/cli/index.d.ts.map +1 -0
  22. package/dist/cli/make.d.ts +4 -0
  23. package/dist/cli/make.d.ts.map +1 -0
  24. package/dist/cli/rakta.d.ts +3 -0
  25. package/dist/cli/rakta.d.ts.map +1 -0
  26. package/dist/cli/rakta.js +1511 -0
  27. package/dist/cli/rakta.js.map +33 -0
  28. package/dist/cli/routes.d.ts +2 -0
  29. package/dist/cli/routes.d.ts.map +1 -0
  30. package/dist/cli/rpcTypes.d.ts +2 -0
  31. package/dist/cli/rpcTypes.d.ts.map +1 -0
  32. package/dist/cli/seo.d.ts +2 -0
  33. package/dist/cli/seo.d.ts.map +1 -0
  34. package/dist/cli/start.d.ts +2 -0
  35. package/dist/cli/start.d.ts.map +1 -0
  36. package/dist/components/Click.d.ts +11 -0
  37. package/dist/components/Click.d.ts.map +1 -0
  38. package/dist/components/Picture.d.ts +22 -0
  39. package/dist/components/Picture.d.ts.map +1 -0
  40. package/dist/components/index.d.ts +5 -0
  41. package/dist/components/index.d.ts.map +1 -0
  42. package/dist/components/index.js +1383 -0
  43. package/dist/components/index.js.map +15 -0
  44. package/dist/config/defineConfig.d.ts +64 -0
  45. package/dist/config/defineConfig.d.ts.map +1 -0
  46. package/dist/config/index.d.ts +4 -0
  47. package/dist/config/index.d.ts.map +1 -0
  48. package/dist/config/index.js +104 -0
  49. package/dist/config/index.js.map +11 -0
  50. package/dist/config/loadConfig.d.ts +4 -0
  51. package/dist/config/loadConfig.d.ts.map +1 -0
  52. package/dist/forge/build.d.ts +7 -0
  53. package/dist/forge/build.d.ts.map +1 -0
  54. package/dist/forge/devServer.d.ts +7 -0
  55. package/dist/forge/devServer.d.ts.map +1 -0
  56. package/dist/forge/index.d.ts +6 -0
  57. package/dist/forge/index.d.ts.map +1 -0
  58. package/dist/forge/index.js +579 -0
  59. package/dist/forge/index.js.map +17 -0
  60. package/dist/forge/inspect.d.ts +9 -0
  61. package/dist/forge/inspect.d.ts.map +1 -0
  62. package/dist/forge/types.d.ts +55 -0
  63. package/dist/forge/types.d.ts.map +1 -0
  64. package/dist/http/errors.d.ts +17 -0
  65. package/dist/http/errors.d.ts.map +1 -0
  66. package/dist/http/index.d.ts +4 -0
  67. package/dist/http/index.d.ts.map +1 -0
  68. package/dist/http/index.js +154 -0
  69. package/dist/http/index.js.map +11 -0
  70. package/dist/http/panturaFetch.d.ts +33 -0
  71. package/dist/http/panturaFetch.d.ts.map +1 -0
  72. package/dist/http/types.d.ts +24 -0
  73. package/dist/http/types.d.ts.map +1 -0
  74. package/dist/index.d.ts +30 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +3872 -0
  77. package/dist/index.js.map +50 -0
  78. package/dist/pwa/cache.d.ts +6 -0
  79. package/dist/pwa/cache.d.ts.map +1 -0
  80. package/dist/pwa/index.d.ts +5 -0
  81. package/dist/pwa/index.d.ts.map +1 -0
  82. package/dist/pwa/index.js +136 -0
  83. package/dist/pwa/index.js.map +12 -0
  84. package/dist/pwa/manifest.d.ts +11 -0
  85. package/dist/pwa/manifest.d.ts.map +1 -0
  86. package/dist/pwa/serviceWorker.d.ts +11 -0
  87. package/dist/pwa/serviceWorker.d.ts.map +1 -0
  88. package/dist/pwa/types.d.ts +45 -0
  89. package/dist/pwa/types.d.ts.map +1 -0
  90. package/dist/render/index.d.ts +5 -0
  91. package/dist/render/index.d.ts.map +1 -0
  92. package/dist/render/index.js +183 -0
  93. package/dist/render/index.js.map +11 -0
  94. package/dist/render/modes.d.ts +13 -0
  95. package/dist/render/modes.d.ts.map +1 -0
  96. package/dist/render/renderer.d.ts +15 -0
  97. package/dist/render/renderer.d.ts.map +1 -0
  98. package/dist/render/types.d.ts +72 -0
  99. package/dist/render/types.d.ts.map +1 -0
  100. package/dist/router/index.d.ts +5 -0
  101. package/dist/router/index.d.ts.map +1 -0
  102. package/dist/router/index.js +228 -0
  103. package/dist/router/index.js.map +12 -0
  104. package/dist/router/manifest.d.ts +6 -0
  105. package/dist/router/manifest.d.ts.map +1 -0
  106. package/dist/router/matcher.d.ts +5 -0
  107. package/dist/router/matcher.d.ts.map +1 -0
  108. package/dist/router/scanner.d.ts +6 -0
  109. package/dist/router/scanner.d.ts.map +1 -0
  110. package/dist/router/types.d.ts +45 -0
  111. package/dist/router/types.d.ts.map +1 -0
  112. package/dist/rpc/client.d.ts +24 -0
  113. package/dist/rpc/client.d.ts.map +1 -0
  114. package/dist/rpc/index.d.ts +6 -0
  115. package/dist/rpc/index.d.ts.map +1 -0
  116. package/dist/rpc/index.js +179 -0
  117. package/dist/rpc/index.js.map +13 -0
  118. package/dist/rpc/procedure.d.ts +28 -0
  119. package/dist/rpc/procedure.d.ts.map +1 -0
  120. package/dist/rpc/router.d.ts +12 -0
  121. package/dist/rpc/router.d.ts.map +1 -0
  122. package/dist/rpc/types.d.ts +48 -0
  123. package/dist/rpc/types.d.ts.map +1 -0
  124. package/dist/schema/array.d.ts +15 -0
  125. package/dist/schema/array.d.ts.map +1 -0
  126. package/dist/schema/boolean.d.ts +7 -0
  127. package/dist/schema/boolean.d.ts.map +1 -0
  128. package/dist/schema/errors.d.ts +21 -0
  129. package/dist/schema/errors.d.ts.map +1 -0
  130. package/dist/schema/index.d.ts +11 -0
  131. package/dist/schema/index.d.ts.map +1 -0
  132. package/dist/schema/index.js +393 -0
  133. package/dist/schema/index.js.map +16 -0
  134. package/dist/schema/number.d.ts +17 -0
  135. package/dist/schema/number.d.ts.map +1 -0
  136. package/dist/schema/object.d.ts +19 -0
  137. package/dist/schema/object.d.ts.map +1 -0
  138. package/dist/schema/string.d.ts +18 -0
  139. package/dist/schema/string.d.ts.map +1 -0
  140. package/dist/schema/types.d.ts +27 -0
  141. package/dist/schema/types.d.ts.map +1 -0
  142. package/dist/seo/head.d.ts +8 -0
  143. package/dist/seo/head.d.ts.map +1 -0
  144. package/dist/seo/index.d.ts +9 -0
  145. package/dist/seo/index.d.ts.map +1 -0
  146. package/dist/seo/index.js +1578 -0
  147. package/dist/seo/index.js.map +17 -0
  148. package/dist/seo/metadata.d.ts +106 -0
  149. package/dist/seo/metadata.d.ts.map +1 -0
  150. package/dist/seo/robots.d.ts +14 -0
  151. package/dist/seo/robots.d.ts.map +1 -0
  152. package/dist/seo/sitemap.d.ts +27 -0
  153. package/dist/seo/sitemap.d.ts.map +1 -0
  154. package/dist/store/createStore.d.ts +18 -0
  155. package/dist/store/createStore.d.ts.map +1 -0
  156. package/dist/store/index.d.ts +3 -0
  157. package/dist/store/index.d.ts.map +1 -0
  158. package/dist/store/index.js +925 -0
  159. package/dist/store/index.js.map +12 -0
  160. package/dist/store/types.d.ts +14 -0
  161. package/dist/store/types.d.ts.map +1 -0
  162. package/dist/tide/adapter.d.ts +8 -0
  163. package/dist/tide/adapter.d.ts.map +1 -0
  164. package/dist/tide/index.d.ts +4 -0
  165. package/dist/tide/index.d.ts.map +1 -0
  166. package/dist/tide/index.js +477 -0
  167. package/dist/tide/index.js.map +16 -0
  168. package/dist/tide/runtime.d.ts +8 -0
  169. package/dist/tide/runtime.d.ts.map +1 -0
  170. package/dist/tide/types.d.ts +40 -0
  171. package/dist/tide/types.d.ts.map +1 -0
  172. package/package.json +128 -0
package/dist/index.js ADDED
@@ -0,0 +1,3872 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+
34
+ // ../../node_modules/.bun/react@19.2.7/node_modules/react/cjs/react.development.js
35
+ var require_react_development = __commonJS((exports, module) => {
36
+ (function() {
37
+ function defineDeprecationWarning(methodName, info) {
38
+ Object.defineProperty(Component.prototype, methodName, {
39
+ get: function() {
40
+ console.warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
41
+ }
42
+ });
43
+ }
44
+ function getIteratorFn(maybeIterable) {
45
+ if (maybeIterable === null || typeof maybeIterable !== "object")
46
+ return null;
47
+ maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
48
+ return typeof maybeIterable === "function" ? maybeIterable : null;
49
+ }
50
+ function warnNoop(publicInstance, callerName) {
51
+ publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
52
+ var warningKey = publicInstance + "." + callerName;
53
+ didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.", callerName, publicInstance), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
54
+ }
55
+ function Component(props, context, updater) {
56
+ this.props = props;
57
+ this.context = context;
58
+ this.refs = emptyObject;
59
+ this.updater = updater || ReactNoopUpdateQueue;
60
+ }
61
+ function ComponentDummy() {}
62
+ function PureComponent(props, context, updater) {
63
+ this.props = props;
64
+ this.context = context;
65
+ this.refs = emptyObject;
66
+ this.updater = updater || ReactNoopUpdateQueue;
67
+ }
68
+ function noop() {}
69
+ function testStringCoercion(value) {
70
+ return "" + value;
71
+ }
72
+ function checkKeyStringCoercion(value) {
73
+ try {
74
+ testStringCoercion(value);
75
+ var JSCompiler_inline_result = false;
76
+ } catch (e) {
77
+ JSCompiler_inline_result = true;
78
+ }
79
+ if (JSCompiler_inline_result) {
80
+ JSCompiler_inline_result = console;
81
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
82
+ var JSCompiler_inline_result$jscomp$0 = typeof Symbol === "function" && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
83
+ JSCompiler_temp_const.call(JSCompiler_inline_result, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", JSCompiler_inline_result$jscomp$0);
84
+ return testStringCoercion(value);
85
+ }
86
+ }
87
+ function getComponentNameFromType(type) {
88
+ if (type == null)
89
+ return null;
90
+ if (typeof type === "function")
91
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
92
+ if (typeof type === "string")
93
+ return type;
94
+ switch (type) {
95
+ case REACT_FRAGMENT_TYPE:
96
+ return "Fragment";
97
+ case REACT_PROFILER_TYPE:
98
+ return "Profiler";
99
+ case REACT_STRICT_MODE_TYPE:
100
+ return "StrictMode";
101
+ case REACT_SUSPENSE_TYPE:
102
+ return "Suspense";
103
+ case REACT_SUSPENSE_LIST_TYPE:
104
+ return "SuspenseList";
105
+ case REACT_ACTIVITY_TYPE:
106
+ return "Activity";
107
+ }
108
+ if (typeof type === "object")
109
+ switch (typeof type.tag === "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), type.$$typeof) {
110
+ case REACT_PORTAL_TYPE:
111
+ return "Portal";
112
+ case REACT_CONTEXT_TYPE:
113
+ return type.displayName || "Context";
114
+ case REACT_CONSUMER_TYPE:
115
+ return (type._context.displayName || "Context") + ".Consumer";
116
+ case REACT_FORWARD_REF_TYPE:
117
+ var innerType = type.render;
118
+ type = type.displayName;
119
+ type || (type = innerType.displayName || innerType.name || "", type = type !== "" ? "ForwardRef(" + type + ")" : "ForwardRef");
120
+ return type;
121
+ case REACT_MEMO_TYPE:
122
+ return innerType = type.displayName || null, innerType !== null ? innerType : getComponentNameFromType(type.type) || "Memo";
123
+ case REACT_LAZY_TYPE:
124
+ innerType = type._payload;
125
+ type = type._init;
126
+ try {
127
+ return getComponentNameFromType(type(innerType));
128
+ } catch (x) {}
129
+ }
130
+ return null;
131
+ }
132
+ function getTaskName(type) {
133
+ if (type === REACT_FRAGMENT_TYPE)
134
+ return "<>";
135
+ if (typeof type === "object" && type !== null && type.$$typeof === REACT_LAZY_TYPE)
136
+ return "<...>";
137
+ try {
138
+ var name = getComponentNameFromType(type);
139
+ return name ? "<" + name + ">" : "<...>";
140
+ } catch (x) {
141
+ return "<...>";
142
+ }
143
+ }
144
+ function getOwner() {
145
+ var dispatcher = ReactSharedInternals.A;
146
+ return dispatcher === null ? null : dispatcher.getOwner();
147
+ }
148
+ function UnknownOwner() {
149
+ return Error("react-stack-top-frame");
150
+ }
151
+ function hasValidKey(config) {
152
+ if (hasOwnProperty.call(config, "key")) {
153
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
154
+ if (getter && getter.isReactWarning)
155
+ return false;
156
+ }
157
+ return config.key !== undefined;
158
+ }
159
+ function defineKeyPropWarningGetter(props, displayName) {
160
+ function warnAboutAccessingKey() {
161
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", displayName));
162
+ }
163
+ warnAboutAccessingKey.isReactWarning = true;
164
+ Object.defineProperty(props, "key", {
165
+ get: warnAboutAccessingKey,
166
+ configurable: true
167
+ });
168
+ }
169
+ function elementRefGetterWithDeprecationWarning() {
170
+ var componentName = getComponentNameFromType(this.type);
171
+ didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."));
172
+ componentName = this.props.ref;
173
+ return componentName !== undefined ? componentName : null;
174
+ }
175
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
176
+ var refProp = props.ref;
177
+ type = {
178
+ $$typeof: REACT_ELEMENT_TYPE,
179
+ type,
180
+ key,
181
+ props,
182
+ _owner: owner
183
+ };
184
+ (refProp !== undefined ? refProp : null) !== null ? Object.defineProperty(type, "ref", {
185
+ enumerable: false,
186
+ get: elementRefGetterWithDeprecationWarning
187
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
188
+ type._store = {};
189
+ Object.defineProperty(type._store, "validated", {
190
+ configurable: false,
191
+ enumerable: false,
192
+ writable: true,
193
+ value: 0
194
+ });
195
+ Object.defineProperty(type, "_debugInfo", {
196
+ configurable: false,
197
+ enumerable: false,
198
+ writable: true,
199
+ value: null
200
+ });
201
+ Object.defineProperty(type, "_debugStack", {
202
+ configurable: false,
203
+ enumerable: false,
204
+ writable: true,
205
+ value: debugStack
206
+ });
207
+ Object.defineProperty(type, "_debugTask", {
208
+ configurable: false,
209
+ enumerable: false,
210
+ writable: true,
211
+ value: debugTask
212
+ });
213
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
214
+ return type;
215
+ }
216
+ function cloneAndReplaceKey(oldElement, newKey) {
217
+ newKey = ReactElement(oldElement.type, newKey, oldElement.props, oldElement._owner, oldElement._debugStack, oldElement._debugTask);
218
+ oldElement._store && (newKey._store.validated = oldElement._store.validated);
219
+ return newKey;
220
+ }
221
+ function validateChildKeys(node) {
222
+ isValidElement(node) ? node._store && (node._store.validated = 1) : typeof node === "object" && node !== null && node.$$typeof === REACT_LAZY_TYPE && (node._payload.status === "fulfilled" ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
223
+ }
224
+ function isValidElement(object) {
225
+ return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
226
+ }
227
+ function escape(key) {
228
+ var escaperLookup = { "=": "=0", ":": "=2" };
229
+ return "$" + key.replace(/[=:]/g, function(match) {
230
+ return escaperLookup[match];
231
+ });
232
+ }
233
+ function getElementKey(element, index) {
234
+ return typeof element === "object" && element !== null && element.key != null ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
235
+ }
236
+ function resolveThenable(thenable) {
237
+ switch (thenable.status) {
238
+ case "fulfilled":
239
+ return thenable.value;
240
+ case "rejected":
241
+ throw thenable.reason;
242
+ default:
243
+ switch (typeof thenable.status === "string" ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(function(fulfilledValue) {
244
+ thenable.status === "pending" && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
245
+ }, function(error) {
246
+ thenable.status === "pending" && (thenable.status = "rejected", thenable.reason = error);
247
+ })), thenable.status) {
248
+ case "fulfilled":
249
+ return thenable.value;
250
+ case "rejected":
251
+ throw thenable.reason;
252
+ }
253
+ }
254
+ throw thenable;
255
+ }
256
+ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
257
+ var type = typeof children;
258
+ if (type === "undefined" || type === "boolean")
259
+ children = null;
260
+ var invokeCallback = false;
261
+ if (children === null)
262
+ invokeCallback = true;
263
+ else
264
+ switch (type) {
265
+ case "bigint":
266
+ case "string":
267
+ case "number":
268
+ invokeCallback = true;
269
+ break;
270
+ case "object":
271
+ switch (children.$$typeof) {
272
+ case REACT_ELEMENT_TYPE:
273
+ case REACT_PORTAL_TYPE:
274
+ invokeCallback = true;
275
+ break;
276
+ case REACT_LAZY_TYPE:
277
+ return invokeCallback = children._init, mapIntoArray(invokeCallback(children._payload), array, escapedPrefix, nameSoFar, callback);
278
+ }
279
+ }
280
+ if (invokeCallback) {
281
+ invokeCallback = children;
282
+ callback = callback(invokeCallback);
283
+ var childKey = nameSoFar === "" ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
284
+ isArrayImpl(callback) ? (escapedPrefix = "", childKey != null && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
285
+ return c;
286
+ })) : callback != null && (isValidElement(callback) && (callback.key != null && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(callback, escapedPrefix + (callback.key == null || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(userProvidedKeyEscapeRegex, "$&/") + "/") + childKey), nameSoFar !== "" && invokeCallback != null && isValidElement(invokeCallback) && invokeCallback.key == null && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
287
+ return 1;
288
+ }
289
+ invokeCallback = 0;
290
+ childKey = nameSoFar === "" ? "." : nameSoFar + ":";
291
+ if (isArrayImpl(children))
292
+ for (var i = 0;i < children.length; i++)
293
+ nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
294
+ else if (i = getIteratorFn(children), typeof i === "function")
295
+ for (i === children.entries && (didWarnAboutMaps || console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."), didWarnAboutMaps = true), children = i.call(children), i = 0;!(nameSoFar = children.next()).done; )
296
+ nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
297
+ else if (type === "object") {
298
+ if (typeof children.then === "function")
299
+ return mapIntoArray(resolveThenable(children), array, escapedPrefix, nameSoFar, callback);
300
+ array = String(children);
301
+ throw Error("Objects are not valid as a React child (found: " + (array === "[object Object]" ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead.");
302
+ }
303
+ return invokeCallback;
304
+ }
305
+ function mapChildren(children, func, context) {
306
+ if (children == null)
307
+ return children;
308
+ var result = [], count = 0;
309
+ mapIntoArray(children, result, "", "", function(child) {
310
+ return func.call(context, child, count++);
311
+ });
312
+ return result;
313
+ }
314
+ function lazyInitializer(payload) {
315
+ if (payload._status === -1) {
316
+ var ioInfo = payload._ioInfo;
317
+ ioInfo != null && (ioInfo.start = ioInfo.end = performance.now());
318
+ ioInfo = payload._result;
319
+ var thenable = ioInfo();
320
+ thenable.then(function(moduleObject) {
321
+ if (payload._status === 0 || payload._status === -1) {
322
+ payload._status = 1;
323
+ payload._result = moduleObject;
324
+ var _ioInfo = payload._ioInfo;
325
+ _ioInfo != null && (_ioInfo.end = performance.now());
326
+ thenable.status === undefined && (thenable.status = "fulfilled", thenable.value = moduleObject);
327
+ }
328
+ }, function(error) {
329
+ if (payload._status === 0 || payload._status === -1) {
330
+ payload._status = 2;
331
+ payload._result = error;
332
+ var _ioInfo2 = payload._ioInfo;
333
+ _ioInfo2 != null && (_ioInfo2.end = performance.now());
334
+ thenable.status === undefined && (thenable.status = "rejected", thenable.reason = error);
335
+ }
336
+ });
337
+ ioInfo = payload._ioInfo;
338
+ if (ioInfo != null) {
339
+ ioInfo.value = thenable;
340
+ var displayName = thenable.displayName;
341
+ typeof displayName === "string" && (ioInfo.name = displayName);
342
+ }
343
+ payload._status === -1 && (payload._status = 0, payload._result = thenable);
344
+ }
345
+ if (payload._status === 1)
346
+ return ioInfo = payload._result, ioInfo === undefined && console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
347
+
348
+ Your code should look like:
349
+ const MyComponent = lazy(() => import('./MyComponent'))
350
+
351
+ Did you accidentally put curly braces around the import?`, ioInfo), "default" in ioInfo || console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
352
+
353
+ Your code should look like:
354
+ const MyComponent = lazy(() => import('./MyComponent'))`, ioInfo), ioInfo.default;
355
+ throw payload._result;
356
+ }
357
+ function resolveDispatcher() {
358
+ var dispatcher = ReactSharedInternals.H;
359
+ dispatcher === null && console.error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
360
+ 1. You might have mismatching versions of React and the renderer (such as React DOM)
361
+ 2. You might be breaking the Rules of Hooks
362
+ 3. You might have more than one copy of React in the same app
363
+ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`);
364
+ return dispatcher;
365
+ }
366
+ function releaseAsyncTransition() {
367
+ ReactSharedInternals.asyncTransitions--;
368
+ }
369
+ function enqueueTask(task) {
370
+ if (enqueueTaskImpl === null)
371
+ try {
372
+ var requireString = ("require" + Math.random()).slice(0, 7);
373
+ enqueueTaskImpl = (module && module[requireString]).call(module, "timers").setImmediate;
374
+ } catch (_err) {
375
+ enqueueTaskImpl = function(callback) {
376
+ didWarnAboutMessageChannel === false && (didWarnAboutMessageChannel = true, typeof MessageChannel === "undefined" && console.error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));
377
+ var channel = new MessageChannel;
378
+ channel.port1.onmessage = callback;
379
+ channel.port2.postMessage(undefined);
380
+ };
381
+ }
382
+ return enqueueTaskImpl(task);
383
+ }
384
+ function aggregateErrors(errors) {
385
+ return 1 < errors.length && typeof AggregateError === "function" ? new AggregateError(errors) : errors[0];
386
+ }
387
+ function popActScope(prevActQueue, prevActScopeDepth) {
388
+ prevActScopeDepth !== actScopeDepth - 1 && console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. ");
389
+ actScopeDepth = prevActScopeDepth;
390
+ }
391
+ function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
392
+ var queue = ReactSharedInternals.actQueue;
393
+ if (queue !== null)
394
+ if (queue.length !== 0)
395
+ try {
396
+ flushActQueue(queue);
397
+ enqueueTask(function() {
398
+ return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
399
+ });
400
+ return;
401
+ } catch (error) {
402
+ ReactSharedInternals.thrownErrors.push(error);
403
+ }
404
+ else
405
+ ReactSharedInternals.actQueue = null;
406
+ 0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
407
+ }
408
+ function flushActQueue(queue) {
409
+ if (!isFlushing) {
410
+ isFlushing = true;
411
+ var i = 0;
412
+ try {
413
+ for (;i < queue.length; i++) {
414
+ var callback = queue[i];
415
+ do {
416
+ ReactSharedInternals.didUsePromise = false;
417
+ var continuation = callback(false);
418
+ if (continuation !== null) {
419
+ if (ReactSharedInternals.didUsePromise) {
420
+ queue[i] = callback;
421
+ queue.splice(0, i);
422
+ return;
423
+ }
424
+ callback = continuation;
425
+ } else
426
+ break;
427
+ } while (1);
428
+ }
429
+ queue.length = 0;
430
+ } catch (error) {
431
+ queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
432
+ } finally {
433
+ isFlushing = false;
434
+ }
435
+ }
436
+ }
437
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
438
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
439
+ isMounted: function() {
440
+ return false;
441
+ },
442
+ enqueueForceUpdate: function(publicInstance) {
443
+ warnNoop(publicInstance, "forceUpdate");
444
+ },
445
+ enqueueReplaceState: function(publicInstance) {
446
+ warnNoop(publicInstance, "replaceState");
447
+ },
448
+ enqueueSetState: function(publicInstance) {
449
+ warnNoop(publicInstance, "setState");
450
+ }
451
+ }, assign = Object.assign, emptyObject = {};
452
+ Object.freeze(emptyObject);
453
+ Component.prototype.isReactComponent = {};
454
+ Component.prototype.setState = function(partialState, callback) {
455
+ if (typeof partialState !== "object" && typeof partialState !== "function" && partialState != null)
456
+ throw Error("takes an object of state variables to update or a function which returns an object of state variables.");
457
+ this.updater.enqueueSetState(this, partialState, callback, "setState");
458
+ };
459
+ Component.prototype.forceUpdate = function(callback) {
460
+ this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
461
+ };
462
+ var deprecatedAPIs = {
463
+ isMounted: [
464
+ "isMounted",
465
+ "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
466
+ ],
467
+ replaceState: [
468
+ "replaceState",
469
+ "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
470
+ ]
471
+ };
472
+ for (fnName in deprecatedAPIs)
473
+ deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
474
+ ComponentDummy.prototype = Component.prototype;
475
+ deprecatedAPIs = PureComponent.prototype = new ComponentDummy;
476
+ deprecatedAPIs.constructor = PureComponent;
477
+ assign(deprecatedAPIs, Component.prototype);
478
+ deprecatedAPIs.isPureReactComponent = true;
479
+ var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = {
480
+ H: null,
481
+ A: null,
482
+ T: null,
483
+ S: null,
484
+ actQueue: null,
485
+ asyncTransitions: 0,
486
+ isBatchingLegacy: false,
487
+ didScheduleLegacyUpdate: false,
488
+ didUsePromise: false,
489
+ thrownErrors: [],
490
+ getCurrentStack: null,
491
+ recentlyCreatedOwnerStacks: 0
492
+ }, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
493
+ return null;
494
+ };
495
+ deprecatedAPIs = {
496
+ react_stack_bottom_frame: function(callStackForError) {
497
+ return callStackForError();
498
+ }
499
+ };
500
+ var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
501
+ var didWarnAboutElementRef = {};
502
+ var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(deprecatedAPIs, UnknownOwner)();
503
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
504
+ var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = typeof reportError === "function" ? reportError : function(error) {
505
+ if (typeof window === "object" && typeof window.ErrorEvent === "function") {
506
+ var event = new window.ErrorEvent("error", {
507
+ bubbles: true,
508
+ cancelable: true,
509
+ message: typeof error === "object" && error !== null && typeof error.message === "string" ? String(error.message) : String(error),
510
+ error
511
+ });
512
+ if (!window.dispatchEvent(event))
513
+ return;
514
+ } else if (typeof process === "object" && typeof process.emit === "function") {
515
+ process.emit("uncaughtException", error);
516
+ return;
517
+ }
518
+ console.error(error);
519
+ }, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = typeof queueMicrotask === "function" ? function(callback) {
520
+ queueMicrotask(function() {
521
+ return queueMicrotask(callback);
522
+ });
523
+ } : enqueueTask;
524
+ deprecatedAPIs = Object.freeze({
525
+ __proto__: null,
526
+ c: function(size) {
527
+ return resolveDispatcher().useMemoCache(size);
528
+ }
529
+ });
530
+ var fnName = {
531
+ map: mapChildren,
532
+ forEach: function(children, forEachFunc, forEachContext) {
533
+ mapChildren(children, function() {
534
+ forEachFunc.apply(this, arguments);
535
+ }, forEachContext);
536
+ },
537
+ count: function(children) {
538
+ var n = 0;
539
+ mapChildren(children, function() {
540
+ n++;
541
+ });
542
+ return n;
543
+ },
544
+ toArray: function(children) {
545
+ return mapChildren(children, function(child) {
546
+ return child;
547
+ }) || [];
548
+ },
549
+ only: function(children) {
550
+ if (!isValidElement(children))
551
+ throw Error("React.Children.only expected to receive a single React element child.");
552
+ return children;
553
+ }
554
+ };
555
+ exports.Activity = REACT_ACTIVITY_TYPE;
556
+ exports.Children = fnName;
557
+ exports.Component = Component;
558
+ exports.Fragment = REACT_FRAGMENT_TYPE;
559
+ exports.Profiler = REACT_PROFILER_TYPE;
560
+ exports.PureComponent = PureComponent;
561
+ exports.StrictMode = REACT_STRICT_MODE_TYPE;
562
+ exports.Suspense = REACT_SUSPENSE_TYPE;
563
+ exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
564
+ exports.__COMPILER_RUNTIME = deprecatedAPIs;
565
+ exports.act = function(callback) {
566
+ var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
567
+ actScopeDepth++;
568
+ var queue = ReactSharedInternals.actQueue = prevActQueue !== null ? prevActQueue : [], didAwaitActCall = false;
569
+ try {
570
+ var result = callback();
571
+ } catch (error) {
572
+ ReactSharedInternals.thrownErrors.push(error);
573
+ }
574
+ if (0 < ReactSharedInternals.thrownErrors.length)
575
+ throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
576
+ if (result !== null && typeof result === "object" && typeof result.then === "function") {
577
+ var thenable = result;
578
+ queueSeveralMicrotasks(function() {
579
+ didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"));
580
+ });
581
+ return {
582
+ then: function(resolve, reject) {
583
+ didAwaitActCall = true;
584
+ thenable.then(function(returnValue) {
585
+ popActScope(prevActQueue, prevActScopeDepth);
586
+ if (prevActScopeDepth === 0) {
587
+ try {
588
+ flushActQueue(queue), enqueueTask(function() {
589
+ return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
590
+ });
591
+ } catch (error$0) {
592
+ ReactSharedInternals.thrownErrors.push(error$0);
593
+ }
594
+ if (0 < ReactSharedInternals.thrownErrors.length) {
595
+ var _thrownError = aggregateErrors(ReactSharedInternals.thrownErrors);
596
+ ReactSharedInternals.thrownErrors.length = 0;
597
+ reject(_thrownError);
598
+ }
599
+ } else
600
+ resolve(returnValue);
601
+ }, function(error) {
602
+ popActScope(prevActQueue, prevActScopeDepth);
603
+ 0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
604
+ });
605
+ }
606
+ };
607
+ }
608
+ var returnValue$jscomp$0 = result;
609
+ popActScope(prevActQueue, prevActScopeDepth);
610
+ prevActScopeDepth === 0 && (flushActQueue(queue), queue.length !== 0 && queueSeveralMicrotasks(function() {
611
+ didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"));
612
+ }), ReactSharedInternals.actQueue = null);
613
+ if (0 < ReactSharedInternals.thrownErrors.length)
614
+ throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
615
+ return {
616
+ then: function(resolve, reject) {
617
+ didAwaitActCall = true;
618
+ prevActScopeDepth === 0 ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
619
+ return recursivelyFlushAsyncActWork(returnValue$jscomp$0, resolve, reject);
620
+ })) : resolve(returnValue$jscomp$0);
621
+ }
622
+ };
623
+ };
624
+ exports.cache = function(fn) {
625
+ return function() {
626
+ return fn.apply(null, arguments);
627
+ };
628
+ };
629
+ exports.cacheSignal = function() {
630
+ return null;
631
+ };
632
+ exports.captureOwnerStack = function() {
633
+ var getCurrentStack = ReactSharedInternals.getCurrentStack;
634
+ return getCurrentStack === null ? null : getCurrentStack();
635
+ };
636
+ exports.cloneElement = function(element, config, children) {
637
+ if (element === null || element === undefined)
638
+ throw Error("The argument must be a React element, but you passed " + element + ".");
639
+ var props = assign({}, element.props), key = element.key, owner = element._owner;
640
+ if (config != null) {
641
+ var JSCompiler_inline_result;
642
+ a: {
643
+ if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(config, "ref").get) && JSCompiler_inline_result.isReactWarning) {
644
+ JSCompiler_inline_result = false;
645
+ break a;
646
+ }
647
+ JSCompiler_inline_result = config.ref !== undefined;
648
+ }
649
+ JSCompiler_inline_result && (owner = getOwner());
650
+ hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
651
+ for (propName in config)
652
+ !hasOwnProperty.call(config, propName) || propName === "key" || propName === "__self" || propName === "__source" || propName === "ref" && config.ref === undefined || (props[propName] = config[propName]);
653
+ }
654
+ var propName = arguments.length - 2;
655
+ if (propName === 1)
656
+ props.children = children;
657
+ else if (1 < propName) {
658
+ JSCompiler_inline_result = Array(propName);
659
+ for (var i = 0;i < propName; i++)
660
+ JSCompiler_inline_result[i] = arguments[i + 2];
661
+ props.children = JSCompiler_inline_result;
662
+ }
663
+ props = ReactElement(element.type, key, props, owner, element._debugStack, element._debugTask);
664
+ for (key = 2;key < arguments.length; key++)
665
+ validateChildKeys(arguments[key]);
666
+ return props;
667
+ };
668
+ exports.createContext = function(defaultValue) {
669
+ defaultValue = {
670
+ $$typeof: REACT_CONTEXT_TYPE,
671
+ _currentValue: defaultValue,
672
+ _currentValue2: defaultValue,
673
+ _threadCount: 0,
674
+ Provider: null,
675
+ Consumer: null
676
+ };
677
+ defaultValue.Provider = defaultValue;
678
+ defaultValue.Consumer = {
679
+ $$typeof: REACT_CONSUMER_TYPE,
680
+ _context: defaultValue
681
+ };
682
+ defaultValue._currentRenderer = null;
683
+ defaultValue._currentRenderer2 = null;
684
+ return defaultValue;
685
+ };
686
+ exports.createElement = function(type, config, children) {
687
+ for (var i = 2;i < arguments.length; i++)
688
+ validateChildKeys(arguments[i]);
689
+ i = {};
690
+ var key = null;
691
+ if (config != null)
692
+ for (propName in didWarnAboutOldJSXRuntime || !("__self" in config) || "key" in config || (didWarnAboutOldJSXRuntime = true, console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")), hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key), config)
693
+ hasOwnProperty.call(config, propName) && propName !== "key" && propName !== "__self" && propName !== "__source" && (i[propName] = config[propName]);
694
+ var childrenLength = arguments.length - 2;
695
+ if (childrenLength === 1)
696
+ i.children = children;
697
+ else if (1 < childrenLength) {
698
+ for (var childArray = Array(childrenLength), _i = 0;_i < childrenLength; _i++)
699
+ childArray[_i] = arguments[_i + 2];
700
+ Object.freeze && Object.freeze(childArray);
701
+ i.children = childArray;
702
+ }
703
+ if (type && type.defaultProps)
704
+ for (propName in childrenLength = type.defaultProps, childrenLength)
705
+ i[propName] === undefined && (i[propName] = childrenLength[propName]);
706
+ key && defineKeyPropWarningGetter(i, typeof type === "function" ? type.displayName || type.name || "Unknown" : type);
707
+ var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
708
+ return ReactElement(type, key, i, getOwner(), propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack, propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
709
+ };
710
+ exports.createRef = function() {
711
+ var refObject = { current: null };
712
+ Object.seal(refObject);
713
+ return refObject;
714
+ };
715
+ exports.forwardRef = function(render) {
716
+ render != null && render.$$typeof === REACT_MEMO_TYPE ? console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).") : typeof render !== "function" ? console.error("forwardRef requires a render function but was given %s.", render === null ? "null" : typeof render) : render.length !== 0 && render.length !== 2 && console.error("forwardRef render functions accept exactly two parameters: props and ref. %s", render.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined.");
717
+ render != null && render.defaultProps != null && console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");
718
+ var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
719
+ Object.defineProperty(elementType, "displayName", {
720
+ enumerable: false,
721
+ configurable: true,
722
+ get: function() {
723
+ return ownName;
724
+ },
725
+ set: function(name) {
726
+ ownName = name;
727
+ render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
728
+ }
729
+ });
730
+ return elementType;
731
+ };
732
+ exports.isValidElement = isValidElement;
733
+ exports.lazy = function(ctor) {
734
+ ctor = { _status: -1, _result: ctor };
735
+ var lazyType = {
736
+ $$typeof: REACT_LAZY_TYPE,
737
+ _payload: ctor,
738
+ _init: lazyInitializer
739
+ }, ioInfo = {
740
+ name: "lazy",
741
+ start: -1,
742
+ end: -1,
743
+ value: null,
744
+ owner: null,
745
+ debugStack: Error("react-stack-top-frame"),
746
+ debugTask: console.createTask ? console.createTask("lazy()") : null
747
+ };
748
+ ctor._ioInfo = ioInfo;
749
+ lazyType._debugInfo = [{ awaited: ioInfo }];
750
+ return lazyType;
751
+ };
752
+ exports.memo = function(type, compare) {
753
+ type == null && console.error("memo: The first argument must be a component. Instead received: %s", type === null ? "null" : typeof type);
754
+ compare = {
755
+ $$typeof: REACT_MEMO_TYPE,
756
+ type,
757
+ compare: compare === undefined ? null : compare
758
+ };
759
+ var ownName;
760
+ Object.defineProperty(compare, "displayName", {
761
+ enumerable: false,
762
+ configurable: true,
763
+ get: function() {
764
+ return ownName;
765
+ },
766
+ set: function(name) {
767
+ ownName = name;
768
+ type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
769
+ }
770
+ });
771
+ return compare;
772
+ };
773
+ exports.startTransition = function(scope) {
774
+ var prevTransition = ReactSharedInternals.T, currentTransition = {};
775
+ currentTransition._updatedFibers = new Set;
776
+ ReactSharedInternals.T = currentTransition;
777
+ try {
778
+ var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
779
+ onStartTransitionFinish !== null && onStartTransitionFinish(currentTransition, returnValue);
780
+ typeof returnValue === "object" && returnValue !== null && typeof returnValue.then === "function" && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
781
+ } catch (error) {
782
+ reportGlobalError(error);
783
+ } finally {
784
+ prevTransition === null && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.")), prevTransition !== null && currentTransition.types !== null && (prevTransition.types !== null && prevTransition.types !== currentTransition.types && console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
785
+ }
786
+ };
787
+ exports.unstable_useCacheRefresh = function() {
788
+ return resolveDispatcher().useCacheRefresh();
789
+ };
790
+ exports.use = function(usable) {
791
+ return resolveDispatcher().use(usable);
792
+ };
793
+ exports.useActionState = function(action, initialState, permalink) {
794
+ return resolveDispatcher().useActionState(action, initialState, permalink);
795
+ };
796
+ exports.useCallback = function(callback, deps) {
797
+ return resolveDispatcher().useCallback(callback, deps);
798
+ };
799
+ exports.useContext = function(Context) {
800
+ var dispatcher = resolveDispatcher();
801
+ Context.$$typeof === REACT_CONSUMER_TYPE && console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?");
802
+ return dispatcher.useContext(Context);
803
+ };
804
+ exports.useDebugValue = function(value, formatterFn) {
805
+ return resolveDispatcher().useDebugValue(value, formatterFn);
806
+ };
807
+ exports.useDeferredValue = function(value, initialValue) {
808
+ return resolveDispatcher().useDeferredValue(value, initialValue);
809
+ };
810
+ exports.useEffect = function(create, deps) {
811
+ create == null && console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?");
812
+ return resolveDispatcher().useEffect(create, deps);
813
+ };
814
+ exports.useEffectEvent = function(callback) {
815
+ return resolveDispatcher().useEffectEvent(callback);
816
+ };
817
+ exports.useId = function() {
818
+ return resolveDispatcher().useId();
819
+ };
820
+ exports.useImperativeHandle = function(ref, create, deps) {
821
+ return resolveDispatcher().useImperativeHandle(ref, create, deps);
822
+ };
823
+ exports.useInsertionEffect = function(create, deps) {
824
+ create == null && console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?");
825
+ return resolveDispatcher().useInsertionEffect(create, deps);
826
+ };
827
+ exports.useLayoutEffect = function(create, deps) {
828
+ create == null && console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?");
829
+ return resolveDispatcher().useLayoutEffect(create, deps);
830
+ };
831
+ exports.useMemo = function(create, deps) {
832
+ return resolveDispatcher().useMemo(create, deps);
833
+ };
834
+ exports.useOptimistic = function(passthrough, reducer) {
835
+ return resolveDispatcher().useOptimistic(passthrough, reducer);
836
+ };
837
+ exports.useReducer = function(reducer, initialArg, init) {
838
+ return resolveDispatcher().useReducer(reducer, initialArg, init);
839
+ };
840
+ exports.useRef = function(initialValue) {
841
+ return resolveDispatcher().useRef(initialValue);
842
+ };
843
+ exports.useState = function(initialState) {
844
+ return resolveDispatcher().useState(initialState);
845
+ };
846
+ exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
847
+ return resolveDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
848
+ };
849
+ exports.useTransition = function() {
850
+ return resolveDispatcher().useTransition();
851
+ };
852
+ exports.version = "19.2.7";
853
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
854
+ })();
855
+ });
856
+
857
+ // ../../node_modules/.bun/react@19.2.7/node_modules/react/index.js
858
+ var require_react = __commonJS((exports, module) => {
859
+ if (false) {} else {
860
+ module.exports = require_react_development();
861
+ }
862
+ });
863
+
864
+ // ../../node_modules/.bun/react@19.2.7/node_modules/react/cjs/react-jsx-dev-runtime.development.js
865
+ var require_react_jsx_dev_runtime_development = __commonJS((exports) => {
866
+ var React2 = __toESM(require_react());
867
+ (function() {
868
+ function getComponentNameFromType(type) {
869
+ if (type == null)
870
+ return null;
871
+ if (typeof type === "function")
872
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
873
+ if (typeof type === "string")
874
+ return type;
875
+ switch (type) {
876
+ case REACT_FRAGMENT_TYPE:
877
+ return "Fragment";
878
+ case REACT_PROFILER_TYPE:
879
+ return "Profiler";
880
+ case REACT_STRICT_MODE_TYPE:
881
+ return "StrictMode";
882
+ case REACT_SUSPENSE_TYPE:
883
+ return "Suspense";
884
+ case REACT_SUSPENSE_LIST_TYPE:
885
+ return "SuspenseList";
886
+ case REACT_ACTIVITY_TYPE:
887
+ return "Activity";
888
+ }
889
+ if (typeof type === "object")
890
+ switch (typeof type.tag === "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), type.$$typeof) {
891
+ case REACT_PORTAL_TYPE:
892
+ return "Portal";
893
+ case REACT_CONTEXT_TYPE:
894
+ return type.displayName || "Context";
895
+ case REACT_CONSUMER_TYPE:
896
+ return (type._context.displayName || "Context") + ".Consumer";
897
+ case REACT_FORWARD_REF_TYPE:
898
+ var innerType = type.render;
899
+ type = type.displayName;
900
+ type || (type = innerType.displayName || innerType.name || "", type = type !== "" ? "ForwardRef(" + type + ")" : "ForwardRef");
901
+ return type;
902
+ case REACT_MEMO_TYPE:
903
+ return innerType = type.displayName || null, innerType !== null ? innerType : getComponentNameFromType(type.type) || "Memo";
904
+ case REACT_LAZY_TYPE:
905
+ innerType = type._payload;
906
+ type = type._init;
907
+ try {
908
+ return getComponentNameFromType(type(innerType));
909
+ } catch (x) {}
910
+ }
911
+ return null;
912
+ }
913
+ function testStringCoercion(value) {
914
+ return "" + value;
915
+ }
916
+ function checkKeyStringCoercion(value) {
917
+ try {
918
+ testStringCoercion(value);
919
+ var JSCompiler_inline_result = false;
920
+ } catch (e) {
921
+ JSCompiler_inline_result = true;
922
+ }
923
+ if (JSCompiler_inline_result) {
924
+ JSCompiler_inline_result = console;
925
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
926
+ var JSCompiler_inline_result$jscomp$0 = typeof Symbol === "function" && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
927
+ JSCompiler_temp_const.call(JSCompiler_inline_result, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", JSCompiler_inline_result$jscomp$0);
928
+ return testStringCoercion(value);
929
+ }
930
+ }
931
+ function getTaskName(type) {
932
+ if (type === REACT_FRAGMENT_TYPE)
933
+ return "<>";
934
+ if (typeof type === "object" && type !== null && type.$$typeof === REACT_LAZY_TYPE)
935
+ return "<...>";
936
+ try {
937
+ var name = getComponentNameFromType(type);
938
+ return name ? "<" + name + ">" : "<...>";
939
+ } catch (x) {
940
+ return "<...>";
941
+ }
942
+ }
943
+ function getOwner() {
944
+ var dispatcher = ReactSharedInternals.A;
945
+ return dispatcher === null ? null : dispatcher.getOwner();
946
+ }
947
+ function UnknownOwner() {
948
+ return Error("react-stack-top-frame");
949
+ }
950
+ function hasValidKey(config) {
951
+ if (hasOwnProperty.call(config, "key")) {
952
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
953
+ if (getter && getter.isReactWarning)
954
+ return false;
955
+ }
956
+ return config.key !== undefined;
957
+ }
958
+ function defineKeyPropWarningGetter(props, displayName) {
959
+ function warnAboutAccessingKey() {
960
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", displayName));
961
+ }
962
+ warnAboutAccessingKey.isReactWarning = true;
963
+ Object.defineProperty(props, "key", {
964
+ get: warnAboutAccessingKey,
965
+ configurable: true
966
+ });
967
+ }
968
+ function elementRefGetterWithDeprecationWarning() {
969
+ var componentName = getComponentNameFromType(this.type);
970
+ didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."));
971
+ componentName = this.props.ref;
972
+ return componentName !== undefined ? componentName : null;
973
+ }
974
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
975
+ var refProp = props.ref;
976
+ type = {
977
+ $$typeof: REACT_ELEMENT_TYPE,
978
+ type,
979
+ key,
980
+ props,
981
+ _owner: owner
982
+ };
983
+ (refProp !== undefined ? refProp : null) !== null ? Object.defineProperty(type, "ref", {
984
+ enumerable: false,
985
+ get: elementRefGetterWithDeprecationWarning
986
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
987
+ type._store = {};
988
+ Object.defineProperty(type._store, "validated", {
989
+ configurable: false,
990
+ enumerable: false,
991
+ writable: true,
992
+ value: 0
993
+ });
994
+ Object.defineProperty(type, "_debugInfo", {
995
+ configurable: false,
996
+ enumerable: false,
997
+ writable: true,
998
+ value: null
999
+ });
1000
+ Object.defineProperty(type, "_debugStack", {
1001
+ configurable: false,
1002
+ enumerable: false,
1003
+ writable: true,
1004
+ value: debugStack
1005
+ });
1006
+ Object.defineProperty(type, "_debugTask", {
1007
+ configurable: false,
1008
+ enumerable: false,
1009
+ writable: true,
1010
+ value: debugTask
1011
+ });
1012
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
1013
+ return type;
1014
+ }
1015
+ function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
1016
+ var children = config.children;
1017
+ if (children !== undefined)
1018
+ if (isStaticChildren)
1019
+ if (isArrayImpl(children)) {
1020
+ for (isStaticChildren = 0;isStaticChildren < children.length; isStaticChildren++)
1021
+ validateChildKeys(children[isStaticChildren]);
1022
+ Object.freeze && Object.freeze(children);
1023
+ } else
1024
+ console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
1025
+ else
1026
+ validateChildKeys(children);
1027
+ if (hasOwnProperty.call(config, "key")) {
1028
+ children = getComponentNameFromType(type);
1029
+ var keys = Object.keys(config).filter(function(k) {
1030
+ return k !== "key";
1031
+ });
1032
+ isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
1033
+ didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(`A props object containing a "key" prop is being spread into JSX:
1034
+ let props = %s;
1035
+ <%s {...props} />
1036
+ React keys must be passed directly to JSX without using spread:
1037
+ let props = %s;
1038
+ <%s key={someKey} {...props} />`, isStaticChildren, children, keys, children), didWarnAboutKeySpread[children + isStaticChildren] = true);
1039
+ }
1040
+ children = null;
1041
+ maybeKey !== undefined && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
1042
+ hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
1043
+ if ("key" in config) {
1044
+ maybeKey = {};
1045
+ for (var propName in config)
1046
+ propName !== "key" && (maybeKey[propName] = config[propName]);
1047
+ } else
1048
+ maybeKey = config;
1049
+ children && defineKeyPropWarningGetter(maybeKey, typeof type === "function" ? type.displayName || type.name || "Unknown" : type);
1050
+ return ReactElement(type, children, maybeKey, getOwner(), debugStack, debugTask);
1051
+ }
1052
+ function validateChildKeys(node) {
1053
+ isValidElement(node) ? node._store && (node._store.validated = 1) : typeof node === "object" && node !== null && node.$$typeof === REACT_LAZY_TYPE && (node._payload.status === "fulfilled" ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
1054
+ }
1055
+ function isValidElement(object) {
1056
+ return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1057
+ }
1058
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React2.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
1059
+ return null;
1060
+ };
1061
+ React2 = {
1062
+ react_stack_bottom_frame: function(callStackForError) {
1063
+ return callStackForError();
1064
+ }
1065
+ };
1066
+ var specialPropKeyWarningShown;
1067
+ var didWarnAboutElementRef = {};
1068
+ var unknownOwnerDebugStack = React2.react_stack_bottom_frame.bind(React2, UnknownOwner)();
1069
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
1070
+ var didWarnAboutKeySpread = {};
1071
+ exports.Fragment = REACT_FRAGMENT_TYPE;
1072
+ exports.jsxDEV = function(type, config, maybeKey, isStaticChildren) {
1073
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
1074
+ return jsxDEVImpl(type, config, maybeKey, isStaticChildren, trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack, trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
1075
+ };
1076
+ })();
1077
+ });
1078
+
1079
+ // ../../node_modules/.bun/react@19.2.7/node_modules/react/jsx-dev-runtime.js
1080
+ var require_jsx_dev_runtime = __commonJS((exports, module) => {
1081
+ if (false) {} else {
1082
+ module.exports = require_react_jsx_dev_runtime_development();
1083
+ }
1084
+ });
1085
+
1086
+ // src/auto-import/generator.ts
1087
+ import { mkdirSync, writeFileSync } from "fs";
1088
+ import { join as join2 } from "path";
1089
+
1090
+ // src/auto-import/scanner.ts
1091
+ import { existsSync, readdirSync } from "fs";
1092
+ import { basename, extname, join, relative } from "path";
1093
+ var DEFAULT_EXTENSIONS = [
1094
+ ".ts",
1095
+ ".tsx",
1096
+ ".js",
1097
+ ".jsx"
1098
+ ];
1099
+ function detectKind(filePath) {
1100
+ const lower = filePath.replace(/\\/g, "/").toLowerCase();
1101
+ if (lower.includes("/stores/") || lower.endsWith(".store.ts") || lower.endsWith(".store.tsx")) {
1102
+ return "store";
1103
+ }
1104
+ if (lower.includes("/schemas/") || lower.endsWith(".schema.ts") || lower.endsWith(".schema.tsx")) {
1105
+ return "schema";
1106
+ }
1107
+ if (lower.includes("/components/")) {
1108
+ return "component";
1109
+ }
1110
+ const fileName = basename(lower);
1111
+ if (fileName.startsWith("use")) {
1112
+ return "hook";
1113
+ }
1114
+ if (lower.includes("/lib/") || lower.includes("/utils/") || lower.includes("/helpers/")) {
1115
+ return "utils";
1116
+ }
1117
+ return "unknown";
1118
+ }
1119
+ function toPascalCase(text) {
1120
+ return text.replace(/[-_.]/g, " ").replace(/\s+(.)/g, (_match, char) => char.toUpperCase()).replace(/^(.)/, (_match, char) => char.toUpperCase());
1121
+ }
1122
+ function deriveExportName(filePath, dirPath) {
1123
+ const relativePath = relative(dirPath, filePath).replace(/\\/g, "/");
1124
+ const withoutExtension = relativePath.replace(/\.(ts|tsx|js|jsx)$/, "").replace(/\/index$/, "");
1125
+ return toPascalCase(withoutExtension.replace(/\//g, "_"));
1126
+ }
1127
+ function walkDirectory(dirPath, extensions) {
1128
+ if (!existsSync(dirPath)) {
1129
+ return [];
1130
+ }
1131
+ const collected = [];
1132
+ function walk(currentPath) {
1133
+ const entries = readdirSync(currentPath, {
1134
+ withFileTypes: true
1135
+ });
1136
+ for (const entry of entries) {
1137
+ if (entry.name.startsWith(".") || entry.name === "node_modules") {
1138
+ continue;
1139
+ }
1140
+ const fullPath = join(currentPath, entry.name);
1141
+ if (entry.isDirectory()) {
1142
+ walk(fullPath);
1143
+ continue;
1144
+ }
1145
+ if (entry.isFile() && extensions.includes(extname(entry.name))) {
1146
+ collected.push(fullPath);
1147
+ }
1148
+ }
1149
+ }
1150
+ walk(dirPath);
1151
+ return collected;
1152
+ }
1153
+ function scanForExports(options) {
1154
+ const extensions = options.extensions ?? DEFAULT_EXTENSIONS;
1155
+ const discovered = [];
1156
+ const outputAbs = join(options.frontendRoot, options.outputDirectory);
1157
+ for (const directory of options.directories) {
1158
+ const directoryAbs = join(options.frontendRoot, directory);
1159
+ const files = walkDirectory(directoryAbs, extensions);
1160
+ for (const filePath of files) {
1161
+ const relativeFromOutput = relative(outputAbs, filePath).replace(/\\/g, "/").replace(/\.(ts|tsx)$/, "");
1162
+ const importPath = relativeFromOutput.startsWith(".") ? relativeFromOutput : `./${relativeFromOutput}`;
1163
+ discovered.push({
1164
+ name: deriveExportName(filePath, directoryAbs),
1165
+ filePath: relative(options.frontendRoot, filePath).replace(/\\/g, "/"),
1166
+ importPath,
1167
+ kind: detectKind(filePath)
1168
+ });
1169
+ }
1170
+ }
1171
+ return discovered;
1172
+ }
1173
+
1174
+ // src/auto-import/generator.ts
1175
+ var GENERATED_HEADER = `// This file is auto-generated by: bun rakta imports:generate
1176
+ // Do not edit manually. Re-generate whenever you add or remove files.
1177
+ // Note: Rakta Auto Import v0.1.0 produces a typed re-export layer.
1178
+ // Import from this file in your app code:
1179
+ // import { useCounterStore, http } from "./.rakta/auto-imports";
1180
+ `;
1181
+ function buildImportLines(exports) {
1182
+ if (exports.length === 0) {
1183
+ return `// No exports discovered. Check your autoImport.directories config.
1184
+ `;
1185
+ }
1186
+ return exports.map((discoveredExport) => `export * from "${discoveredExport.importPath}";`).join(`
1187
+ `);
1188
+ }
1189
+ function generateAutoImports(options) {
1190
+ const exports = scanForExports({
1191
+ frontendRoot: options.frontendRoot,
1192
+ directories: options.directories,
1193
+ outputDirectory: options.outputDirectory,
1194
+ ...options.extensions ? {
1195
+ extensions: options.extensions
1196
+ } : {}
1197
+ });
1198
+ const outputDir = join2(options.frontendRoot, options.outputDirectory);
1199
+ mkdirSync(outputDir, {
1200
+ recursive: true
1201
+ });
1202
+ const tsContent = `${GENERATED_HEADER}
1203
+ ${buildImportLines(exports)}
1204
+ `;
1205
+ writeFileSync(join2(outputDir, "auto-imports.ts"), tsContent, "utf-8");
1206
+ if (options.generateDts) {
1207
+ const dtsContent = tsContent.replace("// This file is auto-generated by: bun rakta imports:generate", "// Type declarations \u2014 auto-generated by: bun rakta imports:generate");
1208
+ writeFileSync(join2(outputDir, "auto-imports.d.ts"), dtsContent, "utf-8");
1209
+ }
1210
+ return {
1211
+ generatedAt: new Date().toISOString(),
1212
+ sourceDirectories: options.directories,
1213
+ exports
1214
+ };
1215
+ }
1216
+ function printAutoImportSummary(manifest) {
1217
+ console.log(`
1218
+ Rakta Auto Import`);
1219
+ console.log(` ${"\u2500".repeat(50)}`);
1220
+ console.log(`Generated: ${manifest.generatedAt}`);
1221
+ console.log(`Exports: ${manifest.exports.length}`);
1222
+ if (manifest.exports.length > 0) {
1223
+ console.log("");
1224
+ for (const discoveredExport of manifest.exports) {
1225
+ console.log(`[${discoveredExport.kind.padEnd(10)}] ${discoveredExport.name} <- ${discoveredExport.filePath}`);
1226
+ }
1227
+ }
1228
+ console.log(` ${"\u2500".repeat(50)}
1229
+ `);
1230
+ }
1231
+ // src/components/Click.tsx
1232
+ var import_react = __toESM(require_react(), 1);
1233
+ function isModifiedEvent(event) {
1234
+ return event.metaKey || event.altKey || event.ctrlKey || event.shiftKey;
1235
+ }
1236
+ function isExternalTo(to) {
1237
+ return to.startsWith("http://") || to.startsWith("https://") || to.startsWith("//") || to.startsWith("mailto:") || to.startsWith("tel:");
1238
+ }
1239
+ function getCurrentPathname() {
1240
+ if (typeof window === "undefined") {
1241
+ return "/";
1242
+ }
1243
+ return window.location.pathname;
1244
+ }
1245
+ function getCleanPathname(to) {
1246
+ const [pathname] = to.split(/[?#]/);
1247
+ if (pathname && pathname.length > 0) {
1248
+ return pathname;
1249
+ }
1250
+ return "/";
1251
+ }
1252
+ function getPathnameFromTo(to) {
1253
+ const cleanPathname = getCleanPathname(to);
1254
+ if (typeof window === "undefined") {
1255
+ return cleanPathname;
1256
+ }
1257
+ try {
1258
+ return new URL(to, window.location.origin).pathname;
1259
+ } catch {
1260
+ return cleanPathname;
1261
+ }
1262
+ }
1263
+ function createNavigationState(to) {
1264
+ return {
1265
+ source: "rakta-click",
1266
+ to
1267
+ };
1268
+ }
1269
+ function navigate(to, shouldReplace) {
1270
+ if (typeof window === "undefined") {
1271
+ return;
1272
+ }
1273
+ const navigationState = createNavigationState(to);
1274
+ if (shouldReplace) {
1275
+ window.history.replaceState(navigationState, "", to);
1276
+ } else {
1277
+ window.history.pushState(navigationState, "", to);
1278
+ }
1279
+ window.dispatchEvent(new PopStateEvent("popstate", {
1280
+ state: navigationState
1281
+ }));
1282
+ }
1283
+ function openExternalTo(to, target) {
1284
+ if (typeof window === "undefined") {
1285
+ return;
1286
+ }
1287
+ if (target === "_blank") {
1288
+ window.open(to, "_blank", "noopener,noreferrer");
1289
+ return;
1290
+ }
1291
+ window.location.assign(to);
1292
+ }
1293
+ function prefetchPage(to) {
1294
+ if (typeof window === "undefined" || typeof document === "undefined") {
1295
+ return;
1296
+ }
1297
+ const targetUrl = new URL(to, window.location.origin).href;
1298
+ const existingLinks = Array.from(document.querySelectorAll('link[rel="prefetch"]'));
1299
+ const alreadyPrefetched = existingLinks.some((link2) => link2.href === targetUrl);
1300
+ if (alreadyPrefetched) {
1301
+ return;
1302
+ }
1303
+ const link = document.createElement("link");
1304
+ link.rel = "prefetch";
1305
+ link.href = targetUrl;
1306
+ link.as = "document";
1307
+ document.head.appendChild(link);
1308
+ }
1309
+ function mergeClassNames(className, activeClassName, isActive) {
1310
+ const classNames = [];
1311
+ if (className && className.length > 0) {
1312
+ classNames.push(className);
1313
+ }
1314
+ if (isActive && activeClassName && activeClassName.length > 0) {
1315
+ classNames.push(activeClassName);
1316
+ }
1317
+ return classNames.join(" ");
1318
+ }
1319
+ function applyClassName(clickAttributes, className) {
1320
+ if (className.length === 0) {
1321
+ return;
1322
+ }
1323
+ clickAttributes.className = className;
1324
+ }
1325
+ function applyStyle(clickAttributes, style) {
1326
+ if (!style) {
1327
+ return;
1328
+ }
1329
+ clickAttributes.style = style;
1330
+ }
1331
+ function applyInternalAttributes(clickAttributes, target, rel, isActive) {
1332
+ if (target) {
1333
+ clickAttributes.target = target;
1334
+ }
1335
+ if (rel && rel.length > 0) {
1336
+ clickAttributes.rel = rel;
1337
+ }
1338
+ if (isActive) {
1339
+ clickAttributes["aria-current"] = "page";
1340
+ }
1341
+ }
1342
+ function applyExternalAttributes(clickAttributes, target, rel) {
1343
+ clickAttributes.target = target ?? "_blank";
1344
+ clickAttributes.rel = rel && rel.length > 0 ? rel : "noopener noreferrer";
1345
+ }
1346
+ function renderClickElement(attributes, children) {
1347
+ return import_react.default.createElement("click", attributes, children);
1348
+ }
1349
+ function Click({
1350
+ to,
1351
+ prefetch = false,
1352
+ replace = false,
1353
+ activeClassName,
1354
+ className,
1355
+ children,
1356
+ onClick,
1357
+ onKeyDown,
1358
+ style,
1359
+ target,
1360
+ rel,
1361
+ ...restAttributes
1362
+ }) {
1363
+ const isExternal = isExternalTo(to);
1364
+ const isActive = !isExternal && getCurrentPathname() === getPathnameFromTo(to);
1365
+ const resolvedClassName = mergeClassNames(className, activeClassName, isActive);
1366
+ import_react.useEffect(() => {
1367
+ if (!prefetch || isExternal) {
1368
+ return;
1369
+ }
1370
+ prefetchPage(to);
1371
+ }, [prefetch, isExternal, to]);
1372
+ const handleClick = import_react.useCallback((event) => {
1373
+ onClick?.(event);
1374
+ if (event.defaultPrevented || isModifiedEvent(event)) {
1375
+ return;
1376
+ }
1377
+ if (isExternal) {
1378
+ event.preventDefault();
1379
+ openExternalTo(to, target ?? "_blank");
1380
+ return;
1381
+ }
1382
+ if (target === "_blank") {
1383
+ return;
1384
+ }
1385
+ event.preventDefault();
1386
+ navigate(to, replace);
1387
+ }, [isExternal, onClick, replace, target, to]);
1388
+ const handleKeyDown = import_react.useCallback((event) => {
1389
+ onKeyDown?.(event);
1390
+ if (event.defaultPrevented || event.key !== "Enter") {
1391
+ return;
1392
+ }
1393
+ if (isExternal) {
1394
+ event.preventDefault();
1395
+ openExternalTo(to, target ?? "_blank");
1396
+ return;
1397
+ }
1398
+ if (target === "_blank") {
1399
+ return;
1400
+ }
1401
+ event.preventDefault();
1402
+ navigate(to, replace);
1403
+ }, [isExternal, onKeyDown, replace, target, to]);
1404
+ const clickAttributes = {
1405
+ ...restAttributes,
1406
+ to,
1407
+ onClick: handleClick,
1408
+ onKeyDown: handleKeyDown
1409
+ };
1410
+ applyClassName(clickAttributes, resolvedClassName);
1411
+ applyStyle(clickAttributes, style);
1412
+ if (isExternal) {
1413
+ applyExternalAttributes(clickAttributes, target, rel);
1414
+ } else {
1415
+ applyInternalAttributes(clickAttributes, target, rel, isActive);
1416
+ }
1417
+ return renderClickElement(clickAttributes, children);
1418
+ }
1419
+ // src/components/Picture.tsx
1420
+ var import_react2 = __toESM(require_react(), 1);
1421
+ var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
1422
+ function Picture({
1423
+ path,
1424
+ alt,
1425
+ title,
1426
+ height,
1427
+ width,
1428
+ blurDataURL,
1429
+ onLoadComplete,
1430
+ onError,
1431
+ className,
1432
+ style,
1433
+ loading = "lazy",
1434
+ responsive = true,
1435
+ objectFit = "cover",
1436
+ priority = false,
1437
+ ...rest
1438
+ }) {
1439
+ const [isLoaded, setIsLoaded] = import_react2.useState(false);
1440
+ const [hasError, setHasError] = import_react2.useState(false);
1441
+ const imageRef = import_react2.useRef(null);
1442
+ const pictureRef = import_react2.useRef(null);
1443
+ const resolvedLoading = priority ? "eager" : loading === "auto" ? "lazy" : loading;
1444
+ import_react2.useEffect(() => {
1445
+ const imageElement = imageRef.current;
1446
+ if (imageElement?.complete) {
1447
+ setIsLoaded(true);
1448
+ onLoadComplete?.();
1449
+ }
1450
+ }, [onLoadComplete]);
1451
+ const handleLoad = import_react2.useCallback(() => {
1452
+ setIsLoaded(true);
1453
+ onLoadComplete?.();
1454
+ }, [onLoadComplete]);
1455
+ const handleError = import_react2.useCallback(() => {
1456
+ setHasError(true);
1457
+ onError?.();
1458
+ }, [onError]);
1459
+ const resolvedPath = hasError && blurDataURL ? blurDataURL : path;
1460
+ const resolvedWidth = responsive ? "100%" : width ?? "auto";
1461
+ const wrapperStyle = {
1462
+ position: "relative",
1463
+ display: "inline-block",
1464
+ overflow: "hidden",
1465
+ height: height ?? "auto",
1466
+ width: resolvedWidth
1467
+ };
1468
+ const imageStyle = {
1469
+ display: "block",
1470
+ height: height ?? undefined,
1471
+ width: resolvedWidth,
1472
+ minHeight: height ?? undefined,
1473
+ objectFit,
1474
+ transition: blurDataURL ? "filter 0.3s ease" : undefined,
1475
+ filter: blurDataURL && !isLoaded && !hasError ? "blur(12px) brightness(1.05)" : "none",
1476
+ ...style
1477
+ };
1478
+ if (blurDataURL) {
1479
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV("div", {
1480
+ style: {
1481
+ ...wrapperStyle,
1482
+ backgroundImage: `url(${blurDataURL})`,
1483
+ backgroundSize: "cover",
1484
+ backgroundPosition: "center"
1485
+ },
1486
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV("picture", {
1487
+ ref: pictureRef,
1488
+ className,
1489
+ ...rest,
1490
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV("img", {
1491
+ ref: imageRef,
1492
+ src: resolvedPath,
1493
+ alt,
1494
+ "aria-label": alt,
1495
+ title,
1496
+ loading: resolvedLoading,
1497
+ decoding: priority ? "sync" : "async",
1498
+ style: imageStyle,
1499
+ onLoad: handleLoad,
1500
+ onError: handleError
1501
+ }, undefined, false, undefined, this)
1502
+ }, undefined, false, undefined, this)
1503
+ }, undefined, false, undefined, this);
1504
+ }
1505
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV("picture", {
1506
+ ref: pictureRef,
1507
+ className,
1508
+ ...rest,
1509
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV("img", {
1510
+ ref: imageRef,
1511
+ src: resolvedPath,
1512
+ alt,
1513
+ "aria-label": alt,
1514
+ title,
1515
+ loading: resolvedLoading,
1516
+ decoding: priority ? "sync" : "async",
1517
+ style: imageStyle,
1518
+ onLoad: handleLoad,
1519
+ onError: handleError
1520
+ }, undefined, false, undefined, this)
1521
+ }, undefined, false, undefined, this);
1522
+ }
1523
+ // src/config/defineConfig.ts
1524
+ function defineConfig(config) {
1525
+ return config;
1526
+ }
1527
+ var defineRaktaConfig = defineConfig;
1528
+ var defaultConfig = {
1529
+ appName: "Rakta.js App",
1530
+ appDir: "app",
1531
+ publicDir: "public",
1532
+ port: 3000,
1533
+ css: {
1534
+ framework: "tailwind"
1535
+ },
1536
+ seo: {
1537
+ defaultTitle: "Rakta.js App",
1538
+ titleTemplate: "%s | Rakta.js App",
1539
+ defaultDescription: "Built with Rakta.js",
1540
+ siteUrl: "http://localhost:3000"
1541
+ },
1542
+ server: {
1543
+ port: 3000,
1544
+ hostname: "0.0.0.0",
1545
+ cors: true,
1546
+ compression: false,
1547
+ trustProxy: false
1548
+ },
1549
+ build: {
1550
+ entryPoint: "entry.client.tsx",
1551
+ outDir: "dist",
1552
+ sourcemap: false,
1553
+ minify: true,
1554
+ splitting: false,
1555
+ target: "browser"
1556
+ },
1557
+ autoImport: {
1558
+ enabled: false,
1559
+ directories: ["components", "lib", "stores", "schemas"],
1560
+ outputDirectory: ".rakta",
1561
+ extensions: [".ts", ".tsx", ".js", ".jsx"],
1562
+ dts: true
1563
+ },
1564
+ rpc: {
1565
+ enabled: false,
1566
+ basePath: "/rpc",
1567
+ maxBodySize: 1048576
1568
+ },
1569
+ render: {
1570
+ defaultMode: "csr",
1571
+ routes: {}
1572
+ }
1573
+ };
1574
+ // src/config/loadConfig.ts
1575
+ import { existsSync as existsSync2 } from "fs";
1576
+ import { join as join3, resolve } from "path";
1577
+ var CONFIG_FILENAMES = [
1578
+ "rakta.config.ts",
1579
+ "rakta.config.js",
1580
+ "rakta.config.mts",
1581
+ "rakta.config.mjs"
1582
+ ];
1583
+ async function loadConfig(cwd = process.cwd()) {
1584
+ const resolvedCwd = resolve(cwd);
1585
+ for (const filename of CONFIG_FILENAMES) {
1586
+ const configPath = join3(resolvedCwd, filename);
1587
+ if (!existsSync2(configPath)) {
1588
+ continue;
1589
+ }
1590
+ const configModule = await import(configPath);
1591
+ const userConfig = configModule.default ?? {};
1592
+ return mergeConfig(defaultConfig, userConfig);
1593
+ }
1594
+ return defaultConfig;
1595
+ }
1596
+ function mergeConfig(baseConfig, overrideConfig) {
1597
+ return {
1598
+ appName: overrideConfig.appName ?? baseConfig.appName,
1599
+ appDir: overrideConfig.appDir ?? baseConfig.appDir,
1600
+ publicDir: overrideConfig.publicDir ?? baseConfig.publicDir,
1601
+ port: overrideConfig.port ?? baseConfig.port,
1602
+ css: overrideConfig.css !== undefined ? { ...baseConfig.css, ...overrideConfig.css } : baseConfig.css,
1603
+ seo: overrideConfig.seo !== undefined ? { ...baseConfig.seo, ...overrideConfig.seo } : baseConfig.seo,
1604
+ server: overrideConfig.server !== undefined ? { ...baseConfig.server, ...overrideConfig.server } : baseConfig.server,
1605
+ build: overrideConfig.build !== undefined ? { ...baseConfig.build, ...overrideConfig.build } : baseConfig.build,
1606
+ autoImport: overrideConfig.autoImport !== undefined ? { ...baseConfig.autoImport, ...overrideConfig.autoImport } : baseConfig.autoImport,
1607
+ rpc: overrideConfig.rpc !== undefined ? { ...baseConfig.rpc, ...overrideConfig.rpc } : baseConfig.rpc,
1608
+ render: overrideConfig.render !== undefined ? {
1609
+ defaultMode: overrideConfig.render.defaultMode ?? baseConfig.render.defaultMode,
1610
+ routes: {
1611
+ ...baseConfig.render.routes,
1612
+ ...overrideConfig.render.routes
1613
+ }
1614
+ } : baseConfig.render
1615
+ };
1616
+ }
1617
+ // src/forge/build.ts
1618
+ import { mkdirSync as mkdirSync2 } from "fs";
1619
+ import { join as join5, resolve as resolve2 } from "path";
1620
+
1621
+ // src/router/manifest.ts
1622
+ import { existsSync as existsSync4, readFileSync, writeFileSync as writeFileSync2 } from "fs";
1623
+
1624
+ // src/router/scanner.ts
1625
+ import { existsSync as existsSync3, readdirSync as readdirSync2, statSync } from "fs";
1626
+ import { join as join4, relative as relative2 } from "path";
1627
+ var FILE_TO_KIND = {
1628
+ "page.tsx": "page",
1629
+ "page.ts": "page",
1630
+ "page.jsx": "page",
1631
+ "page.js": "page",
1632
+ "layout.tsx": "layout",
1633
+ "layout.ts": "layout",
1634
+ "layout.jsx": "layout",
1635
+ "layout.js": "layout",
1636
+ "loading.tsx": "loading",
1637
+ "loading.ts": "loading",
1638
+ "loading.jsx": "loading",
1639
+ "loading.js": "loading",
1640
+ "notFound.tsx": "notFound",
1641
+ "notFound.ts": "notFound",
1642
+ "notFound.jsx": "notFound",
1643
+ "notFound.js": "notFound",
1644
+ "error.tsx": "error",
1645
+ "error.ts": "error",
1646
+ "error.jsx": "error",
1647
+ "error.js": "error",
1648
+ "route.ts": "api",
1649
+ "route.js": "api"
1650
+ };
1651
+ function parseSegment(raw) {
1652
+ const isDynamic = raw.startsWith("[") && raw.endsWith("]");
1653
+ const paramName = isDynamic ? raw.slice(1, -1) : "";
1654
+ return { raw, isDynamic, paramName };
1655
+ }
1656
+ function collectParamNames(segments) {
1657
+ return segments.filter((segment) => segment.isDynamic && segment.paramName.length > 0).map((segment) => segment.paramName);
1658
+ }
1659
+ function segmentsToUrlPattern(segments) {
1660
+ if (segments.length === 0)
1661
+ return "/";
1662
+ const parts = segments.map((segment) => segment.isDynamic && segment.paramName ? `:${segment.paramName}` : segment.raw);
1663
+ return `/${parts.join("/")}`;
1664
+ }
1665
+ function scanDirectory(dirPath, appRoot, results) {
1666
+ if (!existsSync3(dirPath))
1667
+ return;
1668
+ const entries = readdirSync2(dirPath);
1669
+ for (const entryName of entries) {
1670
+ const fullPath = join4(dirPath, entryName);
1671
+ const stats = statSync(fullPath);
1672
+ if (stats.isDirectory()) {
1673
+ scanDirectory(fullPath, appRoot, results);
1674
+ continue;
1675
+ }
1676
+ if (!stats.isFile())
1677
+ continue;
1678
+ const kind = FILE_TO_KIND[entryName];
1679
+ if (!kind)
1680
+ continue;
1681
+ const relativePath = relative2(appRoot, fullPath).replace(/\\/g, "/");
1682
+ const dirRelative = relative2(appRoot, dirPath).replace(/\\/g, "/");
1683
+ const rawSegments = dirRelative === "" ? [] : dirRelative.split("/");
1684
+ const segments = rawSegments.map(parseSegment);
1685
+ const urlPattern = segmentsToUrlPattern(segments);
1686
+ const paramNames = collectParamNames(segments);
1687
+ const isDynamic = paramNames.length > 0;
1688
+ results.push({
1689
+ filePath: relativePath,
1690
+ urlPattern,
1691
+ kind,
1692
+ segments,
1693
+ isDynamic,
1694
+ paramNames
1695
+ });
1696
+ }
1697
+ }
1698
+ function scanRoutes(options) {
1699
+ const results = [];
1700
+ scanDirectory(options.appDir, options.appDir, results);
1701
+ results.sort((routeA, routeB) => {
1702
+ if (routeA.isDynamic !== routeB.isDynamic) {
1703
+ return routeA.isDynamic ? 1 : -1;
1704
+ }
1705
+ return routeA.urlPattern.localeCompare(routeB.urlPattern);
1706
+ });
1707
+ return results;
1708
+ }
1709
+
1710
+ // src/router/manifest.ts
1711
+ function generateManifest(appDir) {
1712
+ const routes = scanRoutes({ appDir });
1713
+ const manifest = {
1714
+ version: "1",
1715
+ generatedAt: new Date().toISOString(),
1716
+ routes
1717
+ };
1718
+ return manifest;
1719
+ }
1720
+ function writeManifest(manifest, outputPath) {
1721
+ writeFileSync2(outputPath, JSON.stringify(manifest, null, 2), "utf-8");
1722
+ }
1723
+ function readManifest(manifestPath) {
1724
+ if (!existsSync4(manifestPath))
1725
+ return null;
1726
+ const raw = readFileSync(manifestPath, "utf-8");
1727
+ const parsed = JSON.parse(raw);
1728
+ if (typeof parsed !== "object" || parsed === null || !("version" in parsed) || !("routes" in parsed)) {
1729
+ return null;
1730
+ }
1731
+ return parsed;
1732
+ }
1733
+ function printManifest(manifest) {
1734
+ const pageRoutes = manifest.routes.filter((route) => route.kind === "page");
1735
+ const apiRoutes = manifest.routes.filter((route) => route.kind === "api");
1736
+ const layoutRoutes = manifest.routes.filter((route) => route.kind === "layout");
1737
+ const specialRoutes = manifest.routes.filter((route) => ["loading", "not-found", "error"].includes(route.kind));
1738
+ const line = "\u2500".repeat(56);
1739
+ console.log(`
1740
+ Rakta.js Route Manifest`);
1741
+ console.log(` ${line}`);
1742
+ console.log(` Generated: ${manifest.generatedAt}`);
1743
+ console.log(` Total: ${manifest.routes.length} routes
1744
+ `);
1745
+ if (pageRoutes.length > 0) {
1746
+ console.log(" Pages:");
1747
+ for (const route of pageRoutes) {
1748
+ const dynamic = route.isDynamic ? ` [params: ${route.paramNames.join(", ")}]` : "";
1749
+ console.log(` GET ${route.urlPattern}${dynamic}`);
1750
+ }
1751
+ console.log("");
1752
+ }
1753
+ if (apiRoutes.length > 0) {
1754
+ console.log(" API Routes:");
1755
+ for (const route of apiRoutes) {
1756
+ const dynamic = route.isDynamic ? ` [params: ${route.paramNames.join(", ")}]` : "";
1757
+ console.log(` ANY ${route.urlPattern}${dynamic}`);
1758
+ }
1759
+ console.log("");
1760
+ }
1761
+ if (layoutRoutes.length > 0) {
1762
+ console.log(" Layouts:");
1763
+ for (const route of layoutRoutes) {
1764
+ console.log(` ${route.urlPattern === "/" ? "root" : route.urlPattern}`);
1765
+ }
1766
+ console.log("");
1767
+ }
1768
+ if (specialRoutes.length > 0) {
1769
+ console.log(" Special:");
1770
+ for (const route of specialRoutes) {
1771
+ console.log(` [${route.kind}] ${route.filePath}`);
1772
+ }
1773
+ console.log("");
1774
+ }
1775
+ console.log(` ${line}
1776
+ `);
1777
+ }
1778
+
1779
+ // src/forge/build.ts
1780
+ async function buildProject(options) {
1781
+ const startMs = Date.now();
1782
+ const artifacts = [];
1783
+ const errors = [];
1784
+ mkdirSync2(resolve2(options.outDir), { recursive: true });
1785
+ const manifest = generateManifest(options.appDir);
1786
+ const manifestPath = join5(options.outDir, "route-manifest.json");
1787
+ writeManifest(manifest, manifestPath);
1788
+ const manifestContent = JSON.stringify(manifest);
1789
+ artifacts.push({
1790
+ outputPath: manifestPath,
1791
+ sizeBytes: new TextEncoder().encode(manifestContent).byteLength,
1792
+ kind: "manifest"
1793
+ });
1794
+ const buildResult = await Bun.build({
1795
+ entrypoints: [options.entryPoint],
1796
+ outdir: options.outDir,
1797
+ target: options.target,
1798
+ minify: options.minify,
1799
+ sourcemap: options.sourcemap ? "external" : "none",
1800
+ splitting: options.splitting,
1801
+ naming: {
1802
+ entry: "[name].[ext]",
1803
+ chunk: "chunks/[name]-[hash].[ext]",
1804
+ asset: "assets/[name]-[hash].[ext]"
1805
+ }
1806
+ });
1807
+ if (!buildResult.success) {
1808
+ for (const log of buildResult.logs) {
1809
+ errors.push(log.message);
1810
+ }
1811
+ return {
1812
+ success: false,
1813
+ artifacts,
1814
+ manifest,
1815
+ buildMs: Date.now() - startMs,
1816
+ errors
1817
+ };
1818
+ }
1819
+ for (const output of buildResult.outputs) {
1820
+ artifacts.push({
1821
+ outputPath: output.path,
1822
+ sizeBytes: output.size,
1823
+ kind: output.path.endsWith(".css") ? "stylesheet" : "script"
1824
+ });
1825
+ }
1826
+ return {
1827
+ success: true,
1828
+ artifacts,
1829
+ manifest,
1830
+ buildMs: Date.now() - startMs,
1831
+ errors: []
1832
+ };
1833
+ }
1834
+ // src/forge/devServer.ts
1835
+ import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
1836
+ import { join as join6 } from "path";
1837
+
1838
+ // src/render/modes.ts
1839
+ var RENDER_MODE_DESCRIPTORS = {
1840
+ csr: {
1841
+ mode: "csr",
1842
+ label: "Client-Side Rendering",
1843
+ shortLabel: "CSR",
1844
+ description: "React renders entirely in the browser. The server sends a minimal HTML shell with a JS bundle. No server required at runtime.",
1845
+ serverRequired: false,
1846
+ buildTimeGenerated: false,
1847
+ clientHydration: true,
1848
+ roadmap: false
1849
+ },
1850
+ ssr: {
1851
+ mode: "ssr",
1852
+ label: "Server-Side Rendering",
1853
+ shortLabel: "SSR",
1854
+ description: "React renders to HTML on the server per request. The client receives full HTML and then hydrates. Requires a running Node/Bun server.",
1855
+ serverRequired: true,
1856
+ buildTimeGenerated: false,
1857
+ clientHydration: true,
1858
+ roadmap: true
1859
+ },
1860
+ ssg: {
1861
+ mode: "ssg",
1862
+ label: "Static Site Generation",
1863
+ shortLabel: "SSG",
1864
+ description: "Pages are fully rendered at build time. Output is static HTML files. No server required at runtime.",
1865
+ serverRequired: false,
1866
+ buildTimeGenerated: true,
1867
+ clientHydration: false,
1868
+ roadmap: true
1869
+ },
1870
+ csg: {
1871
+ mode: "csg",
1872
+ label: "Client-Side Generation",
1873
+ shortLabel: "CSG",
1874
+ description: "A static shell is generated at build time, data is fetched and rendered on the client. Combines SSG speed with dynamic data.",
1875
+ serverRequired: false,
1876
+ buildTimeGenerated: true,
1877
+ clientHydration: true,
1878
+ roadmap: true
1879
+ },
1880
+ spa: {
1881
+ mode: "spa",
1882
+ label: "Single Page Application",
1883
+ shortLabel: "SPA",
1884
+ description: "A single HTML entry point is served for all routes. React handles all routing client-side. Equivalent to a standard Vite SPA.",
1885
+ serverRequired: false,
1886
+ buildTimeGenerated: false,
1887
+ clientHydration: true,
1888
+ roadmap: false
1889
+ },
1890
+ hybrid: {
1891
+ mode: "hybrid",
1892
+ label: "Hybrid Rendering",
1893
+ shortLabel: "Hybrid",
1894
+ description: "Different routes use different render modes. Configured via the `render.routes` map in rakta.config.ts. The top-level mode is the fallback.",
1895
+ serverRequired: false,
1896
+ buildTimeGenerated: false,
1897
+ clientHydration: true,
1898
+ roadmap: false
1899
+ }
1900
+ };
1901
+ function pathMatchesPattern(pathname, pattern) {
1902
+ if (pattern === pathname)
1903
+ return true;
1904
+ const patternParts = pattern.split("/");
1905
+ const pathParts = pathname.split("/");
1906
+ if (patternParts.length !== pathParts.length)
1907
+ return false;
1908
+ for (let i = 0;i < patternParts.length; i++) {
1909
+ const pp = patternParts[i];
1910
+ const path = pathParts[i];
1911
+ if (pp === undefined || path === undefined)
1912
+ return false;
1913
+ if (pp.startsWith(":"))
1914
+ continue;
1915
+ if (pp !== path)
1916
+ return false;
1917
+ }
1918
+ return true;
1919
+ }
1920
+ function resolveRouteMode(pathname, config) {
1921
+ const patterns = Object.keys(config.routes).sort((a, b) => b.length - a.length);
1922
+ for (const pattern of patterns) {
1923
+ const overrideMode = config.routes[pattern];
1924
+ if (overrideMode !== undefined && pathMatchesPattern(pathname, pattern)) {
1925
+ return {
1926
+ routePath: pathname,
1927
+ mode: overrideMode,
1928
+ source: "route-override"
1929
+ };
1930
+ }
1931
+ }
1932
+ return {
1933
+ routePath: pathname,
1934
+ mode: config.defaultMode,
1935
+ source: "default"
1936
+ };
1937
+ }
1938
+ function getModeDescriptor(mode) {
1939
+ return RENDER_MODE_DESCRIPTORS[mode];
1940
+ }
1941
+ function isRoadmapMode(mode) {
1942
+ return RENDER_MODE_DESCRIPTORS[mode].roadmap;
1943
+ }
1944
+ function requiresServer(mode) {
1945
+ return RENDER_MODE_DESCRIPTORS[mode].serverRequired;
1946
+ }
1947
+ function isBuildTimeMode(mode) {
1948
+ return RENDER_MODE_DESCRIPTORS[mode].buildTimeGenerated;
1949
+ }
1950
+
1951
+ // src/render/renderer.ts
1952
+ function buildHtmlShell(options) {
1953
+ return `
1954
+ <!DOCTYPE html>
1955
+ <html lang="${options.lang}">
1956
+ <head>
1957
+ <meta charset="UTF-8" />
1958
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
1959
+ <title>
1960
+ ${options.appName}
1961
+ </title>
1962
+ <link rel="stylesheet" href="${options.cssPath}" />
1963
+ </head>
1964
+ <body>
1965
+ <div id="rakta-root"></div>
1966
+ <script type="module" src="${options.scriptPath}"></script>
1967
+ </body>
1968
+ </html>`;
1969
+ }
1970
+ function makeSuccess(html, mode, renderMs, httpStatus = 200, fromCache = false) {
1971
+ return {
1972
+ kind: "success",
1973
+ html,
1974
+ mode,
1975
+ httpStatus,
1976
+ responseHeaders: { "Content-Type": "text/html; charset=utf-8" },
1977
+ fromCache,
1978
+ renderMs
1979
+ };
1980
+ }
1981
+ function makeFailure(reason, mode, httpStatus = 500) {
1982
+ return { kind: "failure", reason, mode, httpStatus };
1983
+ }
1984
+ async function render(context, options) {
1985
+ const startMs = Date.now();
1986
+ if (isRoadmapMode(context.mode)) {
1987
+ console.warn(`[Rakta.js] Render mode "${context.mode}" is a roadmap feature (v0.2.0). ` + `Falling back to CSR for: ${context.routePath}`);
1988
+ return makeSuccess(buildHtmlShell(options), "csr", Date.now() - startMs);
1989
+ }
1990
+ switch (context.mode) {
1991
+ case "csr":
1992
+ case "spa":
1993
+ return makeSuccess(buildHtmlShell(options), context.mode, Date.now() - startMs);
1994
+ case "hybrid":
1995
+ return makeSuccess(buildHtmlShell(options), "csr", Date.now() - startMs);
1996
+ case "ssr":
1997
+ case "ssg":
1998
+ case "csg":
1999
+ return makeFailure(`Render mode "${context.mode}" is not yet implemented.`, context.mode, 501);
2000
+ }
2001
+ }
2002
+ function renderNotFound(options) {
2003
+ return makeSuccess(buildHtmlShell(options), "csr", 0, 404);
2004
+ }
2005
+ function renderServerError(reason, mode) {
2006
+ return makeFailure(reason, mode, 500);
2007
+ }
2008
+
2009
+ // src/router/matcher.ts
2010
+ function escapeRegex(text) {
2011
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2012
+ }
2013
+ function buildPatternRegex(segments) {
2014
+ const paramNames = [];
2015
+ const parts = segments.map((segment) => {
2016
+ if (segment.isDynamic && segment.paramName) {
2017
+ paramNames.push(segment.paramName);
2018
+ return "([^/]+)";
2019
+ }
2020
+ return escapeRegex(segment.raw);
2021
+ });
2022
+ const pattern = parts.length === 0 ? "" : `/${parts.join("/")}`;
2023
+ const regex = new RegExp(`^${pattern || "/"}$`);
2024
+ return { regex, paramNames };
2025
+ }
2026
+ function matchRoute(pathname, routes) {
2027
+ const normalized = pathname !== "/" && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
2028
+ for (const entry of routes) {
2029
+ if (entry.kind !== "page" && entry.kind !== "api")
2030
+ continue;
2031
+ const { regex, paramNames } = buildPatternRegex(entry.segments);
2032
+ const match = regex.exec(normalized);
2033
+ if (!match)
2034
+ continue;
2035
+ const params = {};
2036
+ paramNames.forEach((name, index) => {
2037
+ const captured = match[index + 1];
2038
+ if (captured !== undefined) {
2039
+ params[name] = decodeURIComponent(captured);
2040
+ }
2041
+ });
2042
+ return { entry, params };
2043
+ }
2044
+ return null;
2045
+ }
2046
+ function findLayoutsForPathname(pathname, routes) {
2047
+ const layoutRoutes = routes.filter((route) => route.kind === "layout");
2048
+ return layoutRoutes.filter((layout) => {
2049
+ if (layout.urlPattern === "/")
2050
+ return true;
2051
+ return pathname === layout.urlPattern || pathname.startsWith(`${layout.urlPattern}/`);
2052
+ });
2053
+ }
2054
+ function findSpecialRoute(kind, pathname, routes) {
2055
+ const candidates = routes.filter((route) => route.kind === kind);
2056
+ let best = null;
2057
+ let bestLength = -1;
2058
+ for (const candidate of candidates) {
2059
+ const prefix = candidate.urlPattern === "/" ? "" : candidate.urlPattern;
2060
+ if (pathname.startsWith(prefix) && prefix.length > bestLength) {
2061
+ best = candidate;
2062
+ bestLength = prefix.length;
2063
+ }
2064
+ }
2065
+ return best;
2066
+ }
2067
+
2068
+ // src/forge/devServer.ts
2069
+ var DEFAULT_DEV_PORT = 3000;
2070
+ var MIME_MAP = {
2071
+ ".html": "text/html; charset=utf-8",
2072
+ ".js": "application/javascript; charset=utf-8",
2073
+ ".mjs": "application/javascript; charset=utf-8",
2074
+ ".css": "text/css; charset=utf-8",
2075
+ ".json": "application/json; charset=utf-8",
2076
+ ".png": "image/png",
2077
+ ".jpg": "image/jpeg",
2078
+ ".jpeg": "image/jpeg",
2079
+ ".webp": "image/webp",
2080
+ ".svg": "image/svg+xml",
2081
+ ".ico": "image/x-icon",
2082
+ ".woff": "font/woff",
2083
+ ".woff2": "font/woff2",
2084
+ ".ttf": "font/ttf"
2085
+ };
2086
+ function resolveMime(filePath) {
2087
+ const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
2088
+ return MIME_MAP[ext] ?? "application/octet-stream";
2089
+ }
2090
+ function resolveDevPort(port) {
2091
+ return port > 0 ? port : DEFAULT_DEV_PORT;
2092
+ }
2093
+ function startDevServer(options) {
2094
+ const manifest = generateManifest(options.appDir);
2095
+ const resolvedPort = resolveDevPort(options.port);
2096
+ const server = Bun.serve({
2097
+ port: resolvedPort,
2098
+ hostname: options.host,
2099
+ async fetch(request) {
2100
+ const url = new URL(request.url);
2101
+ const { pathname } = url;
2102
+ const publicPath = join6(options.publicDir, pathname);
2103
+ if (existsSync5(publicPath) && !publicPath.endsWith("/")) {
2104
+ return new Response(readFileSync2(publicPath), {
2105
+ headers: { "Content-Type": resolveMime(pathname) }
2106
+ });
2107
+ }
2108
+ const apiMatch = matchRoute(pathname, manifest.routes.filter((route) => route.kind === "api"));
2109
+ if (apiMatch) {
2110
+ const modulePath = join6(options.appDir, apiMatch.entry.filePath);
2111
+ const routeModule = await import(modulePath);
2112
+ const method = request.method.toUpperCase();
2113
+ const handler = routeModule[method];
2114
+ if (typeof handler !== "function") {
2115
+ return new Response("Method not allowed", { status: 405 });
2116
+ }
2117
+ return await handler(request);
2118
+ }
2119
+ const resolved = resolveRouteMode(pathname, options.renderConfig);
2120
+ const searchParams = {};
2121
+ url.searchParams.forEach((value, key) => {
2122
+ searchParams[key] = value;
2123
+ });
2124
+ const requestHeaders = {};
2125
+ request.headers.forEach((value, key) => {
2126
+ requestHeaders[key] = value;
2127
+ });
2128
+ const result = await render({
2129
+ routePath: pathname,
2130
+ mode: resolved.mode,
2131
+ params: {},
2132
+ searchParams,
2133
+ requestHeaders,
2134
+ timestampMs: Date.now()
2135
+ }, {
2136
+ appName: options.appName,
2137
+ scriptPath: "/app.js",
2138
+ cssPath: "/globals.css",
2139
+ lang: "en"
2140
+ });
2141
+ if (result.kind === "failure") {
2142
+ return new Response(result.reason, { status: result.httpStatus });
2143
+ }
2144
+ return new Response(result.html, {
2145
+ status: result.httpStatus,
2146
+ headers: result.responseHeaders
2147
+ });
2148
+ }
2149
+ });
2150
+ const serverPort = typeof server.port === "number" ? server.port : resolvedPort;
2151
+ return {
2152
+ port: serverPort,
2153
+ host: options.host,
2154
+ url: `http://${options.host}:${serverPort}`,
2155
+ stop: () => server.stop()
2156
+ };
2157
+ }
2158
+ // src/forge/inspect.ts
2159
+ import { existsSync as existsSync6, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
2160
+ import { join as join7 } from "path";
2161
+ function detectArtifactKind(filename) {
2162
+ if (filename === "route-manifest.json")
2163
+ return "manifest";
2164
+ if (filename.endsWith(".css"))
2165
+ return "stylesheet";
2166
+ if (filename.endsWith(".js") || filename.endsWith(".mjs"))
2167
+ return "script";
2168
+ return "asset";
2169
+ }
2170
+ function formatBytes(bytes) {
2171
+ if (bytes < 1024)
2172
+ return `${bytes} B`;
2173
+ if (bytes < 1048576)
2174
+ return `${(bytes / 1024).toFixed(1)} KB`;
2175
+ return `${(bytes / 1048576).toFixed(2)} MB`;
2176
+ }
2177
+ function scanDirectory2(dirPath) {
2178
+ if (!existsSync6(dirPath))
2179
+ return [];
2180
+ const collected = [];
2181
+ function walk(current) {
2182
+ const entries = readdirSync3(current, { withFileTypes: true });
2183
+ for (const entry of entries) {
2184
+ const full = join7(current, entry.name);
2185
+ if (entry.isDirectory()) {
2186
+ walk(full);
2187
+ } else if (entry.isFile()) {
2188
+ collected.push({
2189
+ outputPath: full,
2190
+ sizeBytes: statSync2(full).size,
2191
+ kind: detectArtifactKind(entry.name)
2192
+ });
2193
+ }
2194
+ }
2195
+ }
2196
+ walk(dirPath);
2197
+ return collected;
2198
+ }
2199
+ function inspectBuild(options) {
2200
+ const artifacts = scanDirectory2(options.outDir);
2201
+ const manifestPath = join7(options.outDir, "route-manifest.json");
2202
+ const manifest = readManifest(manifestPath);
2203
+ const emptyManifest = {
2204
+ version: "1",
2205
+ generatedAt: new Date().toISOString(),
2206
+ routes: []
2207
+ };
2208
+ const routeModes = (manifest ?? emptyManifest).routes.filter((r) => r.kind === "page" || r.kind === "api").map((r) => {
2209
+ const resolved = resolveRouteMode(r.urlPattern, options.renderConfig);
2210
+ return {
2211
+ pattern: r.urlPattern,
2212
+ mode: resolved.mode,
2213
+ source: resolved.source
2214
+ };
2215
+ });
2216
+ return {
2217
+ buildDir: options.outDir,
2218
+ artifacts,
2219
+ manifest: manifest ?? emptyManifest,
2220
+ routeModes,
2221
+ totalSizeBytes: artifacts.reduce((sum, a) => sum + a.sizeBytes, 0),
2222
+ inspectedAt: new Date().toISOString()
2223
+ };
2224
+ }
2225
+ function printInspectReport(report) {
2226
+ const sep = "\u2500".repeat(58);
2227
+ console.log(`
2228
+
2229
+ Rakta.js Forge - Build Inspection
2230
+ `);
2231
+ console.log(`
2232
+ ${sep}
2233
+ `);
2234
+ console.log(`
2235
+ Directory: ${report.buildDir}
2236
+ `);
2237
+ console.log(`
2238
+ Inspected: ${report.inspectedAt}
2239
+ `);
2240
+ console.log(`
2241
+ Total size: ${formatBytes(report.totalSizeBytes)}
2242
+
2243
+ `);
2244
+ if (report.artifacts.length > 0) {
2245
+ console.log("Artifacts:");
2246
+ for (const artifact of report.artifacts) {
2247
+ const rel = artifact.outputPath.replace(report.buildDir, ".").replace(/\\/g, "/");
2248
+ console.log(`
2249
+ [${artifact.kind.padEnd(10)}]
2250
+ ${rel.padEnd(38)}
2251
+ ${formatBytes(artifact.sizeBytes)}`);
2252
+ }
2253
+ console.log("");
2254
+ }
2255
+ if (report.routeModes.length > 0) {
2256
+ console.log("Route Render Modes:");
2257
+ for (const rm of report.routeModes) {
2258
+ const src = rm.source === "route-override" ? "(override)" : "(default) ";
2259
+ console.log(`
2260
+ ${rm.mode.toUpperCase().padEnd(8)}
2261
+ ${rm.pattern.padEnd(36)} ${src}`);
2262
+ }
2263
+ console.log("");
2264
+ }
2265
+ console.log(`${sep}
2266
+ `);
2267
+ }
2268
+ // src/http/errors.ts
2269
+ class HttpResponseError extends Error {
2270
+ status;
2271
+ statusText;
2272
+ url;
2273
+ constructor(response) {
2274
+ super(`HTTP ${response.status} ${response.statusText} - ${response.url}`);
2275
+ this.name = "HttpResponseError";
2276
+ this.status = response.status;
2277
+ this.statusText = response.statusText;
2278
+ this.url = response.url;
2279
+ }
2280
+ }
2281
+
2282
+ class HttpTimeoutError extends Error {
2283
+ url;
2284
+ timeoutMs;
2285
+ constructor(url, timeoutMs) {
2286
+ super(`Request to ${url} timed out after ${timeoutMs}ms`);
2287
+ this.name = "HttpTimeoutError";
2288
+ this.url = url;
2289
+ this.timeoutMs = timeoutMs;
2290
+ }
2291
+ }
2292
+
2293
+ class HttpNetworkError extends Error {
2294
+ url;
2295
+ originalError;
2296
+ constructor(url, originalError) {
2297
+ super(`Network error for ${url}: ${originalError.message}`);
2298
+ this.name = "HttpNetworkError";
2299
+ this.url = url;
2300
+ this.originalError = originalError;
2301
+ }
2302
+ }
2303
+ // src/http/panturaFetch.ts
2304
+ function buildUrl(baseUrl, path, params) {
2305
+ const base = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
2306
+ const fullUrl = path.startsWith("http") ? path : `${base}${path}`;
2307
+ const parsedUrl = new URL(fullUrl);
2308
+ if (params) {
2309
+ for (const [key, value] of Object.entries(params)) {
2310
+ parsedUrl.searchParams.set(key, String(value));
2311
+ }
2312
+ }
2313
+ return parsedUrl.toString();
2314
+ }
2315
+ function canSendBody(method) {
2316
+ return method !== "GET" && method !== "HEAD";
2317
+ }
2318
+ function createRequestInit(method, headers, body) {
2319
+ const requestInit = {
2320
+ method,
2321
+ headers
2322
+ };
2323
+ if (body !== undefined && canSendBody(method)) {
2324
+ requestInit.body = JSON.stringify(body);
2325
+ }
2326
+ return requestInit;
2327
+ }
2328
+
2329
+ class RaktaHttpClient {
2330
+ clientConfig;
2331
+ requestInterceptors = [];
2332
+ responseInterceptors = [];
2333
+ constructor(config) {
2334
+ this.clientConfig = {
2335
+ baseUrl: config.baseUrl,
2336
+ headers: config.headers ?? {
2337
+ "Content-Type": "application/json"
2338
+ },
2339
+ timeout: config.timeout ?? 30000
2340
+ };
2341
+ }
2342
+ addRequestInterceptor(interceptorFn) {
2343
+ this.requestInterceptors.push(interceptorFn);
2344
+ return this;
2345
+ }
2346
+ addResponseInterceptor(interceptorFn) {
2347
+ const wrappedInterceptor = async (response, data) => {
2348
+ return await Promise.resolve(interceptorFn(response, data));
2349
+ };
2350
+ this.responseInterceptors.push(wrappedInterceptor);
2351
+ return this;
2352
+ }
2353
+ async execute(method, path, body, requestConfig) {
2354
+ let resolvedUrl = buildUrl(this.clientConfig.baseUrl, path, requestConfig?.params);
2355
+ let requestInit = createRequestInit(method, {
2356
+ ...this.clientConfig.headers,
2357
+ ...requestConfig?.headers ?? {}
2358
+ }, body);
2359
+ for (const interceptorFn of this.requestInterceptors) {
2360
+ [resolvedUrl, requestInit] = await Promise.resolve(interceptorFn(resolvedUrl, requestInit));
2361
+ }
2362
+ const timeoutMs = requestConfig?.timeout ?? this.clientConfig.timeout;
2363
+ const abortController = new AbortController;
2364
+ const timeoutHandle = setTimeout(() => abortController.abort(), timeoutMs);
2365
+ requestInit = { ...requestInit, signal: abortController.signal };
2366
+ let response;
2367
+ try {
2368
+ response = await fetch(resolvedUrl, requestInit);
2369
+ } catch (caughtError) {
2370
+ clearTimeout(timeoutHandle);
2371
+ if (caughtError instanceof DOMException && caughtError.name === "AbortError") {
2372
+ throw new HttpTimeoutError(resolvedUrl, timeoutMs);
2373
+ }
2374
+ throw new HttpNetworkError(resolvedUrl, caughtError instanceof Error ? caughtError : new Error(String(caughtError)));
2375
+ }
2376
+ clearTimeout(timeoutHandle);
2377
+ if (!response.ok) {
2378
+ throw new HttpResponseError(response);
2379
+ }
2380
+ const contentType = response.headers.get("content-type") ?? "";
2381
+ let responseData;
2382
+ if (contentType.includes("application/json")) {
2383
+ responseData = await response.json();
2384
+ } else {
2385
+ responseData = await response.text();
2386
+ }
2387
+ let interceptedData = responseData;
2388
+ for (const interceptorFn of this.responseInterceptors) {
2389
+ interceptedData = await Promise.resolve(interceptorFn(response, interceptedData));
2390
+ }
2391
+ return interceptedData;
2392
+ }
2393
+ get(path, config) {
2394
+ return this.execute("GET", path, undefined, config);
2395
+ }
2396
+ post(path, body, config) {
2397
+ return this.execute("POST", path, body, config);
2398
+ }
2399
+ put(path, body, config) {
2400
+ return this.execute("PUT", path, body, config);
2401
+ }
2402
+ patch(path, body, config) {
2403
+ return this.execute("PATCH", path, body, config);
2404
+ }
2405
+ delete(path, config) {
2406
+ return this.execute("DELETE", path, undefined, config);
2407
+ }
2408
+ }
2409
+ function createRaktaHttp(config) {
2410
+ return new RaktaHttpClient(config);
2411
+ }
2412
+ // src/pwa/cache.ts
2413
+ function buildCacheName(cacheName, cacheVersion) {
2414
+ const sanitizedName = cacheName.trim().toLowerCase().replace(/\s+/g, "-");
2415
+ const sanitizedVersion = cacheVersion.trim().toLowerCase();
2416
+ return `${sanitizedName}-${sanitizedVersion}`;
2417
+ }
2418
+ function resolvePrecacheList(options) {
2419
+ const uniqueUrls = new Set(options.precacheUrls);
2420
+ uniqueUrls.add(options.offlineFallbackUrl);
2421
+ return Array.from(uniqueUrls);
2422
+ }
2423
+ // src/pwa/manifest.ts
2424
+ function generateManifest2(options) {
2425
+ const manifestObject = {
2426
+ name: options.name,
2427
+ short_name: options.shortName,
2428
+ start_url: options.startUrl ?? "/",
2429
+ scope: options.scope ?? "/",
2430
+ display: options.display ?? "standalone",
2431
+ background_color: options.backgroundColor ?? "#050505",
2432
+ theme_color: options.themeColor ?? "#dc2626",
2433
+ icons: options.icons.map((icon) => {
2434
+ const manifestIcon = {
2435
+ src: icon.src,
2436
+ sizes: icon.sizes,
2437
+ type: icon.type
2438
+ };
2439
+ if (icon.purpose !== undefined) {
2440
+ return {
2441
+ ...manifestIcon,
2442
+ purpose: icon.purpose
2443
+ };
2444
+ }
2445
+ return manifestIcon;
2446
+ })
2447
+ };
2448
+ if (options.description !== undefined) {
2449
+ return {
2450
+ ...manifestObject,
2451
+ description: options.description
2452
+ };
2453
+ }
2454
+ return manifestObject;
2455
+ }
2456
+ function generateManifestJson(options) {
2457
+ return JSON.stringify(generateManifest2(options), undefined, 2);
2458
+ }
2459
+ function createManifestHandler(options) {
2460
+ return () => {
2461
+ const manifestJson = generateManifestJson(options);
2462
+ return new Response(manifestJson, {
2463
+ status: 200,
2464
+ headers: {
2465
+ "Content-Type": "application/manifest+json; charset=utf-8",
2466
+ "Cache-Control": "public, max-age=3600"
2467
+ }
2468
+ });
2469
+ };
2470
+ }
2471
+ // src/pwa/serviceWorker.ts
2472
+ function toJsStringArray(values) {
2473
+ return `[${values.map((value) => JSON.stringify(value)).join(", ")}]`;
2474
+ }
2475
+ function generateServiceWorkerSource(options) {
2476
+ const cacheName = buildCacheName(options.cacheName, options.cacheVersion);
2477
+ const precacheList = resolvePrecacheList(options);
2478
+ const offlineFallbackUrl = options.offlineFallbackUrl;
2479
+ return `// Generated by Rakta.js ShrimpHarbor - do not edit manually.
2480
+ // Re-run "bun rakta pwa:generate" to regenerate this file.
2481
+
2482
+ const CACHE_NAME = ${JSON.stringify(cacheName)};
2483
+ const OFFLINE_FALLBACK_URL = ${JSON.stringify(offlineFallbackUrl)};
2484
+ const PRECACHE_URLS = ${toJsStringArray(precacheList)};
2485
+
2486
+ self.addEventListener("install", (installEvent) => {
2487
+ installEvent.waitUntil(
2488
+ caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE_URLS)),
2489
+ );
2490
+ self.skipWaiting();
2491
+ });
2492
+
2493
+ self.addEventListener("activate", (activateEvent) => {
2494
+ activateEvent.waitUntil(
2495
+ caches.keys().then((cacheKeys) =>
2496
+ Promise.all(
2497
+ cacheKeys
2498
+ .filter((cacheKey) => cacheKey !== CACHE_NAME)
2499
+ .map((staleCacheKey) => caches.delete(staleCacheKey)),
2500
+ ),
2501
+ ),
2502
+ );
2503
+ self.clients.claim();
2504
+ });
2505
+
2506
+ self.addEventListener("fetch", (fetchEvent) => {
2507
+ if (fetchEvent.request.method !== "GET") {
2508
+ return;
2509
+ }
2510
+
2511
+ fetchEvent.respondWith(
2512
+ caches.match(fetchEvent.request).then((cachedResponse) => {
2513
+ if (cachedResponse) {
2514
+ return cachedResponse;
2515
+ }
2516
+
2517
+ return fetch(fetchEvent.request)
2518
+ .then((networkResponse) => {
2519
+ const responseClone = networkResponse.clone();
2520
+ caches
2521
+ .open(CACHE_NAME)
2522
+ .then((cache) => cache.put(fetchEvent.request, responseClone));
2523
+ return networkResponse;
2524
+ })
2525
+ .catch(() => {
2526
+ if (fetchEvent.request.mode === "navigate") {
2527
+ return caches.match(OFFLINE_FALLBACK_URL);
2528
+ }
2529
+
2530
+ return caches.match(fetchEvent.request);
2531
+ });
2532
+ }),
2533
+ );
2534
+ });
2535
+ `;
2536
+ }
2537
+ // src/rpc/client.ts
2538
+ class RaktaRpcError extends Error {
2539
+ code;
2540
+ details;
2541
+ constructor(message, code, details) {
2542
+ super(message);
2543
+ this.name = "RaktaRpcError";
2544
+ this.code = code;
2545
+ if (details !== undefined) {
2546
+ this.details = details;
2547
+ }
2548
+ }
2549
+ }
2550
+ async function callProcedure(clientConfig, procedureName, procedureInput) {
2551
+ const abortController = new AbortController;
2552
+ const timeoutMs = clientConfig.timeout ?? 30000;
2553
+ const timeoutHandle = setTimeout(() => abortController.abort(), timeoutMs);
2554
+ let response;
2555
+ try {
2556
+ response = await fetch(clientConfig.baseUrl, {
2557
+ method: "POST",
2558
+ headers: {
2559
+ "Content-Type": "application/json",
2560
+ ...clientConfig.headers ?? {}
2561
+ },
2562
+ body: JSON.stringify({
2563
+ procedure: procedureName,
2564
+ input: procedureInput
2565
+ }),
2566
+ signal: abortController.signal
2567
+ });
2568
+ } finally {
2569
+ clearTimeout(timeoutHandle);
2570
+ }
2571
+ const responseEnvelope = await response.json();
2572
+ if (!responseEnvelope.ok) {
2573
+ throw new RaktaRpcError(responseEnvelope.error, responseEnvelope.code, responseEnvelope.details);
2574
+ }
2575
+ return responseEnvelope.data;
2576
+ }
2577
+ function createRaktaClient(clientConfig) {
2578
+ return new Proxy({}, {
2579
+ get(_target, procedureName) {
2580
+ return {
2581
+ query: (procedureInput) => callProcedure(clientConfig, procedureName, procedureInput),
2582
+ mutate: (procedureInput) => callProcedure(clientConfig, procedureName, procedureInput)
2583
+ };
2584
+ }
2585
+ });
2586
+ }
2587
+ // src/rpc/procedure.ts
2588
+ class ProcedureBuilder {
2589
+ inputSchema;
2590
+ constructor(inputSchema) {
2591
+ if (inputSchema !== undefined) {
2592
+ this.inputSchema = inputSchema;
2593
+ }
2594
+ }
2595
+ input(schema) {
2596
+ return new ProcedureBuilder(schema);
2597
+ }
2598
+ query(handler) {
2599
+ return this.build("query", handler);
2600
+ }
2601
+ mutation(handler) {
2602
+ return this.build("mutation", handler);
2603
+ }
2604
+ build(kind, handler) {
2605
+ if (this.inputSchema !== undefined) {
2606
+ return {
2607
+ kind,
2608
+ inputSchema: this.inputSchema,
2609
+ handler
2610
+ };
2611
+ }
2612
+ return {
2613
+ kind,
2614
+ handler
2615
+ };
2616
+ }
2617
+ }
2618
+ var publicProcedure = new ProcedureBuilder;
2619
+ // src/schema/errors.ts
2620
+ class RaktaSchemaError extends Error {
2621
+ errors;
2622
+ constructor(errors) {
2623
+ const first = errors[0];
2624
+ const prefix = first ? `[${first.path.join(".") || "root"}] ${first.message}` : "Validation failed";
2625
+ super(`Rakta Schema: ${prefix}${errors.length > 1 ? ` (and ${errors.length - 1} more)` : ""}`);
2626
+ this.name = "RaktaSchemaError";
2627
+ this.errors = errors;
2628
+ }
2629
+ }
2630
+ function prefixErrors(errors, key) {
2631
+ return errors.map((error) => ({
2632
+ ...error,
2633
+ path: [key, ...error.path]
2634
+ }));
2635
+ }
2636
+ var preFixErrors = prefixErrors;
2637
+
2638
+ // src/rpc/router.ts
2639
+ function createRaktaRouter(procedures) {
2640
+ return procedures;
2641
+ }
2642
+ function createRpcHandler(router) {
2643
+ return async (request) => {
2644
+ if (request.method !== "POST") {
2645
+ return buildJsonResponse({
2646
+ ok: false,
2647
+ error: "Only POST requests are accepted",
2648
+ code: "method_not_allowed"
2649
+ }, 405);
2650
+ }
2651
+ let rpcPayload;
2652
+ try {
2653
+ rpcPayload = await request.json();
2654
+ } catch {
2655
+ return buildJsonResponse({ ok: false, error: "Invalid JSON body", code: "parse_error" }, 400);
2656
+ }
2657
+ if (typeof rpcPayload.procedure !== "string") {
2658
+ return buildJsonResponse({
2659
+ ok: false,
2660
+ error: "Missing procedure name",
2661
+ code: "invalid_request"
2662
+ }, 400);
2663
+ }
2664
+ const selectedProcedure = router[rpcPayload.procedure];
2665
+ if (selectedProcedure === undefined) {
2666
+ return buildJsonResponse({
2667
+ ok: false,
2668
+ error: `Procedure "${rpcPayload.procedure}" not found`,
2669
+ code: "not_found"
2670
+ }, 404);
2671
+ }
2672
+ let validatedInput = rpcPayload.input;
2673
+ if (selectedProcedure.inputSchema !== undefined) {
2674
+ const validationErrors = selectedProcedure.inputSchema._run(rpcPayload.input);
2675
+ if (validationErrors.length > 0) {
2676
+ return buildJsonResponse({
2677
+ ok: false,
2678
+ error: "Input validation failed",
2679
+ code: "validation_error",
2680
+ details: validationErrors.map((validationError) => ({
2681
+ path: validationError.path,
2682
+ message: validationError.message
2683
+ }))
2684
+ }, 422);
2685
+ }
2686
+ validatedInput = selectedProcedure.inputSchema.parse(rpcPayload.input);
2687
+ }
2688
+ try {
2689
+ const procedureOutput = await selectedProcedure.handler({
2690
+ input: validatedInput
2691
+ });
2692
+ return buildJsonResponse({ ok: true, data: procedureOutput }, 200);
2693
+ } catch (caughtError) {
2694
+ if (caughtError instanceof RaktaSchemaError) {
2695
+ return buildJsonResponse({
2696
+ ok: false,
2697
+ error: caughtError.message,
2698
+ code: "schema_error"
2699
+ }, 422);
2700
+ }
2701
+ const errorMessage = caughtError instanceof Error ? caughtError.message : "Internal server error";
2702
+ return buildJsonResponse({ ok: false, error: errorMessage, code: "internal_error" }, 500);
2703
+ }
2704
+ };
2705
+ }
2706
+ function buildJsonResponse(responseEnvelope, statusCode) {
2707
+ return new Response(JSON.stringify(responseEnvelope), {
2708
+ status: statusCode,
2709
+ headers: { "Content-Type": "application/json; charset=utf-8" }
2710
+ });
2711
+ }
2712
+ // src/schema/types.ts
2713
+ class RaktaType {
2714
+ parse(value) {
2715
+ const result = this.safeParse(value);
2716
+ if (result.kind === "failure") {
2717
+ throw new RaktaSchemaError(result.errors);
2718
+ }
2719
+ return result.data;
2720
+ }
2721
+ safeParse(value) {
2722
+ const errors = this._run(value);
2723
+ if (errors.length > 0) {
2724
+ return {
2725
+ kind: "failure",
2726
+ errors
2727
+ };
2728
+ }
2729
+ return {
2730
+ kind: "success",
2731
+ data: value
2732
+ };
2733
+ }
2734
+ optional() {
2735
+ return new OptionalType(this);
2736
+ }
2737
+ }
2738
+
2739
+ class OptionalType extends RaktaType {
2740
+ inner;
2741
+ constructor(inner) {
2742
+ super();
2743
+ this.inner = inner;
2744
+ }
2745
+ _run(value) {
2746
+ if (typeof value === "undefined") {
2747
+ return [];
2748
+ }
2749
+ return this.inner._run(value);
2750
+ }
2751
+ }
2752
+
2753
+ // src/schema/array.ts
2754
+ class ArrayType extends RaktaType {
2755
+ itemSchema;
2756
+ minLength;
2757
+ maxLength;
2758
+ constructor(itemSchema, minLength, maxLength) {
2759
+ super();
2760
+ this.itemSchema = itemSchema;
2761
+ if (typeof minLength === "number") {
2762
+ this.minLength = minLength;
2763
+ }
2764
+ if (typeof maxLength === "number") {
2765
+ this.maxLength = maxLength;
2766
+ }
2767
+ }
2768
+ clone(minLength, maxLength) {
2769
+ return new ArrayType(this.itemSchema, minLength, maxLength);
2770
+ }
2771
+ min(length) {
2772
+ return this.clone(length, this.maxLength);
2773
+ }
2774
+ max(length) {
2775
+ return this.clone(this.minLength, length);
2776
+ }
2777
+ nonempty() {
2778
+ return this.min(1);
2779
+ }
2780
+ _run(value) {
2781
+ if (!Array.isArray(value)) {
2782
+ return [
2783
+ {
2784
+ path: [],
2785
+ message: "Expected an array",
2786
+ code: "invalid_type"
2787
+ }
2788
+ ];
2789
+ }
2790
+ const errors = [];
2791
+ if (typeof this.minLength === "number" && value.length < this.minLength) {
2792
+ errors.push({
2793
+ path: [],
2794
+ message: `Array must contain at least ${this.minLength} item(s)`,
2795
+ code: "too_small"
2796
+ });
2797
+ }
2798
+ if (typeof this.maxLength === "number" && value.length > this.maxLength) {
2799
+ errors.push({
2800
+ path: [],
2801
+ message: `Array must contain at most ${this.maxLength} item(s)`,
2802
+ code: "too_big"
2803
+ });
2804
+ }
2805
+ for (let index = 0;index < value.length; index += 1) {
2806
+ const itemValue = value[index];
2807
+ const itemErrors = this.itemSchema._run(itemValue);
2808
+ errors.push(...itemErrors.map((error) => ({
2809
+ ...error,
2810
+ path: [String(index), ...error.path]
2811
+ })));
2812
+ }
2813
+ return errors;
2814
+ }
2815
+ }
2816
+ function array(itemSchema) {
2817
+ return new ArrayType(itemSchema);
2818
+ }
2819
+ // src/schema/boolean.ts
2820
+ class BooleanType extends RaktaType {
2821
+ _run(value) {
2822
+ if (typeof value !== "boolean") {
2823
+ return [
2824
+ {
2825
+ path: [],
2826
+ message: "Expected a boolean",
2827
+ code: "invalid_type"
2828
+ }
2829
+ ];
2830
+ }
2831
+ return [];
2832
+ }
2833
+ }
2834
+ function boolean() {
2835
+ return new BooleanType;
2836
+ }
2837
+ // src/schema/number.ts
2838
+ class NumberType extends RaktaType {
2839
+ rules;
2840
+ constructor(rules = []) {
2841
+ super();
2842
+ this.rules = rules;
2843
+ }
2844
+ addRule(rule) {
2845
+ return new NumberType([...this.rules, rule]);
2846
+ }
2847
+ _run(value) {
2848
+ if (typeof value !== "number" || Number.isNaN(value)) {
2849
+ return [
2850
+ {
2851
+ path: [],
2852
+ message: "Expected a number",
2853
+ code: "invalid_type"
2854
+ }
2855
+ ];
2856
+ }
2857
+ const errors = [];
2858
+ for (const rule of this.rules) {
2859
+ const result = rule(value);
2860
+ if (result) {
2861
+ errors.push(result);
2862
+ }
2863
+ }
2864
+ return errors;
2865
+ }
2866
+ min(threshold) {
2867
+ return this.addRule((value) => value < threshold ? {
2868
+ path: [],
2869
+ message: `Must be at least ${threshold}`,
2870
+ code: "too_small"
2871
+ } : undefined);
2872
+ }
2873
+ max(threshold) {
2874
+ return this.addRule((value) => value > threshold ? {
2875
+ path: [],
2876
+ message: `Must be at most ${threshold}`,
2877
+ code: "too_big"
2878
+ } : undefined);
2879
+ }
2880
+ int() {
2881
+ return this.addRule((value) => !Number.isInteger(value) ? {
2882
+ path: [],
2883
+ message: "Expected an integer",
2884
+ code: "not_integer"
2885
+ } : undefined);
2886
+ }
2887
+ positive() {
2888
+ return this.addRule((value) => value <= 0 ? {
2889
+ path: [],
2890
+ message: "Must be a positive number",
2891
+ code: "not_positive"
2892
+ } : undefined);
2893
+ }
2894
+ nonnegative() {
2895
+ return this.addRule((value) => value < 0 ? {
2896
+ path: [],
2897
+ message: "Must be zero or positive",
2898
+ code: "not_nonnegative"
2899
+ } : undefined);
2900
+ }
2901
+ }
2902
+ function number() {
2903
+ return new NumberType;
2904
+ }
2905
+ // src/schema/object.ts
2906
+ class ObjectType extends RaktaType {
2907
+ shape;
2908
+ constructor(shape) {
2909
+ super();
2910
+ this.shape = shape;
2911
+ }
2912
+ _run(value) {
2913
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
2914
+ return [
2915
+ {
2916
+ path: [],
2917
+ message: "Expected an object",
2918
+ code: "invalid_type"
2919
+ }
2920
+ ];
2921
+ }
2922
+ const errors = [];
2923
+ const record = value;
2924
+ for (const key of Object.keys(this.shape)) {
2925
+ const fieldSchema = this.shape[key];
2926
+ if (typeof fieldSchema === "undefined") {
2927
+ continue;
2928
+ }
2929
+ const fieldValue = record[key];
2930
+ const fieldErrors = fieldSchema._run(fieldValue);
2931
+ errors.push(...prefixErrors(fieldErrors, key));
2932
+ }
2933
+ return errors;
2934
+ }
2935
+ extend(extension) {
2936
+ return new ObjectType({
2937
+ ...this.shape,
2938
+ ...extension
2939
+ });
2940
+ }
2941
+ pick(keys) {
2942
+ const picked = {};
2943
+ for (const key of keys) {
2944
+ if (key in this.shape) {
2945
+ picked[key] = this.shape[key];
2946
+ }
2947
+ }
2948
+ return new ObjectType(picked);
2949
+ }
2950
+ omit(keys) {
2951
+ const result = { ...this.shape };
2952
+ for (const key of keys) {
2953
+ delete result[key];
2954
+ }
2955
+ return new ObjectType(result);
2956
+ }
2957
+ }
2958
+ function object(shape) {
2959
+ return new ObjectType(shape);
2960
+ }
2961
+ // src/schema/string.ts
2962
+ var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
2963
+ var URL_PATTERN = /^https?:\/\/[^\s$.?#].[^\s]*$/i;
2964
+
2965
+ class StringType extends RaktaType {
2966
+ rules;
2967
+ constructor(rules = []) {
2968
+ super();
2969
+ this.rules = rules;
2970
+ }
2971
+ addRule(rule) {
2972
+ return new StringType([...this.rules, rule]);
2973
+ }
2974
+ _run(value) {
2975
+ if (typeof value !== "string") {
2976
+ return [
2977
+ {
2978
+ path: [],
2979
+ message: "Expected a string",
2980
+ code: "invalid_type"
2981
+ }
2982
+ ];
2983
+ }
2984
+ const errors = [];
2985
+ for (const rule of this.rules) {
2986
+ errors.push(...rule(value));
2987
+ }
2988
+ return errors;
2989
+ }
2990
+ min(length) {
2991
+ return this.addRule((value) => {
2992
+ if (value.length >= length) {
2993
+ return [];
2994
+ }
2995
+ return [
2996
+ {
2997
+ path: [],
2998
+ message: `Must be at least ${length} character(s)`,
2999
+ code: "too_small"
3000
+ }
3001
+ ];
3002
+ });
3003
+ }
3004
+ max(length) {
3005
+ return this.addRule((value) => {
3006
+ if (value.length <= length) {
3007
+ return [];
3008
+ }
3009
+ return [
3010
+ {
3011
+ path: [],
3012
+ message: `Must be at most ${length} character(s)`,
3013
+ code: "too_big"
3014
+ }
3015
+ ];
3016
+ });
3017
+ }
3018
+ email() {
3019
+ return this.addRule((value) => {
3020
+ if (EMAIL_PATTERN.test(value)) {
3021
+ return [];
3022
+ }
3023
+ return [
3024
+ {
3025
+ path: [],
3026
+ message: "Invalid email address",
3027
+ code: "invalid_email"
3028
+ }
3029
+ ];
3030
+ });
3031
+ }
3032
+ url() {
3033
+ return this.addRule((value) => {
3034
+ if (URL_PATTERN.test(value)) {
3035
+ return [];
3036
+ }
3037
+ return [
3038
+ {
3039
+ path: [],
3040
+ message: "Invalid URL",
3041
+ code: "invalid_url"
3042
+ }
3043
+ ];
3044
+ });
3045
+ }
3046
+ regex(pattern, customMessage) {
3047
+ return this.addRule((value) => {
3048
+ if (pattern.test(value)) {
3049
+ return [];
3050
+ }
3051
+ return [
3052
+ {
3053
+ path: [],
3054
+ message: customMessage ?? `Did not match pattern ${pattern.toString()}`,
3055
+ code: "invalid_pattern"
3056
+ }
3057
+ ];
3058
+ });
3059
+ }
3060
+ nonempty() {
3061
+ return this.min(1);
3062
+ }
3063
+ }
3064
+ function string() {
3065
+ return new StringType;
3066
+ }
3067
+ // src/seo/metadata.ts
3068
+ function resolveTitle(metadata) {
3069
+ if (!metadata.title && metadata.defaultTitle) {
3070
+ return metadata.defaultTitle;
3071
+ }
3072
+ if (!metadata.title) {
3073
+ return "";
3074
+ }
3075
+ if (metadata.titleTemplate) {
3076
+ return metadata.titleTemplate.replace("%s", metadata.title);
3077
+ }
3078
+ return metadata.title;
3079
+ }
3080
+ function resolveRobotsContent(robots) {
3081
+ if (typeof robots === "string") {
3082
+ return robots;
3083
+ }
3084
+ const directives = [];
3085
+ if (robots.index === false) {
3086
+ directives.push("noindex");
3087
+ } else {
3088
+ directives.push("index");
3089
+ }
3090
+ if (robots.follow === false) {
3091
+ directives.push("nofollow");
3092
+ } else {
3093
+ directives.push("follow");
3094
+ }
3095
+ if (robots.nocache) {
3096
+ directives.push("nocache");
3097
+ }
3098
+ return directives.join(", ");
3099
+ }
3100
+ function mergeMetadata(base, override) {
3101
+ const mergedMetadata = {
3102
+ ...base,
3103
+ ...override
3104
+ };
3105
+ if (base.openGraph || override.openGraph) {
3106
+ mergedMetadata.openGraph = {
3107
+ ...base.openGraph,
3108
+ ...override.openGraph
3109
+ };
3110
+ }
3111
+ if (base.twitter || override.twitter) {
3112
+ mergedMetadata.twitter = {
3113
+ ...base.twitter,
3114
+ ...override.twitter
3115
+ };
3116
+ }
3117
+ if (base.alternates || override.alternates) {
3118
+ mergedMetadata.alternates = {
3119
+ ...base.alternates,
3120
+ ...override.alternates
3121
+ };
3122
+ }
3123
+ if (base.icons || override.icons) {
3124
+ mergedMetadata.icons = {
3125
+ ...base.icons,
3126
+ ...override.icons
3127
+ };
3128
+ }
3129
+ if (base.other || override.other) {
3130
+ mergedMetadata.other = {
3131
+ ...base.other,
3132
+ ...override.other
3133
+ };
3134
+ }
3135
+ return mergedMetadata;
3136
+ }
3137
+
3138
+ // src/seo/head.tsx
3139
+ var jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
3140
+ function KeywordsContent(keywords) {
3141
+ return Array.isArray(keywords) ? keywords.join(", ") : keywords;
3142
+ }
3143
+ function getAuthorKey(authorName) {
3144
+ return `author-${authorName}`;
3145
+ }
3146
+ function getIconKey(prefix, iconUrl, iconSizes) {
3147
+ if (iconSizes && iconSizes.length > 0) {
3148
+ return `${prefix}-${iconUrl}-${iconSizes}`;
3149
+ }
3150
+ return `${prefix}-${iconUrl}`;
3151
+ }
3152
+ function getOpenGraphImageKey(image) {
3153
+ const width = image.width ? String(image.width) : "auto-width";
3154
+ const height = image.height ? String(image.height) : "auto-height";
3155
+ return `og-image-${image.url}-${width}-${height}`;
3156
+ }
3157
+ function getJsonLdKey(schema) {
3158
+ return `jsonld-${JSON.stringify(schema)}`;
3159
+ }
3160
+ function RaktaHead({ metadata }) {
3161
+ const resolvedTitle = resolveTitle(metadata);
3162
+ const robotsContent = metadata.robots ? resolveRobotsContent(metadata.robots) : "";
3163
+ const jsonLdArray = metadata.jsonLd ? Array.isArray(metadata.jsonLd) ? metadata.jsonLd : [metadata.jsonLd] : [];
3164
+ const canonical = metadata.canonical ?? metadata.alternates?.canonical ?? "";
3165
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(jsx_dev_runtime2.Fragment, {
3166
+ children: [
3167
+ resolvedTitle && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("title", {
3168
+ children: resolvedTitle
3169
+ }, undefined, false, undefined, this),
3170
+ metadata.description && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3171
+ name: "description",
3172
+ content: metadata.description
3173
+ }, undefined, false, undefined, this),
3174
+ metadata.keywords && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3175
+ name: "keywords",
3176
+ content: KeywordsContent(metadata.keywords)
3177
+ }, undefined, false, undefined, this),
3178
+ metadata.applicationName && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3179
+ name: "application-name",
3180
+ content: metadata.applicationName
3181
+ }, undefined, false, undefined, this),
3182
+ metadata.creator && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3183
+ name: "author",
3184
+ content: metadata.creator
3185
+ }, undefined, false, undefined, this),
3186
+ metadata.publisher && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3187
+ name: "publisher",
3188
+ content: metadata.publisher
3189
+ }, undefined, false, undefined, this),
3190
+ metadata.colorScheme && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3191
+ name: "color-scheme",
3192
+ content: metadata.colorScheme
3193
+ }, undefined, false, undefined, this),
3194
+ robotsContent && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3195
+ name: "robots",
3196
+ content: robotsContent
3197
+ }, undefined, false, undefined, this),
3198
+ metadata.viewport && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3199
+ name: "viewport",
3200
+ content: metadata.viewport
3201
+ }, undefined, false, undefined, this),
3202
+ metadata.authors?.map((author) => /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3203
+ name: "author",
3204
+ content: author.name
3205
+ }, getAuthorKey(author.name), false, undefined, this)),
3206
+ canonical && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("link", {
3207
+ rel: "canonical",
3208
+ href: canonical
3209
+ }, undefined, false, undefined, this),
3210
+ metadata.alternates?.languages && Object.entries(metadata.alternates.languages).map(([lang, url]) => /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("link", {
3211
+ rel: "alternate",
3212
+ hrefLang: lang,
3213
+ href: url
3214
+ }, lang, false, undefined, this)),
3215
+ metadata.manifest && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("link", {
3216
+ rel: "manifest",
3217
+ href: metadata.manifest
3218
+ }, undefined, false, undefined, this),
3219
+ metadata.icons?.icon && (typeof metadata.icons.icon === "string" ? /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("link", {
3220
+ rel: "icon",
3221
+ href: metadata.icons.icon
3222
+ }, undefined, false, undefined, this) : metadata.icons.icon.map((icon) => /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("link", {
3223
+ rel: "icon",
3224
+ href: icon.url,
3225
+ sizes: icon.sizes,
3226
+ type: icon.type
3227
+ }, getIconKey("icon", icon.url, icon.sizes), false, undefined, this))),
3228
+ metadata.icons?.shortcut && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("link", {
3229
+ rel: "shortcut icon",
3230
+ href: metadata.icons.shortcut
3231
+ }, undefined, false, undefined, this),
3232
+ metadata.icons?.apple && (typeof metadata.icons.apple === "string" ? /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("link", {
3233
+ rel: "apple-touch-icon",
3234
+ href: metadata.icons.apple
3235
+ }, undefined, false, undefined, this) : metadata.icons.apple.map((icon) => /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("link", {
3236
+ rel: "apple-touch-icon",
3237
+ href: icon.url,
3238
+ sizes: icon.sizes
3239
+ }, getIconKey("apple", icon.url, icon.sizes), false, undefined, this))),
3240
+ metadata.openGraph && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(jsx_dev_runtime2.Fragment, {
3241
+ children: [
3242
+ (metadata.openGraph.title ?? resolvedTitle) && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3243
+ property: "og:title",
3244
+ content: metadata.openGraph.title ?? resolvedTitle
3245
+ }, undefined, false, undefined, this),
3246
+ (metadata.openGraph.description ?? metadata.description) && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3247
+ property: "og:description",
3248
+ content: metadata.openGraph.description ?? metadata.description ?? ""
3249
+ }, undefined, false, undefined, this),
3250
+ metadata.openGraph.type && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3251
+ property: "og:type",
3252
+ content: metadata.openGraph.type
3253
+ }, undefined, false, undefined, this),
3254
+ metadata.openGraph.url && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3255
+ property: "og:url",
3256
+ content: metadata.openGraph.url
3257
+ }, undefined, false, undefined, this),
3258
+ metadata.openGraph.siteName && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3259
+ property: "og:site_name",
3260
+ content: metadata.openGraph.siteName
3261
+ }, undefined, false, undefined, this),
3262
+ metadata.openGraph.locale && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3263
+ property: "og:locale",
3264
+ content: metadata.openGraph.locale
3265
+ }, undefined, false, undefined, this),
3266
+ metadata.openGraph.images?.map((image) => /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(jsx_dev_runtime2.Fragment, {
3267
+ children: [
3268
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3269
+ property: "og:image",
3270
+ content: image.url
3271
+ }, undefined, false, undefined, this),
3272
+ image.width && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3273
+ property: "og:image:width",
3274
+ content: String(image.width)
3275
+ }, undefined, false, undefined, this),
3276
+ image.height && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3277
+ property: "og:image:height",
3278
+ content: String(image.height)
3279
+ }, undefined, false, undefined, this),
3280
+ image.alt && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3281
+ property: "og:image:alt",
3282
+ content: image.alt
3283
+ }, undefined, false, undefined, this),
3284
+ image.type && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3285
+ property: "og:image:type",
3286
+ content: image.type
3287
+ }, undefined, false, undefined, this)
3288
+ ]
3289
+ }, getOpenGraphImageKey(image), true, undefined, this))
3290
+ ]
3291
+ }, undefined, true, undefined, this),
3292
+ metadata.twitter && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(jsx_dev_runtime2.Fragment, {
3293
+ children: [
3294
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3295
+ name: "twitter:card",
3296
+ content: metadata.twitter.card ?? "summary"
3297
+ }, undefined, false, undefined, this),
3298
+ metadata.twitter.site && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3299
+ name: "twitter:site",
3300
+ content: metadata.twitter.site
3301
+ }, undefined, false, undefined, this),
3302
+ metadata.twitter.creator && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3303
+ name: "twitter:creator",
3304
+ content: metadata.twitter.creator
3305
+ }, undefined, false, undefined, this),
3306
+ (metadata.twitter.title ?? resolvedTitle) && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3307
+ name: "twitter:title",
3308
+ content: metadata.twitter.title ?? resolvedTitle
3309
+ }, undefined, false, undefined, this),
3310
+ (metadata.twitter.description ?? metadata.description) && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3311
+ name: "twitter:description",
3312
+ content: metadata.twitter.description ?? metadata.description ?? ""
3313
+ }, undefined, false, undefined, this),
3314
+ metadata.twitter.image && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3315
+ name: "twitter:image",
3316
+ content: metadata.twitter.image
3317
+ }, undefined, false, undefined, this),
3318
+ metadata.twitter.imageAlt && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3319
+ name: "twitter:image:alt",
3320
+ content: metadata.twitter.imageAlt
3321
+ }, undefined, false, undefined, this)
3322
+ ]
3323
+ }, undefined, true, undefined, this),
3324
+ metadata.other && Object.entries(metadata.other).map(([name, content]) => {
3325
+ const contentValue = Array.isArray(content) ? content.join(", ") : content;
3326
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("meta", {
3327
+ name,
3328
+ content: contentValue
3329
+ }, name, false, undefined, this);
3330
+ }),
3331
+ jsonLdArray.map((schema) => /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("script", {
3332
+ type: "application/ld+json",
3333
+ children: JSON.stringify(schema)
3334
+ }, getJsonLdKey(schema), false, undefined, this))
3335
+ ]
3336
+ }, undefined, true, undefined, this);
3337
+ }
3338
+ // src/seo/robots.ts
3339
+ function generateRobotsTxt(options) {
3340
+ const lines = [];
3341
+ for (const rule of options.rules) {
3342
+ const agents = Array.isArray(rule.userAgent) ? rule.userAgent : [rule.userAgent];
3343
+ for (const agent of agents) {
3344
+ lines.push(`User-agent: ${agent}`);
3345
+ }
3346
+ if (rule.allow) {
3347
+ const allowPaths = Array.isArray(rule.allow) ? rule.allow : [rule.allow];
3348
+ for (const allowPath of allowPaths) {
3349
+ lines.push(`Allow: ${allowPath}`);
3350
+ }
3351
+ }
3352
+ if (rule.disAllow) {
3353
+ const disAllowPaths = Array.isArray(rule.disAllow) ? rule.disAllow : [rule.disAllow];
3354
+ for (const disAllowPath of disAllowPaths) {
3355
+ lines.push(`Disallow: ${disAllowPath}`);
3356
+ }
3357
+ }
3358
+ if (rule.crawlDelay !== undefined) {
3359
+ lines.push(`Crawl-delay: ${rule.crawlDelay}`);
3360
+ }
3361
+ lines.push("");
3362
+ }
3363
+ if (options.sitemap) {
3364
+ const sitemaps = Array.isArray(options.sitemap) ? options.sitemap : [options.sitemap];
3365
+ for (const sitemapUrl of sitemaps) {
3366
+ lines.push(`Sitemap: ${sitemapUrl}`);
3367
+ }
3368
+ lines.push("");
3369
+ }
3370
+ if (options.host) {
3371
+ lines.push(`Host: ${options.host}`);
3372
+ }
3373
+ return `${lines.join(`
3374
+ `).trimEnd()}
3375
+ `;
3376
+ }
3377
+ function createRobotsHandler(options) {
3378
+ return () => {
3379
+ const robotsTxt = generateRobotsTxt(options);
3380
+ return new Response(robotsTxt, {
3381
+ status: 200,
3382
+ headers: {
3383
+ "Content-Type": "text/plain; charset=utf-8",
3384
+ "Cache-Control": "public, max-age=3600, s-maxage=86400"
3385
+ }
3386
+ });
3387
+ };
3388
+ }
3389
+ // src/seo/sitemap.ts
3390
+ function encodeRaktaXmlValue(text) {
3391
+ return text.replace(/&/g, "&amp;").replace(/'/g, "&apos;").replace(/"/g, "&quot;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/\r/g, "").replace(/\n/g, "").replace(/\t/g, " ").trim();
3392
+ }
3393
+ function normalizeBaseUrl(baseUrl) {
3394
+ return baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
3395
+ }
3396
+ function createAbsoluteUrl(baseUrl, loc) {
3397
+ if (loc.startsWith("http://") || loc.startsWith("https://")) {
3398
+ return loc;
3399
+ }
3400
+ if (loc.startsWith("/")) {
3401
+ return `${baseUrl}${loc}`;
3402
+ }
3403
+ return `${baseUrl}/${loc}`;
3404
+ }
3405
+ function normalizePriority(priority) {
3406
+ if (priority < 0) {
3407
+ return "0.0";
3408
+ }
3409
+ if (priority > 1) {
3410
+ return "1.0";
3411
+ }
3412
+ return priority.toFixed(1);
3413
+ }
3414
+ function generateSitemapXml(options) {
3415
+ const { baseUrl, entries, xslUrl } = options;
3416
+ const normalizedBase = normalizeBaseUrl(baseUrl);
3417
+ const xmlParts = [];
3418
+ xmlParts.push(`
3419
+ <?xml
3420
+ version="1.0"
3421
+ encoding="UTF-8"?
3422
+ >
3423
+ `);
3424
+ if (xslUrl) {
3425
+ xmlParts.push(`<?xml-stylesheet
3426
+ type="text/xsl"
3427
+ href="${encodeRaktaXmlValue(xslUrl)}"?
3428
+ >`);
3429
+ }
3430
+ xmlParts.push(`<urlset ` + `xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ` + `xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" ` + `xmlns:xhtml="http://www.w3.org/1999/xhtml">`);
3431
+ for (const entry of entries) {
3432
+ const fullLoc = createAbsoluteUrl(normalizedBase, entry.loc);
3433
+ xmlParts.push(`<url>`);
3434
+ xmlParts.push(`
3435
+ <loc>
3436
+ ${encodeRaktaXmlValue(fullLoc)}
3437
+ </loc>
3438
+ `);
3439
+ if (entry.lastmod) {
3440
+ xmlParts.push(`
3441
+ <lastmod>
3442
+ ${encodeRaktaXmlValue(entry.lastmod)}
3443
+ </lastmod>
3444
+ `);
3445
+ }
3446
+ if (entry.changefreq) {
3447
+ xmlParts.push(`
3448
+ <changefreq>
3449
+ ${entry.changefreq}
3450
+ </changefreq>
3451
+ `);
3452
+ }
3453
+ if (typeof entry.priority === "number") {
3454
+ xmlParts.push(`
3455
+ <priority>
3456
+ ${normalizePriority(entry.priority)}
3457
+ </priority>
3458
+ `);
3459
+ }
3460
+ if (entry.alternates) {
3461
+ for (const [lang, url] of Object.entries(entry.alternates)) {
3462
+ const fullAlt = createAbsoluteUrl(normalizedBase, url);
3463
+ xmlParts.push(`<xhtml:link
3464
+ rel="alternate"
3465
+ hreflang="${encodeRaktaXmlValue(lang)}"
3466
+ href="${encodeRaktaXmlValue(fullAlt)}"
3467
+ />`);
3468
+ }
3469
+ }
3470
+ if (entry.images) {
3471
+ for (const image of entry.images) {
3472
+ const imageLoc = createAbsoluteUrl(normalizedBase, image.loc);
3473
+ xmlParts.push(`<image:image>`);
3474
+ xmlParts.push(`
3475
+ <image:loc>
3476
+ ${encodeRaktaXmlValue(imageLoc)}
3477
+ </image:loc>
3478
+ `);
3479
+ if (image.caption) {
3480
+ xmlParts.push(`
3481
+ <image:caption>
3482
+ ${encodeRaktaXmlValue(image.caption)}
3483
+ </image:caption>
3484
+ `);
3485
+ }
3486
+ if (image.title) {
3487
+ xmlParts.push(`
3488
+ <image:title>
3489
+ ${encodeRaktaXmlValue(image.title)}
3490
+ </image:title>
3491
+ `);
3492
+ }
3493
+ xmlParts.push(`</image:image>`);
3494
+ }
3495
+ }
3496
+ xmlParts.push(`</url>`);
3497
+ }
3498
+ xmlParts.push(`</urlset>`);
3499
+ return xmlParts.join(`
3500
+ `);
3501
+ }
3502
+ function createSitemapHandler(options) {
3503
+ return () => {
3504
+ const xml = generateSitemapXml(options);
3505
+ return new Response(xml, {
3506
+ status: 200,
3507
+ headers: {
3508
+ "Content-Type": "application/xml; charset=utf-8",
3509
+ "Cache-Control": "public, max-age=3600, s-maxage=86400"
3510
+ }
3511
+ });
3512
+ };
3513
+ }
3514
+ function generateSitemapIndexXml(baseUrl, sitemaps) {
3515
+ const normalizedBase = normalizeBaseUrl(baseUrl);
3516
+ const xmlParts = [];
3517
+ xmlParts.push(`
3518
+ <?xml
3519
+ version="1.0"
3520
+ encoding="UTF-8"?
3521
+ >
3522
+ `);
3523
+ xmlParts.push(`
3524
+ <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3525
+ `);
3526
+ for (const entry of sitemaps) {
3527
+ const fullLoc = createAbsoluteUrl(normalizedBase, entry.loc);
3528
+ xmlParts.push(`<sitemap>`);
3529
+ xmlParts.push(`
3530
+ <loc>
3531
+ ${encodeRaktaXmlValue(fullLoc)}
3532
+ </loc>
3533
+ `);
3534
+ if (entry.lastmod) {
3535
+ xmlParts.push(`
3536
+ <lastmod>
3537
+ ${encodeRaktaXmlValue(entry.lastmod)}
3538
+ </lastmod>
3539
+ `);
3540
+ }
3541
+ xmlParts.push(`</sitemap>`);
3542
+ }
3543
+ xmlParts.push(`</sitemapindex>`);
3544
+ return xmlParts.join(`
3545
+ `);
3546
+ }
3547
+ // src/store/createStore.ts
3548
+ var import_react3 = __toESM(require_react(), 1);
3549
+ function createStoreApi(creator) {
3550
+ const listeners = new Set;
3551
+ let currentState;
3552
+ const getState = () => currentState;
3553
+ const emitChange = (nextState, previousState) => {
3554
+ if (Object.is(previousState, nextState)) {
3555
+ return;
3556
+ }
3557
+ for (const listenerFn of listeners) {
3558
+ listenerFn(nextState, previousState);
3559
+ }
3560
+ };
3561
+ const setState = (arg) => {
3562
+ const previousState = currentState;
3563
+ const partialUpdate = typeof arg === "function" ? arg(currentState) : arg;
3564
+ currentState = {
3565
+ ...currentState,
3566
+ ...partialUpdate
3567
+ };
3568
+ emitChange(currentState, previousState);
3569
+ };
3570
+ const subscribe = (listenerFn) => {
3571
+ listeners.add(listenerFn);
3572
+ return () => {
3573
+ listeners.delete(listenerFn);
3574
+ };
3575
+ };
3576
+ currentState = creator(setState, getState);
3577
+ const initialState = currentState;
3578
+ const reset = () => {
3579
+ const previousState = currentState;
3580
+ currentState = initialState;
3581
+ emitChange(currentState, previousState);
3582
+ };
3583
+ return {
3584
+ getState,
3585
+ setState,
3586
+ subscribe,
3587
+ reset
3588
+ };
3589
+ }
3590
+ function createRaktaStore(creator) {
3591
+ const storeApi = createStoreApi(creator);
3592
+ function useStore(selector) {
3593
+ const getSnapshot = () => {
3594
+ const state = storeApi.getState();
3595
+ if (selector !== undefined) {
3596
+ return selector(state);
3597
+ }
3598
+ return state;
3599
+ };
3600
+ return import_react3.useSyncExternalStore(storeApi.subscribe, getSnapshot, getSnapshot);
3601
+ }
3602
+ return Object.assign(useStore, storeApi);
3603
+ }
3604
+ // src/tide/adapter.ts
3605
+ import { existsSync as existsSync7, readFileSync as readFileSync3 } from "fs";
3606
+ import { join as join8 } from "path";
3607
+
3608
+ // src/tide/runtime.ts
3609
+ function createRuntimeContext(request, url, params, resolvedMode) {
3610
+ const searchParams = {};
3611
+ url.searchParams.forEach((value, key) => {
3612
+ searchParams[key] = value;
3613
+ });
3614
+ const requestHeaders = {};
3615
+ request.headers.forEach((value, key) => {
3616
+ requestHeaders[key] = value;
3617
+ });
3618
+ return {
3619
+ url,
3620
+ params,
3621
+ request,
3622
+ searchParams,
3623
+ resolvedMode,
3624
+ requestHeaders,
3625
+ pathname: url.pathname,
3626
+ timestampMs: Date.now(),
3627
+ method: request.method.toUpperCase()
3628
+ };
3629
+ }
3630
+ function buildTextResponse(body, status, headers) {
3631
+ return new Response(body, { status, headers });
3632
+ }
3633
+ function buildHtmlResponse(html, status = 200) {
3634
+ return buildTextResponse(html, status, {
3635
+ "Content-Type": "text/html; charset=utf-8"
3636
+ });
3637
+ }
3638
+ function buildJsonResponse2(responseData, status = 200) {
3639
+ return buildTextResponse(JSON.stringify(responseData), status, {
3640
+ "Content-Type": "application/json; charset=utf-8"
3641
+ });
3642
+ }
3643
+ function buildErrorResponse(errorMessage, status = 500) {
3644
+ return buildJsonResponse2({ error: errorMessage }, status);
3645
+ }
3646
+
3647
+ // src/tide/adapter.ts
3648
+ var STATIC_MIME_TYPES = {
3649
+ ".js": "application/javascript; charset=utf-8",
3650
+ ".ts": "application/javascript; charset=utf-8",
3651
+ ".css": "text/css; charset=utf-8",
3652
+ ".json": "application/json; charset=utf-8",
3653
+ ".png": "image/png",
3654
+ ".jpg": "image/jpeg",
3655
+ ".jpeg": "image/jpeg",
3656
+ ".webp": "image/webp",
3657
+ ".svg": "image/svg+xml",
3658
+ ".ico": "image/x-icon",
3659
+ ".woff": "font/woff",
3660
+ ".woff2": "font/woff2"
3661
+ };
3662
+ function mimeForPath(filePath) {
3663
+ const extensionIndex = filePath.lastIndexOf(".");
3664
+ if (extensionIndex < 0) {
3665
+ return "application/octet-stream";
3666
+ }
3667
+ const extension = filePath.slice(extensionIndex).toLowerCase();
3668
+ return STATIC_MIME_TYPES[extension] ?? "application/octet-stream";
3669
+ }
3670
+ function normalizeStaticPath(pathname) {
3671
+ const pathnameWithoutLeadingSlash = pathname.replace(/^\/+/, "");
3672
+ if (pathnameWithoutLeadingSlash.length > 0) {
3673
+ return pathnameWithoutLeadingSlash;
3674
+ }
3675
+ return "index.html";
3676
+ }
3677
+ function isApiRouteExports(value) {
3678
+ if (typeof value !== "object" || value === null) {
3679
+ return false;
3680
+ }
3681
+ return true;
3682
+ }
3683
+ function getApiRouteHandler(routeExports, method) {
3684
+ if (method === "GET") {
3685
+ return routeExports.GET;
3686
+ }
3687
+ if (method === "POST") {
3688
+ return routeExports.POST;
3689
+ }
3690
+ if (method === "PUT") {
3691
+ return routeExports.PUT;
3692
+ }
3693
+ if (method === "PATCH") {
3694
+ return routeExports.PATCH;
3695
+ }
3696
+ if (method === "DELETE") {
3697
+ return routeExports.DELETE;
3698
+ }
3699
+ if (method === "HEAD") {
3700
+ return routeExports.HEAD;
3701
+ }
3702
+ if (method === "OPTIONS") {
3703
+ return routeExports.OPTIONS;
3704
+ }
3705
+ return;
3706
+ }
3707
+ function createBunAdapter(adapterConfig, renderConfig) {
3708
+ const manifest = generateManifest(adapterConfig.appDir);
3709
+ const searchDirectories = [adapterConfig.publicDir, adapterConfig.outDir];
3710
+ let serverInstance;
3711
+ async function handle(request) {
3712
+ const url = new URL(request.url);
3713
+ const { pathname } = url;
3714
+ const staticPathname = normalizeStaticPath(pathname);
3715
+ for (const searchDirectory of searchDirectories) {
3716
+ const filePath = join8(searchDirectory, staticPathname);
3717
+ if (existsSync7(filePath) && !filePath.endsWith("/")) {
3718
+ return new Response(readFileSync3(filePath), {
3719
+ headers: {
3720
+ "Content-Type": mimeForPath(filePath),
3721
+ "Cache-Control": "public, max-age=31536000, immutable"
3722
+ }
3723
+ });
3724
+ }
3725
+ }
3726
+ const apiRoutes = manifest.routes.filter((route) => route.kind === "api");
3727
+ const apiMatch = matchRoute(pathname, apiRoutes);
3728
+ if (apiMatch) {
3729
+ const modulePath = join8(adapterConfig.appDir, apiMatch.entry.filePath);
3730
+ const routeModule = await import(modulePath);
3731
+ if (!isApiRouteExports(routeModule)) {
3732
+ return new Response("Invalid API route module", {
3733
+ status: 500
3734
+ });
3735
+ }
3736
+ const handler = getApiRouteHandler(routeModule, request.method.toUpperCase());
3737
+ if (!handler) {
3738
+ return new Response("Method not allowed", {
3739
+ status: 405
3740
+ });
3741
+ }
3742
+ return await handler(request);
3743
+ }
3744
+ const resolvedRouteMode = resolveRouteMode(pathname, renderConfig);
3745
+ const runtimeContext = createRuntimeContext(request, url, {}, resolvedRouteMode.mode);
3746
+ const renderResult = await render({
3747
+ routePath: runtimeContext.pathname,
3748
+ mode: runtimeContext.resolvedMode,
3749
+ params: runtimeContext.params,
3750
+ searchParams: runtimeContext.searchParams,
3751
+ requestHeaders: runtimeContext.requestHeaders,
3752
+ timestampMs: runtimeContext.timestampMs
3753
+ }, {
3754
+ appName: adapterConfig.appName,
3755
+ scriptPath: "/app.js",
3756
+ cssPath: "/globals.css",
3757
+ lang: "en"
3758
+ });
3759
+ if (renderResult.kind === "failure") {
3760
+ return buildErrorResponse(renderResult.reason, renderResult.httpStatus);
3761
+ }
3762
+ return buildHtmlResponse(renderResult.html, renderResult.httpStatus);
3763
+ }
3764
+ return {
3765
+ kind: "bun",
3766
+ handle,
3767
+ start: async () => {
3768
+ serverInstance = Bun.serve({
3769
+ port: adapterConfig.port,
3770
+ hostname: adapterConfig.host,
3771
+ fetch: handle
3772
+ });
3773
+ console.log(`[Rakta.js Tide] Running at http://${adapterConfig.host}:${serverInstance.port}`);
3774
+ },
3775
+ stop: () => {
3776
+ if (!serverInstance) {
3777
+ return;
3778
+ }
3779
+ serverInstance.stop();
3780
+ }
3781
+ };
3782
+ }
3783
+ // src/index.ts
3784
+ var RAKTA_NAME = "Rakta.js";
3785
+ var RAKTA_VERSION = "0.1.0";
3786
+ var RAKTA_TAGLINE = "Small in size. Fierce in speed. Alive in every route.";
3787
+ export {
3788
+ writeManifest,
3789
+ string,
3790
+ startDevServer,
3791
+ scanRoutes,
3792
+ scanForExports,
3793
+ resolveTitle,
3794
+ resolveRouteMode,
3795
+ resolveRobotsContent,
3796
+ resolvePrecacheList,
3797
+ requiresServer,
3798
+ renderServerError,
3799
+ renderNotFound,
3800
+ render,
3801
+ readManifest,
3802
+ publicProcedure,
3803
+ printManifest,
3804
+ printInspectReport,
3805
+ printAutoImportSummary,
3806
+ preFixErrors,
3807
+ object,
3808
+ number,
3809
+ mergeMetadata,
3810
+ mergeConfig,
3811
+ matchRoute,
3812
+ loadConfig,
3813
+ isRoadmapMode,
3814
+ isBuildTimeMode,
3815
+ inspectBuild,
3816
+ getModeDescriptor,
3817
+ generateSitemapXml,
3818
+ generateSitemapIndexXml,
3819
+ generateServiceWorkerSource,
3820
+ generateRobotsTxt,
3821
+ generateManifest2 as generatePwaManifest,
3822
+ generateManifestJson,
3823
+ generateManifest,
3824
+ generateAutoImports,
3825
+ findSpecialRoute,
3826
+ findLayoutsForPathname,
3827
+ defineRaktaConfig,
3828
+ defineConfig,
3829
+ defaultConfig,
3830
+ createSitemapHandler,
3831
+ createRuntimeContext,
3832
+ createRpcHandler,
3833
+ createRobotsHandler,
3834
+ createRaktaStore,
3835
+ createRaktaRouter,
3836
+ createRaktaHttp,
3837
+ createRaktaClient,
3838
+ createManifestHandler,
3839
+ createBunAdapter,
3840
+ buildTextResponse,
3841
+ buildProject,
3842
+ buildJsonResponse2 as buildJsonResponse,
3843
+ buildHtmlResponse,
3844
+ buildErrorResponse,
3845
+ buildCacheName,
3846
+ boolean,
3847
+ array,
3848
+ StringType,
3849
+ RaktaType,
3850
+ RaktaSchemaError,
3851
+ RaktaRpcError,
3852
+ RaktaHttpClient,
3853
+ RaktaHead,
3854
+ RENDER_MODE_DESCRIPTORS,
3855
+ RAKTA_VERSION,
3856
+ RAKTA_TAGLINE,
3857
+ RAKTA_NAME,
3858
+ ProcedureBuilder,
3859
+ Picture,
3860
+ Picture as Photo,
3861
+ OptionalType,
3862
+ ObjectType,
3863
+ NumberType,
3864
+ HttpTimeoutError,
3865
+ HttpResponseError,
3866
+ HttpNetworkError,
3867
+ Click,
3868
+ BooleanType,
3869
+ ArrayType
3870
+ };
3871
+
3872
+ //# debugId=3BC1F83A70EC3DAC64756E2164756E21