@cfp-studio/plugin-vue3 16.0.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/LICENSE +21 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +656 -0
- package/package.json +51 -0
- package/preview/index.ts +141 -0
- package/preview/modules/@vue/compiler-core/LICENSE +21 -0
- package/preview/modules/@vue/compiler-core/README.md +1 -0
- package/preview/modules/@vue/compiler-core/dist/compiler-core.cjs.js +6813 -0
- package/preview/modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6690 -0
- package/preview/modules/@vue/compiler-core/dist/compiler-core.d.ts +1091 -0
- package/preview/modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js +5790 -0
- package/preview/modules/@vue/compiler-core/index.js +7 -0
- package/preview/modules/@vue/compiler-core/node_modules/.bin/parser +17 -0
- package/preview/modules/@vue/compiler-core/package.json +58 -0
- package/preview/modules/@vue/compiler-sfc/LICENSE +21 -0
- package/preview/modules/@vue/compiler-sfc/README.md +80 -0
- package/preview/modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +24970 -0
- package/preview/modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts +484 -0
- package/preview/modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +53043 -0
- package/preview/modules/@vue/compiler-sfc/node_modules/.bin/parser +17 -0
- package/preview/modules/@vue/compiler-sfc/package.json +67 -0
- package/preview/modules/@vue/reactivity/LICENSE +21 -0
- package/preview/modules/@vue/reactivity/README.md +19 -0
- package/preview/modules/@vue/reactivity/dist/reactivity.cjs.js +1939 -0
- package/preview/modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1789 -0
- package/preview/modules/@vue/reactivity/dist/reactivity.d.ts +754 -0
- package/preview/modules/@vue/reactivity/dist/reactivity.esm-browser.js +1938 -0
- package/preview/modules/@vue/reactivity/dist/reactivity.esm-browser.prod.js +5 -0
- package/preview/modules/@vue/reactivity/dist/reactivity.esm-bundler.js +1896 -0
- package/preview/modules/@vue/reactivity/dist/reactivity.global.js +1994 -0
- package/preview/modules/@vue/reactivity/dist/reactivity.global.prod.js +5 -0
- package/preview/modules/@vue/reactivity/index.js +7 -0
- package/preview/modules/@vue/reactivity/package.json +55 -0
- package/preview/modules/@vue/runtime-core/LICENSE +21 -0
- package/preview/modules/@vue/runtime-core/README.md +28 -0
- package/preview/modules/@vue/runtime-core/dist/runtime-core.cjs.js +8493 -0
- package/preview/modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6654 -0
- package/preview/modules/@vue/runtime-core/dist/runtime-core.d.ts +1832 -0
- package/preview/modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +8419 -0
- package/preview/modules/@vue/runtime-core/index.js +7 -0
- package/preview/modules/@vue/runtime-core/package.json +52 -0
- package/preview/modules/@vue/runtime-dom/LICENSE +21 -0
- package/preview/modules/@vue/runtime-dom/README.md +13 -0
- package/preview/modules/@vue/runtime-dom/dist/runtime-dom.cjs.js +1820 -0
- package/preview/modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1669 -0
- package/preview/modules/@vue/runtime-dom/dist/runtime-dom.d.ts +1395 -0
- package/preview/modules/@vue/runtime-dom/dist/runtime-dom.esm-browser.js +12332 -0
- package/preview/modules/@vue/runtime-dom/dist/runtime-dom.esm-browser.prod.js +5 -0
- package/preview/modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +1860 -0
- package/preview/modules/@vue/runtime-dom/dist/runtime-dom.global.js +12383 -0
- package/preview/modules/@vue/runtime-dom/dist/runtime-dom.global.prod.js +5 -0
- package/preview/modules/@vue/runtime-dom/index.js +7 -0
- package/preview/modules/@vue/runtime-dom/package.json +60 -0
- package/preview/modules/@vue/shared/LICENSE +21 -0
- package/preview/modules/@vue/shared/README.md +3 -0
- package/preview/modules/@vue/shared/dist/shared.cjs.js +594 -0
- package/preview/modules/@vue/shared/dist/shared.cjs.prod.js +594 -0
- package/preview/modules/@vue/shared/dist/shared.d.ts +328 -0
- package/preview/modules/@vue/shared/dist/shared.esm-bundler.js +519 -0
- package/preview/modules/@vue/shared/index.js +7 -0
- package/preview/modules/@vue/shared/package.json +47 -0
- package/preview/modules/vue/LICENSE +21 -0
- package/preview/modules/vue/README.md +62 -0
- package/preview/modules/vue/compiler-sfc/index.browser.js +1 -0
- package/preview/modules/vue/compiler-sfc/index.browser.mjs +1 -0
- package/preview/modules/vue/compiler-sfc/index.d.mts +1 -0
- package/preview/modules/vue/compiler-sfc/index.d.ts +1 -0
- package/preview/modules/vue/compiler-sfc/index.js +3 -0
- package/preview/modules/vue/compiler-sfc/index.mjs +3 -0
- package/preview/modules/vue/compiler-sfc/package.json +4 -0
- package/preview/modules/vue/compiler-sfc/register-ts.js +3 -0
- package/preview/modules/vue/dist/vue.cjs.js +80 -0
- package/preview/modules/vue/dist/vue.cjs.prod.js +66 -0
- package/preview/modules/vue/dist/vue.d.mts +7 -0
- package/preview/modules/vue/dist/vue.d.ts +7 -0
- package/preview/modules/vue/dist/vue.esm-browser.js +18216 -0
- package/preview/modules/vue/dist/vue.esm-browser.prod.js +9 -0
- package/preview/modules/vue/dist/vue.esm-bundler.js +71 -0
- package/preview/modules/vue/dist/vue.global.js +18096 -0
- package/preview/modules/vue/dist/vue.global.prod.js +9 -0
- package/preview/modules/vue/dist/vue.runtime.esm-browser.js +12355 -0
- package/preview/modules/vue/dist/vue.runtime.esm-browser.prod.js +5 -0
- package/preview/modules/vue/dist/vue.runtime.esm-bundler.js +26 -0
- package/preview/modules/vue/dist/vue.runtime.global.js +12407 -0
- package/preview/modules/vue/dist/vue.runtime.global.prod.js +5 -0
- package/preview/modules/vue/index.js +7 -0
- package/preview/modules/vue/index.mjs +1 -0
- package/preview/modules/vue/jsx-runtime/index.d.ts +25 -0
- package/preview/modules/vue/jsx-runtime/index.js +15 -0
- package/preview/modules/vue/jsx-runtime/index.mjs +12 -0
- package/preview/modules/vue/jsx-runtime/package.json +5 -0
- package/preview/modules/vue/jsx.d.ts +22 -0
- package/preview/modules/vue/node_modules/.bin/tsc +17 -0
- package/preview/modules/vue/node_modules/.bin/tsserver +17 -0
- package/preview/modules/vue/package.json +112 -0
- package/preview/modules/vue/server-renderer/index.d.mts +1 -0
- package/preview/modules/vue/server-renderer/index.d.ts +1 -0
- package/preview/modules/vue/server-renderer/index.js +1 -0
- package/preview/modules/vue/server-renderer/index.mjs +1 -0
- package/preview/modules/vue/server-renderer/package.json +4 -0
- package/preview/tsconfig.json +8 -0
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cfp-studio/plugin-vue3",
|
|
3
|
+
"version": "16.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"preview"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@vitejs/plugin-vue": "5.2.1",
|
|
15
|
+
"@vitejs/plugin-vue-jsx": "4.1.1",
|
|
16
|
+
"@vue/compiler-sfc": "3.5.13",
|
|
17
|
+
"fs-extra": "11.3.0",
|
|
18
|
+
"typescript": "5.7.3",
|
|
19
|
+
"vue": "3.5.13",
|
|
20
|
+
"@cfp-studio/serializable-values": "9.0.6",
|
|
21
|
+
"@cfp-studio/vfs": "2.1.4",
|
|
22
|
+
"@cfp-studio/type-analyzer": "10.1.5",
|
|
23
|
+
"@cfp-studio/api": "16.1.0",
|
|
24
|
+
"@cfp-studio/storybook-helpers": "6.0.1",
|
|
25
|
+
"@cfp-studio/analyzer-api": "0.1.9"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@playwright/test": "1.50.1",
|
|
29
|
+
"@types/fs-extra": "11.0.4",
|
|
30
|
+
"@vue/compiler-core": "3.5.13",
|
|
31
|
+
"@vue/reactivity": "3.5.13",
|
|
32
|
+
"@vue/runtime-core": "3.5.13",
|
|
33
|
+
"@vue/runtime-dom": "3.5.13",
|
|
34
|
+
"@vue/shared": "3.5.13",
|
|
35
|
+
"pino": "9.6.0",
|
|
36
|
+
"pino-pretty": "11.3.0",
|
|
37
|
+
"rimraf": "6.0.1",
|
|
38
|
+
"shx": "0.3.4",
|
|
39
|
+
"unbuild": "2.0.0",
|
|
40
|
+
"vite": "6.2.0",
|
|
41
|
+
"vitest": "2.1.9",
|
|
42
|
+
"@cfp-studio/core": "1.0.1",
|
|
43
|
+
"@cfp-studio/testing": "14.0.1",
|
|
44
|
+
"@cfp-studio/iframe": "18.0.1"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc && tsc -p preview/tsconfig.json && unbuild",
|
|
48
|
+
"test": "vitest",
|
|
49
|
+
"e2e-test": "playwright test"
|
|
50
|
+
}
|
|
51
|
+
}
|
package/preview/index.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { GetPropsFn, RendererLoader } from "@cfp-studio/iframe";
|
|
2
|
+
import type { App } from "vue";
|
|
3
|
+
import { createApp } from "vue";
|
|
4
|
+
|
|
5
|
+
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
6
|
+
const root = document.getElementById("root")!;
|
|
7
|
+
let app: App | null = null;
|
|
8
|
+
|
|
9
|
+
export const loadRenderer: RendererLoader = async ({
|
|
10
|
+
wrapperModule,
|
|
11
|
+
wrapperName,
|
|
12
|
+
previewableModule,
|
|
13
|
+
previewableName,
|
|
14
|
+
shouldAbortRender,
|
|
15
|
+
}) => {
|
|
16
|
+
const isStoryModule = !!previewableModule.default?.component;
|
|
17
|
+
const Wrapper =
|
|
18
|
+
(wrapperModule?.[wrapperName || "default"]) || null;
|
|
19
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
20
|
+
let Previewable: any;
|
|
21
|
+
if (
|
|
22
|
+
(
|
|
23
|
+
previewableModule.default?.__file ||
|
|
24
|
+
previewableModule.default?.options?.__file
|
|
25
|
+
)?.endsWith(".vue")
|
|
26
|
+
) {
|
|
27
|
+
Previewable = previewableModule.default;
|
|
28
|
+
if (!Previewable) {
|
|
29
|
+
throw new Error("No default component could be found");
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
Previewable =
|
|
33
|
+
previewableModule[previewableName] ||
|
|
34
|
+
previewableModule.PreviewJsEval(
|
|
35
|
+
`try { return ${previewableName}; } catch { return null; }`
|
|
36
|
+
);
|
|
37
|
+
if (!Previewable) {
|
|
38
|
+
throw new Error(`No component or story named '${previewableName}'`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const storyDecorators = Previewable.decorators || [];
|
|
42
|
+
let RenderComponent = Previewable;
|
|
43
|
+
if (Previewable.render && !isStoryModule) {
|
|
44
|
+
// Vue component. Nothing to do.
|
|
45
|
+
} else {
|
|
46
|
+
// JSX or Storybook story, either CSF2 or CSF3.
|
|
47
|
+
if (typeof Previewable === "function") {
|
|
48
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
49
|
+
RenderComponent = (props: any) => {
|
|
50
|
+
const storyReturnValue = Previewable(props);
|
|
51
|
+
if (storyReturnValue.template) {
|
|
52
|
+
// CSF2 story.
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
return h(storyReturnValue, props);
|
|
55
|
+
}
|
|
56
|
+
// JSX
|
|
57
|
+
return storyReturnValue;
|
|
58
|
+
};
|
|
59
|
+
} else {
|
|
60
|
+
// CSF3 story.
|
|
61
|
+
const csf3Story = Previewable;
|
|
62
|
+
RenderComponent =
|
|
63
|
+
csf3Story.component || previewableModule.default?.component;
|
|
64
|
+
if (!RenderComponent) {
|
|
65
|
+
throw new Error("Encountered a story with no component");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const decorators = [
|
|
70
|
+
...storyDecorators,
|
|
71
|
+
...(previewableModule.default?.decorators || []),
|
|
72
|
+
];
|
|
73
|
+
const Decorated = decorators.reduce((component, decorator) => {
|
|
74
|
+
const decorated = decorator();
|
|
75
|
+
return {
|
|
76
|
+
...decorated,
|
|
77
|
+
components: { ...decorated.components, story: component },
|
|
78
|
+
};
|
|
79
|
+
}, RenderComponent);
|
|
80
|
+
return {
|
|
81
|
+
render: async (getProps: GetPropsFn) => {
|
|
82
|
+
if (shouldAbortRender()) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (app) {
|
|
86
|
+
app.unmount();
|
|
87
|
+
app = null;
|
|
88
|
+
}
|
|
89
|
+
const props = getProps({
|
|
90
|
+
presetGlobalProps: previewableModule.default?.args || {},
|
|
91
|
+
presetProps: Previewable.args || {},
|
|
92
|
+
});
|
|
93
|
+
app = createApp(() => {
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
const decoratedNode = slotTransformingH(Decorated, props);
|
|
96
|
+
return Wrapper
|
|
97
|
+
? // @ts-ignore
|
|
98
|
+
h(Wrapper, null, () => decoratedNode)
|
|
99
|
+
: decoratedNode;
|
|
100
|
+
}, {});
|
|
101
|
+
app.mount(root);
|
|
102
|
+
if (Previewable.play) {
|
|
103
|
+
try {
|
|
104
|
+
await Previewable.play({ canvasElement: root });
|
|
105
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
106
|
+
} catch (e: any) {
|
|
107
|
+
// For some reason, Storybook expects to throw exceptions that should be ignored.
|
|
108
|
+
if (!e.message?.startsWith("ignoredException")) {
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
jsxFactory: slotTransformingH,
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
120
|
+
function slotTransformingH(component: any, props: any, children: any) {
|
|
121
|
+
const localProps = props || {};
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
return h(
|
|
124
|
+
component,
|
|
125
|
+
Object.fromEntries(
|
|
126
|
+
Object.entries(localProps).filter(
|
|
127
|
+
([propName]) => !propName.startsWith("slot:")
|
|
128
|
+
)
|
|
129
|
+
),
|
|
130
|
+
children !== undefined
|
|
131
|
+
? children
|
|
132
|
+
: Object.fromEntries(
|
|
133
|
+
Object.entries(localProps)
|
|
134
|
+
.filter(([propName]) => propName.startsWith("slot:"))
|
|
135
|
+
.map(([propName, propValue]) => [
|
|
136
|
+
propName.substring(5),
|
|
137
|
+
() => propValue,
|
|
138
|
+
])
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-present, Yuxi (Evan) You
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @vue/compiler-core
|