@erikey/react 0.2.6 → 0.2.7

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.
@@ -0,0 +1,57 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+
37
+ // src/require-shim.ts
38
+ import * as React from "react";
39
+ import * as ReactDOM from "react-dom";
40
+ var g = globalThis;
41
+ if (typeof g.require === "undefined") {
42
+ g.require = function requireShim(moduleName) {
43
+ if (moduleName === "react") return React;
44
+ if (moduleName === "react-dom") return ReactDOM;
45
+ throw new Error(
46
+ `[require-shim] Dynamic require of "${moduleName}" is not supported. Only "react" and "react-dom" are shimmed.`
47
+ );
48
+ };
49
+ }
50
+
51
+ export {
52
+ __require,
53
+ __commonJS,
54
+ __export,
55
+ __toESM
56
+ };
57
+ //# sourceMappingURL=chunk-E3EMTIQ5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/require-shim.ts"],"sourcesContent":["/**\n * CJS Require Shim for Browser Environments\n *\n * This module MUST be imported at the very top of entry points (index.ts, ui/index.tsx)\n * BEFORE any other imports that might trigger CJS code.\n *\n * ## Why This Exists\n *\n * We bundle `better-auth` and `@daveyplate/better-auth-ui` into @erikey/react.\n * These packages depend on `use-sync-external-store` which ONLY ships CommonJS.\n * The CJS code contains `require(\"react\")` calls.\n *\n * When tsup/esbuild bundles CJS into ESM, it wraps require() calls in a `__require()`\n * helper that throws \"Dynamic require of X is not supported\" in browsers.\n *\n * The __require helper checks `typeof require !== \"undefined\"` first.\n * If require exists, it uses it. If not, it throws.\n *\n * ## How This Shim Works\n *\n * We set `globalThis.require` BEFORE the __require helper is initialized.\n * This makes `typeof require` return \"function\" instead of \"undefined\".\n * The __require helper then uses our shim instead of throwing.\n *\n * ## Environment Handling\n *\n * **Production (Vite build):**\n * - No require function exists\n * - We set globalThis.require to our shim\n * - __require uses our shim → returns React\n *\n * **Sandpack Preview:**\n * - Sandpack provides its own require function\n * - typeof globalThis.require !== \"undefined\" → we DON'T override\n * - __require uses Sandpack's require → Sandpack provides React\n *\n * ## Critical Notes\n *\n * - This file MUST be in package.json sideEffects to prevent tree-shaking\n * - This MUST be the first import in entry points\n * - The module executes immediately on import (side effect)\n */\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst g = globalThis as any;\n\n// Only set require if it doesn't exist\n// Sandpack and other environments may provide their own\nif (typeof g.require === 'undefined') {\n g.require = function requireShim(moduleName: string): unknown {\n if (moduleName === 'react') return React;\n if (moduleName === 'react-dom') return ReactDOM;\n // For any other module, throw a clear error\n throw new Error(\n `[require-shim] Dynamic require of \"${moduleName}\" is not supported. ` +\n `Only \"react\" and \"react-dom\" are shimmed.`\n );\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,YAAY,WAAW;AACvB,YAAY,cAAc;AAG1B,IAAM,IAAI;AAIV,IAAI,OAAO,EAAE,YAAY,aAAa;AACpC,IAAE,UAAU,SAAS,YAAY,YAA6B;AAC5D,QAAI,eAAe,QAAS,QAAO;AACnC,QAAI,eAAe,YAAa,QAAO;AAEvC,UAAM,IAAI;AAAA,MACR,sCAAsC,UAAU;AAAA,IAElD;AAAA,EACF;AACF;","names":[]}