@umijs/utils 4.0.37 → 4.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/getDevBanner.js +3 -70
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +1 -2
- package/compiled/open/LICENSE +0 -9
- package/compiled/open/index.d.ts +0 -153
- package/compiled/open/index.js +0 -1
- package/compiled/open/package.json +0 -1
- package/compiled/open/xdg-open +0 -1066
- package/dist/openBrowser.d.ts +0 -9
- package/dist/openBrowser.js +0 -96
- package/dist/openChrome.applescript +0 -95
package/dist/openBrowser.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The following is modified based on source found in
|
|
3
|
-
* https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/openBrowser.js
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Reads the BROWSER environment variable and decides what to do with it. Returns
|
|
7
|
-
* true if it opened a browser or ran a node.js script, otherwise false.
|
|
8
|
-
*/
|
|
9
|
-
export declare function openBrowser(url: string): boolean;
|
package/dist/openBrowser.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
|
|
22
|
-
// src/openBrowser.ts
|
|
23
|
-
var openBrowser_exports = {};
|
|
24
|
-
__export(openBrowser_exports, {
|
|
25
|
-
openBrowser: () => openBrowser
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(openBrowser_exports);
|
|
28
|
-
var import_chalk = __toESM(require("../compiled/chalk"));
|
|
29
|
-
var import_child_process = require("child_process");
|
|
30
|
-
var import_cross_spawn = __toESM(require("../compiled/cross-spawn"));
|
|
31
|
-
var import_open = __toESM(require("../compiled/open"));
|
|
32
|
-
function executeNodeScript(scriptPath, url) {
|
|
33
|
-
const extraArgs = process.argv.slice(2);
|
|
34
|
-
const child = (0, import_cross_spawn.default)(process.execPath, [scriptPath, ...extraArgs, url], {
|
|
35
|
-
stdio: "inherit"
|
|
36
|
-
});
|
|
37
|
-
child.on("close", (code) => {
|
|
38
|
-
if (code !== 0) {
|
|
39
|
-
console.log();
|
|
40
|
-
console.log(import_chalk.default.red("The script specified as BROWSER environment variable failed."));
|
|
41
|
-
console.log(import_chalk.default.cyan(scriptPath) + " exited with code " + code + ".");
|
|
42
|
-
console.log();
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
function startBrowserProcess(browser, url) {
|
|
49
|
-
const shouldTryOpenChromiumWithAppleScript = process.platform === "darwin" && (typeof browser !== "string" || browser === "google chrome");
|
|
50
|
-
if (shouldTryOpenChromiumWithAppleScript) {
|
|
51
|
-
const supportedChromiumBrowsers = [
|
|
52
|
-
"Google Chrome Canary",
|
|
53
|
-
"Google Chrome Dev",
|
|
54
|
-
"Google Chrome Beta",
|
|
55
|
-
"Google Chrome",
|
|
56
|
-
"Microsoft Edge",
|
|
57
|
-
"Brave Browser",
|
|
58
|
-
"Vivaldi",
|
|
59
|
-
"Chromium"
|
|
60
|
-
];
|
|
61
|
-
for (let chromiumBrowser of supportedChromiumBrowsers) {
|
|
62
|
-
try {
|
|
63
|
-
(0, import_child_process.execSync)('ps cax | grep "' + chromiumBrowser + '"');
|
|
64
|
-
(0, import_child_process.execSync)('osascript openChrome.applescript "' + encodeURI(url) + '" "' + chromiumBrowser + '"', {
|
|
65
|
-
cwd: __dirname,
|
|
66
|
-
stdio: "ignore"
|
|
67
|
-
});
|
|
68
|
-
return true;
|
|
69
|
-
} catch (err) {
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (process.platform === "darwin" && browser === "open") {
|
|
74
|
-
browser = void 0;
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
(0, import_open.default)(url, { app: browser, wait: false, url: true }).catch(() => {
|
|
78
|
-
});
|
|
79
|
-
return true;
|
|
80
|
-
} catch (err) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function openBrowser(url) {
|
|
85
|
-
const browser = process.env.BROWSER || "";
|
|
86
|
-
if (browser.toLowerCase().endsWith(".js")) {
|
|
87
|
-
return executeNodeScript(browser, url);
|
|
88
|
-
} else if (browser.toLowerCase() !== "none") {
|
|
89
|
-
return startBrowserProcess(browser, url);
|
|
90
|
-
}
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
-
0 && (module.exports = {
|
|
95
|
-
openBrowser
|
|
96
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
(*
|
|
2
|
-
Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
-
|
|
4
|
-
This source code is licensed under the MIT license found in the
|
|
5
|
-
LICENSE file at
|
|
6
|
-
https://github.com/facebookincubator/create-react-app/blob/master/LICENSE
|
|
7
|
-
*)
|
|
8
|
-
|
|
9
|
-
property targetTab: null
|
|
10
|
-
property targetTabIndex: -1
|
|
11
|
-
property targetWindow: null
|
|
12
|
-
property theProgram: "Google Chrome"
|
|
13
|
-
|
|
14
|
-
on run argv
|
|
15
|
-
set theURL to item 1 of argv
|
|
16
|
-
|
|
17
|
-
-- Allow requested program to be optional,
|
|
18
|
-
-- default to Google Chrome
|
|
19
|
-
if (count of argv) > 1 then
|
|
20
|
-
set theProgram to item 2 of argv
|
|
21
|
-
end if
|
|
22
|
-
|
|
23
|
-
using terms from application "Google Chrome"
|
|
24
|
-
tell application theProgram
|
|
25
|
-
|
|
26
|
-
if (count every window) = 0 then
|
|
27
|
-
make new window
|
|
28
|
-
end if
|
|
29
|
-
|
|
30
|
-
-- 1: Looking for tab running debugger
|
|
31
|
-
-- then, Reload debugging tab if found
|
|
32
|
-
-- then return
|
|
33
|
-
set found to my lookupTabWithUrl(theURL)
|
|
34
|
-
if found then
|
|
35
|
-
set targetWindow's active tab index to targetTabIndex
|
|
36
|
-
tell targetTab to reload
|
|
37
|
-
tell targetWindow to activate
|
|
38
|
-
set index of targetWindow to 1
|
|
39
|
-
return
|
|
40
|
-
end if
|
|
41
|
-
|
|
42
|
-
-- 2: Looking for Empty tab
|
|
43
|
-
-- In case debugging tab was not found
|
|
44
|
-
-- We try to find an empty tab instead
|
|
45
|
-
set found to my lookupTabWithUrl("chrome://newtab/")
|
|
46
|
-
if found then
|
|
47
|
-
set targetWindow's active tab index to targetTabIndex
|
|
48
|
-
set URL of targetTab to theURL
|
|
49
|
-
tell targetWindow to activate
|
|
50
|
-
return
|
|
51
|
-
end if
|
|
52
|
-
|
|
53
|
-
-- 3: Create new tab
|
|
54
|
-
-- both debugging and empty tab were not found
|
|
55
|
-
-- make a new tab with url
|
|
56
|
-
tell window 1
|
|
57
|
-
activate
|
|
58
|
-
make new tab with properties {URL:theURL}
|
|
59
|
-
end tell
|
|
60
|
-
end tell
|
|
61
|
-
end using terms from
|
|
62
|
-
end run
|
|
63
|
-
|
|
64
|
-
-- Function:
|
|
65
|
-
-- Lookup tab with given url
|
|
66
|
-
-- if found, store tab, index, and window in properties
|
|
67
|
-
-- (properties were declared on top of file)
|
|
68
|
-
on lookupTabWithUrl(lookupUrl)
|
|
69
|
-
using terms from application "Google Chrome"
|
|
70
|
-
tell application theProgram
|
|
71
|
-
-- Find a tab with the given url
|
|
72
|
-
set found to false
|
|
73
|
-
set theTabIndex to -1
|
|
74
|
-
repeat with theWindow in every window
|
|
75
|
-
set theTabIndex to 0
|
|
76
|
-
repeat with theTab in every tab of theWindow
|
|
77
|
-
set theTabIndex to theTabIndex + 1
|
|
78
|
-
if (theTab's URL as string) contains lookupUrl then
|
|
79
|
-
-- assign tab, tab index, and window to properties
|
|
80
|
-
set targetTab to theTab
|
|
81
|
-
set targetTabIndex to theTabIndex
|
|
82
|
-
set targetWindow to theWindow
|
|
83
|
-
set found to true
|
|
84
|
-
exit repeat
|
|
85
|
-
end if
|
|
86
|
-
end repeat
|
|
87
|
-
|
|
88
|
-
if found then
|
|
89
|
-
exit repeat
|
|
90
|
-
end if
|
|
91
|
-
end repeat
|
|
92
|
-
end tell
|
|
93
|
-
end using terms from
|
|
94
|
-
return found
|
|
95
|
-
end lookupTabWithUrl
|