1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 * Build: <objdir>/dist/@types/lib.gecko.services.d.ts,
9 * from: <objdir>/xpcom/components/services.json,
10 * generated by a previous build step.
13 const fs = require("fs");
16 * NOTE: Do not modify this file by hand.
17 * Content was generated from services.json.
22 cpmm: ["ContentProcessMessageManager"],
23 mm: ["ChromeMessageBroadcaster"],
24 ppmm: ["ParentProcessMessageManager"],
27 function main(lib_dts, services_json) {
28 let interfaces = JSON.parse(fs.readFileSync(services_json, "utf8"));
30 for (let [iface, svc] of Object.entries(interfaces)) {
31 SERVICES[svc] = SERVICES[svc] ?? [];
32 SERVICES[svc].push(iface);
36 lines.push("interface JSServices {");
37 for (let [svc, ifaces] of Object.entries(SERVICES).sort()) {
38 lines.push(` ${svc}: ${ifaces.join(" & ")};`);
42 let dts = lines.join("\n");
43 console.log(`[INFO] ${lib_dts} (${dts.length.toLocaleString()} bytes)`);
44 fs.writeFileSync(lib_dts, dts);
47 main(...process.argv.slice(2));