poveste 0.19.0 → 0.19.1

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
@@ -16,17 +16,17 @@ panel.
16
16
  Install `poveste` alongside the plugin for your framework:
17
17
 
18
18
  ```shell
19
- pnpm i -D poveste @poveste/plugin-vue # Vue 3
20
- pnpm i -D poveste @poveste/plugin-svelte # Svelte 5 and SvelteKit
21
- pnpm i -D poveste @poveste/plugin-nuxt # Nuxt 4
22
- pnpm i -D poveste @poveste/plugin-quasar # Quasar
23
- pnpm i -D poveste @poveste/plugin-solid # Solid, renderer only
24
- pnpm i -D poveste @poveste/plugin-react # React 19, renderer only
19
+ pnpm i -D poveste @poveste/plugin-vue # Vue 3
20
+ pnpm i -D poveste @poveste/plugin-svelte # Svelte 5 and SvelteKit
21
+ pnpm i -D poveste @poveste/plugin-vue @poveste/plugin-nuxt # Nuxt 4
22
+ pnpm i -D poveste @poveste/plugin-vue @poveste/plugin-quasar # Quasar
23
+ pnpm i -D poveste @poveste/plugin-solid # Solid, renderer only
24
+ pnpm i -D poveste @poveste/plugin-react # React 19, renderer only
25
25
  ```
26
26
 
27
27
  > **Installed an older version than you expected?** For about a day after a release, pnpm installs the previous one with no error and no hint, and for a plugin that's new in that release, its empty `0.0.1` placeholder. That's pnpm's release-age cooldown, not a broken publish. `package.json` keeps the old `^x.y.z`, so waiting doesn't fix it: install again with `npm`, with `--config.minimum-release-age=0` (kebab-case: pnpm 12.4 ignores the camelCase spelling), or with exact versions.
28
28
 
29
- Then create a `poveste.config.ts` in your project root:
29
+ Then create a `poveste.config.ts` in your project root. For a Vue project it is this:
30
30
 
31
31
  ```ts
32
32
  import { HstVue } from '@poveste/plugin-vue'
@@ -39,6 +39,8 @@ export default defineConfig({
39
39
  })
40
40
  ```
41
41
 
42
+ Every other framework uses its own plugin, and Quasar also needs a setup file, so take the config from its guide: [Svelte](https://poveste.dev/guide/svelte/getting-started), [SvelteKit](https://poveste.dev/guide/sveltekit/getting-started), [Nuxt](https://poveste.dev/guide/nuxt/getting-started), [Quasar](https://poveste.dev/guide/quasar/getting-started), [Solid](https://poveste.dev/guide/solid/getting-started) or [React](https://poveste.dev/guide/react/getting-started).
43
+
42
44
  ## Commands
43
45
 
44
46
  | | |
@@ -30,5 +30,12 @@ export type Invoke = (name: string, data: unknown[]) => Promise<unknown>;
30
30
  * that branch, and no id or file in either book carried the prefix.
31
31
  */
32
32
  export declare function filenameOf(module: Readonly<EvaluatedModuleNode>, root: string): string;
33
+ /**
34
+ * The keys an externalised module added to `globalThis` when Node ran it. Node
35
+ * caches that module, so once a worker's reset deletes them nothing installs them
36
+ * again. Vue's development build sets `__VUE_HMR_RUNTIME__` this way, and a story
37
+ * compiled with HMR code reads it at its top level (#1320).
38
+ */
39
+ export declare const globalsFromExternals: Set<string>;
33
40
  /** A runner over a module server, reached through `invoke`. `root` is the Vite root. */
34
41
  export declare function createRunner(invoke: Invoke, root: string, evaluatedModules?: EvaluatedModules): ModuleRunner;
@@ -67,6 +67,25 @@ export function filenameOf(module, root) {
67
67
  }
68
68
  return join(root, 'virtual-module');
69
69
  }
70
+ /**
71
+ * The keys an externalised module added to `globalThis` when Node ran it. Node
72
+ * caches that module, so once a worker's reset deletes them nothing installs them
73
+ * again. Vue's development build sets `__VUE_HMR_RUNTIME__` this way, and a story
74
+ * compiled with HMR code reads it at its top level (#1320).
75
+ */
76
+ export const globalsFromExternals = new Set();
77
+ const ranExternals = new Set();
78
+ async function importRecordingGlobals(file) {
79
+ const before = new Set(Object.keys(globalThis));
80
+ const imported = await import(file);
81
+ ranExternals.add(file);
82
+ for (const key of Object.keys(globalThis)) {
83
+ if (!before.has(key)) {
84
+ globalsFromExternals.add(key);
85
+ }
86
+ }
87
+ return imported;
88
+ }
70
89
  /** As vite-node did: a CJS package's named exports are read through its default. */
