@jsenv/plugin-toolbar 1.5.12 → 1.5.15

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.
@@ -313,24 +313,26 @@ const removeForceHideElement = element => {
313
313
  element.removeAttribute("data-force-hide");
314
314
  };
315
315
  const setStyles = (element, styles) => {
316
- const elementStyle = element.style;
317
- const restoreStyles = Object.keys(styles).map(styleName => {
318
- let restore;
319
- if (styleName in elementStyle) {
320
- const currentStyle = elementStyle[styleName];
321
- restore = () => {
322
- elementStyle[styleName] = currentStyle;
323
- };
324
- } else {
325
- restore = () => {
326
- delete elementStyle[styleName];
327
- };
328
- }
329
- elementStyle[styleName] = styles[styleName];
330
- return restore;
331
- });
316
+ const restoreCallbackSet = new Set();
317
+ for (const key of Object.keys(styles)) {
318
+ const inlineValue = element.style[key];
319
+ restoreCallbackSet.add(() => {
320
+ if (inlineValue === "") {
321
+ element.style.removeProperty(key);
322
+ } else {
323
+ element.style[key] = inlineValue;
324
+ }
325
+ });
326
+ }
327
+ for (const key of Object.keys(styles)) {
328
+ const value = styles[key];
329
+ element.style[key] = value;
330
+ }
332
331
  return () => {
333
- restoreStyles.forEach(restore => restore());
332
+ for (const restoreCallback of restoreCallbackSet) {
333
+ restoreCallback();
334
+ }
335
+ restoreCallbackSet.clear();
334
336
  };
335
337
  };
