@jsenv/plugin-toolbar 0.1.12 → 0.1.14

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.
@@ -1,4 +1,6 @@
1
- <!DOCTYPE html><html><head>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
2
4
  <title>Jsenv toolbar</title>
3
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
4
6
  <meta charset="utf-8">
@@ -311,6 +313,5 @@
311
313
  </svg>
312
314
  </div>
313
315
  <script type="module" src="../js/toolbar_core.js" data-jsenv-force-inline="" no-html-supervisor=""></script>
314
-
315
-
316
- </body></html>
316
+ </body>
317
+ </html>
@@ -1,4 +1,4 @@
1
- import { parseHtmlString, injectScriptNodeAsEarlyAsPossible, createHtmlNode, stringifyHtmlAst } from "@jsenv/ast";
1
+ import { parseHtmlString, injectHtmlNodeAsEarlyAsPossible, createHtmlNode, stringifyHtmlAst } from "@jsenv/ast";
2
2
 
3
3
  const jsenvPluginToolbar = ({
4
4
  logLevel = "warn",
@@ -30,20 +30,19 @@ const jsenvPluginToolbar = ({
30
30
  expectedType: "html",
31
31
  specifier: toolbarHtmlClientFileUrl
32
32
  });
33
- injectScriptNodeAsEarlyAsPossible(htmlAst, createHtmlNode({
33
+ injectHtmlNodeAsEarlyAsPossible(htmlAst, createHtmlNode({
34
34
  tagName: "script",
35
35
  type: "module",
36
- textContent: `
37
- import { injectToolbar } from ${toolbarInjectorReference.generatedSpecifier}
38
- injectToolbar(${JSON.stringify({
39
- toolbarUrl: toolbarClientFileReference.generatedSpecifier,
36
+ textContent: generateCodeToInjectToolbar({
37
+ toolbarInjectorReference,
38
+ toolbarClientFileReference,
40
39
  logLevel,
41
40
  theme,
42
41
  opened,
43
42
  autoreload,
44
43
  animationsEnabled,
45
44
  notificationsEnabled
46
- }, null, " ")})`
45
+ })
47
46
  }), "jsenv:toolbar");
48
47
  const htmlModified = stringifyHtmlAst(htmlAst);
49
48
  return {
@@ -53,5 +52,29 @@ injectToolbar(${JSON.stringify({
53
52
  }
54
53
  };
55
54
  };
55
+ const generateCodeToInjectToolbar = ({
56
+ toolbarInjectorReference,
57
+ toolbarClientFileReference,
58
+ logLevel,
59
+ theme,
60
+ opened,
61
+ autoreload,
62
+ animationsEnabled,
63
+ notificationsEnabled
64
+ }) => {
65
+ const from = toolbarInjectorReference.generatedSpecifier;
66
+ const paramsSource = JSON.stringify({
67
+ toolbarUrl: toolbarClientFileReference.generatedSpecifier,
68
+ logLevel,
69
+ theme,
70
+ opened,
71
+ autoreload,
72
+ animationsEnabled,
73
+ notificationsEnabled
74
+ }, null, " ");
75
+ return `import { injectToolbar } from ${from}
76
+
77
+ injectToolbar(${paramsSource});`;
78
+ };
56
79
 
57
80
  export { jsenvPluginToolbar };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-toolbar",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/jsenv/jsenv-core",
7
+ "url": "https://github.com/jsenv/core",
8
8
  "directory": "packages/jsenv-plugin-toolbar"
9
9
  },
10
10
  "publishConfig": {
@@ -26,7 +26,7 @@
26
26
  "/src/"
27
27
  ],
28
28
  "dependencies": {
29
- "@jsenv/ast": "3.0.5",
29
+ "@jsenv/ast": "3.0.7",
30
30
  "@preact/signals": "1.1.3"
31
31
  },
32
32
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  parseHtmlString,
3
3
  stringifyHtmlAst,
4
- injectScriptNodeAsEarlyAsPossible,
4
+ injectHtmlNodeAsEarlyAsPossible,
5
5
  createHtmlNode,
6
6
  } from "@jsenv/ast"
7
7
 
@@ -42,26 +42,21 @@ export const jsenvPluginToolbar = ({
42
42
  expectedType: "html",
43
43
  specifier: toolbarHtmlClientFileUrl,
44
44
  })
45
- injectScriptNodeAsEarlyAsPossible(
45
+ injectHtmlNodeAsEarlyAsPossible(
46
46
  htmlAst,
47
47
  createHtmlNode({
48
48
  tagName: "script",
49
49
  type: "module",
50
- textContent: `
51
- import { injectToolbar } from ${toolbarInjectorReference.generatedSpecifier}
52
- injectToolbar(${JSON.stringify(
53
- {
54
- toolbarUrl: toolbarClientFileReference.generatedSpecifier,
55
- logLevel,
56
- theme,
57
- opened,
58
- autoreload,
59
- animationsEnabled,
60
- notificationsEnabled,
61
- },
62
- null,
63
- " ",
64
- )})`,
50
+ textContent: generateCodeToInjectToolbar({
51
+ toolbarInjectorReference,
52
+ toolbarClientFileReference,
53
+ logLevel,
54
+ theme,
55
+ opened,
56
+ autoreload,
57
+ animationsEnabled,
58
+ notificationsEnabled,
59
+ }),
65
60
  }),
66
61
  "jsenv:toolbar",
67
62
  )
@@ -73,3 +68,33 @@ injectToolbar(${JSON.stringify(
73
68
  },
74
69
  }
75
70
  }
71
+
72
+ const generateCodeToInjectToolbar = ({
73
+ toolbarInjectorReference,
74
+ toolbarClientFileReference,
75
+ logLevel,
76
+ theme,
77
+ opened,
78
+ autoreload,
79
+ animationsEnabled,
80
+ notificationsEnabled,
81
+ }) => {
82
+ const from = toolbarInjectorReference.generatedSpecifier
83
+ const paramsSource = JSON.stringify(
84
+ {
85
+ toolbarUrl: toolbarClientFileReference.generatedSpecifier,
86
+ logLevel,
87
+ theme,
88
+ opened,
89
+ autoreload,
90
+ animationsEnabled,
91
+ notificationsEnabled,
92
+ },
93
+ null,
94
+ " ",
95
+ )
96
+
97
+ return `import { injectToolbar } from ${from}
98
+
99
+ injectToolbar(${paramsSource});`
100
+ }