public JintProjectionStateHandler(string source, bool enableContentTypeValidation, TimeSpan compilationTimeout, TimeSpan executionTimeout)
        {
            _enableContentTypeValidation = enableContentTypeValidation;
            _definitionBuilder           = new SourceDefinitionBuilder();
            _definitionBuilder.NoWhen();
            _definitionBuilder.AllEvents();
            TimeConstraint timeConstraint = new(compilationTimeout, executionTimeout);

            _engine = new Engine(opts => opts.Constraint(timeConstraint));
            _engine.Global.RemoveOwnProperty("eval");
            _state              = JsValue.Undefined;
            _sharedState        = JsValue.Undefined;
            _interpreterRuntime = new InterpreterRuntime(_engine, _definitionBuilder);



            timeConstraint.Compiling();
            _engine.Execute(source);
            timeConstraint.Executing();
            _json = _interpreterRuntime.SwitchToExecutionMode();
            _engine.Global.FastAddProperty("emit", new ClrFunctionInstance(_engine, "emit", Emit, 4), true, false, true);
            _engine.Global.FastAddProperty("linkTo", new ClrFunctionInstance(_engine, "linkTo", LinkTo, 3), true, false, true);
            _engine.Global.FastAddProperty("linkStreamTo", new ClrFunctionInstance(_engine, "linkStreamTo", LinkStreamTo, 3), true, false, true);
            _engine.Global.FastAddProperty("copyTo", new ClrFunctionInstance(_engine, "copyTo", CopyTo, 3), true, false, true);
            _emitted = new List <EmittedEventEnvelope>();
        }