@mind-elixir/open-desktop 0.0.1
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/index.d.ts +13 -0
- package/dist/index.js +47 -0
- package/dist/index.umd.cjs +1 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MindElixirData } from 'mind-elixir';
|
|
2
|
+
/**
|
|
3
|
+
* 启动 Mind Elixir 并发送思维导图数据
|
|
4
|
+
* @param mindmapData 思维导图数据
|
|
5
|
+
* @param source 数据来源URL
|
|
6
|
+
* @param options 配置选项
|
|
7
|
+
*/
|
|
8
|
+
export declare const launchMindElixir: (mindmapData: MindElixirData, source?: string, options?: {
|
|
9
|
+
appUrl?: string;
|
|
10
|
+
serviceUrl?: string;
|
|
11
|
+
pingUrl?: string;
|
|
12
|
+
timeout?: number;
|
|
13
|
+
}) => Promise<void>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function a(t) {
|
|
2
|
+
return new Promise((n, o) => {
|
|
3
|
+
const i = Date.now(), e = document.createElement("iframe");
|
|
4
|
+
e.style.display = "none", e.src = t, document.body.appendChild(e), setTimeout(() => {
|
|
5
|
+
Date.now() - i < 1500 ? (window.open("https://desktop.mind-elixir.com/", "_blank"), o("未安装 Mind Elixir Desktop")) : n(!0);
|
|
6
|
+
}, 2e3);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
const c = (t, n = 1e4) => new Promise((o, i) => {
|
|
10
|
+
const e = Date.now(), r = async () => {
|
|
11
|
+
try {
|
|
12
|
+
if ((await fetch(t)).ok) {
|
|
13
|
+
o();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
if (Date.now() - e > n) {
|
|
19
|
+
i(new Error("服务启动超时"));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
setTimeout(r, 100);
|
|
23
|
+
};
|
|
24
|
+
r();
|
|
25
|
+
}), l = async (t, n, o = {}) => {
|
|
26
|
+
const {
|
|
27
|
+
appUrl: i = "mind-elixir://open",
|
|
28
|
+
serviceUrl: e = "http://127.0.0.1:6595/create-mindmap",
|
|
29
|
+
pingUrl: r = "http://127.0.0.1:6595/ping",
|
|
30
|
+
timeout: s = 8e3
|
|
31
|
+
} = o;
|
|
32
|
+
if (await a(i), await c(r, s), !(await fetch(e, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: {
|
|
35
|
+
"Content-Type": "application/json"
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
mindmap: JSON.stringify(t),
|
|
39
|
+
source: n || window.location.href.split("?")[0]
|
|
40
|
+
})
|
|
41
|
+
})).ok)
|
|
42
|
+
throw new Error("发送思维导图数据失败");
|
|
43
|
+
console.log("思维导图已成功发送到 Mind Elixir");
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
l as launchMindElixir
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(n,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(n=typeof globalThis<"u"?globalThis:n||self,t(n.OpenDesktop={}))})(this,function(n){"use strict";function t(i){return new Promise((o,r)=>{const s=Date.now(),e=document.createElement("iframe");e.style.display="none",e.src=i,document.body.appendChild(e),setTimeout(()=>{Date.now()-s<1500?(window.open("https://desktop.mind-elixir.com/","_blank"),r("未安装 Mind Elixir Desktop")):o(!0)},2e3)})}const p=(i,o=1e4)=>new Promise((r,s)=>{const e=Date.now(),c=async()=>{try{if((await fetch(i)).ok){r();return}}catch{}if(Date.now()-e>o){s(new Error("服务启动超时"));return}setTimeout(c,100)};c()}),d=async(i,o,r={})=>{const{appUrl:s="mind-elixir://open",serviceUrl:e="http://127.0.0.1:6595/create-mindmap",pingUrl:c="http://127.0.0.1:6595/ping",timeout:a=8e3}=r;if(await t(s),await p(c,a),!(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mindmap:JSON.stringify(i),source:o||window.location.href.split("?")[0]})})).ok)throw new Error("发送思维导图数据失败");console.log("思维导图已成功发送到 Mind Elixir")};n.launchMindElixir=d,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mind-elixir/open-desktop",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Import XMind files to MindElixir format",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.umd.cjs",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "~5.8.3",
|
|
25
|
+
"vite": "^6.3.5",
|
|
26
|
+
"vite-plugin-dts": "^4.5.4",
|
|
27
|
+
"mind-elixir": "^5.0.0",
|
|
28
|
+
"@mind-elixir/typescript-config": "1.0.0"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"xmind",
|
|
32
|
+
"mindmap",
|
|
33
|
+
"mind-elixir",
|
|
34
|
+
"import"
|
|
35
|
+
],
|
|
36
|
+
"author": "Mind Elixir",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc && vite build",
|
|
40
|
+
"dev": "vite build --watch",
|
|
41
|
+
"clean": "rm -rf dist",
|
|
42
|
+
"check-types": "tsc --noEmit"
|
|
43
|
+
}
|
|
44
|
+
}
|