Skip to content

Commit

Permalink
Merge branch 'main' into Notes-100--Comment-Edit-bldrs-ai#1186
Browse files Browse the repository at this point in the history
Signed-off-by: OlegMoshkovich <oleg.mosh@gmail.com>
  • Loading branch information
OlegMoshkovich authored May 31, 2024
2 parents 3c067c5 + 5c00c85 commit 09db10b
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 16 deletions.
Binary file removed bldrs-ai-conway-0.1.510-1.tgz
Binary file not shown.
Binary file removed bldrs-ai-conway-0.1.513.tgz
Binary file not shown.
Binary file added bldrs-ai-conway-0.1.543.tgz
Binary file not shown.
24 changes: 18 additions & 6 deletions cypress/e2e/open/200/open-step-model.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,28 @@ import {
describe('Open 200: Open STEP Model', () => {
beforeEach(homepageSetup)
context('Returning user visits homepage', () => {
const interceptTag = 'stepLoad'
const stepPath = '/share/v/gh/bldrs-ai/test-models/main/step/gear.step'
const stepInterceptTag = 'stepLoad'

const stpPath = '/share/v/gh/bldrs-ai/test-models/main/step/gear.stp'
const stpInterceptTag = 'stpLoad'

beforeEach(() => {
setIsReturningUser()
const sharePathToGear = '/share/v/gh/bldrs-ai/test-models/main/step/gear.step.ifc'
setupVirtualPathIntercept(sharePathToGear, '/gear.step', interceptTag)
cy.visit(sharePathToGear)
// Use same actual file for both
setupVirtualPathIntercept(stepPath, '/gear.step', stepInterceptTag)
setupVirtualPathIntercept(stpPath, '/gear.step', stpInterceptTag)
})

it('Loads gear.step - Screen', () => {
cy.visit(stepPath)
waitForModelReady(stepInterceptTag)
cy.percySnapshot()
})

it('Loads gear.step (with .ifc hack) - Screen', () => {
waitForModelReady(interceptTag)
it('Loads gear.stp - Screen', () => {
cy.visit(stpPath)
waitForModelReady(stpInterceptTag)
cy.percySnapshot()
})
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@babel/plugin-syntax-import-assertions": "7.18.6",
"@babel/preset-env": "7.18.10",
"@babel/preset-react": "7.18.6",
"@bldrs-ai/conway": "./bldrs-ai-conway-0.1.513.tgz",
"@bldrs-ai/conway": "./bldrs-ai-conway-0.1.543.tgz",
"@bldrs-ai/ifclib": "5.3.3",
"@emotion/react": "11.10.0",
"@emotion/styled": "11.10.0",
Expand Down
3 changes: 2 additions & 1 deletion src/Containers/CadView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {MeshLambertMaterial} from 'three'
import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'
import useTheme from '@mui/styles/useTheme'
import {filetypeRegex} from '../Filetype'
import {useAuth0} from '../Auth0/Auth0Proxy'
import AboutControl from '../Components/About/AboutControl'
import {onHash} from '../Components/Camera/CameraControl'
Expand Down Expand Up @@ -673,7 +674,7 @@ export default function CadView({
// TODO(pablo): would be nice to have more consistent handling of path parsing.
useEffect(() => {
if (rootElement) {
const parts = location.pathname.split(/\.ifc/i)
const parts = location.pathname.split(filetypeRegex)
const expectedPartCount = 2
if (parts.length === expectedPartCount && parts[1] !== '') {
selectElementBasedOnFilepath(parts[1])
Expand Down
15 changes: 11 additions & 4 deletions src/Filetype.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
export const supportedTypes = ['ifc']
import {assertDefined} from './utils/assert.js'


// TODO: 3dm, glb
export const supportedTypes = ['ifc', 'stp', 'step']

export const supportedTypesUsageStr = `${supportedTypes.join(',')}`


/** Make a non-capturing group of a choice of filetypes. */
const typeRegexStr = `(?:${supportedTypes.join('|')})`
export const typeRegexStr = `(?:${supportedTypes.join('|')})`


/** */
const filetypeRegex = new RegExp(typeRegexStr, 'i')
export const filetypeRegex = new RegExp(typeRegexStr, 'i')


/** Prepend it with a '.' to make a file suffix*/
Expand Down Expand Up @@ -40,9 +46,10 @@ export function pathSuffixSupported(pathWithSuffix) {
* @return {{parts: Array.<string>, extension: string}}
*/
export function splitAroundExtension(filepath) {
assertDefined(filepath)
const match = fileSuffixRegex.exec(filepath)
if (!match) {
throw new FilenameParseError(`Filepath must contain ".${typeRegexStr}" (case-insensitive)`)
throw new FilenameParseError(`Filepath(${filepath}) must contain ".${typeRegexStr}" (case-insensitive)`)
}
const parts = filepath.split(fileSuffixRegex)
return {parts, extension: match[0]}
Expand Down
2 changes: 1 addition & 1 deletion src/Filetype.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Filetype', () => {
expect(extension).toStrictEqual(`.${ext}`)
}
expect(() => {
splitAroundExtension(`asdf.obj/blah`)
splitAroundExtension(`asdf.com/blah`)
}).toThrow(FilenameParseError)
})
})
Binary file removed web-ifc-viewer-1.0.209-bldrs-2.tgz
Binary file not shown.
Binary file removed web-ifc-viewer-1.0.209-bldrs-3.tgz
Binary file not shown.
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2078,9 +2078,9 @@
resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@bldrs-ai/conway@./bldrs-ai-conway-0.1.513.tgz":
version "0.1.513"
resolved "./bldrs-ai-conway-0.1.513.tgz#00db5bb00d99da0085c4e86cdd4f2925fb2ac592"
"@bldrs-ai/conway@./bldrs-ai-conway-0.1.543.tgz":
version "0.1.543"
resolved "./bldrs-ai-conway-0.1.543.tgz#943bd79db8c4332a0cd68e117b94520f5ce8d288"
dependencies:
buffer "^6.0.3"
gl-matrix "^3.4.3"
Expand Down

0 comments on commit 09db10b

Please sign in to comment.