Skip to content

Commit

Permalink
Merge branch 'main' into timeline
Browse files Browse the repository at this point in the history
Signed-off-by: OlegMoshkovich <oleg.mosh@gmail.com>
  • Loading branch information
OlegMoshkovich committed Oct 13, 2023
2 parents 7650e39 + 59bff6d commit 149fb78
Show file tree
Hide file tree
Showing 14 changed files with 1,031 additions and 718 deletions.
5 changes: 3 additions & 2 deletions .cosmos.webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path')


module.exports = {
target: ['web', 'es2021'],
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
devServer: {
publicPath: '/cosmos/',
Expand All @@ -19,8 +20,8 @@ module.exports = {
module: {
rules: [
{
test: /\.jsx$/,
exclude: /node_modules/,
test: /\.(js|jsx)$/,
exclude: /node_modules\/(?!bldrs-conway)/, // Exclude all of node_modules except bldrs-conway
use: {
loader: 'babel-loader',
options: {
Expand Down
53 changes: 49 additions & 4 deletions .github/workflows/end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
install-cypress-webifc:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04-4vcpu-16gb
steps:
- name: checkout
id: checkout
Expand All @@ -24,7 +24,7 @@ jobs:
uses: cypress-io/github-action@v6
with:
runTests: false
build: yarn build-share
build: yarn build-share-webifc

- name: Save build artifacts
id: build-artifacts
Expand All @@ -35,7 +35,7 @@ jobs:
path: docs/

run-cypress-on-linux-webifc:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04-4vcpu-16gb
needs: install-cypress-webifc
steps:
- name: checkout
Expand All @@ -54,4 +54,49 @@ jobs:
uses: cypress-io/github-action@v6
with:
browser: chrome
start: node config/serve.js
start: yarn serve-share-webifc

install-cypress-conway:
runs-on: ubuntu-22.04-4vcpu-16gb
needs: run-cypress-on-linux-webifc
steps:
- name: checkout
id: checkout
uses: actions/checkout@v3

- name: Install Cypress Conway
id: install-cypress-conway
uses: cypress-io/github-action@v6
with:
runTests: false
build: yarn build-share-conway

- name: Save build artifacts
id: build-artifacts
uses: actions/upload-artifact@v3
with:
name: build-conway-${{ github.sha }}
if-no-files-found: error
path: docs/

run-cypress-on-linux-conway:
runs-on: ubuntu-22.04-4vcpu-16gb
needs: install-cypress-conway
steps:
- name: checkout
id: checkout
uses: actions/checkout@v3

- name: Restore build artifacts
id: restore-artifacts
uses: actions/download-artifact@v3
with:
name: build-conway-${{ github.sha }}
path: docs/

- name: E2E Tests on Google Chrome
id: e2e-on-google-chrome
uses: cypress-io/github-action@v6
with:
browser: chrome
start: yarn serve-share-conway
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*.log
/coverage

cypress/downloads
cypress/videos
cypress/screenshots

Expand Down
Binary file added bldrs-conway-v0.0.1.tgz
Binary file not shown.
95 changes: 60 additions & 35 deletions config/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,70 @@ const entryPoint = path.resolve(__dirname, '..', 'src', 'index.jsx')
const assetsDir = path.resolve(__dirname, '..', 'public')
export const buildDir = path.resolve(__dirname, '..', 'docs')

export const build = {
entryPoints: [entryPoint],
bundle: true,
minify: process.env.MINIFY_BUILD === 'true',
// https://esbuild.github.io/api/#keep-names
// We use code identifiers e.g. in ItemProperties for their names
keepNames: true,
// Splitting
// Entry points (our src/index.jsx) are currently not named with
// cache-busting segments, like index-x84nfi.js, so we should be
// careful with our caching, i.e. not putting much index.jsx.
// See:
// https://esbuild.github.io/api/#chunk-names
// https://github.com/evanw/esbuild/issues/16
splitting: false,
metafile: true,
outdir: buildDir,
format: 'esm',
sourcemap: true,
platform: 'browser',
target: ['chrome58', 'firefox57', 'safari11', 'edge18', 'es2020'],
logLevel: 'info',
define: {
'process.env.OAUTH2_CLIENT_ID': JSON.stringify(process.env.OAUTH2_CLIENT_ID),
'process.env.OAUTH2_REDIRECT_URI': JSON.stringify(process.env.OAUTH2_REDIRECT_URI || null),
'process.env.AUTH0_DOMAIN': JSON.stringify(process.env.AUTH0_DOMAIN),
'process.env.GITHUB_API_TOKEN': JSON.stringify(process.env.GITHUB_API_TOKEN),
'process.env.GITHUB_BASE_URL': JSON.stringify(process.env.GITHUB_BASE_URL || 'https://api.github.com'),
'process.env.SENTRY_DSN': JSON.stringify(process.env.SENTRY_DSN || null),
'process.env.SENTRY_ENVIRONMENT': JSON.stringify(process.env.SENTRY_ENVIRONMENT || process.env.NODE_ENV),
'process.env.DISABLE_MOCK_SERVICE_WORKER': JSON.stringify(process.env.DISABLE_MOCK_SERVICE_WORKER),
'process.env.RAW_GIT_PROXY_URL': JSON.stringify(process.env.RAW_GIT_PROXY_URL || 'https://raw.githubusercontent.com'),
const webIfcShimAliasPlugin = {
name: 'webIfcShimAlias',
setup(build) {
build.onResolve({ filter: /^web-ifc$/ }, (args) => {
return {
path: path.resolve(__dirname, '../node_modules/bldrs-conway/compiled/src/shim/ifc_api.js'),
};
});
},
plugins: [
};

const useWebIfcShim = process.env.USE_WEBIFC_SHIM === 'true';
export const buildConfig = (useWebIfcShim) => {
const entryPoint = path.resolve(__dirname, '..', 'src', 'index.jsx');
const assetsDir = path.resolve(__dirname, '..', 'public');
const buildDir = path.resolve(__dirname, '..', 'docs');

// Initialize plugins array
const plugins = [
progress(),
svgrPlugin({plugins: ['@svgr/plugin-jsx'], dimensions: false}),
copyStaticFiles({
src: assetsDir,
dest: buildDir,
}),
],
}
];


// Conditionally include webIfcShimAliasPlugin
if (useWebIfcShim) {
console.log("Using Conway shim backend")
plugins.push(webIfcShimAliasPlugin);
} else {
console.log("Using original Web-Ifc backend")
}

// Return the build config
return {
entryPoints: [entryPoint],
bundle: true,
minify: process.env.MINIFY_BUILD === 'true',
keepNames: true,
splitting: false,
metafile: true,
outdir: buildDir,
format: 'esm',
sourcemap: true,
platform: 'browser',
target: ['chrome64', 'firefox62', 'safari11.1', 'edge79', 'es2021'],
logLevel: 'info',
define: {
'process.env.OAUTH2_CLIENT_ID': JSON.stringify(process.env.OAUTH2_CLIENT_ID),
'process.env.OAUTH2_REDIRECT_URI': JSON.stringify(process.env.OAUTH2_REDIRECT_URI || null),
'process.env.AUTH0_DOMAIN': JSON.stringify(process.env.AUTH0_DOMAIN),
'process.env.GITHUB_API_TOKEN': JSON.stringify(process.env.GITHUB_API_TOKEN),
'process.env.GITHUB_BASE_URL': JSON.stringify(process.env.GITHUB_BASE_URL || 'https://api.github.com'),
'process.env.SENTRY_DSN': JSON.stringify(process.env.SENTRY_DSN || null),
'process.env.SENTRY_ENVIRONMENT': JSON.stringify(process.env.SENTRY_ENVIRONMENT || process.env.NODE_ENV),
'process.env.DISABLE_MOCK_SERVICE_WORKER': JSON.stringify(process.env.DISABLE_MOCK_SERVICE_WORKER),
'process.env.RAW_GIT_PROXY_URL': JSON.stringify(process.env.RAW_GIT_PROXY_URL || 'https://raw.githubusercontent.com'),
'process.env.USE_WEBIFC_SHIM': JSON.stringify(useWebIfcShim),
},
plugins: plugins,
};
};

export const build = buildConfig(useWebIfcShim)
5 changes: 4 additions & 1 deletion config/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ const proxyRequestHandler = ((options, res) => http.request(options, (proxyRes)
*
* See https://esbuild.github.io/api/#customizing-server-behavior
*/
// Read the environment variable
const useWebIfcShim = process.env.USE_WEBIFC_SHIM === 'true';

esbuild.serve({
port: SERVE_PORT - 1,
servedir: common.build.outdir,
}, common.build).then((result) => {
}, common.buildConfig(useWebIfcShim)).then((result) => {
// The result tells us where esbuild's local server is
const {host, port} = result

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/ifc-model/load-sample-model.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('sample models', () => {
const REMOTE_IFC_FIXTURE = 'TestFixture.ifc'
const REQUEST_SUCCESS_CODE = 200

context('when no model is loaded', () => {
context.skip('when no model is loaded', () => {
beforeEach(() => {
cy.setCookie('isFirstTime', 'false')
cy.visit('/')
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/integration/bldrs-inside-iframe.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const path = require('path')
* framework itself loads the system under test within an iframe. This means
* that in all these tests Bldrs runs in an iframe which runs in an iframe.
*/
describe('bldrs inside iframe', () => {
describe.skip('bldrs inside iframe', () => {
const SYSTEM_UNDER_TEST = '/cypress/static/bldrs-inside-iframe.html'
const KEYCODE_ESC = 27
const REQUEST_SUCCESS_CODE = 200
Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
global.TextEncoder = global.TextEncoder || require('util').TextEncoder;
global.TextDecoder = global.TextDecoder || require('util').TextDecoder;

/**
* TODO(pablo): this is a work-around for jest not understanding es6
* modules. I don't really understand the problem, just that this
Expand Down Expand Up @@ -34,6 +37,7 @@ const esModules = [
'vfile',
'vfile-message',
'web-ifc',
'bldrs-conway',
'web-ifc-three',
'web-ifc-viewer',
'use-double-tap',
Expand Down
22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
{
"name": "bldrs",
"version": "1.0.0-r701",
"version": "1.0.0-r730",
"main": "src/index.jsx",
"license": "MIT",
"homepage": "https://github.com/bldrs-ai/Share",
"bugs": {
"url": "https://github.com/bldrs-ai/Share/issues"
},
"scripts": {
"build": "yarn clean && yarn build-share && yarn build-cosmos",
"build": "yarn clean && yarn build-share-webifc && yarn build-cosmos",
"build-conway": "yarn clean && yarn build-share-conway && yarn build-cosmos",
"build-webifc": "yarn clean && yarn build-share-webifc && yarn build-cosmos",
"build-cosmos": "shx rm -rf docs/cosmos; shx mkdir -p docs ; cosmos-export --config .cosmos.config.json && shx mv cosmos-export docs/cosmos",
"build-share": "yarn write-new-version && node config/build.js && yarn build-share-copy-web-asm",
"build-share-copy-web-asm": "shx cp node_modules/web-ifc/*.wasm docs/static/js",
"build-share": "yarn write-new-version && node config/build.js",
"build-share-conway": "USE_WEBIFC_SHIM=true yarn build-share && yarn build-share-copy-web-asm-conway",
"build-share-webifc": "USE_WEBIFC_SHIM=false yarn build-share && yarn build-share-copy-web-asm-webifc",
"build-share-copy-web-asm-webifc": "shx cp node_modules/web-ifc/*.wasm docs/static/js",
"build-share-copy-web-asm-conway": "shx cp node_modules/bldrs-conway/compiled/dependencies/conway-geom/Dist/*.wasm docs/static/js",
"clean": "shx rm -rf docs",
"deps-graph": "npx dependency-cruiser src --include-only 'jsx?' --config --output-type dot | dot -T svg > deps.svg",
"husky-init": "husky install",
"lint": "yarn eslint src && tsc",
"precommit": "yarn lint && yarn test",
"serve": "yarn serve-share",
"serve-cosmos": "cosmos --config .cosmos.config.json",
"serve-share": "yarn build-share && node config/serve.js",
"serve-share-conway": "yarn build-share-conway && USE_WEBIFC_SHIM=true node config/serve.js",
"serve-share-webifc": "yarn build-share-webifc && USE_WEBIFC_SHIM=false node config/serve.js",
"test": "jest",
"cypress:open": "cypress run",
"cypress-spec": "cypress run --spec",
Expand All @@ -42,6 +47,7 @@
"@octokit/rest": "^19.0.3",
"@sentry/react": "^7.61.0",
"@sentry/tracing": "^7.61.0",
"bldrs-conway": "./bldrs-conway-v0.0.1.tgz",
"clsx": "^1.2.1",
"cypress-react-router": "^2.0.1",
"material-ui-popup-state": "^5.0.4",
Expand Down Expand Up @@ -75,7 +81,7 @@
"@pablo-mayrgundter/cookies.js": "^1.0.0",
"@svgr/plugin-jsx": "^8.0.1",
"@svgr/webpack": "^8.0.1",
"@testing-library/cypress": "^9.0.0",
"@testing-library/cypress": "^10.0.1",
"@testing-library/dom": "^8.19.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
Expand All @@ -88,7 +94,7 @@
"babel-loader": "^8.2.5",
"canvas": "^2.11.0",
"cypress": "^13.2.0",
"cypress-real-events": "^1.7.6",
"cypress-real-events": "^1.10.3",
"esbuild": "^0.15.5",
"esbuild-clean-plugin": "^1.0.0",
"esbuild-copy-static-files": "^0.1.0",
Expand Down
2 changes: 0 additions & 2 deletions src/Containers/CadView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ import VersionsHistoryPanel from '../Components/VersionHistoryPanel'
import {usePlaceMark} from '../hooks/usePlaceMark'
import {groupElementsByTypes} from '../utils/ifc'


/**
* Experimenting with a global. Just calling #indexElement and #clear
* when new models load.
*/
export const searchIndex = new SearchIndex()
let count = 0


/**
* Only container for the for the app. Hosts the IfcViewer as well as
* nav components.
Expand Down
2 changes: 2 additions & 0 deletions src/Infrastructure/IfcViewerAPIExtended.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import debug from '../utils/debug'


const viewParameter = (new URLSearchParams(window.location.search)).get('view')?.toLowerCase() ?? 'default'


const viewRules = {
'default': [],
'ch.sia380-1.heatmap': ['Rule1', 'Rule2'],
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"target": "ES2021",
"jsx": "react-jsx",
"lib": ["es6", "dom"],
"module": "es6",
Expand Down

0 comments on commit 149fb78

Please sign in to comment.