ttsc 0.19.3 → 0.20.0
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/README.md +7 -5
- package/cmd/graphdump/main.go +2 -4
- package/cmd/ttsc/filter.go +12 -4
- package/cmd/ttsc/filter_resolves_flag_names_case_insensitively_test.go +53 -0
- package/cmd/ttsc/flags_gen.go +3 -3
- package/cmd/ttscgraph/dump.go +5 -7
- package/cmd/ttscgraph/run_dump_emits_only_checker_verified_member_relations_test.go +118 -0
- package/cmd/ttscgraph/serve.go +58 -308
- package/cmd/ttscgraph/serve_session_keeps_base_url_fallback_unchanged_test.go +49 -0
- package/cmd/ttscgraph/serve_session_keeps_esm_directory_candidate_unchanged_test.go +61 -0
- package/cmd/ttscgraph/serve_session_keeps_exports_blocked_file_candidates_unchanged_test.go +64 -0
- package/cmd/ttscgraph/serve_session_keeps_inactive_conditional_export_unchanged_test.go +66 -0
- package/cmd/ttscgraph/serve_session_keeps_lower_priority_module_candidate_unchanged_test.go +67 -0
- package/cmd/ttscgraph/serve_session_keeps_lower_priority_paths_pattern_unchanged_test.go +58 -0
- package/cmd/ttscgraph/serve_session_keeps_nonlongest_root_dirs_candidate_unchanged_test.go +54 -0
- package/cmd/ttscgraph/serve_session_reloads_commonjs_package_entry_for_esm_test.go +50 -0
- package/cmd/ttscgraph/serve_session_reloads_module_suffix_candidate_test.go +41 -0
- package/cmd/ttscgraph/serve_session_reloads_superseding_module_candidates_test.go +216 -0
- package/cmd/ttscgraph/serve_session_retries_failed_dump_test.go +103 -0
- package/driver/graph.go +12 -6
- package/driver/lsp.go +30 -0
- package/driver/program.go +37 -1
- package/driver/resolution_candidates.go +819 -0
- package/driver/windowsjunction/windowsjunction.go +40 -0
- package/go.mod +2 -0
- package/internal/graph/build.go +45 -11
- package/internal/graph/dump.go +276 -100
- package/internal/graph/dump_checkout_paths_are_stable_test.go +210 -0
- package/internal/graph/dump_diagnostics_ride_the_generation_that_built_it_test.go +9 -3
- package/internal/graph/dump_paths.go +172 -0
- package/internal/graph/dump_paths_are_portable_and_injective_test.go +93 -0
- package/internal/graph/dump_uses_ecma_line_terminators_test.go +87 -0
- package/internal/graph/duplicate_variable_object_members_keep_first_declaration_test.go +61 -0
- package/internal/graph/edges.go +208 -0
- package/internal/graph/graph.go +143 -5
- package/internal/graph/line_model.go +122 -0
- package/internal/graph/member_relation_edges_follow_checker_validity_test.go +85 -0
- package/internal/graph/member_relation_edges_preserve_checker_boundaries_test.go +191 -0
- package/internal/graph/member_relation_edges_reject_checker_invalid_pairs_test.go +119 -0
- package/internal/graph/node_ids_preserve_hash_bearing_components_test.go +41 -0
- package/internal/graph/node_modifiers_emit_union_strings_test.go +4 -1
- package/internal/graph/object_literal_members_ride_on_the_snapshot_test.go +192 -0
- package/internal/graph/object_member_signatures_preserve_literal_whitespace_test.go +67 -0
- package/internal/graph/object_members.go +229 -0
- package/internal/graph/provenance.go +88 -30
- package/internal/graph/source_texts_cover_every_resident_program_source_test.go +73 -0
- package/internal/graphsymbols/position_helpers_follow_ecma_line_terminators_test.go +66 -0
- package/internal/graphsymbols/provider.go +26 -91
- package/internal/lspserver/lsp_clean_didopen_refreshes_compiler_state_test.go +144 -0
- package/internal/lspserver/lsp_completion.go +109 -0
- package/internal/lspserver/lsp_completion_gate_never_refuses_a_matching_line_test.go +50 -0
- package/internal/lspserver/lsp_completion_hints_longest_trigger_wins_test.go +149 -0
- package/internal/lspserver/lsp_completion_hints_nearest_trigger_wins_test.go +37 -0
- package/internal/lspserver/lsp_completion_merges_into_upstream_response_test.go +149 -0
- package/internal/lspserver/lsp_completion_nearest_hint_replaces_nearest_filter_test.go +43 -0
- package/internal/lspserver/lsp_completion_preserves_completion_list_extensions_test.go +99 -0
- package/internal/lspserver/lsp_completion_refuses_hints_inside_a_string_literal_test.go +69 -0
- package/internal/lspserver/lsp_completion_replaces_full_filter_in_rank_order_test.go +85 -0
- package/internal/lspserver/lsp_completion_request.go +455 -0
- package/internal/lspserver/lsp_completion_scope.go +530 -0
- package/internal/lspserver/lsp_completion_scope_bench_test.go +41 -0
- package/internal/lspserver/lsp_completion_scope_classifies_regex_statement_and_operator_boundaries_test.go +39 -0
- package/internal/lspserver/lsp_completion_scope_ignores_jsdoc_bytes_in_literals_test.go +108 -0
- package/internal/lspserver/lsp_completion_scope_refuses_regex_hints_test.go +52 -0
- package/internal/lspserver/lsp_completion_trigger_uses_last_rune_test.go +24 -0
- package/internal/lspserver/lsp_deleted_watched_file_withdraws_plugin_diagnostics_test.go +110 -0
- package/internal/lspserver/lsp_didsave_keeps_the_incremental_changed_uri_path_test.go +78 -0
- package/internal/lspserver/lsp_hints_absence_is_not_an_error_test.go +46 -0
- package/internal/lspserver/lsp_hints_refresh_coalesces_concurrent_requests_test.go +82 -0
- package/internal/lspserver/lsp_hints_refresh_ignores_a_superseded_generation_test.go +40 -0
- package/internal/lspserver/lsp_hints_refresh_keeps_each_producer_isolated_test.go +64 -0
- package/internal/lspserver/lsp_hints_refresh_replaces_the_session_snapshot_test.go +66 -0
- package/internal/lspserver/lsp_hints_refresh_scheduled_by_editor_events_test.go +90 -0
- package/internal/lspserver/lsp_hints_refresh_serves_completion_while_running_test.go +91 -0
- package/internal/lspserver/lsp_index_byte_from_bounds_its_search_start_test.go +38 -0
- package/internal/lspserver/lsp_initialize_constrains_position_encoding_to_utf16_test.go +205 -0
- package/internal/lspserver/lsp_late_completion_trigger_is_reported_once_test.go +105 -0
- package/internal/lspserver/lsp_native_completion_hints_decode_flat_lint_wire_test.go +66 -0
- package/internal/lspserver/lsp_native_completion_hints_grouped_compatibility_boundary_test.go +60 -0
- package/internal/lspserver/lsp_native_plugin_source.go +315 -2
- package/internal/lspserver/lsp_native_resident.go +304 -0
- package/internal/lspserver/lsp_plugin.go +85 -8
- package/internal/lspserver/lsp_plugin_completion_resolve_stays_local_test.go +82 -0
- package/internal/lspserver/lsp_position_conversions_span_astral_and_combining_runes_test.go +119 -0
- package/internal/lspserver/lsp_proxy.go +601 -9
- package/internal/lspserver/lsp_refresh.go +70 -0
- package/internal/lspserver/lsp_resident_falls_back_when_serve_unsupported_test.go +43 -0
- package/internal/lspserver/lsp_resident_maps_verb_args_test.go +34 -0
- package/internal/lspserver/lsp_server.go +13 -1
- package/internal/lspserver/lsp_watched_file_changes_reach_compiler_caches_test.go +172 -0
- package/lib/TtscCompiler.d.ts +3 -1
- package/lib/TtscCompiler.js +5 -1
- package/lib/TtscCompiler.js.map +1 -1
- package/lib/TtscService.d.ts +13 -3
- package/lib/TtscService.js +6 -6
- package/lib/TtscService.js.map +1 -1
- package/lib/compiler/internal/project/readConfigJson.d.ts +30 -0
- package/lib/compiler/internal/project/readConfigJson.js +208 -0
- package/lib/compiler/internal/project/readConfigJson.js.map +1 -0
- package/lib/compiler/internal/project/readProjectConfig.js +53 -149
- package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
- package/lib/compiler/internal/residentTransformProcess.d.ts +15 -2
- package/lib/compiler/internal/residentTransformProcess.js +159 -39
- package/lib/compiler/internal/residentTransformProcess.js.map +1 -1
- package/lib/compiler/internal/runBuild.d.ts +6 -0
- package/lib/compiler/internal/runBuild.js +143 -44
- package/lib/compiler/internal/runBuild.js.map +1 -1
- package/lib/compiler/internal/startResidentTransform.d.ts +5 -1
- package/lib/compiler/internal/startResidentTransform.js +3 -1
- package/lib/compiler/internal/startResidentTransform.js.map +1 -1
- package/lib/compiler/internal/transformProjectInMemory.js +12 -2
- package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
- package/lib/flags/parser.d.ts +19 -0
- package/lib/flags/parser.js +78 -36
- package/lib/flags/parser.js.map +1 -1
- package/lib/flags/schema.d.ts +49 -11
- package/lib/flags/schema.js +94 -22
- package/lib/flags/schema.js.map +1 -1
- package/lib/internal/assertSafeExplicitCacheDirectory.d.ts +5 -0
- package/lib/internal/assertSafeExplicitCacheDirectory.js +26 -0
- package/lib/internal/assertSafeExplicitCacheDirectory.js.map +1 -0
- package/lib/launcher/internal/runTtsc.js +107 -69
- package/lib/launcher/internal/runTtsc.js.map +1 -1
- package/lib/launcher/internal/runTtsx.js +28 -41
- package/lib/launcher/internal/runTtsx.js.map +1 -1
- package/lib/launcher/internal/runtimeHooks.d.ts +15 -0
- package/lib/launcher/internal/runtimeHooks.js +18 -1
- package/lib/launcher/internal/runtimeHooks.js.map +1 -1
- package/lib/launcher/internal/watchTopology.d.ts +43 -0
- package/lib/launcher/internal/watchTopology.js +360 -0
- package/lib/launcher/internal/watchTopology.js.map +1 -0
- package/lib/plugin/internal/buildSourcePlugin.d.ts +14 -3
- package/lib/plugin/internal/buildSourcePlugin.js +247 -61
- package/lib/plugin/internal/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/loadProjectPlugins.js +63 -2
- package/lib/plugin/internal/loadProjectPlugins.js.map +1 -1
- package/lib/structures/ITtscCompilerTransformation.d.ts +16 -0
- package/lib/structures/internal/ITtscParsedProjectConfig.d.ts +2 -0
- package/package.json +8 -8
- package/shim/ast/shim.go +48 -3
- package/shim/astnav/go.mod +14 -0
- package/shim/astnav/go.sum +20 -0
- package/shim/astnav/shim.go +15 -0
- package/shim/checker/shim.go +100 -0
- package/shim/core/shim.go +47 -0
- package/shim/diagnosticwriter/lint.go +50 -0
- package/src/TtscCompiler.ts +5 -1
- package/src/TtscService.ts +37 -10
- package/src/compiler/internal/project/readConfigJson.ts +209 -0
- package/src/compiler/internal/project/readProjectConfig.ts +62 -158
- package/src/compiler/internal/residentTransformProcess.ts +197 -39
- package/src/compiler/internal/runBuild.ts +169 -47
- package/src/compiler/internal/startResidentTransform.ts +12 -1
- package/src/compiler/internal/transformProjectInMemory.ts +12 -1
- package/src/flags/parser.ts +113 -42
- package/src/flags/schema.ts +113 -31
- package/src/internal/assertSafeExplicitCacheDirectory.ts +29 -0
- package/src/launcher/internal/runTtsc.ts +117 -68
- package/src/launcher/internal/runTtsx.ts +29 -44
- package/src/launcher/internal/runtimeHooks.ts +30 -2
- package/src/launcher/internal/watchTopology.ts +466 -0
- package/src/plugin/internal/buildSourcePlugin.ts +326 -64
- package/src/plugin/internal/loadProjectPlugins.ts +80 -2
- package/src/structures/ITtscCompilerTransformation.ts +17 -0
- package/src/structures/internal/ITtscParsedProjectConfig.ts +2 -0
- package/tools/shim_audit/baseline.json +0 -3
- package/tools/shim_audit/main.go +42 -14
- package/tools/shim_audit/shim_dir_coverage_test.go +25 -0
- package/utility/flags_gen.go +3 -3
- package/utility/host.go +9 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchTopology.js","sourceRoot":"","sources":["../../../src/launcher/internal/watchTopology.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,mFAA+E;AAC/E,yFAAsF;AACtF,qEAAkE;AAClE,qEAA8E;AAwB9E;;;;;;;GAOG;AACH;IAWqB,OAAO;IACP,SAAS;IAXpB,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,iBAAiB,GAAG,IAAI,GAAG,EAAwB,CAAC;IACpD,WAAW,GAAsB,EAAE,CAAC;IACpC,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;IAChD,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClC,YAAY,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC/C,mBAAmB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChD,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE5C,YACmB,OAA6B,EAC7B,SAAiC;uBADjC,OAAO;yBACP,SAAS;IACzB,CAAC;IAEJ,gFAAgF;IACzE,OAAO,CAAC,MAAe;QAC5B,MAAM,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClE,MAAM,OAAO,GACX,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK;YAC3C,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CA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AAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,WAAW,CAClB,IAAuB,EACvB,KAAwB;IAExB,OAAO,CACL,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAC7E,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,SAAiB;IACnD,MAAM,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAChD,OAAO,CACL,QAAQ,KAAK,EAAE;QACf,CAAC,QAAQ,KAAK,IAAI;YAChB,QAAQ,CAAC,UAAU,CAAC,KAAK,mBAAI,CAAC,GAAG,EAAE,CAAC,KAAK,KAAK;YAC9C,CAAC,mBAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAC9B,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,SAAS,OAAO,CAAC,QAAgB;IAC/B,MAAM,QAAQ,GAAG,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC1E,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SpawnSyncOptionsWithStringEncoding, type SpawnSyncReturns } from "node:child_process";
|
|
1
2
|
/** One contributor's resolved Go source plus its target sub-package name. */
|
|
2
3
|
export interface ITtscBuildContributor {
|
|
3
4
|
/** Sub-package suffix: scratch lands at `<host>/contrib/<name>/`. */
|
|
@@ -158,6 +159,13 @@ export declare function formatDuration(ms: number): string;
|
|
|
158
159
|
* `/` (the workspace convention) and then delegate to
|
|
159
160
|
* {@link autoQuoteGoModToken}, which mirrors `modfile.AutoQuote`.
|
|
160
161
|
*
|
|
162
|
+
* Separator normalization is itself a quoting trigger. A Windows UNC
|
|
163
|
+
* (`\\server\share\...`) or extended-length (`\\?\C:\...`) path normalizes into
|
|
164
|
+
* a token that starts with `//`, and the modfile lexer reads `//` as a line
|
|
165
|
+
* comment wherever it appears. Emitted bare, such a token turns its whole
|
|
166
|
+
* `use`/`replace` line into a comment: `go` exits 0, reports nothing, and the
|
|
167
|
+
* overlay module simply disappears from the workspace.
|
|
168
|
+
*
|
|
161
169
|
* Exported for unit tests.
|
|
162
170
|
*/
|
|
163
171
|
export declare function formatGoWorkPath(p: string): string;
|
|
@@ -165,13 +173,16 @@ export declare function formatGoWorkPath(p: string): string;
|
|
|
165
173
|
* Quote `token` for a `go.mod`/`go.work` line exactly as
|
|
166
174
|
* `golang.org/x/mod/modfile`'s `AutoQuote` does: return it unchanged when it is
|
|
167
175
|
* already a clean bare token, otherwise return its Go double-quoted form so the
|
|
168
|
-
* value round-trips through the modfile lexer. A
|
|
169
|
-
* emitted byte-for-byte as before; only tokens that would otherwise
|
|
170
|
-
*
|
|
176
|
+
* value round-trips through the modfile lexer. A clean bare token is therefore
|
|
177
|
+
* emitted byte-for-byte as before; only tokens that would otherwise be split or
|
|
178
|
+
* interpreted as comments are quoted.
|
|
171
179
|
*
|
|
172
180
|
* Exported for unit tests.
|
|
173
181
|
*/
|
|
174
182
|
export declare function autoQuoteGoModToken(token: string): string;
|
|
183
|
+
export declare function spawnGoTool(goBinary: string, args: readonly string[], options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
|
|
184
|
+
/** Build the fixed cmd.exe switch sequence for one already quoted payload. */
|
|
185
|
+
export declare function windowsGoCommandArgs(payload: string): string[];
|
|
175
186
|
/**
|
|
176
187
|
* Resolve the directory where compiled plugin binaries are cached.
|
|
177
188
|
*
|
|
@@ -12,6 +12,8 @@ exports.inspectPluginBuildLock = inspectPluginBuildLock;
|
|
|
12
12
|
exports.formatDuration = formatDuration;
|
|
13
13
|
exports.formatGoWorkPath = formatGoWorkPath;
|
|
14
14
|
exports.autoQuoteGoModToken = autoQuoteGoModToken;
|
|
15
|
+
exports.spawnGoTool = spawnGoTool;
|
|
16
|
+
exports.windowsGoCommandArgs = windowsGoCommandArgs;
|
|
15
17
|
exports.resolvePluginCacheRoot = resolvePluginCacheRoot;
|
|
16
18
|
exports.resolveSourceBuildCachePaths = resolveSourceBuildCachePaths;
|
|
17
19
|
exports.resolveCleanTargets = resolveCleanTargets;
|
|
@@ -24,6 +26,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
24
26
|
const node_module_1 = require("node:module");
|
|
25
27
|
const node_os_1 = __importDefault(require("node:os"));
|
|
26
28
|
const node_path_1 = __importDefault(require("node:path"));
|
|
29
|
+
const node_url_1 = require("node:url");
|
|
27
30
|
const paths_1 = require("../../compiler/internal/paths");
|
|
28
31
|
const GO_MOD_SEARCH_MAX_DEPTH = 3;
|
|
29
32
|
const TTSC_GO_MODULE_PATH = "github.com/samchon/ttsc/packages/ttsc";
|
|
@@ -172,7 +175,7 @@ function buildSourcePlugin(opts) {
|
|
|
172
175
|
const { dir, entry, source } = resolveSourceBuildTarget(opts);
|
|
173
176
|
const overlayDirs = [...(opts.overlayDirs ?? findTtscOverlayDirs())].sort();
|
|
174
177
|
const contributors = opts.contributors ?? [];
|
|
175
|
-
const goBinary = resolveGoCompiler(env);
|
|
178
|
+
const goBinary = resolveGoToolForBuild(resolveGoCompiler(env), env, dir);
|
|
176
179
|
ensureExecutableGoToolchain(goBinary);
|
|
177
180
|
const key = computeCacheKey({
|
|
178
181
|
contributors,
|
|
@@ -222,7 +225,8 @@ function compileSourcePlugin(opts) {
|
|
|
222
225
|
.map((c) => c.name)
|
|
223
226
|
.join(", ")}`;
|
|
224
227
|
process.stderr.write(`ttsc: building ${opts.label} "${opts.pluginName}" from ${opts.source}${extra} ` +
|
|
225
|
-
`(this runs once per cache key and can take several minutes on a cold Go cache)
|
|
228
|
+
`(this runs once per cache key and can take several minutes on a cold Go cache) ` +
|
|
229
|
+
`See https://ttsc.dev/docs/ttsc/compile#plugin-cache to persist it across builds.\n`);
|
|
226
230
|
}
|
|
227
231
|
const scratchDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), `ttsc-plugin-${opts.key}-`));
|
|
228
232
|
try {
|
|
@@ -1104,6 +1108,13 @@ function sourceBuildWorkspaceReplacements(useDirs, goModReader) {
|
|
|
1104
1108
|
* `/` (the workspace convention) and then delegate to
|
|
1105
1109
|
* {@link autoQuoteGoModToken}, which mirrors `modfile.AutoQuote`.
|
|
1106
1110
|
*
|
|
1111
|
+
* Separator normalization is itself a quoting trigger. A Windows UNC
|
|
1112
|
+
* (`\\server\share\...`) or extended-length (`\\?\C:\...`) path normalizes into
|
|
1113
|
+
* a token that starts with `//`, and the modfile lexer reads `//` as a line
|
|
1114
|
+
* comment wherever it appears. Emitted bare, such a token turns its whole
|
|
1115
|
+
* `use`/`replace` line into a comment: `go` exits 0, reports nothing, and the
|
|
1116
|
+
* overlay module simply disappears from the workspace.
|
|
1117
|
+
*
|
|
1107
1118
|
* Exported for unit tests.
|
|
1108
1119
|
*/
|
|
1109
1120
|
function formatGoWorkPath(p) {
|
|
@@ -1113,9 +1124,9 @@ function formatGoWorkPath(p) {
|
|
|
1113
1124
|
* Quote `token` for a `go.mod`/`go.work` line exactly as
|
|
1114
1125
|
* `golang.org/x/mod/modfile`'s `AutoQuote` does: return it unchanged when it is
|
|
1115
1126
|
* already a clean bare token, otherwise return its Go double-quoted form so the
|
|
1116
|
-
* value round-trips through the modfile lexer. A
|
|
1117
|
-
* emitted byte-for-byte as before; only tokens that would otherwise
|
|
1118
|
-
*
|
|
1127
|
+
* value round-trips through the modfile lexer. A clean bare token is therefore
|
|
1128
|
+
* emitted byte-for-byte as before; only tokens that would otherwise be split or
|
|
1129
|
+
* interpreted as comments are quoted.
|
|
1119
1130
|
*
|
|
1120
1131
|
* Exported for unit tests.
|
|
1121
1132
|
*/
|
|
@@ -1143,11 +1154,11 @@ function mustQuoteGoModToken(s) {
|
|
|
1143
1154
|
}
|
|
1144
1155
|
continue;
|
|
1145
1156
|
}
|
|
1146
|
-
if (!
|
|
1157
|
+
if (!isGoPrintable(ch)) {
|
|
1147
1158
|
return true;
|
|
1148
1159
|
}
|
|
1149
1160
|
}
|
|
1150
|
-
return s === "" || s
|
|
1161
|
+
return s === "" || s.includes("//") || s.includes("/*");
|
|
1151
1162
|
}
|
|
1152
1163
|
// Mirror `strconv.Quote`: wrap in double quotes, backslash-escape `"` and `\`,
|
|
1153
1164
|
// emit Go-printable runes verbatim (including the ASCII space and printable
|
|
@@ -1197,11 +1208,6 @@ function escapeGoRune(ch) {
|
|
|
1197
1208
|
}
|
|
1198
1209
|
}
|
|
1199
1210
|
}
|
|
1200
|
-
// `unicode.IsGraphic`: categories L, M, N, P, S, Zs (all spacing).
|
|
1201
|
-
const GO_GRAPHIC_RE = /^[\p{L}\p{M}\p{N}\p{P}\p{S}\p{Zs}]$/u;
|
|
1202
|
-
function isGoGraphic(ch) {
|
|
1203
|
-
return GO_GRAPHIC_RE.test(ch);
|
|
1204
|
-
}
|
|
1205
1211
|
// `strconv.IsPrint`: the graphic categories except that the ONLY spacing
|
|
1206
1212
|
// character is the ASCII space (U+0020); other Unicode spaces are escaped.
|
|
1207
1213
|
const GO_PRINTABLE_RE = /^[\p{L}\p{M}\p{N}\p{P}\p{S}]$/u;
|
|
@@ -1312,18 +1318,61 @@ function goToolchainNotFoundMessage(pluginName) {
|
|
|
1312
1318
|
`or set TTSC_GO_BINARY to an absolute path.`);
|
|
1313
1319
|
}
|
|
1314
1320
|
function spawnGoTool(goBinary, args, options) {
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
+
if (process.platform !== "win32") {
|
|
1322
|
+
return (0, node_child_process_1.spawnSync)(goBinary, [...args], options);
|
|
1323
|
+
}
|
|
1324
|
+
const inheritedEnv = options.env ?? process.env;
|
|
1325
|
+
const resolved = resolveWindowsGoTool(goBinary, inheritedEnv, spawnWorkingDirectory(options.cwd));
|
|
1326
|
+
if (!resolved.wrapper) {
|
|
1327
|
+
return (0, node_child_process_1.spawnSync)(goBinary, [...args], options);
|
|
1328
|
+
}
|
|
1329
|
+
// Preserve the native spawn ENOENT contract before cmd.exe becomes the
|
|
1330
|
+
// actual child process. The callers use that code for the install guidance.
|
|
1331
|
+
if (resolved.location === null) {
|
|
1332
|
+
return (0, node_child_process_1.spawnSync)(goBinary, [...args], options);
|
|
1333
|
+
}
|
|
1334
|
+
const shim = createWindowsGoCommandShim([resolved.location, ...args]);
|
|
1335
|
+
return (0, node_child_process_1.spawnSync)(readWindowsEnvironmentValue(inheritedEnv, "COMSPEC") ??
|
|
1336
|
+
readWindowsEnvironmentValue(process.env, "COMSPEC") ??
|
|
1337
|
+
"cmd.exe", windowsGoCommandArgs(shim.payload), {
|
|
1321
1338
|
...options,
|
|
1322
|
-
|
|
1339
|
+
env: { ...inheritedEnv, ...shim.environment },
|
|
1340
|
+
shell: false,
|
|
1341
|
+
// The /c payload is already one fully quoted Windows command line.
|
|
1342
|
+
windowsVerbatimArguments: true,
|
|
1323
1343
|
});
|
|
1324
1344
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1345
|
+
/** Build the fixed cmd.exe switch sequence for one already quoted payload. */
|
|
1346
|
+
function windowsGoCommandArgs(payload) {
|
|
1347
|
+
return ["/d", "/v:off", "/s", "/c", payload];
|
|
1348
|
+
}
|
|
1349
|
+
function spawnWorkingDirectory(cwd) {
|
|
1350
|
+
if (cwd === undefined)
|
|
1351
|
+
return process.cwd();
|
|
1352
|
+
return node_path_1.default.resolve(typeof cwd === "string" ? cwd : (0, node_url_1.fileURLToPath)(cwd));
|
|
1353
|
+
}
|
|
1354
|
+
function isWindowsCommandWrapper(location) {
|
|
1355
|
+
return process.platform === "win32" && /\.(?:bat|cmd)$/i.test(location);
|
|
1356
|
+
}
|
|
1357
|
+
/** Pass volatile cmd wrapper arguments through one-pass environment expansion. */
|
|
1358
|
+
function createWindowsGoCommandShim(args) {
|
|
1359
|
+
const prefix = `TTSC_GO_COMMAND_SHIM_${node_crypto_1.default
|
|
1360
|
+
.randomBytes(8)
|
|
1361
|
+
.toString("hex")
|
|
1362
|
+
.toUpperCase()}_ARG_`;
|
|
1363
|
+
const environment = Object.fromEntries(args.map((arg, index) => [prefix + index, quoteWindowsCommandArg(arg)]));
|
|
1364
|
+
return {
|
|
1365
|
+
environment,
|
|
1366
|
+
// cmd expands each placeholder exactly once. Percent-shaped text inside an
|
|
1367
|
+
// expanded value is not scanned as a second environment reference.
|
|
1368
|
+
payload: `"${args.map((_, index) => `%${prefix}${index}%`).join(" ")}"`,
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
/** Quote one argv value for the Windows command-line parser used by cmd. */
|
|
1372
|
+
function quoteWindowsCommandArg(arg) {
|
|
1373
|
+
return `"${String(arg)
|
|
1374
|
+
.replace(/(\\*)"/g, '$1$1\\"')
|
|
1375
|
+
.replace(/(\\*)$/, "$1$1")}"`;
|
|
1327
1376
|
}
|
|
1328
1377
|
function goBuildEnv(goBinary, goBuildCacheRoot, effectiveEnv = process.env) {
|
|
1329
1378
|
const env = { ...effectiveEnv };
|
|
@@ -1691,15 +1740,18 @@ function resolveGoCompiler(env = process.env) {
|
|
|
1691
1740
|
*/
|
|
1692
1741
|
function computeCacheKey(inputs) {
|
|
1693
1742
|
const env = inputs.env ?? process.env;
|
|
1743
|
+
const goBinary = inputs.goBinary === undefined
|
|
1744
|
+
? undefined
|
|
1745
|
+
: resolveGoToolForBuild(inputs.goBinary, env, inputs.dir);
|
|
1694
1746
|
const hash = node_crypto_1.default.createHash("sha256");
|
|
1695
1747
|
hash.update(`ttsc=${inputs.ttscVersion}\n`);
|
|
1696
1748
|
hash.update(`tsgo=${inputs.tsgoVersion}\n`);
|
|
1697
1749
|
hash.update(`platform=${process.platform}/${process.arch}\n`);
|
|
1698
1750
|
hash.update(`entry=${inputs.entry}\n`);
|
|
1699
|
-
if (
|
|
1700
|
-
hash.update(`go=${resolveGoCompilerIdentity(
|
|
1751
|
+
if (goBinary !== undefined) {
|
|
1752
|
+
hash.update(`go=${resolveGoCompilerIdentity(goBinary, env, inputs.dir)}\n`);
|
|
1701
1753
|
}
|
|
1702
|
-
hashGoBuildEnvironment(hash,
|
|
1754
|
+
hashGoBuildEnvironment(hash, goBinary, inputs.dir, env);
|
|
1703
1755
|
hashExternalGoBuildEnvironment(hash, env);
|
|
1704
1756
|
hashSourceDirectory(hash, "plugin", inputs.dir);
|
|
1705
1757
|
for (const [index, dir] of [...(inputs.overlayDirs ?? [])].sort().entries()) {
|
|
@@ -1782,19 +1834,26 @@ function isHashableFile(name) {
|
|
|
1782
1834
|
// content signature (byte size + nanosecond mtime). That signature changes if
|
|
1783
1835
|
// a long-lived host rewrites the binary in place between calls, so the memo
|
|
1784
1836
|
// re-derives the identity exactly as the un-memoized code would and the
|
|
1785
|
-
// cache-key bytes stay byte-for-byte identical to today.
|
|
1786
|
-
//
|
|
1837
|
+
// cache-key bytes stay byte-for-byte identical to today. The selected compiler
|
|
1838
|
+
// path is shared by every build subprocess on Windows, while `go version` uses
|
|
1839
|
+
// the same effective cwd and environment as the cache-key `go env` query. The
|
|
1840
|
+
// memo key includes that context so an environment-sensitive wrapper cannot
|
|
1841
|
+
// lend its version result to another compiler invocation.
|
|
1787
1842
|
const goCompilerIdentityCache = new Map();
|
|
1788
|
-
function resolveGoCompilerIdentity(goBinary, env = process.env) {
|
|
1789
|
-
const
|
|
1790
|
-
const
|
|
1843
|
+
function resolveGoCompilerIdentity(goBinary, env = process.env, cwd = process.cwd()) {
|
|
1844
|
+
const selected = resolveGoToolForBuild(goBinary, env, cwd);
|
|
1845
|
+
const resolved = process.platform === "win32"
|
|
1846
|
+
? resolveRealPath(selected)
|
|
1847
|
+
: resolveExecutableIdentityPath(selected, env, cwd);
|
|
1848
|
+
const compilerEnv = goBuildEnv(selected, undefined, env);
|
|
1849
|
+
const memoKey = goCompilerIdentityMemoKey(goBinary, resolved, compilerEnv, cwd);
|
|
1791
1850
|
if (memoKey !== null) {
|
|
1792
1851
|
const cached = goCompilerIdentityCache.get(memoKey);
|
|
1793
1852
|
if (cached !== undefined) {
|
|
1794
1853
|
return cached;
|
|
1795
1854
|
}
|
|
1796
1855
|
}
|
|
1797
|
-
const identity = computeGoCompilerIdentity(
|
|
1856
|
+
const identity = computeGoCompilerIdentity(selected, resolved, compilerEnv, cwd);
|
|
1798
1857
|
if (memoKey !== null) {
|
|
1799
1858
|
goCompilerIdentityCache.set(memoKey, identity);
|
|
1800
1859
|
}
|
|
@@ -1803,21 +1862,30 @@ function resolveGoCompilerIdentity(goBinary, env = process.env) {
|
|
|
1803
1862
|
// Build a memo key that pins both the resolved binary path and its current
|
|
1804
1863
|
// content. Returns null (skip caching, recompute) when the binary cannot be
|
|
1805
1864
|
// stat-ed, so the rare unstattable case never serves a stale identity.
|
|
1806
|
-
function goCompilerIdentityMemoKey(goBinary, resolved) {
|
|
1865
|
+
function goCompilerIdentityMemoKey(goBinary, resolved, env, cwd) {
|
|
1807
1866
|
try {
|
|
1808
1867
|
const stat = node_fs_1.default.statSync(resolved);
|
|
1809
|
-
|
|
1868
|
+
const context = node_crypto_1.default.createHash("sha256");
|
|
1869
|
+
context.update(cwd);
|
|
1870
|
+
for (const [key, value] of Object.entries(env).sort(([left], [right]) => left === right ? 0 : left < right ? -1 : 1)) {
|
|
1871
|
+
if (value === undefined)
|
|
1872
|
+
continue;
|
|
1873
|
+
context.update(`\0${key.length}:${key}${value.length}:${value}`);
|
|
1874
|
+
}
|
|
1875
|
+
return `${goBinary}\0${resolved}\0${stat.size}\0${stat.mtimeMs}\0${context.digest("hex")}`;
|
|
1810
1876
|
}
|
|
1811
1877
|
catch {
|
|
1812
1878
|
return null;
|
|
1813
1879
|
}
|
|
1814
1880
|
}
|
|
1815
|
-
function computeGoCompilerIdentity(goBinary, resolved) {
|
|
1881
|
+
function computeGoCompilerIdentity(goBinary, resolved, env, cwd) {
|
|
1816
1882
|
if (!node_fs_1.default.existsSync(resolved)) {
|
|
1817
1883
|
return "missing";
|
|
1818
1884
|
}
|
|
1819
1885
|
const version = spawnGoTool(goBinary, ["version"], {
|
|
1886
|
+
cwd,
|
|
1820
1887
|
encoding: "utf8",
|
|
1888
|
+
env,
|
|
1821
1889
|
windowsHide: true,
|
|
1822
1890
|
});
|
|
1823
1891
|
const versionText = version.error !== undefined
|
|
@@ -1826,45 +1894,163 @@ function computeGoCompilerIdentity(goBinary, resolved) {
|
|
|
1826
1894
|
const binaryHash = hashFile(resolved);
|
|
1827
1895
|
return `sha256:${binaryHash}:${versionText}`;
|
|
1828
1896
|
}
|
|
1829
|
-
function resolveExecutableIdentityPath(binary, env = process.env) {
|
|
1830
|
-
|
|
1831
|
-
|
|
1897
|
+
function resolveExecutableIdentityPath(binary, env = process.env, cwd = process.cwd()) {
|
|
1898
|
+
const resolved = findExecutablePath(binary, env, cwd);
|
|
1899
|
+
return resolved === null ? binary : resolveRealPath(resolved);
|
|
1900
|
+
}
|
|
1901
|
+
/** Pin Windows PATH and command-wrapper lookup to one build-wide target. */
|
|
1902
|
+
function resolveGoToolForBuild(binary, env, cwd) {
|
|
1903
|
+
if (process.platform !== "win32")
|
|
1904
|
+
return binary;
|
|
1905
|
+
return resolveWindowsGoTool(binary, env, cwd).location ?? binary;
|
|
1906
|
+
}
|
|
1907
|
+
function findExecutablePath(binary, env, cwd) {
|
|
1908
|
+
for (const candidate of executableSearchBases(binary, env, cwd)) {
|
|
1909
|
+
const resolved = findExecutableCandidate(candidate, env);
|
|
1910
|
+
if (resolved !== null)
|
|
1911
|
+
return resolved;
|
|
1832
1912
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1913
|
+
return null;
|
|
1914
|
+
}
|
|
1915
|
+
/** Preserve libuv's native target before falling back to cmd/bat wrappers. */
|
|
1916
|
+
function resolveWindowsGoTool(binary, env, cwd) {
|
|
1917
|
+
const candidates = executableSearchBases(binary, env, cwd);
|
|
1918
|
+
if (isWindowsCommandWrapper(binary)) {
|
|
1919
|
+
return {
|
|
1920
|
+
location: candidates.find(isExecutableFile) ?? null,
|
|
1921
|
+
wrapper: true,
|
|
1922
|
+
};
|
|
1835
1923
|
}
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
// a `.cmd`/`.bat` wrapper resolves to its real file and is hashed into the
|
|
1846
|
-
// cache key. Otherwise the wrapper reads as "missing" and a change to it
|
|
1847
|
-
// would not invalidate the cached plugin binary.
|
|
1848
|
-
for (const ext of windowsExecutableExtensions(env)) {
|
|
1849
|
-
const executable = `${candidate}${ext}`;
|
|
1850
|
-
if (node_fs_1.default.existsSync(executable)) {
|
|
1851
|
-
return resolveRealPath(executable);
|
|
1852
|
-
}
|
|
1924
|
+
const hasExtension = windowsFileNameHasExtension(binary);
|
|
1925
|
+
for (const candidate of candidates) {
|
|
1926
|
+
if (hasExtension && isExecutableFile(candidate)) {
|
|
1927
|
+
return { location: candidate, wrapper: false };
|
|
1928
|
+
}
|
|
1929
|
+
for (const extension of [".com", ".exe"]) {
|
|
1930
|
+
const executable = candidate + extension;
|
|
1931
|
+
if (isExecutableFile(executable)) {
|
|
1932
|
+
return { location: executable, wrapper: false };
|
|
1853
1933
|
}
|
|
1854
1934
|
}
|
|
1855
1935
|
}
|
|
1856
|
-
|
|
1936
|
+
const wrapperExtensions = windowsExecutableExtensions(env).filter((ext) => /\.(?:bat|cmd)$/i.test(ext));
|
|
1937
|
+
for (const candidate of candidates) {
|
|
1938
|
+
for (const extension of wrapperExtensions) {
|
|
1939
|
+
const executable = candidate + extension;
|
|
1940
|
+
if (isExecutableFile(executable)) {
|
|
1941
|
+
return { location: executable, wrapper: true };
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
return { location: null, wrapper: false };
|
|
1946
|
+
}
|
|
1947
|
+
function executableSearchBases(binary, env, cwd) {
|
|
1948
|
+
if (node_path_1.default.isAbsolute(binary))
|
|
1949
|
+
return [binary];
|
|
1950
|
+
if (hasPathQualifier(binary))
|
|
1951
|
+
return [node_path_1.default.resolve(cwd, binary)];
|
|
1952
|
+
const directories = process.platform === "win32"
|
|
1953
|
+
? splitWindowsSearchPath(readPathEnvironment(env))
|
|
1954
|
+
// libuv skips only genuinely empty slices. A quoted-empty slice
|
|
1955
|
+
// survives that check, unquotes to "", and therefore names cwd.
|
|
1956
|
+
.filter((entry) => entry.length > 0)
|
|
1957
|
+
.map(unquoteWindowsSearchEntry)
|
|
1958
|
+
: readPathEnvironment(env).split(node_path_1.default.delimiter);
|
|
1959
|
+
const noDefaultCurrentDirectory = process.platform === "win32"
|
|
1960
|
+
? readWindowsEnvironmentValue(process.env, "NoDefaultCurrentDirectoryInExePath")
|
|
1961
|
+
: undefined;
|
|
1962
|
+
if (process.platform === "win32" && noDefaultCurrentDirectory === undefined) {
|
|
1963
|
+
directories.unshift(cwd);
|
|
1964
|
+
}
|
|
1965
|
+
return directories.map((dir) => node_path_1.default.resolve(cwd, dir, binary));
|
|
1966
|
+
}
|
|
1967
|
+
function findExecutableCandidate(candidate, env) {
|
|
1968
|
+
if (isExecutableFile(candidate))
|
|
1969
|
+
return candidate;
|
|
1970
|
+
if (process.platform !== "win32")
|
|
1971
|
+
return null;
|
|
1972
|
+
// Probe every PATHEXT extension, not just `.exe`, so a compiler backed by a
|
|
1973
|
+
// `.cmd`/`.bat` wrapper is both launched correctly and hashed into the cache
|
|
1974
|
+
// key. Otherwise the wrapper reads as missing and changes do not invalidate
|
|
1975
|
+
// the cached plugin binary.
|
|
1976
|
+
for (const ext of windowsExecutableExtensions(env)) {
|
|
1977
|
+
const executable = `${candidate}${ext}`;
|
|
1978
|
+
if (isExecutableFile(executable))
|
|
1979
|
+
return executable;
|
|
1980
|
+
}
|
|
1981
|
+
return null;
|
|
1982
|
+
}
|
|
1983
|
+
function isExecutableFile(location) {
|
|
1984
|
+
try {
|
|
1985
|
+
return node_fs_1.default.statSync(location).isFile();
|
|
1986
|
+
}
|
|
1987
|
+
catch {
|
|
1988
|
+
return false;
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
function hasPathQualifier(location) {
|
|
1992
|
+
return (location.includes(node_path_1.default.sep) ||
|
|
1993
|
+
(process.platform === "win32" &&
|
|
1994
|
+
(location.includes("/") || /^[a-zA-Z]:/.test(location))));
|
|
1995
|
+
}
|
|
1996
|
+
function windowsFileNameHasExtension(location) {
|
|
1997
|
+
const name = node_path_1.default.basename(location);
|
|
1998
|
+
const dot = name.indexOf(".");
|
|
1999
|
+
return dot >= 0 && dot < name.length - 1;
|
|
2000
|
+
}
|
|
2001
|
+
function splitWindowsSearchPath(value) {
|
|
2002
|
+
const entries = [];
|
|
2003
|
+
let start = 0;
|
|
2004
|
+
let quote = "";
|
|
2005
|
+
for (let index = 0; index < value.length; index++) {
|
|
2006
|
+
const character = value[index];
|
|
2007
|
+
if (quote !== "") {
|
|
2008
|
+
if (character === quote)
|
|
2009
|
+
quote = "";
|
|
2010
|
+
}
|
|
2011
|
+
else if ((character === '"' || character === "'") && index === start) {
|
|
2012
|
+
quote = character;
|
|
2013
|
+
}
|
|
2014
|
+
else if (character === ";") {
|
|
2015
|
+
entries.push(value.slice(start, index));
|
|
2016
|
+
start = index + 1;
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
entries.push(value.slice(start));
|
|
2020
|
+
return entries;
|
|
2021
|
+
}
|
|
2022
|
+
function unquoteWindowsSearchEntry(location) {
|
|
2023
|
+
const first = location[0];
|
|
2024
|
+
const withoutFirst = first === '"' || first === "'" ? location.slice(1) : location;
|
|
2025
|
+
const last = withoutFirst[withoutFirst.length - 1];
|
|
2026
|
+
return last === '"' || last === "'"
|
|
2027
|
+
? withoutFirst.slice(0, -1)
|
|
2028
|
+
: withoutFirst;
|
|
1857
2029
|
}
|
|
1858
2030
|
function windowsExecutableExtensions(env = process.env) {
|
|
1859
|
-
const pathext = env
|
|
2031
|
+
const pathext = readWindowsEnvironmentValue(env, "PATHEXT");
|
|
1860
2032
|
const raw = pathext && pathext.length > 0 ? pathext : ".COM;.EXE;.BAT;.CMD";
|
|
1861
|
-
return raw
|
|
1862
|
-
.
|
|
1863
|
-
.map((ext) => ext.
|
|
2033
|
+
return splitWindowsSearchPath(raw)
|
|
2034
|
+
.map(unquoteWindowsSearchEntry)
|
|
2035
|
+
.map((ext) => ext.toLowerCase())
|
|
1864
2036
|
.filter((ext) => ext.length > 0);
|
|
1865
2037
|
}
|
|
1866
2038
|
function readPathEnvironment(env = process.env) {
|
|
1867
|
-
return
|
|
2039
|
+
return process.platform === "win32"
|
|
2040
|
+
? (readWindowsEnvironmentValue(env, "PATH") ??
|
|
2041
|
+
readWindowsEnvironmentValue(process.env, "PATH") ??
|
|
2042
|
+
"")
|
|
2043
|
+
: (env.PATH ?? "/usr/bin:/bin");
|
|
2044
|
+
}
|
|
2045
|
+
function readWindowsEnvironmentValue(env, name) {
|
|
2046
|
+
const exact = env[name];
|
|
2047
|
+
if (exact !== undefined)
|
|
2048
|
+
return exact;
|
|
2049
|
+
const normalized = name.toLowerCase();
|
|
2050
|
+
const key = Object.keys(env)
|
|
2051
|
+
.filter((candidate) => candidate.toLowerCase() === normalized)
|
|
2052
|
+
.sort()[0];
|
|
2053
|
+
return key === undefined ? undefined : env[key];
|
|
1868
2054
|
}
|
|
1869
2055
|
function resolveRealPath(location) {
|
|
1870
2056
|
try {
|