-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
64 changed files
with
644 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ export default defineConfig({ | |
|
||
rollupOptions: { | ||
external: [ | ||
/@histoire/, | ||
'vue', | ||
], | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
// https://github.com/microsoft/TypeScript/issues/33079 | ||
export * from './dist/client/client' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
// https://github.com/microsoft/TypeScript/issues/33079 | ||
export * from './dist/client/server' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "@histoire/plugin-vue", | ||
"version": "0.7.3", | ||
"description": "Histoire plugin for Vue.js support", | ||
"license": "MIT", | ||
"author": { | ||
"name": "Guillaume Chau" | ||
}, | ||
"repository": { | ||
"url": "https://github.com/Akryum/histoire.git", | ||
"type": "git", | ||
"directory": "packages/histoire-plugin-vue" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"type": "module", | ||
"exports": { | ||
"./client": { | ||
"import": "./dist/bundled/client.js", | ||
"types": "./dist/client/client.d.ts" | ||
}, | ||
"./collect": { | ||
"import": "./dist/bundled/server.js", | ||
"types": "./dist/client/server.d.ts" | ||
}, | ||
"./*": "./*" | ||
}, | ||
"scripts": { | ||
"build": "rimraf dist && vite build && pnpm run build:types", | ||
"build:types": "vue-tsc --declaration --emitDeclarationOnly", | ||
"watch": "concurrently \"vite build --watch\" \"pnpm run build:types --watch\"" | ||
}, | ||
"dependencies": { | ||
"@histoire/controls": "workspace:^", | ||
"@histoire/shared": "workspace:^" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^2.3.1", | ||
"typescript": "^4.6.3", | ||
"vite": "^2.9.1", | ||
"vue": "^3.2.31", | ||
"vue-tsc": "^0.35.2" | ||
}, | ||
"peerDependencies": { | ||
"histoire": "workspace:^", | ||
"vue": "^3.2.31" | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
packages/histoire-plugin-vue/src/client/app/MountStoryVue3.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<script lang="ts" setup> | ||
import { App, createApp, h, onMounted, onUnmounted, ref } from 'vue' | ||
import type { Story } from '@histoire/shared' | ||
import { registerGlobalComponents } from './global-components.js' | ||
import { RouterLinkStub } from './RouterLinkStub' | ||
const props = defineProps<{ | ||
story: Story | ||
}>() | ||
const el = ref<HTMLDivElement>() | ||
let app: App | ||
async function mountStory () { | ||
app = createApp({ | ||
name: 'MountStoryVue3', | ||
render: () => { | ||
return h(props.story.file.component, { | ||
story: props.story, | ||
}) | ||
}, | ||
}) | ||
registerGlobalComponents(app) | ||
// Stubs | ||
app.component('RouterLink', RouterLinkStub) | ||
const target = document.createElement('div') | ||
el.value.appendChild(target) | ||
app.mount(target) | ||
} | ||
onMounted(async () => { | ||
await mountStory() | ||
}) | ||
onUnmounted(() => { | ||
app?.unmount() | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div ref="el" /> | ||
</template> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...c/client/app/components/exposed/Story.vue → ...toire-plugin-vue/src/client/app/Story.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...client/app/components/exposed/Variant.vue → ...ire-plugin-vue/src/client/app/Variant.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...toire/src/client/app/global-components.ts → ...n-vue/src/client/app/global-components.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as SandboxVue3 } from './SandboxVue3.vue' | ||
export { default as MountStoryVue3 } from './MountStoryVue3.vue' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { unref, isRef } from 'vue' | ||
|
||
const isObject = (val) => val !== null && typeof val === 'object' | ||
|
||
export function toRawDeep (val, seen = new Set()) { | ||
const unwrappedValue = isRef(val) ? unref(val) : val | ||
|
||
if (seen.has(unwrappedValue)) { | ||
return Array.isArray(unwrappedValue) ? [] : {} | ||
} | ||
|
||
seen.add(unwrappedValue) | ||
|
||
if (!isObject(unwrappedValue)) { | ||
return unwrappedValue | ||
} | ||
|
||
if (Array.isArray(unwrappedValue)) { | ||
return unwrappedValue.map(value => toRawDeep(value, seen)) | ||
} | ||
|
||
return toRawObject(unwrappedValue, seen) | ||
} | ||
|
||
const toRawObject = (obj: Record<any, any>, seen = new Set()) => Object.keys(obj).reduce((raw, key) => { | ||
raw[key] = toRawDeep(obj[key], seen) | ||
return raw | ||
}, {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './app/index.js' | ||
export * from './codegen.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './server/run.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/histoire/src/client/server/vue3/run.ts → ...toire-plugin-vue/src/client/server/run.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// <reference types="vite/client" /> | ||
|
||
declare module '*.vue' { | ||
import { ComponentOptions } from 'vue' | ||
const comp: ComponentOptions | ||
export default comp | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "node", | ||
"outDir": "dist", | ||
"rootDir": "src", | ||
"allowSyntheticDefaultImports": true, | ||
"esModuleInterop": true, | ||
"removeComments": false, | ||
"resolveJsonModule": true, | ||
"skipLibCheck": true, | ||
"types": [ | ||
"node", | ||
"@peeky/test" | ||
], | ||
"lib": [ | ||
"ESNext", | ||
"DOM" | ||
], | ||
"sourceMap": false, | ||
"preserveWatchOutput": true, | ||
"preserveSymlinks": true, | ||
// Strict | ||
"noImplicitAny": false, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
"strictBindCallApply": true, | ||
"strictFunctionTypes": true, | ||
// Volar | ||
"jsx": "preserve", | ||
}, | ||
"include": [ | ||
"src" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"generated/**/*", | ||
"dist/**/*", | ||
"src/**/*.spec.ts" | ||
] | ||
} |
Oops, something went wrong.