Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: useStore & useVueImportMap composable #207

Merged
merged 7 commits into from
Jan 21, 2024
Merged

Conversation

sxzz
Copy link
Member

@sxzz sxzz commented Jan 12, 2024

  • Separate import map and store as two functions
    • useStore: keep most of the functionality, and refactor to composables
    • useVueImportMap: extract links of the Vue import map.

Copy link

vercel bot commented Jan 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
repl ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2024 10:50am

tsVersion: store.state.typescriptVersion,
tsLocale: store.state.typescriptLocale || store.state.locale,
tsVersion: store.typescriptVersion,
tsLocale: store.locale,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change: remove typescriptLocale, since it's already marked as deprecated.

imports.vue = runtimeUrl
imports['vue/server-renderer'] = ssrUrl
this.setImportMap(importMap)
this.forceSandboxReset()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed resetFlip flag. I tested vuejs/docs#1973 issue on Safari and works now.

I guess this issue is resolved, since sandbox will be re-created after import map is updated

@@ -15,7 +15,6 @@ export interface Props {
showImportMap?: boolean
showTsConfig?: boolean
clearConsole?: boolean
sfcOptions?: SFCOptions
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change: remove sfcOptions on component but moved to Store

for (const filename in store.state.files) {
const file = store.state.files[filename]
for (const filename in store.files) {
const file = store.files[filename]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change: remove state property and merged top level of Store

@@ -56,7 +56,7 @@ export async function compileFile(
const { errors, descriptor } = store.compiler.parse(code, {
filename,
sourceMap: true,
templateParseOptions: store.options?.template?.compilerOptions,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change: rename options to sfcOptions

dependencyVersion = ref(Object.create(null)),
reloadLanguageTools = ref(),
}: Partial<StoreState> = {},
serializedState?: string,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move serializedState as the second argument.

typescriptVersion = ref('latest'),
dependencyVersion = ref(Object.create(null)),
reloadLanguageTools = ref(),
}: Partial<StoreState> = {},
Copy link
Member Author

@sxzz sxzz Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed StoreOptions and merged to StoreState

Comment on lines -62 to -76
watchEffect(() => {
const { store } = props
const sfcOptions = (store.options = props.sfcOptions || {})
sfcOptions.script ||= {}
sfcOptions.script.fs = {
fileExists(file: string) {
if (file.startsWith('/')) file = file.slice(1)
return !!store.state.files[file]
},
readFile(file: string) {
if (file.startsWith('/')) file = file.slice(1)
return store.state.files[file].code
},
}
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to store

@@ -168,27 +169,15 @@ export async function compileFile(
}

// styles
const ceFilter = store.customElement
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed customElement option, now get it from sfcOptions.script.customElement.

@sxzz sxzz mentioned this pull request Jan 14, 2024
@sxzz sxzz merged commit d01bf55 into main Jan 21, 2024
2 checks passed
@sxzz sxzz deleted the refactor/use-store branch January 21, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant