| 65 | CodeSignalHelpers<TOwner>; |
| 66 | |
| 67 | export class CodeSignalContext<TOwner> |
| 68 | extends SignalContext<PossibleCodeScope, CodeScope, TOwner> |
| 69 | implements CodeSignalHelpers<TOwner> |
| 70 | { |
| 71 | private readonly progress = createSignal(0); |
| 72 | |
| 73 | public constructor( |
| 74 | initial: PossibleCodeScope, |
| 75 | owner: TOwner, |
| 76 | private readonly highlighter?: SignalValue<CodeHighlighter | null>, |
| 77 | ) { |
| 78 | super(initial, deepLerp, owner); |
| 79 | Object.defineProperty(this.invokable, 'edit', { |
| 80 | value: this.edit.bind(this), |
| 81 | }); |
| 82 | Object.defineProperty(this.invokable, 'append', { |
| 83 | value: this.append.bind(this), |
| 84 | }); |
| 85 | Object.defineProperty(this.invokable, 'prepend', { |
| 86 | value: this.prepend.bind(this), |
| 87 | }); |
| 88 | Object.defineProperty(this.invokable, 'insert', { |
| 89 | value: this.insert.bind(this), |
| 90 | }); |
| 91 | Object.defineProperty(this.invokable, 'remove', { |
| 92 | value: this.remove.bind(this), |
| 93 | }); |
| 94 | Object.defineProperty(this.invokable, 'replace', { |
| 95 | value: this.replace.bind(this), |
| 96 | }); |
| 97 | } |
| 98 | |
| 99 | public override *tweener( |
| 100 | value: SignalValue<PossibleCodeScope>, |
| 101 | duration: number, |
| 102 | timingFunction: TimingFunction, |
| 103 | ): ThreadGenerator { |
| 104 | let tokenize = defaultTokenize; |
| 105 | const highlighter = unwrap(this.highlighter); |
| 106 | if (highlighter) { |
| 107 | yield (async () => { |
| 108 | do { |
| 109 | await DependencyContext.consumePromises(); |
| 110 | highlighter.initialize(); |
| 111 | } while (DependencyContext.hasPromises()); |
| 112 | })(); |
| 113 | tokenize = (input: string) => highlighter.tokenize(input); |
| 114 | } |
| 115 | |
| 116 | this.progress(0); |
| 117 | this.set({ |
| 118 | progress: this.progress, |
| 119 | fragments: defaultDiffer(this.get(), this.parse(unwrap(value)), tokenize), |
| 120 | }); |
| 121 | yield* this.progress(1, duration, timingFunction); |
| 122 | this.set(value); |
| 123 | } |
| 124 |
nothing calls this directly
no test coverage detected