(value: T)
| 569 | } |
| 570 | |
| 571 | function cloneAndFreezeSnapshotValue<T>(value: T): T { |
| 572 | if (Array.isArray(value)) { |
| 573 | return Object.freeze(value.map((item) => cloneAndFreezeSnapshotValue(item))) as T; |
| 574 | } |
| 575 | if (value && typeof value === 'object') { |
| 576 | const prototype = Object.getPrototypeOf(value); |
| 577 | if (prototype !== Object.prototype && prototype !== null) return value; |
| 578 | const clone: Record<string, unknown> = Object.create(prototype); |
| 579 | for (const key of Object.keys(value)) { |
| 580 | const descriptor = Object.getOwnPropertyDescriptor(value, key); |
| 581 | if (!descriptor || !('value' in descriptor)) { |
| 582 | throw new Error(`Invocation snapshot rejects accessor property ${key}`); |
| 583 | } |
| 584 | clone[key] = cloneAndFreezeSnapshotValue(descriptor.value); |
| 585 | } |
| 586 | return Object.freeze(clone) as T; |
| 587 | } |
| 588 | return value; |
| 589 | } |
| 590 | |
| 591 | function invocationContinuationMetadata( |
| 592 | continuation: RuntimeContinuation, |
no test coverage detected