Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .claude/settings.local.json

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't upload the settings.local.json. do you mind removing this file from the PR and adding it to the .gitignore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"permissions": {
"allow": [
"Bash(npm run:*)",
"Bash(grep -r \"MemoryRouter\\\\|initialEntries\" c:UsersezequDocumentsGitHubcreator-hubpackagescreator-hubrenderersrc --include=*.tsx --include=*.ts)",
"Bash(gh api:*)",
"WebFetch(domain:api.github.com)",
"WebFetch(domain:raw.githubusercontent.com)",
"Bash(curl -s \"https://raw.githubusercontent.com/decentraland/creator-hub/test-new-layout-home/packages/creator-hub/renderer/src/components/LearnPage/index.ts\" -o \"C:/Users/ezequ/AppData/Local/Temp/LearnPage_index.ts\")",
"Bash(curl -s \"https://raw.githubusercontent.com/decentraland/creator-hub/test-new-layout-home/packages/creator-hub/renderer/src/components/LearnPage/images/docs-icon.svg\" -o \"C:/Users/ezequ/AppData/Local/Temp/LearnPage_docs-icon.svg\")",
"Bash(curl -s \"https://raw.githubusercontent.com/decentraland/creator-hub/test-new-layout-home/packages/creator-hub/renderer/src/components/LearnPage/images/link-icon.svg\" -o \"C:/Users/ezequ/AppData/Local/Temp/LearnPage_link-icon.svg\")",
"Bash(curl -s \"https://raw.githubusercontent.com/decentraland/creator-hub/test-new-layout-home/packages/creator-hub/renderer/src/components/LearnPage/component.tsx\")",
"Bash(curl -s \"https://raw.githubusercontent.com/decentraland/creator-hub/test-new-layout-home/packages/creator-hub/renderer/src/components/LearnPage/styles.css\")",
"Bash(git ls-tree:*)",
"Bash(git checkout:*)",
"Bash(npx tsc:*)",
"Bash(find packages/creator-hub/renderer/src/components/Container -name *.tsx)",
"Bash(xargs grep:*)",
"Bash(gh pr:*)",
"Bash(npm install:*)",
"Bash(git add:*)",
"Bash(git commit:*)",
"Bash(grep -E \"\\\\.\\(ts|js\\)$\")",
"Bash(find /c/Users/ezequ/Documents/GitHub/creator-hub -type f -name *.ts -path */lib/deploy*)",
"Bash(grep -r \"api/files\\\\|/files\" /c/Users/ezequ/Documents/GitHub/creator-hub --include=*.ts --include=*.tsx)",
"Bash(find /c/Users/ezequ/Documents/GitHub/creator-hub -type f -name *.ts -path */services/* -o -name *fs* -path */services/*)",
"Bash(grep -r \"publishScene\\\\|editor.publish\" /c/Users/ezequ/Documents/GitHub/creator-hub/packages/creator-hub --include=*.ts --include=*.tsx)",
"Bash(find /c/Users/ezequ/Documents/GitHub/creator-hub -type f -name *file* -path */modules/*)",
"Bash(git log:*)",
"Bash(python3 -c \"import json; data=json.load\\(open\\(''packages/creator-hub/renderer/src/modules/store/translation/locales/en.json''\\)\\); print\\(json.dumps\\(data.get\\(''scene_list'', {}\\).get\\(''sort'', {}\\), indent=2\\)\\)\")",
"Bash(node -e \"const d=require\\(''./packages/creator-hub/renderer/src/modules/store/translation/locales/en.json''\\); console.log\\(JSON.stringify\\(d.scene_list?.sort, null, 2\\)\\)\")",
"Bash(node -e \"const d=require\\(''./packages/creator-hub/renderer/src/modules/store/translation/locales/en.json''\\); console.log\\(JSON.stringify\\(d.scene_list?.table, null, 2\\)\\)\")",
"Bash(python3 -c \":*)",
"Bash(grep ^ignore$)",
"Bash(du -sh \"/c/Users/ezequ/AppData/Roaming/creator-hub/Scenes/Versus MK/assets/\"*/)",
"Bash(du -sh \"/c/Users/ezequ/AppData/Roaming/creator-hub/Scenes/Versus MK/assets/scene/\"*/)",
"Bash(xargs stat:*)",
"Read(//c/Users/ezequ/Documents/GitHub/creator-hub/{sum+=$1} END {print \"\"\"\"\"\"\"\"Total bytes:\"\"\"\"\"\"\"\", sum, \"\"\"\"\"\"\"\"= MB:\"\"\"\"\"\"\"\", sum/1024/**)",
"Bash(find '/c/Users/ezequ/AppData/Roaming/creator-hub/Scenes/Versus MK/assets' -type f -exec wc -c {})",
"Bash(2)",
"Read(//c/Users/ezequ/Documents/GitHub/creator-hub/{sum+=$1} END {print \"\"\"\"\"\"\"\"Total bytes:\"\"\"\"\"\"\"\", sum, \"\"\"\"\"\"\"\" = MB:\"\"\"\"\"\"\"\", sum/1024/**)",
"Bash(while read:*)",
"Bash(do node:*)",
"Bash(done)",
"Read(//c/Users/ezequ/Documents/GitHub/creator-hub/{sum+=$1} END {print \"\"\"\"\"\"\"\"Total:\"\"\"\"\"\"\"\", sum, \"\"\"\"\"\"\"\"bytes =\"\"\"\"\"\"\"\", sum/1024/**)",
"Bash(node -e \":*)",
"Bash(node -e \"const path=require\\(''path''\\);const fs=require\\(''fs''\\);function s\\(d\\){let t=0;try{const e=fs.readdirSync\\(d\\);for\\(const n of e\\){const f=path.join\\(d,n\\);const st=fs.statSync\\(f\\);if\\(st.isDirectory\\(\\)\\)t+=s\\(f\\);else t+=st.size;}}catch\\(e\\){console.error\\(''err'',d,e.message\\);}return t;}const p=''C:/Users/ezequ/AppData/Roaming/creator-hub/Scenes/Versus MK/assets'';console.log\\(s\\(p\\)/1024/1024,''MB''\\);\")",
"Bash(grep -n \"contextBridge\\\\|exposeInMainWorld\" c:/Users/ezequ/Documents/GitHub/creator-hub/packages/creator-hub/preload/src/*.ts)",
"Bash(grep -rn \"contextBridge\\\\|exposeInMainWorld\" c:/Users/ezequ/Documents/GitHub/creator-hub/packages/creator-hub/preload/ --include=*.ts)",
"Bash(find c:/Users/ezequ/Documents/GitHub/creator-hub/node_modules/@dcl/sdk-commands/dist -name *.js)",
"Bash(find c:/Users/ezequ/Documents/GitHub/creator-hub -path */sdk-commands/dist* -name *.js)"
]
}
}
17 changes: 2 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions packages/creator-hub/main/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const config = {
'/shared/': join(PACKAGE_ROOT, '../shared') + '/',
},
},
ssr: {
noExternal: ['@sentry/electron'],
},
build: {
ssr: true,
sourcemap: 'inline',
Expand All @@ -28,17 +31,30 @@ const config = {
minify: process.env.MODE !== 'development',
lib: {
entry: 'src/index.ts',
formats: ['es'],
formats: ['cjs'],
},
rollupOptions: {
output: {
entryFileNames: '[name].js',
entryFileNames: '[name].cjs',
},
},
emptyOutDir: true,
reportCompressedSize: false,
},
plugins: [
{
name: 'patch-sentry-electron-normalize',
transform(code, id) {
if (id.includes('@sentry') && id.includes('normalize.js')) {
// electron.app is not yet initialized at module load time in Electron 40.
// Defer the call until getModuleFromFilename is first used.
return code.replace(
/const getModuleFromFilename = .*?createGetModuleFromFilename\(electron\.app\.getAppPath\(\)\);/,
'let _getModuleFromFilename;\nconst getModuleFromFilename = (...args) => {\n if (!_getModuleFromFilename) _getModuleFromFilename = node.createGetModuleFromFilename(electron.app.getAppPath());\n return _getModuleFromFilename(...args);\n};',
);
}
},
},
sentryVitePlugin({
org: 'decentraland',
project: 'creator-hub',
Expand Down
2 changes: 1 addition & 1 deletion packages/creator-hub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"redux-logger": "3.0.6",
"unplugin-auto-expose": "0.3.0"
},
"main": "main/dist/index.js",
"main": "main/dist/index.cjs",
"overrides": {
"ua-parser-js": "2.0.0"
},
Expand Down
105 changes: 95 additions & 10 deletions packages/creator-hub/preload/src/modules/workspace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { shell } from 'electron';
import ignore from 'ignore';
import type { Scene } from '@dcl/schemas';

import {
Expand All @@ -21,6 +22,68 @@ import { getDefaultScenesPath, getScenesPath } from './settings';
import { DEFAULT_THUMBNAIL, NEW_SCENE_NAME, EMPTY_SCENE_TEMPLATE_REPO } from './constants';
import { getProjectId } from './analytics';

// Mirrors defaultDclIgnore from @dcl/sdk-commands/dist/logic/dcl-ignore.js so that
// project.size matches the size shown during the publish flow.
const DEFAULT_ASSET_IGNORE_PATTERNS = [
'.*',
'package.json',
'package-lock.json',
'yarn-lock.json',
'build.json',
'export',
'tsconfig.json',
'tslint.json',
'node_modules',
'dclcontext',
'**/*.ts',
'**/*.tsx',
'Dockerfile',
'thumbnails',
'dist',
'README.md',
'*.blend',
'*.fbx',
'*.zip',
'*.rar',
// Extra patterns always pushed by getDCLIgnorePatterns on top of defaultDclIgnore
'node_modules/**',
'*.md',
];

async function getDirectorySize(
fs: Services['fs'],
path: Services['path'],
dirPath: string,
ignorePatterns: string[] = [],
): Promise<number> {
const ig = ignore().add(['.git', ...ignorePatterns]);

async function scan(currentDir: string, relBase: string): Promise<number> {
let total = 0;
try {
const entries = await fs.readdir(currentDir);
await Promise.all(
entries.map(async entry => {
const relPath = relBase ? `${relBase}/${entry}` : entry;
if (ig.ignores(relPath)) return;
const entryPath = path.join(currentDir, entry);
if (await fs.isDirectory(entryPath)) {
total += await scan(entryPath, relPath);
} else {
const stat = await fs.stat(entryPath);
total += stat.size;
}
}),
);
} catch {
// Directory doesn't exist or can't be read
}
return total;
}

return scan(dirPath, '');
}

export function initializeWorkspace(services: Services) {
const { config, fs, ipc, path, pkg, npm } = services;

Expand Down Expand Up @@ -111,6 +174,23 @@ export function initializeWorkspace(services: Services) {
}
}

async function getProjectSize({ path: _path }: { path: string }): Promise<number> {
const dclIgnoreContent = await fs.readFile(path.join(_path, '.dclignore')).catch(() => null);
const dclIgnorePatterns = dclIgnoreContent
? dclIgnoreContent.toString().split('\n').filter(Boolean)
: [];

// Mirror getDCLIgnorePatterns from @dcl/sdk-commands/dist/logic/dcl-ignore.js:
// always merge .dclignore content with defaultDclIgnore (SDK always pushes both).
const allPatterns = Array.from(
new Set([...dclIgnorePatterns, ...DEFAULT_ASSET_IGNORE_PATTERNS]),
);

// Scan the entire project root — not just assets/ — to include bin/game.js and
// other files the SDK packages for deployment.
return getDirectorySize(fs, path, _path, allPatterns);
}

async function getProject({
path: _path,
opts,
Expand All @@ -119,13 +199,16 @@ export function initializeWorkspace(services: Services) {
opts?: GetProjectsOpts;
}): Promise<Project> {
try {
const [id, scene, stat, dependencyAvailableUpdates, infoFs] = await Promise.all([
getProjectId(_path),
getScene(_path),
fs.stat(_path),
opts?.omitOutdatedPackages ? Promise.resolve({}) : getOutdatedPackages(_path),
getProjectInfoFs(_path),
]);
const [id, scene, stat, sceneJsonStat, dependencyAvailableUpdates, infoFs] =
await Promise.all([
getProjectId(_path),
getScene(_path),
fs.stat(_path),
fs.stat(path.join(_path, 'scene.json')).catch(() => null),
opts?.omitOutdatedPackages ? Promise.resolve({}) : getOutdatedPackages(_path),
getProjectInfoFs(_path),
]);
const assetsSize = opts?.skipSize ? 0 : await getProjectSize({ path: _path });
const thumbnail = await getProjectThumbnailAsBase64(_path, scene);
const layout = getRowsAndCols(scene.scene.parcels.map($ => parseCoords($)));
const info = await infoFs.getAll();
Expand All @@ -139,9 +222,10 @@ export function initializeWorkspace(services: Services) {
layout,
scene: scene.scene,
createdAt: Number(stat.birthtime),
updatedAt: Number(stat.mtime),
updatedAt: Number(sceneJsonStat?.mtime ?? stat.mtime),
publishedAt: 0, // TODO: possible to get publishedAt from catalyst?
size: stat.size,
size: assetsSize,
sizeStatus: opts?.skipSize ? 'pending' : 'done',
worldConfiguration: scene?.worldConfiguration,
dependencyAvailableUpdates,
info,
Expand Down Expand Up @@ -239,7 +323,7 @@ export function initializeWorkspace(services: Services) {
async function getWorkspace(): Promise<Workspace> {
const cfg = await config.getConfig();
const [[projects, missing], templates] = await Promise.all([
getProjects(cfg.workspace.paths, { omitOutdatedPackages: true }),
getProjects(cfg.workspace.paths, { omitOutdatedPackages: true, skipSize: true }),
getTemplates(),
]);

Expand Down Expand Up @@ -507,6 +591,7 @@ export function initializeWorkspace(services: Services) {
getProjectThumbnailAsBase64,
getOutdatedPackages,
getProject,
getProjectSize,
getSceneSourceFile,
getPath,
getProjects,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@
.Filters .right > span {
margin: 0 8px 0 0;
}

.Filters .right .SearchInput {
margin-left: 24px;
}
Loading
Loading