@absolutejs/absolute 0.19.0-beta.19 → 0.19.0-beta.20

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.
package/dist/index.js CHANGED
@@ -202214,61 +202214,7 @@ var SRC_PREFIX = "/@src/", jsTranspiler2, TRANSPILABLE, REACT_EXTENSIONS, escape
202214
202214
  return `${prefix}${SRC_PREFIX}${srcPath.replace(/\\/g, "/")}${suffix}`;
202215
202215
  });
202216
202216
  return result;
202217
- }, HOOK_NAMES, findComponents = (code) => {
202218
- const components = [];
202219
- const exportRe = /(?:export\s+(?:default\s+)?(?:function\s+|(?:const|let|var)\s+))([A-Z][a-zA-Z0-9]*)/g;
202220
- let match;
202221
- while ((match = exportRe.exec(code)) !== null) {
202222
- const name = match[1];
202223
- if (!name)
202224
- continue;
202225
- const startIdx = match.index;
202226
- const bodySlice = code.slice(startIdx, startIdx + 2000);
202227
- const hasHooks = Array.from(HOOK_NAMES).some((hook) => bodySlice.includes(hook + "("));
202228
- components.push({ hasHooks, name });
202229
- }
202230
- return components;
202231
- }, computeHookSignature = (code, componentName) => {
202232
- const startIdx = code.indexOf(componentName);
202233
- if (startIdx === -1)
202234
- return "";
202235
- const bodySlice = code.slice(startIdx, startIdx + 2000);
202236
- const hooks = [];
202237
- for (const hook of HOOK_NAMES) {
202238
- if (bodySlice.includes(hook + "("))
202239
- hooks.push(hook);
202240
- }
202241
- return Buffer.from(hooks.join(",")).toString("base64").slice(0, 12);
202242
- }, REFRESH_PREAMBLE, injectRefreshRegistration = (code, filePath, projectRoot) => {
202243
- const components = findComponents(code);
202244
- if (components.length === 0)
202245
- return code;
202246
- const hasAnyHooks = components.some((c) => c.hasHooks);
202247
- const sigSetup = hasAnyHooks ? `
202248
- var _s = $RefreshSig$();` : "";
202249
- let result = `${REFRESH_PREAMBLE}${sigSetup}
202250
- ${code}`;
202251
- const exportedNames = [];
202252
- for (const comp of components) {
202253
- if (!comp.hasHooks)
202254
- continue;
202255
- const sig = computeHookSignature(result, comp.name);
202256
- result = result.replace(new RegExp(`export\\s+(?:const|let)\\s+(${comp.name}\\s*=)`), `var $1`);
202257
- exportedNames.push(comp.name);
202258
- result += `
202259
- ${comp.name} = _s(${comp.name}, ${JSON.stringify(sig)});`;
202260
- }
202261
- if (exportedNames.length > 0) {
202262
- result += `
202263
- export { ${exportedNames.join(", ")} };`;
202264
- }
202265
- const relPath = relative6(projectRoot, filePath).replace(/\\/g, "/");
202266
- const registrations = components.map((c) => `$RefreshReg$(${c.name}, ${JSON.stringify(`${relPath}:${c.name}`)});`).join(`
202267
- `);
202268
- return `${result}
202269
- ${registrations}
202270
- `;
202271
- }, JSX_AUTO_RE, JSXS_AUTO_RE, JSX_PROD_RE, FRAGMENT_RE, addJsxImport = (code) => {
202217
+ }, HOOK_NAMES, REFRESH_PREAMBLE, JSX_AUTO_RE, JSXS_AUTO_RE, JSX_PROD_RE, FRAGMENT_RE, addJsxImport = (code) => {
202272
202218
  const imports = [];
202273
202219
  const jsxDevMatch = JSX_AUTO_RE.exec(code);
202274
202220
  if (jsxDevMatch) {
@@ -202291,14 +202237,19 @@ ${registrations}
202291
202237
  return imports.join(`
202292
202238
  `) + `
202293
202239
  ` + code;
202294
- }, transformReactFile = (filePath, projectRoot, rewriter) => {
202240
+ }, reactTranspiler, transformReactFile = (filePath, projectRoot, rewriter) => {
202295
202241
  const raw = readFileSync9(filePath, "utf-8");
202296
- const transpiled = new Bun.Transpiler({
202297
- loader: extname3(filePath) === ".jsx" ? "jsx" : "tsx"
202298
- }).transformSync(raw);
202299
- const withJsx = addJsxImport(transpiled);
202300
- const withRefresh = injectRefreshRegistration(withJsx, filePath, projectRoot);
202301
- return rewriteImports2(withRefresh, filePath, projectRoot, rewriter);
202242
+ let transpiled = reactTranspiler.transformSync(raw);
202243
+ transpiled = addJsxImport(transpiled);
202244
+ transpiled = transpiled.replace(/import\s*\{[^}]*\}\s*from\s*["']react-refresh\/runtime["'];?\n?/, "");
202245
+ transpiled = transpiled.replace(/\$RefreshReg\$_[a-z0-9]+/g, "$RefreshReg$");
202246
+ transpiled = transpiled.replace(/\$RefreshSig\$_[a-z0-9]+/g, "$RefreshSig$");
202247
+ transpiled = `var $RefreshReg$ = window.$RefreshReg$ || function(){};
202248
+ ` + `var $RefreshSig$ = window.$RefreshSig$ || function(){ return function(t){ return t; }; };
202249
+ ` + transpiled;
202250
+ const relPath = relative6(projectRoot, filePath).replace(/\\/g, "/");
202251
+ transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
202252
+ return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202302
202253
  }, transformPlainFile = (filePath, projectRoot, rewriter) => {
202303
202254
  const raw = readFileSync9(filePath, "utf-8");
202304
202255
  const ext = extname3(filePath);
@@ -202402,6 +202353,10 @@ var init_moduleServer = __esm(() => {
202402
202353
  JSXS_AUTO_RE = /\b(jsxs_[a-z0-9]+)\b/;
202403
202354
  JSX_PROD_RE = /\b(jsx_[a-z0-9]+)\b/;
202404
202355
  FRAGMENT_RE = /\b(Fragment_[a-z0-9]+)\b/;
202356
+ reactTranspiler = new Bun.Transpiler({
202357
+ loader: "tsx",
202358
+ reactFastRefresh: true
202359
+ });
202405
202360
  invalidateModule = invalidate;
202406
202361
  SRC_URL_PREFIX = SRC_PREFIX;
202407
202362
  });
@@ -204341,5 +204296,5 @@ export {
204341
204296
  ANGULAR_INIT_TIMEOUT_MS
204342
204297
  };
204343
204298
 
204344
- //# debugId=03961D5A04FB822E64756E2164756E21
204299
+ //# debugId=2876E20329D813AB64756E2164756E21
204345
204300
  //# sourceMappingURL=index.js.map