/**
* RxJS execution context for Worker thread
* Centralizes all RxJS imports and provides a safe execution context
*/
import {
// Core
Observable,
Subject,
BehaviorSubject,
ReplaySubject,
AsyncSubject,
connectable,
// Creation functions
of,
from,
interval,
timer,
range,
generate,
concat,
merge,
combineLatest,
zip,
forkJoin,
race,
partition,
iif,
defer,
scheduled,
throwError,
EMPTY,
NEVER,
firstValueFrom,
lastValueFrom,
// Transformation operators
map,
scan,
mergeScan,
reduce,
pairwise,
groupBy,
mergeMap,
switchMap,
concatMap,
exhaustMap,
expand,
buffer,
bufferTime,
bufferCount,
bufferWhen,
bufferToggle,
windowTime,
window as windowOp,
windowCount,
windowToggle,
windowWhen,
// Filtering operators
filter,
take,
takeLast,
takeWhile,
skip,
skipLast,
skipWhile,
skipUntil,
first,
last,
elementAt,
find,
findIndex,
debounceTime,
throttleTime,
auditTime,
audit,
sampleTime,
sample,
ignoreElements,
distinct,
distinctUntilChanged,
distinctUntilKeyChanged,
// Combination operators
concatWith,
mergeWith,
combineLatestWith,
zipWith,
raceWith,
withLatestFrom,
mergeAll,
concatAll,
switchAll,
exhaustAll,
combineLatestAll,
zipAll,
// Utility operators
tap,
delay,
delayWhen,
timeout,
takeUntil,
finalize,
repeat,
retry,
startWith,
endWith,
toArray,
materialize,
dematerialize,
observeOn,
subscribeOn,
timestamp,
// Conditional operators
defaultIfEmpty,
every,
isEmpty,
// Error handling operators
catchError,
retryWhen,
// Multicasting operators
share,
shareReplay,
connect,
refCount,
// Deprecated but commonly used
pluck,
mapTo,
switchMapTo,
mergeMapTo,
concatMapTo,
// Additional utility
count,
max,
min,
single,
throwIfEmpty,
} from 'rxjs';
/**
* RxJS symbols available in the execution context
*/
export const rxjsSymbols = {
// Core
Observable,
Subject,
BehaviorSubject,
ReplaySubject,
AsyncSubject,
connectable,
// Creation functions
of,
from,
interval,
timer,
range,
generate,
concat,
merge,
combineLatest,
zip,
forkJoin,
race,
partition,
iif,
defer,
scheduled,
throwError,
EMPTY,
NEVER,
firstValueFrom,
lastValueFrom,
// Transformation operators
map,
scan,
mergeScan,
reduce,
pairwise,
groupBy,
mergeMap,
switchMap,
concatMap,
exhaustMap,
expand,
buffer,
bufferTime,
bufferCount,
bufferWhen,
bufferToggle,
windowTime,
window: windowOp,
windowCount,
windowToggle,
windowWhen,
// Filtering operators
filter,
take,
takeLast,
takeWhile,
skip,
skipLast,
skipWhile,
skipUntil,
first,
last,
elementAt,
find,
findIndex,
debounceTime,
throttleTime,
auditTime,
audit,
sampleTime,
sample,
ignoreElements,
distinct,
distinctUntilChanged,
distinctUntilKeyChanged,
// Combination operators
concatWith,
mergeWith,
combineLatestWith,
zipWith,
raceWith,
withLatestFrom,
mergeAll,
concatAll,
switchAll,
exhaustAll,
combineLatestAll,
zipAll,
// Utility operators
tap,
delay,
delayWhen,
timeout,
takeUntil,
finalize,
repeat,
retry,
startWith,
endWith,
toArray,
materialize,
dematerialize,
observeOn,
subscribeOn,
timestamp,
// Conditional operators
defaultIfEmpty,
every,
isEmpty,
// Error handling operators
catchError,
retryWhen,
// Multicasting operators
share,
shareReplay,
connect,
refCount,
// Deprecated but commonly used
pluck,
mapTo,
switchMapTo,
mergeMapTo,
concatMapTo,
// Additional utility
count,
max,
min,
single,
throwIfEmpty,
};
/**
* Safe globals for the execution context
* These are the only non-RxJS APIs available in user code
*/
export const safeGlobals = {
console: {
log: (..._args: unknown[]) => {},
error: (..._args: unknown[]) => {},
warn: (..._args: unknown[]) => {},
},
setTimeout,
clearTimeout,
Date,
Math,
JSON,
Array,
Object,
String,
Number,
Boolean,
Promise,
};
/**
* Dangerous globals that must be explicitly undefined
*/
export const blockedGlobals = {
process: undefined,
require: undefined,
module: undefined,
exports: undefined,
__dirname: undefined,
__filename: undefined,
global: undefined,
globalThis: undefined,
};
/**
* Creates the complete execution context for user code
*/
export function createExecutionContext(): Record<string, unknown> {
return {
...rxjsSymbols,
...safeGlobals,
...blockedGlobals,
};
}
// Re-export commonly used types for worker
export { Observable, EMPTY } from 'rxjs';