Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
Plaintext
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
// Vendored from: https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/client-and-server-references.ts
|
|
|
|
function extractInfoFromServerReferenceId(id) {
|
|
const infoByte = parseInt(id.slice(0, 2), 16);
|
|
// eslint-disable-next-line no-bitwise
|
|
const typeBit = (infoByte >> 7) & 0x1;
|
|
// eslint-disable-next-line no-bitwise
|
|
const argMask = (infoByte >> 1) & 0x3f;
|
|
// eslint-disable-next-line no-bitwise
|
|
const restArgs = infoByte & 0x1;
|
|
const usedArgs = Array(6);
|
|
|
|
for (let index = 0; index < 6; index++) {
|
|
const bitPosition = 5 - index;
|
|
// eslint-disable-next-line no-bitwise
|
|
const bit = (argMask >> bitPosition) & 0x1;
|
|
usedArgs[index] = bit === 1;
|
|
}
|
|
|
|
return {
|
|
type: typeBit === 1 ? 'use-cache' : 'server-action',
|
|
usedArgs: usedArgs ,
|
|
hasRestArgs: restArgs === 1,
|
|
};
|
|
}
|
|
|
|
function isServerReference(value) {
|
|
return value.$$typeof === Symbol.for('react.server.reference');
|
|
}
|
|
|
|
/**
|
|
* Check if the function is a use cache function.
|
|
*
|
|
* @param value - The function to check.
|
|
* @returns true if the function is a use cache function, false otherwise.
|
|
*/
|
|
function isUseCacheFunction(value) {
|
|
if (!isServerReference(value)) {
|
|
return false;
|
|
}
|
|
|
|
const { type } = extractInfoFromServerReferenceId(value.$$id);
|
|
|
|
return type === 'use-cache';
|
|
}
|
|
|
|
exports.isUseCacheFunction = isUseCacheFunction;
|
|
//# sourceMappingURL=isUseCacheFunction.js.map
|