当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript util-electron.isRenderer函数代码示例

本文整理汇总了TypeScript中eez-studio-shared/util-electron.isRenderer函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isRenderer函数的具体用法?TypeScript isRenderer怎么用?TypeScript isRenderer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了isRenderer函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: watch

export function watch(
    sourceId: string,
    filterSpecification: any,
    callback: (message: any) => void
) {
    let targetId = guid();

    // add target to this window
    targets.set(targetId, {
        sourceId,
        filterSpecification,
        callback
    });

    if (!filterSpecification || !filterSpecification.skipInitialQuery) {
        let source = sources.get(sourceId);
        if (source && source.onNewTarget) {
            source.onNewTarget(targetId, filterSpecification, true);
        }
    }

    // add target to other windows
    let targetWindowId: number;
    if (isRenderer()) {
        targetWindowId = EEZStudio.electron.remote.getCurrentWindow().id;
    } else {
        targetWindowId = -1;
    }

    getBrowserWindow()
        .getAllWindows()
        .forEach(window => {
            if (window.id !== targetWindowId) {
                sendNotifyWatch(window.webContents, {
                    sourceId,
                    filterSpecification,
                    targetId,
                    targetWindowId
                });
            }
        });

    if (isRenderer()) {
        sendNotifyWatch(EEZStudio.electron.ipcRenderer, {
            sourceId,
            filterSpecification,
            targetId,
            targetWindowId
        });
    }

    return targetId;
}
开发者ID:eez-open,项目名称:studio,代码行数:53,代码来源:notify.ts

示例2: getBrowserWindow

function getBrowserWindow() {
    if (isRenderer()) {
        return EEZStudio.electron.remote.BrowserWindow;
    } else {
        return require("electron").BrowserWindow;
    }
}
开发者ID:eez-open,项目名称:studio,代码行数:7,代码来源:notify.ts

示例3: function

ipc.on("notify/get-targets", function(event: any, windowId: number) {
    let targetWindowId: number;
    if (isRenderer()) {
        targetWindowId = EEZStudio.electron.remote.getCurrentWindow().id;
    } else {
        targetWindowId = -1;
    }
    targets.forEach((target, targetId) => {
        if (target.callback) {
            sendNotifyWatch(getBrowserWindow().fromId(windowId).webContents, {
                sourceId: target.sourceId,
                filterSpecification: target.filterSpecification,
                targetId,
                targetWindowId
            });
        }
    });
});
开发者ID:eez-open,项目名称:studio,代码行数:18,代码来源:notify.ts

示例4: values

import { stringCompare } from "eez-studio-shared/string";
import { beginTransaction, commitTransaction } from "eez-studio-shared/store";

import { IDesignerContext } from "eez-studio-designer/designer-interfaces";

import { loadInstrumentExtension } from "instrument/import";
import { instrumentStore, instruments } from "instrument/instrument-object";
import * as AddInstrumentDialogModule from "instrument/add-instrument-dialog";
import * as DeletedInstrumentsDialogModule from "instrument/deleted-instruments-dialog";
import { IInstrumentProperties } from "instrument/export";

import * as ConnectionModule from "instrument/connection/connection";

import { createInstrumentListStore } from "instrument/window/lists/store";

if (!isRenderer()) {
    createInstrumentListStore(null);
}

export interface IInstrumentExtensionProperties extends IExtensionProperties {
    properties: IInstrumentProperties;
}

export const instrumentExtensions = computed(() => {
    return values(extensions)
        .filter(extension => extension.type === "instrument")
        .sort((a, b) => stringCompare(a.displayName || a.name, b.displayName || b.name));
});

