@jitar/plugin-vite 0.5.0 → 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/LICENCE ADDED
@@ -0,0 +1,23 @@
1
+
2
+ (The MIT License)
3
+
4
+ Copyright (c) 2023 Masking Technology B.V. <https://masking.tech>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
- return `<script type="module">const jitar = await import("/jitar/client.js"); await jitar.startClient(document.location.origin, [${segmentString}]);</script>`;
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.5.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,10 +27,15 @@
27
27
  "access": "public"
28
28
  },
29
29
  "dependencies": {
30
- "@jitar/reflection": "^0.5.0"
30
+ "@jitar/reflection": "^0.6.0"
31
31
  },
32
32
  "peerDependencies": {
33
- "vite": "^4.4.11"
33
+ "vite": ">=4.0.0 || >=5.0.0"
34
+ },
35
+ "peerDependenciesMeta": {
36
+ "vite": {
37
+ "optional": true
38
+ }
34
39
  },
35
40
  "repository": {
36
41
  "type": "git",
@@ -42,6 +47,8 @@
42
47
  "homepage": "https://jitar.dev",
43
48
  "keywords": [
44
49
  "vite",
50
+ "vite-plugin",
45
51
  "jitar"
46
- ]
52
+ ],
53
+ "gitHead": "4aca9604744308e313f73e44623dc04989b2f570"
47
54
  }