Merge branch 'monaco-editor-lib-import-reactity-fix' into 'development'
Fix Reactivity issue with library imports when changing version See merge request GeneralProtocols/xo/stack!109
This commit is contained in:
@@ -33,7 +33,7 @@ const emit = defineEmits<{
|
|||||||
(e: 'execute'): void;
|
(e: 'execute'): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
watch(() => props.libs, async () => {
|
watch(props.libs, async () => {
|
||||||
updateEditorTypes();
|
updateEditorTypes();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div v-if="showLogs || fullHeight" class="output-container" :style="outputContainerStyle">
|
<div v-if="showLogs || fullHeight" class="output-container" :style="outputContainerStyle">
|
||||||
<div class="output-container-buttons">
|
<div class="output-container-buttons">
|
||||||
<button v-if="!fullHeight" @click="showLogs = false" class="secondary-button">Close</button>
|
<button v-if="!fullHeight" @click="showLogs = false" class="secondary-button">Close</button>
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useData } from 'vitepress';
|
import { useData } from 'vitepress';
|
||||||
import { ref, onMounted, onBeforeUnmount, computed, version } from 'vue';
|
import { ref, onMounted, onBeforeUnmount, computed } from 'vue';
|
||||||
|
|
||||||
// Import the iframe HTML template
|
// Import the iframe HTML template
|
||||||
// NOTE: Having this in an external file is many-fold neater than stashing it all in here.
|
// NOTE: Having this in an external file is many-fold neater than stashing it all in here.
|
||||||
@@ -79,8 +80,7 @@ interface ConsoleLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define share URL base
|
// Define share URL base
|
||||||
// const SHARE_BASE_URL = 'https://stack.xo.cash/playground.html';
|
const SHARE_BASE_URL = 'https://stack.xo.cash/playground.html';
|
||||||
const SHARE_BASE_URL = 'http://localhost:5173/playground.html';
|
|
||||||
|
|
||||||
// Define a unique ID to pass into the IFrame.
|
// Define a unique ID to pass into the IFrame.
|
||||||
// NOTE: We do this so that we can reliably identify where the postMessage came from.
|
// NOTE: We do this so that we can reliably identify where the postMessage came from.
|
||||||
@@ -406,6 +406,7 @@ defineExpose({
|
|||||||
right: 0px;
|
right: 0px;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
z-index: 1001; /* Monaco's editor is z-index 1000, so we need to be above it */
|
||||||
}
|
}
|
||||||
|
|
||||||
.output-container {
|
.output-container {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
outputHeight="20%"
|
outputHeight="20%"
|
||||||
fullHeight
|
fullHeight
|
||||||
hideRunButton
|
hideRunButton
|
||||||
:libs="libs"
|
:libs="xocashLibs"
|
||||||
:isDark="isDark"
|
:isDark="isDark"
|
||||||
>
|
>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useData } from 'vitepress';
|
import { useData } from 'vitepress';
|
||||||
|
|
||||||
import { useXOCashLibs } from '../utils/useXOCashLibs';
|
import { useXOCashLibs } from '../utils/useXOCashLibs';
|
||||||
@@ -38,10 +38,6 @@ import CodeSandbox from './CodeSandbox.vue'
|
|||||||
|
|
||||||
const xocashLibs = useXOCashLibs();
|
const xocashLibs = useXOCashLibs();
|
||||||
|
|
||||||
const libs = computed(() => {
|
|
||||||
return { ...xocashLibs }
|
|
||||||
});
|
|
||||||
|
|
||||||
const { isDark } = useData();
|
const { isDark } = useData();
|
||||||
|
|
||||||
const sandbox = ref<InstanceType<typeof CodeSandbox> | null>(null);
|
const sandbox = ref<InstanceType<typeof CodeSandbox> | null>(null);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export type ImportedLib = {
|
|||||||
export type XOCashLibs = {
|
export type XOCashLibs = {
|
||||||
'@xocash/stack': ImportedLib;
|
'@xocash/stack': ImportedLib;
|
||||||
'@xocash/primitives': ImportedLib;
|
'@xocash/primitives': ImportedLib;
|
||||||
}
|
};
|
||||||
|
|
||||||
const xocashLibs = reactive<XOCashLibs>({
|
const xocashLibs = reactive<XOCashLibs>({
|
||||||
'@xocash/stack': {
|
'@xocash/stack': {
|
||||||
@@ -64,8 +64,14 @@ export const useXOCashLibs = (): XOCashLibs => {
|
|||||||
// Fetch the versions and set the selected version when the component is mounted.
|
// Fetch the versions and set the selected version when the component is mounted.
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
xocashLibs['@xocash/stack'].versions = await getVersions();
|
xocashLibs['@xocash/stack'].versions = await getVersions();
|
||||||
|
|
||||||
|
// Only update the selected version if it is not already set.
|
||||||
|
if (!xocashLibs['@xocash/stack'].selectedVersion) {
|
||||||
xocashLibs['@xocash/stack'].selectedVersion =
|
xocashLibs['@xocash/stack'].selectedVersion =
|
||||||
xocashLibs['@xocash/stack'].versions[xocashLibs['@xocash/stack'].versions.length - 1];
|
xocashLibs['@xocash/stack'].versions[
|
||||||
|
xocashLibs['@xocash/stack'].versions.length - 1
|
||||||
|
];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return xocashLibs;
|
return xocashLibs;
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ The below is Address mess.
|
|||||||
height="50em"
|
height="50em"
|
||||||
editorHeight="30em"
|
editorHeight="30em"
|
||||||
outputHeight="20em"
|
outputHeight="20em"
|
||||||
fullHeight
|
fullHeight>
|
||||||
>
|
|
||||||
|
|
||||||
```
|
```
|
||||||
import { Address } from '@xocash/stack';
|
import { Address } from '@xocash/stack';
|
||||||
@@ -59,8 +58,7 @@ We can have more than one per page too. For example:
|
|||||||
height="50em"
|
height="50em"
|
||||||
editorHeight="30em"
|
editorHeight="30em"
|
||||||
outputHeight="20em"
|
outputHeight="20em"
|
||||||
fullHeight
|
fullHeight>
|
||||||
>
|
|
||||||
|
|
||||||
```
|
```
|
||||||
import { BlockchainElectrum } from '@xocash/stack';
|
import { BlockchainElectrum } from '@xocash/stack';
|
||||||
@@ -87,8 +85,7 @@ The below demonstrates instantiating a wallet.
|
|||||||
height="50em"
|
height="50em"
|
||||||
editorHeight="30em"
|
editorHeight="30em"
|
||||||
outputHeight="20em"
|
outputHeight="20em"
|
||||||
fullHeight
|
fullHeight>
|
||||||
>
|
|
||||||
|
|
||||||
```
|
```
|
||||||
import { BlockchainElectrum, WalletP2PKH } from '@xocash/stack';
|
import { BlockchainElectrum, WalletP2PKH } from '@xocash/stack';
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ export class Script {
|
|||||||
// Attempt to compile the script called "main"
|
// Attempt to compile the script called "main"
|
||||||
const compilationResult = compiler.generateBytecode<true>({
|
const compilationResult = compiler.generateBytecode<true>({
|
||||||
data: {
|
data: {
|
||||||
...data,
|
bytecode: data,
|
||||||
},
|
},
|
||||||
scriptId: '_main',
|
scriptId: '_main',
|
||||||
debug: true,
|
debug: true,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export default defineConfig({
|
|||||||
input: 'dist/index.d.ts',
|
input: 'dist/index.d.ts',
|
||||||
output: {
|
output: {
|
||||||
file: 'dist/types-bundled.d.ts',
|
file: 'dist/types-bundled.d.ts',
|
||||||
format: 'es'
|
format: 'es',
|
||||||
},
|
},
|
||||||
plugins: [dts()],
|
plugins: [dts()],
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user