@teactjs/react 0.1.0-alpha.6 → 0.1.0-alpha.8

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 (2) hide show
  1. package/dist/index.js +99 -948
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,880 +1,46 @@
1
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
- var __toESM = (mod, isNodeMode, target) => {
8
- target = mod != null ? __create(__getProtoOf(mod)) : {};
9
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
- for (let key of __getOwnPropNames(mod))
11
- if (!__hasOwnProp.call(to, key))
12
- __defProp(to, key, {
13
- get: () => mod[key],
14
- enumerable: true
15
- });
16
- return to;
17
- };
18
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
-
20
- // ../../node_modules/.bun/react@19.2.4/node_modules/react/cjs/react.development.js
21
- var require_react_development = __commonJS((exports, module) => {
22
- (function() {
23
- function defineDeprecationWarning(methodName, info) {
24
- Object.defineProperty(Component.prototype, methodName, {
25
- get: function() {
26
- console.warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
27
- }
28
- });
29
- }
30
- function getIteratorFn(maybeIterable) {
31
- if (maybeIterable === null || typeof maybeIterable !== "object")
32
- return null;
33
- maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
34
- return typeof maybeIterable === "function" ? maybeIterable : null;
35
- }
36
- function warnNoop(publicInstance, callerName) {
37
- publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
38
- var warningKey = publicInstance + "." + callerName;
39
- 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);
40
- }
41
- function Component(props, context, updater) {
42
- this.props = props;
43
- this.context = context;
44
- this.refs = emptyObject;
45
- this.updater = updater || ReactNoopUpdateQueue;
46
- }
47
- function ComponentDummy() {}
48
- function PureComponent(props, context, updater) {
49
- this.props = props;
50
- this.context = context;
51
- this.refs = emptyObject;
52
- this.updater = updater || ReactNoopUpdateQueue;
53
- }
54
- function noop() {}
55
- function testStringCoercion(value) {
56
- return "" + value;
57
- }
58
- function checkKeyStringCoercion(value) {
59
- try {
60
- testStringCoercion(value);
61
- var JSCompiler_inline_result = false;
62
- } catch (e) {
63
- JSCompiler_inline_result = true;
64
- }
65
- if (JSCompiler_inline_result) {
66
- JSCompiler_inline_result = console;
67
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
68
- var JSCompiler_inline_result$jscomp$0 = typeof Symbol === "function" && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
69
- 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);
70
- return testStringCoercion(value);
71
- }
72
- }
73
- function getComponentNameFromType(type) {
74
- if (type == null)
75
- return null;
76
- if (typeof type === "function")
77
- return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
78
- if (typeof type === "string")
79
- return type;
80
- switch (type) {
81
- case REACT_FRAGMENT_TYPE:
82
- return "Fragment";
83
- case REACT_PROFILER_TYPE:
84
- return "Profiler";
85
- case REACT_STRICT_MODE_TYPE:
86
- return "StrictMode";
87
- case REACT_SUSPENSE_TYPE:
88
- return "Suspense";
89
- case REACT_SUSPENSE_LIST_TYPE:
90
- return "SuspenseList";
91
- case REACT_ACTIVITY_TYPE:
92
- return "Activity";
93
- }
94
- if (typeof type === "object")
95
- 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) {
96
- case REACT_PORTAL_TYPE:
97
- return "Portal";
98
- case REACT_CONTEXT_TYPE:
99
- return type.displayName || "Context";
100
- case REACT_CONSUMER_TYPE:
101
- return (type._context.displayName || "Context") + ".Consumer";
102
- case REACT_FORWARD_REF_TYPE:
103
- var innerType = type.render;
104
- type = type.displayName;
105
- type || (type = innerType.displayName || innerType.name || "", type = type !== "" ? "ForwardRef(" + type + ")" : "ForwardRef");
106
- return type;
107
- case REACT_MEMO_TYPE:
108
- return innerType = type.displayName || null, innerType !== null ? innerType : getComponentNameFromType(type.type) || "Memo";
109
- case REACT_LAZY_TYPE:
110
- innerType = type._payload;
111
- type = type._init;
112
- try {
113
- return getComponentNameFromType(type(innerType));
114
- } catch (x) {}
115
- }
116
- return null;
117
- }
118
- function getTaskName(type) {
119
- if (type === REACT_FRAGMENT_TYPE)
120
- return "<>";
121
- if (typeof type === "object" && type !== null && type.$$typeof === REACT_LAZY_TYPE)
122
- return "<...>";
123
- try {
124
- var name = getComponentNameFromType(type);
125
- return name ? "<" + name + ">" : "<...>";
126
- } catch (x) {
127
- return "<...>";
128
- }
129
- }
130
- function getOwner() {
131
- var dispatcher = ReactSharedInternals.A;
132
- return dispatcher === null ? null : dispatcher.getOwner();
133
- }
134
- function UnknownOwner() {
135
- return Error("react-stack-top-frame");
136
- }
137
- function hasValidKey(config) {
138
- if (hasOwnProperty.call(config, "key")) {
139
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
140
- if (getter && getter.isReactWarning)
141
- return false;
142
- }
143
- return config.key !== undefined;
144
- }
145
- function defineKeyPropWarningGetter(props, displayName) {
146
- function warnAboutAccessingKey() {
147
- 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));
148
- }
149
- warnAboutAccessingKey.isReactWarning = true;
150
- Object.defineProperty(props, "key", {
151
- get: warnAboutAccessingKey,
152
- configurable: true
153
- });
154
- }
155
- function elementRefGetterWithDeprecationWarning() {
156
- var componentName = getComponentNameFromType(this.type);
157
- 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."));
158
- componentName = this.props.ref;
159
- return componentName !== undefined ? componentName : null;
160
- }
161
- function ReactElement(type, key, props, owner, debugStack, debugTask) {
162
- var refProp = props.ref;
163
- type = {
164
- $$typeof: REACT_ELEMENT_TYPE,
165
- type,
166
- key,
167
- props,
168
- _owner: owner
169
- };
170
- (refProp !== undefined ? refProp : null) !== null ? Object.defineProperty(type, "ref", {
171
- enumerable: false,
172
- get: elementRefGetterWithDeprecationWarning
173
- }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
174
- type._store = {};
175
- Object.defineProperty(type._store, "validated", {
176
- configurable: false,
177
- enumerable: false,
178
- writable: true,
179
- value: 0
180
- });
181
- Object.defineProperty(type, "_debugInfo", {
182
- configurable: false,
183
- enumerable: false,
184
- writable: true,
185
- value: null
186
- });
187
- Object.defineProperty(type, "_debugStack", {
188
- configurable: false,
189
- enumerable: false,
190
- writable: true,
191
- value: debugStack
192
- });
193
- Object.defineProperty(type, "_debugTask", {
194
- configurable: false,
195
- enumerable: false,
196
- writable: true,
197
- value: debugTask
198
- });
199
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
200
- return type;
201
- }
202
- function cloneAndReplaceKey(oldElement, newKey) {
203
- newKey = ReactElement(oldElement.type, newKey, oldElement.props, oldElement._owner, oldElement._debugStack, oldElement._debugTask);
204
- oldElement._store && (newKey._store.validated = oldElement._store.validated);
205
- return newKey;
206
- }
207
- function validateChildKeys(node) {
208
- 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));
209
- }
210
- function isValidElement(object) {
211
- return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
212
- }
213
- function escape(key) {
214
- var escaperLookup = { "=": "=0", ":": "=2" };
215
- return "$" + key.replace(/[=:]/g, function(match) {
216
- return escaperLookup[match];
217
- });
218
- }
219
- function getElementKey(element, index) {
220
- return typeof element === "object" && element !== null && element.key != null ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
221
- }
222
- function resolveThenable(thenable) {
223
- switch (thenable.status) {
224
- case "fulfilled":
225
- return thenable.value;
226
- case "rejected":
227
- throw thenable.reason;
228
- default:
229
- switch (typeof thenable.status === "string" ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(function(fulfilledValue) {
230
- thenable.status === "pending" && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
231
- }, function(error) {
232
- thenable.status === "pending" && (thenable.status = "rejected", thenable.reason = error);
233
- })), thenable.status) {
234
- case "fulfilled":
235
- return thenable.value;
236
- case "rejected":
237
- throw thenable.reason;
238
- }
239
- }
240
- throw thenable;
241
- }
242
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
243
- var type = typeof children;
244
- if (type === "undefined" || type === "boolean")
245
- children = null;
246
- var invokeCallback = false;
247
- if (children === null)
248
- invokeCallback = true;
249
- else
250
- switch (type) {
251
- case "bigint":
252
- case "string":
253
- case "number":
254
- invokeCallback = true;
255
- break;
256
- case "object":
257
- switch (children.$$typeof) {
258
- case REACT_ELEMENT_TYPE:
259
- case REACT_PORTAL_TYPE:
260
- invokeCallback = true;
261
- break;
262
- case REACT_LAZY_TYPE:
263
- return invokeCallback = children._init, mapIntoArray(invokeCallback(children._payload), array, escapedPrefix, nameSoFar, callback);
264
- }
265
- }
266
- if (invokeCallback) {
267
- invokeCallback = children;
268
- callback = callback(invokeCallback);
269
- var childKey = nameSoFar === "" ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
270
- isArrayImpl(callback) ? (escapedPrefix = "", childKey != null && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
271
- return c;
272
- })) : 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));
273
- return 1;
274
- }
275
- invokeCallback = 0;
276
- childKey = nameSoFar === "" ? "." : nameSoFar + ":";
277
- if (isArrayImpl(children))
278
- for (var i = 0;i < children.length; i++)
279
- nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
280
- else if (i = getIteratorFn(children), typeof i === "function")
281
- 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; )
282
- nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
283
- else if (type === "object") {
284
- if (typeof children.then === "function")
285
- return mapIntoArray(resolveThenable(children), array, escapedPrefix, nameSoFar, callback);
286
- array = String(children);
287
- 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.");
288
- }
289
- return invokeCallback;
290
- }
291
- function mapChildren(children, func, context) {
292
- if (children == null)
293
- return children;
294
- var result = [], count = 0;
295
- mapIntoArray(children, result, "", "", function(child) {
296
- return func.call(context, child, count++);
297
- });
298
- return result;
299
- }
300
- function lazyInitializer(payload) {
301
- if (payload._status === -1) {
302
- var ioInfo = payload._ioInfo;
303
- ioInfo != null && (ioInfo.start = ioInfo.end = performance.now());
304
- ioInfo = payload._result;
305
- var thenable = ioInfo();
306
- thenable.then(function(moduleObject) {
307
- if (payload._status === 0 || payload._status === -1) {
308
- payload._status = 1;
309
- payload._result = moduleObject;
310
- var _ioInfo = payload._ioInfo;
311
- _ioInfo != null && (_ioInfo.end = performance.now());
312
- thenable.status === undefined && (thenable.status = "fulfilled", thenable.value = moduleObject);
313
- }
314
- }, function(error) {
315
- if (payload._status === 0 || payload._status === -1) {
316
- payload._status = 2;
317
- payload._result = error;
318
- var _ioInfo2 = payload._ioInfo;
319
- _ioInfo2 != null && (_ioInfo2.end = performance.now());
320
- thenable.status === undefined && (thenable.status = "rejected", thenable.reason = error);
321
- }
322
- });
323
- ioInfo = payload._ioInfo;
324
- if (ioInfo != null) {
325
- ioInfo.value = thenable;
326
- var displayName = thenable.displayName;
327
- typeof displayName === "string" && (ioInfo.name = displayName);
328
- }
329
- payload._status === -1 && (payload._status = 0, payload._result = thenable);
330
- }
331
- if (payload._status === 1)
332
- return ioInfo = payload._result, ioInfo === undefined && console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
333
-
334
- Your code should look like:
335
- const MyComponent = lazy(() => import('./MyComponent'))
336
-
337
- 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
338
-
339
- Your code should look like:
340
- const MyComponent = lazy(() => import('./MyComponent'))`, ioInfo), ioInfo.default;
341
- throw payload._result;
342
- }
343
- function resolveDispatcher() {
344
- var dispatcher = ReactSharedInternals.H;
345
- 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:
346
- 1. You might have mismatching versions of React and the renderer (such as React DOM)
347
- 2. You might be breaking the Rules of Hooks
348
- 3. You might have more than one copy of React in the same app
349
- See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`);
350
- return dispatcher;
351
- }
352
- function releaseAsyncTransition() {
353
- ReactSharedInternals.asyncTransitions--;
354
- }
355
- function enqueueTask(task) {
356
- if (enqueueTaskImpl === null)
357
- try {
358
- var requireString = ("require" + Math.random()).slice(0, 7);
359
- enqueueTaskImpl = (module && module[requireString]).call(module, "timers").setImmediate;
360
- } catch (_err) {
361
- enqueueTaskImpl = function(callback) {
362
- 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."));
363
- var channel = new MessageChannel;
364
- channel.port1.onmessage = callback;
365
- channel.port2.postMessage(undefined);
366
- };
367
- }
368
- return enqueueTaskImpl(task);
369
- }
370
- function aggregateErrors(errors) {
371
- return 1 < errors.length && typeof AggregateError === "function" ? new AggregateError(errors) : errors[0];
372
- }
373
- function popActScope(prevActQueue, prevActScopeDepth) {
374
- 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. ");
375
- actScopeDepth = prevActScopeDepth;
376
- }
377
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
378
- var queue = ReactSharedInternals.actQueue;
379
- if (queue !== null)
380
- if (queue.length !== 0)
381
- try {
382
- flushActQueue(queue);
383
- enqueueTask(function() {
384
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
385
- });
386
- return;
387
- } catch (error) {
388
- ReactSharedInternals.thrownErrors.push(error);
389
- }
390
- else
391
- ReactSharedInternals.actQueue = null;
392
- 0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
393
- }
394
- function flushActQueue(queue) {
395
- if (!isFlushing) {
396
- isFlushing = true;
397
- var i = 0;
398
- try {
399
- for (;i < queue.length; i++) {
400
- var callback = queue[i];
401
- do {
402
- ReactSharedInternals.didUsePromise = false;
403
- var continuation = callback(false);
404
- if (continuation !== null) {
405
- if (ReactSharedInternals.didUsePromise) {
406
- queue[i] = callback;
407
- queue.splice(0, i);
408
- return;
409
- }
410
- callback = continuation;
411
- } else
412
- break;
413
- } while (1);
414
- }
415
- queue.length = 0;
416
- } catch (error) {
417
- queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
418
- } finally {
419
- isFlushing = false;
420
- }
421
- }
422
- }
423
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
424
- 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 = {
425
- isMounted: function() {
426
- return false;
427
- },
428
- enqueueForceUpdate: function(publicInstance) {
429
- warnNoop(publicInstance, "forceUpdate");
430
- },
431
- enqueueReplaceState: function(publicInstance) {
432
- warnNoop(publicInstance, "replaceState");
433
- },
434
- enqueueSetState: function(publicInstance) {
435
- warnNoop(publicInstance, "setState");
436
- }
437
- }, assign = Object.assign, emptyObject = {};
438
- Object.freeze(emptyObject);
439
- Component.prototype.isReactComponent = {};
440
- Component.prototype.setState = function(partialState, callback) {
441
- if (typeof partialState !== "object" && typeof partialState !== "function" && partialState != null)
442
- throw Error("takes an object of state variables to update or a function which returns an object of state variables.");
443
- this.updater.enqueueSetState(this, partialState, callback, "setState");
444
- };
445
- Component.prototype.forceUpdate = function(callback) {
446
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
447
- };
448
- var deprecatedAPIs = {
449
- isMounted: [
450
- "isMounted",
451
- "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
452
- ],
453
- replaceState: [
454
- "replaceState",
455
- "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
456
- ]
457
- };
458
- for (fnName in deprecatedAPIs)
459
- deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
460
- ComponentDummy.prototype = Component.prototype;
461
- deprecatedAPIs = PureComponent.prototype = new ComponentDummy;
462
- deprecatedAPIs.constructor = PureComponent;
463
- assign(deprecatedAPIs, Component.prototype);
464
- deprecatedAPIs.isPureReactComponent = true;
465
- var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = {
466
- H: null,
467
- A: null,
468
- T: null,
469
- S: null,
470
- actQueue: null,
471
- asyncTransitions: 0,
472
- isBatchingLegacy: false,
473
- didScheduleLegacyUpdate: false,
474
- didUsePromise: false,
475
- thrownErrors: [],
476
- getCurrentStack: null,
477
- recentlyCreatedOwnerStacks: 0
478
- }, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
479
- return null;
480
- };
481
- deprecatedAPIs = {
482
- react_stack_bottom_frame: function(callStackForError) {
483
- return callStackForError();
484
- }
485
- };
486
- var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
487
- var didWarnAboutElementRef = {};
488
- var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(deprecatedAPIs, UnknownOwner)();
489
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
490
- var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = typeof reportError === "function" ? reportError : function(error) {
491
- if (typeof window === "object" && typeof window.ErrorEvent === "function") {
492
- var event = new window.ErrorEvent("error", {
493
- bubbles: true,
494
- cancelable: true,
495
- message: typeof error === "object" && error !== null && typeof error.message === "string" ? String(error.message) : String(error),
496
- error
497
- });
498
- if (!window.dispatchEvent(event))
499
- return;
500
- } else if (typeof process === "object" && typeof process.emit === "function") {
501
- process.emit("uncaughtException", error);
502
- return;
503
- }
504
- console.error(error);
505
- }, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = typeof queueMicrotask === "function" ? function(callback) {
506
- queueMicrotask(function() {
507
- return queueMicrotask(callback);
508
- });
509
- } : enqueueTask;
510
- deprecatedAPIs = Object.freeze({
511
- __proto__: null,
512
- c: function(size) {
513
- return resolveDispatcher().useMemoCache(size);
514
- }
515
- });
516
- var fnName = {
517
- map: mapChildren,
518
- forEach: function(children, forEachFunc, forEachContext) {
519
- mapChildren(children, function() {
520
- forEachFunc.apply(this, arguments);
521
- }, forEachContext);
522
- },
523
- count: function(children) {
524
- var n = 0;
525
- mapChildren(children, function() {
526
- n++;
527
- });
528
- return n;
529
- },
530
- toArray: function(children) {
531
- return mapChildren(children, function(child) {
532
- return child;
533
- }) || [];
534
- },
535
- only: function(children) {
536
- if (!isValidElement(children))
537
- throw Error("React.Children.only expected to receive a single React element child.");
538
- return children;
539
- }
540
- };
541
- exports.Activity = REACT_ACTIVITY_TYPE;
542
- exports.Children = fnName;
543
- exports.Component = Component;
544
- exports.Fragment = REACT_FRAGMENT_TYPE;
545
- exports.Profiler = REACT_PROFILER_TYPE;
546
- exports.PureComponent = PureComponent;
547
- exports.StrictMode = REACT_STRICT_MODE_TYPE;
548
- exports.Suspense = REACT_SUSPENSE_TYPE;
549
- exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
550
- exports.__COMPILER_RUNTIME = deprecatedAPIs;
551
- exports.act = function(callback) {
552
- var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
553
- actScopeDepth++;
554
- var queue = ReactSharedInternals.actQueue = prevActQueue !== null ? prevActQueue : [], didAwaitActCall = false;
555
- try {
556
- var result = callback();
557
- } catch (error) {
558
- ReactSharedInternals.thrownErrors.push(error);
559
- }
560
- if (0 < ReactSharedInternals.thrownErrors.length)
561
- throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
562
- if (result !== null && typeof result === "object" && typeof result.then === "function") {
563
- var thenable = result;
564
- queueSeveralMicrotasks(function() {
565
- 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 () => ...);"));
566
- });
567
- return {
568
- then: function(resolve, reject) {
569
- didAwaitActCall = true;
570
- thenable.then(function(returnValue) {
571
- popActScope(prevActQueue, prevActScopeDepth);
572
- if (prevActScopeDepth === 0) {
573
- try {
574
- flushActQueue(queue), enqueueTask(function() {
575
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
576
- });
577
- } catch (error$0) {
578
- ReactSharedInternals.thrownErrors.push(error$0);
579
- }
580
- if (0 < ReactSharedInternals.thrownErrors.length) {
581
- var _thrownError = aggregateErrors(ReactSharedInternals.thrownErrors);
582
- ReactSharedInternals.thrownErrors.length = 0;
583
- reject(_thrownError);
584
- }
585
- } else
586
- resolve(returnValue);
587
- }, function(error) {
588
- popActScope(prevActQueue, prevActScopeDepth);
589
- 0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
590
- });
591
- }
592
- };
593
- }
594
- var returnValue$jscomp$0 = result;
595
- popActScope(prevActQueue, prevActScopeDepth);
596
- prevActScopeDepth === 0 && (flushActQueue(queue), queue.length !== 0 && queueSeveralMicrotasks(function() {
597
- 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(() => ...)"));
598
- }), ReactSharedInternals.actQueue = null);
599
- if (0 < ReactSharedInternals.thrownErrors.length)
600
- throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
601
- return {
602
- then: function(resolve, reject) {
603
- didAwaitActCall = true;
604
- prevActScopeDepth === 0 ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
605
- return recursivelyFlushAsyncActWork(returnValue$jscomp$0, resolve, reject);
606
- })) : resolve(returnValue$jscomp$0);
607
- }
608
- };
609
- };
610
- exports.cache = function(fn) {
611
- return function() {
612
- return fn.apply(null, arguments);
613
- };
614
- };
615
- exports.cacheSignal = function() {
616
- return null;
617
- };
618
- exports.captureOwnerStack = function() {
619
- var getCurrentStack = ReactSharedInternals.getCurrentStack;
620
- return getCurrentStack === null ? null : getCurrentStack();
621
- };
622
- exports.cloneElement = function(element, config, children) {
623
- if (element === null || element === undefined)
624
- throw Error("The argument must be a React element, but you passed " + element + ".");
625
- var props = assign({}, element.props), key = element.key, owner = element._owner;
626
- if (config != null) {
627
- var JSCompiler_inline_result;
628
- a: {
629
- if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(config, "ref").get) && JSCompiler_inline_result.isReactWarning) {
630
- JSCompiler_inline_result = false;
631
- break a;
632
- }
633
- JSCompiler_inline_result = config.ref !== undefined;
634
- }
635
- JSCompiler_inline_result && (owner = getOwner());
636
- hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
637
- for (propName in config)
638
- !hasOwnProperty.call(config, propName) || propName === "key" || propName === "__self" || propName === "__source" || propName === "ref" && config.ref === undefined || (props[propName] = config[propName]);
639
- }
640
- var propName = arguments.length - 2;
641
- if (propName === 1)
642
- props.children = children;
643
- else if (1 < propName) {
644
- JSCompiler_inline_result = Array(propName);
645
- for (var i = 0;i < propName; i++)
646
- JSCompiler_inline_result[i] = arguments[i + 2];
647
- props.children = JSCompiler_inline_result;
648
- }
649
- props = ReactElement(element.type, key, props, owner, element._debugStack, element._debugTask);
650
- for (key = 2;key < arguments.length; key++)
651
- validateChildKeys(arguments[key]);
652
- return props;
653
- };
654
- exports.createContext = function(defaultValue) {
655
- defaultValue = {
656
- $$typeof: REACT_CONTEXT_TYPE,
657
- _currentValue: defaultValue,
658
- _currentValue2: defaultValue,
659
- _threadCount: 0,
660
- Provider: null,
661
- Consumer: null
662
- };
663
- defaultValue.Provider = defaultValue;
664
- defaultValue.Consumer = {
665
- $$typeof: REACT_CONSUMER_TYPE,
666
- _context: defaultValue
667
- };
668
- defaultValue._currentRenderer = null;
669
- defaultValue._currentRenderer2 = null;
670
- return defaultValue;
671
- };
672
- exports.createElement = function(type, config, children) {
673
- for (var i = 2;i < arguments.length; i++)
674
- validateChildKeys(arguments[i]);
675
- i = {};
676
- var key = null;
677
- if (config != null)
678
- 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)
679
- hasOwnProperty.call(config, propName) && propName !== "key" && propName !== "__self" && propName !== "__source" && (i[propName] = config[propName]);
680
- var childrenLength = arguments.length - 2;
681
- if (childrenLength === 1)
682
- i.children = children;
683
- else if (1 < childrenLength) {
684
- for (var childArray = Array(childrenLength), _i = 0;_i < childrenLength; _i++)
685
- childArray[_i] = arguments[_i + 2];
686
- Object.freeze && Object.freeze(childArray);
687
- i.children = childArray;
688
- }
689
- if (type && type.defaultProps)
690
- for (propName in childrenLength = type.defaultProps, childrenLength)
691
- i[propName] === undefined && (i[propName] = childrenLength[propName]);
692
- key && defineKeyPropWarningGetter(i, typeof type === "function" ? type.displayName || type.name || "Unknown" : type);
693
- var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
694
- return ReactElement(type, key, i, getOwner(), propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack, propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
695
- };
696
- exports.createRef = function() {
697
- var refObject = { current: null };
698
- Object.seal(refObject);
699
- return refObject;
700
- };
701
- exports.forwardRef = function(render) {
702
- 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.");
703
- render != null && render.defaultProps != null && console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");
704
- var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
705
- Object.defineProperty(elementType, "displayName", {
706
- enumerable: false,
707
- configurable: true,
708
- get: function() {
709
- return ownName;
710
- },
711
- set: function(name) {
712
- ownName = name;
713
- render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
714
- }
715
- });
716
- return elementType;
717
- };
718
- exports.isValidElement = isValidElement;
719
- exports.lazy = function(ctor) {
720
- ctor = { _status: -1, _result: ctor };
721
- var lazyType = {
722
- $$typeof: REACT_LAZY_TYPE,
723
- _payload: ctor,
724
- _init: lazyInitializer
725
- }, ioInfo = {
726
- name: "lazy",
727
- start: -1,
728
- end: -1,
729
- value: null,
730
- owner: null,
731
- debugStack: Error("react-stack-top-frame"),
732
- debugTask: console.createTask ? console.createTask("lazy()") : null
733
- };
734
- ctor._ioInfo = ioInfo;
735
- lazyType._debugInfo = [{ awaited: ioInfo }];
736
- return lazyType;
737
- };
738
- exports.memo = function(type, compare) {
739
- type == null && console.error("memo: The first argument must be a component. Instead received: %s", type === null ? "null" : typeof type);
740
- compare = {
741
- $$typeof: REACT_MEMO_TYPE,
742
- type,
743
- compare: compare === undefined ? null : compare
744
- };
745
- var ownName;
746
- Object.defineProperty(compare, "displayName", {
747
- enumerable: false,
748
- configurable: true,
749
- get: function() {
750
- return ownName;
751
- },
752
- set: function(name) {
753
- ownName = name;
754
- type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
755
- }
756
- });
757
- return compare;
758
- };
759
- exports.startTransition = function(scope) {
760
- var prevTransition = ReactSharedInternals.T, currentTransition = {};
761
- currentTransition._updatedFibers = new Set;
762
- ReactSharedInternals.T = currentTransition;
763
- try {
764
- var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
765
- onStartTransitionFinish !== null && onStartTransitionFinish(currentTransition, returnValue);
766
- typeof returnValue === "object" && returnValue !== null && typeof returnValue.then === "function" && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
767
- } catch (error) {
768
- reportGlobalError(error);
769
- } finally {
770
- 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;
771
- }
772
- };
773
- exports.unstable_useCacheRefresh = function() {
774
- return resolveDispatcher().useCacheRefresh();
775
- };
776
- exports.use = function(usable) {
777
- return resolveDispatcher().use(usable);
778
- };
779
- exports.useActionState = function(action, initialState, permalink) {
780
- return resolveDispatcher().useActionState(action, initialState, permalink);
781
- };
782
- exports.useCallback = function(callback, deps) {
783
- return resolveDispatcher().useCallback(callback, deps);
784
- };
785
- exports.useContext = function(Context) {
786
- var dispatcher = resolveDispatcher();
787
- 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?");
788
- return dispatcher.useContext(Context);
789
- };
790
- exports.useDebugValue = function(value, formatterFn) {
791
- return resolveDispatcher().useDebugValue(value, formatterFn);
792
- };
793
- exports.useDeferredValue = function(value, initialValue) {
794
- return resolveDispatcher().useDeferredValue(value, initialValue);
795
- };
796
- exports.useEffect = function(create, deps) {
797
- create == null && console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?");
798
- return resolveDispatcher().useEffect(create, deps);
799
- };
800
- exports.useEffectEvent = function(callback) {
801
- return resolveDispatcher().useEffectEvent(callback);
802
- };
803
- exports.useId = function() {
804
- return resolveDispatcher().useId();
805
- };
806
- exports.useImperativeHandle = function(ref, create, deps) {
807
- return resolveDispatcher().useImperativeHandle(ref, create, deps);
808
- };
809
- exports.useInsertionEffect = function(create, deps) {
810
- create == null && console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?");
811
- return resolveDispatcher().useInsertionEffect(create, deps);
812
- };
813
- exports.useLayoutEffect = function(create, deps) {
814
- create == null && console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?");
815
- return resolveDispatcher().useLayoutEffect(create, deps);
816
- };
817
- exports.useMemo = function(create, deps) {
818
- return resolveDispatcher().useMemo(create, deps);
819
- };
820
- exports.useOptimistic = function(passthrough, reducer) {
821
- return resolveDispatcher().useOptimistic(passthrough, reducer);
822
- };
823
- exports.useReducer = function(reducer, initialArg, init) {
824
- return resolveDispatcher().useReducer(reducer, initialArg, init);
825
- };
826
- exports.useRef = function(initialValue) {
827
- return resolveDispatcher().useRef(initialValue);
828
- };
829
- exports.useState = function(initialState) {
830
- return resolveDispatcher().useState(initialState);
831
- };
832
- exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
833
- return resolveDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
834
- };
835
- exports.useTransition = function() {
836
- return resolveDispatcher().useTransition();
837
- };
838
- exports.version = "19.2.4";
839
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
840
- })();
841
- });
842
-
843
- // ../../node_modules/.bun/react@19.2.4/node_modules/react/index.js
844
- var require_react = __commonJS((exports, module) => {
845
- var react_development = __toESM(require_react_development());
846
- if (false) {} else {
847
- module.exports = react_development;
848
- }
849
- });
850
-
851
2
  // src/index.ts
