@ttsc/unplugin 0.30.2 → 0.30.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bun.js +3 -16
- package/lib/bun.js.map +1 -1
- package/lib/bun.mjs +3 -16
- package/lib/bun.mjs.map +1 -1
- package/lib/core/esbuild.d.cts +4 -0
- package/lib/core/esbuild.d.mts +4 -0
- package/lib/core/esbuild.d.ts +4 -0
- package/lib/core/esbuild.js +110 -0
- package/lib/core/esbuild.js.map +1 -0
- package/lib/core/esbuild.mjs +108 -0
- package/lib/core/esbuild.mjs.map +1 -0
- package/lib/core/index.js +49 -89
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +50 -90
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/transform.d.cts +5 -3
- package/lib/core/transform.d.mts +5 -3
- package/lib/core/transform.d.ts +5 -3
- package/lib/core/transform.js +25 -25
- package/lib/core/transform.js.map +1 -1
- package/lib/core/transform.mjs +25 -25
- package/lib/core/transform.mjs.map +1 -1
- package/lib/core/viteServe.d.cts +16 -38
- package/lib/core/viteServe.d.mts +16 -38
- package/lib/core/viteServe.d.ts +16 -38
- package/lib/core/viteServe.js +234 -98
- package/lib/core/viteServe.js.map +1 -1
- package/lib/core/viteServe.mjs +235 -98
- package/lib/core/viteServe.mjs.map +1 -1
- package/package.json +4 -3
- package/src/bun.ts +2 -17
- package/src/core/esbuild.ts +127 -0
- package/src/core/index.ts +51 -100
- package/src/core/transform.ts +30 -28
- package/src/core/viteServe.ts +275 -164
package/lib/core/index.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
1
|
import { createUnplugin } from 'unplugin';
|
|
2
|
+
import { createEsbuildOptions } from './esbuild.mjs';
|
|
4
3
|
import { resolveOptions } from './options.mjs';
|
|
5
4
|
import { typescriptTransformSourcePattern } from './sourceExtensions.mjs';
|
|
6
5
|
import { createTtscTransformCache, stripQuery, transformTtsc, beginTtscTransformBuild, resetTtscTransformCache, isDeclarationFile } from './transform.mjs';
|
|
7
6
|
export { captureWatchInputBaseline, captureWatchInputFileBaseline, collectExternalInputHashes, collectProjectInputHashSnapshot, collectProjectInputHashes, isProjectWalkPath, isWatchInputKeyBaseline, watchInputEvidenceMatchesBaseline } from './transform.mjs';
|
|
8
|
-
import {
|
|
7
|
+
import { createViteServeInputWatch } from './viteServe.mjs';
|
|
9
8
|
export { mergeMembershipPolicyOverlay, readProjectMembershipPolicy, readTsconfigSourceSnapshot } from './tsconfigPaths.mjs';
|
|
10
9
|
export { discoverNearestProjectTsconfig, findNearestProjectTsconfig, findProjectTsconfigs } from './projectDiscovery.mjs';
|
|
11
10
|
|
|
@@ -41,10 +40,13 @@ const virtualModulePattern = /\0/;
|
|
|
41
40
|
* server configured without a watcher takes the pass lifecycle with them,
|
|
42
41
|
* having declared it will observe no edit at all.
|
|
43
42
|
*/
|
|
44
|
-
const unpluginFactory = (rawOptions = {}) => {
|
|
43
|
+
const unpluginFactory = (rawOptions = {}, meta) => {
|
|
45
44
|
const options = resolveOptions(rawOptions);
|
|
45
|
+
if (meta.framework === "esbuild") {
|
|
46
|
+
return createEsbuildOptions(options, isTransformTarget);
|
|
47
|
+
}
|
|
46
48
|
const transformCache = createTtscTransformCache();
|
|
47
|
-
const
|
|
49
|
+
const serveInputs = createViteServeInputWatch();
|
|
48
50
|
let aliases;
|
|
49
51
|
let viteCommand;
|
|
50
52
|
let viteWatching = true;
|
|
@@ -59,13 +61,6 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
59
61
|
// old containers cannot dispose a replacement's freshly initialized cache.
|
|
60
62
|
let viteBuildOwners = new WeakSet();
|
|
61
63
|
let viteBuildLifecycles = 0;
|
|
62
|
-
// esbuild schedules one-shot onDispose callbacks after it settles the build
|
|
63
|
-
// Promise. Acquire ownership only at onStart: plugin setup runs before build
|
|
64
|
-
// option validation, and a validation failure has no onDispose callback with
|
|
65
|
-
// which to release a setup-time owner. Once a build has actually started, the
|
|
66
|
-
// count keeps an older delayed callback from disposing its active generation.
|
|
67
|
-
const esbuildOwners = new WeakSet();
|
|
68
|
-
let esbuildLifecycles = 0;
|
|
69
64
|
return {
|
|
70
65
|
name,
|
|
71
66
|
enforce: "pre",
|
|
@@ -95,14 +90,11 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
95
90
|
viteBuildWatching =
|
|
96
91
|
config.build?.watch != null;
|
|
97
92
|
},
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
// hook can route watch inputs that do not exist yet — superseding
|
|
102
|
-
// resolution candidates above all — around that graph and still
|
|
103
|
-
// invalidate their importers when the path is created.
|
|
93
|
+
// Compiler dependencies belong to the filesystem watch graph. Vite's
|
|
94
|
+
// transform-context addWatchFile also inserts runtime imports, so none
|
|
95
|
+
// of those dependencies may use that channel during serve (#1368).
|
|
104
96
|
configureServer(server) {
|
|
105
|
-
|
|
97
|
+
serveInputs.attach(server);
|
|
106
98
|
},
|
|
107
99
|
// Vite calls buildEnd when the dev server closes, and Rollup calls it at
|
|
108
100
|
// the end of every build phase; drop every poller and, once the last
|
|
@@ -119,15 +111,15 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
119
111
|
// fixing one of the two sites alone left this host recompiling the whole
|
|
120
112
|
// project per edit (samchon/ttsc#1301). The watching build hands its
|
|
121
113
|
// teardown to `closeWatcher` below instead.
|
|
122
|
-
buildEnd() {
|
|
114
|
+
async buildEnd() {
|
|
123
115
|
if (viteBuildOwners.delete(this)) {
|
|
124
116
|
viteBuildLifecycles -= 1;
|
|
125
117
|
}
|
|
126
118
|
if (viteBuildLifecycles === 0) {
|
|
127
|
-
missingInputs.dispose();
|
|
128
119
|
if (viteCommand === "serve" || !viteBuildWatching) {
|
|
129
120
|
resetTtscTransformCache(transformCache);
|
|
130
121
|
}
|
|
122
|
+
await serveInputs.dispose();
|
|
131
123
|
}
|
|
132
124
|
},
|
|
133
125
|
// The watching build's real teardown, and the only hook in a
|
|
@@ -144,11 +136,11 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
144
136
|
// `buildEnd` would then decrement a counter that is already zero and
|
|
145
137
|
// strand it below zero, after which the disposal above could never fire
|
|
146
138
|
// again for this plugin instance.
|
|
147
|
-
closeWatcher() {
|
|
139
|
+
async closeWatcher() {
|
|
148
140
|
viteBuildOwners = new WeakSet();
|
|
149
141
|
viteBuildLifecycles = 0;
|
|
150
|
-
missingInputs.dispose();
|
|
151
142
|
resetTtscTransformCache(transformCache);
|
|
143
|
+
await serveInputs.dispose();
|
|
152
144
|
},
|
|
153
145
|
},
|
|
154
146
|
// Rollup and Rolldown carry none of the Vite block's hooks, so before this
|
|
@@ -198,23 +190,14 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
198
190
|
resetTtscTransformCache(transformCache);
|
|
199
191
|
});
|
|
200
192
|
},
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
build.onDispose(() => {
|
|
210
|
-
if (!esbuildOwners.delete(build)) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
esbuildLifecycles -= 1;
|
|
214
|
-
if (esbuildLifecycles === 0) {
|
|
215
|
-
resetTtscTransformCache(transformCache);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
193
|
+
farm: {
|
|
194
|
+
// Farm calls buildStart only for the initial compilation. Every update
|
|
195
|
+
// opens a new pass so a failed verdict can recover, while an unchanged
|
|
196
|
+
// successful generation remains reusable across its module deliveries.
|
|
197
|
+
updateModules: {
|
|
198
|
+
executor() {
|
|
199
|
+
beginTtscTransformBuild(transformCache);
|
|
200
|
+
},
|
|
218
201
|
},
|
|
219
202
|
},
|
|
220
203
|
buildStart() {
|
|
@@ -258,58 +241,35 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
258
241
|
return undefined;
|
|
259
242
|
}
|
|
260
243
|
return transformTtsc(file, source, options, aliases, transformCache, {
|
|
261
|
-
//
|
|
262
|
-
//
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
// missing paths and directories, so those are watched against their
|
|
269
|
-
// compiler predicates instead and invalidate this module when the
|
|
270
|
-
// observation changes.
|
|
271
|
-
addWatchFile: (watched, evidence) => {
|
|
272
|
-
if (viteCommand === "serve" && missingInputs.serving()) {
|
|
273
|
-
const observation = evidence?.state?.codec === "predicates"
|
|
274
|
-
? evidence.state.observation
|
|
275
|
-
: undefined;
|
|
276
|
-
const unsafePredicate = observation !== undefined &&
|
|
277
|
-
observation.fileExists !== true &&
|
|
278
|
-
observation.stat !== "file" &&
|
|
279
|
-
observation.readFile?.ok !== true
|
|
280
|
-
? observation
|
|
281
|
-
: undefined;
|
|
282
|
-
if (unsafePredicate !== undefined) {
|
|
283
|
-
missingInputs.watch(watched, path.resolve(file), unsafePredicate);
|
|
284
|
-
return;
|
|
244
|
+
// A watcherless server has no invalidation channel and needs no
|
|
245
|
+
// watch-input derivation. Every other host keeps its native contract.
|
|
246
|
+
addWatchFiles: viteCommand === "serve" && !viteWatching
|
|
247
|
+
? undefined
|
|
248
|
+
: (inputs, failed) => {
|
|
249
|
+
if (viteCommand === "serve") {
|
|
250
|
+
serveInputs.replace(file, inputs, failed);
|
|
285
251
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
252
|
+
else {
|
|
253
|
+
const native = this.getNativeBuildContext?.();
|
|
254
|
+
for (const input of inputs) {
|
|
255
|
+
if (native?.framework === "rspack" &&
|
|
256
|
+
native.loaderContext !== undefined) {
|
|
257
|
+
// Compilation-level dependencies schedule a pass but do
|
|
258
|
+
// not invalidate Rspack's cached transformed modules.
|
|
259
|
+
if (input.evidence?.missing === true)
|
|
260
|
+
native.loaderContext.addMissingDependency(input.file);
|
|
261
|
+
else
|
|
262
|
+
native.loaderContext.addDependency(input.file);
|
|
263
|
+
}
|
|
264
|
+
else if (native?.framework === "farm") {
|
|
265
|
+
native.context.addWatchFile(file, input.file);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
this.addWatchFile(input.file);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
300
271
|
}
|
|
301
|
-
}
|
|
302
|
-
// A dev server configured without a watcher can never deliver a
|
|
303
|
-
// change event, so a registration here buys nothing, and it is not
|
|
304
|
-
// free: Vite's import analysis resolves every registered path like a
|
|
305
|
-
// real import of the transformed module, once per module. The
|
|
306
|
-
// adapter's own missing-input poll above stays active either way,
|
|
307
|
-
// because it never depended on Vite's watcher.
|
|
308
|
-
if (viteCommand === "serve" && !viteWatching) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
this.addWatchFile(watched);
|
|
312
|
-
},
|
|
272
|
+
},
|
|
313
273
|
// A module the plugin declared volatile depends on non-file inputs,
|
|
314
274
|
// which no file-dependency snapshot can represent; mark it
|
|
315
275
|
// uncacheable where the bundler exposes that control.
|
package/lib/core/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/core/index.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/core/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;AAyBA,MAAM,IAAI,GAAG,eAAe;AAC5B;;;;;;;;AAQG;AACI,MAAM,iBAAiB,GAAG;AACjC;AACA,MAAM,kBAAkB,GAAG,oCAAoC;AAC/D;;;AAGG;AACH,MAAM,oBAAoB,GAAG,IAAI;AAEjC;;;;;;;;;;;;;AAaG;AACH,MAAM,eAAe,GAGjB,CAAC,UAAU,GAAG,EAAE,E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ooks {
|
|
|
425
425
|
addWatchFile?: (file: string, evidence?: TtscWatchInputEvidence) => void;
|
|
426
426
|
/**
|
|
427
427
|
* Batched form of {@link addWatchFile}. When supplied, the transform calls it
|
|
428
|
-
* once per delivered module and does not call `addWatchFile` for that
|
|
429
|
-
*
|
|
428
|
+
* once per delivered module and does not call `addWatchFile` for that module.
|
|
429
|
+
* `failed` marks a recovery batch: a failed compiler can omit inputs from its
|
|
430
|
+
* previous successful result, so replacing hosts should retain those
|
|
431
|
+
* spellings until the next successful delivery.
|
|
430
432
|
*/
|
|
431
|
-
addWatchFiles?: (inputs: readonly TtscWatchInput[]) => void;
|
|
433
|
+
addWatchFiles?: (inputs: readonly TtscWatchInput[], failed?: boolean) => void;
|
|
432
434
|
/**
|
|
433
435
|
* Invoked when the plugin declared the transformed file volatile (the
|
|
434
436
|
* envelope's `volatile` list): its output depends on non-file inputs that no
|
package/lib/core/transform.d.mts
CHANGED
|
@@ -425,10 +425,12 @@ export interface TtscTransformHooks {
|
|
|
425
425
|
addWatchFile?: (file: string, evidence?: TtscWatchInputEvidence) => void;
|
|
426
426
|
/**
|
|
427
427
|
* Batched form of {@link addWatchFile}. When supplied, the transform calls it
|
|
428
|
-
* once per delivered module and does not call `addWatchFile` for that
|
|
429
|
-
*
|
|
428
|
+
* once per delivered module and does not call `addWatchFile` for that module.
|
|
429
|
+
* `failed` marks a recovery batch: a failed compiler can omit inputs from its
|
|
430
|
+
* previous successful result, so replacing hosts should retain those
|
|
431
|
+
* spellings until the next successful delivery.
|
|
430
432
|
*/
|
|
431
|
-
addWatchFiles?: (inputs: readonly TtscWatchInput[]) => void;
|
|
433
|
+
addWatchFiles?: (inputs: readonly TtscWatchInput[], failed?: boolean) => void;
|
|
432
434
|
/**
|
|
433
435
|
* Invoked when the plugin declared the transformed file volatile (the
|
|
434
436
|
* envelope's `volatile` list): its output depends on non-file inputs that no
|
package/lib/core/transform.d.ts
CHANGED
|
@@ -425,10 +425,12 @@ export interface TtscTransformHooks {
|
|
|
425
425
|
addWatchFile?: (file: string, evidence?: TtscWatchInputEvidence) => void;
|
|
426
426
|
/**
|
|
427
427
|
* Batched form of {@link addWatchFile}. When supplied, the transform calls it
|
|
428
|
-
* once per delivered module and does not call `addWatchFile` for that
|
|
429
|
-
*
|
|
428
|
+
* once per delivered module and does not call `addWatchFile` for that module.
|
|
429
|
+
* `failed` marks a recovery batch: a failed compiler can omit inputs from its
|
|
430
|
+
* previous successful result, so replacing hosts should retain those
|
|
431
|
+
* spellings until the next successful delivery.
|
|
430
432
|
*/
|
|
431
|
-
addWatchFiles?: (inputs: readonly TtscWatchInput[]) => void;
|
|
433
|
+
addWatchFiles?: (inputs: readonly TtscWatchInput[], failed?: boolean) => void;
|
|
432
434
|
/**
|
|
433
435
|
* Invoked when the plugin declared the transformed file volatile (the
|
|
434
436
|
* envelope's `volatile` list): its output depends on non-file inputs that no
|
package/lib/core/transform.js
CHANGED
|
@@ -65,14 +65,13 @@ class TtscUnstableGenerationError extends TtscTerminalGenerationError {
|
|
|
65
65
|
/**
|
|
66
66
|
* A compile this pass already attempted, whose envelope failed outright.
|
|
67
67
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* made a single broken save cost one compile per delivered module
|
|
68
|
+
* Native project diagnostics carry a structured failure envelope; setup and
|
|
69
|
+
* host failures can still arrive as opaque exceptions. Both settle the current
|
|
70
|
+
* attempt, so the adapter uses the delivery boundary it owns rather than
|
|
71
|
+
* guessing retryability from a diagnostic message. Inside a pass the answer is
|
|
72
|
+
* already settled, so every later module replays it instead of repeating a
|
|
73
|
+
* whole-project transform to reach the same verdict, which is what made a
|
|
74
|
+
* single broken save cost one compile per delivered module
|
|
76
75
|
* (samchon/ttsc#1303).
|
|
77
76
|
*
|
|
78
77
|
* The scope is exactly the pass. A host whose `buildStart` repeats drops the
|
|
@@ -1051,11 +1050,11 @@ function collectDeclaredIdentities(state, projectRoot, listed) {
|
|
|
1051
1050
|
* invalidated, and the error stays on screen (samchon/ttsc#1312).
|
|
1052
1051
|
*
|
|
1053
1052
|
* A failure envelope can retain exact external input spellings from its graph
|
|
1054
|
-
* and host metadata
|
|
1055
|
-
*
|
|
1056
|
-
*
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
1053
|
+
* and host metadata, including missing resolution candidates on native
|
|
1054
|
+
* typecheck failures. For hosts that return no graph, structured diagnostics or
|
|
1055
|
+
* standard diagnostic lines provide only the paths they actually name. The cost
|
|
1056
|
+
* is paid only on a failure, and only until the next compile succeeds and
|
|
1057
|
+
* narrows the set back to the derived inputs.
|
|
1059
1058
|
*/
|
|
1060
1059
|
function notifyFailedGenerationInputs(hooks, cached) {
|
|
1061
1060
|
const addWatchFile = hooks?.addWatchFile;
|
|
@@ -1100,7 +1099,7 @@ function notifyFailedGenerationInputs(hooks, cached) {
|
|
|
1100
1099
|
}
|
|
1101
1100
|
}
|
|
1102
1101
|
if (addWatchFiles !== undefined) {
|
|
1103
|
-
addWatchFiles(inputs);
|
|
1102
|
+
addWatchFiles(inputs, true);
|
|
1104
1103
|
return;
|
|
1105
1104
|
}
|
|
1106
1105
|
for (const input of inputs) {
|
|
@@ -3408,7 +3407,9 @@ membership) {
|
|
|
3408
3407
|
});
|
|
3409
3408
|
broker.pendingRegistrations += 1;
|
|
3410
3409
|
broker.child.ref();
|
|
3411
|
-
|
|
3410
|
+
// Bun's IPC channel omits Node's Control.ref/unref methods. The child itself
|
|
3411
|
+
// still owns the outstanding acknowledgement on that runtime.
|
|
3412
|
+
broker.child.channel?.ref?.();
|
|
3412
3413
|
const id = broker.nextId++;
|
|
3413
3414
|
let resolveReady;
|
|
3414
3415
|
const ready = new Promise((resolve) => {
|
|
@@ -3479,7 +3480,7 @@ membership) {
|
|
|
3479
3480
|
// exit mid-build.
|
|
3480
3481
|
if (broker.pendingRegistrations === 0 && broker.pendingDrains === 0) {
|
|
3481
3482
|
broker.child.unref();
|
|
3482
|
-
broker.child.channel?.unref();
|
|
3483
|
+
broker.child.channel?.unref?.();
|
|
3483
3484
|
}
|
|
3484
3485
|
}
|
|
3485
3486
|
}
|
|
@@ -3595,7 +3596,7 @@ function startWindowsProjectMutationDrain(broker) {
|
|
|
3595
3596
|
broker.pendingDrains -= 1;
|
|
3596
3597
|
if (broker.pendingDrains === 0 && broker.pendingRegistrations === 0) {
|
|
3597
3598
|
broker.child.unref();
|
|
3598
|
-
broker.child.channel?.unref();
|
|
3599
|
+
broker.child.channel?.unref?.();
|
|
3599
3600
|
}
|
|
3600
3601
|
resolve();
|
|
3601
3602
|
};
|
|
@@ -3606,7 +3607,7 @@ function startWindowsProjectMutationDrain(broker) {
|
|
|
3606
3607
|
// process exits mid-build with nothing to report.
|
|
3607
3608
|
broker.pendingDrains += 1;
|
|
3608
3609
|
broker.child.ref();
|
|
3609
|
-
broker.child.channel?.ref();
|
|
3610
|
+
broker.child.channel?.ref?.();
|
|
3610
3611
|
const timer = setTimeout(release, WINDOWS_MUTATION_DRAIN_FALLBACK_MS);
|
|
3611
3612
|
broker.drains.set(id, release);
|
|
3612
3613
|
if (broker.child.send?.({ id, op: "drain" }) !== true) {
|
|
@@ -5699,13 +5700,12 @@ function formatUnknownError(error) {
|
|
|
5699
5700
|
/**
|
|
5700
5701
|
* Remove terminal colour and cursor sequences from text the adapter surfaces.
|
|
5701
5702
|
*
|
|
5702
|
-
* An
|
|
5703
|
-
*
|
|
5704
|
-
*
|
|
5705
|
-
*
|
|
5706
|
-
*
|
|
5707
|
-
*
|
|
5708
|
-
* (samchon/ttsc#1312).
|
|
5703
|
+
* An opaque host exception can contain the host's own rendered output, colour
|
|
5704
|
+
* and all, with no structured diagnostics to format instead. What the adapter
|
|
5705
|
+
* hands back is not going to a terminal: it becomes the `Error` a bundler
|
|
5706
|
+
* reports, so it lands in a Vite overlay, a webpack error report or a CI
|
|
5707
|
+
* annotation, where the escapes render as literal noise around the file and
|
|
5708
|
+
* line the reader needs (samchon/ttsc#1312).
|
|
5709
5709
|
*
|
|
5710
5710
|
* The colour originates in the host's rendering rather than in anything this
|
|
5711
5711
|
* adapter configures, so this is the adapter-side repair, applied to every
|