Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zhi-device

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zhi-device - npm Package Compare versions

Comparing version 0.9.0 to 1.0.0

83

./dist/index.js
var P = Object.defineProperty;
var g = (n, e, t) => e in n ? P(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var s = (n, e, t) => (g(n, typeof e != "symbol" ? e + "" : e, t), t);
const p = class {
var g = (i, e, t) => e in i ? P(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
var s = (i, e, t) => (g(i, typeof e != "symbol" ? e + "" : e, t), t);
const u = class {
/**

@@ -9,22 +9,22 @@ * 检测是否运行在Chrome插件中

static isInChromeExtension() {
return p.isInBrowser ? window.location.href.indexOf("chrome-extension://") > -1 : !1;
return u.isInBrowser ? window.location.href.indexOf("chrome-extension://") > -1 : !1;
}
};
let i = p;
let n = u;
/**
* 是否在Node环境
*/
s(i, "isNode", typeof process < "u" && process.versions != null && process.versions.node != null), /**
s(n, "isNode", typeof process < "u" && process.versions != null && process.versions.node != null), /**
* 是否在浏览器环境
*/
s(i, "isInBrowser", typeof window < "u" && typeof document < "u"), /**
s(n, "isInBrowser", typeof window < "u" && typeof document < "u"), /**
* 浏览器路径分隔符
*/
s(i, "BrowserSeparator", "/"), /**
s(n, "BrowserSeparator", "/"), /**
* 是否是Electron环境
*/
s(i, "isElectron", () => typeof process < "u" && process.versions != null && process.versions.electron != null), /**
s(n, "isElectron", () => typeof process < "u" && process.versions != null && process.versions.electron != null), /**
* 是否有Node环境,目前包括 Electron 和 Node
*/
s(i, "hasNodeEnv", () => p.isElectron() || p.isNode), /**
s(n, "hasNodeEnv", () => u.isElectron() || u.isNode), /**
* 获取url参数

@@ -34,4 +34,4 @@ *

*/
s(i, "getQueryString", (e) => {
if (!p.isInBrowser)
s(n, "getQueryString", (e) => {
if (!u.isInBrowser)
return "";

@@ -62,3 +62,3 @@ const a = window.location.search.substring(1).split("&");

*/
s(i, "replaceUrlParam", (e, t, a) => {
s(n, "replaceUrlParam", (e, t, a) => {
a == null && (a = "");

@@ -79,5 +79,5 @@ const r = new RegExp("\\b(" + t + "=).*?(&|#|$)");

*/
s(i, "setUrlParameter", (e, t, a) => {
s(n, "setUrlParameter", (e, t, a) => {
if (e.includes(t))
return p.replaceUrlParam(e, t, a);
return u.replaceUrlParam(e, t, a);
const r = e.split("#");

@@ -93,7 +93,7 @@ let c = r[0];

*/
s(i, "reloadTabPage", (e, t = 200) => {
s(n, "reloadTabPage", (e, t = 200) => {
setTimeout(function() {
if (p.isInBrowser) {
if (u.isInBrowser) {
const a = window.location.href;
window.location.href = p.setUrlParameter(a, "tab", e);
window.location.href = u.setUrlParameter(a, "tab", e);
}

@@ -104,5 +104,5 @@ }, t);

*/
s(i, "reloadPage", () => {
s(n, "reloadPage", () => {
setTimeout(function() {
p.isInBrowser && window.location.reload();
u.isInBrowser && window.location.reload();
}, 200);

@@ -115,8 +115,8 @@ }), /**

*/
s(i, "reloadPageWithMessageCallback", (e, t) => {
s(n, "reloadPageWithMessageCallback", (e, t) => {
t && t(e), setTimeout(function() {
p.isInBrowser && window.location.reload();
u.isInBrowser && window.location.reload();
}, 200);
});
var o = /* @__PURE__ */ ((n) => (n.BasePathType_Appearance = "Appearance", n.BasePathType_Data = "Data", n.BasePathType_Themes = "Themes", n.BasePathType_ZhiTheme = "ZhiTheme", n.BasePathType_None = "None", n))(o || {});
var o = /* @__PURE__ */ ((i) => (i.BasePathType_Appearance = "Appearance", i.BasePathType_Data = "Data", i.BasePathType_Themes = "Themes", i.BasePathType_ZhiTheme = "ZhiTheme", i.BasePathType_None = "None", i))(o || {});
const h = class {

@@ -127,3 +127,3 @@ /**

static isInSiyuanBrowser() {
return i.isInBrowser ? typeof window.siyuan < "u" && typeof window.Lute < "u" : !1;
return n.isInBrowser ? typeof window.siyuan < "u" && typeof window.Lute < "u" : !1;
}

@@ -250,3 +250,3 @@ /**

static joinPath(...e) {
if (i.hasNodeEnv()) {
if (n.hasNodeEnv()) {
const t = this.requireLib("path");

@@ -259,3 +259,3 @@ if (t)

static browserJoinPath(...e) {
return e.join(i.BrowserSeparator);
return e.join(n.BrowserSeparator);
}

@@ -312,3 +312,3 @@ /**

static siyuanThemePath() {
if (i.hasNodeEnv())
if (n.hasNodeEnv())
return this.joinPath(this.siyuanAppearancePath(), "themes");

@@ -343,10 +343,9 @@ {

};
let u = h;
let p = h;
/**
* 思源笔记iframe挂件环境
*/
s(u, "isInSiyuanWidget", () => i.isInBrowser ? window.frameElement != null && window.frameElement.parentElement != null && window.frameElement.parentElement.parentElement != null && window.frameElement.parentElement.parentElement.getAttribute("data-node-id") !== "" : !1), /**
s(p, "isInSiyuanWidget", () => n.isInBrowser ? window.frameElement != null && window.frameElement.parentElement != null && window.frameElement.parentElement.parentElement != null && window.frameElement.parentElement.parentElement.getAttribute("data-node-id") !== "" : !1), /**
* 思源笔记新窗口
*
* @deprecated window.terwer 判断方式已废弃,建议以后打开新窗口注入 window.siyuanNewWin ,这样语义会更容易理解
* @author terwer

@@ -356,3 +355,3 @@ * @version 0.1.0

*/
s(u, "isInSiyuanNewWin", () => !i.isInBrowser || !i.isElectron() ? !1 : typeof window.terwer < "u" || typeof window.siyuanNewWin < "u"), // =========================
s(p, "isInSiyuanNewWin", () => typeof window < "u" && window.process && window.process.type === "renderer"), // =========================
// require start

@@ -367,4 +366,4 @@ // =========================

*/
s(u, "requireLib", (e, t = !0, a = o.BasePathType_None) => {
if (!i.hasNodeEnv())
s(p, "requireLib", (e, t = !0, a = o.BasePathType_None) => {
if (!n.hasNodeEnv())
throw new Error("require ony works on node env");

@@ -399,3 +398,3 @@ let r = e;

*/
s(u, "requireAppearanceLib", (e) => h.requireLib(e, !1, o.BasePathType_Appearance)), /**
s(p, "requireAppearanceLib", (e) => h.requireLib(e, !1, o.BasePathType_Appearance)), /**
* 引入依赖,以 data 的基本路径为准

@@ -405,3 +404,3 @@ *

*/
s(u, "requireDataLib", (e) => h.requireLib(e, !1, o.BasePathType_Data)), /**
s(p, "requireDataLib", (e) => h.requireLib(e, !1, o.BasePathType_Data)), /**
* 引入依赖,以 theme 的基本路径为准

@@ -411,3 +410,3 @@ *

*/
s(u, "requireThemesLib", (e) => h.requireLib(e, !1, o.BasePathType_Themes)), /**
s(p, "requireThemesLib", (e) => h.requireLib(e, !1, o.BasePathType_Themes)), /**
* 引入依赖,以 ZhiTheme 的基本路径为准

@@ -417,4 +416,4 @@ *

*/
s(u, "requireZhiThemeLib", (e) => h.requireLib(e, !1, o.BasePathType_ZhiTheme));
var w = /* @__PURE__ */ ((n) => (n.DeviceType_Mobile_Device = "Mobile", n.DeviceType_Siyuan_Widget = "Siyuan_Widget", n.DeviceType_Siyuan_NewWin = "Siyuan_NewWindow", n.DeviceType_Siyuan_MainWin = "Siyuan_MainWindow", n.DeviceType_Siyuan_Browser = "Siyuan_Browser", n.DeviceType_Chrome_Extension = "Chrome_Extension", n.DeviceType_Chrome_Browser = "Chrome_Browser", n.DeviceType_Node = "Node", n))(w || {});
s(p, "requireZhiThemeLib", (e) => h.requireLib(e, !1, o.BasePathType_ZhiTheme));
var w = /* @__PURE__ */ ((i) => (i.DeviceType_Mobile_Device = "Mobile", i.DeviceType_Siyuan_Widget = "Siyuan_Widget", i.DeviceType_Siyuan_NewWin = "Siyuan_NewWindow", i.DeviceType_Siyuan_MainWin = "Siyuan_MainWindow", i.DeviceType_Siyuan_Browser = "Siyuan_Browser", i.DeviceType_Chrome_Extension = "Chrome_Extension", i.DeviceType_Chrome_Browser = "Chrome_Browser", i.DeviceType_Node = "Node", i))(w || {});
class v {

@@ -425,3 +424,3 @@ /**

static getDevice() {
return this.detectMobileDevice() ? w.DeviceType_Mobile_Device : u.isInSiyuanWidget() ? w.DeviceType_Siyuan_Widget : u.isInSiyuanNewWin() ? w.DeviceType_Siyuan_NewWin : i.isElectron() ? w.DeviceType_Siyuan_MainWin : u.isInSiyuanBrowser() ? w.DeviceType_Siyuan_Browser : i.isInChromeExtension() ? w.DeviceType_Chrome_Extension : i.isNode ? w.DeviceType_Node : w.DeviceType_Chrome_Browser;
return this.detectMobileDevice() ? w.DeviceType_Mobile_Device : p.isInSiyuanWidget() ? w.DeviceType_Siyuan_Widget : p.isInSiyuanNewWin() ? w.DeviceType_Siyuan_NewWin : n.isElectron() ? w.DeviceType_Siyuan_MainWin : p.isInSiyuanBrowser() ? w.DeviceType_Siyuan_Browser : n.isInChromeExtension() ? w.DeviceType_Chrome_Extension : n.isNode ? w.DeviceType_Node : w.DeviceType_Chrome_Browser;
}

@@ -434,3 +433,3 @@ /**

let e = !1;
return i.isInBrowser && function(t) {
return n.isInBrowser && function(t) {
(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(

@@ -446,6 +445,6 @@ t

o as BasePathTypeEnum,
i as BrowserUtil,
n as BrowserUtil,
v as DeviceDetection,
w as DeviceTypeEnum,
u as SiyuanDevice
p as SiyuanDevice
};
var P = Object.defineProperty;
var g = (n, e, t) => e in n ? P(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var s = (n, e, t) => (g(n, typeof e != "symbol" ? e + "" : e, t), t);
const p = class {
var g = (i, e, t) => e in i ? P(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
var s = (i, e, t) => (g(i, typeof e != "symbol" ? e + "" : e, t), t);
const u = class {
/**

@@ -9,22 +9,22 @@ * 检测是否运行在Chrome插件中

static isInChromeExtension() {
return p.isInBrowser ? window.location.href.indexOf("chrome-extension://") > -1 : !1;
return u.isInBrowser ? window.location.href.indexOf("chrome-extension://") > -1 : !1;
}
};
let i = p;
let n = u;
/**
* 是否在Node环境
*/
s(i, "isNode", typeof process < "u" && process.versions != null && process.versions.node != null), /**
s(n, "isNode", typeof process < "u" && process.versions != null && process.versions.node != null), /**
* 是否在浏览器环境
*/
s(i, "isInBrowser", typeof window < "u" && typeof document < "u"), /**
s(n, "isInBrowser", typeof window < "u" && typeof document < "u"), /**
* 浏览器路径分隔符
*/
s(i, "BrowserSeparator", "/"), /**
s(n, "BrowserSeparator", "/"), /**
* 是否是Electron环境
*/
s(i, "isElectron", () => typeof process < "u" && process.versions != null && process.versions.electron != null), /**
s(n, "isElectron", () => typeof process < "u" && process.versions != null && process.versions.electron != null), /**
* 是否有Node环境,目前包括 Electron 和 Node
*/
s(i, "hasNodeEnv", () => p.isElectron() || p.isNode), /**
s(n, "hasNodeEnv", () => u.isElectron() || u.isNode), /**
* 获取url参数

@@ -34,4 +34,4 @@ *

*/
s(i, "getQueryString", (e) => {
if (!p.isInBrowser)
s(n, "getQueryString", (e) => {
if (!u.isInBrowser)
return "";

@@ -62,3 +62,3 @@ const a = window.location.search.substring(1).split("&");

*/
s(i, "replaceUrlParam", (e, t, a) => {
s(n, "replaceUrlParam", (e, t, a) => {
a == null && (a = "");

@@ -79,5 +79,5 @@ const r = new RegExp("\\b(" + t + "=).*?(&|#|$)");

*/
s(i, "setUrlParameter", (e, t, a) => {
s(n, "setUrlParameter", (e, t, a) => {
if (e.includes(t))
return p.replaceUrlParam(e, t, a);
return u.replaceUrlParam(e, t, a);
const r = e.split("#");

@@ -93,7 +93,7 @@ let c = r[0];

*/
s(i, "reloadTabPage", (e, t = 200) => {
s(n, "reloadTabPage", (e, t = 200) => {
setTimeout(function() {
if (p.isInBrowser) {
if (u.isInBrowser) {
const a = window.location.href;
window.location.href = p.setUrlParameter(a, "tab", e);
window.location.href = u.setUrlParameter(a, "tab", e);
}

@@ -104,5 +104,5 @@ }, t);

*/
s(i, "reloadPage", () => {
s(n, "reloadPage", () => {
setTimeout(function() {
p.isInBrowser && window.location.reload();
u.isInBrowser && window.location.reload();
}, 200);

@@ -115,8 +115,8 @@ }), /**

*/
s(i, "reloadPageWithMessageCallback", (e, t) => {
s(n, "reloadPageWithMessageCallback", (e, t) => {
t && t(e), setTimeout(function() {
p.isInBrowser && window.location.reload();
u.isInBrowser && window.location.reload();
}, 200);
});
var o = /* @__PURE__ */ ((n) => (n.BasePathType_Appearance = "Appearance", n.BasePathType_Data = "Data", n.BasePathType_Themes = "Themes", n.BasePathType_ZhiTheme = "ZhiTheme", n.BasePathType_None = "None", n))(o || {});
var o = /* @__PURE__ */ ((i) => (i.BasePathType_Appearance = "Appearance", i.BasePathType_Data = "Data", i.BasePathType_Themes = "Themes", i.BasePathType_ZhiTheme = "ZhiTheme", i.BasePathType_None = "None", i))(o || {});
const h = class {

@@ -127,3 +127,3 @@ /**

static isInSiyuanBrowser() {
return i.isInBrowser ? typeof window.siyuan < "u" && typeof window.Lute < "u" : !1;
return n.isInBrowser ? typeof window.siyuan < "u" && typeof window.Lute < "u" : !1;
}

@@ -250,3 +250,3 @@ /**

static joinPath(...e) {
if (i.hasNodeEnv()) {
if (n.hasNodeEnv()) {
const t = this.requireLib("path");

@@ -259,3 +259,3 @@ if (t)

static browserJoinPath(...e) {
return e.join(i.BrowserSeparator);
return e.join(n.BrowserSeparator);
}

@@ -312,3 +312,3 @@ /**

static siyuanThemePath() {
if (i.hasNodeEnv())
if (n.hasNodeEnv())
return this.joinPath(this.siyuanAppearancePath(), "themes");

@@ -343,10 +343,9 @@ {

};
let u = h;
let p = h;
/**
* 思源笔记iframe挂件环境
*/
s(u, "isInSiyuanWidget", () => i.isInBrowser ? window.frameElement != null && window.frameElement.parentElement != null && window.frameElement.parentElement.parentElement != null && window.frameElement.parentElement.parentElement.getAttribute("data-node-id") !== "" : !1), /**
s(p, "isInSiyuanWidget", () => n.isInBrowser ? window.frameElement != null && window.frameElement.parentElement != null && window.frameElement.parentElement.parentElement != null && window.frameElement.parentElement.parentElement.getAttribute("data-node-id") !== "" : !1), /**
* 思源笔记新窗口
*
* @deprecated window.terwer 判断方式已废弃,建议以后打开新窗口注入 window.siyuanNewWin ,这样语义会更容易理解
* @author terwer

@@ -356,3 +355,3 @@ * @version 0.1.0

*/
s(u, "isInSiyuanNewWin", () => !i.isInBrowser || !i.isElectron() ? !1 : typeof window.terwer < "u" || typeof window.siyuanNewWin < "u"), // =========================
s(p, "isInSiyuanNewWin", () => typeof window < "u" && window.process && window.process.type === "renderer"), // =========================
// require start

@@ -367,4 +366,4 @@ // =========================

*/
s(u, "requireLib", (e, t = !0, a = o.BasePathType_None) => {
if (!i.hasNodeEnv())
s(p, "requireLib", (e, t = !0, a = o.BasePathType_None) => {
if (!n.hasNodeEnv())
throw new Error("require ony works on node env");

@@ -399,3 +398,3 @@ let r = e;

*/
s(u, "requireAppearanceLib", (e) => h.requireLib(e, !1, o.BasePathType_Appearance)), /**
s(p, "requireAppearanceLib", (e) => h.requireLib(e, !1, o.BasePathType_Appearance)), /**
* 引入依赖,以 data 的基本路径为准

@@ -405,3 +404,3 @@ *

*/
s(u, "requireDataLib", (e) => h.requireLib(e, !1, o.BasePathType_Data)), /**
s(p, "requireDataLib", (e) => h.requireLib(e, !1, o.BasePathType_Data)), /**
* 引入依赖,以 theme 的基本路径为准

@@ -411,3 +410,3 @@ *

*/
s(u, "requireThemesLib", (e) => h.requireLib(e, !1, o.BasePathType_Themes)), /**
s(p, "requireThemesLib", (e) => h.requireLib(e, !1, o.BasePathType_Themes)), /**
* 引入依赖,以 ZhiTheme 的基本路径为准

@@ -417,4 +416,4 @@ *

*/
s(u, "requireZhiThemeLib", (e) => h.requireLib(e, !1, o.BasePathType_ZhiTheme));
var w = /* @__PURE__ */ ((n) => (n.DeviceType_Mobile_Device = "Mobile", n.DeviceType_Siyuan_Widget = "Siyuan_Widget", n.DeviceType_Siyuan_NewWin = "Siyuan_NewWindow", n.DeviceType_Siyuan_MainWin = "Siyuan_MainWindow", n.DeviceType_Siyuan_Browser = "Siyuan_Browser", n.DeviceType_Chrome_Extension = "Chrome_Extension", n.DeviceType_Chrome_Browser = "Chrome_Browser", n.DeviceType_Node = "Node", n))(w || {});
s(p, "requireZhiThemeLib", (e) => h.requireLib(e, !1, o.BasePathType_ZhiTheme));
var w = /* @__PURE__ */ ((i) => (i.DeviceType_Mobile_Device = "Mobile", i.DeviceType_Siyuan_Widget = "Siyuan_Widget", i.DeviceType_Siyuan_NewWin = "Siyuan_NewWindow", i.DeviceType_Siyuan_MainWin = "Siyuan_MainWindow", i.DeviceType_Siyuan_Browser = "Siyuan_Browser", i.DeviceType_Chrome_Extension = "Chrome_Extension", i.DeviceType_Chrome_Browser = "Chrome_Browser", i.DeviceType_Node = "Node", i))(w || {});
class v {

@@ -425,3 +424,3 @@ /**

static getDevice() {
return this.detectMobileDevice() ? w.DeviceType_Mobile_Device : u.isInSiyuanWidget() ? w.DeviceType_Siyuan_Widget : u.isInSiyuanNewWin() ? w.DeviceType_Siyuan_NewWin : i.isElectron() ? w.DeviceType_Siyuan_MainWin : u.isInSiyuanBrowser() ? w.DeviceType_Siyuan_Browser : i.isInChromeExtension() ? w.DeviceType_Chrome_Extension : i.isNode ? w.DeviceType_Node : w.DeviceType_Chrome_Browser;
return this.detectMobileDevice() ? w.DeviceType_Mobile_Device : p.isInSiyuanWidget() ? w.DeviceType_Siyuan_Widget : p.isInSiyuanNewWin() ? w.DeviceType_Siyuan_NewWin : n.isElectron() ? w.DeviceType_Siyuan_MainWin : p.isInSiyuanBrowser() ? w.DeviceType_Siyuan_Browser : n.isInChromeExtension() ? w.DeviceType_Chrome_Extension : n.isNode ? w.DeviceType_Node : w.DeviceType_Chrome_Browser;
}

@@ -434,3 +433,3 @@ /**

let e = !1;
return i.isInBrowser && function(t) {
return n.isInBrowser && function(t) {
(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(

@@ -446,6 +445,6 @@ t

o as BasePathTypeEnum,
i as BrowserUtil,
n as BrowserUtil,
v as DeviceDetection,
w as DeviceTypeEnum,
u as SiyuanDevice
p as SiyuanDevice
};

@@ -18,3 +18,2 @@ import BasePathTypeEnum from "./basePathTypeEnum";

*
* @deprecated window.terwer 判断方式已废弃,建议以后打开新窗口注入 window.siyuanNewWin ,这样语义会更容易理解
* @author terwer

@@ -24,3 +23,3 @@ * @version 0.1.0

*/
static isInSiyuanNewWin: () => boolean;
static isInSiyuanNewWin: () => any;
/**

@@ -27,0 +26,0 @@ * 检测是否运行在思源打开的浏览器中

{
"name": "zhi-device",
"version": "0.9.0",
"version": "1.0.0",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

{
"name": "zhi-device",
"version": "0.9.0",
"version": "1.0.0",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc