@poveste/plugin-quasar 0.8.2
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/LICENSE +22 -0
- package/README.md +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +116 -0
- package/dist/setup.d.ts +24 -0
- package/dist/setup.js +10 -0
- package/package.json +78 -0
- package/setup.d.ts +1 -0
- package/setup.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Guillaume Chau (original "histoire" project)
|
|
4
|
+
Copyright (c) 2026 Sorin Gitlan (poveste fork)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @poveste/plugin-quasar
|
|
2
|
+
|
|
3
|
+
Builds a Poveste book inside a Quasar project.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { HstQuasar } from '@poveste/plugin-quasar'
|
|
7
|
+
import { HstVue } from '@poveste/plugin-vue'
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
plugins: [
|
|
11
|
+
HstVue(),
|
|
12
|
+
HstQuasar(),
|
|
13
|
+
],
|
|
14
|
+
})
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Quasar builds its Vite config asynchronously and exposes it through an
|
|
18
|
+
entrypoint whose own header says it is for tooling. This plugin fetches it and
|
|
19
|
+
makes the two adjustments a book needs — both of which are easy to get wrong and
|
|
20
|
+
fail in ways that do not point back at them.
|
|
21
|
+
|
|
22
|
+
Quasar's plugins are passed through whole. Nothing needs removing, which is
|
|
23
|
+
unusual: `@poveste/plugin-nuxt` drops six. Removing Quasar's Vue plugin as a
|
|
24
|
+
duplicate is the tempting mistake, and `@quasar/vite-plugin` refuses outright
|
|
25
|
+
because it asserts a Vue plugin is registered before it.
|
|
26
|
+
|
|
27
|
+
Quasar is also kept transformed rather than externalised during story
|
|
28
|
+
collection. Its plugin writes `__QUASAR_VERSION__` while transforming its own
|
|
29
|
+
source, so a source loaded through Node instead has nothing to read.
|
|
30
|
+
|
|
31
|
+
## Boot files
|
|
32
|
+
|
|
33
|
+
Poveste renders your components in its own app, so Quasar's boot files never run
|
|
34
|
+
on their own — and an app extension registers its components through a boot file
|
|
35
|
+
it contributes, so an extension's components are missing too. Both fail quietly:
|
|
36
|
+
the build succeeds and the component is simply absent.
|
|
37
|
+
|
|
38
|
+
Pass them to `setupQuasar` in your setup file:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { setupQuasar } from '@poveste/plugin-quasar/setup'
|
|
42
|
+
import { defineSetupVue3 } from '@poveste/plugin-vue'
|
|
43
|
+
import greeting from './boot/greeting'
|
|
44
|
+
|
|
45
|
+
export const setupVue3 = defineSetupVue3(setupQuasar({
|
|
46
|
+
boot: [greeting],
|
|
47
|
+
}))
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Only `app` is passed to a boot file: a story has no router, no store and no SSR
|
|
51
|
+
context, so one that needs those has to be split or guarded.
|
|
52
|
+
|
|
53
|
+
Needs `@quasar/app-vite@^3.8.0` and `quasar@^2.24.0`. Quasar's SPA config is what
|
|
54
|
+
the entrypoint returns, so that is what a book is built with.
|
|
55
|
+
|
|
56
|
+
The setup helper imports Quasar's stylesheet, which is Sass, so the project needs
|
|
57
|
+
a Sass compiler for Vite to use — `sass` or `sass-embedded`. Quasar projects have
|
|
58
|
+
one already; a project that reaches Quasar another way may not, and Vite says so
|
|
59
|
+
with `Preprocessor dependency "sass" not found`.
|
|
60
|
+
|
|
61
|
+
Quasar reports a project it will not build by exiting the process rather than
|
|
62
|
+
raising an error. That is caught while its config is being read, so a missing
|
|
63
|
+
`index.html` or a rejected `quasar.config` fails as a Poveste error naming this
|
|
64
|
+
plugin instead of taking the CLI down with no explanation.
|
|
65
|
+
|
|
66
|
+
[Configuration](https://poveste.dev/reference/config.html) ·
|
|
67
|
+
[Quasar recipe](https://poveste.dev/guide/config.html)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Plugin } from '@poveste/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Quasar builds its Vite config asynchronously and hands it over through one
|
|
4
|
+
* entrypoint, whose own header says it is "used exclusively by @quasar/testing
|
|
5
|
+
* AEs". That is the same footing as Tailwind's `__unstable__loadDesignSystem`:
|
|
6
|
+
* usable, and not something to ask every user to import from their own config.
|
|
7
|
+
*/
|
|
8
|
+
export declare const QUASAR_PROJECT_REQUIRED: string;
|
|
9
|
+
export declare const QUASAR_EXITED: string;
|
|
10
|
+
export declare const QUASAR_APP_VITE_REQUIRED: string;
|
|
11
|
+
/** What `getTestingConfig` hands back — a Vite config, loosely typed at this boundary. */
|
|
12
|
+
export interface QuasarViteConfig {
|
|
13
|
+
define?: Record<string, unknown>;
|
|
14
|
+
resolve?: {
|
|
15
|
+
alias?: unknown;
|
|
16
|
+
extensions?: unknown;
|
|
17
|
+
dedupe?: unknown;
|
|
18
|
+
};
|
|
19
|
+
plugins?: unknown[];
|
|
20
|
+
}
|
|
21
|
+
export interface HstQuasarOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Passed through to `getTestingConfig`. It resolves the SPA config whatever is
|
|
24
|
+
* asked of it today, so this exists for when that stops being true.
|
|
25
|
+
*/
|
|
26
|
+
ctx?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
type GetTestingConfig = (ctx?: Record<string, unknown>) => Promise<QuasarViteConfig>;
|
|
29
|
+
export declare function isPackageAbsent(error: unknown): boolean;
|
|
30
|
+
export declare function resolveTestingConfig(importTesting?: () => Promise<unknown>): Promise<GetTestingConfig>;
|
|
31
|
+
/** The directory holding the nearest quasar.config, searching upwards from `from`. */
|
|
32
|
+
export declare function findQuasarProject(from: string, exists?: (path: string) => boolean): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Quasar validates the project while building its config, and reports a failure by
|
|
35
|
+
* calling its own `fatal()` — which ends in `process.exit(1)`. From inside a plugin
|
|
36
|
+
* hook that takes the whole CLI down with it: no poveste error, no plugin named,
|
|
37
|
+
* and `poveste dev` gone with it.
|
|
38
|
+
*
|
|
39
|
+
* Nothing here can stop a dependency exiting, so the exit is turned into a throw for
|
|
40
|
+
* as long as the call lasts. The real `process.exit` goes back either way.
|
|
41
|
+
*/
|
|
42
|
+
export declare function withoutProcessExit<T>(fn: () => Promise<T>): Promise<T>;
|
|
43
|
+
/**
|
|
44
|
+
* Quasar's plugins are passed through whole. Nothing needs removing — unusually,
|
|
45
|
+
* since the Nuxt plugin drops six — and removing its Vue plugin in particular
|
|
46
|
+
* fails config resolution, because @quasar/vite-plugin asserts one precedes it.
|
|
47
|
+
*
|
|
48
|
+
* `ssr.noExternal` is the part users should not have to know: Quasar's plugin
|
|
49
|
+
* writes `__QUASAR_VERSION__` while transforming its own source, so that source
|
|
50
|
+
* has to be transformed rather than externalised during story collection.
|
|
51
|
+
*/
|
|
52
|
+
export declare function quasarViteConfig(viteConfig: QuasarViteConfig): {
|
|
53
|
+
ssr: {
|
|
54
|
+
noExternal: RegExp[];
|
|
55
|
+
};
|
|
56
|
+
define: {
|
|
57
|
+
[x: string]: unknown;
|
|
58
|
+
};
|
|
59
|
+
resolve: {
|
|
60
|
+
alias: unknown;
|
|
61
|
+
extensions: unknown;
|
|
62
|
+
dedupe: unknown;
|
|
63
|
+
};
|
|
64
|
+
plugins: unknown[];
|
|
65
|
+
};
|
|
66
|
+
export declare function HstQuasar(options?: HstQuasarOptions): Plugin;
|
|
67
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { dirname, join, parse } from 'pathe';
|
|
4
|
+
/**
|
|
5
|
+
* Quasar builds its Vite config asynchronously and hands it over through one
|
|
6
|
+
* entrypoint, whose own header says it is "used exclusively by @quasar/testing
|
|
7
|
+
* AEs". That is the same footing as Tailwind's `__unstable__loadDesignSystem`:
|
|
8
|
+
* usable, and not something to ask every user to import from their own config.
|
|
9
|
+
*/
|
|
10
|
+
export const QUASAR_PROJECT_REQUIRED = '@poveste/plugin-quasar found no quasar.config file above the current directory. '
|
|
11
|
+
+ 'It reads the Vite config Quasar builds for the project, so it needs a Quasar project to read.';
|
|
12
|
+
export const QUASAR_EXITED = '@poveste/plugin-quasar: Quasar ended the process while resolving its config. Its own output is above; '
|
|
13
|
+
+ 'a missing index.html or a quasar.config it refuses are the usual causes.';
|
|
14
|
+
export const QUASAR_APP_VITE_REQUIRED = '@poveste/plugin-quasar needs @quasar/app-vite: the installed copy does not export '
|
|
15
|
+
+ '`getTestingConfig` from `@quasar/app-vite/testing`. Install @quasar/app-vite@^3.8.0.';
|
|
16
|
+
function hasGetTestingConfig(mod) {
|
|
17
|
+
return typeof mod?.getTestingConfig === 'function';
|
|
18
|
+
}
|
|
19
|
+
/** Only these mean the package or its entrypoint is absent. Anything else is its own problem. */
|
|
20
|
+
const ABSENT = new Set(['ERR_MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED']);
|
|
21
|
+
export function isPackageAbsent(error) {
|
|
22
|
+
return ABSENT.has(error?.code ?? '');
|
|
23
|
+
}
|
|
24
|
+
export async function resolveTestingConfig(importTesting = () => import('@quasar/app-vite/testing')) {
|
|
25
|
+
let mod;
|
|
26
|
+
try {
|
|
27
|
+
mod = await importTesting();
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// A broken transitive dependency, or a file the installed Node will not parse,
|
|
31
|
+
// is not a missing package — saying so sends the reader to reinstall something
|
|
32
|
+
// that was never the problem, and loses the error that was.
|
|
33
|
+
if (!isPackageAbsent(error)) {
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
throw new Error(QUASAR_APP_VITE_REQUIRED, { cause: error });
|
|
37
|
+
}
|
|
38
|
+
if (!hasGetTestingConfig(mod)) {
|
|
39
|
+
throw new Error(QUASAR_APP_VITE_REQUIRED);
|
|
40
|
+
}
|
|
41
|
+
return mod.getTestingConfig;
|
|
42
|
+
}
|
|
43
|
+
/** The directory holding the nearest quasar.config, searching upwards from `from`. */
|
|
44
|
+
export function findQuasarProject(from, exists = existsSync) {
|
|
45
|
+
const names = ['quasar.config.js', 'quasar.config.mjs', 'quasar.config.cjs', 'quasar.config.ts'];
|
|
46
|
+
let dir = from;
|
|
47
|
+
let { root } = parse(from);
|
|
48
|
+
// On Windows this is `C:` and needs the trailing slash to terminate the walk.
|
|
49
|
+
if (root[1] === ':' && root[2] === undefined) {
|
|
50
|
+
root += '/';
|
|
51
|
+
}
|
|
52
|
+
while (true) {
|
|
53
|
+
if (names.some(name => exists(join(dir, name)))) {
|
|
54
|
+
return dir;
|
|
55
|
+
}
|
|
56
|
+
if (dir === root) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
dir = dirname(dir);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Quasar validates the project while building its config, and reports a failure by
|
|
64
|
+
* calling its own `fatal()` — which ends in `process.exit(1)`. From inside a plugin
|
|
65
|
+
* hook that takes the whole CLI down with it: no poveste error, no plugin named,
|
|
66
|
+
* and `poveste dev` gone with it.
|
|
67
|
+
*
|
|
68
|
+
* Nothing here can stop a dependency exiting, so the exit is turned into a throw for
|
|
69
|
+
* as long as the call lasts. The real `process.exit` goes back either way.
|
|
70
|
+
*/
|
|
71
|
+
export async function withoutProcessExit(fn) {
|
|
72
|
+
const realExit = process.exit;
|
|
73
|
+
process.exit = ((code) => {
|
|
74
|
+
throw new Error(`${QUASAR_EXITED} (exit code ${code ?? 0})`);
|
|
75
|
+
});
|
|
76
|
+
try {
|
|
77
|
+
return await fn();
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
process.exit = realExit;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Quasar's plugins are passed through whole. Nothing needs removing — unusually,
|
|
85
|
+
* since the Nuxt plugin drops six — and removing its Vue plugin in particular
|
|
86
|
+
* fails config resolution, because @quasar/vite-plugin asserts one precedes it.
|
|
87
|
+
*
|
|
88
|
+
* `ssr.noExternal` is the part users should not have to know: Quasar's plugin
|
|
89
|
+
* writes `__QUASAR_VERSION__` while transforming its own source, so that source
|
|
90
|
+
* has to be transformed rather than externalised during story collection.
|
|
91
|
+
*/
|
|
92
|
+
export function quasarViteConfig(viteConfig) {
|
|
93
|
+
return {
|
|
94
|
+
ssr: { noExternal: [/quasar/] },
|
|
95
|
+
define: { ...viteConfig.define },
|
|
96
|
+
resolve: {
|
|
97
|
+
alias: viteConfig.resolve?.alias,
|
|
98
|
+
extensions: viteConfig.resolve?.extensions,
|
|
99
|
+
dedupe: viteConfig.resolve?.dedupe,
|
|
100
|
+
},
|
|
101
|
+
plugins: viteConfig.plugins,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function HstQuasar(options = {}) {
|
|
105
|
+
return {
|
|
106
|
+
name: '@poveste/plugin-quasar',
|
|
107
|
+
async defaultConfig() {
|
|
108
|
+
if (!findQuasarProject(process.cwd())) {
|
|
109
|
+
throw new Error(QUASAR_PROJECT_REQUIRED);
|
|
110
|
+
}
|
|
111
|
+
const getTestingConfig = await resolveTestingConfig();
|
|
112
|
+
const viteConfig = await withoutProcessExit(() => getTestingConfig(options.ctx ?? {}));
|
|
113
|
+
return { vite: quasarViteConfig(viteConfig) };
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
package/dist/setup.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { App } from 'vue';
|
|
2
|
+
import 'quasar/src/css/index.sass';
|
|
3
|
+
/**
|
|
4
|
+
* A Quasar boot file. Quasar hands these the router, the store and the SSR
|
|
5
|
+
* context as well; a story has none of those, so only `app` is passed and a boot
|
|
6
|
+
* file needing more has to be split or guarded.
|
|
7
|
+
*/
|
|
8
|
+
export type BootFile = (params: {
|
|
9
|
+
app: App;
|
|
10
|
+
}) => unknown;
|
|
11
|
+
export interface SetupQuasarOptions {
|
|
12
|
+
/** Passed to `app.use(Quasar, …)` — Quasar's own plugin options. */
|
|
13
|
+
quasar?: Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Boot files to run. Poveste renders stories in its own app, so the ones
|
|
16
|
+
* `quasar.config.js` lists never run on their own; nor do the ones app
|
|
17
|
+
* extensions contribute, which is why an extension's components are otherwise
|
|
18
|
+
* missing with no error. Import them and pass them here.
|
|
19
|
+
*/
|
|
20
|
+
boot?: BootFile[];
|
|
21
|
+
}
|
|
22
|
+
export declare function setupQuasar(options?: SetupQuasarOptions): ({ app }: {
|
|
23
|
+
app: App;
|
|
24
|
+
}) => void;
|
package/dist/setup.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@poveste/plugin-quasar",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.8.2",
|
|
5
|
+
"description": "Poveste plugin that builds a book inside a Quasar project",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Sorin Gitlan"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"homepage": "https://poveste.dev",
|
|
11
|
+
"repository": {
|
|
12
|
+
"url": "https://github.com/poveste-dev/poveste.git",
|
|
13
|
+
"type": "git",
|
|
14
|
+
"directory": "packages/poveste-plugin-quasar"
|
|
15
|
+
},
|
|
16
|
+
"bugs": "https://github.com/poveste-dev/poveste/issues",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"poveste",
|
|
19
|
+
"histoire",
|
|
20
|
+
"storybook",
|
|
21
|
+
"component-playground",
|
|
22
|
+
"component-explorer",
|
|
23
|
+
"stories",
|
|
24
|
+
"styleguide",
|
|
25
|
+
"vite",
|
|
26
|
+
"vue",
|
|
27
|
+
"quasar",
|
|
28
|
+
"plugin"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./dist/index.js",
|
|
35
|
+
"./setup": {
|
|
36
|
+
"types": "./setup.d.ts",
|
|
37
|
+
"default": "./setup.js"
|
|
38
|
+
},
|
|
39
|
+
"./*": "./*"
|
|
40
|
+
},
|
|
41
|
+
"main": "./dist/index.js",
|
|
42
|
+
"module": "./dist/index.js",
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"setup.d.ts",
|
|
47
|
+
"setup.js"
|
|
48
|
+
],
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@quasar/app-vite": "^3.8.0",
|
|
54
|
+
"quasar": "^2.24.0",
|
|
55
|
+
"vue": "^3.5.26",
|
|
56
|
+
"poveste": "^0.8.2"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"pathe": "^1.1.2",
|
|
60
|
+
"@poveste/shared": "0.8.2"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@quasar/app-vite": "^3.8.1",
|
|
64
|
+
"@types/node": "^22.10.1",
|
|
65
|
+
"quasar": "^2.27.0",
|
|
66
|
+
"typescript": "5.6.3",
|
|
67
|
+
"vite": "^8.2.0",
|
|
68
|
+
"vitest": "^4.1.10",
|
|
69
|
+
"vue": "^3.5.26",
|
|
70
|
+
"poveste": "0.8.2"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "rimraf dist && tsc -d",
|
|
74
|
+
"watch": "tsc -d -w --sourceMap",
|
|
75
|
+
"test": "vitest run",
|
|
76
|
+
"test:dev": "vitest"
|
|
77
|
+
}
|
|
78
|
+
}
|
package/setup.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/setup.js'
|
package/setup.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/setup.js'
|