Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
update ts config
Browse files Browse the repository at this point in the history
  • Loading branch information
HexaField committed Aug 18, 2024
1 parent 3bc1ef8 commit 5645bb8
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 26 deletions.
15 changes: 10 additions & 5 deletions packages/common/tests/regex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,28 +253,33 @@ describe('regex.test', () => {
const positiveCases = [
{
url: 'https://example.com/projects/etherealengine/default-project/assets/images/logo.png',
projectName: 'etherealengine/default-project',
orgName: 'etherealengine',
projectName: 'default-project',
assetPath: 'assets/images/logo.png'
},
{
url: 'https://example.com/static-resources/etherealengine/default-project/assets/images/logo.png',
projectName: 'etherealengine/default-project',
orgName: 'etherealengine',
projectName: 'default-project',
assetPath: 'assets/images/logo.png'
},
{
url: 'https://example.com/projects/etherealengine/default-project/assets/animations/emotes.glb',
projectName: 'etherealengine/default-project',
orgName: 'etherealengine',
projectName: 'default-project',
assetPath: 'assets/animations/emotes.glb'
},
{
url: 'https://example.com/projects/etherealengine/default-project/assets/animations/locomotion.glb',
projectName: 'etherealengine/default-project',
orgName: 'etherealengine',
projectName: 'default-project',
assetPath: 'assets/animations/locomotion.glb'
}
]
positiveCases.forEach(({ url, projectName, assetPath }) => {
positiveCases.forEach(({ url, orgName, projectName, assetPath }) => {
const match = STATIC_ASSET_REGEX.exec(url)
assert.ok(match, `Expected '${url}' to match STATIC_ASSET_REGEX`)
assert.equal(match?.[1], orgName, `Expected org name name '${orgName}' in '${url}'. Found ${match?.[1]}`)
assert.equal(match?.[2], projectName, `Expected project name '${projectName}' in '${url}'. Found ${match?.[2]}`)
assert.equal(match?.[3], assetPath, `Expected asset path '${assetPath}' in '${url}'. Found ${match?.[3]}`)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/functions/exportGLTF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import exportModelGLTF from '@etherealengine/engine/src/assets/functions/exportM
import { uploadProjectFiles } from './assetFunctions'

export default async function exportGLTF(entity: Entity, path: string) {
const [, pName, fileName] = STATIC_ASSET_REGEX.exec(path)!
return exportRelativeGLTF(entity, pName, fileName)
const [, orgname, pName, fileName] = STATIC_ASSET_REGEX.exec(path)!
return exportRelativeGLTF(entity, `${orgname}/${pName}`, fileName)
}

export async function exportRelativeGLTF(entity: Entity, projectName: string, relativePath: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export default class ImageRoutingExtension extends ExporterExtension implements
let projectSrc = getState(EditorState).projectName!
let relativeSrc = './assets/'
if (resolvedPath) {
projectSrc = resolvedPath[1]
relativeSrc = resolvedPath[2]
projectSrc = `${resolvedPath[1]}/${resolvedPath[2]}`
relativeSrc = resolvedPath[3]
relativeSrc = relativeSrc.replace(/\/[^\/]*$/, '')
}
const dst = this.writer.options.relativePath!.replace(/\/[^\/]*$/, '')
Expand All @@ -70,8 +70,8 @@ export default class ImageRoutingExtension extends ExporterExtension implements
let oldURI = texture.userData.src
if (!oldURI) {
const resolved = STATIC_ASSET_REGEX.exec(texture.image.src)!
const oldProject = resolved[1]
const relativeOldURL = resolved[2]
const oldProject = `${resolved[1]}/${resolved[2]}`
const relativeOldURL = resolved[3]
if (oldProject !== projectSrc) {
const srcWithProject = pathJoin(projectSrc, relativeSrc)
const dstWithProject = pathJoin(oldProject, relativeOldURL)
Expand Down
7 changes: 5 additions & 2 deletions packages/engine/src/assets/functions/pathResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ export function getFileName(path: string) {
}

export function getRelativeURI(path: string) {
return STATIC_ASSET_REGEX.exec(path)?.[2] ?? ''
return STATIC_ASSET_REGEX.exec(path)?.[3] ?? ''
}

export function getProjectName(path: string) {
return STATIC_ASSET_REGEX.exec(path)?.[1] ?? ''
const match = STATIC_ASSET_REGEX.exec(path)
if (!match?.length) return ''
const [, orgName, projectName] = match!
return `${orgName}/${projectName}`
}

export function modelResourcesPath(modelName: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export function updateModelVariant(
const levelIndex = variantComponent.levels.findIndex((level) => level.metadata['device'] === targetDevice)
if (levelIndex < 0) return
const deviceVariant = variantComponent.levels[levelIndex]
const modelRelativePath = STATIC_ASSET_REGEX.exec(modelComponent.src.value)?.[2]
const deviceRelativePath = deviceVariant ? STATIC_ASSET_REGEX.exec(deviceVariant.src.value)?.[2] : ''
const modelRelativePath = STATIC_ASSET_REGEX.exec(modelComponent.src.value)?.[3]
const deviceRelativePath = deviceVariant ? STATIC_ASSET_REGEX.exec(deviceVariant.src.value)?.[3] : ''
if (deviceVariant && modelRelativePath !== deviceRelativePath) {
variantComponent.currentLevel.set(levelIndex)
}
Expand Down
8 changes: 4 additions & 4 deletions packages/projects/template-project/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"**/node_modules/**"
],
"include": [
"../../../../__global.d.ts",
"../../../server-core/src/*",
"../**/*.ts",
"../**/*.tsx"
"../../../../../__global.d.ts",
"../../../../server-core/src/*",
"./**/*.ts",
"./**/*.tsx"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export async function up(knex: Knex): Promise<void> {
await knex(projectPath).where('id', project.id).update({
name: newName
})
await knex(routePath).where('projectName', project.name).update({
projectName: newName
await knex(routePath).where('project', project.name).update({
project: newName
})
await knex(staticResourcePath).where('project', project.name).update({
project: newName
Expand All @@ -61,8 +61,8 @@ export async function up(knex: Knex): Promise<void> {
await knex(projectPath).where('id', project.id).update({
name: newName
})
await knex(routePath).where('projectName', project.name).update({
projectName: newName
await knex(routePath).where('project', project.name).update({
project: newName
})
await knex(staticResourcePath).where('project', project.name).update({
project: newName
Expand Down Expand Up @@ -93,8 +93,8 @@ export async function down(knex: Knex): Promise<void> {
await knex(projectPath).where('id', project.id).update({
name: newName
})
await knex(routePath).where('projectName', oldName).update({
projectName: newName
await knex(routePath).where('project', oldName).update({
project: newName
})
await knex(staticResourcePath).where('project', oldName).update({
project: newName
Expand Down
7 changes: 6 additions & 1 deletion packages/ui/src/components/editor/properties/model/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ export const ModelNodeEditor: EditorComponentType = (props) => {
const editorState = getState(EditorState)
const projectState = getState(ProjectState)
const loadedProjects = useState(() => projectState.projects.map((project) => project.name))
const srcProject = useState(() => STATIC_ASSET_REGEX.exec(modelComponent.src.value)?.[1] ?? editorState.projectName!)
const srcProject = useState(() => {
const match = STATIC_ASSET_REGEX.exec(modelComponent.src.value)
if (!match?.length) return editorState.projectName!
const [_, orgName, projectName] = match
return `${orgName}/${projectName}`
})

const [dereferenceFeatureFlag, gltfTransformFeatureFlag] = useFeatureFlags([
FeatureFlags.Studio.Model.Dereference,
Expand Down

0 comments on commit 5645bb8

Please sign in to comment.