@rg-dev/stdlib 1.0.57 → 1.0.58

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/lib/index.d.cts CHANGED
@@ -4,5 +4,6 @@ import './common-env'
4
4
  import './node-download'
5
5
  import './trpc-helpers'
6
6
  import './axios-helpers'
7
+ import './vite-helpers'
7
8
 
8
9
  export declare const VERSION:string
package/lib/index.d.ts CHANGED
@@ -4,5 +4,6 @@ import './common-env'
4
4
  import './node-download'
5
5
  import './trpc-helpers'
6
6
  import './axios-helpers'
7
+ import './vite-helpers'
7
8
 
8
9
  export declare const VERSION:string
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/vite-helpers.ts
21
+ var vite_helpers_exports = {};
22
+ __export(vite_helpers_exports, {
23
+ VERSION: () => VERSION,
24
+ createViteMiddleware: () => createViteMiddleware
25
+ });
26
+ module.exports = __toCommonJS(vite_helpers_exports);
27
+
28
+ // src/index.ts
29
+ var VERSION = "1";
30
+
31
+ // src/common-env.ts
32
+ function isNonEmptyString(str) {
33
+ return typeof str == "string" && str.trim().length > 0;
34
+ }
35
+
36
+ // src/vite-helpers.ts
37
+ async function createViteMiddleware(rootPath, editHtmlFn) {
38
+ if (!isNonEmptyString(rootPath)) {
39
+ throw new Error("invalid rootPath");
40
+ }
41
+ console.log(`starting vite middleware in ${rootPath}`);
42
+ const vite = await require(Function(`return 'vite'`)()).createServer(
43
+ {
44
+ root: rootPath,
45
+ logLevel: "info",
46
+ server: {
47
+ middlewareMode: true,
48
+ watch: {
49
+ usePolling: true,
50
+ interval: 300
51
+ }
52
+ },
53
+ plugins: [
54
+ {
55
+ name: "html-base-url",
56
+ transformIndexHtml(html) {
57
+ return (editHtmlFn == null ? void 0 : editHtmlFn(html)) || html;
58
+ }
59
+ }
60
+ ]
61
+ }
62
+ );
63
+ return vite.middlewares;
64
+ }
@@ -0,0 +1,6 @@
1
+ import { Handler } from 'express';
2
+ export { VERSION } from './index.cjs';
3
+
4
+ declare function createViteMiddleware(rootPath: string, editHtmlFn?: (html: string) => string): Promise<Handler>;
5
+
6
+ export { createViteMiddleware };
@@ -0,0 +1,6 @@
1
+ import { Handler } from 'express';
2
+ export { VERSION } from './index.js';
3
+
4
+ declare function createViteMiddleware(rootPath: string, editHtmlFn?: (html: string) => string): Promise<Handler>;
5
+
6
+ export { createViteMiddleware };
@@ -0,0 +1,48 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/index.ts
9
+ var VERSION = "1";
10
+
11
+ // src/common-env.ts
12
+ function isNonEmptyString(str) {
13
+ return typeof str == "string" && str.trim().length > 0;
14
+ }
15
+
16
+ // src/vite-helpers.ts
17
+ async function createViteMiddleware(rootPath, editHtmlFn) {
18
+ if (!isNonEmptyString(rootPath)) {
19
+ throw new Error("invalid rootPath");
20
+ }
21
+ console.log(`starting vite middleware in ${rootPath}`);
22
+ const vite = await __require(Function(`return 'vite'`)()).createServer(
23
+ {
24
+ root: rootPath,
25
+ logLevel: "info",
26
+ server: {
27
+ middlewareMode: true,
28
+ watch: {
29
+ usePolling: true,
30
+ interval: 300
31
+ }
32
+ },
33
+ plugins: [
34
+ {
35
+ name: "html-base-url",
36
+ transformIndexHtml(html) {
37
+ return (editHtmlFn == null ? void 0 : editHtmlFn(html)) || html;
38
+ }
39
+ }
40
+ ]
41
+ }
42
+ );
43
+ return vite.middlewares;
44
+ }
45
+ export {
46
+ VERSION,
47
+ createViteMiddleware
48
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rg-dev/stdlib",
3
- "version": "1.0.57",
3
+ "version": "1.0.58",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -31,6 +31,9 @@
31
31
  ],
32
32
  "lib/axios-helpers": [
33
33
  "lib/axios-helpers.d.ts"
34
+ ],
35
+ "lib/vite-helpers": [
36
+ "lib/vite-helpers.d.ts"
34
37
  ]
35
38
  }
36
39
  },
@@ -70,6 +73,11 @@
70
73
  "import": "./lib/node-download.js",
71
74
  "require": "./lib/node-download.cjs",
72
75
  "types": "./lib/node-download.d.ts"
76
+ },
77
+ "./lib/vite-helpers": {
78
+ "import": "./lib/vite-helpers.js",
79
+ "require": "./lib/vite-helpers.cjs",
80
+ "types": "./lib/vite-helpers.d.ts"
73
81
  }
74
82
  },
75
83
  "dependencies": {