@maci0/dsh-alias 0.7.3 → 0.7.4

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/lib/client.js +17 -14
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -28,7 +28,7 @@ Requires DeepSeek Harness `>=0.2.2-rc.4 <0.3.0`. Restart DSH and refresh the bro
28
28
  > would win).
29
29
 
30
30
  ```sh
31
- dsh plugin --profile web add --save-exact @maci0/dsh-alias@0.7.3
31
+ dsh plugin --profile web add --save-exact @maci0/dsh-alias@0.7.4
32
32
  ```
33
33
 
34
34
  Pin an exact npm version. To upgrade, run the same command with the newer
package/lib/client.js CHANGED
@@ -7,10 +7,10 @@
7
7
  * every write goes through `ctx.configForms`, the same settings document
8
8
  * `/alias` writes on the host, so the two surfaces cannot disagree.
9
9
  *
10
- * Chrome is a stylesheet, not inline style objects: the module system claims
11
- * every `<style>` tag a factory appends while it materializes and removes it
12
- * when the package unloads, so the tags cost nothing to own. All classes are
13
- * `da-`-prefixed because that sheet lands in the page's own document.
10
+ * Chrome is a stylesheet, not inline style objects: `apply` installs one
11
+ * `<style data-plugin>` tag through `ctx.effect`, and the plugin's dispose
12
+ * removes it. All classes are `da-`-prefixed because that sheet lands in the
13
+ * page's own document.
14
14
  *
15
15
  * This file is plain JavaScript on purpose. The client module system serves a
16
16
  * package's `exports["./client"]` artifact as a lazy-CJS factory registered on
@@ -65,17 +65,8 @@ window.__ModuleLoader__.load({
65
65
  '.da-error{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-error)}',
66
66
  ].join('')
67
67
 
68
- // Appended while the factory materializes: the module system claims the tag
69
- // for this package and disposes it on unload. Guarded because the node unit
70
- // tests evaluate this file without a DOM.
71
- if (typeof document !== 'undefined') {
72
- const style = document.createElement('style')
73
- style.textContent = CSS
74
- document.head.append(style)
75
- }
76
-
77
68
  /** Plugin version, shown in the card header. Kept in lockstep with package.json. */
78
- const VERSION = '0.7.3'
69
+ const VERSION = '0.7.4'
79
70
 
80
71
  const en = {
81
72
  title: 'Alias',
@@ -319,6 +310,18 @@ window.__ModuleLoader__.load({
319
310
  * @param ctx - the browser plugin context.
320
311
  */
321
312
  function apply(ctx) {
313
+ // One stylesheet per plugin instance, removed when the plugin disposes.
314
+ // Guarded because the node unit tests evaluate this file without a DOM.
315
+ if (typeof document !== 'undefined') {
316
+ ctx.effect(() => {
317
+ const style = document.createElement('style')
318
+ style.setAttribute('data-plugin', '@maci0/dsh-alias')
319
+ style.textContent = CSS
320
+ document.head.append(style)
321
+ return () => style.remove()
322
+ }, 'dsh-alias: stylesheet')
323
+ }
324
+
322
325
  const t = ctx.locale.bind(LOCALE_NS)
323
326
  ctx.effect(
324
327
  () => ctx.locale.register(LOCALE_NS, { en, zh }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maci0/dsh-alias",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"