vite-plugin-spire.officejs-test 1.0.7 → 1.0.8

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.

Potentially problematic release.


This version of vite-plugin-spire.officejs-test might be problematic. Click here for more details.

package/README.md CHANGED
@@ -38,7 +38,7 @@ export default defineConfig({
38
38
 
39
39
 
40
40
  # 参数
41
- | 属性 | 说明 | 类型 | 默认 |
42
- | -------- | ----------- | --------------- | ------------------------------ |
43
- | port | 服务端口 | `number` | 3001 |
44
- | name | 服务名称 | `string` | `'vite-plugin-spire.officejs'` |
41
+ | 属性 | 说明 | 类型 | 默认 |
42
+ | ---- | -------- | -------- | ------------------------------ |
43
+ | port | 服务端口 | `number` | 8000 |
44
+ | name | 服务名称 | `string` | `'vite-plugin-spire.officejs'` |
package/lib/index.mjs CHANGED
@@ -2,61 +2,61 @@ import { fileURLToPath as n } from "node:url";
2
2
  import { dirname as a } from "node:path";
3
3
  import c from "path";
4
4
  import f from "./utils/initserver.mjs";
5
- import o from "./utils/bundle.mjs";
5
+ import t from "./utils/bundle.mjs";
6
6
  a(n(import.meta.url));
7
7
  function v(s = {}) {
8
8
  const i = [
9
9
  {
10
- package: "spire.officejs-document-test",
10
+ package: "spire.officejs-web-word-test",
11
11
  path: "/spireword",
12
12
  route: "/service/spireword",
13
13
  name: "spireword",
14
14
  build: "/service/spireword"
15
15
  },
16
16
  {
17
- package: "spire.officejs-spreadsheet-test",
17
+ package: "spire.officejs-web-excel-test",
18
18
  path: "/spireexcel",
19
19
  route: "/service/spireexcel",
20
20
  name: "spireexcel",
21
21
  build: "/service/spireexcel"
22
22
  },
23
23
  {
24
- package: "spire.officejs-presentation-test",
24
+ package: "spire.officejs-web-powerpoint-test",
25
25
  path: "/spirepowerpoint",
26
26
  route: "/service/spirepowerpoint",
27
27
  name: "spirepowerpoint",
28
28
  build: "/service/spirepowerpoint"
29
29
  },
30
30
  {
31
- package: "spire.officejs-pdf-test",
31
+ package: "spire.officejs-web-pdf-test",
32
32
  path: "/spireword",
33
33
  route: "/service/spireword",
34
34
  name: "pdf",
35
35
  build: "/service/spireword"
36
36
  },
37
37
  {
38
- package: "spire.officejs-common-test",
38
+ package: "spire.officejs-web-common-test",
39
39
  path: "/lib",
40
40
  route: "/service/spirecommon",
41
41
  name: "spirecommon",
42
42
  build: "/service/spirecommon"
43
43
  },
44
44
  {
45
- package: "spire.officejs-editors-test",
45
+ package: "spire.officejs-web-editors-test",
46
46
  path: "/lib",
47
47
  route: "/editors",
48
48
  name: "editors",
49
49
  build: "/editors"
50
50
  },
51
51
  {
52
- package: "spire.officejs-externs-test",
52
+ package: "spire.officejs-web-externs-test",
53
53
  path: "/lib",
54
54
  route: "/externs",
55
55
  name: "externs",
56
56
  build: "/externs"
57
57
  },
58
58
  {
59
- package: "spire.officejs-fonts-test",
59
+ package: "spire.officejs-web-fontsweb-test",
60
60
  path: "/lib",
61
61
  route: "/fontsweb",
62
62
  name: "fontsweb",
@@ -64,23 +64,23 @@ function v(s = {}) {
64
64
  }
65
65
  ], {
66
66
  port: p = 8e3,
67
- name: t = "vite-plugin-spire-officejs"
67
+ name: o = "vite-plugin-spire.officejs"
68
68
  } = s;
69
69
  let r = "";
70
70
  return {
71
- name: t,
71
+ name: o,
72
72
  configResolved(e) {
73
73
  r = e.root, c.resolve(r, e.build.outDir);
74
74
  },
75
75
  // 开发环境
76
76
  // 创建一个子进程来提供officeJS的静态资源
77
77
  configureServer(e) {
78
- f(e, i, p, t);
78
+ f(e, i, p, o);
79
79
  },
80
80
  // 生产环境
81
81
  // 将officeJS的静态资源拷贝到输出目录中
82
- async writeBundle(e, m) {
83
- console.log("bundle", o), await o(e, r, i);
82
+ async writeBundle(e, l) {
83
+ console.log("bundle", t), await t(e, r, i);
84
84
  }
85
85
  };
86
86
  }
@@ -1,16 +1,16 @@
1
- import { createServer as P } from "node:http";
2
- import { fileURLToPath as j } from "node:url";
3
- import { dirname as x, resolve as y, join as k } from "node:path";
1
+ import { createServer as j } from "node:http";
2
+ import { fileURLToPath as x } from "node:url";
3
+ import { dirname as y, resolve as P, join as k } from "node:path";
4
4
  import { access as S } from "node:fs/promises";
5
5
  import { statSync as C, createReadStream as H } from "node:fs";
6
- const A = (f, l, i, g) => {
6
+ const A = (f, i, c, g) => {
7
7
  var p;
8
- let n;
9
- n = P(async (o, t) => {
10
- var h;
11
- const c = new URL(o.url, `http://${o.headers.host}`).pathname;
8
+ let r;
9
+ r = j(async (o, t) => {
10
+ var m;
11
+ const l = new URL(o.url, `http://${o.headers.host}`).pathname;
12
12
  let a = {};
13
- if (c.includes("Spire.Pdf.Base") ? a = l.find((e) => e.name == "pdf") : a = l.find((e) => c.startsWith(e.route)), !a) {
13
+ if (l.includes("Spire.Pdf.Base") ? a = i.find((e) => e.name == "pdf") : a = i.find((e) => l.startsWith(e.route)), !a) {
14
14
  t.writeHead(404, { "Content-Type": "text/plain" }), t.end("Resource not found");
15
15
  return;
16
16
  }
@@ -19,14 +19,14 @@ const A = (f, l, i, g) => {
19
19
  let e;
20
20
  try {
21
21
  const s = await import.meta.resolve(`${a.package}/package.json`);
22
- e = x(s);
22
+ e = y(s);
23
23
  } catch {
24
- e = y(process.cwd(), "node_modules", a.package);
24
+ e = P(process.cwd(), "node_modules", a.package);
25
25
  }
26
26
  e.startsWith("file://") || (e.startsWith("/") || e.match(/^[A-Za-z]:/)) && (e = "file://" + (e.startsWith("/") ? "" : "/") + e);
27
- const u = j(e), w = c.replace(a.route, "") || "/index.html", r = k(u, a.path, w);
28
- console.log("fullPath", r), await S(r);
29
- const v = C(r), m = (h = r.split(".").pop()) == null ? void 0 : h.toLowerCase(), $ = {
27
+ const u = x(e), w = l.replace(a.route, "") || "/index.html", n = k(u, a.path, w);
28
+ await S(n);
29
+ const v = C(n), h = (m = n.split(".").pop()) == null ? void 0 : m.toLowerCase(), $ = {
30
30
  html: "text/html",
31
31
  js: "application/javascript",
32
32
  css: "text/css",
@@ -37,22 +37,22 @@ const A = (f, l, i, g) => {
37
37
  wasm: "application/wasm"
38
38
  };
39
39
  t.writeHead(200, {
40
- "Content-Type": m && $[m] || "application/octet-stream",
40
+ "Content-Type": h && $[h] || "application/octet-stream",
41
41
  "Content-Length": v.size
42
42
  });
43
- const d = H(r);
43
+ const d = H(n);
44
44
  d.pipe(t), d.on("error", (s) => {
45
- console.error(`Stream error for ${r}:`, s), t.writeHead(500), t.end("Internal server error");
45
+ console.error(`Stream error for ${n}:`, s), t.writeHead(500), t.end("Internal server error");
46
46
  });
47
47
  } catch (e) {
48
48
  e.code === "ENOENT" ? (t.writeHead(404, { "Content-Type": "text/plain" }), t.end(`File not found: ${o.url}`)) : (console.error(`Error serving ${o.url}:`, e), t.writeHead(500), t.end("Internal server error"));
49
49
  }
50
- }), n.listen(i, () => {
51
- console.log(`📦 [${g}] NPM包静态资源服务已启动:`), console.log(` - 服务地址: http://localhost:${i}`), l.forEach((o) => {
52
- console.log(` - 映射 ${o.package}${o.path} -> http://localhost:${i}${o.route}`);
50
+ }), r.listen(c, () => {
51
+ console.log(`📦 [${g}] spire.officejs静态资源服务已启动:`), console.log(` - 服务地址: http://localhost:${c}`), i.forEach((o) => {
52
+ console.log(` - 映射 ${o.package}${o.path} -> http://localhost:${c}${o.route}`);
53
53
  });
54
54
  }), (p = f.httpServer) == null || p.on("close", () => {
55
- n == null || n.close();
55
+ r == null || r.close();
56
56
  });
57
57
  };
58
58
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-spire.officejs-test",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "",
5
5
  "main": "./lib/index.mjs",
6
6
  "files": [