@absolutejs/absolute 0.19.0-beta.18 → 0.19.0-beta.19
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/.absolutejs/tsconfig.tsbuildinfo +1 -1
- package/dist/build.js +102 -13
- package/dist/build.js.map +3 -3
- package/dist/index.js +102 -13
- package/dist/index.js.map +3 -3
- package/native/packages/darwin-arm64/fast_ops.dylib +0 -0
- package/native/packages/darwin-arm64/package.json +1 -1
- package/native/packages/darwin-x64/fast_ops.dylib +0 -0
- package/native/packages/darwin-x64/package.json +1 -1
- package/native/packages/linux-arm64/package.json +1 -1
- package/native/packages/linux-x64/fast_ops.so +0 -0
- package/native/packages/linux-x64/package.json +1 -1
- package/package.json +5 -5
package/dist/build.js
CHANGED
|
@@ -202214,29 +202214,90 @@ 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
|
-
},
|
|
202217
|
+
}, HOOK_NAMES, findComponents = (code) => {
|
|
202218
202218
|
const components = [];
|
|
202219
|
+
const exportRe = /(?:export\s+(?:default\s+)?(?:function\s+|(?:const|let|var)\s+))([A-Z][a-zA-Z0-9]*)/g;
|
|
202219
202220
|
let match;
|
|
202220
|
-
|
|
202221
|
-
|
|
202222
|
-
if (
|
|
202223
|
-
|
|
202224
|
-
|
|
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);
|
|
202225
202244
|
if (components.length === 0)
|
|
202226
202245
|
return code;
|
|
202227
|
-
const
|
|
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(`
|
|
202228
202267
|
`);
|
|
202229
|
-
|
|
202230
|
-
return `${sigSetup}
|
|
202231
|
-
${code}
|
|
202268
|
+
return `${result}
|
|
202232
202269
|
${registrations}
|
|
202233
202270
|
`;
|
|
202271
|
+
}, JSX_AUTO_RE, JSXS_AUTO_RE, JSX_PROD_RE, FRAGMENT_RE, addJsxImport = (code) => {
|
|
202272
|
+
const imports = [];
|
|
202273
|
+
const jsxDevMatch = JSX_AUTO_RE.exec(code);
|
|
202274
|
+
if (jsxDevMatch) {
|
|
202275
|
+
imports.push(`import { jsxDEV as ${jsxDevMatch[1]} } from "react/jsx-dev-runtime";`);
|
|
202276
|
+
}
|
|
202277
|
+
const jsxsMatch = JSXS_AUTO_RE.exec(code);
|
|
202278
|
+
if (jsxsMatch && (!jsxDevMatch || jsxsMatch[1] !== jsxDevMatch[1])) {
|
|
202279
|
+
imports.push(`import { jsxs as ${jsxsMatch[1]} } from "react/jsx-runtime";`);
|
|
202280
|
+
}
|
|
202281
|
+
const jsxProdMatch = JSX_PROD_RE.exec(code);
|
|
202282
|
+
if (jsxProdMatch) {
|
|
202283
|
+
imports.push(`import { jsx as ${jsxProdMatch[1]} } from "react/jsx-runtime";`);
|
|
202284
|
+
}
|
|
202285
|
+
const fragmentMatch = FRAGMENT_RE.exec(code);
|
|
202286
|
+
if (fragmentMatch) {
|
|
202287
|
+
imports.push(`import { Fragment as ${fragmentMatch[1]} } from "react";`);
|
|
202288
|
+
}
|
|
202289
|
+
if (imports.length === 0)
|
|
202290
|
+
return code;
|
|
202291
|
+
return imports.join(`
|
|
202292
|
+
`) + `
|
|
202293
|
+
` + code;
|
|
202234
202294
|
}, transformReactFile = (filePath, projectRoot, rewriter) => {
|
|
202235
202295
|
const raw = readFileSync9(filePath, "utf-8");
|
|
202236
202296
|
const transpiled = new Bun.Transpiler({
|
|
202237
202297
|
loader: extname3(filePath) === ".jsx" ? "jsx" : "tsx"
|
|
202238
202298
|
}).transformSync(raw);
|
|
202239
|
-
const
|
|
202299
|
+
const withJsx = addJsxImport(transpiled);
|
|
202300
|
+
const withRefresh = injectRefreshRegistration(withJsx, filePath, projectRoot);
|
|
202240
202301
|
return rewriteImports2(withRefresh, filePath, projectRoot, rewriter);
|
|
202241
202302
|
}, transformPlainFile = (filePath, projectRoot, rewriter) => {
|
|
202242
202303
|
const raw = readFileSync9(filePath, "utf-8");
|
|
@@ -202312,7 +202373,35 @@ var init_moduleServer = __esm(() => {
|
|
|
202312
202373
|
jsTranspiler2 = new Bun.Transpiler({ loader: "js" });
|
|
202313
202374
|
TRANSPILABLE = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs"]);
|
|
202314
202375
|
REACT_EXTENSIONS = new Set([".tsx", ".jsx"]);
|
|
202315
|
-
|
|
202376
|
+
HOOK_NAMES = new Set([
|
|
202377
|
+
"useState",
|
|
202378
|
+
"useReducer",
|
|
202379
|
+
"useEffect",
|
|
202380
|
+
"useLayoutEffect",
|
|
202381
|
+
"useMemo",
|
|
202382
|
+
"useCallback",
|
|
202383
|
+
"useRef",
|
|
202384
|
+
"useContext",
|
|
202385
|
+
"useImperativeHandle",
|
|
202386
|
+
"useDebugValue",
|
|
202387
|
+
"useDeferredValue",
|
|
202388
|
+
"useTransition",
|
|
202389
|
+
"useId",
|
|
202390
|
+
"useSyncExternalStore",
|
|
202391
|
+
"useInsertionEffect",
|
|
202392
|
+
"useOptimistic",
|
|
202393
|
+
"useFormStatus",
|
|
202394
|
+
"useActionState"
|
|
202395
|
+
]);
|
|
202396
|
+
REFRESH_PREAMBLE = [
|
|
202397
|
+
"var $RefreshReg$ = window.$RefreshReg$ || function(){};",
|
|
202398
|
+
"var $RefreshSig$ = window.$RefreshSig$ || function(){ return function(t){ return t; }; };"
|
|
202399
|
+
].join(`
|
|
202400
|
+
`);
|
|
202401
|
+
JSX_AUTO_RE = /\b(jsxDEV_[a-z0-9]+)\b/;
|
|
202402
|
+
JSXS_AUTO_RE = /\b(jsxs_[a-z0-9]+)\b/;
|
|
202403
|
+
JSX_PROD_RE = /\b(jsx_[a-z0-9]+)\b/;
|
|
202404
|
+
FRAGMENT_RE = /\b(Fragment_[a-z0-9]+)\b/;
|
|
202316
202405
|
invalidateModule = invalidate;
|
|
202317
202406
|
SRC_URL_PREFIX = SRC_PREFIX;
|
|
202318
202407
|
});
|
|
@@ -203903,5 +203992,5 @@ export {
|
|
|
203903
203992
|
build
|
|
203904
203993
|
};
|
|
203905
203994
|
|
|
203906
|
-
//# debugId=
|
|
203995
|
+
//# debugId=33AC0B71663B0C6B64756E2164756E21
|
|
203907
203996
|
//# sourceMappingURL=build.js.map
|