function createInstrument(extension: IExtension) {
    return {
开发者ID:eez-open,项目名称:studio,代码行数:31,代码来源:instrument-extension.ts

示例5: function

import Database from "better-sqlite3";
import { isRenderer } from "eez-studio-shared/util-electron";

import * as MainSettingsModule from "main/settings";

export let getDbPath: () => string;
export let setDbPath: (dbPath: string) => void;

if (isRenderer()) {
    getDbPath = function() {
        return EEZStudio.electron.ipcRenderer.sendSync("getDbPath");
    };

    setDbPath = function(dbPath: string) {
        EEZStudio.electron.ipcRenderer.send("setDbPath", dbPath);
    };
} else {
    ({ getDbPath, setDbPath } = require("main/settings") as typeof MainSettingsModule);
}

export let db = new Database(getDbPath());
db.defaultSafeIntegers();

// // DB query is executed in Main process
// if (!isRenderer()) {
//     const { ipcMain } = require("electron");

//     ipcMain.on(
//         "dbQueryTask",
//         (event: Electron.Event, taskId: string, query: string, ...args: any[]) => {
//             try {
开发者ID:eez-open,项目名称:studio,代码行数:31,代码来源:db.ts

示例6: loadInstrumentExtension

export async function loadInstrumentExtension(extensionFolderPath: string) {
    try {
        let idfFilePath = await findIdfFile(extensionFolderPath);
        if (!idfFilePath) {
            throw "IDF file not found";
        }

        if (isRenderer()) {
            let idfXmlAsString = await readTextFile(idfFilePath);
            let idf = parseXmlString(idfXmlAsString);
            let ScpiConfiguration = $(idf).find(">ScpiConfigurations");
            if (ScpiConfiguration.length && ScpiConfiguration.attr("guid")) {
                let id = ScpiConfiguration.attr("guid")!;

                let name = ScpiConfiguration.attr("name") || "Unknown name";
                let version = ScpiConfiguration.attr("firmwareVersion") || "Unknown version";

                let properties: IInstrumentExtensionProperties;
                let isEditable: boolean;
                let downloadUrl: string | undefined;
                let sha256: string | undefined;
                let moreDescription: string | undefined;

                let packageJsonFilePath = extensionFolderPath + "/package.json";
                if (await fileExists(packageJsonFilePath)) {
                    const packageJson = await readPackageJson(packageJsonFilePath);
                    version = packageJson.version;
                    properties = packageJson["eez-studio"];
                    isEditable = await fileExists(extensionFolderPath + "/.editable");
                    downloadUrl = packageJson.download;
                    sha256 = packageJson.sha256;
                    moreDescription = properties.moreDescription;
                } else {
                    properties = EMPTY_INSTRUMENT_PROPERTIES;
                    isEditable = true;

                    await writeBinaryData(extensionFolderPath + "/.editable", "");

                    await writeJsObjectToFile(packageJsonFilePath, {
                        name,
                        version,
                        "eez-studio": properties
                    });

                    downloadUrl = undefined;
                }

                const isDirty =
                    isEditable &&
                    ((await fileExists(extensionFolderPath + "/package.json")) ||
                        (await fileExists(extensionFolderPath + "/image.png")));

                const extension: IExtension = observable(
                    {
                        id,
                        type: "instrument",
                        name,
                        description:
                            ScpiConfiguration.attr("description") || "Unknown description.",
                        moreDescription,
                        version,
                        author: ScpiConfiguration.attr("author") || "Unknown author",
                        image: "",
                        renderPropertiesComponent: () => {
                            const {
                                renderPropertiesComponent
                            } = require("instrument/properties-component") as typeof PropertiesComponentModule;

                            return new Promise<JSX.Element>(resolve => {
                                resolve(renderPropertiesComponent(extension));
                            });
                        },
                        properties,
                        isEditable,
                        isDirty,

                        shortName: ScpiConfiguration.attr("shortName") || "",
                        revisionNumber: ScpiConfiguration.attr("revisionNumber") || "",
                        supportedModels: ScpiConfiguration.attr("supportedModels") || "",
                        revisionComments: ScpiConfiguration.attr("revisionComments") || ""
                    },
                    {
                        properties: observable.shallow
                    }
                );

                const imageFilePath = extensionFolderPath + "/" + "image.png";
                if (await fileExists(imageFilePath)) {
                    extension.image = localPathToFileUrl(imageFilePath);
                } else {
                    extension.image = INSTRUMENT_NO_IMAGE;
                }

                extension.download = downloadUrl;
                extension.sha256 = sha256;

                extension.installationFolderPath = extensionFolderPath;

                return extension;
            }
//.........这里部分代码省略.........
开发者ID:eez-open,项目名称:studio,代码行数:101,代码来源:import.ts


注:本文中的eez-studio-shared/util-electron.isRenderer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。