2023-10-14 23:47:20 -04:00
|
|
|
import * as SignalsParts from "signals-original";
|
|
|
|
|
2023-10-16 10:27:22 -04:00
|
|
|
type Entry = [signal:SignalsParts.Signal<unknown>, initArg:unknown];
|
2023-10-14 23:47:20 -04:00
|
|
|
|
2023-10-16 10:27:22 -04:00
|
|
|
let recordEntry:Entry[] = [];
|
|
|
|
let recordEntryNew:Entry[] = [];
|
|
|
|
let recordIndex = 0;
|
|
|
|
export const recordIndexReset =()=> recordIndex = 0;
|
|
|
|
export const recordEntrySwap =()=>
|
|
|
|
{
|
|
|
|
recordEntry = recordEntryNew;
|
|
|
|
recordEntryNew = [] as Entry[];
|
|
|
|
};
|
2023-10-14 23:47:20 -04:00
|
|
|
const proxySignal =(arg)=>
|
|
|
|
{
|
2023-10-16 10:27:22 -04:00
|
|
|
const lookupOld = recordEntry[recordIndex];
|
|
|
|
if(lookupOld && lookupOld[1] === arg)
|
|
|
|
{
|
|
|
|
recordEntryNew[recordIndex] = lookupOld;
|
|
|
|
recordIndex++;
|
|
|
|
return lookupOld[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const sig = SignalsParts.signal(arg);
|
|
|
|
recordEntryNew[recordIndex] = [sig, arg];
|
|
|
|
recordEntry[recordIndex] = [sig, arg];
|
|
|
|
recordIndex++;
|
|
|
|
return sig;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-10-14 23:47:20 -04:00
|
|
|
|
|
|
|
export * from "signals-original";
|
|
|
|
export { proxySignal as signal };
|
|
|
|
// ? export {ProxyCreate as createElement, ProxyState as useState, ProxyReducer as useReducer };
|
|
|
|
// ? export default {...ReactParts, createElement:ProxyCreate, useState:ProxyState, useReducer:ProxyReducer};
|