852
- var import_react5 = __toESM(require_react(), 1);
3
+ import {
4
+ useState as useState2,
5
+ useEffect as useEffect2,
6
+ useReducer,
7
+ useMemo,
8
+ useCallback as useCallback2,
9
+ useRef as useRef2,
10
+ useContext as useContext2,
11
+ useId as useId2,
12
+ use,
13
+ createContext as createContext2,
14
+ memo,
15
+ Fragment,
16
+ createElement,
17
+ Suspense
18
+ } from "react";
853
19
 
854
20
  // src/components.ts
855
- var import_react2 = __toESM(require_react(), 1);
21
+ import React2, { useContext, useId, createContext } from "react";
856
22
 
857
23
  // src/callback-registry.ts
858
- var import_react = __toESM(require_react(), 1);
859
- var CallbackRegistryCtx = import_react.default.createContext(null);
24
+ import React from "react";
25
+ var CallbackRegistryCtx = React.createContext(null);
860
26
 
861
27
  // src/components.ts
862
- var KeyboardCtx = import_react2.createContext(false);
863
- var ReplyKeyboardCtx = import_react2.createContext(false);
864
- var MediaGroupCtx = import_react2.createContext(false);
28
+ var KeyboardCtx = createContext(false);
29
+ var ReplyKeyboardCtx = createContext(false);
30
+ var MediaGroupCtx = createContext(false);
865
31
  function Message({ text, parseMode, disablePreview, children }) {
866
- return import_react2.default.createElement("tg-message", { text, parseMode, disablePreview }, children);
32
+ return React2.createElement("tg-message", { text, parseMode, disablePreview }, children);
867
33
  }
