@jsenv/core 39.2.16 → 39.2.18

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/js/ribbon.js CHANGED
@@ -35,8 +35,7 @@ const injectRibbon = ({ text }) => {
35
35
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
36
36
  text-align: center;
37
37
  user-select: none;
38
- }
39
- `;
38
+ }`;
40
39
  const html = /* html */ `<div id="jsenv_ribbon_container">
41
40
  <style>${css}</style>
42
41
  <div id="jsenv_ribbon">
@@ -64,7 +63,33 @@ const injectRibbon = ({ text }) => {
64
63
  const jsenvRibbonElement = new JsenvRibbonHtmlElement({
65
64
  hidden: toolbarStateInLocalStorage.ribbonDisplayed === false,
66
65
  });
67
- document.body.appendChild(jsenvRibbonElement);
66
+ appendIntoRespectingLineBreaksAndIndentation(
67
+ jsenvRibbonElement,
68
+ document.body,
69
+ );
70
+ };
71
+
72
+ const appendIntoRespectingLineBreaksAndIndentation = (
73
+ node,
74
+ parentNode,
75
+ { indent = 2 } = {},
76
+ ) => {
77
+ const indentMinusOne = " ".repeat(indent - 1);
78
+ const desiredIndent = " ".repeat(indent);
79
+ const previousSibling =
80
+ parentNode.childNodes[parentNode.childNodes.length - 1];
81
+ if (previousSibling && previousSibling.nodeName === "#text") {
82
+ if (previousSibling.nodeValue === `\n${indentMinusOne}`) {
83
+ previousSibling.nodeValue = `\n${desiredIndent}`;
84
+ }
85
+ if (previousSibling.nodeValue !== `\n${desiredIndent}`) {
86
+ previousSibling.nodeValue = `\n${desiredIndent}`;
87
+ }
88
+ } else {
89
+ parentNode.appendChild(document.createTextNode(`\n${desiredIndent}`));
90
+ }
91
+ parentNode.appendChild(node);
92
+ parentNode.appendChild(document.createTextNode(`\n${indentMinusOne}`));
68
93
  };
69
94
 
70
95
  export { injectRibbon };
@@ -3065,7 +3065,7 @@ const isWindowsPathnameSpecifier = (specifier) => {
3065
3065
  };
3066
3066
  const hasScheme$1 = (specifier) => /^[a-zA-Z]+:/.test(specifier);
3067
3067
 
3068
- const createFilter = (patterns, url) => {
3068
+ const createFilter = (patterns, url, map = (v) => v) => {
3069
3069
  const associations = resolveAssociations(
3070
3070
  {
3071
3071
  yes: patterns,
@@ -3074,7 +3074,7 @@ const createFilter = (patterns, url) => {
3074
3074
  );
3075
3075
  return (url) => {
3076
3076
  const meta = applyAssociations({ url, associations });
3077
- return Boolean(meta.yes);
3077
+ return Boolean(map(meta.yes));
3078
3078
  };
3079
3079
  };
3080
3080
 
@@ -18865,13 +18865,12 @@ Add "${key}" in that file.
18865
18865
  --- suggestion b ---
18866
18866
  Fix eventual typo in "${key}"?
18867
18867
  --- suggestion c ---
18868
- Mark injection as optional using INJECTIONS.optional()
18869
-
18868
+ Mark injection as optional using INJECTIONS.optional():
18870
18869
  import { INJECTIONS } from "@jsenv/core";
18871
18870
 
18872
18871
  return {
18873
18872
  "${key}": INJECTIONS.optional(${JSON.stringify(value)}),
18874
- }`,
18873
+ };`,
18875
18874
  );
18876
18875
  }
18877
18876
  continue;
@@ -23180,6 +23179,9 @@ ${e.trace?.message}`);
23180
23179
  }
23181
23180
  },
