From c140b08e125e36b81f0c6acd63282655502a9bea Mon Sep 17 00:00:00 2001 From: DaTekShaman Date: Mon, 5 Jan 2026 19:49:38 +0300 Subject: [PATCH] Add test-options.js script for reporting global variables and content types --- config-sub-converter/scripts/test-options.js | 46 ++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 config-sub-converter/scripts/test-options.js diff --git a/config-sub-converter/scripts/test-options.js b/config-sub-converter/scripts/test-options.js new file mode 100644 index 0000000..108f592 --- /dev/null +++ b/config-sub-converter/scripts/test-options.js @@ -0,0 +1,46 @@ +function safeStringify(obj) { + const seen = new WeakSet(); + return JSON.stringify( + obj, + (k, v) => { + if (typeof v === "object" && v !== null) { + if (seen.has(v)) return "[Circular]"; + seen.add(v); + } + if (typeof v === "function") return `[Function: ${v.name || "anonymous"}]`; + if (typeof v === "bigint") return v.toString(); + return v; + }, + 2 + ); +} + +function globalKeysSample(limit = 200) { + try { + const keys = Object.getOwnPropertyNames(globalThis).sort(); + return keys.slice(0, limit); + } catch { + return []; + } +} + +const report = { + types: { + $content: typeof $content, + $files: typeof $files, + $options: typeof $options, + ProxyUtils: typeof ProxyUtils, + produceArtifact: typeof produceArtifact, + }, + values: { + $contentPreview: (typeof $content === "string" ? $content.slice(0, 300) : $content), + $contentLength: (typeof $content === "string" ? $content.length : null), + $files: $files ?? null, + $options: $options ?? null, + }, + globals: { + globalThisKeysSample: globalKeysSample(), + } +}; + +$content = safeStringify(report);