868
34
  function InlineKeyboard({ children }) {
869
- return import_react2.default.createElement(KeyboardCtx.Provider, { value: true }, import_react2.default.createElement("tg-keyboard", null, children));
35
+ return React2.createElement(KeyboardCtx.Provider, { value: true }, React2.createElement("tg-keyboard", null, children));
870
36
  }
871
37
  function ButtonRow({ children }) {
872
- const insideKeyboard = import_react2.useContext(KeyboardCtx);
38
+ const insideKeyboard = useContext(KeyboardCtx);
873
39
  if (!insideKeyboard) {
874
40
  throw new Error(`[Teact] <ButtonRow> must be used inside <InlineKeyboard>.
875
41
  ` + "Wrap your ButtonRow with <InlineKeyboard> first.");
876
42
  }
877
- return import_react2.default.createElement("tg-button-row", null, children);
43
+ return React2.createElement("tg-button-row", null, children);
878
44
  }
879
45
  var VARIANT_PREFIX = {
880
46
  default: "",
@@ -883,7 +49,7 @@ var VARIANT_PREFIX = {
883
49
  outline: "\u25E6 "
884
50
  };
885
51
  function Button({ text, variant = "default", onClick, url, conversation }) {
886
- const insideKeyboard = import_react2.useContext(KeyboardCtx);
52
+ const insideKeyboard = useContext(KeyboardCtx);
887
53
  if (!insideKeyboard) {
888
54
  throw new Error(`[Teact] <Button> must be used inside <InlineKeyboard>.
889
55
  ` + `Example:
@@ -893,8 +59,8 @@ function Button({ text, variant = "default", onClick, url, conversation }) {
893
59
  </ButtonRow>
894
60
  </InlineKeyboard>`);
895
61
  }
896
- const registry = import_react2.useContext(CallbackRegistryCtx);
897
- const id = import_react2.useId();
62
+ const registry = useContext(CallbackRegistryCtx);
63
+ const id = useId();
898
64
  let callbackData;
899
65
  if (url) {} else if (conversation) {
900
66
  callbackData = `__convo:${conversation}`;
@@ -907,105 +73,105 @@ function Button({ text, variant = "default", onClick, url, conversation }) {
907
73
  callbackData = text;
908
74
  }
909
75
  const displayText = VARIANT_PREFIX[variant] + text;
910
- return import_react2.default.createElement("tg-button", { text: displayText, callbackData, url });
76
+ return React2.createElement("tg-button", { text: displayText, callbackData, url });
911
77
  }
912
78
  function WebAppButton({ text, url, variant = "default" }) {
913
- const insideKeyboard = import_react2.useContext(KeyboardCtx);
79
+ const insideKeyboard = useContext(KeyboardCtx);
914
80
  if (!insideKeyboard) {
915
81
  throw new Error("[Teact] <Button.WebApp> must be used inside <InlineKeyboard>.");
916
82
  }
917
83
  const displayText = VARIANT_PREFIX[variant] + text;
918
- return import_react2.default.createElement("tg-button", { text: displayText, webAppUrl: url });
84
+ return React2.createElement("tg-button", { text: displayText, webAppUrl: url });
919
85
  }
920
86
  function Photo({ src, caption, parseMode, hasSpoiler, children }) {
921
- return import_react2.default.createElement("tg-photo", { src, caption, parseMode, hasSpoiler }, children);
87
+ return React2.createElement("tg-photo", { src, caption, parseMode, hasSpoiler }, children);
922
88
  }
923
89
  function Video({ src, caption, parseMode, width, height, duration, supportsStreaming, hasSpoiler, children }) {
924
- return import_react2.default.createElement("tg-video", { src, caption, parseMode, width, height, duration, supportsStreaming, hasSpoiler }, children);
90
+ return React2.createElement("tg-video", { src, caption, parseMode, width, height, duration, supportsStreaming, hasSpoiler }, children);
925
91
  }
926
92
  function Animation({ src, caption, parseMode, width, height, duration, hasSpoiler, children }) {
927
- return import_react2.default.createElement("tg-animation", { src, caption, parseMode, width, height, duration, hasSpoiler }, children);
93
+ return React2.createElement("tg-animation", { src, caption, parseMode, width, height, duration, hasSpoiler }, children);
928
94
  }
929
95
  function Voice({ src, caption, parseMode, duration, children }) {
930
- return import_react2.default.createElement("tg-voice", { src, caption, parseMode, duration }, children);
96
+ return React2.createElement("tg-voice", { src, caption, parseMode, duration }, children);
931
97
  }
932
98
  function Audio({ src, caption, parseMode, performer, title, duration, children }) {
933
- return import_react2.default.createElement("tg-audio", { src, caption, parseMode, performer, title, duration }, children);
99
+ return React2.createElement("tg-audio", { src, caption, parseMode, performer, title, duration }, children);
934
100
  }
935
101
  function VideoNote({ src, duration, length }) {
936
- return import_react2.default.createElement("tg-video-note", { src, duration, length });
102
+ return React2.createElement("tg-video-note", { src, duration, length });
937
103
  }
938
104
  function Sticker({ src, emoji }) {
939
- return import_react2.default.createElement("tg-sticker", { src, emoji });
105
+ return React2.createElement("tg-sticker", { src, emoji });
940
106
  }
941
107
  function Document({ src, caption, filename, children }) {
942
- return import_react2.default.createElement("tg-document", { src, caption, filename }, children);
108
+ return React2.createElement("tg-document", { src, caption, filename }, children);
943
109
  }
944
110
  function Contact({ phoneNumber, firstName, lastName, vcard }) {
945
- return import_react2.default.createElement("tg-contact", { phoneNumber, firstName, lastName, vcard });
111
+ return React2.createElement("tg-contact", { phoneNumber, firstName, lastName, vcard });
946
112
  }
947
113
  function Location({ latitude, longitude, horizontalAccuracy }) {
948
- return import_react2.default.createElement("tg-location", { latitude, longitude, horizontalAccuracy });
114
+ return React2.createElement("tg-location", { latitude, longitude, horizontalAccuracy });
949
115
  }
950
116
  function LiveLocation({ latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius }) {
951
- return import_react2.default.createElement("tg-location", { latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius });
117
+ return React2.createElement("tg-location", { latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius });
952
118
  }
953
119
  function Venue({ latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType }) {
954
- return import_react2.default.createElement("tg-venue", { latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType });
120
+ return React2.createElement("tg-venue", { latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType });
955
121
  }
956
122
  function MediaGroup({ children }) {
957
- return import_react2.default.createElement(MediaGroupCtx.Provider, { value: true }, import_react2.default.createElement("tg-media-group", null, children));
123
+ return React2.createElement(MediaGroupCtx.Provider, { value: true }, React2.createElement("tg-media-group", null, children));
958
124
  }
959
125
  function MediaPhoto({ src, caption, parseMode, hasSpoiler }) {
960
- const insideGroup = import_react2.useContext(MediaGroupCtx);
126
+ const insideGroup = useContext(MediaGroupCtx);
961
127
  if (!insideGroup) {
962
128
  throw new Error("[Teact] <MediaGroup.Photo> must be used inside <MediaGroup>.");
963
129
  }
964
- return import_react2.default.createElement("tg-media-photo", { src, caption, parseMode, hasSpoiler });
130
+ return React2.createElement("tg-media-photo", { src, caption, parseMode, hasSpoiler });
965
131
  }
966
132
  function MediaVideo({ src, caption, parseMode, width, height, duration, supportsStreaming, hasSpoiler }) {
967
- const insideGroup = import_react2.useContext(MediaGroupCtx);
133
+ const insideGroup = useContext(MediaGroupCtx);
968
134
  if (!insideGroup) {
969
135
  throw new Error("[Teact] <MediaGroup.Video> must be used inside <MediaGroup>.");
970
136
  }
971
- return import_react2.default.createElement("tg-media-video", { src, caption, parseMode, width, height, duration, supportsStreaming, hasSpoiler });
137
+ return React2.createElement("tg-media-video", { src, caption, parseMode, width, height, duration, supportsStreaming, hasSpoiler });
972
138
  }
973
139
  function ReplyKeyboard({ oneTimeKeyboard, resizeKeyboard = true, placeholder, isPersistent, children }) {
974
- return import_react2.default.createElement(ReplyKeyboardCtx.Provider, { value: true }, import_react2.default.createElement("tg-reply-keyboard", { oneTimeKeyboard, resizeKeyboard, placeholder, isPersistent }, children));
140
+ return React2.createElement(ReplyKeyboardCtx.Provider, { value: true }, React2.createElement("tg-reply-keyboard", { oneTimeKeyboard, resizeKeyboard, placeholder, isPersistent }, children));
975
141
  }
976
142
  function ReplyRow({ children }) {
977
- const inside = import_react2.useContext(ReplyKeyboardCtx);
143
+ const inside = useContext(ReplyKeyboardCtx);
978
144
  if (!inside) {
979
145
  throw new Error("[Teact] <ReplyKeyboard.Row> must be used inside <ReplyKeyboard>.");
980
146
  }
981
- return import_react2.default.createElement("tg-reply-row", null, children);
147
+ return React2.createElement("tg-reply-row", null, children);
982
148
  }
983
149
  function ReplyButton({ text }) {
984
- const inside = import_react2.useContext(ReplyKeyboardCtx);
150
+ const inside = useContext(ReplyKeyboardCtx);
985
151
  if (!inside) {
986
152
  throw new Error("[Teact] <ReplyKeyboard.Button> must be used inside <ReplyKeyboard>.");
987
153
  }
988
- return import_react2.default.createElement("tg-reply-button", { text });
154
+ return React2.createElement("tg-reply-button", { text });
989
155
  }
990
156
  function RequestContactButton({ text }) {
991
- const inside = import_react2.useContext(ReplyKeyboardCtx);
157
+ const inside = useContext(ReplyKeyboardCtx);
992
158
  if (!inside) {
993
159
  throw new Error("[Teact] <ReplyKeyboard.RequestContact> must be used inside <ReplyKeyboard>.");
994
160
  }
995
- return import_react2.default.createElement("tg-reply-button", { text, requestContact: true });
161
+ return React2.createElement("tg-reply-button", { text, requestContact: true });
996
162
  }
997
163
  function RequestLocationButton({ text }) {
998
- const inside = import_react2.useContext(ReplyKeyboardCtx);
164
+ const inside = useContext(ReplyKeyboardCtx);
999
165
  if (!inside) {
1000
166
  throw new Error("[Teact] <ReplyKeyboard.RequestLocation> must be used inside <ReplyKeyboard>.");
1001
167
  }
1002
- return import_react2.default.createElement("tg-reply-button", { text, requestLocation: true });
168
+ return React2.createElement("tg-reply-button", { text, requestLocation: true });
1003
169
  }
1004
170
  function ReplyKeyboardRemove() {
1005
- return import_react2.default.createElement("tg-reply-keyboard-remove");
171
+ return React2.createElement("tg-reply-keyboard-remove");
1006
172
  }
1007
173
  function Notification({ text, showAlert }) {
1008
- return import_react2.default.createElement("tg-notification", { text, showAlert });
174
+ return React2.createElement("tg-notification", { text, showAlert });
1009
175
  }
1010
176
  function Poll({
1011
177
  question,
@@ -1019,7 +185,7 @@ function Poll({
1019
185
  openPeriod,
1020
186
  isClosed
1021
187
  }) {
1022
- return import_react2.default.createElement("tg-poll", {
188
+ return React2.createElement("tg-poll", {
1023
189
  question,
1024
190
  options,
1025
191
  isAnonymous,
@@ -1033,13 +199,13 @@ function Poll({
1033
199
  });
1034
200
  }
1035
201
  function Bold({ children }) {
1036
- return import_react2.default.createElement("tg-bold", null, children);
202
+ return React2.createElement("tg-bold", null, children);
1037
203
  }
1038
204
  function Italic({ children }) {
1039
- return import_react2.default.createElement("tg-italic", null, children);
205
+ return React2.createElement("tg-italic", null, children);
1040
206
  }
1041
207
  function Code({ language, children }) {
1042
- return import_react2.default.createElement("tg-code", { language }, children);
208
+ return React2.createElement("tg-code", { language }, children);
1043
209
  }
1044
210
  var ALERT_ICON = {
1045
211
  info: "\u2139\uFE0F",
@@ -1050,19 +216,19 @@ var ALERT_ICON = {
1050
216
  function Alert({ variant = "info", title, children }) {
1051
217
  const icon = ALERT_ICON[variant];
1052
218
  const heading = title ? `${icon} ${title}` : icon;
1053
- return import_react2.default.createElement("tg-alert", { variant, heading }, children);
219
+ return React2.createElement("tg-alert", { variant, heading }, children);
1054
220
  }
1055
221
  function List({ ordered = false, children }) {
1056
- return import_react2.default.createElement("tg-list", { ordered }, children);
222
+ return React2.createElement("tg-list", { ordered }, children);
1057
223
  }
1058
224
  function ListItem({ children }) {
1059
- return import_react2.default.createElement("tg-list-item", null, children);
225
+ return React2.createElement("tg-list-item", null, children);
1060
226
  }
1061
227
  function Divider({ char = "\u2500", length = 20 }) {
1062
- return import_react2.default.createElement("tg-divider", { text: char.repeat(length) });
228
+ return React2.createElement("tg-divider", { text: char.repeat(length) });
1063
229
  }
1064
230
  function SuspenseFallback({ text = "\u23F3 Loading..." }) {
1065
- return import_react2.default.createElement("tg-message", { text });
231
+ return React2.createElement("tg-message", { text });
1066
232
  }
1067
233
  Message.Bold = Bold;
1068
234
  Message.Italic = Italic;
@@ -1084,9 +250,9 @@ Poll.Quiz = function QuizPoll(props) {
1084
250
  return Poll({ ...props, type: "quiz" });
1085
251
  };
1086
252
  // src/error-boundary.ts
1087
- var import_react3 = __toESM(require_react(), 1);
253
+ import React3 from "react";
1088
254
 
1089
- class ErrorBoundary extends import_react3.default.Component {
255
+ class ErrorBoundary extends React3.Component {
1090
256
  state = { error: null };
1091
257
  static getDerivedStateFromError(error) {
1092
258
  return { error };
@@ -1105,7 +271,7 @@ class ErrorBoundary extends import_react3.default.Component {
1105
271
  if (this.props.fallback) {
1106
272
  return this.props.fallback;
1107
273
  }
1108
- return import_react3.default.createElement("tg-message", {
274
+ return React3.createElement("tg-message", {
1109
275
  text: `\u274C Something went wrong:
1110
276
  ${this.state.error.message}
1111
277
 
@@ -1116,20 +282,20 @@ Use /start to restart.`
1116
282
  }
1117
283
  }
1118
284
  // src/hooks.ts
1119
- var import_react4 = __toESM(require_react(), 1);
285
+ import { useState, useEffect, useRef, useCallback } from "react";
1120
286
  var queryCache = new Map;
1121
287
  function useQuery(options) {
1122
288
  const { key, fn, enabled = true, staleTime = 30000, refetchInterval = 0 } = options;
1123
- const [data, setData] = import_react4.useState(() => {
289
+ const [data, setData] = useState(() => {
1124
290
  const cached = queryCache.get(key);
1125
291
  if (cached && Date.now() - cached.fetchedAt < staleTime)
1126
292
  return cached.data;
1127
293
  return;
1128
294
  });
1129
- const [error, setError] = import_react4.useState();
1130
- const [isLoading, setIsLoading] = import_react4.useState(!data && enabled);
1131
- const mountedRef = import_react4.useRef(true);
1132
- const refetch = import_react4.useCallback(async () => {
295
+ const [error, setError] = useState();
296
+ const [isLoading, setIsLoading] = useState(!data && enabled);
297
+ const mountedRef = useRef(true);
298
+ const refetch = useCallback(async () => {
1133
299
  setIsLoading(true);
1134
300
  setError(undefined);
1135
301
  try {
@@ -1146,7 +312,7 @@ function useQuery(options) {
1146
312
  setIsLoading(false);
1147
313
  }
1148
314
  }, [key, fn]);
1149
- import_react4.useEffect(() => {
315
+ useEffect(() => {
1150
316
  mountedRef.current = true;
1151
317
  if (enabled) {
1152
318
  const cached = queryCache.get(key);
@@ -1158,7 +324,7 @@ function useQuery(options) {
1158
324
  mountedRef.current = false;
1159
325
  };
1160
326
  }, [key, enabled]);
1161
- import_react4.useEffect(() => {
327
+ useEffect(() => {
1162
328
  if (!refetchInterval || !enabled)
1163
329
  return;
1164
330
  const id = setInterval(refetch, refetchInterval);
@@ -1175,10 +341,10 @@ function useQuery(options) {
1175
341
  }
1176
342
  function useMutation(options) {
1177
343
  const { fn, onSuccess, onError } = options;
1178
- const [data, setData] = import_react4.useState();
1179
- const [error, setError] = import_react4.useState();
1180
- const [isLoading, setIsLoading] = import_react4.useState(false);
1181
- const mutate = import_react4.useCallback(async (variables) => {
344
+ const [data, setData] = useState();
345
+ const [error, setError] = useState();
346
+ const [isLoading, setIsLoading] = useState(false);
347
+ const mutate = useCallback(async (variables) => {
1182
348
  setIsLoading(true);
1183
349
  setError(undefined);
1184
350
  try {
@@ -1195,7 +361,7 @@ function useMutation(options) {
1195
361
  setIsLoading(false);
1196
362
  }
1197
363
  }, [fn, onSuccess, onError]);
1198
- const reset = import_react4.useCallback(() => {
364
+ const reset = useCallback(() => {
1199
365
  setData(undefined);
1200
366
  setError(undefined);
1201
367
  setIsLoading(false);
@@ -1210,43 +376,28 @@ function useMutation(options) {
1210
376
  reset
1211
377
  };
1212
378
  }
1213
- var export_useState = import_react5.useState;
1214
- var export_useRef = import_react5.useRef;
1215
- var export_useReducer = import_react5.useReducer;
1216
- var export_useMemo = import_react5.useMemo;
1217
- var export_useId = import_react5.useId;
1218
- var export_useEffect = import_react5.useEffect;
1219
- var export_useContext = import_react5.useContext;
1220
- var export_useCallback = import_react5.useCallback;
1221
- var export_use = import_react5.use;
1222
- var export_memo = import_react5.memo;
1223
- var export_createElement = import_react5.createElement;
1224
- var export_createContext = import_react5.createContext;
1225
- var export_Suspense = import_react5.Suspense;
1226
- var export_Fragment = import_react5.Fragment;
1227
-
1228
379
  export {
1229
- export_useState as useState,
1230
- export_useRef as useRef,
1231
- export_useReducer as useReducer,
380
+ useState2 as useState,
381
+ useRef2 as useRef,
382
+ useReducer,
1232
383
  useQuery,
1233
384
  useMutation,
1234
- export_useMemo as useMemo,
1235
- export_useId as useId,
1236
- export_useEffect as useEffect,
1237
- export_useContext as useContext,
1238
- export_useCallback as useCallback,
1239
- export_use as use,
1240
- export_memo as memo,
1241
- export_createElement as createElement,
1242
- export_createContext as createContext,
385
+ useMemo,
386
+ useId2 as useId,
387
+ useEffect2 as useEffect,
388
+ useContext2 as useContext,
389
+ useCallback2 as useCallback,
390
+ use,
391
+ memo,
392
+ createElement,
393
+ createContext2 as createContext,
1243
394
  WebAppButton,
1244
395
  Voice,
1245
396
  VideoNote,
1246
397
  Video,
1247
398
  Venue,
1248
399
  SuspenseFallback,
1249
- export_Suspense as Suspense,
400
+ Suspense,
1250
401
  Sticker,
1251
402
  RequestLocationButton,
1252
403
  RequestContactButton,
@@ -1267,7 +418,7 @@ export {
1267
418
  List,
1268
419
  Italic,
1269
420
  InlineKeyboard,
1270
- export_Fragment as Fragment,
421
+ Fragment,
1271
422
  ErrorBoundary,
1272
423
  Document,
1273
424
  Divider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teactjs/react",
3
- "version": "0.1.0-alpha.6",
3
+ "version": "0.1.0-alpha.8",
4
4
  "description": "React components and hooks for Teact bot framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,10 +13,10 @@
13
13
  },
14
14
  "files": ["dist", "README.md"],
15
15
  "scripts": {
16
- "build": "bun build ./src/index.ts --outdir ./dist --format esm --target bun --external @teactjs/renderer --external @teactjs/react --external @teactjs/runtime --external @teactjs/telegram --external @teactjs/storage && tsc --emitDeclarationOnly --outDir dist --declaration --project tsconfig.build.json"
16
+ "build": "bun build ./src/index.ts --outdir ./dist --format esm --target bun --external react --external react/jsx-runtime --external react/jsx-dev-runtime --external @teactjs/renderer --external @teactjs/react --external @teactjs/runtime --external @teactjs/telegram --external @teactjs/storage && tsc --emitDeclarationOnly --outDir dist --declaration --project tsconfig.build.json"
17
17
  },
18
18
  "dependencies": {
19
- "@teactjs/renderer": "^0.1.0-alpha.6"
19
+ "@teactjs/renderer": "^0.1.0-alpha.8"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "react": "^18.0.0 || ^19.0.0"