71
90
  class InteropEvaluator {
72
91
  root;
@@ -130,7 +149,7 @@ class InteropEvaluator {
130
149
  await run(context[ssrModuleExportsKey], context[ssrImportMetaKey], context[ssrImportKey], context[ssrDynamicImportKey], context[ssrExportAllKey], context[ssrExportNameKey], createRequire(filename), cjsExports, moduleProxy, filename, dirname(filename));
131
150
  }
132
151
  async runExternalModule(file) {
133
- const imported = await import(file);
152
+ const imported = ranExternals.has(file) ? await import(file) : await importRecordingGlobals(file);
134
153
  if (file.endsWith('.mjs') || !('default' in imported)) {
135
154
  return imported;
136
155
  }
@@ -6,7 +6,7 @@ import pc from 'picocolors';
6
6
  import { EvaluatedModules } from 'vite/module-runner';
7
7
  import { createDomEnv, resetDomEnv } from '../dom/env.js';
8
8
  import { invokeOver } from './rpc.js';
9
- import { createRunner } from './runner.js';
9
+ import { createRunner, globalsFromExternals } from './runner.js';
10
10
  import { serveTasks } from './task.js';
11
11
  const __dirname = dirname(fileURLToPath(import.meta.url));
12
12
  const _evaluatedModules = new EvaluatedModules();
@@ -63,7 +63,7 @@ async function collect(payload) {
63
63
  // belongs to one server, so every task it is sent carries that server's root.
64
64
  const runner = _runner ?? (_runner = createRunner((name, data) => _invoke(name, data), payload.root, _evaluatedModules));
65
65
  if (_domEnv) {
66
- resetDomEnv(_domEnv);
66
+ resetDomEnv(_domEnv, globalsFromExternals);
67
67
  }
68
68
  else {
69
69
  _domEnv = createDomEnv();
@@ -6,4 +6,4 @@ export declare function createDomEnv(): {
6
6
  storages: Storage[];
7
7
  };
8
8
  /** Returns a reused environment to the state a fresh one would have been in. */
9
- export declare function resetDomEnv(env: Pick<ReturnType<typeof createDomEnv>, 'window' | 'pristineKeys' | 'storages'>): void;
9
+ export declare function resetDomEnv(env: Pick<ReturnType<typeof createDomEnv>, 'window' | 'pristineKeys' | 'storages'>, kept?: ReadonlySet<string>): void;
@@ -134,7 +134,7 @@ export function createDomEnv() {
134
134
  };
135
135
  }
136
136
  /** Returns a reused environment to the state a fresh one would have been in. */
137
- export function resetDomEnv(env) {
137
+ export function resetDomEnv(env, kept = new Set()) {
138
138
  const doc = env.window.document;
139
139
  for (const el of [doc.documentElement, doc.head, doc.body]) {
140
140
  if (!el)
@@ -149,8 +149,9 @@ export function resetDomEnv(env) {
149
149
  storage.clear();
150
150
  }
151
151
  // Additions only: the modules that installed the rest are cached, not re-run.
152
+ // So are the ones that installed `kept`, after this environment was made.
152
153
  for (const key of Object.keys(globalThis)) {
153
- if (!env.pristineKeys.has(key)) {
154
+ if (!env.pristineKeys.has(key) && !kept.has(key)) {
154
155
  delete globalThis[key];
155
156
  }
156
157
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "poveste",
3
3
  "type": "module",
4
- "version": "0.19.0",
4
+ "version": "0.19.1",
5
5
  "description": "Interactive component playgrounds for Vue, Nuxt, Svelte, SvelteKit and Quasar, plus Solid and React (renderer only) — a drop-in fork of histoire, with Quasar support histoire does not ship.",
6
6
  "author": {
7
7
  "name": "Sorin Gitlan",
@@ -78,10 +78,10 @@
78
78
  },
79
79
  "dependencies": {
80
80
  "@11ty/gray-matter": "^3.0.0",
81
- "@poveste/app": "^0.19.0",
82
- "@poveste/controls": "^0.19.0",
83
- "@poveste/shared": "^0.19.0",
84
- "@poveste/vendors": "^0.19.0",
81
+ "@poveste/app": "^0.19.1",
82
+ "@poveste/controls": "^0.19.1",
83
+ "@poveste/shared": "^0.19.1",
84
+ "@poveste/vendors": "^0.19.1",
85
85
  "change-case": "^5.4.4",
86
86
  "chokidar": "^5.0.0",
87
87
  "defu": "^6.1.4",