@jitar/plugin-vite 0.5.1 → 0.6.0
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 +1 -1
- package/dist/index.js +5 -4
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { PluginOption } from 'vite';
|
|
2
|
-
export default function viteJitar(sourcePath: string, jitarPath: string, jitarUrl: string, segments?: string[]): PluginOption;
|
|
2
|
+
export default function viteJitar(sourcePath: string, jitarPath: string, jitarUrl: string, segments?: string[], middlewares?: string[]): PluginOption;
|
package/dist/index.js
CHANGED
|
@@ -26,9 +26,10 @@ function createServerConfig(jitarUrl) {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function createBootstrapCode(segments) {
|
|
29
|
+
function createBootstrapCode(segments, middlewares) {
|
|
30
30
|
const segmentString = segments.map(segment => `'${segment}'`).join(', ');
|
|
31
|
-
|
|
31
|
+
const middlewareString = middlewares.map(middleware => `'${middleware}'`).join(', ');
|
|
32
|
+
return `<script type="module">const jitar = await import("/jitar/client.js"); await jitar.startClient(document.location.origin, [${segmentString}], [${middlewareString}]);</script>`;
|
|
32
33
|
}
|
|
33
34
|
async function createImportCode(code, id, jitarFullPath, jitarPath) {
|
|
34
35
|
const relativeId = id
|
|
@@ -53,7 +54,7 @@ async function createImportCode(code, id, jitarFullPath, jitarPath) {
|
|
|
53
54
|
+ importCode
|
|
54
55
|
+ exportCode;
|
|
55
56
|
}
|
|
56
|
-
export default function viteJitar(sourcePath, jitarPath, jitarUrl, segments = []) {
|
|
57
|
+
export default function viteJitar(sourcePath, jitarPath, jitarUrl, segments = [], middlewares = []) {
|
|
57
58
|
sourcePath = formatPath(sourcePath);
|
|
58
59
|
jitarPath = formatPath(jitarPath);
|
|
59
60
|
let jitarFullPath = undefined;
|
|
@@ -79,7 +80,7 @@ export default function viteJitar(sourcePath, jitarPath, jitarUrl, segments = []
|
|
|
79
80
|
return createImportCode(code, id, jitarFullPath, jitarPath);
|
|
80
81
|
},
|
|
81
82
|
transformIndexHtml(html) {
|
|
82
|
-
return html.replace('<head>', `<head>${createBootstrapCode(segments)}`);
|
|
83
|
+
return html.replace('<head>', `<head>${createBootstrapCode(segments, middlewares)}`);
|
|
83
84
|
}
|
|
84
85
|
};
|
|
85
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jitar/plugin-vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Vite plugin for Jitar.",
|
|
5
5
|
"author": "Masking Technology <info@masking.tech> (https://jitar.dev)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@jitar/reflection": "^0.
|
|
30
|
+
"@jitar/reflection": "^0.6.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"vite": ">=4.0.0 || >=5.0.0"
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"vite-plugin",
|
|
51
51
|
"jitar"
|
|
52
52
|
],
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "4aca9604744308e313f73e44623dc04989b2f570"
|
|
54
54
|
}
|