2023-05-04 14:23:00 +00:00
|
|
|
const contexts = new WeakMap();
|
|
|
|
|
|
|
|
const ID_PREFIX = 'r';
|
|
|
|
|
|
|
|
function getContext(rendererContextResult) {
|
|
|
|
if (contexts.has(rendererContextResult)) {
|
|
|
|
return contexts.get(rendererContextResult);
|
|
|
|
}
|
|
|
|
const ctx = {
|
|
|
|
currentIndex: 0,
|
|
|
|
get id() {
|
|
|
|
return ID_PREFIX + this.currentIndex.toString();
|
|
|
|
},
|
|
|
|
};
|
|
|
|
contexts.set(rendererContextResult, ctx);
|
|
|
|
return ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function incrementId(rendererContextResult) {
|
2023-05-04 14:25:03 +00:00
|
|
|
const ctx = getContext(rendererContextResult);
|
2023-05-04 14:23:00 +00:00
|
|
|
const id = ctx.id;
|
|
|
|
ctx.currentIndex++;
|
|
|
|
return id;
|
|
|
|
}
|