Skip to content

Commit d2729ec

Browse files
committed
chore: build
1 parent b78b137 commit d2729ec

File tree

11 files changed

+186
-58
lines changed

11 files changed

+186
-58
lines changed

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Install deps
4040
run: bun i
4141
- name: Build
42-
run: bun run build --base="${{ steps.pages.outputs.base_path }}/"
42+
run: bun run build:playground --base="${{ steps.pages.outputs.base_path }}/"
4343
- name: Upload artifact
4444
uses: actions/upload-pages-artifact@v3
4545
with:

deno.lock

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,54 @@
11
{
2-
"name": "scratch-gui",
2+
"name": "bslash",
33
"version": "5.1.12",
44
"type": "module",
55
"description": "Graphical User Interface for creating and running Scratch 3.0 projects",
66
"author": "Massachusetts Institute of Technology",
77
"license": "AGPL-3.0-only",
8-
"homepage": "https://github.com/scratchfoundation/scratch-gui#readme",
8+
"homepage": "https://github.com/evex-dev/bslash",
99
"repository": {
1010
"type": "git",
11-
"url": "https://github.com/scratchfoundation/scratch-gui.git"
11+
"url": "https://github.com/evex-dev/bslash.git"
1212
},
13+
"exports": {
14+
".": {
15+
"import": "./dist/mod.js",
16+
"types": "./dist/types/mod.d.ts"
17+
},
18+
"./css": "./dist/bslash.css"
19+
},
20+
"files": [
21+
"dist",
22+
"README.md",
23+
"LICENSE",
24+
"TRADEMARK"
25+
],
1326
"scripts": {
1427
"dev": "vite",
15-
"build": "vite build"
28+
"build:js": "vite build",
29+
"build:types": "tsc --project tsconfig.build.json",
30+
"build:lib": "deno run build:js && deno run build:types",
31+
"build:playground": "PLAYGROUND=true vite build"
1632
},
1733
"dependencies": {
34+
"react": "^16.14.0",
35+
"react-dom": "^16.14.0",
36+
"react-virtualized": "^9.22.5",
37+
"redux": "^3.7.2",
38+
"react-redux": "^5.1.2"
39+
},
40+
"devDependencies": {
41+
"typescript": "^5.7.2",
42+
"react-intl": "^2.9.0",
1843
"@evex-dev/scratch-paint": "^0.1.1",
44+
"@turbowarp/types": "^0.0.12",
45+
"@types/bun": "latest",
46+
"@types/react": "^19.0.2",
47+
"@vitejs/plugin-react-swc": "^3.7.2",
48+
"esbuild": "^0.24.2",
49+
"jest": "21.2.1",
50+
"vite": "^6.0.6",
51+
"xhr": "^2.6.0",
1952
"@evex/scratch-blocks": "npm:@jsr/evex__scratch-blocks@^0.1.6",
2053
"@microbit/microbit-universal-hex": "^0.2.2",
2154
"balance-text": "^3.3.1",
@@ -40,16 +73,12 @@
4073
"query-string": "^5.1.1",
4174
"react-contextmenu": "^2.14.0",
4275
"react-draggable": "^3.3.2",
43-
"react-intl": "^2.9.0",
4476
"react-modal": "^3.16.3",
4577
"react-popover": "^0.5.10",
46-
"react-redux": "^5.1.2",
4778
"react-responsive": "^5.0.0",
4879
"react-style-proptype": "^3.2.2",
4980
"react-tabs": "^2.3.1",
5081
"react-tooltip": "^4.5.1",
51-
"react-virtualized": "^9.22.5",
52-
"redux": "^3.7.2",
5382
"redux-throttle": "^0.1.1",
5483
"regenerator-runtime": "^0.14.1",
5584
"scratch-audio": "^2.0.36",
@@ -61,17 +90,9 @@
6190
"scratch-vm": "^5.0.75",
6291
"startaudiocontext": "^1.2.1",
6392
"to-style": "^1.3.3",
64-
"wav-encoder": "^1.3.0",
65-
"react": "^16.14.0",
66-
"react-dom": "^16.14.0"
93+
"wav-encoder": "^1.3.0"
6794
},
68-
"devDependencies": {
69-
"@turbowarp/types": "^0.0.12",
70-
"@types/bun": "^1.1.14",
71-
"@vitejs/plugin-react-swc": "^3.7.2",
72-
"esbuild": "^0.24.2",
73-
"jest": "21.2.1",
74-
"vite": "^6.0.6",
75-
"xhr": "^2.6.0"
95+
"peerDependencies": {
96+
"typescript": "^5.0.0"
7697
}
77-
}
98+
}