23182
23181
  handleWebsocket: (websocket, { request }) => {
23182
+ // if (true || logLevel === "debug") {
23183
+ // console.log("handleWebsocket", websocket, request.headers);
23184
+ // }
23183
23185
  if (request.headers["sec-websocket-protocol"] === "jsenv") {
23184
23186
  serverEventsDispatcher.addWebsocket(websocket, request);
23185
23187
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "39.2.16",
3
+ "version": "39.2.18",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -61,27 +61,28 @@
61
61
  "test:only_dev_server_errors": "node --conditions=development ./tests/dev_server/errors/dev_errors_snapshots.test.mjs",
62
62
  "workspace:test:ci": "CI=1 npm run workspace:test",
63
63
  "dev": "node --conditions=development ./scripts/dev/dev.mjs",
64
+ "playwright:install": "npx playwright install-deps && npx playwright install",
64
65
  "certificate:install": "node ./scripts/dev/install_certificate_authority.mjs",
65
66
  "prepublishOnly": "npm run build"
66
67
  },
67
68
  "dependencies": {
68
69
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
69
70
  "@jsenv/abort": "4.3.0",
70
- "@jsenv/ast": "6.2.13",
71
- "@jsenv/filesystem": "4.9.9",
71
+ "@jsenv/ast": "6.2.14",
72
+ "@jsenv/filesystem": "4.9.10",
72
73
  "@jsenv/humanize": "1.2.8",
73
74
  "@jsenv/importmap": "1.2.1",
74
75
  "@jsenv/integrity": "0.0.2",
75
- "@jsenv/js-module-fallback": "1.3.34",
76
+ "@jsenv/js-module-fallback": "1.3.35",
76
77
  "@jsenv/node-esm-resolution": "1.0.2",
77
- "@jsenv/plugin-bundling": "2.7.5",
78
+ "@jsenv/plugin-bundling": "2.7.6",
78
79
  "@jsenv/plugin-minification": "1.5.5",
79
- "@jsenv/plugin-supervisor": "1.5.14",
80
- "@jsenv/plugin-transpilation": "1.4.18",
80
+ "@jsenv/plugin-supervisor": "1.5.15",
81
+ "@jsenv/plugin-transpilation": "1.4.19",
81
82
  "@jsenv/runtime-compat": "1.3.1",
82
- "@jsenv/server": "15.2.18",
83
+ "@jsenv/server": "15.2.19",
83
84
  "@jsenv/sourcemap": "1.2.22",
84
- "@jsenv/url-meta": "8.5.0",
85
+ "@jsenv/url-meta": "8.5.1",
85
86
  "@jsenv/urls": "2.5.2",
86
87
  "@jsenv/utils": "2.1.2",
87
88
  "anchor-markdown-header": "0.7.0"
@@ -561,6 +561,9 @@ ${e.trace?.message}`);
561
561
  }
562
562
  },
563
563
  handleWebsocket: (websocket, { request }) => {
564
+ // if (true || logLevel === "debug") {
565
+ // console.log("handleWebsocket", websocket, request.headers);
566
+ // }
564
567
  if (request.headers["sec-websocket-protocol"] === "jsenv") {
565
568
  serverEventsDispatcher.addWebsocket(websocket, request);
566
569
  }
@@ -69,13 +69,12 @@ Add "${key}" in that file.
69
69
  --- suggestion b ---
70
70
  Fix eventual typo in "${key}"?
71
71
  --- suggestion c ---
72
- Mark injection as optional using INJECTIONS.optional()
73
-
72
+ Mark injection as optional using INJECTIONS.optional():
74
73
  import { INJECTIONS } from "@jsenv/core";
75
74
 
76
75
  return {
77
76
  "${key}": INJECTIONS.optional(${JSON.stringify(value)}),
78
- }`,
77
+ };`,
79
78
  );
80
79
  }
81
80
  continue;
@@ -35,8 +35,7 @@ export const injectRibbon = ({ text }) => {
35
35
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
36
36
  text-align: center;
37
37
  user-select: none;
38
- }
39
- `;
38
+ }`;
40
39
  const html = /* html */ `<div id="jsenv_ribbon_container">
41
40
  <style>${css}</style>
42
41
  <div id="jsenv_ribbon">
@@ -64,5 +63,31 @@ export const injectRibbon = ({ text }) => {
64
63
  const jsenvRibbonElement = new JsenvRibbonHtmlElement({
65
64
  hidden: toolbarStateInLocalStorage.ribbonDisplayed === false,
66
65
  });
67
- document.body.appendChild(jsenvRibbonElement);
66
+ appendIntoRespectingLineBreaksAndIndentation(
67
+ jsenvRibbonElement,
68
+ document.body,
69
+ );
70
+ };
71
+
72
+ const appendIntoRespectingLineBreaksAndIndentation = (
73
+ node,
74
+ parentNode,
75
+ { indent = 2 } = {},
76
+ ) => {
77
+ const indentMinusOne = " ".repeat(indent - 1);
78
+ const desiredIndent = " ".repeat(indent);
79
+ const previousSibling =
80
+ parentNode.childNodes[parentNode.childNodes.length - 1];
81
+ if (previousSibling && previousSibling.nodeName === "#text") {
82
+ if (previousSibling.nodeValue === `\n${indentMinusOne}`) {
83
+ previousSibling.nodeValue = `\n${desiredIndent}`;
84
+ }
85
+ if (previousSibling.nodeValue !== `\n${desiredIndent}`) {
86
+ previousSibling.nodeValue = `\n${desiredIndent}`;
87
+ }
88
+ } else {
89
+ parentNode.appendChild(document.createTextNode(`\n${desiredIndent}`));
90
+ }
91
+ parentNode.appendChild(node);
92
+ parentNode.appendChild(document.createTextNode(`\n${indentMinusOne}`));
68
93
  };