diff options
| author | Luke Hoersten <[email protected]> | 2026-06-14 20:27:06 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2026-06-14 20:27:06 -0500 |
| commit | 97a177b3dd134b5457c5a96688626f7cdfe53a6d (patch) | |
| tree | 1655d8f85a8f03e2b8238dc8641b28a6a7494659 /scrypted/diagnostic.ts | |
| parent | 865c4859d710870245ae7954e729edcaf442a921 (diff) | |
scrypted/diagnostic: probe for mDNS modules ahead of auto-discovery
Diffstat (limited to 'scrypted/diagnostic.ts')
| -rw-r--r-- | scrypted/diagnostic.ts | 70 |
1 files changed, 22 insertions, 48 deletions
diff --git a/scrypted/diagnostic.ts b/scrypted/diagnostic.ts index f611268..e159f1d 100644 --- a/scrypted/diagnostic.ts +++ b/scrypted/diagnostic.ts @@ -1,51 +1,25 @@ -// Paste this into a NEW Scrypted Script (Scripts UI → New). Save + Run. -// The console output tells us exactly which names the Scrypted-eval -// sandbox is exposing on this Scrypted/core version, which guides what -// the real `scrypted-viewport.ts` should reference. -// -// `declare const ...: any` lines below exist only to keep the editor's -// TypeScript happy; they fully erase at runtime, and the `typeof` checks -// look up whatever the runtime injects (or undefined if it doesn't). +// Paste into the diagnostic / probe Scrypted script. Save + Run. +// Tells us which Node/mDNS modules the scriptedEval sandbox lets us +// require() — drives whether the auto-discovery feature can use a +// proper library or has to fall back to raw multicast UDP. -declare const sdk: any; -declare const ScryptedDeviceBase: any; -declare const ScryptedDeviceType: any; -declare const ScryptedInterface: any; -declare const systemManager: any; -declare const deviceManager: any; -declare const mediaManager: any; -declare const endpointManager: any; -declare const log: any; -declare const device: any; -declare const require: any; -declare const exports: any; +declare const sdk: any; +declare const require: any; -console.log("------ Scrypted scriptedEval scope probe ------"); -console.log("sdk ->", typeof sdk); -console.log("ScryptedDeviceBase ->", typeof ScryptedDeviceBase); -console.log("ScryptedDeviceType ->", typeof ScryptedDeviceType); -console.log("ScryptedInterface ->", typeof ScryptedInterface); -console.log("systemManager ->", typeof systemManager); -console.log("deviceManager ->", typeof deviceManager); -console.log("mediaManager ->", typeof mediaManager); -console.log("endpointManager ->", typeof endpointManager); -console.log("log ->", typeof log); -console.log("device ->", typeof device); -console.log("require ->", typeof require); -console.log("exports ->", typeof exports); - -if (typeof sdk !== "undefined" && sdk) { - const keys = Object.keys(sdk); - console.log("sdk has", keys.length, "keys; first 25:", keys.slice(0, 25).join(",")); - console.log("sdk.ScryptedDeviceBase ->", typeof sdk.ScryptedDeviceBase); - console.log("sdk.systemManager ->", typeof sdk.systemManager); -} - -// Try the "require Node builtin" path too — older Scripts plugin builds -// gate `require` differently than the SDK names. -try { - const dns = require("dns"); - console.log("require('dns') -> ok, has", typeof dns.promises === "object" ? "promises" : "(no .promises)"); -} catch (e: any) { - console.log("require('dns') -> ERR:", e && e.message); +console.log("------ scriptedEval require() probe ------"); +for (const mod of [ + "dns", // built-in; we already use this for dns.lookup + "dgram", // built-in; needed for raw mDNS multicast UDP + "multicast-dns", + "bonjour", + "bonjour-service", + "mdns", +]) { + try { + const m = require(mod); + const top = Object.keys(m || {}).slice(0, 8).join(","); + console.log(` ${mod.padEnd(16)} -> ok; top keys: ${top}`); + } catch (e: any) { + console.log(` ${mod.padEnd(16)} -> ${e?.code || "ERR"}: ${e?.message || e}`); + } } |
