Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit e38fb8a

Browse files
authored
Merge branch 'main' into issue-expired-status-delay
2 parents afa5f80 + 47d8d28 commit e38fb8a

File tree

64 files changed

+612
-812
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+612
-812
lines changed

.github/diagram.svg

Lines changed: 1 addition & 1 deletion
Loading

assets/styles/abstracts/_variables.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,6 @@ $placeholder-color: #cccccc;
155155
$search-background-color: #1a1718;
156156
$select-border-color: #7d7d7d;
157157

158-
$frosted-glass-background: rgba(12, 12, 12, 0.7);
159-
$frosted-glass-background-dark: #b0b0b0ad;
160-
$frosted-glass-backdrop-filter: blur(20px);
161-
$frosted-glass-light-backdrop-filter: blur(4px);
162-
163158
$sleek-primary-border: 1px solid $primary;
164159

165160
$table-sticky-header-height: 60vh;

components/MessageNotify.vue

Lines changed: 0 additions & 70 deletions
This file was deleted.

components/codeChecker/massPreview/Canvas.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,8 @@ const generateMassPreview = () => {
6666
}))
6767
}
6868
69-
useEventListener(window, 'message', async (res) => {
70-
const hash = res.data.payload.hash
71-
if (
72-
res.data?.type === 'kodahash/render/completed'
73-
&& canvasPreviews.value.map(p => p.hash).includes(hash)
74-
) {
69+
onKodahashRenderCompleted(({ payload: { hash } }) => {
70+
if (canvasPreviews.value.map(p => p.hash).includes(hash)) {
7571
canvasPreviews.value = canvasPreviews.value.map(preview =>
7672
preview.hash === hash
7773
? { ...preview, renderedAt: performance.now(), loading: false }
Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import type { ZipEntry } from 'unzipit'
22
import { unzip } from 'unzipit'
33
import { blake2AsHex } from '@polkadot/util-crypto'
4-
import config from './codechecker.config'
5-
import type { AssetMessage } from './types'
4+
import config from '../codechecker.config'
5+
import type { AssetMessage } from '../types'
6+
import { hasFileProcessing, processFile } from './processing'
67

78
type FileEntry = { path: string, content: string }
89

9-
const cleanFileName = (path) => {
10+
const cleanFileName = (path): string => {
1011
const parts = path.split('/')
1112
return parts[parts.length - 1] // Returns only the file name
1213
}
1314

14-
const createBlobUrlForEntry = async (entry, mimeType) => {
15+
const createBlobUrlForEntry = async (entry: ZipEntry, mimeType: string) => {
1516
const blob = await entry.blob()
1617
const typedBlob = new Blob([blob], { type: mimeType })
1718
return URL.createObjectURL(typedBlob)
@@ -39,8 +40,7 @@ const extractAssetAttributes = (
3940
// process and add a single asset to the assets array
4041
const processAsset = async (element, entries, assets) => {
4142
const attributes = extractAssetAttributes(element)
42-
const assetType
43-
= element.tagName.toLowerCase() === 'script' ? 'script' : 'style'
43+
const assetType = element.tagName.toLowerCase() === 'script' ? 'script' : 'style'
4444

4545
const asset: AssetMessage = {
4646
type: assetType,
@@ -55,15 +55,28 @@ const processAsset = async (element, entries, assets) => {
5555
}
5656

5757
const cleanName = cleanFileName(attributes.srcOrHref)
58-
const matchingEntryKey = Object.keys(entries).find(key =>
59-
key.endsWith(cleanName),
60-
)
58+
const matchingEntryKey = Object
59+
.keys(entries)
60+
.find(key => key.endsWith(cleanName))
6161

62-
if (matchingEntryKey) {
63-
const blobUrl = await createBlobUrlForEntry(
64-
entries[matchingEntryKey],
65-
attributes.mimeType,
66-
)
62+
if (!matchingEntryKey) {
63+
return
64+
}
65+
66+
const entry = entries[matchingEntryKey] as ZipEntry
67+
68+
if (hasFileProcessing(cleanName)) {
69+
const blobUrl = await processFile({
70+
entry,
71+
entries,
72+
mimeType: attributes.mimeType,
73+
fileName: cleanName,
74+
})
75+
asset.src = blobUrl
76+
assets.push(asset)
77+
}
78+
else {
79+
const blobUrl = await createBlobUrlForEntry(entry, attributes.mimeType)
6780
asset.src = blobUrl
6881
assets.push(asset)
6982
}
@@ -162,7 +175,7 @@ export const extractAssetsFromZip = async (
162175
export const createSandboxAssets = async (
163176
indexFile: FileEntry,
164177
entries: { [key: string]: ZipEntry },
165-
) => {
178+
): Promise<Array<AssetMessage>> => {
166179
const assets: Array<AssetMessage> = []
167180
const htmlContent = indexFile.content
168181
const parser = new DOMParser()
@@ -175,6 +188,7 @@ export const createSandboxAssets = async (
175188
for (const element of assetElements) {
176189
await processAsset(element, entries, assets)
177190
}
191+
178192
return assets
179193
}
180194

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import type { ZipEntry } from 'unzipit'
2+
import config from '../codechecker.config'
3+
import { getObjectUrl, getUpload, uploadFile } from '@/services/playground'
4+
import { getCorsProxiedUrl } from '@/services/cors-proxy'
5+
6+
type FileProcessingHandler = {
7+
processInstance: (params: { content: string, entry: ZipEntry, entries: Record<string, ZipEntry> }) => Promise<string>
8+
findAll: (content: string) => RegExpMatchArray | null
9+
}
10+
11+
const loadTableHandler: FileProcessingHandler = {
12+
findAll: (content: string) => content.match(/loadTable\([^)]+\)/g),
13+
processInstance: async ({ content, entries }) => {
14+
const match = content.match(/loadTable\(['"]([^'"]*)['"](.*?)\)/)
15+
16+
if (!match) {
17+
return content
18+
}
19+
20+
const [, fileUrl = '', params = ''] = match
21+
22+
if (fileUrl.includes('http')) {
23+
return content
24+
}
25+
26+
const file = entries[fileUrl] as ZipEntry
27+
28+
if (!file) {
29+
return content
30+
}
31+
32+
const { key } = await uploadFile({
33+
file: await file.blob(),
34+
fileName: fileUrl,
35+
prefix: 'codeChecker',
36+
})
37+
38+
await exponentialBackoff(() => getUpload(key)).catch(console.log)
39+
40+
// proxy fixes issue with cors
41+
const url = getCorsProxiedUrl(getObjectUrl(key))
42+
43+
return `loadTable("${url}"${params})`
44+
},
45+
}
46+
47+
const fileHandlers: Record<string, FileProcessingHandler[]> = {
48+
[config.sketchFile]: [
49+
loadTableHandler,
50+
],
51+
}
52+
53+
const processFileHandler = async ({ content, entry, handler, entries }: { content: string, entry: ZipEntry, entries: Record<string, ZipEntry>, handler: FileProcessingHandler }): Promise<string> => {
54+
const matches = handler.findAll(content)
55+
56+
if (!matches) return content
57+
58+
let updatedContent = content
59+
60+
for (const match of matches) {
61+
const replacement = await handler.processInstance({
62+
entry,
63+
content: updatedContent,
64+
entries,
65+
})
66+
67+
updatedContent = updatedContent.replace(match, replacement)
68+
}
69+
70+
return updatedContent
71+
}
72+
73+
export const processFile = async ({
74+
entry,
75+
mimeType,
76+
entries,
77+
fileName,
78+
}: {
79+
entry: ZipEntry
80+
mimeType: string
81+
entries: Record<string, ZipEntry>
82+
fileName: string
83+
},
84+
): Promise<string> => {
85+
let content = await entry.text()
86+
87+
for (const handler of fileHandlers[fileName]) {
88+
if (handler.findAll(content)) {
89+
content = await processFileHandler({ handler, content, entry, entries })
90+
}
91+
}
92+
93+
return URL.createObjectURL(new Blob([content], { type: mimeType }))
94+
}
95+
96+
export const hasFileProcessing = (fileName: string): boolean => {
97+
return fileHandlers[fileName] !== undefined
98+
}

components/common/ChooseCollectionDropdown.vue

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,27 +137,18 @@ watch(collectionsEntites, handleCollectionsChange, { immediate: true })
137137
</script>
138138

139139
<style lang="scss" scoped>
140-
@import '@/assets/styles/abstracts/variables';
141-
142140
.dropdown-width {
143141
width: 30rem;
142+
143+
@apply bulma-mobile:w-full;
144144
}
145145
146146
.full-width {
147147
width: 100%;
148+
148149
.dropdown-width,
149150
:deep(.o-drop__menu) {
150151
width: 100%;
151152
}
152153
}
153-
154-
@include mobile {
155-
.dropdown-width {
156-
width: 100%;
157-
}
158-
159-
.mobile-width {
160-
min-width: 6rem;
161-
}
162-
}
163154
</style>

components/common/ConnectWallet/WalletAssetMenu.vue

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ const closeModal = () => {
116116
</script>
117117

118118
<style lang="scss" scoped>
119-
@import '@/assets/styles/abstracts/variables';
120-
121119
.wallet-asset-menu {
122120
display: flex;
123121
justify-content: space-between;
@@ -132,28 +130,24 @@ const closeModal = () => {
132130
.wallet-asset-footer {
133131
border-top: 1px solid grey;
134132
justify-content: space-between;
135-
@include mobile {
136-
justify-content: center;
137-
.language-selector {
138-
margin: 0 2rem;
139-
}
133+
134+
@apply bulma-mobile:justify-center;
135+
136+
.language-selector {
137+
@apply bulma-mobile:my-8 bulma-mobile:mx-0;
140138
}
141139
142140
& > * {
143141
@apply cursor-pointer flex gap-1;
144142
145143
&:hover {
146-
@include ktheme() {
147-
color: theme('text-color');
148-
}
144+
@apply text-text-color;
149145
}
150146
}
151147
152-
@include tablet {
153-
// manually center dropdown menu, because no props "postition" to center it
154-
:deep(.o-drop__menu) {
155-
transform: translateX(50px);
156-
}
148+
/* manually center dropdown menu, because no props "position" to center it */
149+
:deep(.o-drop__menu) {
150+
@apply bulma-tablet:translate-x-[50px]
157151
}
158152
}
159153
</style>

components/common/ConnectWallet/WalletAssetNfts.vue

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,17 @@ watchEffect(() => {
6060
</script>
6161

6262
<style lang="scss" scoped>
63-
@import '@/assets/styles/abstracts/variables';
64-
6563
.nfts {
6664
display: grid;
6765
grid-template-columns: repeat(3, minmax(0, 1fr));
6866
gap: 1rem;
6967
7068
& > * {
71-
@include ktheme() {
72-
border: 1px solid theme('k-grey');
69+
border: 1px solid var(--k-grey);
7370
74-
&:hover {
75-
border-color: theme('border-color');
76-
opacity: 0.85;
77-
}
71+
&:hover {
72+
border-color: var(--border-color);
73+
opacity: 0.85;
7874
}
7975
}
8076
}

components/common/autoTeleport/AutoTeleportModal.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,6 @@ watchDebounced(
336336
</script>
337337

338338
<style lang="scss" scoped>
339-
@import '@/assets/styles/abstracts/variables';
340-
341339
.btn-height {
342340
height: 3.5rem;
343341
}

0 commit comments

Comments
 (0)