zhi-fetch-middleware
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -6,4 +6,4 @@ var C = Object.defineProperty; | ||
const a = e ?? "zhi", i = (n) => { | ||
const s = n.getFullYear(), c = String(n.getMonth() + 1).padStart(2, "0"), m = String(n.getDate()).padStart(2, "0"), T = String(n.getHours()).padStart(2, "0"), I = String(n.getMinutes()).padStart(2, "0"), R = String(n.getSeconds()).padStart(2, "0"); | ||
return `${s}-${c}-${m} ${T}:${I}:${R}`; | ||
const s = n.getFullYear(), c = String(n.getMonth() + 1).padStart(2, "0"), m = String(n.getDate()).padStart(2, "0"), T = String(n.getHours()).padStart(2, "0"), E = String(n.getMinutes()).padStart(2, "0"), R = String(n.getSeconds()).padStart(2, "0"); | ||
return `${s}-${c}-${m} ${T}:${E}:${R}`; | ||
}, o = (n, s, c) => { | ||
@@ -154,4 +154,4 @@ const m = i(/* @__PURE__ */ new Date()); | ||
}); | ||
var w = /* @__PURE__ */ ((t) => (t.BasePathType_Appearance = "Appearance", t.BasePathType_Data = "Data", t.BasePathType_Themes = "Themes", t.BasePathType_ZhiTheme = "ZhiTheme", t.BasePathType_None = "None", t))(w || {}); | ||
const g = class { | ||
var g = /* @__PURE__ */ ((t) => (t.BasePathType_Appearance = "Appearance", t.BasePathType_Data = "Data", t.BasePathType_Themes = "Themes", t.BasePathType_ZhiTheme = "ZhiTheme", t.BasePathType_None = "None", t))(g || {}); | ||
const w = class { | ||
/** | ||
@@ -185,12 +185,12 @@ * 检测是否运行在思源打开的浏览器中 | ||
switch (e) { | ||
case w.BasePathType_Appearance: | ||
case g.BasePathType_Appearance: | ||
r = this.browserJoinPath(this.siyuanAppearanceRelativePath(), t); | ||
break; | ||
case w.BasePathType_Data: | ||
case g.BasePathType_Data: | ||
r = this.browserJoinPath(this.siyuanDataRelativePath(), t); | ||
break; | ||
case w.BasePathType_Themes: | ||
case g.BasePathType_Themes: | ||
r = this.browserJoinPath(this.siyuanThemeRelativePath(), t); | ||
break; | ||
case w.BasePathType_ZhiTheme: | ||
case g.BasePathType_ZhiTheme: | ||
r = this.browserJoinPath(this.zhiThemeRelativePath(), t); | ||
@@ -273,3 +273,3 @@ break; | ||
static async importZhiThemeJs(t) { | ||
return await this.importJs(t, w.BasePathType_ZhiTheme); | ||
return await this.importJs(t, g.BasePathType_ZhiTheme); | ||
} | ||
@@ -375,4 +375,4 @@ // ========================= | ||
}; | ||
let b = g; | ||
u(b, "isInSiyuanWidget", () => h.isInBrowser ? window.frameElement != null && window.frameElement.parentElement != null && window.frameElement.parentElement.parentElement != null && window.frameElement.parentElement.parentElement.getAttribute("data-node-id") !== "" : !1), /** | ||
let b = w; | ||
u(b, "isInSiyuanWidget", () => h.isInBrowser ? typeof window.parent.process < "u" && window.parent.process.versions != null && window.parent.process.versions.electron != null : !1), /** | ||
* 思源笔记新窗口 | ||
@@ -394,3 +394,3 @@ * | ||
*/ | ||
u(b, "requireLib", (t, e = !0, r = w.BasePathType_None) => { | ||
u(b, "requireLib", (t, e = !0, r = g.BasePathType_None) => { | ||
if (!h.hasNodeEnv()) | ||
@@ -401,13 +401,13 @@ throw new Error("require ony works on node env"); | ||
switch (r) { | ||
case w.BasePathType_Appearance: | ||
a = g.joinPath(g.siyuanAppearancePath(), t); | ||
case g.BasePathType_Appearance: | ||
a = w.joinPath(w.siyuanAppearancePath(), t); | ||
break; | ||
case w.BasePathType_Data: | ||
a = g.joinPath(g.siyuanDataPath(), t); | ||
case g.BasePathType_Data: | ||
a = w.joinPath(w.siyuanDataPath(), t); | ||
break; | ||
case w.BasePathType_Themes: | ||
a = g.joinPath(g.siyuanAppearancePath(), "themes", t); | ||
case g.BasePathType_Themes: | ||
a = w.joinPath(w.siyuanAppearancePath(), "themes", t); | ||
break; | ||
case w.BasePathType_ZhiTheme: | ||
a = g.joinPath(g.siyuanAppearancePath(), "themes", "zhi", t); | ||
case g.BasePathType_ZhiTheme: | ||
a = w.joinPath(w.siyuanAppearancePath(), "themes", "zhi", t); | ||
break; | ||
@@ -417,3 +417,3 @@ default: | ||
} | ||
const i = g.siyuanWindow(); | ||
const i = w.siyuanWindow(); | ||
if (!i) | ||
@@ -428,3 +428,3 @@ return require(a); | ||
*/ | ||
u(b, "requireAppearanceLib", (t) => g.requireLib(t, !1, w.BasePathType_Appearance)), /** | ||
u(b, "requireAppearanceLib", (t) => w.requireLib(t, !1, g.BasePathType_Appearance)), /** | ||
* 引入依赖,以 data 的基本路径为准 | ||
@@ -434,3 +434,3 @@ * | ||
*/ | ||
u(b, "requireDataLib", (t) => g.requireLib(t, !1, w.BasePathType_Data)), /** | ||
u(b, "requireDataLib", (t) => w.requireLib(t, !1, g.BasePathType_Data)), /** | ||
* 引入依赖,以 theme 的基本路径为准 | ||
@@ -440,3 +440,3 @@ * | ||
*/ | ||
u(b, "requireThemesLib", (t) => g.requireLib(t, !1, w.BasePathType_Themes)), /** | ||
u(b, "requireThemesLib", (t) => w.requireLib(t, !1, g.BasePathType_Themes)), /** | ||
* 引入依赖,以 ZhiTheme 的基本路径为准 | ||
@@ -446,3 +446,3 @@ * | ||
*/ | ||
u(b, "requireZhiThemeLib", (t) => g.requireLib(t, !1, w.BasePathType_ZhiTheme)); | ||
u(b, "requireZhiThemeLib", (t) => w.requireLib(t, !1, g.BasePathType_ZhiTheme)); | ||
var d = /* @__PURE__ */ ((t) => (t.DeviceType_Mobile_Device = "Mobile", t.DeviceType_Siyuan_Widget = "Siyuan_Widget", t.DeviceType_Siyuan_NewWin = "Siyuan_NewWindow", t.DeviceType_Siyuan_MainWin = "Siyuan_MainWindow", t.DeviceType_Siyuan_Browser = "Siyuan_Browser", t.DeviceType_Chrome_Extension = "Chrome_Extension", t.DeviceType_Chrome_Browser = "Chrome_Browser", t.DeviceType_Node = "Node", t))(d || {}); | ||
@@ -471,4 +471,4 @@ class M { | ||
} | ||
var A = Object.defineProperty, z = (t, e, r) => e in t ? A(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, $ = (t, e, r) => (z(t, typeof e != "symbol" ? e + "" : e, r), r); | ||
class E { | ||
var z = Object.defineProperty, A = (t, e, r) => e in t ? z(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, $ = (t, e, r) => (A(t, typeof e != "symbol" ? e + "" : e, r), r); | ||
class I { | ||
/** | ||
@@ -553,4 +553,4 @@ * 格式化字符串 | ||
const a = e ?? "zhi", i = (n) => { | ||
const s = n.getFullYear(), c = String(n.getMonth() + 1).padStart(2, "0"), m = String(n.getDate()).padStart(2, "0"), T = String(n.getHours()).padStart(2, "0"), I = String(n.getMinutes()).padStart(2, "0"), R = String(n.getSeconds()).padStart(2, "0"); | ||
return `${s}-${c}-${m} ${T}:${I}:${R}`; | ||
const s = n.getFullYear(), c = String(n.getMonth() + 1).padStart(2, "0"), m = String(n.getDate()).padStart(2, "0"), T = String(n.getHours()).padStart(2, "0"), E = String(n.getMinutes()).padStart(2, "0"), R = String(n.getSeconds()).padStart(2, "0"); | ||
return `${s}-${c}-${m} ${T}:${E}:${R}`; | ||
}, o = (n, s, c) => { | ||
@@ -593,3 +593,3 @@ const m = i(/* @__PURE__ */ new Date()); | ||
let a; | ||
E.isEmptyString(e) && (a = r); | ||
I.isEmptyString(e) && (a = r); | ||
try { | ||
@@ -793,3 +793,3 @@ a = JSON.parse(e) || r; | ||
} | ||
$(S, "dateUtil", W), $(S, "strUtil", E), $(S, "htmlUtil", Z), $(S, "jsonUtil", k), $(S, "objectUtil", F); | ||
$(S, "dateUtil", W), $(S, "strUtil", I), $(S, "htmlUtil", Z), $(S, "jsonUtil", k), $(S, "objectUtil", F); | ||
const P = D("node-fetch", "zhi-fetch-middleware"), B = async (t, e, r) => { | ||
@@ -827,3 +827,3 @@ try { | ||
}, _ = D("middleware-fetch", "zhi-fetch-middleware", !1), O = async (t, e, r, a) => { | ||
if (E.isEmptyString(a)) | ||
if (I.isEmptyString(a)) | ||
throw new Error("middlewareUrl can not be empty"); | ||
@@ -908,3 +908,3 @@ const i = a + "/fetch"; | ||
let l = i.statusText; | ||
throw E.isEmptyString(l) ? l = "网络超时或者服务器错误,请稍后再试。" : l = "错误信息:" + l, new Error(l); | ||
throw I.isEmptyString(l) ? l = "网络超时或者服务器错误,请稍后再试。" : l = "错误信息:" + l, new Error(l); | ||
} else | ||
@@ -911,0 +911,0 @@ throw new Error("fetch请求错误"); |
@@ -6,4 +6,4 @@ var C = Object.defineProperty; | ||
const a = e ?? "zhi", i = (n) => { | ||
const s = n.getFullYear(), c = String(n.getMonth() + 1).padStart(2, "0"), m = String(n.getDate()).padStart(2, "0"), T = String(n.getHours()).padStart(2, "0"), I = String(n.getMinutes()).padStart(2, "0"), R = String(n.getSeconds()).padStart(2, "0"); | ||
return `${s}-${c}-${m} ${T}:${I}:${R}`; | ||
const s = n.getFullYear(), c = String(n.getMonth() + 1).padStart(2, "0"), m = String(n.getDate()).padStart(2, "0"), T = String(n.getHours()).padStart(2, "0"), E = String(n.getMinutes()).padStart(2, "0"), R = String(n.getSeconds()).padStart(2, "0"); | ||
return `${s}-${c}-${m} ${T}:${E}:${R}`; | ||
}, o = (n, s, c) => { | ||
@@ -154,4 +154,4 @@ const m = i(/* @__PURE__ */ new Date()); | ||
}); | ||
var w = /* @__PURE__ */ ((t) => (t.BasePathType_Appearance = "Appearance", t.BasePathType_Data = "Data", t.BasePathType_Themes = "Themes", t.BasePathType_ZhiTheme = "ZhiTheme", t.BasePathType_None = "None", t))(w || {}); | ||
const g = class { | ||
var g = /* @__PURE__ */ ((t) => (t.BasePathType_Appearance = "Appearance", t.BasePathType_Data = "Data", t.BasePathType_Themes = "Themes", t.BasePathType_ZhiTheme = "ZhiTheme", t.BasePathType_None = "None", t))(g || {}); | ||
const w = class { | ||
/** | ||
@@ -185,12 +185,12 @@ * 检测是否运行在思源打开的浏览器中 | ||
switch (e) { | ||
case w.BasePathType_Appearance: | ||
case g.BasePathType_Appearance: | ||
r = this.browserJoinPath(this.siyuanAppearanceRelativePath(), t); | ||
break; | ||
case w.BasePathType_Data: | ||
case g.BasePathType_Data: | ||
r = this.browserJoinPath(this.siyuanDataRelativePath(), t); | ||
break; | ||
case w.BasePathType_Themes: | ||
case g.BasePathType_Themes: | ||
r = this.browserJoinPath(this.siyuanThemeRelativePath(), t); | ||
break; | ||
case w.BasePathType_ZhiTheme: | ||
case g.BasePathType_ZhiTheme: | ||
r = this.browserJoinPath(this.zhiThemeRelativePath(), t); | ||
@@ -273,3 +273,3 @@ break; | ||
static async importZhiThemeJs(t) { | ||
return await this.importJs(t, w.BasePathType_ZhiTheme); | ||
return await this.importJs(t, g.BasePathType_ZhiTheme); | ||
} | ||
@@ -375,4 +375,4 @@ // ========================= | ||
}; | ||
let b = g; | ||
u(b, "isInSiyuanWidget", () => h.isInBrowser ? window.frameElement != null && window.frameElement.parentElement != null && window.frameElement.parentElement.parentElement != null && window.frameElement.parentElement.parentElement.getAttribute("data-node-id") !== "" : !1), /** | ||
let b = w; | ||
u(b, "isInSiyuanWidget", () => h.isInBrowser ? typeof window.parent.process < "u" && window.parent.process.versions != null && window.parent.process.versions.electron != null : !1), /** | ||
* 思源笔记新窗口 | ||
@@ -394,3 +394,3 @@ * | ||
*/ | ||
u(b, "requireLib", (t, e = !0, r = w.BasePathType_None) => { | ||
u(b, "requireLib", (t, e = !0, r = g.BasePathType_None) => { | ||
if (!h.hasNodeEnv()) | ||
@@ -401,13 +401,13 @@ throw new Error("require ony works on node env"); | ||
switch (r) { | ||
case w.BasePathType_Appearance: | ||
a = g.joinPath(g.siyuanAppearancePath(), t); | ||
case g.BasePathType_Appearance: | ||
a = w.joinPath(w.siyuanAppearancePath(), t); | ||
break; | ||
case w.BasePathType_Data: | ||
a = g.joinPath(g.siyuanDataPath(), t); | ||
case g.BasePathType_Data: | ||
a = w.joinPath(w.siyuanDataPath(), t); | ||
break; | ||
case w.BasePathType_Themes: | ||
a = g.joinPath(g.siyuanAppearancePath(), "themes", t); | ||
case g.BasePathType_Themes: | ||
a = w.joinPath(w.siyuanAppearancePath(), "themes", t); | ||
break; | ||
case w.BasePathType_ZhiTheme: | ||
a = g.joinPath(g.siyuanAppearancePath(), "themes", "zhi", t); | ||
case g.BasePathType_ZhiTheme: | ||
a = w.joinPath(w.siyuanAppearancePath(), "themes", "zhi", t); | ||
break; | ||
@@ -417,3 +417,3 @@ default: | ||
} | ||
const i = g.siyuanWindow(); | ||
const i = w.siyuanWindow(); | ||
if (!i) | ||
@@ -428,3 +428,3 @@ return require(a); | ||
*/ | ||
u(b, "requireAppearanceLib", (t) => g.requireLib(t, !1, w.BasePathType_Appearance)), /** | ||
u(b, "requireAppearanceLib", (t) => w.requireLib(t, !1, g.BasePathType_Appearance)), /** | ||
* 引入依赖,以 data 的基本路径为准 | ||
@@ -434,3 +434,3 @@ * | ||
*/ | ||
u(b, "requireDataLib", (t) => g.requireLib(t, !1, w.BasePathType_Data)), /** | ||
u(b, "requireDataLib", (t) => w.requireLib(t, !1, g.BasePathType_Data)), /** | ||
* 引入依赖,以 theme 的基本路径为准 | ||
@@ -440,3 +440,3 @@ * | ||
*/ | ||
u(b, "requireThemesLib", (t) => g.requireLib(t, !1, w.BasePathType_Themes)), /** | ||
u(b, "requireThemesLib", (t) => w.requireLib(t, !1, g.BasePathType_Themes)), /** | ||
* 引入依赖,以 ZhiTheme 的基本路径为准 | ||
@@ -446,3 +446,3 @@ * | ||
*/ | ||
u(b, "requireZhiThemeLib", (t) => g.requireLib(t, !1, w.BasePathType_ZhiTheme)); | ||
u(b, "requireZhiThemeLib", (t) => w.requireLib(t, !1, g.BasePathType_ZhiTheme)); | ||
var d = /* @__PURE__ */ ((t) => (t.DeviceType_Mobile_Device = "Mobile", t.DeviceType_Siyuan_Widget = "Siyuan_Widget", t.DeviceType_Siyuan_NewWin = "Siyuan_NewWindow", t.DeviceType_Siyuan_MainWin = "Siyuan_MainWindow", t.DeviceType_Siyuan_Browser = "Siyuan_Browser", t.DeviceType_Chrome_Extension = "Chrome_Extension", t.DeviceType_Chrome_Browser = "Chrome_Browser", t.DeviceType_Node = "Node", t))(d || {}); | ||
@@ -471,4 +471,4 @@ class M { | ||
} | ||
var A = Object.defineProperty, z = (t, e, r) => e in t ? A(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, $ = (t, e, r) => (z(t, typeof e != "symbol" ? e + "" : e, r), r); | ||
class E { | ||
var z = Object.defineProperty, A = (t, e, r) => e in t ? z(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, $ = (t, e, r) => (A(t, typeof e != "symbol" ? e + "" : e, r), r); | ||
class I { | ||
/** | ||
@@ -553,4 +553,4 @@ * 格式化字符串 | ||
const a = e ?? "zhi", i = (n) => { | ||
const s = n.getFullYear(), c = String(n.getMonth() + 1).padStart(2, "0"), m = String(n.getDate()).padStart(2, "0"), T = String(n.getHours()).padStart(2, "0"), I = String(n.getMinutes()).padStart(2, "0"), R = String(n.getSeconds()).padStart(2, "0"); | ||
return `${s}-${c}-${m} ${T}:${I}:${R}`; | ||
const s = n.getFullYear(), c = String(n.getMonth() + 1).padStart(2, "0"), m = String(n.getDate()).padStart(2, "0"), T = String(n.getHours()).padStart(2, "0"), E = String(n.getMinutes()).padStart(2, "0"), R = String(n.getSeconds()).padStart(2, "0"); | ||
return `${s}-${c}-${m} ${T}:${E}:${R}`; | ||
}, o = (n, s, c) => { | ||
@@ -593,3 +593,3 @@ const m = i(/* @__PURE__ */ new Date()); | ||
let a; | ||
E.isEmptyString(e) && (a = r); | ||
I.isEmptyString(e) && (a = r); | ||
try { | ||
@@ -793,3 +793,3 @@ a = JSON.parse(e) || r; | ||
} | ||
$(S, "dateUtil", W), $(S, "strUtil", E), $(S, "htmlUtil", Z), $(S, "jsonUtil", k), $(S, "objectUtil", F); | ||
$(S, "dateUtil", W), $(S, "strUtil", I), $(S, "htmlUtil", Z), $(S, "jsonUtil", k), $(S, "objectUtil", F); | ||
const P = D("node-fetch", "zhi-fetch-middleware"), B = async (t, e, r) => { | ||
@@ -827,3 +827,3 @@ try { | ||
}, _ = D("middleware-fetch", "zhi-fetch-middleware", !1), O = async (t, e, r, a) => { | ||
if (E.isEmptyString(a)) | ||
if (I.isEmptyString(a)) | ||
throw new Error("middlewareUrl can not be empty"); | ||
@@ -908,3 +908,3 @@ const i = a + "/fetch"; | ||
let l = i.statusText; | ||
throw E.isEmptyString(l) ? l = "网络超时或者服务器错误,请稍后再试。" : l = "错误信息:" + l, new Error(l); | ||
throw I.isEmptyString(l) ? l = "网络超时或者服务器错误,请稍后再试。" : l = "错误信息:" + l, new Error(l); | ||
} else | ||
@@ -911,0 +911,0 @@ throw new Error("fetch请求错误"); |
{ | ||
"name": "zhi-fetch-middleware", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "an intermediate tier prepared for fetch requests", |
{ | ||
"name": "zhi-fetch-middleware", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"type": "module", | ||
@@ -26,5 +26,5 @@ "description": "an intermediate tier prepared for fetch requests", | ||
"dependencies": { | ||
"zhi-device": "2.2.0", | ||
"zhi-common": "1.9.6", | ||
"zhi-lib-base": "0.2.6", | ||
"zhi-device": "2.1.0" | ||
"zhi-lib-base": "0.2.6" | ||
}, | ||
@@ -31,0 +31,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71055
+ Addedzhi-device@2.2.0(transitive)
- Removedzhi-device@2.1.0(transitive)
Updatedzhi-device@2.2.0