@xynogen/pix-welcome 0.1.4 → 0.1.6

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/README.md CHANGED
@@ -12,7 +12,7 @@ Renders a coloured ASCII π logo above the editor on session start and runs star
12
12
  pi install npm:@xynogen/pix-welcome
13
13
  ```
14
14
 
15
- > Also included in [`@xynogen/pix-core`](https://github.com/xynogen/pix-mono/tree/main/packages/pix-core):
15
+ > Also included in [`@xynogen/pix-core`](https://www.npmjs.com/package/@xynogen/pix-core):
16
16
  >
17
17
  > ```bash
18
18
  > pi install npm:@xynogen/pix-core
@@ -20,6 +20,8 @@ pi install npm:@xynogen/pix-welcome
20
20
 
21
21
  ## Full distro
22
22
 
23
+ Source: [github.com/xynogen/pix-mono](https://github.com/xynogen/pix-mono)
24
+
23
25
  To install the complete pix suite (all packages + Pi itself):
24
26
 
25
27
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-welcome",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Pi extension — welcome banner with startup health checks",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/extension.ts CHANGED
@@ -3,5 +3,5 @@ import { once } from "./once.ts";
3
3
  import registerWelcome from "./welcome.ts";
4
4
 
5
5
  export default function (pi: ExtensionAPI): void {
6
- once("pix-welcome", () => registerWelcome(pi));
6
+ once(pi, "pix-welcome", () => registerWelcome(pi));
7
7
  }
package/src/once.ts CHANGED
@@ -1,15 +1,25 @@
1
1
  /**
2
- * Idempotency guard for extension activation.
2
+ * Per-instance idempotency guard for extension activation.
3
3
  *
4
- * pix-core (the meta-package) invokes this package's factory in addition to a
5
- * possible direct install. Pi's loader uses jiti with `moduleCache: false`, so
6
- * each load pass re-evaluates modules a plain module-level flag would not be
7
- * shared. The dedupe key therefore lives on `globalThis`, which persists for
8
- * the lifetime of the process across all load passes.
4
+ * pix-core (the meta-package) invokes this package's factory, and a standalone
5
+ * install makes Pi invoke it again sometimes against the SAME `pi`. We must
6
+ * dedupe that. But Pi rebuilds the extension runtime on /new, /resume, /fork,
7
+ * and /reload, handing the factory a BRAND-NEW `pi`; that must re-register.
8
+ *
9
+ * Keying the registry on the `pi` instance satisfies both: same instance =>
10
+ * skip, new instance => run. The registry lives on globalThis because jiti
11
+ * (`moduleCache: false`) re-evaluates this module on every load pass, so a
12
+ * module-scoped WeakMap would not be shared between the aggregator pass and the
13
+ * standalone pass within a single session.
9
14
  */
10
- export function once(key: string, fn: () => void): void {
11
- const g = globalThis as { __pixLoaded?: Set<string> };
12
- const loaded = (g.__pixLoaded ??= new Set<string>());
15
+ export function once(pi: object, key: string, fn: () => void): void {
16
+ const g = globalThis as { __pixOnce?: WeakMap<object, Set<string>> };
17
+ const registry = (g.__pixOnce ??= new WeakMap<object, Set<string>>());
18
+ let loaded = registry.get(pi);
19
+ if (!loaded) {
20
+ loaded = new Set<string>();
21
+ registry.set(pi, loaded);
22
+ }
13
23
  if (loaded.has(key)) return;
14
24
  loaded.add(key);
15
25
  fn();