2019-10-05 05:43:20 +08:00
|
|
|
import { h, reactive, createApp } from '@vue/runtime-dom'
|
|
|
|
import { CompilerOptions } from '@vue/compiler-dom'
|
|
|
|
|
|
|
|
export const compilerOptions: CompilerOptions = reactive({
|
|
|
|
mode: 'module',
|
|
|
|
prefixIdentifiers: false,
|
2019-10-19 09:51:34 +08:00
|
|
|
hoistStatic: false,
|
|
|
|
cacheHandlers: false
|
2019-10-05 05:43:20 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
const App = {
|
|
|
|
setup() {
|
|
|
|
return () => [
|
|
|
|
h('h1', `Vue 3 Template Explorer`),
|
2019-10-05 10:40:54 +08:00
|
|
|
h(
|
|
|
|
'a',
|
|
|
|
{
|
|
|
|
href: `https://github.com/vuejs/vue-next/tree/${__COMMIT__}`,
|
|
|
|
target: `_blank`
|
|
|
|
},
|
|
|
|
`@${__COMMIT__}`
|
|
|
|
),
|
2019-10-05 05:43:20 +08:00
|
|
|
h('div', { id: 'options' }, [
|
|
|
|
// mode selection
|
|
|
|
h('span', { class: 'options-group' }, [
|
|
|
|
h('span', { class: 'label' }, 'Mode:'),
|
|
|
|
h('input', {
|
|
|
|
type: 'radio',
|
|
|
|
id: 'mode-module',
|
|
|
|
name: 'mode',
|
|
|
|
checked: compilerOptions.mode === 'module',
|
|
|
|
onChange() {
|
|
|
|
compilerOptions.mode = 'module'
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
h('label', { for: 'mode-module' }, 'module'),
|
|
|
|
h('input', {
|
|
|
|
type: 'radio',
|
|
|
|
id: 'mode-function',
|
|
|
|
name: 'mode',
|
|
|
|
checked: compilerOptions.mode === 'function',
|
|
|
|
onChange() {
|
|
|
|
compilerOptions.mode = 'function'
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
h('label', { for: 'mode-function' }, 'function')
|
|
|
|
]),
|
|
|
|
|
|
|
|
// toggle prefixIdentifiers
|
|
|
|
h('input', {
|
|
|
|
type: 'checkbox',
|
|
|
|
id: 'prefix',
|
|
|
|
disabled: compilerOptions.mode === 'module',
|
|
|
|
checked:
|
|
|
|
compilerOptions.prefixIdentifiers ||
|
|
|
|
compilerOptions.mode === 'module',
|
2019-10-06 23:55:23 +08:00
|
|
|
onChange(e: Event) {
|
2019-10-05 05:43:20 +08:00
|
|
|
compilerOptions.prefixIdentifiers =
|
2019-10-06 23:55:23 +08:00
|
|
|
(<HTMLInputElement>e.target).checked ||
|
|
|
|
compilerOptions.mode === 'module'
|
2019-10-05 05:43:20 +08:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
h('label', { for: 'prefix' }, 'prefixIdentifiers'),
|
|
|
|
|
|
|
|
// toggle hoistStatic
|
|
|
|
h('input', {
|
|
|
|
type: 'checkbox',
|
|
|
|
id: 'hoist',
|
|
|
|
checked: compilerOptions.hoistStatic,
|
2019-10-06 23:55:23 +08:00
|
|
|
onChange(e: Event) {
|
|
|
|
compilerOptions.hoistStatic = (<HTMLInputElement>e.target).checked
|
2019-10-05 05:43:20 +08:00
|
|
|
}
|
|
|
|
}),
|
2019-10-19 09:51:34 +08:00
|
|
|
h('label', { for: 'hoist' }, 'hoistStatic'),
|
|
|
|
|
|
|
|
// toggle cacheHandlers
|
|
|
|
h('input', {
|
|
|
|
type: 'checkbox',
|
|
|
|
id: 'cache',
|
|
|
|
checked:
|
|
|
|
compilerOptions.cacheHandlers && compilerOptions.prefixIdentifiers,
|
|
|
|
disabled: !compilerOptions.prefixIdentifiers,
|
|
|
|
onChange(e: Event) {
|
|
|
|
compilerOptions.cacheHandlers = (<HTMLInputElement>e.target).checked
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
h('label', { for: 'cache' }, 'cacheHandlers')
|
2019-10-05 05:43:20 +08:00
|
|
|
])
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function initOptions() {
|
2019-10-06 23:55:23 +08:00
|
|
|
createApp().mount(App, document.getElementById('header')!)
|
2019-10-05 05:43:20 +08:00
|
|
|
}
|