{"version":3,"file":"webDevRoots.mjs","names":[],"sources":["../../../src/builders/web/webDevRoots.ts"],"sourcesContent":["/**\n * Where the cockpit's dev server finds the plugin packages to serve with hot\n * reload. Pure: the adapter hands in the environment value and the roots file\n * the last `doompi sync` wrote next to its bundle; this only decides.\n */\n\n/** A delimiter-separated list of plugin package roots; wins over the synced roots file. */\nexport const PLUGIN_ROOTS_ENV = 'DOOMPI_WEB_PLUGIN_ROOTS';\n/** The file `doompi sync` writes beside its bundle, listing the package roots it bundled. */\nexport const PLUGIN_ROOTS_FILE = 'pluginRoots.json';\n\nexport interface DevPluginRootsInput {\n  /** The raw environment value, undefined when unset. */\n  envValue: string | undefined;\n  /** The roots file's text, undefined when no synced bundle exists. */\n  rootsFileText: string | undefined;\n  /** The platform's path list delimiter (':' on POSIX, ';' on Windows). */\n  delimiter: string;\n}\n\n/** The plugin roots the dev server should serve: the environment list, else the synced list, else none. */\nexport function devPluginRoots({ envValue, rootsFileText, delimiter }: DevPluginRootsInput): string[] {\n  if (envValue !== undefined && envValue.trim() !== '') {\n    return envValue\n      .split(delimiter)\n      .map((root) => root.trim())\n      .filter((root) => root !== '');\n  }\n  if (rootsFileText === undefined) return [];\n  try {\n    const parsed: unknown = JSON.parse(rootsFileText);\n    return Array.isArray(parsed) ? parsed.filter((root): root is string => typeof root === 'string') : [];\n  } catch {\n    return [];\n  }\n}\n"],"mappings":";;;;;;;AAOA,MAAa,mBAAmB;;AAEhC,MAAa,oBAAoB;;AAYjC,SAAgB,eAAe,EAAE,UAAU,eAAe,aAA4C;CACpG,IAAI,aAAa,KAAA,KAAa,SAAS,KAAK,MAAM,IAChD,OAAO,SACJ,MAAM,SAAS,CAAC,CAChB,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,QAAQ,SAAS,SAAS,EAAE;CAEjC,IAAI,kBAAkB,KAAA,GAAW,OAAO,CAAC;CACzC,IAAI;EACF,MAAM,SAAkB,KAAK,MAAM,aAAa;EAChD,OAAO,MAAM,QAAQ,MAAM,IAAI,OAAO,QAAQ,SAAyB,OAAO,SAAS,QAAQ,IAAI,CAAC;CACtG,QAAQ;EACN,OAAO,CAAC;CACV;AACF"}