hadars 1.0.1 → 1.0.2

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  renderPreflight,
3
3
  renderToString
4
- } from "./chunk-HIKMDNRB.js";
4
+ } from "./chunk-QOTDCUE5.js";
5
5
  import {
6
6
  createElement
7
7
  } from "./chunk-OZUZS2PD.js";
@@ -6,12 +6,8 @@ import {
6
6
  SUSPENSE_TYPE,
7
7
  createElement
8
8
  } from "./chunk-OZUZS2PD.js";
9
- import {
10
- __require
11
- } from "./chunk-3RG5ZIWI.js";
12
9
 
13
10
  // src/slim-react/renderContext.ts
14
- import { createRequire as _nodeCreateRequire } from "module";
15
11
  var MAP_KEY = "__slimReactContextMap";
16
12
  var _g = globalThis;
17
13
  if (!("__slimReactContextMap" in _g)) _g[MAP_KEY] = null;
@@ -146,31 +142,12 @@ function getTreeId() {
146
142
  const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
147
143
  return stripped + overflow;
148
144
  }
149
- var _detectReact = () => {
150
- if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
151
- const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
152
- return {
153
- major,
154
- // Exact patch version is unknown from the define alone; use a
155
- // representative fallback. Most libraries only check the major.
156
- version: major < 19 ? "18.3.1" : "19.1.1"
157
- };
158
- }
159
- const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
160
- try {
161
- return parse(__require("react").version);
162
- } catch {
163
- }
164
- try {
165
- const req = _nodeCreateRequire(process.cwd() + "/__hadars__.js");
166
- return parse(req("react").version);
167
- } catch {
168
- }
169
- return { major: 19, version: "19.1.1" };
170
- };
171
- var _react = _detectReact();
172
- var REACT_MAJOR = _react.major;
173
- var REACT_VERSION = _react.version;
145
+ var REACT_MAJOR = typeof __HADARS_REACT_MAJOR__ !== "undefined" ? parseInt(String(__HADARS_REACT_MAJOR__), 10) : 19;
146
+ var REACT_VERSION = REACT_MAJOR < 19 ? "18.3.1" : "19.1.1";
147
+ function setReactVersion(major, version2) {
148
+ REACT_MAJOR = major;
149
+ REACT_VERSION = version2 ?? (major < 19 ? "18.3.1" : "19.1.1");
150
+ }
174
151
  function makeId() {
175
152
  const st = s();
176
153
  const treeId = getTreeId();
@@ -272,9 +249,22 @@ function createContext(defaultValue) {
272
249
 
273
250
  // src/slim-react/dispatcher.ts
274
251
  import * as ReactNS from "react";
275
- var _r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
276
- var _r18Raw = !_r19 ? ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"] : void 0;
277
- var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : void 0;
252
+ var _r19;
253
+ var _r18;
254
+ var _detected = false;
255
+ var _k19 = "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE";
256
+ var _k18 = "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";
257
+ function _detect() {
258
+ if (_detected) return;
259
+ _detected = true;
260
+ const r19 = ReactNS[_k19];
261
+ if (r19) {
262
+ _r19 = r19;
263
+ return;
264
+ }
265
+ const raw = ReactNS[_k18];
266
+ if (raw?.ReactCurrentDispatcher) _r18 = raw;
267
+ }
278
268
  var slimDispatcher = {
279
269
  useId: makeId,
280
270
  readContext: (ctx) => getContextValue(ctx),
@@ -302,6 +292,7 @@ var slimDispatcher = {
302
292
  useHostTransitionStatus: () => false
303
293
  };
304
294
  function installDispatcher() {
295
+ _detect();
305
296
  if (_r19) {
306
297
  const prev = _r19.H;
307
298
  _r19.H = slimDispatcher;
@@ -315,6 +306,7 @@ function installDispatcher() {
315
306
  return null;
316
307
  }
317
308
  function restoreDispatcher(prev) {
309
+ _detect();
318
310
  if (_r19) _r19.H = prev;
319
311
  else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
320
312
  }
@@ -1170,7 +1162,7 @@ var Component = class {
1170
1162
  var PureComponent = class extends Component {
1171
1163
  };
1172
1164
  var version = REACT_VERSION;
1173
- var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2 = {
1165
+ var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
1174
1166
  ReactCurrentDispatcher: { current: null },
1175
1167
  ReactCurrentBatchConfig: { transition: null },
1176
1168
  ReactCurrentOwner: { current: null }
@@ -1220,11 +1212,12 @@ var React = {
1220
1212
  // Version
1221
1213
  version,
1222
1214
  // React 18 internals
1223
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2
1215
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
1224
1216
  };
1225
1217
  var slim_react_default = React;
1226
1218
 
1227
1219
  export {
1220
+ setReactVersion,
1228
1221
  useState,
1229
1222
  useReducer,
1230
1223
  useEffect,
@@ -1259,6 +1252,6 @@ export {
1259
1252
  Component,
1260
1253
  PureComponent,
1261
1254
  version,
1262
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2 as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
1255
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
1263
1256
  slim_react_default
1264
1257
  };
package/dist/cli.js CHANGED
@@ -148,7 +148,6 @@ var REACT19_ELEMENT = Symbol.for("react.transitional.element");
148
148
  var FRAGMENT_TYPE = Symbol.for("react.fragment");
149
149
  var SUSPENSE_TYPE = Symbol.for("react.suspense");
150
150
  // src/slim-react/renderContext.ts
151
- import { createRequire as _nodeCreateRequire } from "node:module";
152
151
  var MAP_KEY = "__slimReactContextMap";
153
152
  var _g = globalThis;
154
153
  if (!("__slimReactContextMap" in _g))
@@ -285,27 +284,8 @@ function getTreeId() {
285
284
  const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
286
285
  return stripped + overflow;
287
286
  }
288
- var _detectReact = () => {
289
- if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
290
- const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
291
- return {
292
- major,
293
- version: major < 19 ? "18.3.1" : "19.1.1"
294
- };
295
- }
296
- const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
297
- try {
298
- return parse(__require("react").version);
299
- } catch {}
300
- try {
301
- const req = _nodeCreateRequire(process.cwd() + "/__hadars__.js");
302
- return parse(req("react").version);
303
- } catch {}
304
- return { major: 19, version: "19.1.1" };
305
- };
306
- var _react = _detectReact();
307
- var REACT_MAJOR = _react.major;
308
- var REACT_VERSION = _react.version;
287
+ var REACT_MAJOR = typeof __HADARS_REACT_MAJOR__ !== "undefined" ? parseInt(String(__HADARS_REACT_MAJOR__), 10) : 19;
288
+ var REACT_VERSION = REACT_MAJOR < 19 ? "18.3.1" : "19.1.1";
309
289
  function makeId() {
310
290
  const st = s();
311
291
  const treeId = getTreeId();
@@ -385,9 +365,24 @@ function use(usable) {
385
365
  }
386
366
  // src/slim-react/dispatcher.ts
387
367
  import * as ReactNS from "react";
388
- var _r19 = ReactNS.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
389
- var _r18Raw = !_r19 ? ReactNS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED : undefined;
390
- var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : undefined;
368
+ var _r19;
369
+ var _r18;
370
+ var _detected = false;
371
+ var _k19 = "__CLIENT_INTERNALS_DO_NOT_USE" + "_OR_WARN_USERS_THEY_CANNOT_UPGRADE";
372
+ var _k18 = "__SECRET_INTERNALS_DO_NOT_USE" + "_OR_YOU_WILL_BE_FIRED";
373
+ function _detect() {
374
+ if (_detected)
375
+ return;
376
+ _detected = true;
377
+ const r19 = ReactNS[_k19];
378
+ if (r19) {
379
+ _r19 = r19;
380
+ return;
381
+ }
382
+ const raw = ReactNS[_k18];
383
+ if (raw?.ReactCurrentDispatcher)
384
+ _r18 = raw;
385
+ }
391
386
  var slimDispatcher = {
392
387
  useId: makeId,
393
388
  readContext: (ctx) => getContextValue(ctx),
@@ -413,6 +408,7 @@ var slimDispatcher = {
413
408
  useHostTransitionStatus: () => false
414
409
  };
415
410
  function installDispatcher() {
411
+ _detect();
416
412
  if (_r19) {
417
413
  const prev = _r19.H;
418
414
  _r19.H = slimDispatcher;
@@ -426,6 +422,7 @@ function installDispatcher() {
426
422
  return null;
427
423
  }
428
424
  function restoreDispatcher(prev) {
425
+ _detect();
429
426
  if (_r19)
430
427
  _r19.H = prev;
431
428
  else if (_r18)
@@ -3232,8 +3229,166 @@ Deploy instructions:`);
3232
3229
  await unlink(shimPath).catch(() => {});
3233
3230
  }
3234
3231
  }
3235
- var TEMPLATES = {
3236
- "package.json": (name) => JSON.stringify({
3232
+ var _R = "\x1B[0m";
3233
+ var _B = "\x1B[1m";
3234
+ var _D = "\x1B[2m";
3235
+ var _C = "\x1B[36m";
3236
+ var _G = "\x1B[32m";
3237
+ var _UP_KEY = "\x1B[A";
3238
+ var _DOWN_KEY = "\x1B[B";
3239
+ var _HIDE = "\x1B[?25l";
3240
+ var _SHOW = "\x1B[?25h";
3241
+ var _cl = () => "\r\x1B[2K";
3242
+ var _up = (n) => n > 0 ? `\x1B[${n}A` : "";
3243
+ function _readKeys(handler) {
3244
+ return new Promise((resolve2) => {
3245
+ const { stdin } = process;
3246
+ const wasRaw = stdin.isTTY && stdin.isRaw;
3247
+ if (stdin.isTTY)
3248
+ stdin.setRawMode(true);
3249
+ stdin.resume();
3250
+ stdin.setEncoding("utf-8");
3251
+ const onData = (key) => {
3252
+ if (key === "\x03") {
3253
+ cleanup();
3254
+ process.stdout.write(_SHOW);
3255
+ process.exit(130);
3256
+ }
3257
+ if (handler(key))
3258
+ cleanup();
3259
+ };
3260
+ const cleanup = () => {
3261
+ stdin.removeListener("data", onData);
3262
+ if (stdin.isTTY && !wasRaw)
3263
+ stdin.setRawMode(false);
3264
+ stdin.pause();
3265
+ resolve2();
3266
+ };
3267
+ stdin.on("data", onData);
3268
+ });
3269
+ }
3270
+ async function promptRadio(question, options) {
3271
+ const out = process.stdout;
3272
+ let cursor = 0;
3273
+ const total = 1 + options.length;
3274
+ const render = (redraw) => {
3275
+ if (redraw)
3276
+ out.write(_up(total));
3277
+ out.write(`${_cl()} ${_B}${question}${_R}
3278
+ `);
3279
+ for (let i = 0;i < options.length; i++) {
3280
+ const arrow = i === cursor ? `${_C}❯${_R}` : " ";
3281
+ const text = i === cursor ? `${_B}${options[i]}${_R}` : `${_D}${options[i]}${_R}`;
3282
+ out.write(`${_cl()} ${arrow} ${text}
3283
+ `);
3284
+ }
3285
+ };
3286
+ out.write(_HIDE);
3287
+ render(false);
3288
+ await _readKeys((key) => {
3289
+ if (key === _UP_KEY && cursor > 0) {
3290
+ cursor--;
3291
+ render(true);
3292
+ } else if (key === _DOWN_KEY && cursor < options.length - 1) {
3293
+ cursor++;
3294
+ render(true);
3295
+ } else if (key === "\r") {
3296
+ return true;
3297
+ }
3298
+ return false;
3299
+ });
3300
+ out.write(_up(total));
3301
+ out.write(`${_cl()} ${question} ${_C}${_B}${options[cursor]}${_R}
3302
+ `);
3303
+ for (let i = 0;i < options.length; i++)
3304
+ out.write(`${_cl()}
3305
+ `);
3306
+ out.write(_up(options.length));
3307
+ out.write(_SHOW);
3308
+ return cursor;
3309
+ }
3310
+ async function promptMultiSelect(question, options) {
3311
+ const out = process.stdout;
3312
+ let cursor = 0;
3313
+ const selected = new Set;
3314
+ const total = 2 + options.length;
3315
+ const render = (redraw) => {
3316
+ if (redraw)
3317
+ out.write(_up(total));
3318
+ out.write(`${_cl()} ${_B}${question}${_R}
3319
+ `);
3320
+ out.write(`${_cl()} ${_D}↑↓ navigate · Space select · Enter confirm${_R}
3321
+ `);
3322
+ for (let i = 0;i < options.length; i++) {
3323
+ const arrow = i === cursor ? `${_C}❯${_R}` : " ";
3324
+ const box = selected.has(i) ? `${_G}●${_R}` : `${_D}○${_R}`;
3325
+ const text = i === cursor ? `${_B}${options[i]}${_R}` : `${_D}${options[i]}${_R}`;
3326
+ out.write(`${_cl()} ${arrow} ${box} ${text}
3327
+ `);
3328
+ }
3329
+ };
3330
+ out.write(_HIDE);
3331
+ render(false);
3332
+ await _readKeys((key) => {
3333
+ if (key === _UP_KEY && cursor > 0) {
3334
+ cursor--;
3335
+ render(true);
3336
+ } else if (key === _DOWN_KEY && cursor < options.length - 1) {
3337
+ cursor++;
3338
+ render(true);
3339
+ } else if (key === " ") {
3340
+ selected.has(cursor) ? selected.delete(cursor) : selected.add(cursor);
3341
+ render(true);
3342
+ } else if (key === "\r") {
3343
+ return true;
3344
+ }
3345
+ return false;
3346
+ });
3347
+ const picked = [...selected].sort((a, b) => a - b);
3348
+ const summary = picked.length > 0 ? picked.map((i) => options[i]).join(", ") : "none";
3349
+ out.write(_up(total));
3350
+ out.write(`${_cl()} ${question} ${_C}${_B}${summary}${_R}
3351
+ `);
3352
+ for (let i = 0;i < total - 1; i++)
3353
+ out.write(`${_cl()}
3354
+ `);
3355
+ out.write(_up(total - 1));
3356
+ out.write(_SHOW);
3357
+ return picked;
3358
+ }
3359
+ var PLUGINS = [
3360
+ { pkg: "@swc/plugin-emotion", version: "12.0.0", label: "Emotion (CSS-in-JS)" },
3361
+ { pkg: "@swc/plugin-styled-components", version: "10.0.0", label: "styled-components" },
3362
+ { pkg: "@swc/plugin-relay", version: "10.0.0", label: "Relay (GraphQL)" },
3363
+ { pkg: "@swc/plugin-styled-jsx", version: "11.0.0", label: "styled-jsx" },
3364
+ { pkg: "@swc/plugin-transform-imports", version: "10.0.0", label: "transform-imports" },
3365
+ { pkg: "@swc/plugin-loadable-components", version: "9.0.0", label: "Loadable Components" },
3366
+ { pkg: "@swc/plugin-formatjs", version: "7.0.0", label: "FormatJS (i18n)" }
3367
+ ];
3368
+ function renderSwcPluginsConfig(plugins) {
3369
+ if (plugins.length === 0)
3370
+ return "";
3371
+ const lines = plugins.map((p) => {
3372
+ if (p.pkg === "@swc/plugin-relay") {
3373
+ return ` ['${p.pkg}', { rootDir: process.cwd(), artifactDirectory: 'src/__generated__' }],`;
3374
+ }
3375
+ return ` ['${p.pkg}', {}],`;
3376
+ });
3377
+ return `
3378
+ swcPlugins: [
3379
+ ${lines.join(`
3380
+ `)}
3381
+ ],`;
3382
+ }
3383
+ function buildTemplates(name, opts) {
3384
+ const { useTypeScript, plugins } = opts;
3385
+ const appExt = useTypeScript ? "tsx" : "jsx";
3386
+ const cfgExt = useTypeScript ? "ts" : "js";
3387
+ const tsOrJs = useTypeScript ? "tsconfig.json" : "jsconfig.json";
3388
+ const pluginDeps = {};
3389
+ for (const p of plugins)
3390
+ pluginDeps[p.pkg] = p.version;
3391
+ const packageJson = JSON.stringify({
3237
3392
  name,
3238
3393
  version: "0.1.0",
3239
3394
  type: "module",
@@ -3247,19 +3402,28 @@ var TEMPLATES = {
3247
3402
  hadars: "latest",
3248
3403
  react: "^19.0.0",
3249
3404
  "react-dom": "^19.0.0"
3250
- }
3405
+ },
3406
+ ...Object.keys(pluginDeps).length > 0 ? { devDependencies: pluginDeps } : {}
3251
3407
  }, null, 2) + `
3252
- `,
3253
- "hadars.config.ts": () => `import type { HadarsOptions } from 'hadars';
3408
+ `;
3409
+ const swcSection = renderSwcPluginsConfig(plugins);
3410
+ const hadarsConfig = useTypeScript ? `import type { HadarsOptions } from 'hadars';
3254
3411
 
3255
3412
  const config: HadarsOptions = {
3256
3413
  entry: 'src/App.tsx',
3257
- port: 3000,
3414
+ port: 3000,${swcSection}
3258
3415
  };
3259
3416
 
3260
3417
  export default config;
3261
- `,
3262
- "tsconfig.json": () => JSON.stringify({
3418
+ ` : `/** @type {import('hadars').HadarsOptions} */
3419
+ const config = {
3420
+ entry: 'src/App.jsx',
3421
+ port: 3000,${swcSection}
3422
+ };
3423
+
3424
+ export default config;
3425
+ `;
3426
+ const tsConfigContent = useTypeScript ? JSON.stringify({
3263
3427
  compilerOptions: {
3264
3428
  lib: ["ESNext", "DOM"],
3265
3429
  target: "ESNext",
@@ -3274,215 +3438,184 @@ export default config;
3274
3438
  skipLibCheck: true
3275
3439
  }
3276
3440
  }, null, 2) + `
3277
- `,
3278
- ".gitignore": () => `node_modules/
3279
- .hadars/
3280
- dist/
3281
- `,
3282
- "src/App.tsx": () => `import React from 'react';
3283
- import { HadarsHead, type HadarsApp } from 'hadars';
3441
+ ` : JSON.stringify({
3442
+ compilerOptions: {
3443
+ lib: ["ESNext", "DOM"],
3444
+ target: "ESNext",
3445
+ module: "ESNext",
3446
+ moduleResolution: "bundler",
3447
+ jsx: "react-jsx",
3448
+ checkJs: true,
3449
+ noEmit: true,
3450
+ skipLibCheck: true
3451
+ }
3452
+ }, null, 2) + `
3453
+ `;
3454
+ const appImports = useTypeScript ? `import React from 'react';
3455
+ import { HadarsHead, type HadarsApp } from 'hadars';` : `import React from 'react';
3456
+ import { HadarsHead } from 'hadars';`;
3457
+ const appSignature = useTypeScript ? `const App: HadarsApp<{}> = () => {` : `const App = () => {`;
3458
+ const appContent = `${appImports}
3284
3459
 
3285
3460
  const css = \`
3286
- *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
3461
+ *, *::before, *::after { box-sizing: border-box; }
3287
3462
 
3288
- body {
3289
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
3290
- background: #0f0f13;
3291
- color: #e2e8f0;
3292
- min-height: 100vh;
3463
+ :root {
3464
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3465
+ line-height: 1.5;
3466
+ font-weight: 400;
3467
+ color-scheme: light dark;
3468
+ color: rgba(255, 255, 255, 0.87);
3469
+ background-color: #242424;
3470
+ font-synthesis: none;
3471
+ text-rendering: optimizeLegibility;
3472
+ -webkit-font-smoothing: antialiased;
3293
3473
  }
3294
3474
 
3295
- .nav {
3296
- display: flex;
3297
- align-items: center;
3298
- justify-content: space-between;
3299
- padding: 1rem 2rem;
3300
- border-bottom: 1px solid #1e1e2e;
3301
- }
3302
- .nav-brand { font-weight: 700; font-size: 1.1rem; color: #a78bfa; letter-spacing: -0.02em; }
3303
- .nav-links { display: flex; gap: 1.5rem; }
3304
- .nav-links a { color: #94a3b8; text-decoration: none; font-size: 0.9rem; }
3305
- .nav-links a:hover { color: #e2e8f0; }
3475
+ body { margin: 0; }
3306
3476
 
3307
- .hero {
3308
- text-align: center;
3309
- padding: 5rem 1rem 4rem;
3310
- max-width: 680px;
3477
+ #app {
3478
+ max-width: 1280px;
3311
3479
  margin: 0 auto;
3312
- }
3313
- .hero-badge {
3314
- display: inline-block;
3315
- background: #1e1a2e;
3316
- border: 1px solid #4c1d95;
3317
- color: #a78bfa;
3318
- font-size: 0.75rem;
3319
- font-weight: 600;
3320
- letter-spacing: 0.05em;
3321
- text-transform: uppercase;
3322
- padding: 0.3rem 0.8rem;
3323
- border-radius: 999px;
3324
- margin-bottom: 1.5rem;
3325
- }
3326
- .hero h1 {
3327
- font-size: clamp(2rem, 5vw, 3.25rem);
3328
- font-weight: 800;
3329
- letter-spacing: -0.03em;
3330
- line-height: 1.15;
3331
- margin-bottom: 1rem;
3332
- }
3333
- .hero h1 span { color: #a78bfa; }
3334
- .hero p {
3335
- font-size: 1.1rem;
3336
- color: #94a3b8;
3337
- line-height: 1.7;
3338
- margin-bottom: 2.5rem;
3339
- }
3340
- .hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
3341
- .btn {
3342
- display: inline-flex;
3480
+ padding: 2rem;
3481
+ text-align: center;
3482
+ display: flex;
3483
+ flex-direction: column;
3343
3484
  align-items: center;
3344
- gap: 0.4rem;
3345
- padding: 0.65rem 1.4rem;
3485
+ justify-content: center;
3486
+ min-height: 100vh;
3487
+ }
3488
+
3489
+ .logos { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1.5rem; }
3490
+
3491
+ .logo {
3492
+ height: 6em;
3493
+ padding: 1.5em;
3494
+ will-change: filter;
3495
+ transition: filter 300ms;
3496
+ }
3497
+ .logo-react { animation: spin 20s linear infinite; }
3498
+ .logo-react:hover { filter: drop-shadow(0 0 2em #61dafbaa); }
3499
+
3500
+ @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
3501
+ @media (prefers-reduced-motion: reduce) { .logo-react { animation: none; } }
3502
+
3503
+ h1 { font-size: 3.2em; line-height: 1.1; }
3504
+
3505
+ .card { padding: 2em; }
3506
+ .card p { color: #aaa; }
3507
+
3508
+ button {
3346
3509
  border-radius: 8px;
3347
- font-size: 0.9rem;
3348
- font-weight: 600;
3510
+ border: 1px solid transparent;
3511
+ padding: 0.6em 1.2em;
3512
+ font-size: 1em;
3513
+ font-weight: 500;
3514
+ font-family: inherit;
3515
+ background-color: #1a1a1a;
3349
3516
  cursor: pointer;
3350
- border: none;
3351
- transition: opacity 0.15s, transform 0.1s;
3352
- text-decoration: none;
3353
- }
3354
- .btn:hover { opacity: 0.85; transform: translateY(-1px); }
3355
- .btn:active { transform: translateY(0); }
3356
- .btn-primary { background: #7c3aed; color: #fff; }
3357
- .btn-ghost { background: #1e1e2e; color: #e2e8f0; border: 1px solid #2d2d3e; }
3517
+ transition: border-color 0.25s;
3518
+ }
3519
+ button:hover { border-color: #a78bfa; }
3520
+ button:focus-visible { outline: 4px auto -webkit-focus-ring-color; }
3358
3521
 
3359
- .features {
3360
- display: grid;
3361
- grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
3362
- gap: 1rem;
3363
- max-width: 900px;
3364
- margin: 0 auto 4rem;
3365
- padding: 0 1.5rem;
3366
- }
3367
- .card {
3368
- background: #16161f;
3369
- border: 1px solid #1e1e2e;
3370
- border-radius: 12px;
3371
- padding: 1.5rem;
3372
- }
3373
- .card-icon { font-size: 1.5rem; margin-bottom: 0.75rem; }
3374
- .card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.4rem; }
3375
- .card p { font-size: 0.85rem; color: #64748b; line-height: 1.6; }
3522
+ .hint { color: #555; font-size: 0.9em; }
3523
+ .hint a { color: inherit; }
3524
+ .hint a:hover { color: #a78bfa; }
3376
3525
 
3377
- .demo {
3378
- max-width: 480px;
3379
- margin: 0 auto 4rem;
3380
- padding: 0 1.5rem;
3381
- text-align: center;
3526
+ @media (prefers-color-scheme: light) {
3527
+ :root { color: #213547; background-color: #ffffff; }
3528
+ button { background-color: #f9f9f9; }
3529
+ .card p { color: #666; }
3530
+ .hint { color: #999; }
3382
3531
  }
3383
- .demo-box {
3384
- background: #16161f;
3385
- border: 1px solid #1e1e2e;
3386
- border-radius: 12px;
3387
- padding: 2rem;
3388
- }
3389
- .demo-box h2 { font-size: 0.8rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 1.25rem; }
3390
- .counter { font-size: 3.5rem; font-weight: 800; color: #a78bfa; letter-spacing: -0.04em; margin-bottom: 1.25rem; }
3391
- .demo-actions { display: flex; gap: 0.75rem; justify-content: center; }
3392
-
3393
3532
  \`;
3394
3533
 
3395
- const App: HadarsApp<{}> = () => {
3534
+ ${appSignature}
3396
3535
  const [count, setCount] = React.useState(0);
3397
3536
 
3398
3537
  return (
3399
3538
  <>
3400
3539
  <HadarsHead status={200}>
3401
- <title>My App</title>
3540
+ <title>${name}</title>
3402
3541
  <meta name="viewport" content="width=device-width, initial-scale=1" />
3403
3542
  <style data-id="app-styles" dangerouslySetInnerHTML={{ __html: css }} />
3404
3543
  </HadarsHead>
3405
3544
 
3406
- <nav className="nav">
3407
- <span className="nav-brand">my-app</span>
3408
- <div className="nav-links">
3409
- <a href="https://github.com/dpostolachi/hadar" target="_blank" rel="noopener">github</a>
3545
+ <div id="app">
3546
+ <div className="logos">
3547
+ <a href="https://react.dev" target="_blank" rel="noopener noreferrer">
3548
+ <svg className="logo logo-react" xmlns="http://www.w3.org/2000/svg" viewBox="-11.5 -10.232 23 20.463" aria-label="React">
3549
+ <circle cx="0" cy="0" r="2.05" fill="#61dafb" />
3550
+ <g stroke="#61dafb" strokeWidth="1" fill="none">
3551
+ <ellipse rx="11" ry="4.2" />
3552
+ <ellipse rx="11" ry="4.2" transform="rotate(60)" />
3553
+ <ellipse rx="11" ry="4.2" transform="rotate(120)" />
3554
+ </g>
3555
+ </svg>
3556
+ </a>
3410
3557
  </div>
3411
- </nav>
3412
3558
 
3413
- <section className="hero">
3414
- <div className="hero-badge">built with hadars</div>
3415
- <h1>Ship <span>React apps</span><br />at full speed</h1>
3416
- <p>
3417
- SSR out of the box, zero config, instant hot-reload.
3418
- Edit <code>src/App.tsx</code> to get started.
3419
- </p>
3420
- <div className="hero-actions">
3421
- <button className="btn btn-primary" onClick={() => setCount(c => c + 1)}>
3422
- Try the counter ↓
3423
- </button>
3424
- </div>
3425
- </section>
3559
+ <h1>React + hadars</h1>
3426
3560
 
3427
- <div className="features">
3428
- <div className="card">
3429
- <div className="card-icon">⚡</div>
3430
- <h3>Server-side rendering</h3>
3431
- <p>Pages render on the server and hydrate on the client — great for SEO and first paint.</p>
3432
- </div>
3433
3561
  <div className="card">
3434
- <div className="card-icon">\uD83D\uDD25</div>
3435
- <h3>Hot module reload</h3>
3436
- <p>Changes in <code>src/App.tsx</code> reflect instantly in the browser during development.</p>
3437
- </div>
3438
- <div className="card">
3439
- <div className="card-icon">\uD83D\uDCE6</div>
3440
- <h3>Zero config</h3>
3441
- <p>One config file. Export a React component, run <code>hadars dev</code>, done.</p>
3442
- </div>
3443
- <div className="card">
3444
- <div className="card-icon">\uD83D\uDDC4️</div>
3445
- <h3>Server data hooks</h3>
3446
- <p>Use <code>useServerData</code> to fetch data on the server without extra round-trips.</p>
3562
+ <button onClick={() => setCount(c => c + 1)}>
3563
+ count is {count}
3564
+ </button>
3565
+ <p>
3566
+ Edit <code>src/App.${appExt}</code> and save to test HMR
3567
+ </p>
3447
3568
  </div>
3448
- </div>
3449
3569
 
3450
- <div className="demo">
3451
- <div className="demo-box">
3452
- <h2>Client interactivity works</h2>
3453
- <div className="counter">{count}</div>
3454
- <div className="demo-actions">
3455
- <button className="btn btn-ghost" onClick={() => setCount(c => c - 1)}>− dec</button>
3456
- <button className="btn btn-primary" onClick={() => setCount(c => c + 1)}>+ inc</button>
3457
- </div>
3458
- </div>
3570
+ <p className="hint">
3571
+ <a href="https://hadars.xyz" target="_blank" rel="noopener noreferrer">hadars docs</a>
3572
+ &nbsp;·&nbsp;
3573
+ <a href="https://react.dev" target="_blank" rel="noopener noreferrer">react docs</a>
3574
+ </p>
3459
3575
  </div>
3460
-
3461
3576
  </>
3462
3577
  );
3463
3578
  };
3464
3579
 
3465
3580
  export default App;
3466
- `
3467
- };
3581
+ `;
3582
+ return {
3583
+ "package.json": packageJson,
3584
+ [`hadars.config.${cfgExt}`]: hadarsConfig,
3585
+ [tsOrJs]: tsConfigContent,
3586
+ ".gitignore": `node_modules/
3587
+ .hadars/
3588
+ dist/
3589
+ `,
3590
+ [`src/App.${appExt}`]: appContent
3591
+ };
3592
+ }
3468
3593
  async function createProject(name, cwd) {
3469
3594
  const dir = resolve(cwd, name);
3470
3595
  if (existsSync3(dir)) {
3471
3596
  console.error(`Directory already exists: ${dir}`);
3472
3597
  process.exit(1);
3473
3598
  }
3474
- console.log(`Creating hadars project in ${dir}`);
3599
+ const useTypeScript = await promptRadio("Language?", ["TypeScript", "JavaScript"]) === 0;
3600
+ const selectedIndices = await promptMultiSelect("Select SWC plugins to enable (optional):", PLUGINS.map((p) => p.label));
3601
+ const plugins = selectedIndices.map((i) => PLUGINS[i]);
3602
+ console.log(`
3603
+ Creating hadars project in ${dir}`);
3475
3604
  await mkdir2(join2(dir, "src"), { recursive: true });
3476
- for (const [file, template] of Object.entries(TEMPLATES)) {
3477
- const content = template(name);
3605
+ const files = buildTemplates(name, { useTypeScript, plugins });
3606
+ for (const [file, content] of Object.entries(files)) {
3478
3607
  await writeFile2(join2(dir, file), content, "utf-8");
3479
3608
  console.log(` created ${file}`);
3480
3609
  }
3610
+ const installHint = plugins.length > 0 ? `
3611
+ # Also install selected SWC plugins:
3612
+ npm install -D ${plugins.map((p) => `${p.pkg}@${p.version}`).join(" ")}
3613
+ ` : "";
3481
3614
  console.log(`
3482
3615
  Done! Next steps:
3483
3616
 
3484
3617
  cd ${name}
3485
- npm install # or: bun install / pnpm install
3618
+ npm install # or: bun install / pnpm install${installHint}
3486
3619
  npm run dev # or: bun run dev
3487
3620
  `);
3488
3621
  }
@@ -158,7 +158,6 @@ var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
158
158
  var SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
159
159
 
160
160
  // src/slim-react/renderContext.ts
161
- var import_node_module = require("module");
162
161
  var MAP_KEY = "__slimReactContextMap";
163
162
  var _g = globalThis;
164
163
  if (!("__slimReactContextMap" in _g)) _g[MAP_KEY] = null;
@@ -293,31 +292,8 @@ function getTreeId() {
293
292
  const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
294
293
  return stripped + overflow;
295
294
  }
296
- var _detectReact = () => {
297
- if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
298
- const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
299
- return {
300
- major,
301
- // Exact patch version is unknown from the define alone; use a
302
- // representative fallback. Most libraries only check the major.
303
- version: major < 19 ? "18.3.1" : "19.1.1"
304
- };
305
- }
306
- const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
307
- try {
308
- return parse(require("react").version);
309
- } catch {
310
- }
311
- try {
312
- const req = (0, import_node_module.createRequire)(process.cwd() + "/__hadars__.js");
313
- return parse(req("react").version);
314
- } catch {
315
- }
316
- return { major: 19, version: "19.1.1" };
317
- };
318
- var _react = _detectReact();
319
- var REACT_MAJOR = _react.major;
320
- var REACT_VERSION = _react.version;
295
+ var REACT_MAJOR = typeof __HADARS_REACT_MAJOR__ !== "undefined" ? parseInt(String(__HADARS_REACT_MAJOR__), 10) : 19;
296
+ var REACT_VERSION = REACT_MAJOR < 19 ? "18.3.1" : "19.1.1";
321
297
  function makeId() {
322
298
  const st = s();
323
299
  const treeId = getTreeId();
@@ -405,9 +381,22 @@ function use(usable) {
405
381
 
406
382
  // src/slim-react/dispatcher.ts
407
383
  var ReactNS = __toESM(require("react"), 1);
408
- var _r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
409
- var _r18Raw = !_r19 ? ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"] : void 0;
410
- var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : void 0;
384
+ var _r19;
385
+ var _r18;
386
+ var _detected = false;
387
+ var _k19 = "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE";
388
+ var _k18 = "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";
389
+ function _detect() {
390
+ if (_detected) return;
391
+ _detected = true;
392
+ const r19 = ReactNS[_k19];
393
+ if (r19) {
394
+ _r19 = r19;
395
+ return;
396
+ }
397
+ const raw = ReactNS[_k18];
398
+ if (raw?.ReactCurrentDispatcher) _r18 = raw;
399
+ }
411
400
  var slimDispatcher = {
412
401
  useId: makeId,
413
402
  readContext: (ctx) => getContextValue(ctx),
@@ -435,6 +424,7 @@ var slimDispatcher = {
435
424
  useHostTransitionStatus: () => false
436
425
  };
437
426
  function installDispatcher() {
427
+ _detect();
438
428
  if (_r19) {
439
429
  const prev = _r19.H;
440
430
  _r19.H = slimDispatcher;
@@ -448,6 +438,7 @@ function installDispatcher() {
448
438
  return null;
449
439
  }
450
440
  function restoreDispatcher(prev) {
441
+ _detect();
451
442
  if (_r19) _r19.H = prev;
452
443
  else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
453
444
  }
@@ -6,10 +6,9 @@ import {
6
6
  getReactResponse,
7
7
  makePrecontentHtmlGetter,
8
8
  parseRequest
9
- } from "./chunk-U2JQR4HV.js";
10
- import "./chunk-HIKMDNRB.js";
9
+ } from "./chunk-LDVJ26Q3.js";
10
+ import "./chunk-QOTDCUE5.js";
11
11
  import "./chunk-OZUZS2PD.js";
12
- import "./chunk-3RG5ZIWI.js";
13
12
 
14
13
  // src/cloudflare.ts
15
14
  import "react";
package/dist/index.js CHANGED
@@ -1,5 +1,3 @@
1
- import "./chunk-3RG5ZIWI.js";
2
-
3
1
  // src/utils/Head.tsx
4
2
  import React from "react";
5
3
  function deriveKey(tag, props) {
package/dist/lambda.cjs CHANGED
@@ -198,7 +198,6 @@ var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
198
198
  var SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
199
199
 
200
200
  // src/slim-react/renderContext.ts
201
- var import_node_module = require("module");
202
201
  var MAP_KEY = "__slimReactContextMap";
203
202
  var _g = globalThis;
204
203
  if (!("__slimReactContextMap" in _g)) _g[MAP_KEY] = null;
@@ -333,31 +332,8 @@ function getTreeId() {
333
332
  const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
334
333
  return stripped + overflow;
335
334
  }
336
- var _detectReact = () => {
337
- if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
338
- const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
339
- return {
340
- major,
341
- // Exact patch version is unknown from the define alone; use a
342
- // representative fallback. Most libraries only check the major.
343
- version: major < 19 ? "18.3.1" : "19.1.1"
344
- };
345
- }
346
- const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
347
- try {
348
- return parse(require("react").version);
349
- } catch {
350
- }
351
- try {
352
- const req = (0, import_node_module.createRequire)(process.cwd() + "/__hadars__.js");
353
- return parse(req("react").version);
354
- } catch {
355
- }
356
- return { major: 19, version: "19.1.1" };
357
- };
358
- var _react = _detectReact();
359
- var REACT_MAJOR = _react.major;
360
- var REACT_VERSION = _react.version;
335
+ var REACT_MAJOR = typeof __HADARS_REACT_MAJOR__ !== "undefined" ? parseInt(String(__HADARS_REACT_MAJOR__), 10) : 19;
336
+ var REACT_VERSION = REACT_MAJOR < 19 ? "18.3.1" : "19.1.1";
361
337
  function makeId() {
362
338
  const st = s();
363
339
  const treeId = getTreeId();
@@ -445,9 +421,22 @@ function use(usable) {
445
421
 
446
422
  // src/slim-react/dispatcher.ts
447
423
  var ReactNS = __toESM(require("react"), 1);
448
- var _r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
449
- var _r18Raw = !_r19 ? ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"] : void 0;
450
- var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : void 0;
424
+ var _r19;
425
+ var _r18;
426
+ var _detected = false;
427
+ var _k19 = "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE";
428
+ var _k18 = "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";
429
+ function _detect() {
430
+ if (_detected) return;
431
+ _detected = true;
432
+ const r19 = ReactNS[_k19];
433
+ if (r19) {
434
+ _r19 = r19;
435
+ return;
436
+ }
437
+ const raw = ReactNS[_k18];
438
+ if (raw?.ReactCurrentDispatcher) _r18 = raw;
439
+ }
451
440
  var slimDispatcher = {
452
441
  useId: makeId,
453
442
  readContext: (ctx) => getContextValue(ctx),
@@ -475,6 +464,7 @@ var slimDispatcher = {
475
464
  useHostTransitionStatus: () => false
476
465
  };
477
466
  function installDispatcher() {
467
+ _detect();
478
468
  if (_r19) {
479
469
  const prev = _r19.H;
480
470
  _r19.H = slimDispatcher;
@@ -488,6 +478,7 @@ function installDispatcher() {
488
478
  return null;
489
479
  }
490
480
  function restoreDispatcher(prev) {
481
+ _detect();
491
482
  if (_r19) _r19.H = prev;
492
483
  else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
493
484
  }
package/dist/lambda.js CHANGED
@@ -6,10 +6,9 @@ import {
6
6
  getReactResponse,
7
7
  makePrecontentHtmlGetter,
8
8
  parseRequest
9
- } from "./chunk-U2JQR4HV.js";
10
- import "./chunk-HIKMDNRB.js";
9
+ } from "./chunk-LDVJ26Q3.js";
10
+ import "./chunk-QOTDCUE5.js";
11
11
  import "./chunk-OZUZS2PD.js";
12
- import "./chunk-3RG5ZIWI.js";
13
12
 
14
13
  // src/lambda.ts
15
14
  import "react";
@@ -38,7 +38,7 @@ __export(slim_react_exports, {
38
38
  SLIM_ELEMENT: () => SLIM_ELEMENT,
39
39
  SUSPENSE_TYPE: () => SUSPENSE_TYPE,
40
40
  Suspense: () => Suspense,
41
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: () => __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2,
41
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: () => __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
42
42
  cloneElement: () => cloneElement,
43
43
  createContext: () => createContext,
44
44
  createElement: () => createElement,
@@ -54,6 +54,7 @@ __export(slim_react_exports, {
54
54
  renderToReadableStream: () => renderToStream,
55
55
  renderToStream: () => renderToStream,
56
56
  renderToString: () => renderToString,
57
+ setReactVersion: () => setReactVersion,
57
58
  startTransition: () => startTransition,
58
59
  use: () => use,
59
60
  useActionState: () => useActionState,
@@ -85,7 +86,6 @@ var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
85
86
  var SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
86
87
 
87
88
  // src/slim-react/renderContext.ts
88
- var import_node_module = require("module");
89
89
  var MAP_KEY = "__slimReactContextMap";
90
90
  var _g = globalThis;
91
91
  if (!("__slimReactContextMap" in _g)) _g[MAP_KEY] = null;
@@ -220,31 +220,12 @@ function getTreeId() {
220
220
  const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
221
221
  return stripped + overflow;
222
222
  }
223
- var _detectReact = () => {
224
- if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
225
- const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
226
- return {
227
- major,
228
- // Exact patch version is unknown from the define alone; use a
229
- // representative fallback. Most libraries only check the major.
230
- version: major < 19 ? "18.3.1" : "19.1.1"
231
- };
232
- }
233
- const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
234
- try {
235
- return parse(require("react").version);
236
- } catch {
237
- }
238
- try {
239
- const req = (0, import_node_module.createRequire)(process.cwd() + "/__hadars__.js");
240
- return parse(req("react").version);
241
- } catch {
242
- }
243
- return { major: 19, version: "19.1.1" };
244
- };
245
- var _react = _detectReact();
246
- var REACT_MAJOR = _react.major;
247
- var REACT_VERSION = _react.version;
223
+ var REACT_MAJOR = typeof __HADARS_REACT_MAJOR__ !== "undefined" ? parseInt(String(__HADARS_REACT_MAJOR__), 10) : 19;
224
+ var REACT_VERSION = REACT_MAJOR < 19 ? "18.3.1" : "19.1.1";
225
+ function setReactVersion(major, version2) {
226
+ REACT_MAJOR = major;
227
+ REACT_VERSION = version2 ?? (major < 19 ? "18.3.1" : "19.1.1");
228
+ }
248
229
  function makeId() {
249
230
  const st = s();
250
231
  const treeId = getTreeId();
@@ -373,9 +354,22 @@ function createContext(defaultValue) {
373
354
 
374
355
  // src/slim-react/dispatcher.ts
375
356
  var ReactNS = __toESM(require("react"), 1);
376
- var _r19 = ReactNS["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"];
377
- var _r18Raw = !_r19 ? ReactNS["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"] : void 0;
378
- var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : void 0;
357
+ var _r19;
358
+ var _r18;
359
+ var _detected = false;
360
+ var _k19 = "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE";
361
+ var _k18 = "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";
362
+ function _detect() {
363
+ if (_detected) return;
364
+ _detected = true;
365
+ const r19 = ReactNS[_k19];
366
+ if (r19) {
367
+ _r19 = r19;
368
+ return;
369
+ }
370
+ const raw = ReactNS[_k18];
371
+ if (raw?.ReactCurrentDispatcher) _r18 = raw;
372
+ }
379
373
  var slimDispatcher = {
380
374
  useId: makeId,
381
375
  readContext: (ctx) => getContextValue(ctx),
@@ -403,6 +397,7 @@ var slimDispatcher = {
403
397
  useHostTransitionStatus: () => false
404
398
  };
405
399
  function installDispatcher() {
400
+ _detect();
406
401
  if (_r19) {
407
402
  const prev = _r19.H;
408
403
  _r19.H = slimDispatcher;
@@ -416,6 +411,7 @@ function installDispatcher() {
416
411
  return null;
417
412
  }
418
413
  function restoreDispatcher(prev) {
414
+ _detect();
419
415
  if (_r19) _r19.H = prev;
420
416
  else if (_r18) _r18.ReactCurrentDispatcher.current = prev;
421
417
  }
@@ -1271,7 +1267,7 @@ var Component = class {
1271
1267
  var PureComponent = class extends Component {
1272
1268
  };
1273
1269
  var version = REACT_VERSION;
1274
- var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2 = {
1270
+ var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
1275
1271
  ReactCurrentDispatcher: { current: null },
1276
1272
  ReactCurrentBatchConfig: { transition: null },
1277
1273
  ReactCurrentOwner: { current: null }
@@ -1321,7 +1317,7 @@ var React = {
1321
1317
  // Version
1322
1318
  version,
1323
1319
  // React 18 internals
1324
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2
1320
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
1325
1321
  };
1326
1322
  var slim_react_default = React;
1327
1323
  // Annotate the CommonJS export names for ESM import in node:
@@ -1349,6 +1345,7 @@ var slim_react_default = React;
1349
1345
  renderToReadableStream,
1350
1346
  renderToStream,
1351
1347
  renderToString,
1348
+ setReactVersion,
1352
1349
  startTransition,
1353
1350
  use,
1354
1351
  useActionState,
@@ -1,6 +1,8 @@
1
1
  import { S as SlimNode, a as SlimElement, c as createElement } from '../jsx-runtime-BOYrELJb.cjs';
2
2
  export { C as ComponentFunction, F as FRAGMENT_TYPE, b as Fragment, d as SLIM_ELEMENT, e as SUSPENSE_TYPE, j as jsx, j as jsxDEV, j as jsxs } from '../jsx-runtime-BOYrELJb.cjs';
3
3
 
4
+ declare function setReactVersion(major: number, version?: string): void;
5
+
4
6
  /**
5
7
  * SSR hook implementations.
6
8
  *
@@ -225,4 +227,4 @@ declare const React: {
225
227
  };
226
228
  };
227
229
 
228
- export { Children, Component, type Context, PureComponent, type RenderOptions, SlimElement, SlimNode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, React as default, forwardRef, isValidElement, lazy, memo, renderPreflight, renderToStream as renderToReadableStream, renderToStream, renderToString, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useFormStatus, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
230
+ export { Children, Component, type Context, PureComponent, type RenderOptions, SlimElement, SlimNode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, React as default, forwardRef, isValidElement, lazy, memo, renderPreflight, renderToStream as renderToReadableStream, renderToStream, renderToString, setReactVersion, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useFormStatus, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
@@ -1,6 +1,8 @@
1
1
  import { S as SlimNode, a as SlimElement, c as createElement } from '../jsx-runtime-BOYrELJb.js';
2
2
  export { C as ComponentFunction, F as FRAGMENT_TYPE, b as Fragment, d as SLIM_ELEMENT, e as SUSPENSE_TYPE, j as jsx, j as jsxDEV, j as jsxs } from '../jsx-runtime-BOYrELJb.js';
3
3
 
4
+ declare function setReactVersion(major: number, version?: string): void;
5
+
4
6
  /**
5
7
  * SSR hook implementations.
6
8
  *
@@ -225,4 +227,4 @@ declare const React: {
225
227
  };
226
228
  };
227
229
 
228
- export { Children, Component, type Context, PureComponent, type RenderOptions, SlimElement, SlimNode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, React as default, forwardRef, isValidElement, lazy, memo, renderPreflight, renderToStream as renderToReadableStream, renderToStream, renderToString, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useFormStatus, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
230
+ export { Children, Component, type Context, PureComponent, type RenderOptions, SlimElement, SlimNode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, React as default, forwardRef, isValidElement, lazy, memo, renderPreflight, renderToStream as renderToReadableStream, renderToStream, renderToString, setReactVersion, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useFormStatus, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
@@ -13,6 +13,7 @@ import {
13
13
  renderPreflight,
14
14
  renderToStream,
15
15
  renderToString,
16
+ setReactVersion,
16
17
  slim_react_default,
17
18
  startTransition,
18
19
  use,
@@ -35,7 +36,7 @@ import {
35
36
  useSyncExternalStore,
36
37
  useTransition,
37
38
  version
38
- } from "../chunk-HIKMDNRB.js";
39
+ } from "../chunk-QOTDCUE5.js";
39
40
  import {
40
41
  FRAGMENT_TYPE,
41
42
  Fragment,
@@ -44,7 +45,6 @@ import {
44
45
  createElement,
45
46
  jsx
46
47
  } from "../chunk-OZUZS2PD.js";
47
- import "../chunk-3RG5ZIWI.js";
48
48
  export {
49
49
  Children,
50
50
  Component,
@@ -70,6 +70,7 @@ export {
70
70
  renderToStream as renderToReadableStream,
71
71
  renderToStream,
72
72
  renderToString,
73
+ setReactVersion,
73
74
  startTransition,
74
75
  use,
75
76
  useActionState,
@@ -2,7 +2,6 @@ import {
2
2
  Fragment,
3
3
  jsx
4
4
  } from "../chunk-OZUZS2PD.js";
5
- import "../chunk-3RG5ZIWI.js";
6
5
  export {
7
6
  Fragment,
8
7
  jsx,
@@ -1,6 +1,3 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
1
  // src/ssr-render-worker.ts
5
2
  import { workerData, parentPort } from "node:worker_threads";
6
3
  import { pathToFileURL } from "node:url";
@@ -11,7 +8,6 @@ var REACT19_ELEMENT = Symbol.for("react.transitional.element");
11
8
  var FRAGMENT_TYPE = Symbol.for("react.fragment");
12
9
  var SUSPENSE_TYPE = Symbol.for("react.suspense");
13
10
  // src/slim-react/renderContext.ts
14
- import { createRequire as _nodeCreateRequire } from "node:module";
15
11
  var MAP_KEY = "__slimReactContextMap";
16
12
  var _g = globalThis;
17
13
  if (!("__slimReactContextMap" in _g))
@@ -148,27 +144,8 @@ function getTreeId() {
148
144
  const stripped = (id & ~(1 << 31 - Math.clz32(id))).toString(32);
149
145
  return stripped + overflow;
150
146
  }
151
- var _detectReact = () => {
152
- if (typeof __HADARS_REACT_MAJOR__ !== "undefined") {
153
- const major = parseInt(String(__HADARS_REACT_MAJOR__), 10);
154
- return {
155
- major,
156
- version: major < 19 ? "18.3.1" : "19.1.1"
157
- };
158
- }
159
- const parse = (ver) => ({ major: parseInt(ver.split(".")[0], 10), version: ver });
160
- try {
161
- return parse(__require("react").version);
162
- } catch {}
163
- try {
164
- const req = _nodeCreateRequire(process.cwd() + "/__hadars__.js");
165
- return parse(req("react").version);
166
- } catch {}
167
- return { major: 19, version: "19.1.1" };
168
- };
169
- var _react = _detectReact();
170
- var REACT_MAJOR = _react.major;
171
- var REACT_VERSION = _react.version;
147
+ var REACT_MAJOR = typeof __HADARS_REACT_MAJOR__ !== "undefined" ? parseInt(String(__HADARS_REACT_MAJOR__), 10) : 19;
148
+ var REACT_VERSION = REACT_MAJOR < 19 ? "18.3.1" : "19.1.1";
172
149
  function makeId() {
173
150
  const st = s();
174
151
  const treeId = getTreeId();
@@ -248,9 +225,24 @@ function use(usable) {
248
225
  }
249
226
  // src/slim-react/dispatcher.ts
250
227
  import * as ReactNS from "react";
251
- var _r19 = ReactNS.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
252
- var _r18Raw = !_r19 ? ReactNS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED : undefined;
253
- var _r18 = _r18Raw?.ReactCurrentDispatcher ? _r18Raw : undefined;
228
+ var _r19;
229
+ var _r18;
230
+ var _detected = false;
231
+ var _k19 = "__CLIENT_INTERNALS_DO_NOT_USE" + "_OR_WARN_USERS_THEY_CANNOT_UPGRADE";
232
+ var _k18 = "__SECRET_INTERNALS_DO_NOT_USE" + "_OR_YOU_WILL_BE_FIRED";
233
+ function _detect() {
234
+ if (_detected)
235
+ return;
236
+ _detected = true;
237
+ const r19 = ReactNS[_k19];
238
+ if (r19) {
239
+ _r19 = r19;
240
+ return;
241
+ }
242
+ const raw = ReactNS[_k18];
243
+ if (raw?.ReactCurrentDispatcher)
244
+ _r18 = raw;
245
+ }
254
246
  var slimDispatcher = {
255
247
  useId: makeId,
256
248
  readContext: (ctx) => getContextValue(ctx),
@@ -276,6 +268,7 @@ var slimDispatcher = {
276
268
  useHostTransitionStatus: () => false
277
269
  };
278
270
  function installDispatcher() {
271
+ _detect();
279
272
  if (_r19) {
280
273
  const prev = _r19.H;
281
274
  _r19.H = slimDispatcher;
@@ -289,6 +282,7 @@ function installDispatcher() {
289
282
  return null;
290
283
  }
291
284
  function restoreDispatcher(prev) {
285
+ _detect();
292
286
  if (_r19)
293
287
  _r19.H = prev;
294
288
  else if (_r18)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hadars",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Minimal SSR framework for React — rspack, HMR, TypeScript, Bun/Node/Deno",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",
@@ -1,10 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
- export {
9
- __require
10
- };