333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/**
 * Browser's implementation of the platform-specific tools.
 *
 * This file gonna replace PlatformTools for browser environment.
 * For node.js environment this class is not getting packaged.
 * Don't use methods of this class in the code, use PlatformTools methods instead.
 */
var PlatformTools = /** @class */ (function () {
    function PlatformTools() {
    }
    /**
     * Gets global variable where global stuff can be stored.
     */
    PlatformTools.getGlobalVariable = function () {
        if (typeof window !== "undefined") {
            return window;
        }
        else {
            // NativeScript uses global, not window
            return global;
        }
    };
    /**
     * Loads ("require"-s) given file or package.
     * This operation only supports on node platform
     */
    PlatformTools.load = function (name) {
        if (this.type === "browser")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: require(\"" + name + "\").");
        return "";
    };
    /**
     * Normalizes given path. Does "path.normalize".
     */
    PlatformTools.pathNormalize = function (pathStr) {
        if (this.type === "browser")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: path.normalize(\"" + pathStr + "\").");
        return "";
    };
    /**
     * Gets file extension. Does "path.extname".
     */
    PlatformTools.pathExtname = function (pathStr) {
        if (this.type === "browser")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: path.extname(\"" + pathStr + "\").");
        return "";
    };
    /**
     * Resolved given path. Does "path.resolve".
     */
    PlatformTools.pathResolve = function (pathStr) {
        if (this.type === "browser")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: path.resolve(\"" + pathStr + "\").");
        return "";
    };
    /**
     * Synchronously checks if file exist. Does "fs.existsSync".
     */
    PlatformTools.fileExist = function (pathStr) {
        if (this.type === "browser")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: fs.existsSync(\"" + pathStr + "\").");
        return false;
    };
    /**
     * Gets environment variable.
     */
    PlatformTools.getEnvVariable = function (name) {
        // if (this.type === "browser")
        //     throw new Error(`This option/function is not supported in the browser environment. Failed operation: process.env["${name}"].`);
        return undefined;
    };
    PlatformTools.readFileSync = function (filename) {
        if (this.type === "browser")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: fs.readFileSync(\"" + filename + "\").");
        return null;
    };
    PlatformTools.appendFileSync = function (filename, data) {
        if (this.type === "browser")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: fs.appendFileSync(\"" + filename + "\").");
    };
    PlatformTools.writeFile = function (path, data) {
        if (this.type === "browser")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: fs.writeFile(\"" + path + "\").");
        return Promise.reject(null);
    };
    /**
     * Highlights sql string to be print in the console.
     */
    PlatformTools.highlightSql = function (sql) {
        return sql;
    };
    /**
     * Highlights json string to be print in the console.
     */
    PlatformTools.highlightJson = function (json) {
        return json;
    };
    /**
     * Logging functions needed by AdvancedConsoleLogger (but here without chalk)
     */
    PlatformTools.logInfo = function (prefix, info) {
        console.info(prefix + " ", info);
    };
    PlatformTools.logError = function (prefix, error) {
        console.error(prefix + " ", error);
    };
    PlatformTools.logWarn = function (prefix, warning) {
        console.warn(prefix + " ", warning);
    };
    PlatformTools.log = function (message) {
        console.log(message);
    };
    PlatformTools.warn = function (message) {
        return message;
    };
    /**
     * Type of the currently running platform.
     */
    PlatformTools.type = "browser";
    return PlatformTools;
}());
export { PlatformTools };
/**
 * These classes are needed for stream operations or
 * in the mongodb driver. Both aren't supported in the browser.
 */
var EventEmitter = /** @class */ (function () {
    function EventEmitter() {
    }
    return EventEmitter;
}());
export { EventEmitter };
var Readable = /** @class */ (function () {
    function Readable() {
    }
    return Readable;
}());
export { Readable };
var Writable = /** @class */ (function () {
    function Writable() {
    }
    return Writable;
}());
export { Writable };
if (typeof window !== "undefined") {
    window.Buffer = require("buffer/").Buffer;
}
// NativeScript uses global, not window
if (typeof global !== "undefined") {
    global.Buffer = require("buffer/").Buffer;
}
 
//# sourceMappingURL=PlatformTools.js.map