src/lib/define-dynamic-block.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import {ArgumentType, BlockType} from 'scratch-vm';
1111
* @param {object} categoryInfo - Information about this block's extension category, including any menus and icons.
1212
* @param {object} staticBlockInfo - The base block information before any dynamic changes.
1313
* @param {string} extendedOpcode - The opcode for the block (including the extension ID).
14+
*
15+
* @returns {{
16+
* init: Function,
17+
* mutationToDom: Function,
18+
* }}
1419
*/
1520
// TODO: grow this until it can fully replace `_convertForScratchBlocks` in the VM runtime
1621
const defineDynamicBlock = (ScratchBlocks, categoryInfo, staticBlockInfo, extendedOpcode) => ({

src/lib/save-project-to-server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import { storageStore, type ProjectSaveMeta } from './storage';
1212
* @property {?string} params.title the title of the project.
1313
* @return {Promise} A promise that resolves when the network request resolves.
1414
*/
15-
export default async function (projectId: number | string | null | undefined, vmState: string, params) {
15+
export default async function (projectId: number | string | null | undefined, vmState: string, params: {
16+
originalId?: number | string,
17+
isCopy?: boolean,
18+
isRemix?: boolean,
19+
title?: string
20+
}) {
1621
const isCreatingProject = projectId === null || typeof projectId === 'undefined';
1722
const meta: ProjectSaveMeta = {
1823
isCopy: Object.prototype.hasOwnProperty.call(params, 'isCopy'),

src/lib/storage.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,16 @@ class Storage extends ScratchStorage {
4747
constructor() {
4848
super()
4949
}
50-
translator: (m: string, v?: unknown) => string
51-
setProjectHost(host) {
52-
}
53-
setProjectToken(token) {
54-
}
55-
setAssetHost(host) {
56-
}
57-
setTranslatorFunction(fn) {
50+
translator?: (m: string, v?: unknown) => string
51+
setProjectHost(host: string) {}
52+
setProjectToken(token: string) {}
53+
setAssetHost(host: string) {
54+
}
55+
setTranslatorFunction(fn: (m: string, v?: unknown) => string) {
5856
this.translator = fn
5957
}
6058
addOfficialScratchWebStores() {}
61-
async load(type, assetId, format) {
59+
async load(type: AssetType, assetId: string, format: DataFormat) {
6260
switch(type.name) {
6361
case 'Project': {
6462
const blob = await storageStore.loadProject(assetId, this)
@@ -87,7 +85,7 @@ class Storage extends ScratchStorage {
8785
}
8886
return null
8987
}
90-
get (assetId) {
88+
get (assetId: string | number) {
9189
const got = cacheStore.get(assetId)
9290
if (got) {
9391
return got

src/react-intl.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module 'react-intl' {
2+
export const intlShape: any;
3+
export const defineMessages: any;
4+
}

src/reducers/bslash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Action } from "redux";
1+
import type { Action } from "redux";
22

33
export const CHANGE_OPTIONS_TYPE = 'bslash/CHANGE_OPTIONS'
44
export interface BslashOptions {

tsconfig.build.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"compilerOptions": {
3+
// Enable latest features
4+
"lib": ["ESNext", "DOM"],
5+
"target": "ESNext",
6+
"module": "ESNext",
7+
"moduleDetection": "force",
8+
"jsx": "react-jsx",
9+
"allowJs": true,
10+
11+
// Bundler mode
12+
"moduleResolution": "bundler",
13+
"allowImportingTsExtensions": true,
14+
"verbatimModuleSyntax": true,
15+
"emitDeclarationOnly": true,
16+
"declaration": true,
17+
"outDir": "dist/types",
18+
19+
// Best practices
20+
"strict": true,
21+
"skipLibCheck": true,
22+
"noFallthroughCasesInSwitch": true,
23+
24+
// Some stricter flags (disabled by default)
25+
"noUnusedLocals": false,
26+
"noUnusedParameters": false,
27+
"noPropertyAccessFromIndexSignature": false
28+
},
29+
"exclude": ["node_modules", "dist", "test"],
30+
"include": ["src"]
31+
}

tsconfig.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"compilerOptions": {
3+
// Enable latest features
4+
"lib": ["ESNext", "DOM"],
5+
"target": "ESNext",
6+
"module": "ESNext",
7+
"moduleDetection": "force",
8+
"jsx": "react-jsx",
9+
"allowJs": true,
10+
11+
// Bundler mode
12+
"moduleResolution": "bundler",
13+
"allowImportingTsExtensions": true,
14+
"verbatimModuleSyntax": true,
15+
"emitDeclarationOnly": true,
16+
"declaration": true,
17+
"outDir": "dist/types",
18+
19+
// Best practices
20+
"strict": true,
21+
"skipLibCheck": true,
22+
"noFallthroughCasesInSwitch": true,
23+
24+
// Some stricter flags (disabled by default)
25+
"noUnusedLocals": false,
26+
"noUnusedParameters": false,
27+
"noPropertyAccessFromIndexSignature": false
28+
},
29+
"exclude": ["node_modules", "dist", "test"]
30+
}

vite.config.ts

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig, ResolvedConfig, type Plugin } from 'vite'
1+
import { defineConfig, type ResolvedConfig, type Plugin, type UserConfig } from 'vite'
22
import { reactVirtualized } from './plugins/reactVirtualized.ts'
33
import * as path from 'node:path'
44
import react from '@vitejs/plugin-react-swc'
@@ -59,33 +59,54 @@ const scratchGuiPlugin = (): Plugin => {
5959
}
6060
}
6161

62-
export default defineConfig({
63-
plugins: [
64-
reactVirtualized(),
65-
scratchGuiPlugin(),
66-
react()
67-
],
68-
css: {
69-
modules: {
70-
localsConvention: 'camelCaseOnly'
71-
}
72-
},
73-
esbuild: {
74-
define: {
75-
global: 'globalThis',
76-
'process': `{ "env": {} }`
62+
export default defineConfig((env) => {
63+
const base: UserConfig = {
64+
plugins: [
65+
reactVirtualized(),
66+
scratchGuiPlugin(),
67+
react()
68+
],
69+
css: {
70+
modules: {
71+
localsConvention: 'camelCaseOnly'
72+
}
7773
},
78-
target: 'esnext'
79-
},
80-
build: {
81-
target: 'esnext'
82-
},
83-
optimizeDeps: {
84-
esbuildOptions: {
74+
esbuild: {
8575
define: {
8676
global: 'globalThis',
8777
'process': `{ "env": {} }`
78+
},
79+
target: 'esnext'
80+
},
81+
build: process.env.PLAYGROUND ? {
82+
target: 'esnext',
83+
} :{
84+
target: 'esnext',
85+
lib: {
86+
entry: 'src/mod.tsx',
87+
formats: ['es'],
88+
fileName(format, entryName) {
89+
return 'mod.js'
90+
},
91+
},
92+
rollupOptions: {
93+
external: [
94+
'react',
95+
'react-dom',
96+
'react-virtualized',
97+
'redux',
98+
'react-redux'
99+
],
100+
}
101+
},
102+
optimizeDeps: {
103+
esbuildOptions: {
104+
define: {
105+
global: 'globalThis',
106+
'process': `{ "env": {} }`
107+
}
88108
}
89109
}
90110
}
111+
return base
91112
})

0 commit comments

Comments
 (0)