336
338
  const activateToolbarSection = element => {
@@ -185,8 +185,8 @@ const appendIntoRespectingLineBreaksAndIndentation = (node, parentNode, {
185
185
  parentNode.appendChild(document.createTextNode("\n".concat(indentMinusOne)));
186
186
  };
187
187
  const createToolbarTriggerNode = () => {
188
- const css = /* css */"\n #jsenv_toolbar_trigger {\n display: block;\n overflow: hidden;\n position: fixed;\n z-index: 1000;\n bottom: -32px;\n right: 20px;\n height: 40px;\n width: 40px;\n padding: 0;\n margin: 0;\n border-radius: 5px 5px 0 0;\n border: 1px solid rgba(0, 0, 0, 0.33);\n border-bottom: none;\n box-shadow: 0px 0px 6px 2px rgba(0, 0, 0, 0.46);\n background: transparent;\n text-align: center;\n transition: 600ms;\n }\n\n #jsenv_toolbar_trigger:hover {\n cursor: pointer;\n }\n\n #jsenv_toolbar_trigger[data-expanded] {\n bottom: 0;\n }\n\n #jsenv_toolbar_trigger_icon {\n width: 35px;\n height: 35px;\n opacity: 0;\n transition: 600ms;\n }\n\n #jsenv_toolbar_trigger[data-expanded] #jsenv_toolbar_trigger_icon {\n opacity: 1;\n }";
189
- const html = /* html */" <div id=\"jsenv_toolbar_trigger\" style=\"display:none\">\n <style>".concat(css, "</style>\n <svg id=\"jsenv_toolbar_trigger_icon\">\n <use xlink:href=\"").concat(jsenvLogoSvgUrl, "#jsenv_logo\"></use>\n </svg>\n </div>");
188
+ const css = /* css */"\n #jsenv_toolbar_trigger {\n display: block;\n overflow: hidden;\n position: fixed;\n z-index: 1000;\n bottom: -32px;\n right: 20px;\n height: 40px;\n width: 40px;\n padding: 0;\n margin: 0;\n border-radius: 5px 5px 0 0;\n border: 1px solid rgba(0, 0, 0, 0.33);\n border-bottom: none;\n box-shadow: 0px 0px 6px 2px rgba(0, 0, 0, 0.46);\n background: transparent;\n text-align: center;\n transition: 600ms;\n }\n\n #jsenv_toolbar_trigger:hover {\n cursor: pointer;\n }\n\n #jsenv_toolbar_trigger[data-expanded] {\n bottom: 0;\n }\n\n #jsenv_toolbar_trigger_icon {\n width: 35px;\n height: 35px;\n opacity: 0;\n transition: 600ms;\n }\n\n #jsenv_toolbar_trigger[data-expanded] #jsenv_toolbar_trigger_icon {\n opacity: 1;\n }\n ";
189
+ const html = /* html */" <div\n id=\"jsenv_toolbar_trigger\"\n style=\"display:none\"\n >\n <style>\n ".concat(css, "\n </style>\n <svg id=\"jsenv_toolbar_trigger_icon\">\n <use xlink:href=\"").concat(jsenvLogoSvgUrl, "#jsenv_logo\"></use>\n </svg>\n </div>");
190
190
  class JsenvToolbarTriggerHtmlElement extends HTMLElement {
191
191
  constructor() {
192
192
  super();
@@ -150,6 +150,15 @@ function o(i) {
150
150
  }
151
151
  }
152
152
  let n, s;
153
+ function h(i) {
154
+ const t = n;
155
+ n = void 0;
156
+ try {
157
+ return i();
158
+ } finally {
159
+ n = t;
160
+ }
161
+ }
153
162
  let r = 0,
154
163
  f = 0,
155
164
  e = 0;
@@ -185,21 +194,27 @@ function c(i) {
185
194
  return t;
186
195
  }
187
196
  }
188
- function u(i) {
197
+ function u(i, t) {
189
198
  this.v = i;
190
199
  this.i = 0;
191
200
  this.n = void 0;
192
201
  this.t = void 0;
202
+ this.W = null == t ? void 0 : t.watched;
203
+ this.Z = null == t ? void 0 : t.unwatched;
193
204
  }
194
205
  u.prototype.brand = i;
195
206
  u.prototype.h = function () {
196
207
  return true;
197
208
  };
198
209
  u.prototype.S = function (i) {
199
- if (this.t !== i && void 0 === i.e) {
200
- i.x = this.t;
201
- if (void 0 !== this.t) this.t.e = i;
210
+ const t = this.t;
211
+ if (t !== i && void 0 === i.e) {
212
+ i.x = t;
202
213
  this.t = i;
214
+ if (void 0 !== t) t.e = i;else h(() => {
215
+ var i;
216
+ null == (i = this.W) || i.call(this);
217
+ });
203
218
  }
204
219
  };
205
220
  u.prototype.U = function (i) {
@@ -214,7 +229,13 @@ u.prototype.U = function (i) {
214
229
  o.e = t;
215
230
  i.x = void 0;
216
231
  }
217
- if (i === this.t) this.t = o;
232
+ if (i === this.t) {
233
+ this.t = o;
234
+ if (void 0 === o) h(() => {
235
+ var i;
236
+ null == (i = this.Z) || i.call(this);
237
+ });
238
+ }
218
239
  }
219
240
  };
220
241
  u.prototype.subscribe = function (i) {
@@ -268,8 +289,8 @@ Object.defineProperty(u.prototype, "value", {
268
289
  }
269
290
  }
270
291
  });
271
- function d$1(i) {
272
- return new u(i);
292
+ function d$1(i, t) {
293
+ return new u(i, t);
273
294
  }
274
295
  function v$1(i) {
275
296
  for (let t = i.s; void 0 !== t; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return true;
@@ -303,14 +324,17 @@ function y(i) {
303
324
  }
304
325
  i.s = t;
305
326
  }
306
- function a$1(i) {
327
+ function a$1(i, t) {
307
328
  u.call(this, void 0);
308
329
  this.x = i;
309
330
  this.s = void 0;
310
331
  this.g = e - 1;
311
332
  this.f = 4;
333
+ this.W = null == t ? void 0 : t.watched;
334
+ this.Z = null == t ? void 0 : t.unwatched;
312
335
  }
313
- (a$1.prototype = new u()).h = function () {
336
+ a$1.prototype = new u();
337
+ a$1.prototype.h = function () {
314
338
  this.f &= -3;
315
339
  if (1 & this.f) return false;
316
340
  if (32 == (36 & this.f)) return true;
@@ -374,8 +398,8 @@ Object.defineProperty(a$1.prototype, "value", {
374
398
  return this.v;
375
399
  }
376
400
  });
377
- function w$1(i) {
378
- return new a$1(i);
401
+ function w$1(i, t) {
402
+ return new a$1(i, t);
379
403
  }
380
404
  function _$1(i) {
381
405
  const o = i.u;
@@ -451,6 +475,9 @@ b$1.prototype.d = function () {
451
475
  this.f |= 8;
452
476
  if (!(1 & this.f)) g$1(this);
453
477
  };
478
+ b$1.prototype.dispose = function () {
479
+ this.d();
480
+ };
454
481
  function E(i) {
455
482
  const t = new b$1(i);
456
483
  try {
package/package.json CHANGED
@@ -1,15 +1,12 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-toolbar",
3
- "version": "1.5.12",
4
- "license": "MIT",
3
+ "version": "1.5.15",
5
4
  "repository": {
6
5
  "type": "git",
7
6
  "url": "https://github.com/jsenv/core",
8
7
  "directory": "packages/related/plugin-toolbar"
9
8
  },
10
- "publishConfig": {
11
- "access": "public"
12
- },
9
+ "license": "MIT",
13
10
  "type": "module",
14
11
  "exports": {
15
12
  ".": {
@@ -26,19 +23,22 @@
26
23
  "/src/"
27
24
  ],
28
25
  "scripts": {
29
- "eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
30
26
  "build": "node ./scripts/build.mjs",
27
+ "eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
31
28
  "prepublishOnly": "npm run build"
32
29
  },
33
30
  "dependencies": {
34
- "@jsenv/ast": "6.7.3"
31
+ "@jsenv/ast": "6.7.7"
35
32
  },
36
33
  "devDependencies": {
37
- "@preact/signals": "2.0.4",
38
34
  "@jsenv/core": "../../",
39
- "@jsenv/utils": "../../tooling/utils",
40
35
  "@jsenv/filesystem": "../../tooling/filesystem",
41
36
  "@jsenv/plugin-toolbar": "./",
37
+ "@jsenv/utils": "../../tooling/utils",
38
+ "@preact/signals": "2.0.4",
42
39
  "playwright": "1.52.0"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
43
  }
44
44
  }
@@ -243,13 +243,19 @@ const createToolbarTriggerNode = () => {
243
243
 
244
244
  #jsenv_toolbar_trigger[data-expanded] #jsenv_toolbar_trigger_icon {
245
245
  opacity: 1;
246
- }`;
247
- const html = /* html */ ` <div id="jsenv_toolbar_trigger" style="display:none">
248
- <style>${css}</style>
249
- <svg id="jsenv_toolbar_trigger_icon">
250
- <use xlink:href="${jsenvLogoSvgUrl}#jsenv_logo"></use>
251
- </svg>
252
- </div>`;
246
+ }
247
+ `;
248
+ const html = /* html */ ` <div
249
+ id="jsenv_toolbar_trigger"
250
+ style="display:none"
251
+ >
252
+ <style>
253
+ ${css}
254
+ </style>
255
+ <svg id="jsenv_toolbar_trigger_icon">
256
+ <use xlink:href="${jsenvLogoSvgUrl}#jsenv_logo"></use>
257
+ </svg>
258
+ </div>`;
253
259
 
254
260
  class JsenvToolbarTriggerHtmlElement extends HTMLElement {
255
261
  constructor() {
@@ -12,26 +12,27 @@ export const removeForceHideElement = (element) => {
12
12
  };
13
13
 
14
14
  export const setStyles = (element, styles) => {
15
- const elementStyle = element.style;
16
- const restoreStyles = Object.keys(styles).map((styleName) => {
17
- let restore;
18
- if (styleName in elementStyle) {
19
- const currentStyle = elementStyle[styleName];
20
- restore = () => {
21
- elementStyle[styleName] = currentStyle;
22
- };
23
- } else {
24
- restore = () => {
25
- delete elementStyle[styleName];
26
- };
27
- }
28
-
29
- elementStyle[styleName] = styles[styleName];
30
-
31
- return restore;
32
- });
15
+ const restoreCallbackSet = new Set();
16
+
17
+ for (const key of Object.keys(styles)) {
18
+ const inlineValue = element.style[key];
19
+ restoreCallbackSet.add(() => {
20
+ if (inlineValue === "") {
21
+ element.style.removeProperty(key);
22
+ } else {
23
+ element.style[key] = inlineValue;
24
+ }
25
+ });
26
+ }
27
+ for (const key of Object.keys(styles)) {
28
+ const value = styles[key];
29
+ element.style[key] = value;
30
+ }
33
31
  return () => {
34
- restoreStyles.forEach((restore) => restore());
32
+ for (const restoreCallback of restoreCallbackSet) {
33
+ restoreCallback();
34
+ }
35
+ restoreCallbackSet.clear();
35
36
  };
36
37
  };
37
38