{"version":3,"file":"index.cjs","names":[],"sources":["../src/IsolatedContextManager.ts"],"sourcesContent":["import type { IContextManager, OnChildLoggerCreatedParams } from \"@loglayer/context-manager\";\n\n/**\n * A context manager that maintains isolated context data for each logger instance.\n * When a child logger is created, it starts with no context data - it does not inherit from the parent.\n */\nexport class IsolatedContextManager implements IContextManager {\n  private context: Record<string, any> = {};\n  private hasContext = false;\n\n  /**\n   * Sets the context data to be included with every log entry. Set to `undefined` to clear the context data.\n   */\n  setContext(context?: Record<string, any>): void {\n    if (!context) {\n      this.context = {};\n      this.hasContext = false;\n      return;\n    }\n\n    this.context = context;\n    this.hasContext = true;\n  }\n\n  /**\n   * Appends context data to the existing context data.\n   */\n  appendContext(context: Record<string, any>) {\n    this.context = { ...this.context, ...context };\n    this.hasContext = true;\n  }\n\n  /**\n   * Returns the context data to be included with every log entry.\n   */\n  getContext(): Record<string, any> {\n    return this.context;\n  }\n\n  /**\n   * Returns true if context data is present.\n   */\n  hasContextData(): boolean {\n    return this.hasContext;\n  }\n\n  /**\n   * Does not copy context data from parent to child - child starts with empty context.\n   * This ensures complete isolation between parent and child context managers.\n   */\n  onChildLoggerCreated(_params: OnChildLoggerCreatedParams) {\n    // Intentionally do nothing - child logger starts with no context data\n    // This maintains complete isolation between parent and child contexts\n  }\n\n  /**\n   * Creates a new instance of the context manager with no context data.\n   * The clone starts completely isolated from the original.\n   */\n  clone(): IContextManager {\n    return new IsolatedContextManager();\n  }\n}\n"],"mappings":";;;;;;AAMA,IAAa,yBAAb,MAAa,uBAAkD;CAC7D,AAAQ,UAA+B,EAAE;CACzC,AAAQ,aAAa;;;;CAKrB,WAAW,SAAqC;AAC9C,MAAI,CAAC,SAAS;AACZ,QAAK,UAAU,EAAE;AACjB,QAAK,aAAa;AAClB;;AAGF,OAAK,UAAU;AACf,OAAK,aAAa;;;;;CAMpB,cAAc,SAA8B;AAC1C,OAAK,UAAU;GAAE,GAAG,KAAK;GAAS,GAAG;GAAS;AAC9C,OAAK,aAAa;;;;;CAMpB,aAAkC;AAChC,SAAO,KAAK;;;;;CAMd,iBAA0B;AACxB,SAAO,KAAK;;;;;;CAOd,qBAAqB,SAAqC;;;;;CAS1D,QAAyB;AACvB,SAAO,IAAI,wBAAwB"}