-
Notifications
You must be signed in to change notification settings - Fork 454
fix: 修复preview生产打包的时候repl引入的monaco-editor里的worker跨域报错 #245
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
Merged
chilingling
merged 10 commits into
opentiny:develop
from
rhlin:fix-preview-repl-monaco-worker-cross-domain-error
Feb 26, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
56766c3
fix: 修复preview生产打包的时候repl引入的monaco-editor里的worker跨域报错
rhlin 456b1d8
fix: 通过patch解决生产打包后worker.js需要同个域名问题
rhlin 08c1fc6
fix: 解决开发态 @vue/repl monaco编辑器worker相对地址问题
rhlin 2734e70
feat(design-core/preview): 预览增加调试按钮来打开vue-repl编辑模式,并实现编辑器懒加载
rhlin 295af13
fix(design-core/preview): 修复repl-patch引入脚本路径
rhlin e46bcef
fix(design-core/preview): 修复repl-patch引入脚本路径模块化不支持importScripts问题
rhlin 431f703
fix(design-core/preview): patch repl 脚本,增加允许下载
rhlin c510fde
fix(design-core): esbuild-plugin-copy换到devDependencies
rhlin 2407b00
fix(design-core/preview): 调整调试模式文本样式
rhlin df4dd6e
fix(design-core/preview): 调整调试模式容器高度,去掉无用的css属性
rhlin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
10 changes: 10 additions & 0 deletions
10
packages/design-core/src/preview/src/preview/debugSwitch.js
This file contains hidden or 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,10 @@ | ||
| import { ref, provide, inject } from 'vue' | ||
| export const debuggerSwitchTokenKey = Symbol('tiny-engine-preview-debug-switch') | ||
| export function useDebugSwitch() { | ||
| const debugSwitch = ref(false) | ||
| provide(debuggerSwitchTokenKey, debugSwitch) | ||
| return debugSwitch | ||
| } | ||
| export function injectDebugSwitch() { | ||
| return inject(debuggerSwitchTokenKey) | ||
| } |
This file contains hidden or 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 hidden or 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,50 @@ | ||
| diff --git a/dist/chunks/MonacoEditor-KSgTEMrh.js b/dist/chunks/MonacoEditor-KSgTEMrh.js | ||
| index c9668cbf8c44ba3c816246b746127204839f8349..e893c59a432e53372c18aa2e70d7b7bb9fd666ba 100644 | ||
| --- a/dist/chunks/MonacoEditor-KSgTEMrh.js | ||
| +++ b/dist/chunks/MonacoEditor-KSgTEMrh.js | ||
| @@ -1,5 +1,13 @@ | ||
| import { watchEffect, defineComponent, ref, shallowRef, inject, computed, onMounted, nextTick, watch, onBeforeUnmount, openBlock, createElementBlock, createBlock } from 'vue'; | ||
| import { c as commonjsGlobal, a as getAugmentedNamespace } from './_commonjsHelpers-9Q-OoQuc.js'; | ||
| +function getWorkerURL(url){ | ||
| + if (typeof document !== 'undefined' && document.location && document.location.origin !== url.origin) { | ||
| + return URL.createObjectURL(new Blob([`import '${url.href}'`], { | ||
| + type: 'application/javascript' | ||
| + })) | ||
| + } | ||
| + return url.href; | ||
| +} | ||
|
|
||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| @@ -170640,7 +170648,7 @@ var languages; | ||
|
|
||
| function WorkerWrapper$1(options) { | ||
| return new Worker( | ||
| - ""+new URL('../assets/editor.worker-FXpxnIqv.js', import.meta.url).href+"", | ||
| + ""+getWorkerURL(new URL('../assets/editor.worker-FXpxnIqv.js', import.meta.url))+"", | ||
| { | ||
| type: "module", | ||
| name: options?.name | ||
| @@ -172020,7 +172028,7 @@ function getOrCreateModel(uri, lang, value) { | ||
|
|
||
| function WorkerWrapper(options) { | ||
| return new Worker( | ||
| - ""+new URL('../assets/vue.worker-eqEbSb3e.js', import.meta.url).href+"", | ||
| + ""+getWorkerURL(new URL('../assets/vue.worker-eqEbSb3e.js', import.meta.url))+"", | ||
| { | ||
| type: "module", | ||
| name: options?.name | ||
| diff --git a/dist/vue-repl.js b/dist/vue-repl.js | ||
| index 43bfd22a1a7d6f831e3f85228d809750317c4bfb..d5f5cb335533295c63e4cfa8aaa02770d16babca 100644 | ||
| --- a/dist/vue-repl.js | ||
| +++ b/dist/vue-repl.js | ||
| @@ -528,7 +528,8 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({ | ||
| "allow-popups", | ||
| "allow-same-origin", | ||
| "allow-scripts", | ||
| - "allow-top-navigation-by-user-activation" | ||
| + "allow-top-navigation-by-user-activation", | ||
| + "allow-downloads" | ||
| ].join(" ") | ||
| ); | ||
| const importMap = store.getImportMap(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.