-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bundle dependencies (vue, etc.), closes #87
- Loading branch information
Showing
54 changed files
with
989 additions
and
475 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
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
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
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
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
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
81 changes: 81 additions & 0 deletions
81
packages/histoire-plugin-vue/src/client/app/MountStoryVue3.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* eslint-disable vue/one-component-per-file */ | ||
|
||
import { App, createApp, h, Suspense } from 'vue' | ||
import { | ||
defineComponent as _defineComponent, | ||
PropType as _PropType, | ||
onMounted as _onMounted, | ||
onUnmounted as _onUnmounted, | ||
ref as _ref, | ||
watch as _watch, | ||
h as _h, | ||
} from '@histoire/vendors/dist/client/vue' | ||
import type { Story } from '@histoire/shared' | ||
import { registerGlobalComponents } from './global-components.js' | ||
import { RouterLinkStub } from './RouterLinkStub' | ||
|
||
export default _defineComponent({ | ||
name: 'MountStoryVue3', | ||
|
||
props: { | ||
story: { | ||
type: Object as _PropType<Story>, | ||
required: true, | ||
}, | ||
}, | ||
|
||
setup (props) { | ||
const el = _ref<HTMLDivElement>() | ||
let app: App | ||
|
||
async function mountStory () { | ||
app = createApp({ | ||
name: 'MountStoryVue3', | ||
|
||
render: () => { | ||
return h(Suspense, [ | ||
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) | ||
} | ||
|
||
function unmountStory () { | ||
app?.unmount() | ||
} | ||
|
||
_watch(() => props.story.id, async () => { | ||
unmountStory() | ||
await mountStory() | ||
}) | ||
|
||
_onMounted(async () => { | ||
await mountStory() | ||
}) | ||
|
||
_onUnmounted(() => { | ||
unmountStory() | ||
}) | ||
|
||
return { | ||
el, | ||
} | ||
}, | ||
|
||
render () { | ||
return _h('div', { | ||
ref: 'el', | ||
}) | ||
}, | ||
}) |
46 changes: 0 additions & 46 deletions
46
packages/histoire-plugin-vue/src/client/app/MountStoryVue3.vue
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.